001 002package com.commercetools.api.client; 003 004import java.net.URI; 005import java.nio.charset.StandardCharsets; 006import java.time.Duration; 007import java.util.ArrayList; 008import java.util.Collection; 009import java.util.List; 010import java.util.concurrent.CompletableFuture; 011import java.util.function.Function; 012import java.util.function.Supplier; 013import java.util.stream.Collectors; 014 015import io.vrap.rmf.base.client.*; 016import io.vrap.rmf.base.client.utils.Generated; 017 018import org.apache.commons.lang3.builder.EqualsBuilder; 019import org.apache.commons.lang3.builder.HashCodeBuilder; 020 021/** 022 * 023 * 024 * <hr> 025 * <div class=code-example> 026 * <pre><code class='java'>{@code 027 * CompletableFuture<ApiHttpResponse<com.commercetools.api.models.review.Review>> result = apiRoot 028 * .withProjectKey("{projectKey}") 029 * .reviews() 030 * .withId("{ID}") 031 * .post("") 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 ByProjectKeyReviewsByIDPostString 038 extends StringBodyApiMethod<ByProjectKeyReviewsByIDPostString, com.commercetools.api.models.review.Review> 039 implements com.commercetools.api.client.ConflictingTrait<ByProjectKeyReviewsByIDPostString>, 040 com.commercetools.api.client.ExpandableTrait<ByProjectKeyReviewsByIDPostString>, 041 com.commercetools.api.client.Deprecatable200Trait<ByProjectKeyReviewsByIDPostString>, 042 com.commercetools.api.client.ErrorableTrait<ByProjectKeyReviewsByIDPostString> { 043 044 private String projectKey; 045 private String ID; 046 047 private String reviewUpdate; 048 049 public ByProjectKeyReviewsByIDPostString(final ApiHttpClient apiHttpClient, String projectKey, String ID, 050 String reviewUpdate) { 051 super(apiHttpClient); 052 this.projectKey = projectKey; 053 this.ID = ID; 054 this.reviewUpdate = reviewUpdate; 055 } 056 057 public ByProjectKeyReviewsByIDPostString(ByProjectKeyReviewsByIDPostString t) { 058 super(t); 059 this.projectKey = t.projectKey; 060 this.ID = t.ID; 061 this.reviewUpdate = t.reviewUpdate; 062 } 063 064 @Override 065 protected ApiHttpRequest buildHttpRequest() { 066 List<String> params = new ArrayList<>(getQueryParamUriStrings()); 067 String httpRequestPath = String.format("%s/reviews/%s", this.projectKey, this.ID); 068 if (!params.isEmpty()) { 069 httpRequestPath += "?" + String.join("&", params); 070 } 071 return new ApiHttpRequest(ApiHttpMethod.POST, URI.create(httpRequestPath), getHeaders(), 072 reviewUpdate.getBytes(StandardCharsets.UTF_8)); 073 074 } 075 076 @Override 077 public ApiHttpResponse<com.commercetools.api.models.review.Review> executeBlocking(final ApiHttpClient client, 078 final Duration timeout) { 079 return executeBlocking(client, timeout, com.commercetools.api.models.review.Review.class); 080 } 081 082 @Override 083 public CompletableFuture<ApiHttpResponse<com.commercetools.api.models.review.Review>> execute( 084 final ApiHttpClient client) { 085 return execute(client, com.commercetools.api.models.review.Review.class); 086 } 087 088 public String getProjectKey() { 089 return this.projectKey; 090 } 091 092 public String getID() { 093 return this.ID; 094 } 095 096 public List<String> getExpand() { 097 return this.getQueryParam("expand"); 098 } 099 100 public void setProjectKey(final String projectKey) { 101 this.projectKey = projectKey; 102 } 103 104 public void setID(final String ID) { 105 this.ID = ID; 106 } 107 108 /** 109 * set expand with the specified value 110 * @param <TValue> value type 111 * @param expand value to be set 112 * @return ByProjectKeyReviewsByIDPostString 113 */ 114 public <TValue> ByProjectKeyReviewsByIDPostString withExpand(final TValue expand) { 115 return copy().withQueryParam("expand", expand); 116 } 117 118 /** 119 * add additional expand query parameter 120 * @param <TValue> value type 121 * @param expand value to be added 122 * @return ByProjectKeyReviewsByIDPostString 123 */ 124 public <TValue> ByProjectKeyReviewsByIDPostString addExpand(final TValue expand) { 125 return copy().addQueryParam("expand", expand); 126 } 127 128 /** 129 * set expand with the specified value 130 * @param supplier supplier for the value to be set 131 * @return ByProjectKeyReviewsByIDPostString 132 */ 133 public ByProjectKeyReviewsByIDPostString withExpand(final Supplier<String> supplier) { 134 return copy().withQueryParam("expand", supplier.get()); 135 } 136 137 /** 138 * add additional expand query parameter 139 * @param supplier supplier for the value to be added 140 * @return ByProjectKeyReviewsByIDPostString 141 */ 142 public ByProjectKeyReviewsByIDPostString addExpand(final Supplier<String> supplier) { 143 return copy().addQueryParam("expand", supplier.get()); 144 } 145 146 /** 147 * set expand with the specified value 148 * @param op builder for the value to be set 149 * @return ByProjectKeyReviewsByIDPostString 150 */ 151 public ByProjectKeyReviewsByIDPostString withExpand(final Function<StringBuilder, StringBuilder> op) { 152 return copy().withQueryParam("expand", op.apply(new StringBuilder())); 153 } 154 155 /** 156 * add additional expand query parameter 157 * @param op builder for the value to be added 158 * @return ByProjectKeyReviewsByIDPostString 159 */ 160 public ByProjectKeyReviewsByIDPostString addExpand(final Function<StringBuilder, StringBuilder> op) { 161 return copy().addQueryParam("expand", op.apply(new StringBuilder())); 162 } 163 164 /** 165 * set expand with the specified values 166 * @param <TValue> value type 167 * @param expand values to be set 168 * @return ByProjectKeyReviewsByIDPostString 169 */ 170 public <TValue> ByProjectKeyReviewsByIDPostString withExpand(final Collection<TValue> expand) { 171 return copy().withoutQueryParam("expand") 172 .addQueryParams( 173 expand.stream().map(s -> new ParamEntry<>("expand", s.toString())).collect(Collectors.toList())); 174 } 175 176 /** 177 * add additional expand query parameters 178 * @param <TValue> value type 179 * @param expand values to be added 180 * @return ByProjectKeyReviewsByIDPostString 181 */ 182 public <TValue> ByProjectKeyReviewsByIDPostString addExpand(final Collection<TValue> expand) { 183 return copy().addQueryParams( 184 expand.stream().map(s -> new ParamEntry<>("expand", s.toString())).collect(Collectors.toList())); 185 } 186 187 public String getBody() { 188 return reviewUpdate; 189 } 190 191 public ByProjectKeyReviewsByIDPostString withBody(String reviewUpdate) { 192 ByProjectKeyReviewsByIDPostString t = copy(); 193 t.reviewUpdate = reviewUpdate; 194 return t; 195 } 196 197 @Override 198 public boolean equals(Object o) { 199 if (this == o) 200 return true; 201 202 if (o == null || getClass() != o.getClass()) 203 return false; 204 205 ByProjectKeyReviewsByIDPostString that = (ByProjectKeyReviewsByIDPostString) o; 206 207 return new EqualsBuilder().append(projectKey, that.projectKey) 208 .append(ID, that.ID) 209 .append(reviewUpdate, that.reviewUpdate) 210 .isEquals(); 211 } 212 213 @Override 214 public int hashCode() { 215 return new HashCodeBuilder(17, 37).append(projectKey).append(ID).append(reviewUpdate).toHashCode(); 216 } 217 218 @Override 219 protected ByProjectKeyReviewsByIDPostString copy() { 220 return new ByProjectKeyReviewsByIDPostString(this); 221 } 222}