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.business_unit.BusinessUnit>> result = apiRoot 027 * .withProjectKey("{projectKey}") 028 * .asAssociate() 029 * .withAssociateIdValue("{associateId}") 030 * .businessUnits() 031 * .withId("{ID}") 032 * .post(null) 033 * .execute() 034 * }</code></pre> 035 * </div> 036 */ 037@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen") 038public class ByProjectKeyAsAssociateByAssociateIdBusinessUnitsByIDPost extends 039 BodyApiMethod<ByProjectKeyAsAssociateByAssociateIdBusinessUnitsByIDPost, com.commercetools.api.models.business_unit.BusinessUnit, com.commercetools.api.models.business_unit.BusinessUnitUpdate> 040 implements 041 com.commercetools.api.client.ConflictingTrait<ByProjectKeyAsAssociateByAssociateIdBusinessUnitsByIDPost>, 042 com.commercetools.api.client.ExpandableTrait<ByProjectKeyAsAssociateByAssociateIdBusinessUnitsByIDPost>, 043 com.commercetools.api.client.Deprecatable200Trait<ByProjectKeyAsAssociateByAssociateIdBusinessUnitsByIDPost>, 044 com.commercetools.api.client.ErrorableTrait<ByProjectKeyAsAssociateByAssociateIdBusinessUnitsByIDPost> { 045 046 private String projectKey; 047 private String associateId; 048 private String ID; 049 050 private com.commercetools.api.models.business_unit.BusinessUnitUpdate businessUnitUpdate; 051 052 public ByProjectKeyAsAssociateByAssociateIdBusinessUnitsByIDPost(final ApiHttpClient apiHttpClient, 053 String projectKey, String associateId, String ID, 054 com.commercetools.api.models.business_unit.BusinessUnitUpdate businessUnitUpdate) { 055 super(apiHttpClient); 056 this.projectKey = projectKey; 057 this.associateId = associateId; 058 this.ID = ID; 059 this.businessUnitUpdate = businessUnitUpdate; 060 } 061 062 public ByProjectKeyAsAssociateByAssociateIdBusinessUnitsByIDPost( 063 ByProjectKeyAsAssociateByAssociateIdBusinessUnitsByIDPost t) { 064 super(t); 065 this.projectKey = t.projectKey; 066 this.associateId = t.associateId; 067 this.ID = t.ID; 068 this.businessUnitUpdate = t.businessUnitUpdate; 069 } 070 071 @Override 072 protected ApiHttpRequest buildHttpRequest() { 073 List<String> params = new ArrayList<>(getQueryParamUriStrings()); 074 String httpRequestPath = String.format("%s/as-associate/%s/business-units/%s", this.projectKey, 075 this.associateId, this.ID); 076 if (!params.isEmpty()) { 077 httpRequestPath += "?" + String.join("&", params); 078 } 079 return new ApiHttpRequest(ApiHttpMethod.POST, URI.create(httpRequestPath), getHeaders(), 080 io.vrap.rmf.base.client.utils.json.JsonUtils 081 .executing(() -> apiHttpClient().getSerializerService().toJsonByteArray(businessUnitUpdate))); 082 083 } 084 085 @Override 086 public ApiHttpResponse<com.commercetools.api.models.business_unit.BusinessUnit> executeBlocking( 087 final ApiHttpClient client, final Duration timeout) { 088 return executeBlocking(client, timeout, com.commercetools.api.models.business_unit.BusinessUnit.class); 089 } 090 091 @Override 092 public CompletableFuture<ApiHttpResponse<com.commercetools.api.models.business_unit.BusinessUnit>> execute( 093 final ApiHttpClient client) { 094 return execute(client, com.commercetools.api.models.business_unit.BusinessUnit.class); 095 } 096 097 public String getProjectKey() { 098 return this.projectKey; 099 } 100 101 public String getAssociateId() { 102 return this.associateId; 103 } 104 105 public String getID() { 106 return this.ID; 107 } 108 109 public List<String> getExpand() { 110 return this.getQueryParam("expand"); 111 } 112 113 public void setProjectKey(final String projectKey) { 114 this.projectKey = projectKey; 115 } 116 117 public void setAssociateId(final String associateId) { 118 this.associateId = associateId; 119 } 120 121 public void setID(final String ID) { 122 this.ID = ID; 123 } 124 125 /** 126 * set expand with the specified value 127 * @param expand value to be set 128 * @param <TValue> value type 129 * @return ByProjectKeyAsAssociateByAssociateIdBusinessUnitsByIDPost 130 */ 131 public <TValue> ByProjectKeyAsAssociateByAssociateIdBusinessUnitsByIDPost withExpand(final TValue expand) { 132 return copy().withQueryParam("expand", expand); 133 } 134 135 /** 136 * add additional expand query parameter 137 * @param expand value to be added 138 * @param <TValue> value type 139 * @return ByProjectKeyAsAssociateByAssociateIdBusinessUnitsByIDPost 140 */ 141 public <TValue> ByProjectKeyAsAssociateByAssociateIdBusinessUnitsByIDPost addExpand(final TValue expand) { 142 return copy().addQueryParam("expand", expand); 143 } 144 145 /** 146 * set expand with the specified value 147 * @param supplier supplier for the value to be set 148 * @return ByProjectKeyAsAssociateByAssociateIdBusinessUnitsByIDPost 149 */ 150 public ByProjectKeyAsAssociateByAssociateIdBusinessUnitsByIDPost withExpand(final Supplier<String> supplier) { 151 return copy().withQueryParam("expand", supplier.get()); 152 } 153 154 /** 155 * add additional expand query parameter 156 * @param supplier supplier for the value to be added 157 * @return ByProjectKeyAsAssociateByAssociateIdBusinessUnitsByIDPost 158 */ 159 public ByProjectKeyAsAssociateByAssociateIdBusinessUnitsByIDPost addExpand(final Supplier<String> supplier) { 160 return copy().addQueryParam("expand", supplier.get()); 161 } 162 163 /** 164 * set expand with the specified value 165 * @param op builder for the value to be set 166 * @return ByProjectKeyAsAssociateByAssociateIdBusinessUnitsByIDPost 167 */ 168 public ByProjectKeyAsAssociateByAssociateIdBusinessUnitsByIDPost withExpand( 169 final Function<StringBuilder, StringBuilder> op) { 170 return copy().withQueryParam("expand", op.apply(new StringBuilder())); 171 } 172 173 /** 174 * add additional expand query parameter 175 * @param op builder for the value to be added 176 * @return ByProjectKeyAsAssociateByAssociateIdBusinessUnitsByIDPost 177 */ 178 public ByProjectKeyAsAssociateByAssociateIdBusinessUnitsByIDPost addExpand( 179 final Function<StringBuilder, StringBuilder> op) { 180 return copy().addQueryParam("expand", op.apply(new StringBuilder())); 181 } 182 183 /** 184 * set expand with the specified values 185 * @param expand values to be set 186 * @param <TValue> value type 187 * @return ByProjectKeyAsAssociateByAssociateIdBusinessUnitsByIDPost 188 */ 189 public <TValue> ByProjectKeyAsAssociateByAssociateIdBusinessUnitsByIDPost withExpand( 190 final Collection<TValue> expand) { 191 return copy().withoutQueryParam("expand") 192 .addQueryParams( 193 expand.stream().map(s -> new ParamEntry<>("expand", s.toString())).collect(Collectors.toList())); 194 } 195 196 /** 197 * add additional expand query parameters 198 * @param expand values to be added 199 * @param <TValue> value type 200 * @return ByProjectKeyAsAssociateByAssociateIdBusinessUnitsByIDPost 201 */ 202 public <TValue> ByProjectKeyAsAssociateByAssociateIdBusinessUnitsByIDPost addExpand( 203 final Collection<TValue> expand) { 204 return copy().addQueryParams( 205 expand.stream().map(s -> new ParamEntry<>("expand", s.toString())).collect(Collectors.toList())); 206 } 207 208 public com.commercetools.api.models.business_unit.BusinessUnitUpdate getBody() { 209 return businessUnitUpdate; 210 } 211 212 public ByProjectKeyAsAssociateByAssociateIdBusinessUnitsByIDPost withBody( 213 com.commercetools.api.models.business_unit.BusinessUnitUpdate businessUnitUpdate) { 214 ByProjectKeyAsAssociateByAssociateIdBusinessUnitsByIDPost t = copy(); 215 t.businessUnitUpdate = businessUnitUpdate; 216 return t; 217 } 218 219 @Override 220 public boolean equals(Object o) { 221 if (this == o) 222 return true; 223 224 if (o == null || getClass() != o.getClass()) 225 return false; 226 227 ByProjectKeyAsAssociateByAssociateIdBusinessUnitsByIDPost that = (ByProjectKeyAsAssociateByAssociateIdBusinessUnitsByIDPost) o; 228 229 return new EqualsBuilder().append(projectKey, that.projectKey) 230 .append(associateId, that.associateId) 231 .append(ID, that.ID) 232 .append(businessUnitUpdate, that.businessUnitUpdate) 233 .isEquals(); 234 } 235 236 @Override 237 public int hashCode() { 238 return new HashCodeBuilder(17, 37).append(projectKey) 239 .append(associateId) 240 .append(ID) 241 .append(businessUnitUpdate) 242 .toHashCode(); 243 } 244 245 @Override 246 protected ByProjectKeyAsAssociateByAssociateIdBusinessUnitsByIDPost copy() { 247 return new ByProjectKeyAsAssociateByAssociateIdBusinessUnitsByIDPost(this); 248 } 249}