Repository navigation
ECO-600: Ecommerce Objects - #22
Conversation
[Medium risk] The change moves no dependency version, so no reach applies. It is additive public API under ml.ecommerce() and new ecommerceReport() methods, and a revert removes it, which puts the risk at medium rather than higher. The existing EcommerceShop, EcommerceCategory and EcommerceProduct classes gain date-parsing fields, which the review did not show were checked against ApiResource's parsing of missing or differently formatted dates, though the diff shows no defect there. FindingsEarlier findings (4 dismissed)
SummaryAdds e-commerce resources and revenue reports to the Java SDK The change adds Flow%%{init: {'theme': 'neutral'}}%%
flowchart LR
A["Caller uses ml.ecommerce()"] --> B["Pick resource: shops, products, orders, carts, etc."]
B --> C["Retriever or builder creates request"]
C --> D["EcommerceApi sends request with URL-encoded query; null values dropped"]
D --> E["MailerLite e-commerce API"]
F["ecommerceReport() on campaigns, subscribers, automations, shops"] --> G["EcommerceReportRetriever"]
G -->|"stats() or orders()"| D
What's good
Review context · 0/5 commands
Reviews (6) · Last reviewed commit: "ECO-600: Drop e-commerce query parameter..." · claude-sonnet-5-5 |
|
@segunmailerlite fix the conflicts please |
Keep both the ecommerce report methods and main's new automation and subscriber endpoints. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Restore README whitespace so the diff holds only the e-commerce docs, and add Javadoc to the ecommerce report methods. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
johnkelesidis
left a comment
There was a problem hiding this comment.
Thanks for this! I reviewed the request side against the API source: paths, field names and import shapes (root arrays for products, categories and customers; {"orders": [...]} for orders) all match, and the full suite passes (120 tests, 0 failures).
The main blocker is the conversion_rate type in EcommerceStats, which makes both stats() calls throw on every real response. The tests don't catch it because every stubbed body is {}. The other comments are lower-severity bugs, duplication with existing models, and test gaps. Details inline.
| */ | ||
| public abstract class EcommerceRequest<T extends EcommerceRequest<T>> extends PaginatedRequest<T> { | ||
|
|
||
| private Map<String, String> queryParameters = new LinkedHashMap<String, String>(); |
There was a problem hiding this comment.
Bug: removeQueryParameter() does nothing on e-commerce retrievers. This class keeps its own queryParameters map and overrides add/get, but not ApiRequest.removeQueryParameter. So retriever().limit(10) followed by removeQueryParameter("limit") still sends ?limit=10.
More broadly, this forks query-string building (insertion order, key encoding, no bare ?) away from ApiRequest, which every other retriever still uses. Fixing ApiRequest.getQueryParameters() once (LinkedHashMap, encode keys, return "" when empty) would fix all callers and remove the need for this subclass.
There was a problem hiding this comment.
Fixed: EcommerceRequest now overrides removeQueryParameter, with a test.
I tried the broader fix in ApiRequest.getQueryParameters() (LinkedHashMap, encoded keys, no bare ?), but it broke 33 existing tests. The VCR fixtures are keyed on the exact request URL, so the trailing ? and the param order change every cassette hash, and we can’t re-record them without a live account. I’d rather keep the fork in EcommerceRequest for now and move it into ApiRequest in a separate PR when the fixtures can be re-recorded.
| return EcommerceApi.create(apiObjectReference).postRequest(EcommerceApi.shopPath(shopId, "/orders"), EcommerceApi.json(builderBody), SingleOrder.class); | ||
| } | ||
|
|
||
| public SingleOrder update(String orderId) throws MailerLiteException |
There was a problem hiding this comment.
Bug: update with the builder's usual setters returns 422. create() and update() send the same body, but EcommerceUpdateOrderRequest marks customer and cart as prohibited. So builder().customer(c).item(i).status("complete").update("9") fails. CartBuilder.update() has the same problem with items (EcommerceUpdateCartRequest). Either strip those fields on update or document that update only accepts a subset.
There was a problem hiding this comment.
Fixed: order update() now strips customer and cart, and cart update() strips items, so the body matches the update request rules. I added tests for both that set those fields and check they aren’t sent.
| public Boolean enableResubscribe; | ||
|
|
||
| @SerializedName("group") | ||
| public Group group; |
There was a problem hiding this comment.
Bug (minor): group dates are never parsed. parseDates() / postDeserialize() is never called on this nested Group, so shop.group.createdAt is always null.
There was a problem hiding this comment.
Fixed: EcommerceShop now extends ApiResource and overrides parseDates() to also parse group. SingleShop and ShopsList call it from postDeserialize(). The new test checks that shops[0].group.createdAt gets parsed.
| @SerializedName("stage") | ||
| public String stage; | ||
|
|
||
| @SerializedName("created_at") |
There was a problem hiding this comment.
Dates (created_at, updated_at, completed_at) are raw Strings here and across the new models. The rest of the SDK uses xxxStr + @ParseDate Date (via ApiResource/postDeserialize), as in Group, Automation and OrderActivity. Worth matching that so callers get java.util.Date consistently.
There was a problem hiding this comment.
Done: shop, category, product and order dates now use xxxStr + @ParseDate Date. The single and list responses call parseDates() from postDeserialize(), and nested objects get parsed too (shop group, product categories, the order’s customer and cart items). There’s a test that checks the order, product and category dates come back non-null.
| return api; | ||
| } | ||
|
|
||
| static String json(Object body) |
There was a problem hiding this comment.
This builds a new GsonBuilder/Gson with the same exclusion strategies on every request, duplicating JsonBody.toJson / SdkGson.plain(). Suggest return JsonBody.toJson(body);.
There was a problem hiding this comment.
Done: EcommerceApi.json() now returns JsonBody.toJson(body). The new jsonWithout() helper for the update bodies uses SdkGson.plain() too.
johnkelesidis
left a comment
There was a problem hiding this comment.
please check comments
|
@segunmailerlite can you check the conflicts on this please? |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Matches the ApiRequest change from main, where a null value removes the parameter instead of failing in URLEncoder. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Why?
Changes
ml.ecommerce()with shops, products, variants, categories, customers, orders, carts, cart items, imports and settings, using the SDK's retriever/builder pattern.ecommerceReport()on campaigns, subscribers, automations and shops for revenue stats and attributed orders.