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 * .get() 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 ByProjectKeyAsAssociateByAssociateIdBusinessUnitsByIDGet extends 039 ApiMethod<ByProjectKeyAsAssociateByAssociateIdBusinessUnitsByIDGet, com.commercetools.api.models.business_unit.BusinessUnit> 040 implements 041 com.commercetools.api.client.ExpandableTrait<ByProjectKeyAsAssociateByAssociateIdBusinessUnitsByIDGet>, 042 com.commercetools.api.client.ErrorableTrait<ByProjectKeyAsAssociateByAssociateIdBusinessUnitsByIDGet>, 043 com.commercetools.api.client.Deprecatable200Trait<ByProjectKeyAsAssociateByAssociateIdBusinessUnitsByIDGet> { 044 045 private String projectKey; 046 private String associateId; 047 private String ID; 048 049 public ByProjectKeyAsAssociateByAssociateIdBusinessUnitsByIDGet(final ApiHttpClient apiHttpClient, 050 String projectKey, String associateId, String ID) { 051 super(apiHttpClient); 052 this.projectKey = projectKey; 053 this.associateId = associateId; 054 this.ID = ID; 055 } 056 057 public ByProjectKeyAsAssociateByAssociateIdBusinessUnitsByIDGet( 058 ByProjectKeyAsAssociateByAssociateIdBusinessUnitsByIDGet t) { 059 super(t); 060 this.projectKey = t.projectKey; 061 this.associateId = t.associateId; 062 this.ID = t.ID; 063 } 064 065 @Override 066 protected ApiHttpRequest buildHttpRequest() { 067 List<String> params = new ArrayList<>(getQueryParamUriStrings()); 068 String httpRequestPath = String.format("%s/as-associate/%s/business-units/%s", this.projectKey, 069 this.associateId, this.ID); 070 if (!params.isEmpty()) { 071 httpRequestPath += "?" + String.join("&", params); 072 } 073 return new ApiHttpRequest(ApiHttpMethod.GET, URI.create(httpRequestPath), getHeaders(), null); 074 } 075 076 @Override 077 public ApiHttpResponse<com.commercetools.api.models.business_unit.BusinessUnit> executeBlocking( 078 final ApiHttpClient client, final Duration timeout) { 079 return executeBlocking(client, timeout, com.commercetools.api.models.business_unit.BusinessUnit.class); 080 } 081 082 @Override 083 public CompletableFuture<ApiHttpResponse<com.commercetools.api.models.business_unit.BusinessUnit>> execute( 084 final ApiHttpClient client) { 085 return execute(client, com.commercetools.api.models.business_unit.BusinessUnit.class); 086 } 087 088 public String getProjectKey() { 089 return this.projectKey; 090 } 091 092 public String getAssociateId() { 093 return this.associateId; 094 } 095 096 public String getID() { 097 return this.ID; 098 } 099 100 public List<String> getExpand() { 101 return this.getQueryParam("expand"); 102 } 103 104 public void setProjectKey(final String projectKey) { 105 this.projectKey = projectKey; 106 } 107 108 public void setAssociateId(final String associateId) { 109 this.associateId = associateId; 110 } 111 112 public void setID(final String ID) { 113 this.ID = ID; 114 } 115 116 /** 117 * set expand with the specified value 118 * @param expand value to be set 119 * @param <TValue> value type 120 * @return ByProjectKeyAsAssociateByAssociateIdBusinessUnitsByIDGet 121 */ 122 public <TValue> ByProjectKeyAsAssociateByAssociateIdBusinessUnitsByIDGet withExpand(final TValue expand) { 123 return copy().withQueryParam("expand", expand); 124 } 125 126 /** 127 * add additional expand query parameter 128 * @param expand value to be added 129 * @param <TValue> value type 130 * @return ByProjectKeyAsAssociateByAssociateIdBusinessUnitsByIDGet 131 */ 132 public <TValue> ByProjectKeyAsAssociateByAssociateIdBusinessUnitsByIDGet addExpand(final TValue expand) { 133 return copy().addQueryParam("expand", expand); 134 } 135 136 /** 137 * set expand with the specified value 138 * @param supplier supplier for the value to be set 139 * @return ByProjectKeyAsAssociateByAssociateIdBusinessUnitsByIDGet 140 */ 141 public ByProjectKeyAsAssociateByAssociateIdBusinessUnitsByIDGet withExpand(final Supplier<String> supplier) { 142 return copy().withQueryParam("expand", supplier.get()); 143 } 144 145 /** 146 * add additional expand query parameter 147 * @param supplier supplier for the value to be added 148 * @return ByProjectKeyAsAssociateByAssociateIdBusinessUnitsByIDGet 149 */ 150 public ByProjectKeyAsAssociateByAssociateIdBusinessUnitsByIDGet addExpand(final Supplier<String> supplier) { 151 return copy().addQueryParam("expand", supplier.get()); 152 } 153 154 /** 155 * set expand with the specified value 156 * @param op builder for the value to be set 157 * @return ByProjectKeyAsAssociateByAssociateIdBusinessUnitsByIDGet 158 */ 159 public ByProjectKeyAsAssociateByAssociateIdBusinessUnitsByIDGet withExpand( 160 final Function<StringBuilder, StringBuilder> op) { 161 return copy().withQueryParam("expand", op.apply(new StringBuilder())); 162 } 163 164 /** 165 * add additional expand query parameter 166 * @param op builder for the value to be added 167 * @return ByProjectKeyAsAssociateByAssociateIdBusinessUnitsByIDGet 168 */ 169 public ByProjectKeyAsAssociateByAssociateIdBusinessUnitsByIDGet addExpand( 170 final Function<StringBuilder, StringBuilder> op) { 171 return copy().addQueryParam("expand", op.apply(new StringBuilder())); 172 } 173 174 /** 175 * set expand with the specified values 176 * @param expand values to be set 177 * @param <TValue> value type 178 * @return ByProjectKeyAsAssociateByAssociateIdBusinessUnitsByIDGet 179 */ 180 public <TValue> ByProjectKeyAsAssociateByAssociateIdBusinessUnitsByIDGet withExpand( 181 final Collection<TValue> expand) { 182 return copy().withoutQueryParam("expand") 183 .addQueryParams( 184 expand.stream().map(s -> new ParamEntry<>("expand", s.toString())).collect(Collectors.toList())); 185 } 186 187 /** 188 * add additional expand query parameters 189 * @param expand values to be added 190 * @param <TValue> value type 191 * @return ByProjectKeyAsAssociateByAssociateIdBusinessUnitsByIDGet 192 */ 193 public <TValue> ByProjectKeyAsAssociateByAssociateIdBusinessUnitsByIDGet addExpand( 194 final Collection<TValue> expand) { 195 return copy().addQueryParams( 196 expand.stream().map(s -> new ParamEntry<>("expand", s.toString())).collect(Collectors.toList())); 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 ByProjectKeyAsAssociateByAssociateIdBusinessUnitsByIDGet that = (ByProjectKeyAsAssociateByAssociateIdBusinessUnitsByIDGet) o; 208 209 return new EqualsBuilder().append(projectKey, that.projectKey) 210 .append(associateId, that.associateId) 211 .append(ID, that.ID) 212 .isEquals(); 213 } 214 215 @Override 216 public int hashCode() { 217 return new HashCodeBuilder(17, 37).append(projectKey).append(associateId).append(ID).toHashCode(); 218 } 219 220 @Override 221 protected ByProjectKeyAsAssociateByAssociateIdBusinessUnitsByIDGet copy() { 222 return new ByProjectKeyAsAssociateByAssociateIdBusinessUnitsByIDGet(this); 223 } 224}