001 002package com.commercetools.api.client; 003 004import java.net.URI; 005import java.time.Duration; 006import java.util.ArrayList; 007import java.util.List; 008import java.util.concurrent.CompletableFuture; 009 010import io.vrap.rmf.base.client.*; 011import io.vrap.rmf.base.client.utils.Generated; 012 013import org.apache.commons.lang3.builder.EqualsBuilder; 014import org.apache.commons.lang3.builder.HashCodeBuilder; 015 016/** 017 * <p>If omitted in the request body, the Customer <code>stores</code> field is set to the Store specified in the path parameter.</p> 018 * <p>Creating a Customer produces the CustomerCreated Message.</p> 019 * 020 * <hr> 021 * <div class=code-example> 022 * <pre><code class='java'>{@code 023 * CompletableFuture<ApiHttpResponse<com.commercetools.api.models.customer.CustomerSignInResult>> result = apiRoot 024 * .withProjectKey("{projectKey}") 025 * .inStoreKeyWithStoreKeyValue("{storeKey}") 026 * .me() 027 * .signup() 028 * .post(null) 029 * .execute() 030 * }</code></pre> 031 * </div> 032 */ 033@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen") 034public class ByProjectKeyInStoreKeyByStoreKeyMeSignupPost extends 035 BodyApiMethod<ByProjectKeyInStoreKeyByStoreKeyMeSignupPost, com.commercetools.api.models.customer.CustomerSignInResult, com.commercetools.api.models.me.MyCustomerDraft> 036 implements com.commercetools.api.client.ErrorableTrait<ByProjectKeyInStoreKeyByStoreKeyMeSignupPost> { 037 038 private String projectKey; 039 private String storeKey; 040 041 private com.commercetools.api.models.me.MyCustomerDraft myCustomerDraft; 042 043 public ByProjectKeyInStoreKeyByStoreKeyMeSignupPost(final ApiHttpClient apiHttpClient, String projectKey, 044 String storeKey, com.commercetools.api.models.me.MyCustomerDraft myCustomerDraft) { 045 super(apiHttpClient); 046 this.projectKey = projectKey; 047 this.storeKey = storeKey; 048 this.myCustomerDraft = myCustomerDraft; 049 } 050 051 public ByProjectKeyInStoreKeyByStoreKeyMeSignupPost(ByProjectKeyInStoreKeyByStoreKeyMeSignupPost t) { 052 super(t); 053 this.projectKey = t.projectKey; 054 this.storeKey = t.storeKey; 055 this.myCustomerDraft = t.myCustomerDraft; 056 } 057 058 @Override 059 protected ApiHttpRequest buildHttpRequest() { 060 List<String> params = new ArrayList<>(getQueryParamUriStrings()); 061 String httpRequestPath = String.format("%s/in-store/key=%s/me/signup", this.projectKey, this.storeKey); 062 if (!params.isEmpty()) { 063 httpRequestPath += "?" + String.join("&", params); 064 } 065 return new ApiHttpRequest(ApiHttpMethod.POST, URI.create(httpRequestPath), getHeaders(), 066 io.vrap.rmf.base.client.utils.json.JsonUtils 067 .executing(() -> apiHttpClient().getSerializerService().toJsonByteArray(myCustomerDraft))); 068 069 } 070 071 @Override 072 public ApiHttpResponse<com.commercetools.api.models.customer.CustomerSignInResult> executeBlocking( 073 final ApiHttpClient client, final Duration timeout) { 074 return executeBlocking(client, timeout, com.commercetools.api.models.customer.CustomerSignInResult.class); 075 } 076 077 @Override 078 public CompletableFuture<ApiHttpResponse<com.commercetools.api.models.customer.CustomerSignInResult>> execute( 079 final ApiHttpClient client) { 080 return execute(client, com.commercetools.api.models.customer.CustomerSignInResult.class); 081 } 082 083 public String getProjectKey() { 084 return this.projectKey; 085 } 086 087 public String getStoreKey() { 088 return this.storeKey; 089 } 090 091 public void setProjectKey(final String projectKey) { 092 this.projectKey = projectKey; 093 } 094 095 public void setStoreKey(final String storeKey) { 096 this.storeKey = storeKey; 097 } 098 099 public com.commercetools.api.models.me.MyCustomerDraft getBody() { 100 return myCustomerDraft; 101 } 102 103 public ByProjectKeyInStoreKeyByStoreKeyMeSignupPost withBody( 104 com.commercetools.api.models.me.MyCustomerDraft myCustomerDraft) { 105 ByProjectKeyInStoreKeyByStoreKeyMeSignupPost t = copy(); 106 t.myCustomerDraft = myCustomerDraft; 107 return t; 108 } 109 110 @Override 111 public boolean equals(Object o) { 112 if (this == o) 113 return true; 114 115 if (o == null || getClass() != o.getClass()) 116 return false; 117 118 ByProjectKeyInStoreKeyByStoreKeyMeSignupPost that = (ByProjectKeyInStoreKeyByStoreKeyMeSignupPost) o; 119 120 return new EqualsBuilder().append(projectKey, that.projectKey) 121 .append(storeKey, that.storeKey) 122 .append(myCustomerDraft, that.myCustomerDraft) 123 .isEquals(); 124 } 125 126 @Override 127 public int hashCode() { 128 return new HashCodeBuilder(17, 37).append(projectKey).append(storeKey).append(myCustomerDraft).toHashCode(); 129 } 130 131 @Override 132 protected ByProjectKeyInStoreKeyByStoreKeyMeSignupPost copy() { 133 return new ByProjectKeyInStoreKeyByStoreKeyMeSignupPost(this); 134 } 135}