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.Collection; 009import java.util.List; 010import java.util.concurrent.CompletableFuture; 011import java.util.function.Function; 012import java.util.function.Supplier; 013import java.util.stream.Collectors; 014 015import io.vrap.rmf.base.client.*; 016import io.vrap.rmf.base.client.utils.Generated; 017 018import org.apache.commons.lang3.builder.EqualsBuilder; 019import org.apache.commons.lang3.builder.HashCodeBuilder; 020 021/** 022 * <p>If the QuoteRequest exists in the Project but does not reference the requested BusinessUnit, this method returns an InvalidOperation error.</p> 023 * 024 * <hr> 025 * <div class=code-example> 026 * <pre><code class='java'>{@code 027 * CompletableFuture<ApiHttpResponse<com.commercetools.api.models.quote_request.QuoteRequest>> result = apiRoot 028 * .withProjectKey("{projectKey}") 029 * .asAssociate() 030 * .withAssociateIdValue("{associateId}") 031 * .inBusinessUnitKeyWithBusinessUnitKeyValue("{businessUnitKey}") 032 * .quoteRequests() 033 * .withKey("{key}") 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 ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyQuoteRequestsKeyByKeyPostString 041 extends 042 StringBodyApiMethod<ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyQuoteRequestsKeyByKeyPostString, com.commercetools.api.models.quote_request.QuoteRequest> 043 implements 044 com.commercetools.api.client.ConflictingTrait<ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyQuoteRequestsKeyByKeyPostString>, 045 com.commercetools.api.client.ExpandableTrait<ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyQuoteRequestsKeyByKeyPostString>, 046 com.commercetools.api.client.Deprecatable200Trait<ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyQuoteRequestsKeyByKeyPostString>, 047 com.commercetools.api.client.ErrorableTrait<ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyQuoteRequestsKeyByKeyPostString> { 048 049 private String projectKey; 050 private String associateId; 051 private String businessUnitKey; 052 private String key; 053 054 private String quoteRequestUpdate; 055 056 public ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyQuoteRequestsKeyByKeyPostString( 057 final ApiHttpClient apiHttpClient, String projectKey, String associateId, String businessUnitKey, 058 String key, String quoteRequestUpdate) { 059 super(apiHttpClient); 060 this.projectKey = projectKey; 061 this.associateId = associateId; 062 this.businessUnitKey = businessUnitKey; 063 this.key = key; 064 this.quoteRequestUpdate = quoteRequestUpdate; 065 } 066 067 public ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyQuoteRequestsKeyByKeyPostString( 068 ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyQuoteRequestsKeyByKeyPostString t) { 069 super(t); 070 this.projectKey = t.projectKey; 071 this.associateId = t.associateId; 072 this.businessUnitKey = t.businessUnitKey; 073 this.key = t.key; 074 this.quoteRequestUpdate = t.quoteRequestUpdate; 075 } 076 077 @Override 078 protected ApiHttpRequest buildHttpRequest() { 079 List<String> params = new ArrayList<>(getQueryParamUriStrings()); 080 String httpRequestPath = String.format("%s/as-associate/%s/in-business-unit/key=%s/quote-requests/key=%s", 081 this.projectKey, this.associateId, this.businessUnitKey, this.key); 082 if (!params.isEmpty()) { 083 httpRequestPath += "?" + String.join("&", params); 084 } 085 return new ApiHttpRequest(ApiHttpMethod.POST, URI.create(httpRequestPath), getHeaders(), 086 quoteRequestUpdate.getBytes(StandardCharsets.UTF_8)); 087 088 } 089 090 @Override 091 public ApiHttpResponse<com.commercetools.api.models.quote_request.QuoteRequest> executeBlocking( 092 final ApiHttpClient client, final Duration timeout) { 093 return executeBlocking(client, timeout, com.commercetools.api.models.quote_request.QuoteRequest.class); 094 } 095 096 @Override 097 public CompletableFuture<ApiHttpResponse<com.commercetools.api.models.quote_request.QuoteRequest>> execute( 098 final ApiHttpClient client) { 099 return execute(client, com.commercetools.api.models.quote_request.QuoteRequest.class); 100 } 101 102 public String getProjectKey() { 103 return this.projectKey; 104 } 105 106 public String getAssociateId() { 107 return this.associateId; 108 } 109 110 public String getBusinessUnitKey() { 111 return this.businessUnitKey; 112 } 113 114 public String getKey() { 115 return this.key; 116 } 117 118 public List<String> getExpand() { 119 return this.getQueryParam("expand"); 120 } 121 122 public void setProjectKey(final String projectKey) { 123 this.projectKey = projectKey; 124 } 125 126 public void setAssociateId(final String associateId) { 127 this.associateId = associateId; 128 } 129 130 public void setBusinessUnitKey(final String businessUnitKey) { 131 this.businessUnitKey = businessUnitKey; 132 } 133 134 public void setKey(final String key) { 135 this.key = key; 136 } 137 138 /** 139 * set expand with the specified value 140 * @param <TValue> value type 141 * @param expand value to be set 142 * @return ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyQuoteRequestsKeyByKeyPostString 143 */ 144 public <TValue> ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyQuoteRequestsKeyByKeyPostString withExpand( 145 final TValue expand) { 146 return copy().withQueryParam("expand", expand); 147 } 148 149 /** 150 * add additional expand query parameter 151 * @param <TValue> value type 152 * @param expand value to be added 153 * @return ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyQuoteRequestsKeyByKeyPostString 154 */ 155 public <TValue> ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyQuoteRequestsKeyByKeyPostString addExpand( 156 final TValue expand) { 157 return copy().addQueryParam("expand", expand); 158 } 159 160 /** 161 * set expand with the specified value 162 * @param supplier supplier for the value to be set 163 * @return ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyQuoteRequestsKeyByKeyPostString 164 */ 165 public ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyQuoteRequestsKeyByKeyPostString withExpand( 166 final Supplier<String> supplier) { 167 return copy().withQueryParam("expand", supplier.get()); 168 } 169 170 /** 171 * add additional expand query parameter 172 * @param supplier supplier for the value to be added 173 * @return ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyQuoteRequestsKeyByKeyPostString 174 */ 175 public ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyQuoteRequestsKeyByKeyPostString addExpand( 176 final Supplier<String> supplier) { 177 return copy().addQueryParam("expand", supplier.get()); 178 } 179 180 /** 181 * set expand with the specified value 182 * @param op builder for the value to be set 183 * @return ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyQuoteRequestsKeyByKeyPostString 184 */ 185 public ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyQuoteRequestsKeyByKeyPostString withExpand( 186 final Function<StringBuilder, StringBuilder> op) { 187 return copy().withQueryParam("expand", op.apply(new StringBuilder())); 188 } 189 190 /** 191 * add additional expand query parameter 192 * @param op builder for the value to be added 193 * @return ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyQuoteRequestsKeyByKeyPostString 194 */ 195 public ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyQuoteRequestsKeyByKeyPostString addExpand( 196 final Function<StringBuilder, StringBuilder> op) { 197 return copy().addQueryParam("expand", op.apply(new StringBuilder())); 198 } 199 200 /** 201 * set expand with the specified values 202 * @param <TValue> value type 203 * @param expand values to be set 204 * @return ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyQuoteRequestsKeyByKeyPostString 205 */ 206 public <TValue> ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyQuoteRequestsKeyByKeyPostString withExpand( 207 final Collection<TValue> expand) { 208 return copy().withoutQueryParam("expand") 209 .addQueryParams( 210 expand.stream().map(s -> new ParamEntry<>("expand", s.toString())).collect(Collectors.toList())); 211 } 212 213 /** 214 * add additional expand query parameters 215 * @param <TValue> value type 216 * @param expand values to be added 217 * @return ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyQuoteRequestsKeyByKeyPostString 218 */ 219 public <TValue> ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyQuoteRequestsKeyByKeyPostString addExpand( 220 final Collection<TValue> expand) { 221 return copy().addQueryParams( 222 expand.stream().map(s -> new ParamEntry<>("expand", s.toString())).collect(Collectors.toList())); 223 } 224 225 public String getBody() { 226 return quoteRequestUpdate; 227 } 228 229 public ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyQuoteRequestsKeyByKeyPostString withBody( 230 String quoteRequestUpdate) { 231 ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyQuoteRequestsKeyByKeyPostString t = copy(); 232 t.quoteRequestUpdate = quoteRequestUpdate; 233 return t; 234 } 235 236 @Override 237 public boolean equals(Object o) { 238 if (this == o) 239 return true; 240 241 if (o == null || getClass() != o.getClass()) 242 return false; 243 244 ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyQuoteRequestsKeyByKeyPostString that = (ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyQuoteRequestsKeyByKeyPostString) o; 245 246 return new EqualsBuilder().append(projectKey, that.projectKey) 247 .append(associateId, that.associateId) 248 .append(businessUnitKey, that.businessUnitKey) 249 .append(key, that.key) 250 .append(quoteRequestUpdate, that.quoteRequestUpdate) 251 .isEquals(); 252 } 253 254 @Override 255 public int hashCode() { 256 return new HashCodeBuilder(17, 37).append(projectKey) 257 .append(associateId) 258 .append(businessUnitKey) 259 .append(key) 260 .append(quoteRequestUpdate) 261 .toHashCode(); 262 } 263 264 @Override 265 protected ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyQuoteRequestsKeyByKeyPostString copy() { 266 return new ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyQuoteRequestsKeyByKeyPostString( 267 this); 268 } 269}