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