diff --git a/src/main/java/com/schematic/api/resources/billing/BillingClient.java b/src/main/java/com/schematic/api/resources/billing/BillingClient.java index 1fe43e8..8ec94e3 100644 --- a/src/main/java/com/schematic/api/resources/billing/BillingClient.java +++ b/src/main/java/com/schematic/api/resources/billing/BillingClient.java @@ -25,6 +25,7 @@ import com.schematic.api.resources.billing.requests.CreateMeterRequestBody; import com.schematic.api.resources.billing.requests.CreatePaymentMethodRequestBody; import com.schematic.api.resources.billing.requests.ListBillingProductsRequest; +import com.schematic.api.resources.billing.requests.ListCouponsRequest; import com.schematic.api.resources.billing.requests.ListCustomersRequest; import com.schematic.api.resources.billing.requests.ListInvoicesRequest; import com.schematic.api.resources.billing.requests.ListMetersRequest; @@ -35,6 +36,7 @@ import com.schematic.api.resources.billing.types.CountCustomersResponse; import com.schematic.api.resources.billing.types.DeleteProductPriceResponse; import com.schematic.api.resources.billing.types.ListBillingProductsResponse; +import com.schematic.api.resources.billing.types.ListCouponsResponse; import com.schematic.api.resources.billing.types.ListCustomersResponse; import com.schematic.api.resources.billing.types.ListInvoicesResponse; import com.schematic.api.resources.billing.types.ListMetersResponse; @@ -66,6 +68,74 @@ public BillingClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; } + public ListCouponsResponse listCoupons() { + return listCoupons(ListCouponsRequest.builder().build()); + } + + public ListCouponsResponse listCoupons(ListCouponsRequest request) { + return listCoupons(request, null); + } + + public ListCouponsResponse listCoupons(ListCouponsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/coupons"); + if (request.getIsActive().isPresent()) { + httpUrl.addQueryParameter("is_active", request.getIsActive().get().toString()); + } + if (request.getQ().isPresent()) { + httpUrl.addQueryParameter("q", request.getQ().get()); + } + if (request.getLimit().isPresent()) { + httpUrl.addQueryParameter("limit", request.getLimit().get().toString()); + } + if (request.getOffset().isPresent()) { + httpUrl.addQueryParameter("offset", request.getOffset().get().toString()); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ListCouponsResponse.class); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + public UpsertBillingCouponResponse upsertBillingCoupon(CreateCouponRequestBody request) { return upsertBillingCoupon(request, null); } diff --git a/src/main/java/com/schematic/api/resources/billing/requests/ListCouponsRequest.java b/src/main/java/com/schematic/api/resources/billing/requests/ListCouponsRequest.java new file mode 100644 index 0000000..d5085f0 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/billing/requests/ListCouponsRequest.java @@ -0,0 +1,175 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.billing.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ListCouponsRequest.Builder.class) +public final class ListCouponsRequest { + private final Optional isActive; + + private final Optional q; + + private final Optional limit; + + private final Optional offset; + + private final Map additionalProperties; + + private ListCouponsRequest( + Optional isActive, + Optional q, + Optional limit, + Optional offset, + Map additionalProperties) { + this.isActive = isActive; + this.q = q; + this.limit = limit; + this.offset = offset; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("is_active") + public Optional getIsActive() { + return isActive; + } + + @JsonProperty("q") + public Optional getQ() { + return q; + } + + /** + * @return Page limit (default 100) + */ + @JsonProperty("limit") + public Optional getLimit() { + return limit; + } + + /** + * @return Page offset (default 0) + */ + @JsonProperty("offset") + public Optional getOffset() { + return offset; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ListCouponsRequest && equalTo((ListCouponsRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ListCouponsRequest other) { + return isActive.equals(other.isActive) + && q.equals(other.q) + && limit.equals(other.limit) + && offset.equals(other.offset); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.isActive, this.q, this.limit, this.offset); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional isActive = Optional.empty(); + + private Optional q = Optional.empty(); + + private Optional limit = Optional.empty(); + + private Optional offset = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ListCouponsRequest other) { + isActive(other.getIsActive()); + q(other.getQ()); + limit(other.getLimit()); + offset(other.getOffset()); + return this; + } + + @JsonSetter(value = "is_active", nulls = Nulls.SKIP) + public Builder isActive(Optional isActive) { + this.isActive = isActive; + return this; + } + + public Builder isActive(Boolean isActive) { + this.isActive = Optional.ofNullable(isActive); + return this; + } + + @JsonSetter(value = "q", nulls = Nulls.SKIP) + public Builder q(Optional q) { + this.q = q; + return this; + } + + public Builder q(String q) { + this.q = Optional.ofNullable(q); + return this; + } + + @JsonSetter(value = "limit", nulls = Nulls.SKIP) + public Builder limit(Optional limit) { + this.limit = limit; + return this; + } + + public Builder limit(Integer limit) { + this.limit = Optional.ofNullable(limit); + return this; + } + + @JsonSetter(value = "offset", nulls = Nulls.SKIP) + public Builder offset(Optional offset) { + this.offset = offset; + return this; + } + + public Builder offset(Integer offset) { + this.offset = Optional.ofNullable(offset); + return this; + } + + public ListCouponsRequest build() { + return new ListCouponsRequest(isActive, q, limit, offset, additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/resources/billing/types/ListCouponsParams.java b/src/main/java/com/schematic/api/resources/billing/types/ListCouponsParams.java new file mode 100644 index 0000000..e46d9a2 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/billing/types/ListCouponsParams.java @@ -0,0 +1,175 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.billing.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ListCouponsParams.Builder.class) +public final class ListCouponsParams { + private final Optional isActive; + + private final Optional limit; + + private final Optional offset; + + private final Optional q; + + private final Map additionalProperties; + + private ListCouponsParams( + Optional isActive, + Optional limit, + Optional offset, + Optional q, + Map additionalProperties) { + this.isActive = isActive; + this.limit = limit; + this.offset = offset; + this.q = q; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("is_active") + public Optional getIsActive() { + return isActive; + } + + /** + * @return Page limit (default 100) + */ + @JsonProperty("limit") + public Optional getLimit() { + return limit; + } + + /** + * @return Page offset (default 0) + */ + @JsonProperty("offset") + public Optional getOffset() { + return offset; + } + + @JsonProperty("q") + public Optional getQ() { + return q; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ListCouponsParams && equalTo((ListCouponsParams) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ListCouponsParams other) { + return isActive.equals(other.isActive) + && limit.equals(other.limit) + && offset.equals(other.offset) + && q.equals(other.q); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.isActive, this.limit, this.offset, this.q); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional isActive = Optional.empty(); + + private Optional limit = Optional.empty(); + + private Optional offset = Optional.empty(); + + private Optional q = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ListCouponsParams other) { + isActive(other.getIsActive()); + limit(other.getLimit()); + offset(other.getOffset()); + q(other.getQ()); + return this; + } + + @JsonSetter(value = "is_active", nulls = Nulls.SKIP) + public Builder isActive(Optional isActive) { + this.isActive = isActive; + return this; + } + + public Builder isActive(Boolean isActive) { + this.isActive = Optional.ofNullable(isActive); + return this; + } + + @JsonSetter(value = "limit", nulls = Nulls.SKIP) + public Builder limit(Optional limit) { + this.limit = limit; + return this; + } + + public Builder limit(Integer limit) { + this.limit = Optional.ofNullable(limit); + return this; + } + + @JsonSetter(value = "offset", nulls = Nulls.SKIP) + public Builder offset(Optional offset) { + this.offset = offset; + return this; + } + + public Builder offset(Integer offset) { + this.offset = Optional.ofNullable(offset); + return this; + } + + @JsonSetter(value = "q", nulls = Nulls.SKIP) + public Builder q(Optional q) { + this.q = q; + return this; + } + + public Builder q(String q) { + this.q = Optional.ofNullable(q); + return this; + } + + public ListCouponsParams build() { + return new ListCouponsParams(isActive, limit, offset, q, additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/resources/billing/types/ListCouponsResponse.java b/src/main/java/com/schematic/api/resources/billing/types/ListCouponsResponse.java new file mode 100644 index 0000000..7a43098 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/billing/types/ListCouponsResponse.java @@ -0,0 +1,162 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.billing.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.types.BillingCouponResponseData; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ListCouponsResponse.Builder.class) +public final class ListCouponsResponse { + private final List data; + + private final ListCouponsParams params; + + private final Map additionalProperties; + + private ListCouponsResponse( + List data, ListCouponsParams params, Map additionalProperties) { + this.data = data; + this.params = params; + this.additionalProperties = additionalProperties; + } + + /** + * @return The returned resources + */ + @JsonProperty("data") + public List getData() { + return data; + } + + /** + * @return Input parameters + */ + @JsonProperty("params") + public ListCouponsParams getParams() { + return params; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ListCouponsResponse && equalTo((ListCouponsResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ListCouponsResponse other) { + return data.equals(other.data) && params.equals(other.params); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.data, this.params); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static ParamsStage builder() { + return new Builder(); + } + + public interface ParamsStage { + _FinalStage params(@NotNull ListCouponsParams params); + + Builder from(ListCouponsResponse other); + } + + public interface _FinalStage { + ListCouponsResponse build(); + + _FinalStage data(List data); + + _FinalStage addData(BillingCouponResponseData data); + + _FinalStage addAllData(List data); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements ParamsStage, _FinalStage { + private ListCouponsParams params; + + private List data = new ArrayList<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ListCouponsResponse other) { + data(other.getData()); + params(other.getParams()); + return this; + } + + /** + *

Input parameters

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("params") + public _FinalStage params(@NotNull ListCouponsParams params) { + this.params = Objects.requireNonNull(params, "params must not be null"); + return this; + } + + /** + *

The returned resources

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage addAllData(List data) { + this.data.addAll(data); + return this; + } + + /** + *

The returned resources

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage addData(BillingCouponResponseData data) { + this.data.add(data); + return this; + } + + @java.lang.Override + @JsonSetter(value = "data", nulls = Nulls.SKIP) + public _FinalStage data(List data) { + this.data.clear(); + this.data.addAll(data); + return this; + } + + @java.lang.Override + public ListCouponsResponse build() { + return new ListCouponsResponse(data, params, additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/resources/checkout/CheckoutClient.java b/src/main/java/com/schematic/api/resources/checkout/CheckoutClient.java index aa0c5f6..f440d05 100644 --- a/src/main/java/com/schematic/api/resources/checkout/CheckoutClient.java +++ b/src/main/java/com/schematic/api/resources/checkout/CheckoutClient.java @@ -15,6 +15,7 @@ import com.schematic.api.errors.InternalServerError; import com.schematic.api.errors.NotFoundError; import com.schematic.api.errors.UnauthorizedError; +import com.schematic.api.resources.checkout.requests.CheckoutDataRequestBody; import com.schematic.api.resources.checkout.requests.UpdateTrialEndRequestBody; import com.schematic.api.resources.checkout.types.CheckoutInternalResponse; import com.schematic.api.resources.checkout.types.GetCheckoutDataResponse; @@ -99,20 +100,25 @@ public CheckoutInternalResponse internal( } } - public GetCheckoutDataResponse getCheckoutData(String checkoutInternalId) { - return getCheckoutData(checkoutInternalId, null); + public GetCheckoutDataResponse getCheckoutData(CheckoutDataRequestBody request) { + return getCheckoutData(request, null); } - public GetCheckoutDataResponse getCheckoutData(String checkoutInternalId, RequestOptions requestOptions) { + public GetCheckoutDataResponse getCheckoutData(CheckoutDataRequestBody request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() - .addPathSegments("checkout-internal") - .addPathSegment(checkoutInternalId) - .addPathSegments("data") + .addPathSegments("checkout-internal/data") .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } Request okhttpRequest = new Request.Builder() .url(httpUrl) - .method("GET", null) + .method("POST", body) .headers(Headers.of(clientOptions.headers(requestOptions))) .addHeader("Content-Type", "application/json") .addHeader("Accept", "application/json") @@ -129,15 +135,15 @@ public GetCheckoutDataResponse getCheckoutData(String checkoutInternalId, Reques String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); case 401: throw new UnauthorizedError( ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); case 403: throw new ForbiddenError( ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 404: - throw new NotFoundError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); case 500: throw new InternalServerError( ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); diff --git a/src/main/java/com/schematic/api/resources/checkout/requests/CheckoutDataRequestBody.java b/src/main/java/com/schematic/api/resources/checkout/requests/CheckoutDataRequestBody.java new file mode 100644 index 0000000..8e9bc2e --- /dev/null +++ b/src/main/java/com/schematic/api/resources/checkout/requests/CheckoutDataRequestBody.java @@ -0,0 +1,133 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.checkout.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = CheckoutDataRequestBody.Builder.class) +public final class CheckoutDataRequestBody { + private final String companyId; + + private final Optional selectedPlanId; + + private final Map additionalProperties; + + private CheckoutDataRequestBody( + String companyId, Optional selectedPlanId, Map additionalProperties) { + this.companyId = companyId; + this.selectedPlanId = selectedPlanId; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("company_id") + public String getCompanyId() { + return companyId; + } + + @JsonProperty("selected_plan_id") + public Optional getSelectedPlanId() { + return selectedPlanId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CheckoutDataRequestBody && equalTo((CheckoutDataRequestBody) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CheckoutDataRequestBody other) { + return companyId.equals(other.companyId) && selectedPlanId.equals(other.selectedPlanId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.companyId, this.selectedPlanId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static CompanyIdStage builder() { + return new Builder(); + } + + public interface CompanyIdStage { + _FinalStage companyId(@NotNull String companyId); + + Builder from(CheckoutDataRequestBody other); + } + + public interface _FinalStage { + CheckoutDataRequestBody build(); + + _FinalStage selectedPlanId(Optional selectedPlanId); + + _FinalStage selectedPlanId(String selectedPlanId); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements CompanyIdStage, _FinalStage { + private String companyId; + + private Optional selectedPlanId = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(CheckoutDataRequestBody other) { + companyId(other.getCompanyId()); + selectedPlanId(other.getSelectedPlanId()); + return this; + } + + @java.lang.Override + @JsonSetter("company_id") + public _FinalStage companyId(@NotNull String companyId) { + this.companyId = Objects.requireNonNull(companyId, "companyId must not be null"); + return this; + } + + @java.lang.Override + public _FinalStage selectedPlanId(String selectedPlanId) { + this.selectedPlanId = Optional.ofNullable(selectedPlanId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "selected_plan_id", nulls = Nulls.SKIP) + public _FinalStage selectedPlanId(Optional selectedPlanId) { + this.selectedPlanId = selectedPlanId; + return this; + } + + @java.lang.Override + public CheckoutDataRequestBody build() { + return new CheckoutDataRequestBody(companyId, selectedPlanId, additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/types/ChangeSubscriptionInternalRequestBody.java b/src/main/java/com/schematic/api/types/ChangeSubscriptionInternalRequestBody.java index 06aa99d..96e1195 100644 --- a/src/main/java/com/schematic/api/types/ChangeSubscriptionInternalRequestBody.java +++ b/src/main/java/com/schematic/api/types/ChangeSubscriptionInternalRequestBody.java @@ -27,6 +27,8 @@ public final class ChangeSubscriptionInternalRequestBody { private final String companyId; + private final Optional couponExternalId; + private final String newPlanId; private final String newPriceId; @@ -42,6 +44,7 @@ public final class ChangeSubscriptionInternalRequestBody { private ChangeSubscriptionInternalRequestBody( List addOnIds, String companyId, + Optional couponExternalId, String newPlanId, String newPriceId, List payInAdvance, @@ -50,6 +53,7 @@ private ChangeSubscriptionInternalRequestBody( Map additionalProperties) { this.addOnIds = addOnIds; this.companyId = companyId; + this.couponExternalId = couponExternalId; this.newPlanId = newPlanId; this.newPriceId = newPriceId; this.payInAdvance = payInAdvance; @@ -68,6 +72,11 @@ public String getCompanyId() { return companyId; } + @JsonProperty("coupon_external_id") + public Optional getCouponExternalId() { + return couponExternalId; + } + @JsonProperty("new_plan_id") public String getNewPlanId() { return newPlanId; @@ -108,6 +117,7 @@ public Map getAdditionalProperties() { private boolean equalTo(ChangeSubscriptionInternalRequestBody other) { return addOnIds.equals(other.addOnIds) && companyId.equals(other.companyId) + && couponExternalId.equals(other.couponExternalId) && newPlanId.equals(other.newPlanId) && newPriceId.equals(other.newPriceId) && payInAdvance.equals(other.payInAdvance) @@ -120,6 +130,7 @@ public int hashCode() { return Objects.hash( this.addOnIds, this.companyId, + this.couponExternalId, this.newPlanId, this.newPriceId, this.payInAdvance, @@ -159,6 +170,10 @@ public interface _FinalStage { _FinalStage addAllAddOnIds(List addOnIds); + _FinalStage couponExternalId(Optional couponExternalId); + + _FinalStage couponExternalId(String couponExternalId); + _FinalStage payInAdvance(List payInAdvance); _FinalStage addPayInAdvance(UpdatePayInAdvanceRequestBody payInAdvance); @@ -188,6 +203,8 @@ public static final class Builder implements CompanyIdStage, NewPlanIdStage, New private List payInAdvance = new ArrayList<>(); + private Optional couponExternalId = Optional.empty(); + private List addOnIds = new ArrayList<>(); @JsonAnySetter @@ -199,6 +216,7 @@ private Builder() {} public Builder from(ChangeSubscriptionInternalRequestBody other) { addOnIds(other.getAddOnIds()); companyId(other.getCompanyId()); + couponExternalId(other.getCouponExternalId()); newPlanId(other.getNewPlanId()); newPriceId(other.getNewPriceId()); payInAdvance(other.getPayInAdvance()); @@ -274,6 +292,19 @@ public _FinalStage payInAdvance(List payInAdvance return this; } + @java.lang.Override + public _FinalStage couponExternalId(String couponExternalId) { + this.couponExternalId = Optional.ofNullable(couponExternalId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "coupon_external_id", nulls = Nulls.SKIP) + public _FinalStage couponExternalId(Optional couponExternalId) { + this.couponExternalId = couponExternalId; + return this; + } + @java.lang.Override public _FinalStage addAllAddOnIds(List addOnIds) { this.addOnIds.addAll(addOnIds); @@ -299,6 +330,7 @@ public ChangeSubscriptionInternalRequestBody build() { return new ChangeSubscriptionInternalRequestBody( addOnIds, companyId, + couponExternalId, newPlanId, newPriceId, payInAdvance, diff --git a/src/main/java/com/schematic/api/types/ChangeSubscriptionRequestBody.java b/src/main/java/com/schematic/api/types/ChangeSubscriptionRequestBody.java index d54c66d..544a797 100644 --- a/src/main/java/com/schematic/api/types/ChangeSubscriptionRequestBody.java +++ b/src/main/java/com/schematic/api/types/ChangeSubscriptionRequestBody.java @@ -25,6 +25,8 @@ public final class ChangeSubscriptionRequestBody { private final List addOnIds; + private final Optional couponExternalId; + private final String newPlanId; private final String newPriceId; @@ -39,6 +41,7 @@ public final class ChangeSubscriptionRequestBody { private ChangeSubscriptionRequestBody( List addOnIds, + Optional couponExternalId, String newPlanId, String newPriceId, List payInAdvance, @@ -46,6 +49,7 @@ private ChangeSubscriptionRequestBody( Optional promoCode, Map additionalProperties) { this.addOnIds = addOnIds; + this.couponExternalId = couponExternalId; this.newPlanId = newPlanId; this.newPriceId = newPriceId; this.payInAdvance = payInAdvance; @@ -59,6 +63,11 @@ public List getAddOnIds() { return addOnIds; } + @JsonProperty("coupon_external_id") + public Optional getCouponExternalId() { + return couponExternalId; + } + @JsonProperty("new_plan_id") public String getNewPlanId() { return newPlanId; @@ -97,6 +106,7 @@ public Map getAdditionalProperties() { private boolean equalTo(ChangeSubscriptionRequestBody other) { return addOnIds.equals(other.addOnIds) + && couponExternalId.equals(other.couponExternalId) && newPlanId.equals(other.newPlanId) && newPriceId.equals(other.newPriceId) && payInAdvance.equals(other.payInAdvance) @@ -108,6 +118,7 @@ private boolean equalTo(ChangeSubscriptionRequestBody other) { public int hashCode() { return Objects.hash( this.addOnIds, + this.couponExternalId, this.newPlanId, this.newPriceId, this.payInAdvance, @@ -143,6 +154,10 @@ public interface _FinalStage { _FinalStage addAllAddOnIds(List addOnIds); + _FinalStage couponExternalId(Optional couponExternalId); + + _FinalStage couponExternalId(String couponExternalId); + _FinalStage payInAdvance(List payInAdvance); _FinalStage addPayInAdvance(UpdatePayInAdvanceRequestBody payInAdvance); @@ -170,6 +185,8 @@ public static final class Builder implements NewPlanIdStage, NewPriceIdStage, _F private List payInAdvance = new ArrayList<>(); + private Optional couponExternalId = Optional.empty(); + private List addOnIds = new ArrayList<>(); @JsonAnySetter @@ -180,6 +197,7 @@ private Builder() {} @java.lang.Override public Builder from(ChangeSubscriptionRequestBody other) { addOnIds(other.getAddOnIds()); + couponExternalId(other.getCouponExternalId()); newPlanId(other.getNewPlanId()); newPriceId(other.getNewPriceId()); payInAdvance(other.getPayInAdvance()); @@ -248,6 +266,19 @@ public _FinalStage payInAdvance(List payInAdvance return this; } + @java.lang.Override + public _FinalStage couponExternalId(String couponExternalId) { + this.couponExternalId = Optional.ofNullable(couponExternalId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "coupon_external_id", nulls = Nulls.SKIP) + public _FinalStage couponExternalId(Optional couponExternalId) { + this.couponExternalId = couponExternalId; + return this; + } + @java.lang.Override public _FinalStage addAllAddOnIds(List addOnIds) { this.addOnIds.addAll(addOnIds); @@ -271,7 +302,14 @@ public _FinalStage addOnIds(List addOnIds) { @java.lang.Override public ChangeSubscriptionRequestBody build() { return new ChangeSubscriptionRequestBody( - addOnIds, newPlanId, newPriceId, payInAdvance, paymentMethodId, promoCode, additionalProperties); + addOnIds, + couponExternalId, + newPlanId, + newPriceId, + payInAdvance, + paymentMethodId, + promoCode, + additionalProperties); } } } diff --git a/src/main/java/com/schematic/api/types/CheckoutDataResponseData.java b/src/main/java/com/schematic/api/types/CheckoutDataResponseData.java index 0785869..6608b67 100644 --- a/src/main/java/com/schematic/api/types/CheckoutDataResponseData.java +++ b/src/main/java/com/schematic/api/types/CheckoutDataResponseData.java @@ -32,6 +32,10 @@ public final class CheckoutDataResponseData { private final Optional featureUsage; + private final Optional selectedPlan; + + private final List selectedUsageBasedEntitlements; + private final Optional subscription; private final Map additionalProperties; @@ -42,6 +46,8 @@ private CheckoutDataResponseData( List activeUsageBasedEntitlements, Optional company, Optional featureUsage, + Optional selectedPlan, + List selectedUsageBasedEntitlements, Optional subscription, Map additionalProperties) { this.activeAddOns = activeAddOns; @@ -49,6 +55,8 @@ private CheckoutDataResponseData( this.activeUsageBasedEntitlements = activeUsageBasedEntitlements; this.company = company; this.featureUsage = featureUsage; + this.selectedPlan = selectedPlan; + this.selectedUsageBasedEntitlements = selectedUsageBasedEntitlements; this.subscription = subscription; this.additionalProperties = additionalProperties; } @@ -78,6 +86,16 @@ public Optional getFeatureUsage() { return featureUsage; } + @JsonProperty("selected_plan") + public Optional getSelectedPlan() { + return selectedPlan; + } + + @JsonProperty("selected_usage_based_entitlements") + public List getSelectedUsageBasedEntitlements() { + return selectedUsageBasedEntitlements; + } + @JsonProperty("subscription") public Optional getSubscription() { return subscription; @@ -100,6 +118,8 @@ private boolean equalTo(CheckoutDataResponseData other) { && activeUsageBasedEntitlements.equals(other.activeUsageBasedEntitlements) && company.equals(other.company) && featureUsage.equals(other.featureUsage) + && selectedPlan.equals(other.selectedPlan) + && selectedUsageBasedEntitlements.equals(other.selectedUsageBasedEntitlements) && subscription.equals(other.subscription); } @@ -111,6 +131,8 @@ public int hashCode() { this.activeUsageBasedEntitlements, this.company, this.featureUsage, + this.selectedPlan, + this.selectedUsageBasedEntitlements, this.subscription); } @@ -135,6 +157,10 @@ public static final class Builder { private Optional featureUsage = Optional.empty(); + private Optional selectedPlan = Optional.empty(); + + private List selectedUsageBasedEntitlements = new ArrayList<>(); + private Optional subscription = Optional.empty(); @JsonAnySetter @@ -148,6 +174,8 @@ public Builder from(CheckoutDataResponseData other) { activeUsageBasedEntitlements(other.getActiveUsageBasedEntitlements()); company(other.getCompany()); featureUsage(other.getFeatureUsage()); + selectedPlan(other.getSelectedPlan()); + selectedUsageBasedEntitlements(other.getSelectedUsageBasedEntitlements()); subscription(other.getSubscription()); return this; } @@ -221,6 +249,37 @@ public Builder featureUsage(FeatureUsageDetailResponseData featureUsage) { return this; } + @JsonSetter(value = "selected_plan", nulls = Nulls.SKIP) + public Builder selectedPlan(Optional selectedPlan) { + this.selectedPlan = selectedPlan; + return this; + } + + public Builder selectedPlan(PlanDetailResponseData selectedPlan) { + this.selectedPlan = Optional.ofNullable(selectedPlan); + return this; + } + + @JsonSetter(value = "selected_usage_based_entitlements", nulls = Nulls.SKIP) + public Builder selectedUsageBasedEntitlements( + List selectedUsageBasedEntitlements) { + this.selectedUsageBasedEntitlements.clear(); + this.selectedUsageBasedEntitlements.addAll(selectedUsageBasedEntitlements); + return this; + } + + public Builder addSelectedUsageBasedEntitlements( + UsageBasedEntitlementResponseData selectedUsageBasedEntitlements) { + this.selectedUsageBasedEntitlements.add(selectedUsageBasedEntitlements); + return this; + } + + public Builder addAllSelectedUsageBasedEntitlements( + List selectedUsageBasedEntitlements) { + this.selectedUsageBasedEntitlements.addAll(selectedUsageBasedEntitlements); + return this; + } + @JsonSetter(value = "subscription", nulls = Nulls.SKIP) public Builder subscription(Optional subscription) { this.subscription = subscription; @@ -239,6 +298,8 @@ public CheckoutDataResponseData build() { activeUsageBasedEntitlements, company, featureUsage, + selectedPlan, + selectedUsageBasedEntitlements, subscription, additionalProperties); }