Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DE-527] DE-642 Add include[] parameter for listSubscriptions #58

Merged
merged 4 commits into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion doc/controllers/subscriptions.md
Original file line number Diff line number Diff line change
Expand Up @@ -885,6 +885,7 @@ List<SubscriptionResponse> listSubscriptions(
| `metadata` | `Map<String, String>` | 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.<br>Use in query `direction=asc`. |
| `sort` | [`SubscriptionSort`](../../doc/models/subscription-sort.md) | Query, Optional | The attribute by which to sort<br>**Default**: `SubscriptionSort.SIGNUP_DATE` |
| `include` | [`List<SubscriptionListInclude>`](../../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

Expand All @@ -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<SubscriptionResponse> result = subscriptionsController.listSubscriptions(listSubscriptionsInput);
Expand Down
13 changes: 13 additions & 0 deletions doc/models/subscription-list-include.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

# Subscription List Include

## Enumeration

`SubscriptionListInclude`

## Fields

| Name |
| --- |
| `SelfServicePageToken` |

1 change: 1 addition & 0 deletions doc/models/subscription.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -506,6 +507,8 @@ private ApiCall<List<SubscriptionResponse>, 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))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand All @@ -34,6 +35,7 @@ public class ListSubscriptionsInput {
private Map<String, String> metadata;
private SortingDirection direction;
private SubscriptionSort sort;
private List<SubscriptionListInclude> include;

/**
* Default constructor.
Expand All @@ -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,
Expand All @@ -75,7 +78,8 @@ public ListSubscriptionsInput(
ZonedDateTime endDatetime,
Map<String, String> metadata,
SortingDirection direction,
SubscriptionSort sort) {
SubscriptionSort sort,
List<SubscriptionListInclude> include) {
this.page = page;
this.perPage = perPage;
this.state = state;
Expand All @@ -90,6 +94,7 @@ public ListSubscriptionsInput(
this.metadata = metadata;
this.direction = direction;
this.sort = sort;
this.include = include;
}

/**
Expand Down Expand Up @@ -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<SubscriptionListInclude> 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<SubscriptionListInclude> include) {
this.include = include;
}

/**
* Converts this ListSubscriptionsInput into string format.
* @return String representation of this class
Expand All @@ -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 + "]";
}

/**
Expand All @@ -470,7 +498,8 @@ public Builder toBuilder() {
.endDatetime(getEndDatetime())
.metadata(getMetadata())
.direction(getDirection())
.sort(getSort());
.sort(getSort())
.include(getInclude());
return builder;
}

Expand All @@ -492,6 +521,7 @@ public static class Builder {
private Map<String, String> metadata;
private SortingDirection direction;
private SubscriptionSort sort = SubscriptionSort.SIGNUP_DATE;
private List<SubscriptionListInclude> include;



Expand Down Expand Up @@ -635,14 +665,24 @@ public Builder sort(SubscriptionSort sort) {
return this;
}

/**
* Setter for include.
* @param include List of SubscriptionListInclude value for include.
* @return Builder
*/
public Builder include(List<SubscriptionListInclude> include) {
this.include = include;
return this;
}

/**
* Builds a new {@link ListSubscriptionsInput} object using the set fields.
* @return {@link ListSubscriptionsInput}
*/
public ListSubscriptionsInput build() {
return new ListSubscriptionsInput(page, perPage, state, product, productPricePointId,
coupon, dateField, startDate, endDate, startDatetime, endDatetime, metadata,
direction, sort);
direction, sort, include);
}
}
}
53 changes: 48 additions & 5 deletions src/main/java/com/maxio/advancedbilling/models/Subscription.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public class Subscription {
private Long creditBalanceInCents;
private Long prepaymentBalanceInCents;
private PrepaidConfiguration prepaidConfiguration;
private String selfServicePageToken;

/**
* Default constructor.
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -280,6 +283,7 @@ public Subscription(
this.creditBalanceInCents = creditBalanceInCents;
this.prepaymentBalanceInCents = prepaymentBalanceInCents;
this.prepaidConfiguration = prepaidConfiguration;
this.selfServicePageToken = selfServicePageToken;
}

/**
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -380,7 +385,7 @@ protected Subscription(Integer id, SubscriptionState state, Long balanceInCents,
OptionalNullable<Boolean> receivesInvoiceEmails, OptionalNullable<String> locale,
String currency, OptionalNullable<ZonedDateTime> scheduledCancellationAt,
Long creditBalanceInCents, Long prepaymentBalanceInCents,
PrepaidConfiguration prepaidConfiguration) {
PrepaidConfiguration prepaidConfiguration, String selfServicePageToken) {
this.id = id;
this.state = state;
this.balanceInCents = balanceInCents;
Expand Down Expand Up @@ -442,6 +447,7 @@ protected Subscription(Integer id, SubscriptionState state, Long balanceInCents,
this.creditBalanceInCents = creditBalanceInCents;
this.prepaymentBalanceInCents = prepaymentBalanceInCents;
this.prepaidConfiguration = prepaidConfiguration;
this.selfServicePageToken = selfServicePageToken;
}

/**
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 + "]";
}

/**
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -2602,6 +2633,7 @@ public static class Builder {
private Long creditBalanceInCents;
private Long prepaymentBalanceInCents;
private PrepaidConfiguration prepaidConfiguration;
private String selfServicePageToken;



Expand Down Expand Up @@ -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}
Expand All @@ -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);
}
}
}
Loading