Repository navigation
ECO-600: Ecommerce Objects #22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
segunmailerlite
wants to merge
2
commits into
main
Choose a base branch
from
feature/eco-600-java-sdk
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
src/main/java/com/mailerlite/sdk/ecommerce/CartBuilder.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| /************************************************* | ||
| * MailerLite Java SDK | ||
| * https://github.com/mailerlite/mailerlite-java | ||
| * | ||
| * @author MailerLite <support@mailerlite.com> | ||
| * https://mailerlite.com | ||
| **************************************************/ | ||
| package com.mailerlite.sdk.ecommerce; | ||
|
|
||
| import com.mailerlite.sdk.MailerLite; | ||
| import com.mailerlite.sdk.exceptions.MailerLiteException; | ||
|
|
||
| /** | ||
| * The Class CartBuilder. | ||
| */ | ||
| public class CartBuilder { | ||
|
|
||
| private MailerLite apiObjectReference; | ||
|
|
||
| private String shopId; | ||
|
|
||
| private CartBuilderBody builderBody = new CartBuilderBody(); | ||
|
|
||
| public CartBuilder(MailerLite apiRef, String shopId) | ||
| { | ||
| apiObjectReference = apiRef; | ||
| this.shopId = shopId; | ||
| } | ||
|
|
||
| public CartBuilderBody body() | ||
| { | ||
| return builderBody; | ||
| } | ||
|
|
||
| public CartBuilder checkoutUrl(String checkoutUrl) | ||
| { | ||
| builderBody.checkoutUrl = checkoutUrl; | ||
| return this; | ||
| } | ||
|
|
||
| public CartBuilder cartTotal(Double cartTotal) | ||
| { | ||
| builderBody.cartTotal = cartTotal; | ||
| return this; | ||
| } | ||
|
|
||
| public CartBuilder customerId(String customerId) | ||
| { | ||
| builderBody.customerId = customerId; | ||
| return this; | ||
| } | ||
|
|
||
| public CartBuilder resourceId(String resourceId) | ||
| { | ||
| builderBody.resourceId = resourceId; | ||
| return this; | ||
| } | ||
|
|
||
| public SingleCart update(String cartId) throws MailerLiteException | ||
| { | ||
| return EcommerceApi.create(apiObjectReference).putRequest(EcommerceApi.shopPath(shopId, "/carts/").concat(cartId), EcommerceApi.json(builderBody), SingleCart.class); | ||
| } | ||
| } |
32 changes: 32 additions & 0 deletions
32
src/main/java/com/mailerlite/sdk/ecommerce/CartBuilderBody.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| /************************************************* | ||
| * MailerLite Java SDK | ||
| * https://github.com/mailerlite/mailerlite-java | ||
| * | ||
| * @author MailerLite <support@mailerlite.com> | ||
| * https://mailerlite.com | ||
| **************************************************/ | ||
| package com.mailerlite.sdk.ecommerce; | ||
|
|
||
| import com.google.gson.annotations.SerializedName; | ||
| import java.util.ArrayList; | ||
|
|
||
| /** | ||
| * The Class CartBuilderBody. | ||
| */ | ||
| public class CartBuilderBody { | ||
|
|
||
| @SerializedName("checkout_url") | ||
| public String checkoutUrl; | ||
|
|
||
| @SerializedName("cart_total") | ||
| public Double cartTotal; | ||
|
|
||
| @SerializedName("ecommerce_customer_id") | ||
| public String customerId; | ||
|
|
||
| @SerializedName("resource_id") | ||
| public String resourceId; | ||
|
|
||
| @SerializedName("items") | ||
| public ArrayList<CartItemBuilderBody> items; | ||
| } |
89 changes: 89 additions & 0 deletions
89
src/main/java/com/mailerlite/sdk/ecommerce/CartItemBuilder.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| /************************************************* | ||
| * MailerLite Java SDK | ||
| * https://github.com/mailerlite/mailerlite-java | ||
| * | ||
| * @author MailerLite <support@mailerlite.com> | ||
| * https://mailerlite.com | ||
| **************************************************/ | ||
| package com.mailerlite.sdk.ecommerce; | ||
|
|
||
| import com.mailerlite.sdk.MailerLite; | ||
| import com.mailerlite.sdk.exceptions.MailerLiteException; | ||
|
|
||
| /** | ||
| * The Class CartItemBuilder. | ||
| */ | ||
| public class CartItemBuilder { | ||
|
|
||
| private MailerLite apiObjectReference; | ||
|
|
||
| private String shopId; | ||
|
|
||
| private String cartId; | ||
|
|
||
| private CartItemBuilderBody builderBody = new CartItemBuilderBody(); | ||
|
|
||
| public CartItemBuilder(MailerLite apiRef, String shopId, String cartId) | ||
| { | ||
| apiObjectReference = apiRef; | ||
| this.shopId = shopId; | ||
| this.cartId = cartId; | ||
| } | ||
|
|
||
| public CartItemBuilderBody body() | ||
| { | ||
| return builderBody; | ||
| } | ||
|
|
||
| public CartItemBuilder productId(String productId) | ||
| { | ||
| builderBody.productId = productId; | ||
| return this; | ||
| } | ||
|
|
||
| public CartItemBuilder productResourceId(String productResourceId) | ||
| { | ||
| builderBody.productResourceId = productResourceId; | ||
| return this; | ||
| } | ||
|
|
||
| public CartItemBuilder productVariantId(String productVariantId) | ||
| { | ||
| builderBody.productVariantId = productVariantId; | ||
| return this; | ||
| } | ||
|
|
||
| public CartItemBuilder variant(String variant) | ||
| { | ||
| builderBody.variant = variant; | ||
| return this; | ||
| } | ||
|
|
||
| public CartItemBuilder quantity(Integer quantity) | ||
| { | ||
| builderBody.quantity = quantity; | ||
| return this; | ||
| } | ||
|
|
||
| public CartItemBuilder price(Double price) | ||
| { | ||
| builderBody.price = price; | ||
| return this; | ||
| } | ||
|
|
||
| public CartItemBuilder resourceId(String resourceId) | ||
| { | ||
| builderBody.resourceId = resourceId; | ||
| return this; | ||
| } | ||
|
|
||
| public SingleCartItem create() throws MailerLiteException | ||
| { | ||
| return EcommerceApi.create(apiObjectReference).postRequest(EcommerceApi.shopPath(shopId, "/carts/").concat(cartId).concat("/items"), EcommerceApi.json(builderBody), SingleCartItem.class); | ||
| } | ||
|
|
||
| public SingleCartItem update(String itemId) throws MailerLiteException | ||
| { | ||
| return EcommerceApi.create(apiObjectReference).putRequest(EcommerceApi.shopPath(shopId, "/carts/").concat(cartId).concat("/items").concat("/").concat(itemId), EcommerceApi.json(builderBody), SingleCartItem.class); | ||
| } | ||
| } |
37 changes: 37 additions & 0 deletions
37
src/main/java/com/mailerlite/sdk/ecommerce/CartItemBuilderBody.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| /************************************************* | ||
| * MailerLite Java SDK | ||
| * https://github.com/mailerlite/mailerlite-java | ||
| * | ||
| * @author MailerLite <support@mailerlite.com> | ||
| * https://mailerlite.com | ||
| **************************************************/ | ||
| package com.mailerlite.sdk.ecommerce; | ||
|
|
||
| import com.google.gson.annotations.SerializedName; | ||
|
|
||
| /** | ||
| * The Class CartItemBuilderBody. | ||
| */ | ||
| public class CartItemBuilderBody { | ||
|
|
||
| @SerializedName("ecommerce_product_id") | ||
| public String productId; | ||
|
|
||
| @SerializedName("product_resource_id") | ||
| public String productResourceId; | ||
|
|
||
| @SerializedName("ecommerce_product_variant_id") | ||
| public String productVariantId; | ||
|
|
||
| @SerializedName("variant") | ||
| public String variant; | ||
|
|
||
| @SerializedName("quantity") | ||
| public Integer quantity; | ||
|
|
||
| @SerializedName("price") | ||
| public Double price; | ||
|
|
||
| @SerializedName("resource_id") | ||
| public String resourceId; | ||
| } |
45 changes: 45 additions & 0 deletions
45
src/main/java/com/mailerlite/sdk/ecommerce/CartItemRetriever.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| /************************************************* | ||
| * MailerLite Java SDK | ||
| * https://github.com/mailerlite/mailerlite-java | ||
| * | ||
| * @author MailerLite <support@mailerlite.com> | ||
| * https://mailerlite.com | ||
| **************************************************/ | ||
| package com.mailerlite.sdk.ecommerce; | ||
|
|
||
| import com.mailerlite.sdk.MailerLite; | ||
| import com.mailerlite.sdk.exceptions.MailerLiteException; | ||
|
|
||
| /** | ||
| * The Class CartItemRetriever. | ||
| */ | ||
| public class CartItemRetriever extends EcommerceRequest<CartItemRetriever> { | ||
|
|
||
| private MailerLite apiObjectReference; | ||
|
|
||
| private String shopId; | ||
| private String cartId; | ||
|
|
||
| public CartItemRetriever(MailerLite apiRef, String shopId, String cartId) | ||
| { | ||
| apiObjectReference = apiRef; | ||
| this.shopId = shopId; | ||
| this.cartId = cartId; | ||
| } | ||
|
|
||
|
|
||
| public CartItemsList get() throws MailerLiteException | ||
| { | ||
| return EcommerceApi.create(apiObjectReference).getRequest(EcommerceApi.shopPath(shopId, "/carts/").concat(cartId).concat("/items").concat(this.getQueryParameters()), CartItemsList.class); | ||
| } | ||
|
|
||
| public SingleCartItem getSingle(String itemId) throws MailerLiteException | ||
| { | ||
| return EcommerceApi.create(apiObjectReference).getRequest(EcommerceApi.shopPath(shopId, "/carts/").concat(cartId).concat("/items").concat("/").concat(itemId), SingleCartItem.class); | ||
| } | ||
|
|
||
| @Override | ||
| protected CartItemRetriever getInstance() { | ||
| return this; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| /************************************************* | ||
| * MailerLite Java SDK | ||
| * https://github.com/mailerlite/mailerlite-java | ||
| * | ||
| * @author MailerLite <support@mailerlite.com> | ||
| * https://mailerlite.com | ||
| **************************************************/ | ||
| package com.mailerlite.sdk.ecommerce; | ||
|
|
||
| import com.mailerlite.sdk.MailerLite; | ||
| import com.mailerlite.sdk.MailerLiteResponse; | ||
| import com.mailerlite.sdk.exceptions.MailerLiteException; | ||
|
|
||
| /** | ||
| * The Class CartItems. | ||
| */ | ||
| public class CartItems { | ||
|
|
||
| private MailerLite apiObjectReference; | ||
|
|
||
| private String shopId; | ||
|
|
||
| private String cartId; | ||
|
|
||
| public CartItems(MailerLite apiRef, String shopId, String cartId) | ||
| { | ||
| apiObjectReference = apiRef; | ||
| this.shopId = shopId; | ||
| this.cartId = cartId; | ||
| } | ||
|
|
||
| public CartItemRetriever retriever() | ||
| { | ||
| return new CartItemRetriever(apiObjectReference, shopId, cartId); | ||
| } | ||
|
|
||
| public CartItemBuilder builder() | ||
| { | ||
| return new CartItemBuilder(apiObjectReference, shopId, cartId); | ||
| } | ||
|
|
||
| public MailerLiteResponse delete(String itemId) throws MailerLiteException | ||
| { | ||
| String endpoint = EcommerceApi.shopPath(shopId, "/carts/").concat(cartId).concat("/items/").concat(itemId); | ||
| return EcommerceApi.create(apiObjectReference).deleteRequest(endpoint, MailerLiteResponse.class); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.