-
Notifications
You must be signed in to change notification settings - Fork 15
/
ByProjectKeyCategoriesPost.java
188 lines (156 loc) · 6.47 KB
/
ByProjectKeyCategoriesPost.java
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
package com.commercetools.api.client;
import java.net.URI;
import java.time.Duration;
import java.util.ArrayList;
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 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>Either the scope <code>manage_products:{projectKey}</code> or <code>manage_categories:{projectKey}</code> is required.</p>
* <p>Creating a Category produces the CategoryCreated Message.</p>
*
* <hr>
* <div class=code-example>
* <pre><code class='java'>{@code
* CompletableFuture<ApiHttpResponse<com.commercetools.api.models.category.Category>> result = apiRoot
* .withProjectKey("{projectKey}")
* .categories()
* .post(null)
* .execute()
* }</code></pre>
* </div>
*/
@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen")
public class ByProjectKeyCategoriesPost extends
BodyApiMethod<ByProjectKeyCategoriesPost, com.commercetools.api.models.category.Category, com.commercetools.api.models.category.CategoryDraft>
implements com.commercetools.api.client.ExpandableTrait<ByProjectKeyCategoriesPost>,
com.commercetools.api.client.Deprecatable201Trait<ByProjectKeyCategoriesPost>,
com.commercetools.api.client.ErrorableTrait<ByProjectKeyCategoriesPost> {
private String projectKey;
private com.commercetools.api.models.category.CategoryDraft categoryDraft;
public ByProjectKeyCategoriesPost(final ApiHttpClient apiHttpClient, String projectKey,
com.commercetools.api.models.category.CategoryDraft categoryDraft) {
super(apiHttpClient);
this.projectKey = projectKey;
this.categoryDraft = categoryDraft;
}
public ByProjectKeyCategoriesPost(ByProjectKeyCategoriesPost t) {
super(t);
this.projectKey = t.projectKey;
this.categoryDraft = t.categoryDraft;
}
@Override
protected ApiHttpRequest buildHttpRequest() {
List<String> params = new ArrayList<>(getQueryParamUriStrings());
String httpRequestPath = String.format("/%s/categories", 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(categoryDraft)));
}
@Override
public ApiHttpResponse<com.commercetools.api.models.category.Category> executeBlocking(final ApiHttpClient client,
final Duration timeout) {
return executeBlocking(client, timeout, com.commercetools.api.models.category.Category.class);
}
@Override
public CompletableFuture<ApiHttpResponse<com.commercetools.api.models.category.Category>> execute(
final ApiHttpClient client) {
return execute(client, com.commercetools.api.models.category.Category.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
*/
public <TValue> ByProjectKeyCategoriesPost withExpand(final TValue expand) {
return copy().withQueryParam("expand", expand);
}
/**
* add additional expand query parameter
*/
public <TValue> ByProjectKeyCategoriesPost addExpand(final TValue expand) {
return copy().addQueryParam("expand", expand);
}
/**
* set expand with the specified value
*/
public ByProjectKeyCategoriesPost withExpand(final Supplier<String> supplier) {
return copy().withQueryParam("expand", supplier.get());
}
/**
* add additional expand query parameter
*/
public ByProjectKeyCategoriesPost addExpand(final Supplier<String> supplier) {
return copy().addQueryParam("expand", supplier.get());
}
/**
* set expand with the specified value
*/
public ByProjectKeyCategoriesPost withExpand(final Function<StringBuilder, StringBuilder> op) {
return copy().withQueryParam("expand", op.apply(new StringBuilder()));
}
/**
* add additional expand query parameter
*/
public ByProjectKeyCategoriesPost addExpand(final Function<StringBuilder, StringBuilder> op) {
return copy().addQueryParam("expand", op.apply(new StringBuilder()));
}
/**
* set expand with the specified values
*/
public <TValue> ByProjectKeyCategoriesPost withExpand(final List<TValue> expand) {
return copy().withoutQueryParam("expand")
.addQueryParams(
expand.stream().map(s -> new ParamEntry<>("expand", s.toString())).collect(Collectors.toList()));
}
/**
* add additional expand query parameters
*/
public <TValue> ByProjectKeyCategoriesPost addExpand(final List<TValue> expand) {
return copy().addQueryParams(
expand.stream().map(s -> new ParamEntry<>("expand", s.toString())).collect(Collectors.toList()));
}
public com.commercetools.api.models.category.CategoryDraft getBody() {
return categoryDraft;
}
public ByProjectKeyCategoriesPost withBody(com.commercetools.api.models.category.CategoryDraft categoryDraft) {
ByProjectKeyCategoriesPost t = copy();
t.categoryDraft = categoryDraft;
return t;
}
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
ByProjectKeyCategoriesPost that = (ByProjectKeyCategoriesPost) o;
return new EqualsBuilder().append(projectKey, that.projectKey)
.append(categoryDraft, that.categoryDraft)
.isEquals();
}
@Override
public int hashCode() {
return new HashCodeBuilder(17, 37).append(projectKey).append(categoryDraft).toHashCode();
}
@Override
protected ByProjectKeyCategoriesPost copy() {
return new ByProjectKeyCategoriesPost(this);
}
}