Skip to content

Commit 89d73ef

Browse files
committed
build(codegen): updating SDK
1 parent 6746ea2 commit 89d73ef

19 files changed

+1642
-0
lines changed

changes.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,22 @@
33
<details>
44
<summary>Added Type(s)</summary>
55

6+
- added type `CartMergeMode`
7+
- added type `MergeCartDraft`
68
- added type `DiscountCombinationMode`
79
- added type `DiscountsConfiguration`
810
- added type `ProjectSetDiscountsConfigurationAction`
911
</details>
1012

1113

14+
<details>
15+
<summary>Added Method(s)</summary>
16+
17+
- added method `apiRoot.withProjectKey().carts().customerIdWithCustomerIdValueMerge().post()`
18+
- added method `apiRoot.withProjectKey().inStoreKeyWithStoreKeyValue().carts().customerIdWithCustomerIdValueMerge().post()`
19+
</details>
20+
21+
1222
<details>
1323
<summary>Removed Property(s)</summary>
1424

@@ -23,3 +33,11 @@
2333
- added property `skipConfigurationInputDraft` to type `RecurringOrderSetOrderSkipConfigurationAction`
2434
</details>
2535

36+
37+
<details>
38+
<summary>Added Resource(s)</summary>
39+
40+
- added resource `/{projectKey}/carts/customer-id={customerId}/merge`
41+
- added resource `/{projectKey}/in-store/key={storeKey}/carts/customer-id={customerId}/merge`
42+
</details>
43+

commercetools/commercetools-graphql-api/src/main/resources/graphql/schema.graphqls

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2057,6 +2057,22 @@ type CartLimitsProjection {
20572057
total: CartLimitWithCurrent!
20582058
}
20592059

2060+
enum CartMergeMode {
2061+
"""
2062+
`LineItem`s of the anonymous cart will be copied to the customer’s active cart that has been modified most recently.
2063+
2064+
The `CartState` of the anonymous cart gets changed to `Merged` while the `CartState` of the customer’s cart remains `Active`.
2065+
2066+
`CustomLineItems` and `CustomFields` of the anonymous cart will not be copied to the customers cart.
2067+
2068+
If a `LineItem` in the anonymous cart matches an existing line item in the customer’s cart (same product ID and variant ID), the maximum quantity of both LineItems is used as the new quantity. In that case `CustomFields` on the `LineItem` of the anonymous cart will not be in the resulting `LineItem`.
2069+
"""
2070+
MergeWithExistingCustomerCart
2071+
2072+
"The anonymous cart is used as new active customer cart. No `LineItem`s get merged."
2073+
UseAsNewActiveCustomerCart
2074+
}
2075+
20602076
enum CartOrigin {
20612077
"The cart was created by the customer. This is the default value"
20622078
Customer
@@ -5825,6 +5841,13 @@ interface MeQueryInterface implements CartQueryInterface & ActiveCartInterface &
58255841
shoppingLists(where: String, sort: [String!], limit: Int, offset: Int): ShoppingListQueryResult!
58265842
}
58275843

