-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathByProjectKeyShippingMethodsPost.java
More file actions
217 lines (183 loc) · 7.87 KB
/
ByProjectKeyShippingMethodsPost.java
File metadata and controls
217 lines (183 loc) · 7.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
package com.commercetools.api.client;
import java.net.URI;
import java.time.Duration;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.function.Function;
import java.util.function.Supplier;
import java.util.stream.Collectors;
import com.fasterxml.jackson.core.type.TypeReference;
import io.vrap.rmf.base.client.*;
import io.vrap.rmf.base.client.utils.Generated;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
/**
* <p>Creates a ShippingMethod in the Project.</p>
*
* <hr>
* <div class=code-example>
* <pre><code class='java'>{@code
* CompletableFuture<ApiHttpResponse<com.commercetools.api.models.shipping_method.ShippingMethod>> result = apiRoot
* .withProjectKey("{projectKey}")
* .shippingMethods()
* .post(null)
* .execute()
* }</code></pre>
* </div>
*/
@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen")
public class ByProjectKeyShippingMethodsPost extends
TypeBodyApiMethod<ByProjectKeyShippingMethodsPost, com.commercetools.api.models.shipping_method.ShippingMethod, com.commercetools.api.models.shipping_method.ShippingMethodDraft>
implements com.commercetools.api.client.ExpandableTrait<ByProjectKeyShippingMethodsPost>,
com.commercetools.api.client.Deprecatable201Trait<ByProjectKeyShippingMethodsPost>,
com.commercetools.api.client.ErrorableTrait<ByProjectKeyShippingMethodsPost> {
@Override
public TypeReference<com.commercetools.api.models.shipping_method.ShippingMethod> resultType() {
return new TypeReference<com.commercetools.api.models.shipping_method.ShippingMethod>() {
};
}
private String projectKey;
private com.commercetools.api.models.shipping_method.ShippingMethodDraft shippingMethodDraft;
public ByProjectKeyShippingMethodsPost(final ApiHttpClient apiHttpClient, String projectKey,
com.commercetools.api.models.shipping_method.ShippingMethodDraft shippingMethodDraft) {
super(apiHttpClient);
this.projectKey = projectKey;
this.shippingMethodDraft = shippingMethodDraft;
}
public ByProjectKeyShippingMethodsPost(ByProjectKeyShippingMethodsPost t) {
super(t);
this.projectKey = t.projectKey;
this.shippingMethodDraft = t.shippingMethodDraft;
}
@Override
protected ApiHttpRequest buildHttpRequest() {
List<String> params = new ArrayList<>(getQueryParamUriStrings());
String httpRequestPath = String.format("%s/shipping-methods", encodePathParam(this.projectKey));
if (!params.isEmpty()) {
httpRequestPath += "?" + String.join("&", params);
}
return new ApiHttpRequest(ApiHttpMethod.POST, URI.create(httpRequestPath), getHeaders(),
io.vrap.rmf.base.client.utils.json.JsonUtils
.executing(() -> apiHttpClient().getSerializerService().toJsonByteArray(shippingMethodDraft)));
}
@Override
public ApiHttpResponse<com.commercetools.api.models.shipping_method.ShippingMethod> executeBlocking(
final ApiHttpClient client, final Duration timeout) {
return executeBlocking(client, timeout, com.commercetools.api.models.shipping_method.ShippingMethod.class);
}
@Override
public CompletableFuture<ApiHttpResponse<com.commercetools.api.models.shipping_method.ShippingMethod>> execute(
final ApiHttpClient client) {
return execute(client, com.commercetools.api.models.shipping_method.ShippingMethod.class);
}
public String getProjectKey() {
return this.projectKey;
}
public List<String> getExpand() {
return this.getQueryParam("expand");
}
public void setProjectKey(final String projectKey) {
this.projectKey = projectKey;
}
/**
* set expand with the specified value
* @param expand value to be set
* @param <TValue> value type
* @return ByProjectKeyShippingMethodsPost
*/
public <TValue> ByProjectKeyShippingMethodsPost withExpand(final TValue expand) {
return copy().withQueryParam("expand", expand);
}
/**
* add additional expand query parameter
* @param expand value to be added
* @param <TValue> value type
* @return ByProjectKeyShippingMethodsPost
*/
public <TValue> ByProjectKeyShippingMethodsPost addExpand(final TValue expand) {
return copy().addQueryParam("expand", expand);
}
/**
* set expand with the specified value
* @param supplier supplier for the value to be set
* @return ByProjectKeyShippingMethodsPost
*/
public ByProjectKeyShippingMethodsPost withExpand(final Supplier<String> supplier) {
return copy().withQueryParam("expand", supplier.get());
}
/**
* add additional expand query parameter
* @param supplier supplier for the value to be added
* @return ByProjectKeyShippingMethodsPost
*/
public ByProjectKeyShippingMethodsPost addExpand(final Supplier<String> supplier) {
return copy().addQueryParam("expand", supplier.get());
}
/**
* set expand with the specified value
* @param op builder for the value to be set
* @return ByProjectKeyShippingMethodsPost
*/
public ByProjectKeyShippingMethodsPost withExpand(final Function<StringBuilder, StringBuilder> op) {
return copy().withQueryParam("expand", op.apply(new StringBuilder()));
}
/**
* add additional expand query parameter
* @param op builder for the value to be added
* @return ByProjectKeyShippingMethodsPost
*/
public ByProjectKeyShippingMethodsPost addExpand(final Function<StringBuilder, StringBuilder> op) {
return copy().addQueryParam("expand", op.apply(new StringBuilder()));
}
/**
* set expand with the specified values
* @param expand values to be set
* @param <TValue> value type
* @return ByProjectKeyShippingMethodsPost
*/
public <TValue> ByProjectKeyShippingMethodsPost withExpand(final Collection<TValue> expand) {
return copy().withoutQueryParam("expand")
.addQueryParams(
expand.stream().map(s -> new ParamEntry<>("expand", s.toString())).collect(Collectors.toList()));
}
/**
* add additional expand query parameters
* @param expand values to be added
* @param <TValue> value type
* @return ByProjectKeyShippingMethodsPost
*/
public <TValue> ByProjectKeyShippingMethodsPost addExpand(final Collection<TValue> expand) {
return copy().addQueryParams(
expand.stream().map(s -> new ParamEntry<>("expand", s.toString())).collect(Collectors.toList()));
}
public com.commercetools.api.models.shipping_method.ShippingMethodDraft getBody() {
return shippingMethodDraft;
}
public ByProjectKeyShippingMethodsPost withBody(
com.commercetools.api.models.shipping_method.ShippingMethodDraft shippingMethodDraft) {
ByProjectKeyShippingMethodsPost t = copy();
t.shippingMethodDraft = shippingMethodDraft;
return t;
}
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
ByProjectKeyShippingMethodsPost that = (ByProjectKeyShippingMethodsPost) o;
return new EqualsBuilder().append(projectKey, that.projectKey)
.append(shippingMethodDraft, that.shippingMethodDraft)
.isEquals();
}
@Override
public int hashCode() {
return new HashCodeBuilder(17, 37).append(projectKey).append(shippingMethodDraft).toHashCode();
}
@Override
protected ByProjectKeyShippingMethodsPost copy() {
return new ByProjectKeyShippingMethodsPost(this);
}
}