From 5ed0272b2d5f101b040983b7c320b8cb0312c6f5 Mon Sep 17 00:00:00 2001 From: maxio-sdk Date: Tue, 12 Dec 2023 14:50:30 +0000 Subject: [PATCH 1/4] Automated commit message --- doc/controllers/subscriptions.md | 3 +- doc/models/subscription-list-include.md | 13 +++ doc/models/subscription.md | 1 + .../controllers/SubscriptionsController.java | 3 + .../models/ListSubscriptionsInput.java | 48 +++++++++- .../advancedbilling/models/Subscription.java | 53 +++++++++-- .../models/SubscriptionListInclude.java | 89 +++++++++++++++++++ 7 files changed, 200 insertions(+), 10 deletions(-) create mode 100644 doc/models/subscription-list-include.md create mode 100644 src/main/java/com/maxio/advancedbilling/models/SubscriptionListInclude.java diff --git a/doc/controllers/subscriptions.md b/doc/controllers/subscriptions.md index 0c970c84..d39a193e 100644 --- a/doc/controllers/subscriptions.md +++ b/doc/controllers/subscriptions.md @@ -885,6 +885,7 @@ List listSubscriptions( | `metadata` | `Map` | Query, Optional | The value of the metadata field specified in the parameter. Use in query `metadata[my-field]=value&metadata[other-field]=another_value`. | | `direction` | [`SortingDirection`](../../doc/models/sorting-direction.md) | Query, Optional | Controls the order in which results are returned.
Use in query `direction=asc`. | | `sort` | [`SubscriptionSort`](../../doc/models/subscription-sort.md) | Query, Optional | The attribute by which to sort
**Default**: `SubscriptionSort.SIGNUP_DATE` | +| `include` | [`List`](../../doc/models/subscription-list-include.md) | Query, Optional | Allows including additional data in the response. Use in query: `include[]=self_service_page_token`. | ## Response Type @@ -901,7 +902,7 @@ ListSubscriptionsInput listSubscriptionsInput = new ListSubscriptionsInput.Build .startDatetime(DateTimeHelper.fromRfc8601DateTime("2022-07-01 09:00:05")) .endDatetime(DateTimeHelper.fromRfc8601DateTime("2022-08-01 10:00:05")) .sort(SubscriptionSort.SIGNUP_DATE) - .build(); +Liquid error: Value cannot be null. (Parameter 'key') .build(); try { List result = subscriptionsController.listSubscriptions(listSubscriptionsInput); diff --git a/doc/models/subscription-list-include.md b/doc/models/subscription-list-include.md new file mode 100644 index 00000000..27359075 --- /dev/null +++ b/doc/models/subscription-list-include.md @@ -0,0 +1,13 @@ + +# Subscription List Include + +## Enumeration + +`SubscriptionListInclude` + +## Fields + +| Name | +| --- | +| `SelfServicePageToken` | + diff --git a/doc/models/subscription.md b/doc/models/subscription.md index 7177fe50..2e3e466f 100644 --- a/doc/models/subscription.md +++ b/doc/models/subscription.md @@ -70,6 +70,7 @@ | `CreditBalanceInCents` | `Long` | Optional | - | Long getCreditBalanceInCents() | setCreditBalanceInCents(Long creditBalanceInCents) | | `PrepaymentBalanceInCents` | `Long` | Optional | - | Long getPrepaymentBalanceInCents() | setPrepaymentBalanceInCents(Long prepaymentBalanceInCents) | | `PrepaidConfiguration` | [`PrepaidConfiguration`](../../doc/models/prepaid-configuration.md) | Optional | - | PrepaidConfiguration getPrepaidConfiguration() | setPrepaidConfiguration(PrepaidConfiguration prepaidConfiguration) | +| `SelfServicePageToken` | `String` | Optional | Returned only for list/read Subscription operation when `include[]=self_service_page_token` parameter is provided. | String getSelfServicePageToken() | setSelfServicePageToken(String selfServicePageToken) | ## Example (as JSON) diff --git a/src/main/java/com/maxio/advancedbilling/controllers/SubscriptionsController.java b/src/main/java/com/maxio/advancedbilling/controllers/SubscriptionsController.java index 9749aec2..faa2d40e 100644 --- a/src/main/java/com/maxio/advancedbilling/controllers/SubscriptionsController.java +++ b/src/main/java/com/maxio/advancedbilling/controllers/SubscriptionsController.java @@ -23,6 +23,7 @@ import com.maxio.advancedbilling.models.OverrideSubscriptionRequest; import com.maxio.advancedbilling.models.PrepaidConfigurationResponse; import com.maxio.advancedbilling.models.SubscriptionInclude; +import com.maxio.advancedbilling.models.SubscriptionListInclude; import com.maxio.advancedbilling.models.SubscriptionPreviewResponse; import com.maxio.advancedbilling.models.SubscriptionPurgeType; import com.maxio.advancedbilling.models.SubscriptionResponse; @@ -506,6 +507,8 @@ private ApiCall, ApiException> prepareListSubscriptio .value((input.getDirection() != null) ? input.getDirection().value() : null).isRequired(false)) .queryParam(param -> param.key("sort") .value((input.getSort() != null) ? input.getSort().value() : "signup_date").isRequired(false)) + .queryParam(param -> param.key("include[]") + .value(SubscriptionListInclude.toValue(input.getInclude())).isRequired(false)) .headerParam(param -> param.key("accept").value("application/json")) .authenticationKey(BaseController.AUTHENTICATION_KEY) .httpMethod(HttpMethod.GET)) diff --git a/src/main/java/com/maxio/advancedbilling/models/ListSubscriptionsInput.java b/src/main/java/com/maxio/advancedbilling/models/ListSubscriptionsInput.java index fd498ed9..1d4dee35 100644 --- a/src/main/java/com/maxio/advancedbilling/models/ListSubscriptionsInput.java +++ b/src/main/java/com/maxio/advancedbilling/models/ListSubscriptionsInput.java @@ -14,6 +14,7 @@ import com.maxio.advancedbilling.DateTimeHelper; import java.time.LocalDate; import java.time.ZonedDateTime; +import java.util.List; import java.util.Map; /** @@ -34,6 +35,7 @@ public class ListSubscriptionsInput { private Map metadata; private SortingDirection direction; private SubscriptionSort sort; + private List include; /** * Default constructor. @@ -60,6 +62,7 @@ public ListSubscriptionsInput() { * @param metadata Map of String, value for metadata. * @param direction SortingDirection value for direction. * @param sort SubscriptionSort value for sort. + * @param include List of SubscriptionListInclude value for include. */ public ListSubscriptionsInput( Integer page, @@ -75,7 +78,8 @@ public ListSubscriptionsInput( ZonedDateTime endDatetime, Map metadata, SortingDirection direction, - SubscriptionSort sort) { + SubscriptionSort sort, + List include) { this.page = page; this.perPage = perPage; this.state = state; @@ -90,6 +94,7 @@ public ListSubscriptionsInput( this.metadata = metadata; this.direction = direction; this.sort = sort; + this.include = include; } /** @@ -436,6 +441,29 @@ public void setSort(SubscriptionSort sort) { this.sort = sort; } + /** + * Getter for Include. + * Allows including additional data in the response. Use in query: + * `include[]=self_service_page_token`. + * @return Returns the List of SubscriptionListInclude + */ + @JsonGetter("include[]") + @JsonInclude(JsonInclude.Include.NON_NULL) + public List getInclude() { + return include; + } + + /** + * Setter for Include. + * Allows including additional data in the response. Use in query: + * `include[]=self_service_page_token`. + * @param include Value for List of SubscriptionListInclude + */ + @JsonSetter("include[]") + public void setInclude(List include) { + this.include = include; + } + /** * Converts this ListSubscriptionsInput into string format. * @return String representation of this class @@ -447,7 +475,7 @@ public String toString() { + ", coupon=" + coupon + ", dateField=" + dateField + ", startDate=" + startDate + ", endDate=" + endDate + ", startDatetime=" + startDatetime + ", endDatetime=" + endDatetime + ", metadata=" + metadata + ", direction=" + direction + ", sort=" - + sort + "]"; + + sort + ", include=" + include + "]"; } /** @@ -470,7 +498,8 @@ public Builder toBuilder() { .endDatetime(getEndDatetime()) .metadata(getMetadata()) .direction(getDirection()) - .sort(getSort()); + .sort(getSort()) + .include(getInclude()); return builder; } @@ -492,6 +521,7 @@ public static class Builder { private Map metadata; private SortingDirection direction; private SubscriptionSort sort = SubscriptionSort.SIGNUP_DATE; + private List include; @@ -635,6 +665,16 @@ public Builder sort(SubscriptionSort sort) { return this; } + /** + * Setter for include. + * @param include List of SubscriptionListInclude value for include. + * @return Builder + */ + public Builder include(List include) { + this.include = include; + return this; + } + /** * Builds a new {@link ListSubscriptionsInput} object using the set fields. * @return {@link ListSubscriptionsInput} @@ -642,7 +682,7 @@ public Builder sort(SubscriptionSort sort) { public ListSubscriptionsInput build() { return new ListSubscriptionsInput(page, perPage, state, product, productPricePointId, coupon, dateField, startDate, endDate, startDatetime, endDatetime, metadata, - direction, sort); + direction, sort, include); } } } diff --git a/src/main/java/com/maxio/advancedbilling/models/Subscription.java b/src/main/java/com/maxio/advancedbilling/models/Subscription.java index 21041383..4da5a30a 100644 --- a/src/main/java/com/maxio/advancedbilling/models/Subscription.java +++ b/src/main/java/com/maxio/advancedbilling/models/Subscription.java @@ -82,6 +82,7 @@ public class Subscription { private Long creditBalanceInCents; private Long prepaymentBalanceInCents; private PrepaidConfiguration prepaidConfiguration; + private String selfServicePageToken; /** * Default constructor. @@ -155,6 +156,7 @@ public Subscription() { * @param creditBalanceInCents Long value for creditBalanceInCents. * @param prepaymentBalanceInCents Long value for prepaymentBalanceInCents. * @param prepaidConfiguration PrepaidConfiguration value for prepaidConfiguration. + * @param selfServicePageToken String value for selfServicePageToken. */ public Subscription( Integer id, @@ -217,7 +219,8 @@ public Subscription( ZonedDateTime scheduledCancellationAt, Long creditBalanceInCents, Long prepaymentBalanceInCents, - PrepaidConfiguration prepaidConfiguration) { + PrepaidConfiguration prepaidConfiguration, + String selfServicePageToken) { this.id = id; this.state = state; this.balanceInCents = balanceInCents; @@ -280,6 +283,7 @@ public Subscription( this.creditBalanceInCents = creditBalanceInCents; this.prepaymentBalanceInCents = prepaymentBalanceInCents; this.prepaidConfiguration = prepaidConfiguration; + this.selfServicePageToken = selfServicePageToken; } /** @@ -346,6 +350,7 @@ public Subscription( * @param creditBalanceInCents Long value for creditBalanceInCents. * @param prepaymentBalanceInCents Long value for prepaymentBalanceInCents. * @param prepaidConfiguration PrepaidConfiguration value for prepaidConfiguration. + * @param selfServicePageToken String value for selfServicePageToken. */ protected Subscription(Integer id, SubscriptionState state, Long balanceInCents, @@ -380,7 +385,7 @@ protected Subscription(Integer id, SubscriptionState state, Long balanceInCents, OptionalNullable receivesInvoiceEmails, OptionalNullable locale, String currency, OptionalNullable scheduledCancellationAt, Long creditBalanceInCents, Long prepaymentBalanceInCents, - PrepaidConfiguration prepaidConfiguration) { + PrepaidConfiguration prepaidConfiguration, String selfServicePageToken) { this.id = id; this.state = state; this.balanceInCents = balanceInCents; @@ -442,6 +447,7 @@ protected Subscription(Integer id, SubscriptionState state, Long balanceInCents, this.creditBalanceInCents = creditBalanceInCents; this.prepaymentBalanceInCents = prepaymentBalanceInCents; this.prepaidConfiguration = prepaidConfiguration; + this.selfServicePageToken = selfServicePageToken; } /** @@ -2425,6 +2431,29 @@ public void setPrepaidConfiguration(PrepaidConfiguration prepaidConfiguration) { this.prepaidConfiguration = prepaidConfiguration; } + /** + * Getter for SelfServicePageToken. + * Returned only for list/read Subscription operation when `include[]=self_service_page_token` + * parameter is provided. + * @return Returns the String + */ + @JsonGetter("self_service_page_token") + @JsonInclude(JsonInclude.Include.NON_NULL) + public String getSelfServicePageToken() { + return selfServicePageToken; + } + + /** + * Setter for SelfServicePageToken. + * Returned only for list/read Subscription operation when `include[]=self_service_page_token` + * parameter is provided. + * @param selfServicePageToken Value for String + */ + @JsonSetter("self_service_page_token") + public void setSelfServicePageToken(String selfServicePageToken) { + this.selfServicePageToken = selfServicePageToken; + } + /** * Converts this Subscription into string format. * @return String representation of this class @@ -2463,7 +2492,8 @@ public String toString() { + ", receivesInvoiceEmails=" + receivesInvoiceEmails + ", locale=" + locale + ", currency=" + currency + ", scheduledCancellationAt=" + scheduledCancellationAt + ", creditBalanceInCents=" + creditBalanceInCents + ", prepaymentBalanceInCents=" - + prepaymentBalanceInCents + ", prepaidConfiguration=" + prepaidConfiguration + "]"; + + prepaymentBalanceInCents + ", prepaidConfiguration=" + prepaidConfiguration + + ", selfServicePageToken=" + selfServicePageToken + "]"; } /** @@ -2503,7 +2533,8 @@ public Builder toBuilder() { .currency(getCurrency()) .creditBalanceInCents(getCreditBalanceInCents()) .prepaymentBalanceInCents(getPrepaymentBalanceInCents()) - .prepaidConfiguration(getPrepaidConfiguration()); + .prepaidConfiguration(getPrepaidConfiguration()) + .selfServicePageToken(getSelfServicePageToken()); builder.trialStartedAt = internalGetTrialStartedAt(); builder.trialEndedAt = internalGetTrialEndedAt(); builder.expiresAt = internalGetExpiresAt(); @@ -2602,6 +2633,7 @@ public static class Builder { private Long creditBalanceInCents; private Long prepaymentBalanceInCents; private PrepaidConfiguration prepaidConfiguration; + private String selfServicePageToken; @@ -3491,6 +3523,16 @@ public Builder prepaidConfiguration(PrepaidConfiguration prepaidConfiguration) { return this; } + /** + * Setter for selfServicePageToken. + * @param selfServicePageToken String value for selfServicePageToken. + * @return Builder + */ + public Builder selfServicePageToken(String selfServicePageToken) { + this.selfServicePageToken = selfServicePageToken; + return this; + } + /** * Builds a new {@link Subscription} object using the set fields. * @return {@link Subscription} @@ -3510,7 +3552,8 @@ public Subscription build() { storedCredentialTransactionId, reference, onHoldAt, prepaidDunning, coupons, dunningCommunicationDelayEnabled, dunningCommunicationDelayTimeZone, receivesInvoiceEmails, locale, currency, scheduledCancellationAt, - creditBalanceInCents, prepaymentBalanceInCents, prepaidConfiguration); + creditBalanceInCents, prepaymentBalanceInCents, prepaidConfiguration, + selfServicePageToken); } } } diff --git a/src/main/java/com/maxio/advancedbilling/models/SubscriptionListInclude.java b/src/main/java/com/maxio/advancedbilling/models/SubscriptionListInclude.java new file mode 100644 index 00000000..4679cd5d --- /dev/null +++ b/src/main/java/com/maxio/advancedbilling/models/SubscriptionListInclude.java @@ -0,0 +1,89 @@ +/* + * AdvancedBilling + * + * This file was automatically generated for Maxio by APIMATIC v3.0 ( https://www.apimatic.io ). + */ + +package com.maxio.advancedbilling.models; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.TreeMap; + + +/** + * SubscriptionListInclude to be used. + */ +public enum SubscriptionListInclude { + SELF_SERVICE_PAGE_TOKEN; + + + private static TreeMap valueMap = new TreeMap<>(); + private String value; + + static { + SELF_SERVICE_PAGE_TOKEN.value = "self_service_page_token"; + + valueMap.put("self_service_page_token", SELF_SERVICE_PAGE_TOKEN); + } + + /** + * Returns the enum member associated with the given string value. + * @param toConvert String value to get enum member. + * @return The enum member against the given string value. + * @throws IOException when provided value is not mapped to any enum member. + */ + @JsonCreator + public static SubscriptionListInclude constructFromString(String toConvert) throws IOException { + SubscriptionListInclude enumValue = fromString(toConvert); + if (enumValue == null) + { + throw new IOException("Unable to create enum instance with value: " + toConvert); + } + return enumValue; + } + + /** + * Returns the enum member associated with the given string value. + * @param toConvert String value to get enum member. + * @return The enum member against the given string value. + */ + public static SubscriptionListInclude fromString(String toConvert) { + return valueMap.get(toConvert); + } + + /** + * Returns the string value associated with the enum member. + * @return The string value against enum member. + */ + @JsonValue + public String value() { + return value; + } + + /** + * Get string representation of this enum. + */ + @Override + public String toString() { + return value.toString(); + } + + /** + * Convert list of SubscriptionListInclude values to list of string values. + * @param toConvert The list of SubscriptionListInclude values to convert. + * @return List of representative string values. + */ + public static List toValue(List toConvert) { + if (toConvert == null) { + return null; + } + List convertedValues = new ArrayList<>(); + for (SubscriptionListInclude enumValue : toConvert) { + convertedValues.add(enumValue.value); + } + return convertedValues; + } +} \ No newline at end of file From 00fa6b4b4bdcc503453e4e9404463422bb28a2b5 Mon Sep 17 00:00:00 2001 From: Michal Pierog Date: Tue, 12 Dec 2023 16:00:09 +0100 Subject: [PATCH 2/4] [DE-117] DE-527 Add tests for read and update subscription --- .../SubscriptionsControllerListTest.java | 21 +++++++++++++++++++ .../SubscriptionsControllerReadTest.java | 4 +++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/tests/src/test/java/com/maxio/advancedbilling/controllers/subscriptions/SubscriptionsControllerListTest.java b/tests/src/test/java/com/maxio/advancedbilling/controllers/subscriptions/SubscriptionsControllerListTest.java index dd63accd..4cdfaffd 100644 --- a/tests/src/test/java/com/maxio/advancedbilling/controllers/subscriptions/SubscriptionsControllerListTest.java +++ b/tests/src/test/java/com/maxio/advancedbilling/controllers/subscriptions/SubscriptionsControllerListTest.java @@ -15,6 +15,7 @@ import com.maxio.advancedbilling.models.SortingDirection; import com.maxio.advancedbilling.models.Subscription; import com.maxio.advancedbilling.models.SubscriptionDateField; +import com.maxio.advancedbilling.models.SubscriptionListInclude; import com.maxio.advancedbilling.models.SubscriptionResponse; import com.maxio.advancedbilling.models.SubscriptionSort; import com.maxio.advancedbilling.models.SubscriptionStateFilter; @@ -154,6 +155,26 @@ void shouldReturnAllSubscriptions() throws IOException, ApiException { .hasSize(7) .usingRecursiveFieldByFieldElementComparatorIgnoringFields(IGNORED_FIELDS) .containsExactlyInAnyOrderElementsOf(ALL_SUBSCRIPTIONS); + + assertThat(subscriptions) + .extracting(SubscriptionResponse::getSubscription) + .extracting(Subscription::getSelfServicePageToken) + .containsOnlyNulls(); + } + + @Test + void shouldIncludeSelfServicePageToken() throws IOException, ApiException { + // when + List subscriptions = SUBSCRIPTIONS_CONTROLLER + .listSubscriptions(new ListSubscriptionsInput.Builder() + .include(List.of(SubscriptionListInclude.SELF_SERVICE_PAGE_TOKEN)) + .build()); + + // then + assertThat(subscriptions) + .extracting(SubscriptionResponse::getSubscription) + .extracting(Subscription::getSelfServicePageToken) + .doesNotContainNull(); } @Test diff --git a/tests/src/test/java/com/maxio/advancedbilling/controllers/subscriptions/SubscriptionsControllerReadTest.java b/tests/src/test/java/com/maxio/advancedbilling/controllers/subscriptions/SubscriptionsControllerReadTest.java index a01c2544..e2035b06 100644 --- a/tests/src/test/java/com/maxio/advancedbilling/controllers/subscriptions/SubscriptionsControllerReadTest.java +++ b/tests/src/test/java/com/maxio/advancedbilling/controllers/subscriptions/SubscriptionsControllerReadTest.java @@ -83,10 +83,11 @@ void shouldReadSubscriptionAndIncludeAdditionalFields() throws IOException, ApiE // then assertThat(subscriptionIncludeAll) .usingRecursiveComparison() - .ignoringFields("coupons") + .ignoringFields("coupons", "selfServicePageToken") .isEqualTo(subscriptionIncludeNone); assertThat(subscriptionIncludeNone.getCoupons()).isNull(); + assertThat(subscriptionIncludeNone.getSelfServicePageToken()).isNull(); assertThat(subscriptionIncludeAll.getCoupons()) .isNotNull() .hasSize(1) @@ -98,5 +99,6 @@ void shouldReadSubscriptionAndIncludeAdditionalFields() throws IOException, ApiE .recurring(false) .percentage("0.5") .build()); + assertThat(subscriptionIncludeAll.getSelfServicePageToken()).isNotNull(); } } From 8d2ca8a188b300227cae34b6bcfb4aab28fd1235 Mon Sep 17 00:00:00 2001 From: Michal Pierog Date: Tue, 12 Dec 2023 16:03:04 +0100 Subject: [PATCH 3/4] [DE-117] DE-527 Add tests for read and update subscription --- .../subscriptions/SubscriptionsControllerReadTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/src/test/java/com/maxio/advancedbilling/controllers/subscriptions/SubscriptionsControllerReadTest.java b/tests/src/test/java/com/maxio/advancedbilling/controllers/subscriptions/SubscriptionsControllerReadTest.java index e2035b06..2716a200 100644 --- a/tests/src/test/java/com/maxio/advancedbilling/controllers/subscriptions/SubscriptionsControllerReadTest.java +++ b/tests/src/test/java/com/maxio/advancedbilling/controllers/subscriptions/SubscriptionsControllerReadTest.java @@ -63,7 +63,7 @@ void shouldReadSubscription() throws IOException, ApiException { // then assertThat(readSubscription) .usingRecursiveComparison() - .ignoringFields("currentBillingAmountInCents") + .ignoringFields("currentBillingAmountInCents", "updatedAt") .isEqualTo(subscription); } From 147fb604467b4b2defe727c2f7a226936aa6edc0 Mon Sep 17 00:00:00 2001 From: Michal Pierog Date: Tue, 12 Dec 2023 16:21:31 +0100 Subject: [PATCH 4/4] [DE-117] DE-527 Add tests for read and update subscription --- .../subscriptions/SubscriptionsControllerUpdateTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/src/test/java/com/maxio/advancedbilling/controllers/subscriptions/SubscriptionsControllerUpdateTest.java b/tests/src/test/java/com/maxio/advancedbilling/controllers/subscriptions/SubscriptionsControllerUpdateTest.java index 9503766c..32c7f676 100644 --- a/tests/src/test/java/com/maxio/advancedbilling/controllers/subscriptions/SubscriptionsControllerUpdateTest.java +++ b/tests/src/test/java/com/maxio/advancedbilling/controllers/subscriptions/SubscriptionsControllerUpdateTest.java @@ -119,7 +119,7 @@ void shouldUpdateComponentAndCustomPricing() throws IOException, ApiException { // then assertThat(updatedSubscription).isNotNull(); - assertThat(updatedSubscription.getUpdatedAt()).isAfter(subscription.getUpdatedAt()); + assertThat(updatedSubscription.getUpdatedAt()).isAfterOrEqualTo(subscription.getUpdatedAt()); assertThat(updatedSubscription.getProductPriceInCents()).isEqualTo(1000); Product product = updatedSubscription.getProduct(); assertThat(product.getProductPricePointId()).isNotEqualTo(subscription.getProduct().getProductPricePointId());