001 002package com.commercetools.api.client; 003 004import java.net.URI; 005import java.nio.charset.StandardCharsets; 006import java.time.Duration; 007import java.util.ArrayList; 008import java.util.List; 009import java.util.concurrent.CompletableFuture; 010 011import io.vrap.rmf.base.client.*; 012import io.vrap.rmf.base.client.utils.Generated; 013 014import org.apache.commons.lang3.builder.EqualsBuilder; 015import org.apache.commons.lang3.builder.HashCodeBuilder; 016 017/** 018 * <p>Retrieves the authenticated Customer (that matches the given email/password pair) if they are part of a specific Store.</p> 019 * <ul> 020 * <li>If the Customer does not have a Cart, the most recently modified anonymous cart becomes the Customer's Cart.</li> 021 * <li>If the Customer already has a Cart, the most recently modified anonymous cart is handled according to AnonymousCartSignInMode.</li> 022 * </ul> 023 * <p>If a Cart is returned as part of CustomerSignInResult, it has been recalculated with up-to-date prices, taxes, discounts, and invalid line items removed.</p> 024 * <p>If an account with the given credentials is not found, an InvalidCredentials error is returned.</p> 025 * 026 * <hr> 027 * <div class=code-example> 028 * <pre><code class='java'>{@code 029 * CompletableFuture<ApiHttpResponse<com.commercetools.api.models.customer.CustomerSignInResult>> result = apiRoot 030 * .withProjectKey("{projectKey}") 031 * .inStoreKeyWithStoreKeyValue("{storeKey}") 032 * .me() 033 * .login() 034 * .post("") 035 * .execute() 036 * }</code></pre> 037 * </div> 038 */ 039@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen") 040public class ByProjectKeyInStoreKeyByStoreKeyMeLoginPostString extends 041 StringBodyApiMethod<ByProjectKeyInStoreKeyByStoreKeyMeLoginPostString, com.commercetools.api.models.customer.CustomerSignInResult> 042 implements com.commercetools.api.client.ErrorableTrait<ByProjectKeyInStoreKeyByStoreKeyMeLoginPostString> { 043 044 private String projectKey; 045 private String storeKey; 046 047 private String myCustomerSignin; 048 049 public ByProjectKeyInStoreKeyByStoreKeyMeLoginPostString(final ApiHttpClient apiHttpClient, String projectKey, 050 String storeKey, String myCustomerSignin) { 051 super(apiHttpClient); 052 this.projectKey = projectKey; 053 this.storeKey = storeKey; 054 this.myCustomerSignin = myCustomerSignin; 055 } 056 057 public ByProjectKeyInStoreKeyByStoreKeyMeLoginPostString(ByProjectKeyInStoreKeyByStoreKeyMeLoginPostString t) { 058 super(t); 059 this.projectKey = t.projectKey; 060 this.storeKey = t.storeKey; 061 this.myCustomerSignin = t.myCustomerSignin; 062 } 063 064 @Override 065 protected ApiHttpRequest buildHttpRequest() { 066 List<String> params = new ArrayList<>(getQueryParamUriStrings()); 067 String httpRequestPath = String.format("%s/in-store/key=%s/me/login", this.projectKey, this.storeKey); 068 if (!params.isEmpty()) { 069 httpRequestPath += "?" + String.join("&", params); 070 } 071 return new ApiHttpRequest(ApiHttpMethod.POST, URI.create(httpRequestPath), getHeaders(), 072 myCustomerSignin.getBytes(StandardCharsets.UTF_8)); 073 074 } 075 076 @Override 077 public ApiHttpResponse<com.commercetools.api.models.customer.CustomerSignInResult> executeBlocking( 078 final ApiHttpClient client, final Duration timeout) { 079 return executeBlocking(client, timeout, com.commercetools.api.models.customer.CustomerSignInResult.class); 080 } 081 082 @Override 083 public CompletableFuture<ApiHttpResponse<com.commercetools.api.models.customer.CustomerSignInResult>> execute( 084 final ApiHttpClient client) { 085 return execute(client, com.commercetools.api.models.customer.CustomerSignInResult.class); 086 } 087 088 public String getProjectKey() { 089 return this.projectKey; 090 } 091 092 public String getStoreKey() { 093 return this.storeKey; 094 } 095 096 public void setProjectKey(final String projectKey) { 097 this.projectKey = projectKey; 098 } 099 100 public void setStoreKey(final String storeKey) { 101 this.storeKey = storeKey; 102 } 103 104 public String getBody() { 105 return myCustomerSignin; 106 } 107 108 public ByProjectKeyInStoreKeyByStoreKeyMeLoginPostString withBody(String myCustomerSignin) { 109 ByProjectKeyInStoreKeyByStoreKeyMeLoginPostString t = copy(); 110 t.myCustomerSignin = myCustomerSignin; 111 return t; 112 } 113 114 @Override 115 public boolean equals(Object o) { 116 if (this == o) 117 return true; 118 119 if (o == null || getClass() != o.getClass()) 120 return false; 121 122 ByProjectKeyInStoreKeyByStoreKeyMeLoginPostString that = (ByProjectKeyInStoreKeyByStoreKeyMeLoginPostString) o; 123 124 return new EqualsBuilder().append(projectKey, that.projectKey) 125 .append(storeKey, that.storeKey) 126 .append(myCustomerSignin, that.myCustomerSignin) 127 .isEquals(); 128 } 129 130 @Override 131 public int hashCode() { 132 return new HashCodeBuilder(17, 37).append(projectKey).append(storeKey).append(myCustomerSignin).toHashCode(); 133 } 134 135 @Override 136 protected ByProjectKeyInStoreKeyByStoreKeyMeLoginPostString copy() { 137 return new ByProjectKeyInStoreKeyByStoreKeyMeLoginPostString(this); 138 } 139}