001 002package com.commercetools.api.client; 003 004import java.net.URI; 005import java.time.Duration; 006import java.util.ArrayList; 007import java.util.List; 008import java.util.concurrent.CompletableFuture; 009 010import io.vrap.rmf.base.client.*; 011import io.vrap.rmf.base.client.utils.Generated; 012 013import org.apache.commons.lang3.builder.EqualsBuilder; 014import org.apache.commons.lang3.builder.HashCodeBuilder; 015 016/** 017 * 018 * 019 * <hr> 020 * <div class=code-example> 021 * <pre><code class='java'>{@code 022 * CompletableFuture<ApiHttpResponse<com.commercetools.api.models.subscription.Subscription>> result = apiRoot 023 * .withProjectKey("{projectKey}") 024 * .subscriptions() 025 * .withId("{ID}") 026 * .get() 027 * .execute() 028 * }</code></pre> 029 * </div> 030 */ 031@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen") 032public class ByProjectKeySubscriptionsByIDGet 033 extends ApiMethod<ByProjectKeySubscriptionsByIDGet, com.commercetools.api.models.subscription.Subscription> 034 implements com.commercetools.api.client.ErrorableTrait<ByProjectKeySubscriptionsByIDGet>, 035 com.commercetools.api.client.Deprecatable200Trait<ByProjectKeySubscriptionsByIDGet> { 036 037 private String projectKey; 038 private String ID; 039 040 public ByProjectKeySubscriptionsByIDGet(final ApiHttpClient apiHttpClient, String projectKey, String ID) { 041 super(apiHttpClient); 042 this.projectKey = projectKey; 043 this.ID = ID; 044 } 045 046 public ByProjectKeySubscriptionsByIDGet(ByProjectKeySubscriptionsByIDGet t) { 047 super(t); 048 this.projectKey = t.projectKey; 049 this.ID = t.ID; 050 } 051 052 @Override 053 protected ApiHttpRequest buildHttpRequest() { 054 List<String> params = new ArrayList<>(getQueryParamUriStrings()); 055 String httpRequestPath = String.format("%s/subscriptions/%s", this.projectKey, this.ID); 056 if (!params.isEmpty()) { 057 httpRequestPath += "?" + String.join("&", params); 058 } 059 return new ApiHttpRequest(ApiHttpMethod.GET, URI.create(httpRequestPath), getHeaders(), null); 060 } 061 062 @Override 063 public ApiHttpResponse<com.commercetools.api.models.subscription.Subscription> executeBlocking( 064 final ApiHttpClient client, final Duration timeout) { 065 return executeBlocking(client, timeout, com.commercetools.api.models.subscription.Subscription.class); 066 } 067 068 @Override 069 public CompletableFuture<ApiHttpResponse<com.commercetools.api.models.subscription.Subscription>> execute( 070 final ApiHttpClient client) { 071 return execute(client, com.commercetools.api.models.subscription.Subscription.class); 072 } 073 074 public String getProjectKey() { 075 return this.projectKey; 076 } 077 078 public String getID() { 079 return this.ID; 080 } 081 082 public void setProjectKey(final String projectKey) { 083 this.projectKey = projectKey; 084 } 085 086 public void setID(final String ID) { 087 this.ID = ID; 088 } 089 090 @Override 091 public boolean equals(Object o) { 092 if (this == o) 093 return true; 094 095 if (o == null || getClass() != o.getClass()) 096 return false; 097 098 ByProjectKeySubscriptionsByIDGet that = (ByProjectKeySubscriptionsByIDGet) o; 099 100 return new EqualsBuilder().append(projectKey, that.projectKey).append(ID, that.ID).isEquals(); 101 } 102 103 @Override 104 public int hashCode() { 105 return new HashCodeBuilder(17, 37).append(projectKey).append(ID).toHashCode(); 106 } 107 108 @Override 109 protected ByProjectKeySubscriptionsByIDGet copy() { 110 return new ByProjectKeySubscriptionsByIDGet(this); 111 } 112}