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 a ShoppingList exists in a Project but does <em>not</em> have the <code>store</code> field, or the <code>store</code> field references a different Store, the ResourceNotFound error is returned.</p> 022 * 023 * <hr> 024 * <div class=code-example> 025 * <pre><code class='java'>{@code 026 * CompletableFuture<ApiHttpResponse<com.commercetools.api.models.shopping_list.ShoppingList>> result = apiRoot 027 * .withProjectKey("{projectKey}") 028 * .inStoreKeyWithStoreKeyValue("{storeKey}") 029 * .me() 030 * .shoppingLists() 031 * .withKey("{key}") 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 ByProjectKeyInStoreKeyByStoreKeyMeShoppingListsKeyByKeyGet extends 039 ApiMethod<ByProjectKeyInStoreKeyByStoreKeyMeShoppingListsKeyByKeyGet, com.commercetools.api.models.shopping_list.ShoppingList> 040 implements 041 com.commercetools.api.client.ExpandableTrait<ByProjectKeyInStoreKeyByStoreKeyMeShoppingListsKeyByKeyGet>, 042 com.commercetools.api.client.ErrorableTrait<ByProjectKeyInStoreKeyByStoreKeyMeShoppingListsKeyByKeyGet>, 043 com.commercetools.api.client.Deprecatable200Trait<ByProjectKeyInStoreKeyByStoreKeyMeShoppingListsKeyByKeyGet> { 044 045 private String projectKey; 046 private String storeKey; 047 private String key; 048 049 public ByProjectKeyInStoreKeyByStoreKeyMeShoppingListsKeyByKeyGet(final ApiHttpClient apiHttpClient, 050 String projectKey, String storeKey, String key) { 051 super(apiHttpClient); 052 this.projectKey = projectKey; 053 this.storeKey = storeKey; 054 this.key = key; 055 } 056 057 public ByProjectKeyInStoreKeyByStoreKeyMeShoppingListsKeyByKeyGet( 058 ByProjectKeyInStoreKeyByStoreKeyMeShoppingListsKeyByKeyGet t) { 059 super(t); 060 this.projectKey = t.projectKey; 061 this.storeKey = t.storeKey; 062 this.key = t.key; 063 } 064 065 @Override 066 protected ApiHttpRequest buildHttpRequest() { 067 List<String> params = new ArrayList<>(getQueryParamUriStrings()); 068 String httpRequestPath = String.format("%s/in-store/key=%s/me/shopping-lists/key=%s", this.projectKey, 069 this.storeKey, this.key); 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.shopping_list.ShoppingList> executeBlocking( 078 final ApiHttpClient client, final Duration timeout) { 079 return executeBlocking(client, timeout, com.commercetools.api.models.shopping_list.ShoppingList.class); 080 } 081 082 @Override 083 public CompletableFuture<ApiHttpResponse<com.commercetools.api.models.shopping_list.ShoppingList>> execute( 084 final ApiHttpClient client) { 085 return execute(client, com.commercetools.api.models.shopping_list.ShoppingList.class); 086 } 087 088 public String getProjectKey() { 089 return this.projectKey; 090 } 091 092 public String getStoreKey() { 093 return this.storeKey; 094 } 095 096 public String getKey() { 097 return this.key; 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 setStoreKey(final String storeKey) { 109 this.storeKey = storeKey; 110 } 111 112 public void setKey(final String key) { 113 this.key = key; 114 } 115 116 /** 117 * set expand with the specified value 118 * @param expand value to be set 119 * @param <TValue> value type 120 * @return ByProjectKeyInStoreKeyByStoreKeyMeShoppingListsKeyByKeyGet 121 */ 122 public <TValue> ByProjectKeyInStoreKeyByStoreKeyMeShoppingListsKeyByKeyGet 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 ByProjectKeyInStoreKeyByStoreKeyMeShoppingListsKeyByKeyGet 131 */ 132 public <TValue> ByProjectKeyInStoreKeyByStoreKeyMeShoppingListsKeyByKeyGet 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 ByProjectKeyInStoreKeyByStoreKeyMeShoppingListsKeyByKeyGet 140 */ 141 public ByProjectKeyInStoreKeyByStoreKeyMeShoppingListsKeyByKeyGet 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 ByProjectKeyInStoreKeyByStoreKeyMeShoppingListsKeyByKeyGet 149 */ 150 public ByProjectKeyInStoreKeyByStoreKeyMeShoppingListsKeyByKeyGet 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 ByProjectKeyInStoreKeyByStoreKeyMeShoppingListsKeyByKeyGet 158 */ 159 public ByProjectKeyInStoreKeyByStoreKeyMeShoppingListsKeyByKeyGet 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 ByProjectKeyInStoreKeyByStoreKeyMeShoppingListsKeyByKeyGet 168 */ 169 public ByProjectKeyInStoreKeyByStoreKeyMeShoppingListsKeyByKeyGet 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 ByProjectKeyInStoreKeyByStoreKeyMeShoppingListsKeyByKeyGet 179 */ 180 public <TValue> ByProjectKeyInStoreKeyByStoreKeyMeShoppingListsKeyByKeyGet 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 ByProjectKeyInStoreKeyByStoreKeyMeShoppingListsKeyByKeyGet 192 */ 193 public <TValue> ByProjectKeyInStoreKeyByStoreKeyMeShoppingListsKeyByKeyGet 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 ByProjectKeyInStoreKeyByStoreKeyMeShoppingListsKeyByKeyGet that = (ByProjectKeyInStoreKeyByStoreKeyMeShoppingListsKeyByKeyGet) o; 208 209 return new EqualsBuilder().append(projectKey, that.projectKey) 210 .append(storeKey, that.storeKey) 211 .append(key, that.key) 212 .isEquals(); 213 } 214 215 @Override 216 public int hashCode() { 217 return new HashCodeBuilder(17, 37).append(projectKey).append(storeKey).append(key).toHashCode(); 218 } 219 220 @Override 221 protected ByProjectKeyInStoreKeyByStoreKeyMeShoppingListsKeyByKeyGet copy() { 222 return new ByProjectKeyInStoreKeyByStoreKeyMeShoppingListsKeyByKeyGet(this); 223 } 224}