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