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