001 002package com.commercetools.api.client; 003 004import java.net.URI; 005import java.time.Duration; 006import java.util.ArrayList; 007import java.util.Collection; 008import java.util.List; 009import java.util.concurrent.CompletableFuture; 010import java.util.function.Function; 011import java.util.function.Supplier; 012import java.util.stream.Collectors; 013 014import io.vrap.rmf.base.client.*; 015import io.vrap.rmf.base.client.utils.Generated; 016 017import org.apache.commons.lang3.builder.EqualsBuilder; 018import org.apache.commons.lang3.builder.HashCodeBuilder; 019 020/** 021 * 022 * 023 * <hr> 024 * <div class=code-example> 025 * <pre><code class='java'>{@code 026 * CompletableFuture<ApiHttpResponse<com.commercetools.api.models.customer.Customer>> result = apiRoot 027 * .withProjectKey("{projectKey}") 028 * .customers() 029 * .withPasswordToken("{passwordToken}") 030 * .get() 031 * .execute() 032 * }</code></pre> 033 * </div> 034 */ 035@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen") 036public class ByProjectKeyCustomersPasswordTokenByPasswordTokenGet extends 037 ApiMethod<ByProjectKeyCustomersPasswordTokenByPasswordTokenGet, com.commercetools.api.models.customer.Customer> 038 implements com.commercetools.api.client.ExpandableTrait<ByProjectKeyCustomersPasswordTokenByPasswordTokenGet>, 039 com.commercetools.api.client.ErrorableTrait<ByProjectKeyCustomersPasswordTokenByPasswordTokenGet>, 040 com.commercetools.api.client.Deprecatable200Trait<ByProjectKeyCustomersPasswordTokenByPasswordTokenGet> { 041 042 private String projectKey; 043 private String passwordToken; 044 045 public ByProjectKeyCustomersPasswordTokenByPasswordTokenGet(final ApiHttpClient apiHttpClient, String projectKey, 046 String passwordToken) { 047 super(apiHttpClient); 048 this.projectKey = projectKey; 049 this.passwordToken = passwordToken; 050 } 051 052 public ByProjectKeyCustomersPasswordTokenByPasswordTokenGet( 053 ByProjectKeyCustomersPasswordTokenByPasswordTokenGet t) { 054 super(t); 055 this.projectKey = t.projectKey; 056 this.passwordToken = t.passwordToken; 057 } 058 059 @Override 060 protected ApiHttpRequest buildHttpRequest() { 061 List<String> params = new ArrayList<>(getQueryParamUriStrings()); 062 String httpRequestPath = String.format("%s/customers/password-token=%s", this.projectKey, this.passwordToken); 063 if (!params.isEmpty()) { 064 httpRequestPath += "?" + String.join("&", params); 065 } 066 return new ApiHttpRequest(ApiHttpMethod.GET, URI.create(httpRequestPath), getHeaders(), null); 067 } 068 069 @Override 070 public ApiHttpResponse<com.commercetools.api.models.customer.Customer> executeBlocking(final ApiHttpClient client, 071 final Duration timeout) { 072 return executeBlocking(client, timeout, com.commercetools.api.models.customer.Customer.class); 073 } 074 075 @Override 076 public CompletableFuture<ApiHttpResponse<com.commercetools.api.models.customer.Customer>> execute( 077 final ApiHttpClient client) { 078 return execute(client, com.commercetools.api.models.customer.Customer.class); 079 } 080 081 public String getProjectKey() { 082 return this.projectKey; 083 } 084 085 public String getPasswordToken() { 086 return this.passwordToken; 087 } 088 089 public List<String> getExpand() { 090 return this.getQueryParam("expand"); 091 } 092 093 public void setProjectKey(final String projectKey) { 094 this.projectKey = projectKey; 095 } 096 097 public void setPasswordToken(final String passwordToken) { 098 this.passwordToken = passwordToken; 099 } 100 101 /** 102 * set expand with the specified value 103 * @param expand value to be set 104 * @param <TValue> value type 105 * @return ByProjectKeyCustomersPasswordTokenByPasswordTokenGet 106 */ 107 public <TValue> ByProjectKeyCustomersPasswordTokenByPasswordTokenGet withExpand(final TValue expand) { 108 return copy().withQueryParam("expand", expand); 109 } 110 111 /** 112 * add additional expand query parameter 113 * @param expand value to be added 114 * @param <TValue> value type 115 * @return ByProjectKeyCustomersPasswordTokenByPasswordTokenGet 116 */ 117 public <TValue> ByProjectKeyCustomersPasswordTokenByPasswordTokenGet addExpand(final TValue expand) { 118 return copy().addQueryParam("expand", expand); 119 } 120 121 /** 122 * set expand with the specified value 123 * @param supplier supplier for the value to be set 124 * @return ByProjectKeyCustomersPasswordTokenByPasswordTokenGet 125 */ 126 public ByProjectKeyCustomersPasswordTokenByPasswordTokenGet withExpand(final Supplier<String> supplier) { 127 return copy().withQueryParam("expand", supplier.get()); 128 } 129 130 /** 131 * add additional expand query parameter 132 * @param supplier supplier for the value to be added 133 * @return ByProjectKeyCustomersPasswordTokenByPasswordTokenGet 134 */ 135 public ByProjectKeyCustomersPasswordTokenByPasswordTokenGet addExpand(final Supplier<String> supplier) { 136 return copy().addQueryParam("expand", supplier.get()); 137 } 138 139 /** 140 * set expand with the specified value 141 * @param op builder for the value to be set 142 * @return ByProjectKeyCustomersPasswordTokenByPasswordTokenGet 143 */ 144 public ByProjectKeyCustomersPasswordTokenByPasswordTokenGet withExpand( 145 final Function<StringBuilder, StringBuilder> op) { 146 return copy().withQueryParam("expand", op.apply(new StringBuilder())); 147 } 148 149 /** 150 * add additional expand query parameter 151 * @param op builder for the value to be added 152 * @return ByProjectKeyCustomersPasswordTokenByPasswordTokenGet 153 */ 154 public ByProjectKeyCustomersPasswordTokenByPasswordTokenGet addExpand( 155 final Function<StringBuilder, StringBuilder> op) { 156 return copy().addQueryParam("expand", op.apply(new StringBuilder())); 157 } 158 159 /** 160 * set expand with the specified values 161 * @param expand values to be set 162 * @param <TValue> value type 163 * @return ByProjectKeyCustomersPasswordTokenByPasswordTokenGet 164 */ 165 public <TValue> ByProjectKeyCustomersPasswordTokenByPasswordTokenGet withExpand(final Collection<TValue> expand) { 166 return copy().withoutQueryParam("expand") 167 .addQueryParams( 168 expand.stream().map(s -> new ParamEntry<>("expand", s.toString())).collect(Collectors.toList())); 169 } 170 171 /** 172 * add additional expand query parameters 173 * @param expand values to be added 174 * @param <TValue> value type 175 * @return ByProjectKeyCustomersPasswordTokenByPasswordTokenGet 176 */ 177 public <TValue> ByProjectKeyCustomersPasswordTokenByPasswordTokenGet addExpand(final Collection<TValue> expand) { 178 return copy().addQueryParams( 179 expand.stream().map(s -> new ParamEntry<>("expand", s.toString())).collect(Collectors.toList())); 180 } 181 182 @Override 183 public boolean equals(Object o) { 184 if (this == o) 185 return true; 186 187 if (o == null || getClass() != o.getClass()) 188 return false; 189 190 ByProjectKeyCustomersPasswordTokenByPasswordTokenGet that = (ByProjectKeyCustomersPasswordTokenByPasswordTokenGet) o; 191 192 return new EqualsBuilder().append(projectKey, that.projectKey) 193 .append(passwordToken, that.passwordToken) 194 .isEquals(); 195 } 196 197 @Override 198 public int hashCode() { 199 return new HashCodeBuilder(17, 37).append(projectKey).append(passwordToken).toHashCode(); 200 } 201 202 @Override 203 protected ByProjectKeyCustomersPasswordTokenByPasswordTokenGet copy() { 204 return new ByProjectKeyCustomersPasswordTokenByPasswordTokenGet(this); 205 } 206}