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-582] DE-749 - Improvements in the Account Balance, Prepayment models and "createPrepayment" endpoint #122

Closed
wants to merge 1 commit into from
Closed
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
8 changes: 7 additions & 1 deletion doc/controllers/subscription-invoice-account.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ try {
"prepayment": {
"id": 1,
"subscription_id": 1,
"amount_in_cents": 10000,
"amount": 10000,
"memo": "John Doe - Prepayment",
"created_at": "2020-07-31T05:52:32-04:00",
"starting_balance_in_cents": 0,
Expand All @@ -121,6 +121,12 @@ try {
}
```

## Errors

| HTTP Status Code | Error Description | Exception Class |
| --- | --- | --- |
| 422 | Unprocessable Entity (WebDAV) | `ApiException` |


# List Prepayments

Expand Down
6 changes: 5 additions & 1 deletion doc/models/account-balance.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,16 @@
| Name | Type | Tags | Description | Getter | Setter |
| --- | --- | --- | --- | --- | --- |
| `BalanceInCents` | `Long` | Optional | The balance in cents. | Long getBalanceInCents() | setBalanceInCents(Long balanceInCents) |
| `AutomaticBalanceInCents` | `Long` | Optional | The automatic balance in cents. | Long getAutomaticBalanceInCents() | setAutomaticBalanceInCents(Long automaticBalanceInCents) |
| `RemittanceBalanceInCents` | `Long` | Optional | The remittance balance in cents. | Long getRemittanceBalanceInCents() | setRemittanceBalanceInCents(Long remittanceBalanceInCents) |

## Example (as JSON)

```json
{
"balance_in_cents": 16
"balance_in_cents": 16,
"automatic_balance_in_cents": 226,
"remittance_balance_in_cents": 62
}
```

22 changes: 18 additions & 4 deletions doc/models/account-balances.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
| Name | Type | Tags | Description | Getter | Setter |
| --- | --- | --- | --- | --- | --- |
| `OpenInvoices` | [`AccountBalance`](../../doc/models/account-balance.md) | Optional | The balance, in cents, of the sum of the subscription's open, payable invoices. | AccountBalance getOpenInvoices() | setOpenInvoices(AccountBalance openInvoices) |
| `PendingInvoices` | [`AccountBalance`](../../doc/models/account-balance.md) | Optional | The balance, in cents, of the sum of the subscription's pending, payable invoices. | AccountBalance getPendingInvoices() | setPendingInvoices(AccountBalance pendingInvoices) |
| `PendingDiscounts` | [`AccountBalance`](../../doc/models/account-balance.md) | Optional | The balance, in cents, of the subscription's Pending Discount account. | AccountBalance getPendingDiscounts() | setPendingDiscounts(AccountBalance pendingDiscounts) |
| `ServiceCredits` | [`AccountBalance`](../../doc/models/account-balance.md) | Optional | The balance, in cents, of the subscription's Service Credit account. | AccountBalance getServiceCredits() | setServiceCredits(AccountBalance serviceCredits) |
| `Prepayments` | [`AccountBalance`](../../doc/models/account-balance.md) | Optional | The balance, in cents, of the subscription's Prepayment account. | AccountBalance getPrepayments() | setPrepayments(AccountBalance prepayments) |
Expand All @@ -19,16 +20,29 @@
```json
{
"open_invoices": {
"balance_in_cents": 40
"balance_in_cents": 40,
"automatic_balance_in_cents": 202,
"remittance_balance_in_cents": 170
},
"pending_invoices": {
"balance_in_cents": 0,
"automatic_balance_in_cents": 242,
"remittance_balance_in_cents": 46
},
"pending_discounts": {
"balance_in_cents": 88
"balance_in_cents": 88,
"automatic_balance_in_cents": 154,
"remittance_balance_in_cents": 134
},
"service_credits": {
"balance_in_cents": 84
"balance_in_cents": 84,
"automatic_balance_in_cents": 70,
"remittance_balance_in_cents": 38
},
"prepayments": {
"balance_in_cents": 192
"balance_in_cents": 192,
"automatic_balance_in_cents": 178,
"remittance_balance_in_cents": 146
}
}
```
Expand Down
1 change: 1 addition & 0 deletions doc/models/coupon.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
| `DiscountType` | [`DiscountType`](../../doc/models/discount-type.md) | Optional | - | DiscountType getDiscountType() | setDiscountType(DiscountType discountType) |
| `ExcludeMidPeriodAllocations` | `Boolean` | Optional | - | Boolean getExcludeMidPeriodAllocations() | setExcludeMidPeriodAllocations(Boolean excludeMidPeriodAllocations) |
| `ApplyOnCancelAtEndOfPeriod` | `Boolean` | Optional | - | Boolean getApplyOnCancelAtEndOfPeriod() | setApplyOnCancelAtEndOfPeriod(Boolean applyOnCancelAtEndOfPeriod) |
| `ApplyOnSubscriptionExpiration` | `Boolean` | Optional | - | Boolean getApplyOnSubscriptionExpiration() | setApplyOnSubscriptionExpiration(Boolean applyOnSubscriptionExpiration) |
| `CouponRestrictions` | [`List<CouponRestriction>`](../../doc/models/coupon-restriction.md) | Optional | - | List<CouponRestriction> getCouponRestrictions() | setCouponRestrictions(List<CouponRestriction> couponRestrictions) |

## Example (as JSON)
Expand Down
1 change: 1 addition & 0 deletions doc/models/create-or-update-flat-amount-coupon.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
| `CompoundingStrategy` | [`CompoundingStrategy`](../../doc/models/compounding-strategy.md) | Optional | - | CompoundingStrategy getCompoundingStrategy() | setCompoundingStrategy(CompoundingStrategy compoundingStrategy) |
| `ExcludeMidPeriodAllocations` | `Boolean` | Optional | - | Boolean getExcludeMidPeriodAllocations() | setExcludeMidPeriodAllocations(Boolean excludeMidPeriodAllocations) |
| `ApplyOnCancelAtEndOfPeriod` | `Boolean` | Optional | - | Boolean getApplyOnCancelAtEndOfPeriod() | setApplyOnCancelAtEndOfPeriod(Boolean applyOnCancelAtEndOfPeriod) |
| `ApplyOnSubscriptionExpiration` | `Boolean` | Optional | - | Boolean getApplyOnSubscriptionExpiration() | setApplyOnSubscriptionExpiration(Boolean applyOnSubscriptionExpiration) |

## Example (as JSON)

Expand Down
1 change: 1 addition & 0 deletions doc/models/create-or-update-percentage-coupon.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
| `CompoundingStrategy` | [`CompoundingStrategy`](../../doc/models/compounding-strategy.md) | Optional | - | CompoundingStrategy getCompoundingStrategy() | setCompoundingStrategy(CompoundingStrategy compoundingStrategy) |
| `ExcludeMidPeriodAllocations` | `Boolean` | Optional | - | Boolean getExcludeMidPeriodAllocations() | setExcludeMidPeriodAllocations(Boolean excludeMidPeriodAllocations) |
| `ApplyOnCancelAtEndOfPeriod` | `Boolean` | Optional | - | Boolean getApplyOnCancelAtEndOfPeriod() | setApplyOnCancelAtEndOfPeriod(Boolean applyOnCancelAtEndOfPeriod) |
| `ApplyOnSubscriptionExpiration` | `Boolean` | Optional | - | Boolean getApplyOnSubscriptionExpiration() | setApplyOnSubscriptionExpiration(Boolean applyOnSubscriptionExpiration) |

## Example (as JSON)

Expand Down
2 changes: 1 addition & 1 deletion doc/models/create-prepayment-response.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"prepayment": {
"id": 38,
"subscription_id": 148,
"amount_in_cents": 124,
"amount": 136,
"memo": "memo2",
"created_at": "2016-03-13T12:52:32.123Z"
}
Expand Down
10 changes: 5 additions & 5 deletions doc/models/created-prepayment.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@

| Name | Type | Tags | Description | Getter | Setter |
| --- | --- | --- | --- | --- | --- |
| `Id` | `Integer` | Optional | - | Integer getId() | setId(Integer id) |
| `SubscriptionId` | `Integer` | Optional | - | Integer getSubscriptionId() | setSubscriptionId(Integer subscriptionId) |
| `AmountInCents` | `Long` | Optional | - | Long getAmountInCents() | setAmountInCents(Long amountInCents) |
| `Id` | `Long` | Optional | **Constraints**: `>= 1` | Long getId() | setId(Long id) |
| `SubscriptionId` | `Integer` | Optional | **Constraints**: `>= 1` | Integer getSubscriptionId() | setSubscriptionId(Integer subscriptionId) |
| `Amount` | `Long` | Optional | **Constraints**: `>= 0.01` | Long getAmount() | setAmount(Long amount) |
| `Memo` | `String` | Optional | - | String getMemo() | setMemo(String memo) |
| `CreatedAt` | `ZonedDateTime` | Optional | - | ZonedDateTime getCreatedAt() | setCreatedAt(ZonedDateTime createdAt) |
| `StartingBalanceInCents` | `Long` | Optional | - | Long getStartingBalanceInCents() | setStartingBalanceInCents(Long startingBalanceInCents) |
| `StartingBalanceInCents` | `Long` | Optional | **Constraints**: `>= 0` | Long getStartingBalanceInCents() | setStartingBalanceInCents(Long startingBalanceInCents) |
| `EndingBalanceInCents` | `Long` | Optional | - | Long getEndingBalanceInCents() | setEndingBalanceInCents(Long endingBalanceInCents) |

## Example (as JSON)
Expand All @@ -23,7 +23,7 @@
{
"id": 110,
"subscription_id": 220,
"amount_in_cents": 196,
"amount": 208,
"memo": "memo6",
"created_at": "2016-03-13T12:52:32.123Z"
}
Expand Down
16 changes: 12 additions & 4 deletions doc/models/subscription-group-balances.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,24 @@
```json
{
"prepayments": {
"balance_in_cents": 192
"balance_in_cents": 192,
"automatic_balance_in_cents": 178,
"remittance_balance_in_cents": 146
},
"service_credits": {
"balance_in_cents": 84
"balance_in_cents": 84,
"automatic_balance_in_cents": 70,
"remittance_balance_in_cents": 38
},
"open_invoices": {
"balance_in_cents": 40
"balance_in_cents": 40,
"automatic_balance_in_cents": 202,
"remittance_balance_in_cents": 170
},
"pending_discounts": {
"balance_in_cents": 88
"balance_in_cents": 88,
"automatic_balance_in_cents": 154,
"remittance_balance_in_cents": 134
}
}
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ private ApiCall<CreatePrepaymentResponse, ApiException> prepareCreatePrepaymentR
.deserializer(
response -> ApiHelper.deserialize(response, CreatePrepaymentResponse.class))
.nullify404(false)
.localErrorCase("422",
ErrorCase.setTemplate("HTTP Response Not OK. Status code: {$statusCode}. Response: '{$response.body}'.",
(reason, context) -> new ApiException(reason, context)))
.globalErrorCase(GLOBAL_ERROR_CASES))
.endpointConfiguration(param -> param
.arraySerializationFormat(ArraySerializationFormat.CSV))
Expand Down
155 changes: 151 additions & 4 deletions src/main/java/com/maxio/advancedbilling/models/AccountBalance.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,18 @@
import com.fasterxml.jackson.annotation.JsonGetter;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonSetter;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import io.apimatic.core.types.BaseModel;
import io.apimatic.core.types.OptionalNullable;

/**
* This is a model class for AccountBalance type.
*/
public class AccountBalance
extends BaseModel {
private Long balanceInCents;
private OptionalNullable<Long> automaticBalanceInCents;
private OptionalNullable<Long> remittanceBalanceInCents;

/**
* Default constructor.
Expand All @@ -27,10 +31,30 @@ public AccountBalance() {
/**
* Initialization constructor.
* @param balanceInCents Long value for balanceInCents.
* @param automaticBalanceInCents Long value for automaticBalanceInCents.
* @param remittanceBalanceInCents Long value for remittanceBalanceInCents.
*/
public AccountBalance(
Long balanceInCents) {
Long balanceInCents,
Long automaticBalanceInCents,
Long remittanceBalanceInCents) {
this.balanceInCents = balanceInCents;
this.automaticBalanceInCents = OptionalNullable.of(automaticBalanceInCents);
this.remittanceBalanceInCents = OptionalNullable.of(remittanceBalanceInCents);
}

/**
* Initialization constructor.
* @param balanceInCents Long value for balanceInCents.
* @param automaticBalanceInCents Long value for automaticBalanceInCents.
* @param remittanceBalanceInCents Long value for remittanceBalanceInCents.
*/

protected AccountBalance(Long balanceInCents, OptionalNullable<Long> automaticBalanceInCents,
OptionalNullable<Long> remittanceBalanceInCents) {
this.balanceInCents = balanceInCents;
this.automaticBalanceInCents = automaticBalanceInCents;
this.remittanceBalanceInCents = remittanceBalanceInCents;
}

/**
Expand All @@ -54,14 +78,94 @@ public void setBalanceInCents(Long balanceInCents) {
this.balanceInCents = balanceInCents;
}

/**
* Internal Getter for AutomaticBalanceInCents.
* The automatic balance in cents.
* @return Returns the Internal Long
*/
@JsonGetter("automatic_balance_in_cents")
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonSerialize(using = OptionalNullable.Serializer.class)
protected OptionalNullable<Long> internalGetAutomaticBalanceInCents() {
return this.automaticBalanceInCents;
}

/**
* Getter for AutomaticBalanceInCents.
* The automatic balance in cents.
* @return Returns the Long
*/
public Long getAutomaticBalanceInCents() {
return OptionalNullable.getFrom(automaticBalanceInCents);
}

/**
* Setter for AutomaticBalanceInCents.
* The automatic balance in cents.
* @param automaticBalanceInCents Value for Long
*/
@JsonSetter("automatic_balance_in_cents")
public void setAutomaticBalanceInCents(Long automaticBalanceInCents) {
this.automaticBalanceInCents = OptionalNullable.of(automaticBalanceInCents);
}

/**
* UnSetter for AutomaticBalanceInCents.
* The automatic balance in cents.
*/
public void unsetAutomaticBalanceInCents() {
automaticBalanceInCents = null;
}

/**
* Internal Getter for RemittanceBalanceInCents.
* The remittance balance in cents.
* @return Returns the Internal Long
*/
@JsonGetter("remittance_balance_in_cents")
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonSerialize(using = OptionalNullable.Serializer.class)
protected OptionalNullable<Long> internalGetRemittanceBalanceInCents() {
return this.remittanceBalanceInCents;
}

/**
* Getter for RemittanceBalanceInCents.
* The remittance balance in cents.
* @return Returns the Long
*/
public Long getRemittanceBalanceInCents() {
return OptionalNullable.getFrom(remittanceBalanceInCents);
}

/**
* Setter for RemittanceBalanceInCents.
* The remittance balance in cents.
* @param remittanceBalanceInCents Value for Long
*/
@JsonSetter("remittance_balance_in_cents")
public void setRemittanceBalanceInCents(Long remittanceBalanceInCents) {
this.remittanceBalanceInCents = OptionalNullable.of(remittanceBalanceInCents);
}

/**
* UnSetter for RemittanceBalanceInCents.
* The remittance balance in cents.
*/
public void unsetRemittanceBalanceInCents() {
remittanceBalanceInCents = null;
}

/**
* Converts this AccountBalance into string format.
* @return String representation of this class
*/
@Override
public String toString() {
return "AccountBalance [" + "balanceInCents=" + balanceInCents + ", additionalProperties="
+ getAdditionalProperties() + "]";
return "AccountBalance [" + "balanceInCents=" + balanceInCents
+ ", automaticBalanceInCents=" + automaticBalanceInCents
+ ", remittanceBalanceInCents=" + remittanceBalanceInCents
+ ", additionalProperties=" + getAdditionalProperties() + "]";
}

/**
Expand All @@ -72,6 +176,8 @@ public String toString() {
public Builder toBuilder() {
Builder builder = new Builder()
.balanceInCents(getBalanceInCents());
builder.automaticBalanceInCents = internalGetAutomaticBalanceInCents();
builder.remittanceBalanceInCents = internalGetRemittanceBalanceInCents();
return builder;
}

Expand All @@ -80,6 +186,8 @@ public Builder toBuilder() {
*/
public static class Builder {
private Long balanceInCents;
private OptionalNullable<Long> automaticBalanceInCents;
private OptionalNullable<Long> remittanceBalanceInCents;



Expand All @@ -93,12 +201,51 @@ public Builder balanceInCents(Long balanceInCents) {
return this;
}

/**
* Setter for automaticBalanceInCents.
* @param automaticBalanceInCents Long value for automaticBalanceInCents.
* @return Builder
*/
public Builder automaticBalanceInCents(Long automaticBalanceInCents) {
this.automaticBalanceInCents = OptionalNullable.of(automaticBalanceInCents);
return this;
}

/**
* UnSetter for automaticBalanceInCents.
* @return Builder
*/
public Builder unsetAutomaticBalanceInCents() {
automaticBalanceInCents = null;
return this;
}

/**
* Setter for remittanceBalanceInCents.
* @param remittanceBalanceInCents Long value for remittanceBalanceInCents.
* @return Builder
*/
public Builder remittanceBalanceInCents(Long remittanceBalanceInCents) {
this.remittanceBalanceInCents = OptionalNullable.of(remittanceBalanceInCents);
return this;
}

/**
* UnSetter for remittanceBalanceInCents.
* @return Builder
*/
public Builder unsetRemittanceBalanceInCents() {
remittanceBalanceInCents = null;
return this;
}

/**
* Builds a new {@link AccountBalance} object using the set fields.
* @return {@link AccountBalance}
*/
public AccountBalance build() {
return new AccountBalance(balanceInCents);
return new AccountBalance(balanceInCents, automaticBalanceInCents,
remittanceBalanceInCents);
}
}
}
Loading
Loading