Skip to content

Commit

Permalink
Merge pull request #448 from commercetools/gen-sdk-updates
Browse files Browse the repository at this point in the history
  • Loading branch information
jenschude authored Jun 1, 2023
2 parents 703b309 + 9d213bc commit bc7560f
Show file tree
Hide file tree
Showing 86 changed files with 5,491 additions and 324 deletions.
279 changes: 16 additions & 263 deletions changes.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@

package com.commercetools.api.client;

import java.net.URI;
import java.time.Duration;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CompletableFuture;

import io.vrap.rmf.base.client.*;
import io.vrap.rmf.base.client.utils.Generated;

import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;

/**
* <p>Creates a new Cart by replicating an existing Cart or Order. Can be useful in cases where a customer wants to cancel a recent order to make some changes or reorder a previous order.</p>
* <p>The replicated Cart preserves Customer information, Line Items and Custom Line Items, Custom Fields, Discount Codes, and other settings of the Cart or Order. If the Line Items become invalid, for example, due to removed Products or Prices, they are removed from the new Cart. If the Customer switches to another Customer Group, the new Cart is updated with the new value. It has up-to-date Tax Rates, Prices, and Line Item product data and is in <code>Active</code> CartState.</p>
* <p>The new Cart does not contain Payments or Deliveries. The State of Line Items and Custom Line Items is reset to <code>initial</code>.</p>
* <p>If the Cart exists in the Project but does not reference the requested BusinessUnit, this method returns an InvalidOperation error.</p>
*
* <hr>
* <div class=code-example>
* <pre><code class='java'>{@code
* CompletableFuture<ApiHttpResponse<com.commercetools.api.models.cart.Cart>> result = apiRoot
* .withProjectKey("{projectKey}")
* .asAssociate()
* .withAssociateIdValue("{associateId}")
* .inBusinessUnitKeyWithBusinessUnitKeyValue("{businessUnitKey}")
* .carts()
* .replicate()
* .post(null)
* .execute()
* }</code></pre>
* </div>
*/
@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen")
public class ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyCartsReplicatePost extends
BodyApiMethod<ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyCartsReplicatePost, com.commercetools.api.models.cart.Cart, com.commercetools.api.models.cart.ReplicaCartDraft>
implements
com.commercetools.api.client.ErrorableTrait<ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyCartsReplicatePost> {

private String projectKey;
private String associateId;
private String businessUnitKey;

private com.commercetools.api.models.cart.ReplicaCartDraft replicaCartDraft;

public ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyCartsReplicatePost(
final ApiHttpClient apiHttpClient, String projectKey, String associateId, String businessUnitKey,
com.commercetools.api.models.cart.ReplicaCartDraft replicaCartDraft) {
super(apiHttpClient);
this.projectKey = projectKey;
this.associateId = associateId;
this.businessUnitKey = businessUnitKey;
this.replicaCartDraft = replicaCartDraft;
}

public ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyCartsReplicatePost(
ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyCartsReplicatePost t) {
super(t);
this.projectKey = t.projectKey;
this.associateId = t.associateId;
this.businessUnitKey = t.businessUnitKey;
this.replicaCartDraft = t.replicaCartDraft;
}

@Override
protected ApiHttpRequest buildHttpRequest() {
List<String> params = new ArrayList<>(getQueryParamUriStrings());
String httpRequestPath = String.format("%s/as-associate/%s/in-business-unit/key=%s/carts/replicate",
this.projectKey, this.associateId, this.businessUnitKey);
if (!params.isEmpty()) {
httpRequestPath += "?" + String.join("&", params);
}
return new ApiHttpRequest(ApiHttpMethod.POST, URI.create(httpRequestPath), getHeaders(),
io.vrap.rmf.base.client.utils.json.JsonUtils
.executing(() -> apiHttpClient().getSerializerService().toJsonByteArray(replicaCartDraft)));

}

@Override
public ApiHttpResponse<com.commercetools.api.models.cart.Cart> executeBlocking(final ApiHttpClient client,
final Duration timeout) {
return executeBlocking(client, timeout, com.commercetools.api.models.cart.Cart.class);
}

@Override
public CompletableFuture<ApiHttpResponse<com.commercetools.api.models.cart.Cart>> execute(
final ApiHttpClient client) {
return execute(client, com.commercetools.api.models.cart.Cart.class);
}

public String getProjectKey() {
return this.projectKey;
}

public String getAssociateId() {
return this.associateId;
}

public String getBusinessUnitKey() {
return this.businessUnitKey;
}

public void setProjectKey(final String projectKey) {
this.projectKey = projectKey;
}

public void setAssociateId(final String associateId) {
this.associateId = associateId;
}

public void setBusinessUnitKey(final String businessUnitKey) {
this.businessUnitKey = businessUnitKey;
}

public com.commercetools.api.models.cart.ReplicaCartDraft getBody() {
return replicaCartDraft;
}

public ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyCartsReplicatePost withBody(
com.commercetools.api.models.cart.ReplicaCartDraft replicaCartDraft) {
ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyCartsReplicatePost t = copy();
t.replicaCartDraft = replicaCartDraft;
return t;
}

@Override
public boolean equals(Object o) {
if (this == o)
return true;

if (o == null || getClass() != o.getClass())
return false;

ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyCartsReplicatePost that = (ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyCartsReplicatePost) o;

return new EqualsBuilder().append(projectKey, that.projectKey)
.append(associateId, that.associateId)
.append(businessUnitKey, that.businessUnitKey)
.append(replicaCartDraft, that.replicaCartDraft)
.isEquals();
}

@Override
public int hashCode() {
return new HashCodeBuilder(17, 37).append(projectKey)
.append(associateId)
.append(businessUnitKey)
.append(replicaCartDraft)
.toHashCode();
}

@Override
protected ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyCartsReplicatePost copy() {
return new ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyCartsReplicatePost(this);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@

package com.commercetools.api.client;

import java.net.URI;
import java.nio.charset.StandardCharsets;
import java.time.Duration;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CompletableFuture;

import io.vrap.rmf.base.client.*;
import io.vrap.rmf.base.client.utils.Generated;

import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;

/**
* <p>Creates a new Cart by replicating an existing Cart or Order. Can be useful in cases where a customer wants to cancel a recent order to make some changes or reorder a previous order.</p>
* <p>The replicated Cart preserves Customer information, Line Items and Custom Line Items, Custom Fields, Discount Codes, and other settings of the Cart or Order. If the Line Items become invalid, for example, due to removed Products or Prices, they are removed from the new Cart. If the Customer switches to another Customer Group, the new Cart is updated with the new value. It has up-to-date Tax Rates, Prices, and Line Item product data and is in <code>Active</code> CartState.</p>
* <p>The new Cart does not contain Payments or Deliveries. The State of Line Items and Custom Line Items is reset to <code>initial</code>.</p>
* <p>If the Cart exists in the Project but does not reference the requested BusinessUnit, this method returns an InvalidOperation error.</p>
*
* <hr>
* <div class=code-example>
* <pre><code class='java'>{@code
* CompletableFuture<ApiHttpResponse<com.commercetools.api.models.cart.Cart>> result = apiRoot
* .withProjectKey("{projectKey}")
* .asAssociate()
* .withAssociateIdValue("{associateId}")
* .inBusinessUnitKeyWithBusinessUnitKeyValue("{businessUnitKey}")
* .carts()
* .replicate()
* .post("")
* .execute()
* }</code></pre>
* </div>
*/
@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen")
public class ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyCartsReplicatePostString extends
StringBodyApiMethod<ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyCartsReplicatePostString, com.commercetools.api.models.cart.Cart>
implements
com.commercetools.api.client.ErrorableTrait<ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyCartsReplicatePostString> {

private String projectKey;
private String associateId;
private String businessUnitKey;

private String replicaCartDraft;

public ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyCartsReplicatePostString(
final ApiHttpClient apiHttpClient, String projectKey, String associateId, String businessUnitKey,
String replicaCartDraft) {
super(apiHttpClient);
this.projectKey = projectKey;
this.associateId = associateId;
this.businessUnitKey = businessUnitKey;
this.replicaCartDraft = replicaCartDraft;
}

public ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyCartsReplicatePostString(
ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyCartsReplicatePostString t) {
super(t);
this.projectKey = t.projectKey;
this.associateId = t.associateId;
this.businessUnitKey = t.businessUnitKey;
this.replicaCartDraft = t.replicaCartDraft;
}

@Override
protected ApiHttpRequest buildHttpRequest() {
List<String> params = new ArrayList<>(getQueryParamUriStrings());
String httpRequestPath = String.format("%s/as-associate/%s/in-business-unit/key=%s/carts/replicate",
this.projectKey, this.associateId, this.businessUnitKey);
if (!params.isEmpty()) {
httpRequestPath += "?" + String.join("&", params);
}
return new ApiHttpRequest(ApiHttpMethod.POST, URI.create(httpRequestPath), getHeaders(),
replicaCartDraft.getBytes(StandardCharsets.UTF_8));

}

@Override
public ApiHttpResponse<com.commercetools.api.models.cart.Cart> executeBlocking(final ApiHttpClient client,
final Duration timeout) {
return executeBlocking(client, timeout, com.commercetools.api.models.cart.Cart.class);
}

@Override
public CompletableFuture<ApiHttpResponse<com.commercetools.api.models.cart.Cart>> execute(
final ApiHttpClient client) {
return execute(client, com.commercetools.api.models.cart.Cart.class);
}

public String getProjectKey() {
return this.projectKey;
}

public String getAssociateId() {
return this.associateId;
}

public String getBusinessUnitKey() {
return this.businessUnitKey;
}

public void setProjectKey(final String projectKey) {
this.projectKey = projectKey;
}

public void setAssociateId(final String associateId) {
this.associateId = associateId;
}

public void setBusinessUnitKey(final String businessUnitKey) {
this.businessUnitKey = businessUnitKey;
}

public String getBody() {
return replicaCartDraft;
}

public ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyCartsReplicatePostString withBody(
String replicaCartDraft) {
ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyCartsReplicatePostString t = copy();
t.replicaCartDraft = replicaCartDraft;
return t;
}

@Override
public boolean equals(Object o) {
if (this == o)
return true;

if (o == null || getClass() != o.getClass())
return false;

ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyCartsReplicatePostString that = (ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyCartsReplicatePostString) o;

return new EqualsBuilder().append(projectKey, that.projectKey)
.append(associateId, that.associateId)
.append(businessUnitKey, that.businessUnitKey)
.append(replicaCartDraft, that.replicaCartDraft)
.isEquals();
}

@Override
public int hashCode() {
return new HashCodeBuilder(17, 37).append(projectKey)
.append(associateId)
.append(businessUnitKey)
.append(replicaCartDraft)
.toHashCode();
}

@Override
protected ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyCartsReplicatePostString copy() {
return new ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyCartsReplicatePostString(this);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@

package com.commercetools.api.client;

import java.util.function.UnaryOperator;

import io.vrap.rmf.base.client.ApiHttpClient;
import io.vrap.rmf.base.client.utils.Generated;

@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen")
public class ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyCartsReplicateRequestBuilder {

private final ApiHttpClient apiHttpClient;
private final String projectKey;
private final String associateId;
private final String businessUnitKey;

public ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyCartsReplicateRequestBuilder(
final ApiHttpClient apiHttpClient, final String projectKey, final String associateId,
final String businessUnitKey) {
this.apiHttpClient = apiHttpClient;
this.projectKey = projectKey;
this.associateId = associateId;
this.businessUnitKey = businessUnitKey;
}

public ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyCartsReplicatePost post(
com.commercetools.api.models.cart.ReplicaCartDraft replicaCartDraft) {
return new ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyCartsReplicatePost(
apiHttpClient, projectKey, associateId, businessUnitKey, replicaCartDraft);
}

public ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyCartsReplicatePostString post(
final String replicaCartDraft) {
return new ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyCartsReplicatePostString(
apiHttpClient, projectKey, associateId, businessUnitKey, replicaCartDraft);
}

public ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyCartsReplicatePost post(
UnaryOperator<com.commercetools.api.models.cart.ReplicaCartDraftBuilder> op) {
return post(op.apply(com.commercetools.api.models.cart.ReplicaCartDraftBuilder.of()).build());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,9 @@ public ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyCar
apiHttpClient, projectKey, associateId, businessUnitKey, ID);
}

public ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyCartsReplicateRequestBuilder replicate() {
return new ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyCartsReplicateRequestBuilder(
apiHttpClient, projectKey, associateId, businessUnitKey);
}

}
Loading

0 comments on commit bc7560f

Please sign in to comment.