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 * .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 ByProjectKeyOrdersEditsKeyByKeyPost extends 038 BodyApiMethod<ByProjectKeyOrdersEditsKeyByKeyPost, com.commercetools.api.models.order_edit.OrderEdit, com.commercetools.api.models.order_edit.OrderEditUpdate> 039 implements com.commercetools.api.client.ConflictingTrait<ByProjectKeyOrdersEditsKeyByKeyPost>, 040 com.commercetools.api.client.ExpandableTrait<ByProjectKeyOrdersEditsKeyByKeyPost>, 041 com.commercetools.api.client.Deprecatable200Trait<ByProjectKeyOrdersEditsKeyByKeyPost>, 042 com.commercetools.api.client.ErrorableTrait<ByProjectKeyOrdersEditsKeyByKeyPost> { 043 044 private String projectKey; 045 private String key; 046 047 private com.commercetools.api.models.order_edit.OrderEditUpdate orderEditUpdate; 048 049 public ByProjectKeyOrdersEditsKeyByKeyPost(final ApiHttpClient apiHttpClient, String projectKey, String key, 050 com.commercetools.api.models.order_edit.OrderEditUpdate orderEditUpdate) { 051 super(apiHttpClient); 052 this.projectKey = projectKey; 053 this.key = key; 054 this.orderEditUpdate = orderEditUpdate; 055 } 056 057 public ByProjectKeyOrdersEditsKeyByKeyPost(ByProjectKeyOrdersEditsKeyByKeyPost t) { 058 super(t); 059 this.projectKey = t.projectKey; 060 this.key = t.key; 061 this.orderEditUpdate = t.orderEditUpdate; 062 } 063 064 @Override 065 protected ApiHttpRequest buildHttpRequest() { 066 List<String> params = new ArrayList<>(getQueryParamUriStrings()); 067 String httpRequestPath = String.format("%s/orders/edits/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(orderEditUpdate))); 074 075 } 076 077 @Override 078 public ApiHttpResponse<com.commercetools.api.models.order_edit.OrderEdit> executeBlocking( 079 final ApiHttpClient client, final Duration timeout) { 080 return executeBlocking(client, timeout, com.commercetools.api.models.order_edit.OrderEdit.class); 081 } 082 083 @Override 084 public CompletableFuture<ApiHttpResponse<com.commercetools.api.models.order_edit.OrderEdit>> execute( 085 final ApiHttpClient client) { 086 return execute(client, com.commercetools.api.models.order_edit.OrderEdit.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 ByProjectKeyOrdersEditsKeyByKeyPost 114 */ 115 public <TValue> ByProjectKeyOrdersEditsKeyByKeyPost 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 ByProjectKeyOrdersEditsKeyByKeyPost 124 */ 125 public <TValue> ByProjectKeyOrdersEditsKeyByKeyPost 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 ByProjectKeyOrdersEditsKeyByKeyPost 133 */ 134 public ByProjectKeyOrdersEditsKeyByKeyPost 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 ByProjectKeyOrdersEditsKeyByKeyPost 142 */ 143 public ByProjectKeyOrdersEditsKeyByKeyPost 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 ByProjectKeyOrdersEditsKeyByKeyPost 151 */ 152 public ByProjectKeyOrdersEditsKeyByKeyPost 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 ByProjectKeyOrdersEditsKeyByKeyPost 160 */ 161 public ByProjectKeyOrdersEditsKeyByKeyPost 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 ByProjectKeyOrdersEditsKeyByKeyPost 170 */ 171 public <TValue> ByProjectKeyOrdersEditsKeyByKeyPost 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 ByProjectKeyOrdersEditsKeyByKeyPost 182 */ 183 public <TValue> ByProjectKeyOrdersEditsKeyByKeyPost 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.order_edit.OrderEditUpdate getBody() { 189 return orderEditUpdate; 190 } 191 192 public ByProjectKeyOrdersEditsKeyByKeyPost withBody( 193 com.commercetools.api.models.order_edit.OrderEditUpdate orderEditUpdate) { 194 ByProjectKeyOrdersEditsKeyByKeyPost t = copy(); 195 t.orderEditUpdate = orderEditUpdate; 196 return t; 197 } 198 199 @Override 200 public boolean equals(Object o) { 201 if (this == o) 202 return true; 203 204 if (o == null || getClass() != o.getClass()) 205 return false; 206 207 ByProjectKeyOrdersEditsKeyByKeyPost that = (ByProjectKeyOrdersEditsKeyByKeyPost) o; 208 209 return new EqualsBuilder().append(projectKey, that.projectKey) 210 .append(key, that.key) 211 .append(orderEditUpdate, that.orderEditUpdate) 212 .isEquals(); 213 } 214 215 @Override 216 public int hashCode() { 217 return new HashCodeBuilder(17, 37).append(projectKey).append(key).append(orderEditUpdate).toHashCode(); 218 } 219 220 @Override 221 protected ByProjectKeyOrdersEditsKeyByKeyPost copy() { 222 return new ByProjectKeyOrdersEditsKeyByKeyPost(this); 223 } 224}