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 * <p>Produces the InventoryEntryDeleted Message.</p> 022 * 023 * <hr> 024 * <div class=code-example> 025 * <pre><code class='java'>{@code 026 * CompletableFuture<ApiHttpResponse<com.commercetools.api.models.inventory.InventoryEntry>> result = apiRoot 027 * .withProjectKey("{projectKey}") 028 * .inventory() 029 * .withKey("{key}") 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 ByProjectKeyInventoryKeyByKeyDelete extends 038 ApiMethod<ByProjectKeyInventoryKeyByKeyDelete, com.commercetools.api.models.inventory.InventoryEntry> implements 039 com.commercetools.api.client.ApiDeleteMethod<ByProjectKeyInventoryKeyByKeyDelete, com.commercetools.api.models.inventory.InventoryEntry>, 040 com.commercetools.api.client.VersionedTrait<ByProjectKeyInventoryKeyByKeyDelete>, 041 com.commercetools.api.client.ConflictingTrait<ByProjectKeyInventoryKeyByKeyDelete>, 042 com.commercetools.api.client.ExpandableTrait<ByProjectKeyInventoryKeyByKeyDelete>, 043 com.commercetools.api.client.ErrorableTrait<ByProjectKeyInventoryKeyByKeyDelete>, 044 com.commercetools.api.client.Deprecatable200Trait<ByProjectKeyInventoryKeyByKeyDelete> { 045 046 private String projectKey; 047 private String key; 048 049 public ByProjectKeyInventoryKeyByKeyDelete(final ApiHttpClient apiHttpClient, String projectKey, String key) { 050 super(apiHttpClient); 051 this.projectKey = projectKey; 052 this.key = key; 053 } 054 055 public ByProjectKeyInventoryKeyByKeyDelete(ByProjectKeyInventoryKeyByKeyDelete t) { 056 super(t); 057 this.projectKey = t.projectKey; 058 this.key = t.key; 059 } 060 061 @Override 062 protected ApiHttpRequest buildHttpRequest() { 063 List<String> params = new ArrayList<>(getQueryParamUriStrings()); 064 String httpRequestPath = String.format("%s/inventory/key=%s", this.projectKey, this.key); 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.inventory.InventoryEntry> executeBlocking( 073 final ApiHttpClient client, final Duration timeout) { 074 return executeBlocking(client, timeout, com.commercetools.api.models.inventory.InventoryEntry.class); 075 } 076 077 @Override 078 public CompletableFuture<ApiHttpResponse<com.commercetools.api.models.inventory.InventoryEntry>> execute( 079 final ApiHttpClient client) { 080 return execute(client, com.commercetools.api.models.inventory.InventoryEntry.class); 081 } 082 083 public String getProjectKey() { 084 return this.projectKey; 085 } 086 087 public String getKey() { 088 return this.key; 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 setKey(final String key) { 104 this.key = key; 105 } 106 107 /** 108 * set version with the specified value 109 * @param version value to be set 110 * @param <TValue> value type 111 * @return ByProjectKeyInventoryKeyByKeyDelete 112 */ 113 public <TValue> ByProjectKeyInventoryKeyByKeyDelete 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 ByProjectKeyInventoryKeyByKeyDelete 122 */ 123 public <TValue> ByProjectKeyInventoryKeyByKeyDelete 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 ByProjectKeyInventoryKeyByKeyDelete 131 */ 132 public ByProjectKeyInventoryKeyByKeyDelete 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 ByProjectKeyInventoryKeyByKeyDelete 140 */ 141 public ByProjectKeyInventoryKeyByKeyDelete 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 ByProjectKeyInventoryKeyByKeyDelete 149 */ 150 public ByProjectKeyInventoryKeyByKeyDelete 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 ByProjectKeyInventoryKeyByKeyDelete 158 */ 159 public ByProjectKeyInventoryKeyByKeyDelete 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 ByProjectKeyInventoryKeyByKeyDelete 168 */ 169 public <TValue> ByProjectKeyInventoryKeyByKeyDelete 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 ByProjectKeyInventoryKeyByKeyDelete 180 */ 181 public <TValue> ByProjectKeyInventoryKeyByKeyDelete 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 ByProjectKeyInventoryKeyByKeyDelete 191 */ 192 public <TValue> ByProjectKeyInventoryKeyByKeyDelete 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 ByProjectKeyInventoryKeyByKeyDelete 201 */ 202 public <TValue> ByProjectKeyInventoryKeyByKeyDelete 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 ByProjectKeyInventoryKeyByKeyDelete 210 */ 211 public ByProjectKeyInventoryKeyByKeyDelete 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 ByProjectKeyInventoryKeyByKeyDelete 219 */ 220 public ByProjectKeyInventoryKeyByKeyDelete 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 ByProjectKeyInventoryKeyByKeyDelete 228 */ 229 public ByProjectKeyInventoryKeyByKeyDelete 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 ByProjectKeyInventoryKeyByKeyDelete 237 */ 238 public ByProjectKeyInventoryKeyByKeyDelete 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 ByProjectKeyInventoryKeyByKeyDelete 247 */ 248 public <TValue> ByProjectKeyInventoryKeyByKeyDelete 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 ByProjectKeyInventoryKeyByKeyDelete 259 */ 260 public <TValue> ByProjectKeyInventoryKeyByKeyDelete 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 ByProjectKeyInventoryKeyByKeyDelete that = (ByProjectKeyInventoryKeyByKeyDelete) o; 274 275 return new EqualsBuilder().append(projectKey, that.projectKey).append(key, that.key).isEquals(); 276 } 277 278 @Override 279 public int hashCode() { 280 return new HashCodeBuilder(17, 37).append(projectKey).append(key).toHashCode(); 281 } 282 283 @Override 284 protected ByProjectKeyInventoryKeyByKeyDelete copy() { 285 return new ByProjectKeyInventoryKeyByKeyDelete(this); 286 } 287}