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