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.cart_discount.CartDiscount>> result = apiRoot 027 * .withProjectKey("{projectKey}") 028 * .cartDiscounts() 029 * .withId("{ID}") 030 * .delete() 031 * .withVersion(version) 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 ByProjectKeyCartDiscountsByIDDelete 038 extends ApiMethod<ByProjectKeyCartDiscountsByIDDelete, com.commercetools.api.models.cart_discount.CartDiscount> 039 implements 040 com.commercetools.api.client.ApiDeleteMethod<ByProjectKeyCartDiscountsByIDDelete, com.commercetools.api.models.cart_discount.CartDiscount>, 041 com.commercetools.api.client.VersionedTrait<ByProjectKeyCartDiscountsByIDDelete>, 042 com.commercetools.api.client.ConflictingTrait<ByProjectKeyCartDiscountsByIDDelete>, 043 com.commercetools.api.client.ExpandableTrait<ByProjectKeyCartDiscountsByIDDelete>, 044 com.commercetools.api.client.ErrorableTrait<ByProjectKeyCartDiscountsByIDDelete>, 045 com.commercetools.api.client.Deprecatable200Trait<ByProjectKeyCartDiscountsByIDDelete> { 046 047 private String projectKey; 048 private String ID; 049 050 public ByProjectKeyCartDiscountsByIDDelete(final ApiHttpClient apiHttpClient, String projectKey, String ID) { 051 super(apiHttpClient); 052 this.projectKey = projectKey; 053 this.ID = ID; 054 } 055 056 public ByProjectKeyCartDiscountsByIDDelete(ByProjectKeyCartDiscountsByIDDelete t) { 057 super(t); 058 this.projectKey = t.projectKey; 059 this.ID = t.ID; 060 } 061 062 @Override 063 protected ApiHttpRequest buildHttpRequest() { 064 List<String> params = new ArrayList<>(getQueryParamUriStrings()); 065 String httpRequestPath = String.format("%s/cart-discounts/%s", this.projectKey, this.ID); 066 if (!params.isEmpty()) { 067 httpRequestPath += "?" + String.join("&", params); 068 } 069 return new ApiHttpRequest(ApiHttpMethod.DELETE, URI.create(httpRequestPath), getHeaders(), null); 070 } 071 072 @Override 073 public ApiHttpResponse<com.commercetools.api.models.cart_discount.CartDiscount> executeBlocking( 074 final ApiHttpClient client, final Duration timeout) { 075 return executeBlocking(client, timeout, com.commercetools.api.models.cart_discount.CartDiscount.class); 076 } 077 078 @Override 079 public CompletableFuture<ApiHttpResponse<com.commercetools.api.models.cart_discount.CartDiscount>> execute( 080 final ApiHttpClient client) { 081 return execute(client, com.commercetools.api.models.cart_discount.CartDiscount.class); 082 } 083 084 public String getProjectKey() { 085 return this.projectKey; 086 } 087 088 public String getID() { 089 return this.ID; 090 } 091 092 public List<String> getVersion() { 093 return this.getQueryParam("version"); 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 version with the specified value 110 * @param version value to be set 111 * @param <TValue> value type 112 * @return ByProjectKeyCartDiscountsByIDDelete 113 */ 114 public <TValue> ByProjectKeyCartDiscountsByIDDelete withVersion(final TValue version) { 115 return copy().withQueryParam("version", version); 116 } 117 118 /** 119 * add additional version query parameter 120 * @param version value to be added 121 * @param <TValue> value type 122 * @return ByProjectKeyCartDiscountsByIDDelete 123 */ 124 public <TValue> ByProjectKeyCartDiscountsByIDDelete addVersion(final TValue version) { 125 return copy().addQueryParam("version", version); 126 } 127 128 /** 129 * set version with the specified value 130 * @param supplier supplier for the value to be set 131 * @return ByProjectKeyCartDiscountsByIDDelete 132 */ 133 public ByProjectKeyCartDiscountsByIDDelete withVersion(final Supplier<Long> supplier) { 134 return copy().withQueryParam("version", supplier.get()); 135 } 136 137 /** 138 * add additional version query parameter 139 * @param supplier supplier for the value to be added 140 * @return ByProjectKeyCartDiscountsByIDDelete 141 */ 142 public ByProjectKeyCartDiscountsByIDDelete addVersion(final Supplier<Long> supplier) { 143 return copy().addQueryParam("version", supplier.get()); 144 } 145 146 /** 147 * set version with the specified value 148 * @param op builder for the value to be set 149 * @return ByProjectKeyCartDiscountsByIDDelete 150 */ 151 public ByProjectKeyCartDiscountsByIDDelete withVersion(final Function<StringBuilder, StringBuilder> op) { 152 return copy().withQueryParam("version", op.apply(new StringBuilder())); 153 } 154 155 /** 156 * add additional version query parameter 157 * @param op builder for the value to be added 158 * @return ByProjectKeyCartDiscountsByIDDelete 159 */ 160 public ByProjectKeyCartDiscountsByIDDelete addVersion(final Function<StringBuilder, StringBuilder> op) { 161 return copy().addQueryParam("version", op.apply(new StringBuilder())); 162 } 163 164 /** 165 * set version with the specified values 166 * @param version values to be set 167 * @param <TValue> value type 168 * @return ByProjectKeyCartDiscountsByIDDelete 169 */ 170 public <TValue> ByProjectKeyCartDiscountsByIDDelete withVersion(final Collection<TValue> version) { 171 return copy().withoutQueryParam("version") 172 .addQueryParams( 173 version.stream().map(s -> new ParamEntry<>("version", s.toString())).collect(Collectors.toList())); 174 } 175 176 /** 177 * add additional version query parameters 178 * @param version values to be added 179 * @param <TValue> value type 180 * @return ByProjectKeyCartDiscountsByIDDelete 181 */ 182 public <TValue> ByProjectKeyCartDiscountsByIDDelete addVersion(final Collection<TValue> version) { 183 return copy().addQueryParams( 184 version.stream().map(s -> new ParamEntry<>("version", s.toString())).collect(Collectors.toList())); 185 } 186 187 /** 188 * set expand with the specified value 189 * @param expand value to be set 190 * @param <TValue> value type 191 * @return ByProjectKeyCartDiscountsByIDDelete 192 */ 193 public <TValue> ByProjectKeyCartDiscountsByIDDelete withExpand(final TValue expand) { 194 return copy().withQueryParam("expand", expand); 195 } 196 197 /** 198 * add additional expand query parameter 199 * @param expand value to be added 200 * @param <TValue> value type 201 * @return ByProjectKeyCartDiscountsByIDDelete 202 */ 203 public <TValue> ByProjectKeyCartDiscountsByIDDelete addExpand(final TValue expand) { 204 return copy().addQueryParam("expand", expand); 205 } 206 207 /** 208 * set expand with the specified value 209 * @param supplier supplier for the value to be set 210 * @return ByProjectKeyCartDiscountsByIDDelete 211 */ 212 public ByProjectKeyCartDiscountsByIDDelete withExpand(final Supplier<String> supplier) { 213 return copy().withQueryParam("expand", supplier.get()); 214 } 215 216 /** 217 * add additional expand query parameter 218 * @param supplier supplier for the value to be added 219 * @return ByProjectKeyCartDiscountsByIDDelete 220 */ 221 public ByProjectKeyCartDiscountsByIDDelete addExpand(final Supplier<String> supplier) { 222 return copy().addQueryParam("expand", supplier.get()); 223 } 224 225 /** 226 * set expand with the specified value 227 * @param op builder for the value to be set 228 * @return ByProjectKeyCartDiscountsByIDDelete 229 */ 230 public ByProjectKeyCartDiscountsByIDDelete withExpand(final Function<StringBuilder, StringBuilder> op) { 231 return copy().withQueryParam("expand", op.apply(new StringBuilder())); 232 } 233 234 /** 235 * add additional expand query parameter 236 * @param op builder for the value to be added 237 * @return ByProjectKeyCartDiscountsByIDDelete 238 */ 239 public ByProjectKeyCartDiscountsByIDDelete addExpand(final Function<StringBuilder, StringBuilder> op) { 240 return copy().addQueryParam("expand", op.apply(new StringBuilder())); 241 } 242 243 /** 244 * set expand with the specified values 245 * @param expand values to be set 246 * @param <TValue> value type 247 * @return ByProjectKeyCartDiscountsByIDDelete 248 */ 249 public <TValue> ByProjectKeyCartDiscountsByIDDelete withExpand(final Collection<TValue> expand) { 250 return copy().withoutQueryParam("expand") 251 .addQueryParams( 252 expand.stream().map(s -> new ParamEntry<>("expand", s.toString())).collect(Collectors.toList())); 253 } 254 255 /** 256 * add additional expand query parameters 257 * @param expand values to be added 258 * @param <TValue> value type 259 * @return ByProjectKeyCartDiscountsByIDDelete 260 */ 261 public <TValue> ByProjectKeyCartDiscountsByIDDelete addExpand(final Collection<TValue> expand) { 262 return copy().addQueryParams( 263 expand.stream().map(s -> new ParamEntry<>("expand", s.toString())).collect(Collectors.toList())); 264 } 265 266 @Override 267 public boolean equals(Object o) { 268 if (this == o) 269 return true; 270 271 if (o == null || getClass() != o.getClass()) 272 return false; 273 274 ByProjectKeyCartDiscountsByIDDelete that = (ByProjectKeyCartDiscountsByIDDelete) o; 275 276 return new EqualsBuilder().append(projectKey, that.projectKey).append(ID, that.ID).isEquals(); 277 } 278 279 @Override 280 public int hashCode() { 281 return new HashCodeBuilder(17, 37).append(projectKey).append(ID).toHashCode(); 282 } 283 284 @Override 285 protected ByProjectKeyCartDiscountsByIDDelete copy() { 286 return new ByProjectKeyCartDiscountsByIDDelete(this); 287 } 288}