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 * <p>If the Order exists in the Project but does not have the <code>store</code> field, or the <code>store</code> field references a different Store, this method returns a ResourceNotFound error.</p> 022 * 023 * <hr> 024 * <div class=code-example> 025 * <pre><code class='java'>{@code 026 * CompletableFuture<ApiHttpResponse<com.commercetools.api.models.order.Order>> result = apiRoot 027 * .withProjectKey("{projectKey}") 028 * .inStoreKeyWithStoreKeyValue("{storeKey}") 029 * .orders() 030 * .withOrderNumber("{orderNumber}") 031 * .get() 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 ByProjectKeyInStoreKeyByStoreKeyOrdersOrderNumberByOrderNumberGet extends 038 ApiMethod<ByProjectKeyInStoreKeyByStoreKeyOrdersOrderNumberByOrderNumberGet, com.commercetools.api.models.order.Order> 039 implements 040 com.commercetools.api.client.ExpandableTrait<ByProjectKeyInStoreKeyByStoreKeyOrdersOrderNumberByOrderNumberGet>, 041 com.commercetools.api.client.ErrorableTrait<ByProjectKeyInStoreKeyByStoreKeyOrdersOrderNumberByOrderNumberGet>, 042 com.commercetools.api.client.Deprecatable200Trait<ByProjectKeyInStoreKeyByStoreKeyOrdersOrderNumberByOrderNumberGet> { 043 044 private String projectKey; 045 private String storeKey; 046 private String orderNumber; 047 048 public ByProjectKeyInStoreKeyByStoreKeyOrdersOrderNumberByOrderNumberGet(final ApiHttpClient apiHttpClient, 049 String projectKey, String storeKey, String orderNumber) { 050 super(apiHttpClient); 051 this.projectKey = projectKey; 052 this.storeKey = storeKey; 053 this.orderNumber = orderNumber; 054 } 055 056 public ByProjectKeyInStoreKeyByStoreKeyOrdersOrderNumberByOrderNumberGet( 057 ByProjectKeyInStoreKeyByStoreKeyOrdersOrderNumberByOrderNumberGet t) { 058 super(t); 059 this.projectKey = t.projectKey; 060 this.storeKey = t.storeKey; 061 this.orderNumber = t.orderNumber; 062 } 063 064 @Override 065 protected ApiHttpRequest buildHttpRequest() { 066 List<String> params = new ArrayList<>(getQueryParamUriStrings()); 067 String httpRequestPath = String.format("%s/in-store/key=%s/orders/order-number=%s", this.projectKey, 068 this.storeKey, this.orderNumber); 069 if (!params.isEmpty()) { 070 httpRequestPath += "?" + String.join("&", params); 071 } 072 return new ApiHttpRequest(ApiHttpMethod.GET, URI.create(httpRequestPath), getHeaders(), null); 073 } 074 075 @Override 076 public ApiHttpResponse<com.commercetools.api.models.order.Order> executeBlocking(final ApiHttpClient client, 077 final Duration timeout) { 078 return executeBlocking(client, timeout, com.commercetools.api.models.order.Order.class); 079 } 080 081 @Override 082 public CompletableFuture<ApiHttpResponse<com.commercetools.api.models.order.Order>> execute( 083 final ApiHttpClient client) { 084 return execute(client, com.commercetools.api.models.order.Order.class); 085 } 086 087 public String getProjectKey() { 088 return this.projectKey; 089 } 090 091 public String getStoreKey() { 092 return this.storeKey; 093 } 094 095 public String getOrderNumber() { 096 return this.orderNumber; 097 } 098 099 public List<String> getExpand() { 100 return this.getQueryParam("expand"); 101 } 102 103 public void setProjectKey(final String projectKey) { 104 this.projectKey = projectKey; 105 } 106 107 public void setStoreKey(final String storeKey) { 108 this.storeKey = storeKey; 109 } 110 111 public void setOrderNumber(final String orderNumber) { 112 this.orderNumber = orderNumber; 113 } 114 115 /** 116 * set expand with the specified value 117 * @param expand value to be set 118 * @param <TValue> value type 119 * @return ByProjectKeyInStoreKeyByStoreKeyOrdersOrderNumberByOrderNumberGet 120 */ 121 public <TValue> ByProjectKeyInStoreKeyByStoreKeyOrdersOrderNumberByOrderNumberGet withExpand(final TValue expand) { 122 return copy().withQueryParam("expand", expand); 123 } 124 125 /** 126 * add additional expand query parameter 127 * @param expand value to be added 128 * @param <TValue> value type 129 * @return ByProjectKeyInStoreKeyByStoreKeyOrdersOrderNumberByOrderNumberGet 130 */ 131 public <TValue> ByProjectKeyInStoreKeyByStoreKeyOrdersOrderNumberByOrderNumberGet addExpand(final TValue expand) { 132 return copy().addQueryParam("expand", expand); 133 } 134 135 /** 136 * set expand with the specified value 137 * @param supplier supplier for the value to be set 138 * @return ByProjectKeyInStoreKeyByStoreKeyOrdersOrderNumberByOrderNumberGet 139 */ 140 public ByProjectKeyInStoreKeyByStoreKeyOrdersOrderNumberByOrderNumberGet withExpand( 141 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 ByProjectKeyInStoreKeyByStoreKeyOrdersOrderNumberByOrderNumberGet 149 */ 150 public ByProjectKeyInStoreKeyByStoreKeyOrdersOrderNumberByOrderNumberGet addExpand( 151 final Supplier<String> supplier) { 152 return copy().addQueryParam("expand", supplier.get()); 153 } 154 155 /** 156 * set expand with the specified value 157 * @param op builder for the value to be set 158 * @return ByProjectKeyInStoreKeyByStoreKeyOrdersOrderNumberByOrderNumberGet 159 */ 160 public ByProjectKeyInStoreKeyByStoreKeyOrdersOrderNumberByOrderNumberGet withExpand( 161 final Function<StringBuilder, StringBuilder> op) { 162 return copy().withQueryParam("expand", op.apply(new StringBuilder())); 163 } 164 165 /** 166 * add additional expand query parameter 167 * @param op builder for the value to be added 168 * @return ByProjectKeyInStoreKeyByStoreKeyOrdersOrderNumberByOrderNumberGet 169 */ 170 public ByProjectKeyInStoreKeyByStoreKeyOrdersOrderNumberByOrderNumberGet addExpand( 171 final Function<StringBuilder, StringBuilder> op) { 172 return copy().addQueryParam("expand", op.apply(new StringBuilder())); 173 } 174 175 /** 176 * set expand with the specified values 177 * @param expand values to be set 178 * @param <TValue> value type 179 * @return ByProjectKeyInStoreKeyByStoreKeyOrdersOrderNumberByOrderNumberGet 180 */ 181 public <TValue> ByProjectKeyInStoreKeyByStoreKeyOrdersOrderNumberByOrderNumberGet withExpand( 182 final Collection<TValue> expand) { 183 return copy().withoutQueryParam("expand") 184 .addQueryParams( 185 expand.stream().map(s -> new ParamEntry<>("expand", s.toString())).collect(Collectors.toList())); 186 } 187 188 /** 189 * add additional expand query parameters 190 * @param expand values to be added 191 * @param <TValue> value type 192 * @return ByProjectKeyInStoreKeyByStoreKeyOrdersOrderNumberByOrderNumberGet 193 */ 194 public <TValue> ByProjectKeyInStoreKeyByStoreKeyOrdersOrderNumberByOrderNumberGet addExpand( 195 final Collection<TValue> expand) { 196 return copy().addQueryParams( 197 expand.stream().map(s -> new ParamEntry<>("expand", s.toString())).collect(Collectors.toList())); 198 } 199 200 @Override 201 public boolean equals(Object o) { 202 if (this == o) 203 return true; 204 205 if (o == null || getClass() != o.getClass()) 206 return false; 207 208 ByProjectKeyInStoreKeyByStoreKeyOrdersOrderNumberByOrderNumberGet that = (ByProjectKeyInStoreKeyByStoreKeyOrdersOrderNumberByOrderNumberGet) o; 209 210 return new EqualsBuilder().append(projectKey, that.projectKey) 211 .append(storeKey, that.storeKey) 212 .append(orderNumber, that.orderNumber) 213 .isEquals(); 214 } 215 216 @Override 217 public int hashCode() { 218 return new HashCodeBuilder(17, 37).append(projectKey).append(storeKey).append(orderNumber).toHashCode(); 219 } 220 221 @Override 222 protected ByProjectKeyInStoreKeyByStoreKeyOrdersOrderNumberByOrderNumberGet copy() { 223 return new ByProjectKeyInStoreKeyByStoreKeyOrdersOrderNumberByOrderNumberGet(this); 224 } 225}