Repository navigation
Tons of additions - #4
Conversation
…a products request
GetCategories and getCategoriesAsTree
Add options for getProducts
Change type of customFieldId to String
… additions * 'additions' of github.com:brachetti/bigcommerce-sdk: Create response for custom field creation Change customFieldId to int Replace product with product id Add create product custom field id method Change type of customFieldId to String
Fix CustomFieldResponse
Additional metadata for categories
Additional metadata for categories
sortOrder, metaKeywords, searchKeywords and customURL
additions
|
@brachetti thanks for taking the time to open up this pull request. Our developers are a bit swamped at the moment so we will need about 2 weeks to review your code and ensure it plays well with our integrations. One of our developers will review the request and offer feedback soon. |
ryankazokas
left a comment
There was a problem hiding this comment.
Great additions to the SDK!
Here are some changes you'd have to make for functional purposes, as well as to meet code standards that we have.
One thing we are adding that we forgot to mention here is that we use gitflow. This means PR's for new features should be opened for merging within develop, while hotfixes go directly to master. We will be adding this to the contribution.md doc to avoid confusion in the future, but in the meantime if you aren't familar with gitflow, check out this article:
https://www.atlassian.com/git/tutorials/comparing-workflows/gitflow-workflow
| .queryParam(PAGE, page); | ||
|
|
||
| if (parentId != null) { | ||
| webTarget = webTarget.queryParam(PARENT_ID, parentId); |
There was a problem hiding this comment.
Nothing to fix here for now, but if we add more filters to this filter we may want to consider making this more scalable such as adding a parameter list that we can build.
| private static final String IMAGES = "images"; | ||
| private static final int MAX_LIMIT = 250; | ||
| private static final String PARENT_ID = "parent_id"; | ||
| public static final int MAX_LIMIT = 250; |
There was a problem hiding this comment.
This field doesn't need to be public.
There was a problem hiding this comment.
I see where you are coming from, but when we used the library we put pagination outside and wanted to rely on a number that is more tightly bound to bigcommerce than our application.
There was a problem hiding this comment.
I'm not sure I understand. Can you please describe your use case on code outside of this file needing to know the max limit? If calling code is concerned about the default max size, can't they just use the public methods that allow them to specify the limit?
There was a problem hiding this comment.
I can try. We had in our project something like
public List<Category> getAllCategories(BigcommerceSdk client, Integer parentId) {
return paginate(
(page) -> client.getCategories(parentId, page, BigcommerceSdk.MAX_LIMIT),
START_PAGE
);
}where paginate() was a function that then used the information from the response to, well ... paginate :-)
We felt, that our application should not decide what's the paging limit.
There was a problem hiding this comment.
I see what you mean @brachetti . All i was getting at was to let the sdk do the magic, so your app doesn't need that parameter at all. From the above, it doesn't look like it really needs it.
We do similar things in our apps that use the sdk. See the getProducts method in the sdk. This hides the constant so the calling function just has to pass the page.
public Products getProducts(final int page, String... includes) {
return getProducts(page, MAX_LIMIT, includes);
}
So using the public method without the limit should work:
public Categories getCategories(final int page) {
return getCategories(page, MAX_LIMIT);
}
If you did this, your app wouldn't need to know the max limit and we'd be able to keep it private.
There was a problem hiding this comment.
I see what you are trying to do nod
What do you think about including pagination in the SDK itself, so you rather end up with a getAllProducts() method? I feel this would improve usability a lot
There was a problem hiding this comment.
Yeah, I agree. That's a great idea. That'd be a nice abstraction from having to deal with the pagination at all.
I'd just suggest if this is something you wanted to work on, please open up a GitHub enhancement and submit a new PR for the issue. Thanks!
Here is the contributing.md we are working on. It includes the part about suggesting a new enhancement:
https://github.com/ChannelApe/bigcommerce-sdk/blob/feature/Contribution_Doc/CONTRIBUTING.md#suggesting-a-new-feature
There was a problem hiding this comment.
It's in #5 , I'll base the new branch off this one, since I need the PaginatedModel<T> interface
| import javax.ws.rs.core.Response; | ||
| import javax.ws.rs.core.Response.Status; | ||
|
|
||
| import com.bigcommerce.catalog.models.*; |
There was a problem hiding this comment.
Please refrain from using wildcard imports and import the specific classes you need. It may need all of the classes from that package now, but as we add more models/packages this may change.
See. 3.3.1 of our style guide:
https://channelape.github.io/styleguide/java/javaguide.html
| @XmlAccessorType(XmlAccessType.FIELD) | ||
| @JsonInclude(Include.NON_NULL) | ||
| public class Brand { | ||
| public class Brand implements Serializable { |
There was a problem hiding this comment.
The serializable class Brand does not declare a static final serialVersionUID field of type long
Please add a generated serialVersionUID
| @JsonInclude(NON_NULL) | ||
| public class CustomUrl implements Serializable { | ||
|
|
||
| @XmlElement(name = "url") |
There was a problem hiding this comment.
No need for the annotation here. The marshaler will automatically match fields by name. The only time we use this is when the field in JSON is snake case while we like to keep our fields camelcase.
| import javax.xml.bind.annotation.XmlRootElement; | ||
|
|
||
| import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | ||
| import org.apache.commons.lang3.builder.EqualsBuilder; |
There was a problem hiding this comment.
Please remove this import if you find a way to not use it.
| import javax.xml.bind.JAXBException; | ||
| import javax.xml.bind.Marshaller; | ||
|
|
||
| import com.bigcommerce.catalog.models.*; |
There was a problem hiding this comment.
Please remove your wildcard import
https://channelape.github.io/styleguide/java/javaguide.html#s3.3.1-wildcard-imports
|
|
||
| @XmlAccessorType(XmlAccessType.FIELD) | ||
| @JsonInclude(NON_NULL) | ||
| public class CustomUrl implements Serializable { |
There was a problem hiding this comment.
Please add the generated serialVersionUID here.
| import javax.xml.bind.annotation.XmlRootElement; | ||
| import javax.xml.bind.annotation.XmlTransient; | ||
| import java.util.LinkedList; | ||
| import java.util.List; |
There was a problem hiding this comment.
Please remove these unused imports.
| assertEquals(expectedBrands.get(0).getSearchKeywords(), actualBrands.getBrands().get(0).getSearchKeywords()); | ||
| assertEquals(expectedBrands.get(0).getMetaDescription(), actualBrands.getBrands().get(0).getMetaDescription()); | ||
| assertEquals(expectedBrands.get(0).getMetaKeywords(), actualBrands.getBrands().get(0).getMetaKeywords()); | ||
| assertEquals(expectedBrands.get(0).getCustomUrl().getUrl(), actualBrands.getBrands().get(0).getCustomUrl().getUrl()); |
There was a problem hiding this comment.
It's good that you added coverage on the fields you added for brands. Can you also add some code coverage for the new public sdk methods.
- getCategoriesAsTree
- getCategories
- updateCategory
- createCategory
- createProductCustomField
- deleteProductCustomField
|
@ryankazokas should I change the PR to go into |
|
Yes @brachetti , please switch this PR to go into develop. Thanks! |
|
Hey @brachetti thanks so much for this PR. If you can change the merge branch from |
rjdavis3
left a comment
There was a problem hiding this comment.
Please change merge branch from master to develop. All other code review feedback can be implemented by @ryankazokas on develop.
We will then add all your changes into our next minor release.
Hey there,
This is an introduction of several new endpoints present in the v3 API.
Also some small additions on concepts:
More changed incoming :-)