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.quote.Quote>> result = apiRoot 027 * .withProjectKey("{projectKey}") 028 * .quotes() 029 * .withId("{ID}") 030 * .post(null) 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 ByProjectKeyQuotesByIDPost extends 037 BodyApiMethod<ByProjectKeyQuotesByIDPost, com.commercetools.api.models.quote.Quote, com.commercetools.api.models.quote.QuoteUpdate> 038 implements com.commercetools.api.client.ConflictingTrait<ByProjectKeyQuotesByIDPost>, 039 com.commercetools.api.client.ExpandableTrait<ByProjectKeyQuotesByIDPost>, 040 com.commercetools.api.client.Deprecatable200Trait<ByProjectKeyQuotesByIDPost>, 041 com.commercetools.api.client.ErrorableTrait<ByProjectKeyQuotesByIDPost> { 042 043 private String projectKey; 044 private String ID; 045 046 private com.commercetools.api.models.quote.QuoteUpdate quoteUpdate; 047 048 public ByProjectKeyQuotesByIDPost(final ApiHttpClient apiHttpClient, String projectKey, String ID, 049 com.commercetools.api.models.quote.QuoteUpdate quoteUpdate) { 050 super(apiHttpClient); 051 this.projectKey = projectKey; 052 this.ID = ID; 053 this.quoteUpdate = quoteUpdate; 054 } 055 056 public ByProjectKeyQuotesByIDPost(ByProjectKeyQuotesByIDPost t) { 057 super(t); 058 this.projectKey = t.projectKey; 059 this.ID = t.ID; 060 this.quoteUpdate = t.quoteUpdate; 061 } 062 063 @Override 064 protected ApiHttpRequest buildHttpRequest() { 065 List<String> params = new ArrayList<>(getQueryParamUriStrings()); 066 String httpRequestPath = String.format("%s/quotes/%s", this.projectKey, this.ID); 067 if (!params.isEmpty()) { 068 httpRequestPath += "?" + String.join("&", params); 069 } 070 return new ApiHttpRequest(ApiHttpMethod.POST, URI.create(httpRequestPath), getHeaders(), 071 io.vrap.rmf.base.client.utils.json.JsonUtils 072 .executing(() -> apiHttpClient().getSerializerService().toJsonByteArray(quoteUpdate))); 073 074 } 075 076 @Override 077 public ApiHttpResponse<com.commercetools.api.models.quote.Quote> executeBlocking(final ApiHttpClient client, 078 final Duration timeout) { 079 return executeBlocking(client, timeout, com.commercetools.api.models.quote.Quote.class); 080 } 081 082 @Override 083 public CompletableFuture<ApiHttpResponse<com.commercetools.api.models.quote.Quote>> execute( 084 final ApiHttpClient client) { 085 return execute(client, com.commercetools.api.models.quote.Quote.class); 086 } 087 088 public String getProjectKey() { 089 return this.projectKey; 090 } 091 092 public String getID() { 093 return this.ID; 094 } 095 096 public List<String> getExpand() { 097 return this.getQueryParam("expand"); 098 } 099 100 public void setProjectKey(final String projectKey) { 101 this.projectKey = projectKey; 102 } 103 104 public void setID(final String ID) { 105 this.ID = ID; 106 } 107 108 /** 109 * set expand with the specified value 110 * @param expand value to be set 111 * @param <TValue> value type 112 * @return ByProjectKeyQuotesByIDPost 113 */ 114 public <TValue> ByProjectKeyQuotesByIDPost withExpand(final TValue expand) { 115 return copy().withQueryParam("expand", expand); 116 } 117 118 /** 119 * add additional expand query parameter 120 * @param expand value to be added 121 * @param <TValue> value type 122 * @return ByProjectKeyQuotesByIDPost 123 */ 124 public <TValue> ByProjectKeyQuotesByIDPost addExpand(final TValue expand) { 125 return copy().addQueryParam("expand", expand); 126 } 127 128 /** 129 * set expand with the specified value 130 * @param supplier supplier for the value to be set 131 * @return ByProjectKeyQuotesByIDPost 132 */ 133 public ByProjectKeyQuotesByIDPost withExpand(final Supplier<String> supplier) { 134 return copy().withQueryParam("expand", supplier.get()); 135 } 136 137 /** 138 * add additional expand query parameter 139 * @param supplier supplier for the value to be added 140 * @return ByProjectKeyQuotesByIDPost 141 */ 142 public ByProjectKeyQuotesByIDPost addExpand(final Supplier<String> supplier) { 143 return copy().addQueryParam("expand", supplier.get()); 144 } 145 146 /** 147 * set expand with the specified value 148 * @param op builder for the value to be set 149 * @return ByProjectKeyQuotesByIDPost 150 */ 151 public ByProjectKeyQuotesByIDPost withExpand(final Function<StringBuilder, StringBuilder> op) { 152 return copy().withQueryParam("expand", op.apply(new StringBuilder())); 153 } 154 155 /** 156 * add additional expand query parameter 157 * @param op builder for the value to be added 158 * @return ByProjectKeyQuotesByIDPost 159 */ 160 public ByProjectKeyQuotesByIDPost addExpand(final Function<StringBuilder, StringBuilder> op) { 161 return copy().addQueryParam("expand", op.apply(new StringBuilder())); 162 } 163 164 /** 165 * set expand with the specified values 166 * @param expand values to be set 167 * @param <TValue> value type 168 * @return ByProjectKeyQuotesByIDPost 169 */ 170 public <TValue> ByProjectKeyQuotesByIDPost withExpand(final Collection<TValue> expand) { 171 return copy().withoutQueryParam("expand") 172 .addQueryParams( 173 expand.stream().map(s -> new ParamEntry<>("expand", s.toString())).collect(Collectors.toList())); 174 } 175 176 /** 177 * add additional expand query parameters 178 * @param expand values to be added 179 * @param <TValue> value type 180 * @return ByProjectKeyQuotesByIDPost 181 */ 182 public <TValue> ByProjectKeyQuotesByIDPost addExpand(final Collection<TValue> expand) { 183 return copy().addQueryParams( 184 expand.stream().map(s -> new ParamEntry<>("expand", s.toString())).collect(Collectors.toList())); 185 } 186 187 public com.commercetools.api.models.quote.QuoteUpdate getBody() { 188 return quoteUpdate; 189 } 190 191 public ByProjectKeyQuotesByIDPost withBody(com.commercetools.api.models.quote.QuoteUpdate quoteUpdate) { 192 ByProjectKeyQuotesByIDPost t = copy(); 193 t.quoteUpdate = quoteUpdate; 194 return t; 195 } 196 197 @Override 198 public boolean equals(Object o) { 199 if (this == o) 200 return true; 201 202 if (o == null || getClass() != o.getClass()) 203 return false; 204 205 ByProjectKeyQuotesByIDPost that = (ByProjectKeyQuotesByIDPost) o; 206 207 return new EqualsBuilder().append(projectKey, that.projectKey) 208 .append(ID, that.ID) 209 .append(quoteUpdate, that.quoteUpdate) 210 .isEquals(); 211 } 212 213 @Override 214 public int hashCode() { 215 return new HashCodeBuilder(17, 37).append(projectKey).append(ID).append(quoteUpdate).toHashCode(); 216 } 217 218 @Override 219 protected ByProjectKeyQuotesByIDPost copy() { 220 return new ByProjectKeyQuotesByIDPost(this); 221 } 222}