5844+
input MergeCartDraft {
5845+
anonymousCart: ResourceIdentifierInput
5846+
mergeMode: CartMergeMode = MergeWithExistingCustomerCart
5847+
anonymousId: String
5848+
updateProductData: Boolean = false
5849+
}
5850+
58285851
type Message implements Versioned & ReferenceExpandable {
58295852
id: String!
58305853
type: String!
@@ -6442,6 +6465,11 @@ type Mutation {
64426465
"Create/modify entity as an associate in business-unit."
64436466
asAssociate: AsAssociateArgument): Cart
64446467

6468+
mergeCart(customerId: String!, draft: MergeCartDraft!,
6469+
6470+
"The mutation is only performed if the resource is part of the store. Can be used with store-specific OAuth permissions."
6471+
storeKey: KeyReferenceInput): Cart
6472+
64456473
"BETA: This feature can be subject to change and should be used carefully in production. https://docs.commercetools.com/api/contract#public-beta"
64466474
createMyCart(draft: MyCartDraft!,
64476475

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
2+
package com.commercetools.api.client;
3+
4+
import java.net.URI;
5+
import java.time.Duration;
6+
import java.util.ArrayList;
7+
import java.util.List;
8+
import java.util.concurrent.CompletableFuture;
9+
10+
import com.fasterxml.jackson.core.type.TypeReference;
11+
12+
import io.vrap.rmf.base.client.*;
13+
import io.vrap.rmf.base.client.utils.Generated;
14+
15+
import org.apache.commons.lang3.builder.EqualsBuilder;
16+
import org.apache.commons.lang3.builder.HashCodeBuilder;
17+
18+
/**
19+
* <p>Merges items from an anonymous Cart into the most recently modified active Cart of a Customer. If no active Cart exists, a <a href="https://docs.commercetools.com/apis/ctp:api:type:ResourceNotFoundError" rel="nofollow">ResourceNotFound</a> error is returned.</p>
20+
* <p>For more information, see <span>Merge behavior</span>.</p>
21+
*
22+
* <hr>
23+
* <div class=code-example>
24+
* <pre><code class='java'>{@code
25+
* CompletableFuture<ApiHttpResponse<com.commercetools.api.models.cart.Cart>> result = apiRoot
26+
* .withProjectKey("{projectKey}")
27+
* .carts()
28+
* .customerIdWithCustomerIdValueMerge("{customerId}")
29+
* .post(null)
30+
* .execute()
31+
* }</code></pre>
32+
* </div>
33+
*/
34+
@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen")
35+
public class ByProjectKeyCartsCustomerIdByCustomerIdMergePost extends
36+
TypeBodyApiMethod<ByProjectKeyCartsCustomerIdByCustomerIdMergePost, com.commercetools.api.models.cart.Cart, com.commercetools.api.models.cart.MergeCartDraft>
37+
implements com.commercetools.api.client.ErrorableTrait<ByProjectKeyCartsCustomerIdByCustomerIdMergePost> {
38+
39+
@Override
40+
public TypeReference<com.commercetools.api.models.cart.Cart> resultType() {
41+
return new TypeReference<com.commercetools.api.models.cart.Cart>() {
42+
};
43+
}
44+
45+
private String projectKey;
46+
private String customerId;
47+
48+
private com.commercetools.api.models.cart.MergeCartDraft mergeCartDraft;
49+
50+
public ByProjectKeyCartsCustomerIdByCustomerIdMergePost(final ApiHttpClient apiHttpClient, String projectKey,
51+
String customerId, com.commercetools.api.models.cart.MergeCartDraft mergeCartDraft) {
52+
super(apiHttpClient);
53+
this.projectKey = projectKey;
54+
this.customerId = customerId;
55+
this.mergeCartDraft = mergeCartDraft;
56+
}
57+
58+
public ByProjectKeyCartsCustomerIdByCustomerIdMergePost(ByProjectKeyCartsCustomerIdByCustomerIdMergePost t) {
59+
super(t);
60+
this.projectKey = t.projectKey;
61+
this.customerId = t.customerId;
62+
this.mergeCartDraft = t.mergeCartDraft;
63+
}
64+
65+
@Override
66+
protected ApiHttpRequest buildHttpRequest() {
67+
List<String> params = new ArrayList<>(getQueryParamUriStrings());
68+
String httpRequestPath = String.format("%s/carts/customer-id=%s/merge", encodePathParam(this.projectKey),
69+
encodePathParam(this.customerId));
70+
if (!params.isEmpty()) {
71+
httpRequestPath += "?" + String.join("&", params);
72+
}
73+
return new ApiHttpRequest(ApiHttpMethod.POST, URI.create(httpRequestPath), getHeaders(),
74+
io.vrap.rmf.base.client.utils.json.JsonUtils
75+
.executing(() -> apiHttpClient().getSerializerService().toJsonByteArray(mergeCartDraft)));
76+
77+
}
78+
79+
@Override
80+
public ApiHttpResponse<com.commercetools.api.models.cart.Cart> executeBlocking(final ApiHttpClient client,
81+
final Duration timeout) {
82+
return executeBlocking(client, timeout, com.commercetools.api.models.cart.Cart.class);
83+
}
84+
85+
@Override
86+
public CompletableFuture<ApiHttpResponse<com.commercetools.api.models.cart.Cart>> execute(
87+
final ApiHttpClient client) {
88+
return execute(client, com.commercetools.api.models.cart.Cart.class);
89+
}
90+
91+
public String getProjectKey() {
92+
return this.projectKey;
93+
}
94+
95+
public String getCustomerId() {
96+
return this.customerId;
97+
}
98+
99+
public void setProjectKey(final String projectKey) {
100+
this.projectKey = projectKey;
101+
}
102+
103+
public void setCustomerId(final String customerId) {
104+
this.customerId = customerId;
105+
}
106+
107+
public com.commercetools.api.models.cart.MergeCartDraft getBody() {
108+
return mergeCartDraft;
109+
}
110+
111+
public ByProjectKeyCartsCustomerIdByCustomerIdMergePost withBody(
112+
com.commercetools.api.models.cart.MergeCartDraft mergeCartDraft) {
113+
ByProjectKeyCartsCustomerIdByCustomerIdMergePost t = copy();
114+
t.mergeCartDraft = mergeCartDraft;
115+
return t;
116+
}
117+
118+
@Override
119+
public boolean equals(Object o) {
120+
if (this == o)
121+
return true;
122+
123+
if (o == null || getClass() != o.getClass())
124+
return false;
125+
126+
ByProjectKeyCartsCustomerIdByCustomerIdMergePost that = (ByProjectKeyCartsCustomerIdByCustomerIdMergePost) o;
127+
128+
return new EqualsBuilder().append(projectKey, that.projectKey)
129+
.append(customerId, that.customerId)
130+
.append(mergeCartDraft, that.mergeCartDraft)
131+
.isEquals();
132+
}
133+
134+
@Override
135+
public int hashCode() {
136+
return new HashCodeBuilder(17, 37).append(projectKey).append(customerId).append(mergeCartDraft).toHashCode();
137+
}
138+
139+
@Override
140+
protected ByProjectKeyCartsCustomerIdByCustomerIdMergePost copy() {
141+
return new ByProjectKeyCartsCustomerIdByCustomerIdMergePost(this);
142+
}
143+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
2+
package com.commercetools.api.client;
3+
4+
import java.net.URI;
5+
import java.nio.charset.StandardCharsets;
6+
import java.time.Duration;
7+
import java.util.ArrayList;
8+
import java.util.List;
9+
import java.util.concurrent.CompletableFuture;
10+
11+
import com.fasterxml.jackson.core.type.TypeReference;
12+
13+
import io.vrap.rmf.base.client.*;
14+
import io.vrap.rmf.base.client.utils.Generated;
15+
16+
import org.apache.commons.lang3.builder.EqualsBuilder;
17+
import org.apache.commons.lang3.builder.HashCodeBuilder;
18+
19+
/**
20+
* <p>Merges items from an anonymous Cart into the most recently modified active Cart of a Customer. If no active Cart exists, a <a href="https://docs.commercetools.com/apis/ctp:api:type:ResourceNotFoundError" rel="nofollow">ResourceNotFound</a> error is returned.</p>
21+
* <p>For more information, see <span>Merge behavior</span>.</p>
22+
*
23+
* <hr>
24+
* <div class=code-example>
25+
* <pre><code class='java'>{@code
26+
* CompletableFuture<ApiHttpResponse<com.commercetools.api.models.cart.Cart>> result = apiRoot
27+
* .withProjectKey("{projectKey}")
28+
* .carts()
29+
* .customerIdWithCustomerIdValueMerge("{customerId}")
30+
* .post("")
31+
* .execute()
32+
* }</code></pre>
33+
* </div>
34+
*/
35+
@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen")
36+
public class ByProjectKeyCartsCustomerIdByCustomerIdMergePostString extends
37+
StringBodyApiMethod<ByProjectKeyCartsCustomerIdByCustomerIdMergePostString, com.commercetools.api.models.cart.Cart>
38+
implements com.commercetools.api.client.ErrorableTrait<ByProjectKeyCartsCustomerIdByCustomerIdMergePostString> {
39+
40+
@Override
41+
public TypeReference<com.commercetools.api.models.cart.Cart> resultType() {
42+
return new TypeReference<com.commercetools.api.models.cart.Cart>() {
43+
};
44+
}
45+
46+
private String projectKey;
47+
private String customerId;
48+
49+
private String mergeCartDraft;
50+
51+
public ByProjectKeyCartsCustomerIdByCustomerIdMergePostString(final ApiHttpClient apiHttpClient, String projectKey,
52+
String customerId, String mergeCartDraft) {
53+
super(apiHttpClient);
54+
this.projectKey = projectKey;
55+
this.customerId = customerId;
56+
this.mergeCartDraft = mergeCartDraft;
57+
}
58+
59+
public ByProjectKeyCartsCustomerIdByCustomerIdMergePostString(
60+
ByProjectKeyCartsCustomerIdByCustomerIdMergePostString t) {
61+
super(t);
62+
this.projectKey = t.projectKey;
63+
this.customerId = t.customerId;
64+
this.mergeCartDraft = t.mergeCartDraft;
65+
}
66+
67+
@Override
68+
protected ApiHttpRequest buildHttpRequest() {
69+
List<String> params = new ArrayList<>(getQueryParamUriStrings());
70+
String httpRequestPath = String.format("%s/carts/customer-id=%s/merge", this.projectKey, this.customerId);
71+
if (!params.isEmpty()) {
72+
httpRequestPath += "?" + String.join("&", params);
73+
}
74+
return new ApiHttpRequest(ApiHttpMethod.POST, URI.create(httpRequestPath), getHeaders(),
75+
mergeCartDraft.getBytes(StandardCharsets.UTF_8));
76+
77+
}
78+
79+
@Override
80+
public ApiHttpResponse<com.commercetools.api.models.cart.Cart> executeBlocking(final ApiHttpClient client,
81+
final Duration timeout) {
82+
return executeBlocking(client, timeout, com.commercetools.api.models.cart.Cart.class);
83+
}
84+
85+
@Override
86+
public CompletableFuture<ApiHttpResponse<com.commercetools.api.models.cart.Cart>> execute(
87+
final ApiHttpClient client) {
88+
return execute(client, com.commercetools.api.models.cart.Cart.class);
89+
}
90+
91+
public String getProjectKey() {
92+
return this.projectKey;
93+
}
94+
95+
public String getCustomerId() {
96+
return this.customerId;
97+
}
98+
99+
public void setProjectKey(final String projectKey) {
100+
this.projectKey = projectKey;
101+
}
102+
103+
public void setCustomerId(final String customerId) {
104+
this.customerId = customerId;
105+
}
106+
107+
public String getBody() {
108+
return mergeCartDraft;
109+
}
110+
111+
public ByProjectKeyCartsCustomerIdByCustomerIdMergePostString withBody(String mergeCartDraft) {
112+
ByProjectKeyCartsCustomerIdByCustomerIdMergePostString t = copy();
113+
t.mergeCartDraft = mergeCartDraft;
114+
return t;
115+
}
116+
117+
@Override
118+
public boolean equals(Object o) {
119+
if (this == o)
120+
return true;
121+
122+
if (o == null || getClass() != o.getClass())
123+
return false;
124+
125+
ByProjectKeyCartsCustomerIdByCustomerIdMergePostString that = (ByProjectKeyCartsCustomerIdByCustomerIdMergePostString) o;
126+
127+
return new EqualsBuilder().append(projectKey, that.projectKey)
128+
.append(customerId, that.customerId)
129+
.append(mergeCartDraft, that.mergeCartDraft)
130+
.isEquals();
131+
}
132+
133+
@Override
134+
public int hashCode() {
135+
return new HashCodeBuilder(17, 37).append(projectKey).append(customerId).append(mergeCartDraft).toHashCode();
136+
}
137+
138+
@Override
139+
protected ByProjectKeyCartsCustomerIdByCustomerIdMergePostString copy() {
140+
return new ByProjectKeyCartsCustomerIdByCustomerIdMergePostString(this);
141+
}
142+
}

0 commit comments

Comments
 (0)