|
| 1 | + |
| 2 | +package com.commercetools.api.client; |
| 3 | + |
| 4 | +import java.net.URI; |
| 5 | +import java.time.Duration; |
| 6 | +import java.util.ArrayList; |
| 7 | +import java.util.Collection; |
| 8 | +import java.util.List; |
| 9 | +import java.util.concurrent.CompletableFuture; |
| 10 | +import java.util.function.Function; |
| 11 | +import java.util.function.Supplier; |
| 12 | +import java.util.stream.Collectors; |
| 13 | + |
| 14 | +import com.fasterxml.jackson.core.type.TypeReference; |
| 15 | + |
| 16 | +import io.vrap.rmf.base.client.*; |
| 17 | +import io.vrap.rmf.base.client.utils.Generated; |
| 18 | + |
| 19 | +import org.apache.commons.lang3.builder.EqualsBuilder; |
| 20 | +import org.apache.commons.lang3.builder.HashCodeBuilder; |
| 21 | + |
| 22 | +/** |
| 23 | + * <p>Deletes a Recurrence Policy in the Project.</p> |
| 24 | + * <p>A Recurrence Policy can be deleted only if it is not referenced by any Embedded Price, Standalone Price, or (Custom) Line Item, otherwise a ReferenceExists error is returned.</p> |
| 25 | + * |
| 26 | + * <hr> |
| 27 | + * <div class=code-example> |
| 28 | + * <pre><code class='java'>{@code |
| 29 | + * CompletableFuture<ApiHttpResponse<com.commercetools.api.models.recurrence_policy.RecurrencePolicy>> result = apiRoot |
| 30 | + * .withProjectKey("{projectKey}") |
| 31 | + * .recurrencePolicies() |
| 32 | + * .withId("{ID}") |
| 33 | + * .delete() |
| 34 | + * .withVersion(version) |
| 35 | + * .execute() |
| 36 | + * }</code></pre> |
| 37 | + * </div> |
| 38 | + */ |
| 39 | +@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen") |
| 40 | +public class ByProjectKeyRecurrencePoliciesByIDDelete extends |
| 41 | + TypeApiMethod<ByProjectKeyRecurrencePoliciesByIDDelete, com.commercetools.api.models.recurrence_policy.RecurrencePolicy> |
| 42 | + implements com.commercetools.api.client.VersionedTrait<ByProjectKeyRecurrencePoliciesByIDDelete>, |
| 43 | + com.commercetools.api.client.ConflictingTrait<ByProjectKeyRecurrencePoliciesByIDDelete>, |
| 44 | + com.commercetools.api.client.ExpandableTrait<ByProjectKeyRecurrencePoliciesByIDDelete>, |
| 45 | + com.commercetools.api.client.ErrorableTrait<ByProjectKeyRecurrencePoliciesByIDDelete>, |
| 46 | + com.commercetools.api.client.Deprecatable200Trait<ByProjectKeyRecurrencePoliciesByIDDelete> { |
| 47 | + |
| 48 | + @Override |
| 49 | + public TypeReference<com.commercetools.api.models.recurrence_policy.RecurrencePolicy> resultType() { |
| 50 | + return new TypeReference<com.commercetools.api.models.recurrence_policy.RecurrencePolicy>() { |
| 51 | + }; |
| 52 | + } |
| 53 | + |
| 54 | + private String projectKey; |
| 55 | + private String ID; |
| 56 | + |
| 57 | + public ByProjectKeyRecurrencePoliciesByIDDelete(final ApiHttpClient apiHttpClient, String projectKey, String ID) { |
| 58 | + super(apiHttpClient); |
| 59 | + this.projectKey = projectKey; |
| 60 | + this.ID = ID; |
| 61 | + } |
| 62 | + |
| 63 | + public ByProjectKeyRecurrencePoliciesByIDDelete(ByProjectKeyRecurrencePoliciesByIDDelete t) { |
| 64 | + super(t); |
| 65 | + this.projectKey = t.projectKey; |
| 66 | + this.ID = t.ID; |
| 67 | + } |
| 68 | + |
| 69 | + @Override |
| 70 | + protected ApiHttpRequest buildHttpRequest() { |
| 71 | + List<String> params = new ArrayList<>(getQueryParamUriStrings()); |
| 72 | + String httpRequestPath = String.format("%s/recurrence-policies/%s", encodePathParam(this.projectKey), |
| 73 | + encodePathParam(this.ID)); |
| 74 | + if (!params.isEmpty()) { |
| 75 | + httpRequestPath += "?" + String.join("&", params); |
| 76 | + } |
| 77 | + return new ApiHttpRequest(ApiHttpMethod.DELETE, URI.create(httpRequestPath), getHeaders(), null); |
| 78 | + } |
| 79 | + |
| 80 | + @Override |
| 81 | + public ApiHttpResponse<com.commercetools.api.models.recurrence_policy.RecurrencePolicy> executeBlocking( |
| 82 | + final ApiHttpClient client, final Duration timeout) { |
| 83 | + return executeBlocking(client, timeout, com.commercetools.api.models.recurrence_policy.RecurrencePolicy.class); |
| 84 | + } |
| 85 | + |
| 86 | + @Override |
| 87 | + public CompletableFuture<ApiHttpResponse<com.commercetools.api.models.recurrence_policy.RecurrencePolicy>> execute( |
| 88 | + final ApiHttpClient client) { |
| 89 | + return execute(client, com.commercetools.api.models.recurrence_policy.RecurrencePolicy.class); |
| 90 | + } |
| 91 | + |
| 92 | + public String getProjectKey() { |
| 93 | + return this.projectKey; |
| 94 | + } |
| 95 | + |
| 96 | + public String getID() { |
| 97 | + return this.ID; |
| 98 | + } |
| 99 | + |
| 100 | + public List<String> getVersion() { |
| 101 | + return this.getQueryParam("version"); |
| 102 | + } |
| 103 | + |
| 104 | + public List<String> getExpand() { |
| 105 | + return this.getQueryParam("expand"); |
| 106 | + } |
| 107 | + |
| 108 | + public void setProjectKey(final String projectKey) { |
| 109 | + this.projectKey = projectKey; |
| 110 | + } |
| 111 | + |
| 112 | + public void setID(final String ID) { |
| 113 | + this.ID = ID; |
| 114 | + } |
| 115 | + |
| 116 | + /** |
| 117 | + * set version with the specified value |
| 118 | + * @param version value to be set |
| 119 | + * @param <TValue> value type |
| 120 | + * @return ByProjectKeyRecurrencePoliciesByIDDelete |
| 121 | + */ |
| 122 | + public <TValue> ByProjectKeyRecurrencePoliciesByIDDelete withVersion(final TValue version) { |
| 123 | + return copy().withQueryParam("version", version); |
| 124 | + } |
| 125 | + |
| 126 | + /** |
| 127 | + * add additional version query parameter |
| 128 | + * @param version value to be added |
| 129 | + * @param <TValue> value type |
| 130 | + * @return ByProjectKeyRecurrencePoliciesByIDDelete |
| 131 | + */ |
| 132 | + public <TValue> ByProjectKeyRecurrencePoliciesByIDDelete addVersion(final TValue version) { |
| 133 | + return copy().addQueryParam("version", version); |
| 134 | + } |
| 135 | + |
| 136 | + /** |
| 137 | + * set version with the specified value |
| 138 | + * @param supplier supplier for the value to be set |
| 139 | + * @return ByProjectKeyRecurrencePoliciesByIDDelete |
| 140 | + */ |
| 141 | + public ByProjectKeyRecurrencePoliciesByIDDelete withVersion(final Supplier<Long> supplier) { |
| 142 | + return copy().withQueryParam("version", supplier.get()); |
| 143 | + } |
| 144 | + |
| 145 | + /** |
| 146 | + * add additional version query parameter |
| 147 | + * @param supplier supplier for the value to be added |
| 148 | + * @return ByProjectKeyRecurrencePoliciesByIDDelete |
| 149 | + */ |
| 150 | + public ByProjectKeyRecurrencePoliciesByIDDelete addVersion(final Supplier<Long> supplier) { |
| 151 | + return copy().addQueryParam("version", supplier.get()); |
| 152 | + } |
| 153 | + |
| 154 | + /** |
| 155 | + * set version with the specified value |
| 156 | + * @param op builder for the value to be set |
| 157 | + * @return ByProjectKeyRecurrencePoliciesByIDDelete |
| 158 | + */ |
| 159 | + public ByProjectKeyRecurrencePoliciesByIDDelete withVersion(final Function<StringBuilder, StringBuilder> op) { |
| 160 | + return copy().withQueryParam("version", op.apply(new StringBuilder())); |
| 161 | + } |
| 162 | + |
| 163 | + /** |
| 164 | + * add additional version query parameter |
| 165 | + * @param op builder for the value to be added |
| 166 | + * @return ByProjectKeyRecurrencePoliciesByIDDelete |
| 167 | + */ |
| 168 | + public ByProjectKeyRecurrencePoliciesByIDDelete addVersion(final Function<StringBuilder, StringBuilder> op) { |
| 169 | + return copy().addQueryParam("version", op.apply(new StringBuilder())); |
| 170 | + } |
| 171 | + |
| 172 | + /** |
| 173 | + * set version with the specified values |
| 174 | + * @param version values to be set |
| 175 | + * @param <TValue> value type |
| 176 | + * @return ByProjectKeyRecurrencePoliciesByIDDelete |
| 177 | + */ |
| 178 | + public <TValue> ByProjectKeyRecurrencePoliciesByIDDelete withVersion(final Collection<TValue> version) { |
| 179 | + return copy().withoutQueryParam("version") |
| 180 | + .addQueryParams( |
| 181 | + version.stream().map(s -> new ParamEntry<>("version", s.toString())).collect(Collectors.toList())); |
| 182 | + } |
| 183 | + |
| 184 | + /** |
| 185 | + * add additional version query parameters |
| 186 | + * @param version values to be added |
| 187 | + * @param <TValue> value type |
| 188 | + * @return ByProjectKeyRecurrencePoliciesByIDDelete |
| 189 | + */ |
| 190 | + public <TValue> ByProjectKeyRecurrencePoliciesByIDDelete addVersion(final Collection<TValue> version) { |
| 191 | + return copy().addQueryParams( |
| 192 | + version.stream().map(s -> new ParamEntry<>("version", s.toString())).collect(Collectors.toList())); |
| 193 | + } |
| 194 | + |
| 195 | + /** |
| 196 | + * set expand with the specified value |
| 197 | + * @param expand value to be set |
| 198 | + * @param <TValue> value type |
| 199 | + * @return ByProjectKeyRecurrencePoliciesByIDDelete |
| 200 | + */ |
| 201 | + public <TValue> ByProjectKeyRecurrencePoliciesByIDDelete withExpand(final TValue expand) { |
| 202 | + return copy().withQueryParam("expand", expand); |
| 203 | + } |
| 204 | + |
| 205 | + /** |
| 206 | + * add additional expand query parameter |
| 207 | + * @param expand value to be added |
| 208 | + * @param <TValue> value type |
| 209 | + * @return ByProjectKeyRecurrencePoliciesByIDDelete |
| 210 | + */ |
| 211 | + public <TValue> ByProjectKeyRecurrencePoliciesByIDDelete addExpand(final TValue expand) { |
| 212 | + return copy().addQueryParam("expand", expand); |
| 213 | + } |
| 214 | + |
| 215 | + /** |
| 216 | + * set expand with the specified value |
| 217 | + * @param supplier supplier for the value to be set |
| 218 | + * @return ByProjectKeyRecurrencePoliciesByIDDelete |
| 219 | + */ |
| 220 | + public ByProjectKeyRecurrencePoliciesByIDDelete withExpand(final Supplier<String> supplier) { |
| 221 | + return copy().withQueryParam("expand", supplier.get()); |
| 222 | + } |
| 223 | + |
| 224 | + /** |
| 225 | + * add additional expand query parameter |
| 226 | + * @param supplier supplier for the value to be added |
| 227 | + * @return ByProjectKeyRecurrencePoliciesByIDDelete |
| 228 | + */ |
| 229 | + public ByProjectKeyRecurrencePoliciesByIDDelete addExpand(final Supplier<String> supplier) { |
| 230 | + return copy().addQueryParam("expand", supplier.get()); |
| 231 | + } |
| 232 | + |
| 233 | + /** |
| 234 | + * set expand with the specified value |
| 235 | + * @param op builder for the value to be set |
| 236 | + * @return ByProjectKeyRecurrencePoliciesByIDDelete |
| 237 | + */ |
| 238 | + public ByProjectKeyRecurrencePoliciesByIDDelete withExpand(final Function<StringBuilder, StringBuilder> op) { |
| 239 | + return copy().withQueryParam("expand", op.apply(new StringBuilder())); |
| 240 | + } |
| 241 | + |
| 242 | + /** |
| 243 | + * add additional expand query parameter |
| 244 | + * @param op builder for the value to be added |
| 245 | + * @return ByProjectKeyRecurrencePoliciesByIDDelete |
| 246 | + */ |
| 247 | + public ByProjectKeyRecurrencePoliciesByIDDelete addExpand(final Function<StringBuilder, StringBuilder> op) { |
| 248 | + return copy().addQueryParam("expand", op.apply(new StringBuilder())); |
| 249 | + } |
| 250 | + |
| 251 | + /** |
| 252 | + * set expand with the specified values |
| 253 | + * @param expand values to be set |
| 254 | + * @param <TValue> value type |
| 255 | + * @return ByProjectKeyRecurrencePoliciesByIDDelete |
| 256 | + */ |
| 257 | + public <TValue> ByProjectKeyRecurrencePoliciesByIDDelete withExpand(final Collection<TValue> expand) { |
| 258 | + return copy().withoutQueryParam("expand") |
| 259 | + .addQueryParams( |
| 260 | + expand.stream().map(s -> new ParamEntry<>("expand", s.toString())).collect(Collectors.toList())); |
| 261 | + } |
| 262 | + |
| 263 | + /** |
| 264 | + * add additional expand query parameters |
| 265 | + * @param expand values to be added |
| 266 | + * @param <TValue> value type |
| 267 | + * @return ByProjectKeyRecurrencePoliciesByIDDelete |
| 268 | + */ |
| 269 | + public <TValue> ByProjectKeyRecurrencePoliciesByIDDelete addExpand(final Collection<TValue> expand) { |
| 270 | + return copy().addQueryParams( |
| 271 | + expand.stream().map(s -> new ParamEntry<>("expand", s.toString())).collect(Collectors.toList())); |
| 272 | + } |
| 273 | + |
| 274 | + @Override |
| 275 | + public boolean equals(Object o) { |
| 276 | + if (this == o) |
| 277 | + return true; |
| 278 | + |
| 279 | + if (o == null || getClass() != o.getClass()) |
| 280 | + return false; |
| 281 | + |
| 282 | + ByProjectKeyRecurrencePoliciesByIDDelete that = (ByProjectKeyRecurrencePoliciesByIDDelete) o; |
| 283 | + |
| 284 | + return new EqualsBuilder().append(projectKey, that.projectKey).append(ID, that.ID).isEquals(); |
| 285 | + } |
| 286 | + |
| 287 | + @Override |
| 288 | + public int hashCode() { |
| 289 | + return new HashCodeBuilder(17, 37).append(projectKey).append(ID).toHashCode(); |
| 290 | + } |
| 291 | + |
| 292 | + @Override |
| 293 | + protected ByProjectKeyRecurrencePoliciesByIDDelete copy() { |
| 294 | + return new ByProjectKeyRecurrencePoliciesByIDDelete(this); |
| 295 | + } |
| 296 | +} |
0 commit comments