Skip to content

Commit

Permalink
Automated commit message (#63)
Browse files Browse the repository at this point in the history
[DE-643] Fix types for subscription components endpoints
  • Loading branch information
maciej-nedza authored Dec 14, 2023
1 parent cd345c9 commit 62f81fb
Show file tree
Hide file tree
Showing 9 changed files with 405 additions and 57 deletions.
18 changes: 11 additions & 7 deletions doc/controllers/subscription-components.md
Original file line number Diff line number Diff line change
Expand Up @@ -1103,7 +1103,7 @@ A. No. Usage should be reported as one API call per component on a single subscr
```java
UsageResponse createUsage(
final int subscriptionId,
final int componentId,
final CreateUsageComponentId componentId,
final CreateUsageRequest body)
```

Expand All @@ -1112,7 +1112,7 @@ UsageResponse createUsage(
| Parameter | Type | Tags | Description |
| --- | --- | --- | --- |
| `subscriptionId` | `int` | Template, Required | The Chargify id of the subscription |
| `componentId` | `int` | Template, Required | Either the Chargify id for the component or the component's handle prefixed by `handle:` |
| `componentId` | [`CreateUsageComponentId`](../../doc/models/containers/create-usage-component-id.md) | Template, Required | This is a container for one-of cases. |
| `body` | [`CreateUsageRequest`](../../doc/models/create-usage-request.md) | Body, Optional | - |

## Response Type
Expand All @@ -1123,7 +1123,9 @@ UsageResponse createUsage(

```java
int subscriptionId = 222;
int componentId = 222;
CreateUsageComponentId componentId = CreateUsageComponentId.fromNumber(
144
);
CreateUsageRequest body = new CreateUsageRequest.Builder(
new CreateUsage.Builder()
.quantity(1000D)
Expand Down Expand Up @@ -1195,11 +1197,11 @@ List<UsageResponse> listUsages(
| Parameter | Type | Tags | Description |
| --- | --- | --- | --- |
| `subscriptionId` | `int` | Template, Required | The Chargify id of the subscription |
| `componentId` | `int` | Template, Required | Either the Chargify id for the component or the component's handle prefixed by `handle:` |
| `componentId` | [`ListUsagesInputComponentId`](../../doc/models/containers/list-usages-input-component-id.md) | Template, Required | This is a container for one-of cases. |
| `sinceId` | `Integer` | Query, Optional | Returns usages with an id greater than or equal to the one specified |
| `maxId` | `Integer` | Query, Optional | Returns usages with an id less than or equal to the one specified |
| `sinceDate` | `String` | Query, Optional | Returns usages with a created_at date greater than or equal to midnight (12:00 AM) on the date specified. |
| `untilDate` | `String` | Query, Optional | Returns usages with a created_at date less than or equal to midnight (12:00 AM) on the date specified. |
| `sinceDate` | `LocalDate` | Query, Optional | Returns usages with a created_at date greater than or equal to midnight (12:00 AM) on the date specified. |
| `untilDate` | `LocalDate` | Query, Optional | Returns usages with a created_at date less than or equal to midnight (12:00 AM) on the date specified. |
| `page` | `Integer` | Query, Optional | Result records are organized in pages. By default, the first page of results is displayed. The page parameter specifies a page number of results to fetch. You can start navigating through the pages to consume the results. You do this by passing in a page parameter. Retrieve the next page by adding ?page=2 to the query string. If there are no results to return, then an empty result set will be returned.<br>Use in query `page=1`.<br>**Default**: `1`<br>**Constraints**: `>= 1` |
| `perPage` | `Integer` | Query, Optional | This parameter indicates how many records to fetch in each request. Default value is 20. The maximum allowed values is 200; any per_page value over 200 will be changed to 200.<br>Use in query `per_page=200`.<br>**Default**: `20`<br>**Constraints**: `<= 200` |

Expand All @@ -1212,7 +1214,9 @@ List<UsageResponse> listUsages(
```java
ListUsagesInput listUsagesInput = new ListUsagesInput.Builder(
222,
222
ListUsagesInputComponentId.fromNumber(
144
)
)
.page(2)
.perPage(50)
Expand Down
14 changes: 14 additions & 0 deletions doc/models/containers/create-usage-component-id.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

# Create Usage Component Id

## Class Name

`CreateUsageComponentId`

## Cases

| Type | Factory Method |
| --- | --- |
| `int` | CreateUsageComponentId.fromNumber(int number) |
| `String` | CreateUsageComponentId.fromString(String string) |

14 changes: 14 additions & 0 deletions doc/models/containers/list-usages-input-component-id.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

# List Usages Input Component Id

## Class Name

`ListUsagesInputComponentId`

## Cases

| Type | Factory Method |
| --- | --- |
| `int` | ListUsagesInputComponentId.fromNumber(int number) |
| `String` | ListUsagesInputComponentId.fromString(String string) |

7 changes: 5 additions & 2 deletions doc/models/subscription-component-subscription.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,17 @@ An optional object, will be returned if provided `include=subscription` query pa

| Name | Type | Tags | Description | Getter | Setter |
| --- | --- | --- | --- | --- | --- |
| `State` | `String` | Optional | - | String getState() | setState(String state) |
| `State` | `Object` | Optional | - | Object getState() | setState(Object state) |
| `UpdatedAt` | `String` | Optional | - | String getUpdatedAt() | setUpdatedAt(String updatedAt) |

## Example (as JSON)

```json
{
"state": "state0",
"state": {
"key1": "val1",
"key2": "val2"
},
"updated_at": "updated_at0"
}
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import com.fasterxml.jackson.core.JsonProcessingException;
import com.maxio.advancedbilling.ApiHelper;
import com.maxio.advancedbilling.DateTimeHelper;
import com.maxio.advancedbilling.Server;
import com.maxio.advancedbilling.exceptions.ApiException;
import com.maxio.advancedbilling.exceptions.ComponentAllocationErrorException;
Expand All @@ -33,6 +34,7 @@
import com.maxio.advancedbilling.models.SubscriptionStateFilter;
import com.maxio.advancedbilling.models.UpdateAllocationExpirationDate;
import com.maxio.advancedbilling.models.UsageResponse;
import com.maxio.advancedbilling.models.containers.CreateUsageComponentId;
import io.apimatic.core.ApiCall;
import io.apimatic.core.ErrorCase;
import io.apimatic.core.GlobalConfiguration;
Expand Down Expand Up @@ -696,7 +698,7 @@ private ApiCall<Void, ApiException> prepareDeletePrepaidUsageAllocationRequest(
*/
public UsageResponse createUsage(
final int subscriptionId,
final int componentId,
final CreateUsageComponentId componentId,
final CreateUsageRequest body) throws ApiException, IOException {
return prepareCreateUsageRequest(subscriptionId, componentId, body).execute();
}
Expand All @@ -706,7 +708,7 @@ public UsageResponse createUsage(
*/
private ApiCall<UsageResponse, ApiException> prepareCreateUsageRequest(
final int subscriptionId,
final int componentId,
final CreateUsageComponentId componentId,
final CreateUsageRequest body) throws JsonProcessingException, IOException {
return new ApiCall.Builder<UsageResponse, ApiException>()
.globalConfig(getGlobalConfiguration())
Expand All @@ -717,7 +719,7 @@ private ApiCall<UsageResponse, ApiException> prepareCreateUsageRequest(
.bodySerializer(() -> ApiHelper.serialize(body))
.templateParam(param -> param.key("subscription_id").value(subscriptionId).isRequired(false)
.shouldEncode(true))
.templateParam(param -> param.key("component_id").value(componentId).isRequired(false)
.templateParam(param -> param.key("component_id").value(componentId)
.shouldEncode(true))
.headerParam(param -> param.key("Content-Type")
.value("application/json").isRequired(false))
Expand Down Expand Up @@ -772,16 +774,16 @@ private ApiCall<List<UsageResponse>, ApiException> prepareListUsagesRequest(
.queryParam(param -> param.key("max_id")
.value(input.getMaxId()).isRequired(false))
.queryParam(param -> param.key("since_date")
.value(input.getSinceDate()).isRequired(false))
.value(DateTimeHelper.toSimpleDate(input.getSinceDate())).isRequired(false))
.queryParam(param -> param.key("until_date")
.value(input.getUntilDate()).isRequired(false))
.value(DateTimeHelper.toSimpleDate(input.getUntilDate())).isRequired(false))
.queryParam(param -> param.key("page")
.value(input.getPage()).isRequired(false))
.queryParam(param -> param.key("per_page")
.value(input.getPerPage()).isRequired(false))
.templateParam(param -> param.key("subscription_id").value(input.getSubscriptionId()).isRequired(false)
.shouldEncode(true))
.templateParam(param -> param.key("component_id").value(input.getComponentId()).isRequired(false)
.templateParam(param -> param.key("component_id").value(input.getComponentId())
.shouldEncode(true))
.headerParam(param -> param.key("accept").value("application/json"))
.authenticationKey(BaseController.AUTHENTICATION_KEY)
Expand Down
73 changes: 41 additions & 32 deletions src/main/java/com/maxio/advancedbilling/models/ListUsagesInput.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,22 @@
import com.fasterxml.jackson.annotation.JsonGetter;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonSetter;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.maxio.advancedbilling.DateTimeHelper;
import com.maxio.advancedbilling.models.containers.ListUsagesInputComponentId;
import java.time.LocalDate;

/**
* This is a model class for ListUsagesInput type.
*/
public class ListUsagesInput {
private int subscriptionId;
private int componentId;
private ListUsagesInputComponentId componentId;
private Integer sinceId;
private Integer maxId;
private String sinceDate;
private String untilDate;
private LocalDate sinceDate;
private LocalDate untilDate;
private Integer page;
private Integer perPage;

Expand All @@ -34,21 +39,21 @@ public ListUsagesInput() {
/**
* Initialization constructor.
* @param subscriptionId int value for subscriptionId.
* @param componentId int value for componentId.
* @param componentId ListUsagesInputComponentId value for componentId.
* @param sinceId Integer value for sinceId.
* @param maxId Integer value for maxId.
* @param sinceDate String value for sinceDate.
* @param untilDate String value for untilDate.
* @param sinceDate LocalDate value for sinceDate.
* @param untilDate LocalDate value for untilDate.
* @param page Integer value for page.
* @param perPage Integer value for perPage.
*/
public ListUsagesInput(
int subscriptionId,
int componentId,
ListUsagesInputComponentId componentId,
Integer sinceId,
Integer maxId,
String sinceDate,
String untilDate,
LocalDate sinceDate,
LocalDate untilDate,
Integer page,
Integer perPage) {
this.subscriptionId = subscriptionId;
Expand Down Expand Up @@ -84,20 +89,20 @@ public void setSubscriptionId(int subscriptionId) {
/**
* Getter for ComponentId.
* Either the Chargify id for the component or the component's handle prefixed by `handle:`
* @return Returns the int
* @return Returns the ListUsagesInputComponentId
*/
@JsonGetter("component_id")
public int getComponentId() {
public ListUsagesInputComponentId getComponentId() {
return componentId;
}

/**
* Setter for ComponentId.
* Either the Chargify id for the component or the component's handle prefixed by `handle:`
* @param componentId Value for int
* @param componentId Value for ListUsagesInputComponentId
*/
@JsonSetter("component_id")
public void setComponentId(int componentId) {
public void setComponentId(ListUsagesInputComponentId componentId) {
this.componentId = componentId;
}

Expand Down Expand Up @@ -147,45 +152,49 @@ public void setMaxId(Integer maxId) {
* Getter for SinceDate.
* Returns usages with a created_at date greater than or equal to midnight (12:00 AM) on the
* date specified.
* @return Returns the String
* @return Returns the LocalDate
*/
@JsonGetter("since_date")
@JsonInclude(JsonInclude.Include.NON_NULL)
public String getSinceDate() {
@JsonSerialize(using = DateTimeHelper.SimpleDateSerializer.class)
public LocalDate getSinceDate() {
return sinceDate;
}

/**
* Setter for SinceDate.
* Returns usages with a created_at date greater than or equal to midnight (12:00 AM) on the
* date specified.
* @param sinceDate Value for String
* @param sinceDate Value for LocalDate
*/
@JsonSetter("since_date")
public void setSinceDate(String sinceDate) {
@JsonDeserialize(using = DateTimeHelper.SimpleDateDeserializer.class)
public void setSinceDate(LocalDate sinceDate) {
this.sinceDate = sinceDate;
}

/**
* Getter for UntilDate.
* Returns usages with a created_at date less than or equal to midnight (12:00 AM) on the date
* specified.
* @return Returns the String
* @return Returns the LocalDate
*/
@JsonGetter("until_date")
@JsonInclude(JsonInclude.Include.NON_NULL)
public String getUntilDate() {
@JsonSerialize(using = DateTimeHelper.SimpleDateSerializer.class)
public LocalDate getUntilDate() {
return untilDate;
}

/**
* Setter for UntilDate.
* Returns usages with a created_at date less than or equal to midnight (12:00 AM) on the date
* specified.
* @param untilDate Value for String
* @param untilDate Value for LocalDate
*/
@JsonSetter("until_date")
public void setUntilDate(String untilDate) {
@JsonDeserialize(using = DateTimeHelper.SimpleDateDeserializer.class)
public void setUntilDate(LocalDate untilDate) {
this.untilDate = untilDate;
}

Expand Down Expand Up @@ -276,11 +285,11 @@ public Builder toBuilder() {
*/
public static class Builder {
private int subscriptionId;
private int componentId;
private ListUsagesInputComponentId componentId;
private Integer sinceId;
private Integer maxId;
private String sinceDate;
private String untilDate;
private LocalDate sinceDate;
private LocalDate untilDate;
private Integer page = 1;
private Integer perPage = 20;

Expand All @@ -293,9 +302,9 @@ public Builder() {
/**
* Initialization constructor.
* @param subscriptionId int value for subscriptionId.
* @param componentId int value for componentId.
* @param componentId ListUsagesInputComponentId value for componentId.
*/
public Builder(int subscriptionId, int componentId) {
public Builder(int subscriptionId, ListUsagesInputComponentId componentId) {
this.subscriptionId = subscriptionId;
this.componentId = componentId;
}
Expand All @@ -312,10 +321,10 @@ public Builder subscriptionId(int subscriptionId) {

/**
* Setter for componentId.
* @param componentId int value for componentId.
* @param componentId ListUsagesInputComponentId value for componentId.
* @return Builder
*/
public Builder componentId(int componentId) {
public Builder componentId(ListUsagesInputComponentId componentId) {
this.componentId = componentId;
return this;
}
Expand All @@ -342,20 +351,20 @@ public Builder maxId(Integer maxId) {

/**
* Setter for sinceDate.
* @param sinceDate String value for sinceDate.
* @param sinceDate LocalDate value for sinceDate.
* @return Builder
*/
public Builder sinceDate(String sinceDate) {
public Builder sinceDate(LocalDate sinceDate) {
this.sinceDate = sinceDate;
return this;
}

/**
* Setter for untilDate.
* @param untilDate String value for untilDate.
* @param untilDate LocalDate value for untilDate.
* @return Builder
*/
public Builder untilDate(String untilDate) {
public Builder untilDate(LocalDate untilDate) {
this.untilDate = untilDate;
return this;
}
Expand Down
Loading

0 comments on commit 62f81fb

Please sign in to comment.