diff --git a/api.md b/api.md index 1494c41..0074768 100644 --- a/api.md +++ b/api.md @@ -14,7 +14,7 @@ item from that page on, and `pages()` every page, fetching the next ones on dema the response body as received. The async client's pages have `nextPage()`, `forEach(...)`, `forEachPage(...)` and `toList()`, returning `CompletableFuture`s. -[Add ons](#add-ons) · [Add ons entitlements](#add-ons-entitlements) · [Batch jobs](#batch-jobs) · [Checkout sessions](#checkout-sessions) · [Connect](#connect) · [Coupons](#coupons) · [Credit notes](#credit-notes) · [Custom properties](#custom-properties) · [Customers](#customers) · [Entitlements](#entitlements) · [Events](#events) · [Features](#features) · [Invoices](#invoices) · [Metrics](#metrics) · [Oauth](#oauth) · [Oauth apps](#oauth-apps) · [Plans](#plans) · [Plans versions](#plans-versions) · [Product families](#product-families) · [Products](#products) · [Products entitlements](#products-entitlements) · [Subscriptions](#subscriptions) · [Usage](#usage) · [Webhook endpoints](#webhook-endpoints) · [Webhook endpoints endpoints](#webhook-endpoints-endpoints) +[Add ons](#add-ons) · [Add ons entitlements](#add-ons-entitlements) · [Batch jobs](#batch-jobs) · [Budgets](#budgets) · [Checkout sessions](#checkout-sessions) · [Checks](#checks) · [Connect](#connect) · [Coupons](#coupons) · [Credit notes](#credit-notes) · [Credit units](#credit-units) · [Credit units prices](#credit-units-prices) · [Credits](#credits) · [Credits grants](#credits-grants) · [Credits wallets](#credits-wallets) · [Custom properties](#custom-properties) · [Customers](#customers) · [Entitlements](#entitlements) · [Events](#events) · [Features](#features) · [Invoices](#invoices) · [Metrics](#metrics) · [Oauth](#oauth) · [Oauth apps](#oauth-apps) · [Plans](#plans) · [Plans versions](#plans-versions) · [Product families](#product-families) · [Products](#products) · [Products entitlements](#products-entitlements) · [Subscriptions](#subscriptions) · [Usage](#usage) · [Usage customer](#usage-customer) · [Usage costs](#usage-costs) · [Usage costs customer](#usage-costs-customer) · [Usage costs subscription](#usage-costs-subscription) · [Webhook endpoints](#webhook-endpoints) · [Webhook endpoints endpoints](#webhook-endpoints-endpoints) ## Add ons @@ -48,6 +48,17 @@ the response body as received. The async client's pages have `nextPage()`, `forE | `BatchJobDetailResponse client.batchJobs().retrieve(String batchJobId)` | `GET /api/v1/batch-jobs/{batch_job_id}` | [`BatchJobDetailResponse`](src/main/java/com/meteroid/models/BatchJobDetailResponse.java) | | `BatchJobsListFailuresPage client.batchJobs().listFailures(String batchJobId, [BatchJobsListFailuresOptions options])` | `GET /api/v1/batch-jobs/{batch_job_id}/failures` | [page](src/main/java/com/meteroid/api/BatchJobsListFailuresPage.java) of [`BatchJobItemFailureResponse`](src/main/java/com/meteroid/models/BatchJobItemFailureResponse.java), with the properties of [`BatchJobFailuresResponse`](src/main/java/com/meteroid/models/BatchJobFailuresResponse.java) | +## Budgets + +[`client.budgets()`](src/main/java/com/meteroid/api/Budgets.java) + +| Method | Request | Returns | +| --- | --- | --- | +| `BudgetsListPage client.budgets().list(String idOrAlias, [BudgetsListOptions options])` | `GET /api/v1/customers/{id_or_alias}/budgets` | [page](src/main/java/com/meteroid/api/BudgetsListPage.java) of [`Budget`](src/main/java/com/meteroid/models/Budget.java), with the properties of [`BudgetListResponse`](src/main/java/com/meteroid/models/BudgetListResponse.java) | +| `Budget client.budgets().create(String idOrAlias, String idempotencyKey, CreateBudgetRequest createBudgetRequest)` | `POST /api/v1/customers/{id_or_alias}/budgets` | [`Budget`](src/main/java/com/meteroid/models/Budget.java) | +| `Budget client.budgets().update(String idOrAlias, String budgetId, String idempotencyKey, PatchBudgetRequest patchBudgetRequest)` | `PATCH /api/v1/customers/{id_or_alias}/budgets/{budget_id}` | [`Budget`](src/main/java/com/meteroid/models/Budget.java) | +| `Budget client.budgets().archive(String idOrAlias, String budgetId, String idempotencyKey)` | `POST /api/v1/customers/{id_or_alias}/budgets/{budget_id}/archive` | [`Budget`](src/main/java/com/meteroid/models/Budget.java) | + ## Checkout sessions [`client.checkoutSessions()`](src/main/java/com/meteroid/api/CheckoutSessions.java) @@ -59,6 +70,14 @@ the response body as received. The async client's pages have `nextPage()`, `forE | `GetCheckoutSessionResponse client.checkoutSessions().retrieve(String id)` | `GET /api/v1/checkout-sessions/{id}` | [`GetCheckoutSessionResponse`](src/main/java/com/meteroid/models/GetCheckoutSessionResponse.java) | | `CancelCheckoutSessionResponse client.checkoutSessions().cancel(String id)` | `POST /api/v1/checkout-sessions/{id}/cancel` | [`CancelCheckoutSessionResponse`](src/main/java/com/meteroid/models/CancelCheckoutSessionResponse.java) | +## Checks + +[`client.checks()`](src/main/java/com/meteroid/api/Checks.java) + +| Method | Request | Returns | +| --- | --- | --- | +| `EntitlementCheck client.checks().checkEntitlement(String idOrAlias, String featureIdOrCode, [ChecksCheckEntitlementOptions options])` | `GET /api/v1/customers/{id_or_alias}/entitlements/{feature_id_or_code}/check` | [`EntitlementCheck`](src/main/java/com/meteroid/models/EntitlementCheck.java) | + ## Connect [`client.connect()`](src/main/java/com/meteroid/api/Connect.java) @@ -66,7 +85,7 @@ the response body as received. The async client's pages have `nextPage()`, `forE | Method | Request | Returns | | --- | --- | --- | | `ConnectedAccountsResponse client.connect().listConnectedAccounts()` | `GET /api/v1/connected-accounts` | [`ConnectedAccountsResponse`](src/main/java/com/meteroid/models/ConnectedAccountsResponse.java) | -| `ConnectedAccount client.connect().createConnectedAccount(CreateConnectedAccountRequest createConnectedAccountRequest)` | `POST /api/v1/connected-accounts` | [`ConnectedAccount`](src/main/java/com/meteroid/models/ConnectedAccount.java) | +| `CreateConnectedAccountResponse client.connect().createConnectedAccount(CreateConnectedAccountRequest createConnectedAccountRequest)` | `POST /api/v1/connected-accounts` | [`CreateConnectedAccountResponse`](src/main/java/com/meteroid/models/CreateConnectedAccountResponse.java) | | `ConnectedAccount client.connect().retrieveConnectedAccount(String id)` | `GET /api/v1/connected-accounts/{id}` | [`ConnectedAccount`](src/main/java/com/meteroid/models/ConnectedAccount.java) | | `void client.connect().disconnectAccount(String id)` | `DELETE /api/v1/connected-accounts/{id}` | nothing | | `OnboardingLinkResponse client.connect().createOnboardingLink(String id, CreateOnboardingLinkRequest createOnboardingLinkRequest)` | `POST /api/v1/connected-accounts/{id}/onboarding` | [`OnboardingLinkResponse`](src/main/java/com/meteroid/models/OnboardingLinkResponse.java) | @@ -98,6 +117,55 @@ the response body as received. The async client's pages have `nextPage()`, `forE | `byte[] client.creditNotes().download(String creditNoteId)` | `GET /api/v1/credit-notes/{credit_note_id}/download` | bytes | | `byte[] client.creditNotes().downloadXml(String creditNoteId)` | `GET /api/v1/credit-notes/{credit_note_id}/xml` | bytes | +## Credit units + +[`client.creditUnits()`](src/main/java/com/meteroid/api/CreditUnits.java) + +| Method | Request | Returns | +| --- | --- | --- | +| `CreditUnitListResponse client.creditUnits().list([CreditUnitsListOptions options])` | `GET /api/v1/credit-units` | [`CreditUnitListResponse`](src/main/java/com/meteroid/models/CreditUnitListResponse.java) | +| `CreditUnit client.creditUnits().create(CreditUnitCreateRequest creditUnitCreateRequest)` | `POST /api/v1/credit-units` | [`CreditUnit`](src/main/java/com/meteroid/models/CreditUnit.java) | +| `CreditUnit client.creditUnits().retrieve(String id)` | `GET /api/v1/credit-units/{id}` | [`CreditUnit`](src/main/java/com/meteroid/models/CreditUnit.java) | +| `CreditUnit client.creditUnits().update(String id, CreditUnitUpdateRequest creditUnitUpdateRequest)` | `PATCH /api/v1/credit-units/{id}` | [`CreditUnit`](src/main/java/com/meteroid/models/CreditUnit.java) | + +### Credit units prices + +[`client.creditUnits().prices()`](src/main/java/com/meteroid/api/CreditUnitsPrices.java) + +| Method | Request | Returns | +| --- | --- | --- | +| `CreditUnitPriceListResponse client.creditUnits().prices().list(String id, [CreditUnitsPricesListOptions options])` | `GET /api/v1/credit-units/{id}/prices` | [`CreditUnitPriceListResponse`](src/main/java/com/meteroid/models/CreditUnitPriceListResponse.java) | +| `CreditUnitPrice client.creditUnits().prices().update(String id, String currency, CreditUnitPriceSetRequest creditUnitPriceSetRequest)` | `PUT /api/v1/credit-units/{id}/prices/{currency}` | [`CreditUnitPrice`](src/main/java/com/meteroid/models/CreditUnitPrice.java) | +| `CreditUnitPrice client.creditUnits().prices().archive(String id, String currency)` | `DELETE /api/v1/credit-units/{id}/prices/{currency}` | [`CreditUnitPrice`](src/main/java/com/meteroid/models/CreditUnitPrice.java) | + +## Credits + +[`client.credits()`](src/main/java/com/meteroid/api/Credits.java) + +| Method | Request | Returns | +| --- | --- | --- | +| `CreditsListCustomerCreditLedgerPage client.credits().listCustomerCreditLedger(String idOrAlias, [CreditsListCustomerCreditLedgerOptions options])` | `GET /api/v1/customers/{id_or_alias}/credit-ledger` | [page](src/main/java/com/meteroid/api/CreditsListCustomerCreditLedgerPage.java) of [`LedgerEntry`](src/main/java/com/meteroid/models/LedgerEntry.java), with the properties of [`LedgerListResponse`](src/main/java/com/meteroid/models/LedgerListResponse.java) | +| `TopUpResponse client.credits().createCustomerTopUp(String idOrAlias, String idempotencyKey, CreateTopUpRequest createTopUpRequest)` | `POST /api/v1/customers/{id_or_alias}/top-ups` | [`TopUpResponse`](src/main/java/com/meteroid/models/TopUpResponse.java) | + +### Credits grants + +[`client.credits().grants()`](src/main/java/com/meteroid/api/CreditsGrants.java) + +| Method | Request | Returns | +| --- | --- | --- | +| `CreditsGrantsListPage client.credits().grants().list(String idOrAlias, [CreditsGrantsListOptions options])` | `GET /api/v1/customers/{id_or_alias}/credit-grants` | [page](src/main/java/com/meteroid/api/CreditsGrantsListPage.java) of [`CreditGrant`](src/main/java/com/meteroid/models/CreditGrant.java), with the properties of [`CreditGrantListResponse`](src/main/java/com/meteroid/models/CreditGrantListResponse.java) | +| `CreditGrant client.credits().grants().create(String idOrAlias, String idempotencyKey, CreateCreditGrantRequest createCreditGrantRequest)` | `POST /api/v1/customers/{id_or_alias}/credit-grants` | [`CreditGrant`](src/main/java/com/meteroid/models/CreditGrant.java) | + +### Credits wallets + +[`client.credits().wallets()`](src/main/java/com/meteroid/api/CreditsWallets.java) + +| Method | Request | Returns | +| --- | --- | --- | +| `WalletListResponse client.credits().wallets().list(String idOrAlias, [CreditsWalletsListOptions options])` | `GET /api/v1/customers/{id_or_alias}/wallets` | [`WalletListResponse`](src/main/java/com/meteroid/models/WalletListResponse.java) | +| `WalletCheck client.credits().wallets().check(String idOrAlias, [CreditsWalletsCheckOptions options])` | `GET /api/v1/customers/{id_or_alias}/wallets/check` | [`WalletCheck`](src/main/java/com/meteroid/models/WalletCheck.java) | +| `Wallet client.credits().wallets().update(String idOrAlias, String currency, String idempotencyKey, PatchWalletRequest patchWalletRequest)` | `PATCH /api/v1/customers/{id_or_alias}/wallets/{currency}` | [`Wallet`](src/main/java/com/meteroid/models/Wallet.java) | + ## Custom properties [`client.customProperties()`](src/main/java/com/meteroid/api/CustomProperties.java) @@ -284,10 +352,43 @@ the response body as received. The async client's pages have `nextPage()`, `forE | Method | Request | Returns | | --- | --- | --- | -| `UsageResponse client.usage().retrieveCustomer(String customerId, LocalDate startDate, LocalDate endDate, [UsageRetrieveCustomerOptions options])` | `GET /api/v1/usage/customer/{customer_id}` | [`UsageResponse`](src/main/java/com/meteroid/models/UsageResponse.java) | | `UsageResponse client.usage().retrieveSubscription(String subscriptionId, [UsageRetrieveSubscriptionOptions options])` | `GET /api/v1/usage/subscription/{subscription_id}` | [`UsageResponse`](src/main/java/com/meteroid/models/UsageResponse.java) | | `UsageResponse client.usage().retrieveSummary(LocalDate startDate, LocalDate endDate, [UsageRetrieveSummaryOptions options])` | `GET /api/v1/usage/summary` | [`UsageResponse`](src/main/java/com/meteroid/models/UsageResponse.java) | +### Usage customer + +[`client.usage().customer()`](src/main/java/com/meteroid/api/UsageCustomer.java) + +| Method | Request | Returns | +| --- | --- | --- | +| `UsageResponse client.usage().customer().retrieve(String customerId, LocalDate startDate, LocalDate endDate, [UsageCustomerRetrieveOptions options])` | `GET /api/v1/usage/customer/{customer_id}` | [`UsageResponse`](src/main/java/com/meteroid/models/UsageResponse.java) | +| `UnattributedUsageResponse client.usage().customer().retrieveUnattributed(String customerId, [UsageCustomerRetrieveUnattributedOptions options])` | `GET /api/v1/usage/customer/{customer_id}/unattributed` | [`UnattributedUsageResponse`](src/main/java/com/meteroid/models/UnattributedUsageResponse.java) | + +## Usage costs + +[`client.usageCosts()`](src/main/java/com/meteroid/api/UsageCosts.java) + +| Method | Request | Returns | +| --- | --- | --- | + +### Usage costs customer + +[`client.usageCosts().customer()`](src/main/java/com/meteroid/api/UsageCostsCustomer.java) + +| Method | Request | Returns | +| --- | --- | --- | +| `UsageCostListResponse client.usageCosts().customer().listCosts(String customerId, String metric, ListCustomerUsageCostsGranularity granularity, OffsetDateTime from, OffsetDateTime to, [UsageCostsCustomerListCostsOptions options])` | `GET /api/v1/usage/customer/{customer_id}/costs` | [`UsageCostListResponse`](src/main/java/com/meteroid/models/UsageCostListResponse.java) | +| `UsageEventListResponse client.usageCosts().customer().listEvents(String customerId, String metric, OffsetDateTime from, OffsetDateTime to, [UsageCostsCustomerListEventsOptions options])` | `GET /api/v1/usage/customer/{customer_id}/events` | [`UsageEventListResponse`](src/main/java/com/meteroid/models/UsageEventListResponse.java) | + +### Usage costs subscription + +[`client.usageCosts().subscription()`](src/main/java/com/meteroid/api/UsageCostsSubscription.java) + +| Method | Request | Returns | +| --- | --- | --- | +| `UsageCostListResponse client.usageCosts().subscription().listCosts(String subscriptionId, String metric, ListSubscriptionUsageCostsGranularity granularity, OffsetDateTime from, OffsetDateTime to, [UsageCostsSubscriptionListCostsOptions options])` | `GET /api/v1/usage/subscription/{subscription_id}/costs` | [`UsageCostListResponse`](src/main/java/com/meteroid/models/UsageCostListResponse.java) | +| `UsageEventListResponse client.usageCosts().subscription().listEvents(String subscriptionId, String metric, OffsetDateTime from, OffsetDateTime to, [UsageCostsSubscriptionListEventsOptions options])` | `GET /api/v1/usage/subscription/{subscription_id}/events` | [`UsageEventListResponse`](src/main/java/com/meteroid/models/UsageEventListResponse.java) | + ## Webhook endpoints [`client.webhookEndpoints()`](src/main/java/com/meteroid/api/WebhookEndpoints.java) diff --git a/src/main/java/com/meteroid/Meteroid.java b/src/main/java/com/meteroid/Meteroid.java index 02ab491..255a7f4 100644 --- a/src/main/java/com/meteroid/Meteroid.java +++ b/src/main/java/com/meteroid/Meteroid.java @@ -3,10 +3,14 @@ import com.meteroid.api.AddOns; import com.meteroid.api.BatchJobs; +import com.meteroid.api.Budgets; import com.meteroid.api.CheckoutSessions; +import com.meteroid.api.Checks; import com.meteroid.api.Connect; import com.meteroid.api.Coupons; import com.meteroid.api.CreditNotes; +import com.meteroid.api.CreditUnits; +import com.meteroid.api.Credits; import com.meteroid.api.CustomProperties; import com.meteroid.api.Customers; import com.meteroid.api.Entitlements; @@ -21,6 +25,7 @@ import com.meteroid.api.Products; import com.meteroid.api.Subscriptions; import com.meteroid.api.Usage; +import com.meteroid.api.UsageCosts; import com.meteroid.api.WebhookEndpoints; import com.meteroid.internal.MeteroidAuth; import com.meteroid.internal.MeteroidHttpClient; @@ -58,10 +63,14 @@ public final class Meteroid implements AutoCloseable { private final MeteroidAsync async; private final AddOns addOns; private final BatchJobs batchJobs; + private final Budgets budgets; private final CheckoutSessions checkoutSessions; + private final Checks checks; private final Connect connect; private final Coupons coupons; private final CreditNotes creditNotes; + private final CreditUnits creditUnits; + private final Credits credits; private final CustomProperties customProperties; private final Customers customers; private final Entitlements entitlements; @@ -76,6 +85,7 @@ public final class Meteroid implements AutoCloseable { private final Products products; private final Subscriptions subscriptions; private final Usage usage; + private final UsageCosts usageCosts; private final WebhookEndpoints webhookEndpoints; /** @@ -131,10 +141,14 @@ public Meteroid(MeteroidOptions options) { this.httpClient = new MeteroidHttpClient(parsedUrl, defaultHeaders, options, auth); this.addOns = new AddOns(httpClient); this.batchJobs = new BatchJobs(httpClient); + this.budgets = new Budgets(httpClient); this.checkoutSessions = new CheckoutSessions(httpClient); + this.checks = new Checks(httpClient); this.connect = new Connect(httpClient); this.coupons = new Coupons(httpClient); this.creditNotes = new CreditNotes(httpClient); + this.creditUnits = new CreditUnits(httpClient); + this.credits = new Credits(httpClient); this.customProperties = new CustomProperties(httpClient); this.customers = new Customers(httpClient); this.entitlements = new Entitlements(httpClient); @@ -149,6 +163,7 @@ public Meteroid(MeteroidOptions options) { this.products = new Products(httpClient); this.subscriptions = new Subscriptions(httpClient); this.usage = new Usage(httpClient); + this.usageCosts = new UsageCosts(httpClient); this.webhookEndpoints = new WebhookEndpoints(httpClient); this.withRawResponse = new WithRawResponse(); this.async = new MeteroidAsync(this); @@ -213,6 +228,15 @@ public BatchJobs batchJobs() { return batchJobs; } + /** + * The {@code budgets} operations. + * + * @return the operations + */ + public Budgets budgets() { + return budgets; + } + /** * The {@code checkout_sessions} operations. * @@ -222,6 +246,15 @@ public CheckoutSessions checkoutSessions() { return checkoutSessions; } + /** + * The {@code checks} operations. + * + * @return the operations + */ + public Checks checks() { + return checks; + } + /** * The {@code connect} operations. * @@ -249,6 +282,24 @@ public CreditNotes creditNotes() { return creditNotes; } + /** + * The {@code credit_units} operations. + * + * @return the operations + */ + public CreditUnits creditUnits() { + return creditUnits; + } + + /** + * The {@code credits} operations. + * + * @return the operations + */ + public Credits credits() { + return credits; + } + /** * The {@code custom_properties} operations. * @@ -375,6 +426,15 @@ public Usage usage() { return usage; } + /** + * The {@code usage_costs} operations. + * + * @return the operations + */ + public UsageCosts usageCosts() { + return usageCosts; + } + /** * The {@code webhook_endpoints} operations. * @@ -406,6 +466,15 @@ public BatchJobs.WithRawResponse batchJobs() { return batchJobs.withRawResponse(); } + /** + * The {@code budgets} operations. + * + * @return the operations + */ + public Budgets.WithRawResponse budgets() { + return budgets.withRawResponse(); + } + /** * The {@code checkout_sessions} operations. * @@ -415,6 +484,15 @@ public CheckoutSessions.WithRawResponse checkoutSessions() { return checkoutSessions.withRawResponse(); } + /** + * The {@code checks} operations. + * + * @return the operations + */ + public Checks.WithRawResponse checks() { + return checks.withRawResponse(); + } + /** * The {@code connect} operations. * @@ -442,6 +520,24 @@ public CreditNotes.WithRawResponse creditNotes() { return creditNotes.withRawResponse(); } + /** + * The {@code credit_units} operations. + * + * @return the operations + */ + public CreditUnits.WithRawResponse creditUnits() { + return creditUnits.withRawResponse(); + } + + /** + * The {@code credits} operations. + * + * @return the operations + */ + public Credits.WithRawResponse credits() { + return credits.withRawResponse(); + } + /** * The {@code custom_properties} operations. * @@ -568,6 +664,15 @@ public Usage.WithRawResponse usage() { return usage.withRawResponse(); } + /** + * The {@code usage_costs} operations. + * + * @return the operations + */ + public UsageCosts.WithRawResponse usageCosts() { + return usageCosts.withRawResponse(); + } + /** * The {@code webhook_endpoints} operations. * diff --git a/src/main/java/com/meteroid/MeteroidAsync.java b/src/main/java/com/meteroid/MeteroidAsync.java index 664ea14..6d22b7d 100644 --- a/src/main/java/com/meteroid/MeteroidAsync.java +++ b/src/main/java/com/meteroid/MeteroidAsync.java @@ -3,10 +3,14 @@ import com.meteroid.api.AddOnsAsync; import com.meteroid.api.BatchJobsAsync; +import com.meteroid.api.BudgetsAsync; import com.meteroid.api.CheckoutSessionsAsync; +import com.meteroid.api.ChecksAsync; import com.meteroid.api.ConnectAsync; import com.meteroid.api.CouponsAsync; import com.meteroid.api.CreditNotesAsync; +import com.meteroid.api.CreditUnitsAsync; +import com.meteroid.api.CreditsAsync; import com.meteroid.api.CustomPropertiesAsync; import com.meteroid.api.CustomersAsync; import com.meteroid.api.EntitlementsAsync; @@ -21,6 +25,7 @@ import com.meteroid.api.ProductsAsync; import com.meteroid.api.SubscriptionsAsync; import com.meteroid.api.UsageAsync; +import com.meteroid.api.UsageCostsAsync; import com.meteroid.api.WebhookEndpointsAsync; /** @@ -33,10 +38,14 @@ public final class MeteroidAsync implements AutoCloseable { private final WithRawResponse withRawResponse; private final AddOnsAsync addOns; private final BatchJobsAsync batchJobs; + private final BudgetsAsync budgets; private final CheckoutSessionsAsync checkoutSessions; + private final ChecksAsync checks; private final ConnectAsync connect; private final CouponsAsync coupons; private final CreditNotesAsync creditNotes; + private final CreditUnitsAsync creditUnits; + private final CreditsAsync credits; private final CustomPropertiesAsync customProperties; private final CustomersAsync customers; private final EntitlementsAsync entitlements; @@ -51,16 +60,21 @@ public final class MeteroidAsync implements AutoCloseable { private final ProductsAsync products; private final SubscriptionsAsync subscriptions; private final UsageAsync usage; + private final UsageCostsAsync usageCosts; private final WebhookEndpointsAsync webhookEndpoints; MeteroidAsync(Meteroid sync) { this.sync = sync; this.addOns = new AddOnsAsync(sync.addOns()); this.batchJobs = new BatchJobsAsync(sync.batchJobs()); + this.budgets = new BudgetsAsync(sync.budgets()); this.checkoutSessions = new CheckoutSessionsAsync(sync.checkoutSessions()); + this.checks = new ChecksAsync(sync.checks()); this.connect = new ConnectAsync(sync.connect()); this.coupons = new CouponsAsync(sync.coupons()); this.creditNotes = new CreditNotesAsync(sync.creditNotes()); + this.creditUnits = new CreditUnitsAsync(sync.creditUnits()); + this.credits = new CreditsAsync(sync.credits()); this.customProperties = new CustomPropertiesAsync(sync.customProperties()); this.customers = new CustomersAsync(sync.customers()); this.entitlements = new EntitlementsAsync(sync.entitlements()); @@ -75,6 +89,7 @@ public final class MeteroidAsync implements AutoCloseable { this.products = new ProductsAsync(sync.products()); this.subscriptions = new SubscriptionsAsync(sync.subscriptions()); this.usage = new UsageAsync(sync.usage()); + this.usageCosts = new UsageCostsAsync(sync.usageCosts()); this.webhookEndpoints = new WebhookEndpointsAsync(sync.webhookEndpoints()); this.withRawResponse = new WithRawResponse(); } @@ -115,6 +130,15 @@ public BatchJobsAsync batchJobs() { return batchJobs; } + /** + * The {@code budgets} operations. + * + * @return the operations + */ + public BudgetsAsync budgets() { + return budgets; + } + /** * The {@code checkout_sessions} operations. * @@ -124,6 +148,15 @@ public CheckoutSessionsAsync checkoutSessions() { return checkoutSessions; } + /** + * The {@code checks} operations. + * + * @return the operations + */ + public ChecksAsync checks() { + return checks; + } + /** * The {@code connect} operations. * @@ -151,6 +184,24 @@ public CreditNotesAsync creditNotes() { return creditNotes; } + /** + * The {@code credit_units} operations. + * + * @return the operations + */ + public CreditUnitsAsync creditUnits() { + return creditUnits; + } + + /** + * The {@code credits} operations. + * + * @return the operations + */ + public CreditsAsync credits() { + return credits; + } + /** * The {@code custom_properties} operations. * @@ -277,6 +328,15 @@ public UsageAsync usage() { return usage; } + /** + * The {@code usage_costs} operations. + * + * @return the operations + */ + public UsageCostsAsync usageCosts() { + return usageCosts; + } + /** * The {@code webhook_endpoints} operations. * @@ -314,6 +374,15 @@ public BatchJobsAsync.WithRawResponse batchJobs() { return batchJobs.withRawResponse(); } + /** + * The {@code budgets} operations. + * + * @return the operations + */ + public BudgetsAsync.WithRawResponse budgets() { + return budgets.withRawResponse(); + } + /** * The {@code checkout_sessions} operations. * @@ -323,6 +392,15 @@ public CheckoutSessionsAsync.WithRawResponse checkoutSessions() { return checkoutSessions.withRawResponse(); } + /** + * The {@code checks} operations. + * + * @return the operations + */ + public ChecksAsync.WithRawResponse checks() { + return checks.withRawResponse(); + } + /** * The {@code connect} operations. * @@ -350,6 +428,24 @@ public CreditNotesAsync.WithRawResponse creditNotes() { return creditNotes.withRawResponse(); } + /** + * The {@code credit_units} operations. + * + * @return the operations + */ + public CreditUnitsAsync.WithRawResponse creditUnits() { + return creditUnits.withRawResponse(); + } + + /** + * The {@code credits} operations. + * + * @return the operations + */ + public CreditsAsync.WithRawResponse credits() { + return credits.withRawResponse(); + } + /** * The {@code custom_properties} operations. * @@ -476,6 +572,15 @@ public UsageAsync.WithRawResponse usage() { return usage.withRawResponse(); } + /** + * The {@code usage_costs} operations. + * + * @return the operations + */ + public UsageCostsAsync.WithRawResponse usageCosts() { + return usageCosts.withRawResponse(); + } + /** * The {@code webhook_endpoints} operations. * diff --git a/src/main/java/com/meteroid/api/Budgets.java b/src/main/java/com/meteroid/api/Budgets.java new file mode 100644 index 0000000..c6600fa --- /dev/null +++ b/src/main/java/com/meteroid/api/Budgets.java @@ -0,0 +1,662 @@ +// this file is @generated +package com.meteroid.api; + +import com.meteroid.ApiResponse; +import com.meteroid.RequestOptions; +import com.meteroid.internal.MeteroidHttpClient; +import com.meteroid.internal.Utils; +import com.meteroid.models.Budget; +import com.meteroid.models.BudgetListResponse; +import com.meteroid.models.CreateBudgetRequest; +import com.meteroid.models.PatchBudgetRequest; + +import okhttp3.Headers; +import okhttp3.HttpUrl; + +import java.util.List; +import java.util.Objects; + +/** + * The {@code budgets} operations, blocking. {@link #withRawResponse()} has the same methods + * returning the status and headers along with the body. + */ +public final class Budgets { + private final MeteroidHttpClient client; + private final WithRawResponse withRawResponse; + + /** + * The operations, sending through {@code client}. + * + * @param client the HTTP client of the SDK + */ + public Budgets(MeteroidHttpClient client) { + this.client = client; + this.withRawResponse = new WithRawResponse(); + } + + /** + * The same operations, returning the status and headers along with the body. + * + * @return the operations + */ + public WithRawResponse withRawResponse() { + return withRawResponse; + } + + /** + * List budgets + * + *

A customer's budgets, oldest first, with their estimated spend in the current billing + * period. Archived ones are left out unless requested. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @return the page: the response body, its items and the way to the next pages + */ + public BudgetsListPage list(final String idOrAlias) { + return list(idOrAlias, BudgetsListOptions.none(), RequestOptions.none()); + } + + /** + * List budgets + * + *

A customer's budgets, oldest first, with their estimated spend in the current billing + * period. Archived ones are left out unless requested. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param options the optional parameters + * @return the page: the response body, its items and the way to the next pages + */ + public BudgetsListPage list(final String idOrAlias, final BudgetsListOptions options) { + return list(idOrAlias, options, RequestOptions.none()); + } + + /** + * List budgets + * + *

A customer's budgets, oldest first, with their estimated spend in the current billing + * period. Archived ones are left out unless requested. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param requestOptions headers, timeout and retries of this call + * @return the page: the response body, its items and the way to the next pages + */ + public BudgetsListPage list(final String idOrAlias, final RequestOptions requestOptions) { + return list(idOrAlias, BudgetsListOptions.none(), requestOptions); + } + + /** + * List budgets + * + *

A customer's budgets, oldest first, with their estimated spend in the current billing + * period. Archived ones are left out unless requested. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param options the optional parameters + * @param requestOptions headers, timeout and retries of this call + * @return the page: the response body, its items and the way to the next pages + */ + public BudgetsListPage list( + final String idOrAlias, + final BudgetsListOptions options, + final RequestOptions requestOptions) { + return pageOfList( + exchangeList(idOrAlias, options, requestOptions).send(), + idOrAlias, + options, + requestOptions); + } + + MeteroidHttpClient.Exchange exchangeList( + final String idOrAlias, + final BudgetsListOptions options, + final RequestOptions requestOptions) { + Objects.requireNonNull(idOrAlias, "id_or_alias"); + Objects.requireNonNull(options, "options"); + HttpUrl.Builder url = + client.newUrlBuilder() + .addPathSegments("api/v1/customers") + .addPathSegment(Utils.pathSegment("id_or_alias", idOrAlias)) + .addPathSegments("budgets"); + Boolean value1 = options.includeArchived().orElse(null); + if (value1 != null) { + url.addQueryParameter("include_archived", Utils.serializeQueryParam(value1)); + } + Integer value2 = options.page().orElse(null); + if (value2 != null) { + url.addQueryParameter("page", Utils.serializeQueryParam(value2)); + } + Integer value3 = options.perPage().orElse(null); + if (value3 != null) { + url.addQueryParameter("per_page", Utils.serializeQueryParam(value3)); + } + return client.call("GET", url.build()) + .errors( + com.meteroid.models.RestErrorResponse.class, + "400", + "401", + "404", + "429", + "500") + .options(requestOptions) + .returning(BudgetListResponse.class); + } + + private BudgetsListPage pageOfList( + BudgetListResponse response, + final String idOrAlias, + final BudgetsListOptions options, + final RequestOptions requestOptions) { + List items = itemsOfList(response); + Integer next = nextOfList(response, items, options.page().orElse(0)); + return new BudgetsListPage( + response, + items, + next == null + ? null + : () -> + list( + idOrAlias, + options.toBuilder().page(next).build(), + requestOptions)); + } + + static List itemsOfList(BudgetListResponse response) { + return Utils.optional(response.data()).orElse(List.of()); + } + + /** The parameter of the page after {@code response}, null after the last one. */ + static Integer nextOfList(BudgetListResponse response, List items, Integer current) { + if (items.isEmpty()) { + return null; + } + long pages = + Utils.optional(response.paginationMeta()) + .flatMap(v2 -> Utils.optional(v2.totalPages())) + .map(Number::longValue) + .orElse(Long.MAX_VALUE); + if (current - 0 + 1 >= pages) { + return null; + } + return current + 1; + } + + /** + * Create a budget + * + *

Sets a spending limit for one currency the customer is billed in, with alerts at + * percentages of it, on the customer's whole spend or on one subscription's. A customer has one + * active budget per currency, and per subscription. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param idempotencyKey the {@code Idempotency-Key} required parameter + * @param createBudgetRequest the request body + * @return the response body + */ + public Budget create( + final String idOrAlias, + final String idempotencyKey, + final CreateBudgetRequest createBudgetRequest) { + return create(idOrAlias, idempotencyKey, createBudgetRequest, RequestOptions.none()); + } + + /** + * Create a budget + * + *

Sets a spending limit for one currency the customer is billed in, with alerts at + * percentages of it, on the customer's whole spend or on one subscription's. A customer has one + * active budget per currency, and per subscription. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param idempotencyKey the {@code Idempotency-Key} required parameter + * @param createBudgetRequest the request body + * @param requestOptions headers, timeout and retries of this call + * @return the response body + */ + public Budget create( + final String idOrAlias, + final String idempotencyKey, + final CreateBudgetRequest createBudgetRequest, + final RequestOptions requestOptions) { + return exchangeCreate(idOrAlias, idempotencyKey, createBudgetRequest, requestOptions) + .send(); + } + + MeteroidHttpClient.Exchange exchangeCreate( + final String idOrAlias, + final String idempotencyKey, + final CreateBudgetRequest createBudgetRequest, + final RequestOptions requestOptions) { + Objects.requireNonNull(idOrAlias, "id_or_alias"); + Objects.requireNonNull(idempotencyKey, "Idempotency-Key"); + Objects.requireNonNull(createBudgetRequest, "body"); + HttpUrl url = + client.newUrlBuilder() + .addPathSegments("api/v1/customers") + .addPathSegment(Utils.pathSegment("id_or_alias", idOrAlias)) + .addPathSegments("budgets") + .build(); + Headers.Builder headers = new Headers.Builder(); + headers.set("Idempotency-Key", Utils.serializeQueryParam(idempotencyKey)); + return client.call("POST", url) + .headers(headers.build()) + .json(createBudgetRequest) + .errors( + com.meteroid.models.RestErrorResponse.class, + "400", + "401", + "404", + "409", + "429", + "500") + .options(requestOptions) + .returning(Budget.class); + } + + /** + * Update a budget + * + *

Changes the amount, thresholds or behavior. Send the version you read as + * expected_version; a newer stored version, for instance after the customer edited + * it, is refused with 409. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param budgetId the {@code budget_id} path parameter + * @param idempotencyKey the {@code Idempotency-Key} required parameter + * @param patchBudgetRequest the request body + * @return the response body + */ + public Budget update( + final String idOrAlias, + final String budgetId, + final String idempotencyKey, + final PatchBudgetRequest patchBudgetRequest) { + return update( + idOrAlias, budgetId, idempotencyKey, patchBudgetRequest, RequestOptions.none()); + } + + /** + * Update a budget + * + *

Changes the amount, thresholds or behavior. Send the version you read as + * expected_version; a newer stored version, for instance after the customer edited + * it, is refused with 409. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param budgetId the {@code budget_id} path parameter + * @param idempotencyKey the {@code Idempotency-Key} required parameter + * @param patchBudgetRequest the request body + * @param requestOptions headers, timeout and retries of this call + * @return the response body + */ + public Budget update( + final String idOrAlias, + final String budgetId, + final String idempotencyKey, + final PatchBudgetRequest patchBudgetRequest, + final RequestOptions requestOptions) { + return exchangeUpdate( + idOrAlias, budgetId, idempotencyKey, patchBudgetRequest, requestOptions) + .send(); + } + + MeteroidHttpClient.Exchange exchangeUpdate( + final String idOrAlias, + final String budgetId, + final String idempotencyKey, + final PatchBudgetRequest patchBudgetRequest, + final RequestOptions requestOptions) { + Objects.requireNonNull(idOrAlias, "id_or_alias"); + Objects.requireNonNull(budgetId, "budget_id"); + Objects.requireNonNull(idempotencyKey, "Idempotency-Key"); + Objects.requireNonNull(patchBudgetRequest, "body"); + HttpUrl url = + client.newUrlBuilder() + .addPathSegments("api/v1/customers") + .addPathSegment(Utils.pathSegment("id_or_alias", idOrAlias)) + .addPathSegments("budgets") + .addPathSegment(Utils.pathSegment("budget_id", budgetId)) + .build(); + Headers.Builder headers = new Headers.Builder(); + headers.set("Idempotency-Key", Utils.serializeQueryParam(idempotencyKey)); + return client.call("PATCH", url) + .headers(headers.build()) + .json(patchBudgetRequest) + .errors( + com.meteroid.models.RestErrorResponse.class, + "400", + "401", + "404", + "409", + "429", + "500") + .options(requestOptions) + .returning(Budget.class); + } + + /** + * Archive a budget + * + *

Stops the budget from sending alerts and, for a HARD budget, from refusing access. + * Archiving an archived budget returns it unchanged. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param budgetId the {@code budget_id} path parameter + * @param idempotencyKey the {@code Idempotency-Key} required parameter + * @return the response body + */ + public Budget archive( + final String idOrAlias, final String budgetId, final String idempotencyKey) { + return archive(idOrAlias, budgetId, idempotencyKey, RequestOptions.none()); + } + + /** + * Archive a budget + * + *

Stops the budget from sending alerts and, for a HARD budget, from refusing access. + * Archiving an archived budget returns it unchanged. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param budgetId the {@code budget_id} path parameter + * @param idempotencyKey the {@code Idempotency-Key} required parameter + * @param requestOptions headers, timeout and retries of this call + * @return the response body + */ + public Budget archive( + final String idOrAlias, + final String budgetId, + final String idempotencyKey, + final RequestOptions requestOptions) { + return exchangeArchive(idOrAlias, budgetId, idempotencyKey, requestOptions).send(); + } + + MeteroidHttpClient.Exchange exchangeArchive( + final String idOrAlias, + final String budgetId, + final String idempotencyKey, + final RequestOptions requestOptions) { + Objects.requireNonNull(idOrAlias, "id_or_alias"); + Objects.requireNonNull(budgetId, "budget_id"); + Objects.requireNonNull(idempotencyKey, "Idempotency-Key"); + HttpUrl url = + client.newUrlBuilder() + .addPathSegments("api/v1/customers") + .addPathSegment(Utils.pathSegment("id_or_alias", idOrAlias)) + .addPathSegments("budgets") + .addPathSegment(Utils.pathSegment("budget_id", budgetId)) + .addPathSegments("archive") + .build(); + Headers.Builder headers = new Headers.Builder(); + headers.set("Idempotency-Key", Utils.serializeQueryParam(idempotencyKey)); + return client.call("POST", url) + .headers(headers.build()) + .errors( + com.meteroid.models.RestErrorResponse.class, + "400", + "401", + "404", + "409", + "429", + "500") + .options(requestOptions) + .returning(Budget.class); + } + + /** The operations, returning the status and headers along with the body. */ + public final class WithRawResponse { + private WithRawResponse() {} + + /** + * List budgets + * + *

A customer's budgets, oldest first, with their estimated spend in the current billing + * period. Archived ones are left out unless requested. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @return the status, headers and page + */ + public ApiResponse list(final String idOrAlias) { + return list(idOrAlias, BudgetsListOptions.none(), RequestOptions.none()); + } + + /** + * List budgets + * + *

A customer's budgets, oldest first, with their estimated spend in the current billing + * period. Archived ones are left out unless requested. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param options the optional parameters + * @return the status, headers and page + */ + public ApiResponse list( + final String idOrAlias, final BudgetsListOptions options) { + return list(idOrAlias, options, RequestOptions.none()); + } + + /** + * List budgets + * + *

A customer's budgets, oldest first, with their estimated spend in the current billing + * period. Archived ones are left out unless requested. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and page + */ + public ApiResponse list( + final String idOrAlias, final RequestOptions requestOptions) { + return list(idOrAlias, BudgetsListOptions.none(), requestOptions); + } + + /** + * List budgets + * + *

A customer's budgets, oldest first, with their estimated spend in the current billing + * period. Archived ones are left out unless requested. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param options the optional parameters + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and page + */ + public ApiResponse list( + final String idOrAlias, + final BudgetsListOptions options, + final RequestOptions requestOptions) { + ApiResponse response = + exchangeList(idOrAlias, options, requestOptions).sendRaw(); + return new ApiResponse<>( + response.statusCode(), + response.headers(), + pageOfList(response.body(), idOrAlias, options, requestOptions)); + } + + /** + * Create a budget + * + *

Sets a spending limit for one currency the customer is billed in, with alerts at + * percentages of it, on the customer's whole spend or on one subscription's. A customer has + * one active budget per currency, and per subscription. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param idempotencyKey the {@code Idempotency-Key} required parameter + * @param createBudgetRequest the request body + * @return the status, headers and body + */ + public ApiResponse create( + final String idOrAlias, + final String idempotencyKey, + final CreateBudgetRequest createBudgetRequest) { + return create(idOrAlias, idempotencyKey, createBudgetRequest, RequestOptions.none()); + } + + /** + * Create a budget + * + *

Sets a spending limit for one currency the customer is billed in, with alerts at + * percentages of it, on the customer's whole spend or on one subscription's. A customer has + * one active budget per currency, and per subscription. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param idempotencyKey the {@code Idempotency-Key} required parameter + * @param createBudgetRequest the request body + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body + */ + public ApiResponse create( + final String idOrAlias, + final String idempotencyKey, + final CreateBudgetRequest createBudgetRequest, + final RequestOptions requestOptions) { + return Budgets.this + .exchangeCreate(idOrAlias, idempotencyKey, createBudgetRequest, requestOptions) + .sendRaw(); + } + + /** + * Update a budget + * + *

Changes the amount, thresholds or behavior. Send the version you read as + * expected_version; a newer stored version, for instance after the customer + * edited it, is refused with 409. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param budgetId the {@code budget_id} path parameter + * @param idempotencyKey the {@code Idempotency-Key} required parameter + * @param patchBudgetRequest the request body + * @return the status, headers and body + */ + public ApiResponse update( + final String idOrAlias, + final String budgetId, + final String idempotencyKey, + final PatchBudgetRequest patchBudgetRequest) { + return update( + idOrAlias, budgetId, idempotencyKey, patchBudgetRequest, RequestOptions.none()); + } + + /** + * Update a budget + * + *

Changes the amount, thresholds or behavior. Send the version you read as + * expected_version; a newer stored version, for instance after the customer + * edited it, is refused with 409. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param budgetId the {@code budget_id} path parameter + * @param idempotencyKey the {@code Idempotency-Key} required parameter + * @param patchBudgetRequest the request body + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body + */ + public ApiResponse update( + final String idOrAlias, + final String budgetId, + final String idempotencyKey, + final PatchBudgetRequest patchBudgetRequest, + final RequestOptions requestOptions) { + return Budgets.this + .exchangeUpdate( + idOrAlias, budgetId, idempotencyKey, patchBudgetRequest, requestOptions) + .sendRaw(); + } + + /** + * Archive a budget + * + *

Stops the budget from sending alerts and, for a HARD budget, from refusing access. + * Archiving an archived budget returns it unchanged. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param budgetId the {@code budget_id} path parameter + * @param idempotencyKey the {@code Idempotency-Key} required parameter + * @return the status, headers and body + */ + public ApiResponse archive( + final String idOrAlias, final String budgetId, final String idempotencyKey) { + return archive(idOrAlias, budgetId, idempotencyKey, RequestOptions.none()); + } + + /** + * Archive a budget + * + *

Stops the budget from sending alerts and, for a HARD budget, from refusing access. + * Archiving an archived budget returns it unchanged. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param budgetId the {@code budget_id} path parameter + * @param idempotencyKey the {@code Idempotency-Key} required parameter + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body + */ + public ApiResponse archive( + final String idOrAlias, + final String budgetId, + final String idempotencyKey, + final RequestOptions requestOptions) { + return Budgets.this + .exchangeArchive(idOrAlias, budgetId, idempotencyKey, requestOptions) + .sendRaw(); + } + } +} diff --git a/src/main/java/com/meteroid/api/BudgetsAsync.java b/src/main/java/com/meteroid/api/BudgetsAsync.java new file mode 100644 index 0000000..3301e5b --- /dev/null +++ b/src/main/java/com/meteroid/api/BudgetsAsync.java @@ -0,0 +1,510 @@ +// this file is @generated +package com.meteroid.api; + +import com.meteroid.ApiResponse; +import com.meteroid.RequestOptions; +import com.meteroid.models.Budget; +import com.meteroid.models.BudgetListResponse; +import com.meteroid.models.CreateBudgetRequest; +import com.meteroid.models.PatchBudgetRequest; + +import java.util.List; +import java.util.concurrent.CompletableFuture; + +/** + * The {@code budgets} operations, without blocking: each method returns a {@link + * CompletableFuture}. Obtained from {@code client.async()}. + */ +public final class BudgetsAsync { + private final Budgets sync; + private final WithRawResponse withRawResponse; + + /** + * The operations, sending through {@code sync}. + * + * @param sync the blocking operations + */ + public BudgetsAsync(Budgets sync) { + this.sync = sync; + this.withRawResponse = new WithRawResponse(); + } + + /** + * The same operations, returning the status and headers along with the body. + * + * @return the operations + */ + public WithRawResponse withRawResponse() { + return withRawResponse; + } + + /** + * List budgets + * + *

A customer's budgets, oldest first, with their estimated spend in the current billing + * period. Archived ones are left out unless requested. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @return the page, once received + */ + public CompletableFuture list(final String idOrAlias) { + return list(idOrAlias, BudgetsListOptions.none(), RequestOptions.none()); + } + + /** + * List budgets + * + *

A customer's budgets, oldest first, with their estimated spend in the current billing + * period. Archived ones are left out unless requested. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param options the optional parameters + * @return the page, once received + */ + public CompletableFuture list( + final String idOrAlias, final BudgetsListOptions options) { + return list(idOrAlias, options, RequestOptions.none()); + } + + /** + * List budgets + * + *

A customer's budgets, oldest first, with their estimated spend in the current billing + * period. Archived ones are left out unless requested. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param requestOptions headers, timeout and retries of this call + * @return the page, once received + */ + public CompletableFuture list( + final String idOrAlias, final RequestOptions requestOptions) { + return list(idOrAlias, BudgetsListOptions.none(), requestOptions); + } + + /** + * List budgets + * + *

A customer's budgets, oldest first, with their estimated spend in the current billing + * period. Archived ones are left out unless requested. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param options the optional parameters + * @param requestOptions headers, timeout and retries of this call + * @return the page, once received + */ + public CompletableFuture list( + final String idOrAlias, + final BudgetsListOptions options, + final RequestOptions requestOptions) { + return sync.exchangeList(idOrAlias, options, requestOptions) + .sendAsync() + .thenApply(response -> pageOfList(response, idOrAlias, options, requestOptions)); + } + + private BudgetsListAsyncPage pageOfList( + BudgetListResponse response, + final String idOrAlias, + final BudgetsListOptions options, + final RequestOptions requestOptions) { + List items = Budgets.itemsOfList(response); + Integer next = Budgets.nextOfList(response, items, options.page().orElse(0)); + return new BudgetsListAsyncPage( + response, + items, + next == null + ? null + : () -> + list( + idOrAlias, + options.toBuilder().page(next).build(), + requestOptions)); + } + + /** + * Create a budget + * + *

Sets a spending limit for one currency the customer is billed in, with alerts at + * percentages of it, on the customer's whole spend or on one subscription's. A customer has one + * active budget per currency, and per subscription. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param idempotencyKey the {@code Idempotency-Key} required parameter + * @param createBudgetRequest the request body + * @return the response body, once received + */ + public CompletableFuture create( + final String idOrAlias, + final String idempotencyKey, + final CreateBudgetRequest createBudgetRequest) { + return create(idOrAlias, idempotencyKey, createBudgetRequest, RequestOptions.none()); + } + + /** + * Create a budget + * + *

Sets a spending limit for one currency the customer is billed in, with alerts at + * percentages of it, on the customer's whole spend or on one subscription's. A customer has one + * active budget per currency, and per subscription. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param idempotencyKey the {@code Idempotency-Key} required parameter + * @param createBudgetRequest the request body + * @param requestOptions headers, timeout and retries of this call + * @return the response body, once received + */ + public CompletableFuture create( + final String idOrAlias, + final String idempotencyKey, + final CreateBudgetRequest createBudgetRequest, + final RequestOptions requestOptions) { + return sync.exchangeCreate(idOrAlias, idempotencyKey, createBudgetRequest, requestOptions) + .sendAsync(); + } + + /** + * Update a budget + * + *

Changes the amount, thresholds or behavior. Send the version you read as + * expected_version; a newer stored version, for instance after the customer edited + * it, is refused with 409. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param budgetId the {@code budget_id} path parameter + * @param idempotencyKey the {@code Idempotency-Key} required parameter + * @param patchBudgetRequest the request body + * @return the response body, once received + */ + public CompletableFuture update( + final String idOrAlias, + final String budgetId, + final String idempotencyKey, + final PatchBudgetRequest patchBudgetRequest) { + return update( + idOrAlias, budgetId, idempotencyKey, patchBudgetRequest, RequestOptions.none()); + } + + /** + * Update a budget + * + *

Changes the amount, thresholds or behavior. Send the version you read as + * expected_version; a newer stored version, for instance after the customer edited + * it, is refused with 409. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param budgetId the {@code budget_id} path parameter + * @param idempotencyKey the {@code Idempotency-Key} required parameter + * @param patchBudgetRequest the request body + * @param requestOptions headers, timeout and retries of this call + * @return the response body, once received + */ + public CompletableFuture update( + final String idOrAlias, + final String budgetId, + final String idempotencyKey, + final PatchBudgetRequest patchBudgetRequest, + final RequestOptions requestOptions) { + return sync.exchangeUpdate( + idOrAlias, budgetId, idempotencyKey, patchBudgetRequest, requestOptions) + .sendAsync(); + } + + /** + * Archive a budget + * + *

Stops the budget from sending alerts and, for a HARD budget, from refusing access. + * Archiving an archived budget returns it unchanged. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param budgetId the {@code budget_id} path parameter + * @param idempotencyKey the {@code Idempotency-Key} required parameter + * @return the response body, once received + */ + public CompletableFuture archive( + final String idOrAlias, final String budgetId, final String idempotencyKey) { + return archive(idOrAlias, budgetId, idempotencyKey, RequestOptions.none()); + } + + /** + * Archive a budget + * + *

Stops the budget from sending alerts and, for a HARD budget, from refusing access. + * Archiving an archived budget returns it unchanged. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param budgetId the {@code budget_id} path parameter + * @param idempotencyKey the {@code Idempotency-Key} required parameter + * @param requestOptions headers, timeout and retries of this call + * @return the response body, once received + */ + public CompletableFuture archive( + final String idOrAlias, + final String budgetId, + final String idempotencyKey, + final RequestOptions requestOptions) { + return sync.exchangeArchive(idOrAlias, budgetId, idempotencyKey, requestOptions) + .sendAsync(); + } + + /** The operations, returning the status and headers along with the body. */ + public final class WithRawResponse { + private WithRawResponse() {} + + /** + * List budgets + * + *

A customer's budgets, oldest first, with their estimated spend in the current billing + * period. Archived ones are left out unless requested. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @return the status, headers and page, once received + */ + public CompletableFuture> list(final String idOrAlias) { + return list(idOrAlias, BudgetsListOptions.none(), RequestOptions.none()); + } + + /** + * List budgets + * + *

A customer's budgets, oldest first, with their estimated spend in the current billing + * period. Archived ones are left out unless requested. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param options the optional parameters + * @return the status, headers and page, once received + */ + public CompletableFuture> list( + final String idOrAlias, final BudgetsListOptions options) { + return list(idOrAlias, options, RequestOptions.none()); + } + + /** + * List budgets + * + *

A customer's budgets, oldest first, with their estimated spend in the current billing + * period. Archived ones are left out unless requested. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and page, once received + */ + public CompletableFuture> list( + final String idOrAlias, final RequestOptions requestOptions) { + return list(idOrAlias, BudgetsListOptions.none(), requestOptions); + } + + /** + * List budgets + * + *

A customer's budgets, oldest first, with their estimated spend in the current billing + * period. Archived ones are left out unless requested. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param options the optional parameters + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and page, once received + */ + public CompletableFuture> list( + final String idOrAlias, + final BudgetsListOptions options, + final RequestOptions requestOptions) { + return sync.exchangeList(idOrAlias, options, requestOptions) + .sendRawAsync() + .thenApply( + response -> + new ApiResponse<>( + response.statusCode(), + response.headers(), + pageOfList( + response.body(), + idOrAlias, + options, + requestOptions))); + } + + /** + * Create a budget + * + *

Sets a spending limit for one currency the customer is billed in, with alerts at + * percentages of it, on the customer's whole spend or on one subscription's. A customer has + * one active budget per currency, and per subscription. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param idempotencyKey the {@code Idempotency-Key} required parameter + * @param createBudgetRequest the request body + * @return the status, headers and body, once received + */ + public CompletableFuture> create( + final String idOrAlias, + final String idempotencyKey, + final CreateBudgetRequest createBudgetRequest) { + return create(idOrAlias, idempotencyKey, createBudgetRequest, RequestOptions.none()); + } + + /** + * Create a budget + * + *

Sets a spending limit for one currency the customer is billed in, with alerts at + * percentages of it, on the customer's whole spend or on one subscription's. A customer has + * one active budget per currency, and per subscription. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param idempotencyKey the {@code Idempotency-Key} required parameter + * @param createBudgetRequest the request body + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body, once received + */ + public CompletableFuture> create( + final String idOrAlias, + final String idempotencyKey, + final CreateBudgetRequest createBudgetRequest, + final RequestOptions requestOptions) { + return sync.exchangeCreate( + idOrAlias, idempotencyKey, createBudgetRequest, requestOptions) + .sendRawAsync(); + } + + /** + * Update a budget + * + *

Changes the amount, thresholds or behavior. Send the version you read as + * expected_version; a newer stored version, for instance after the customer + * edited it, is refused with 409. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param budgetId the {@code budget_id} path parameter + * @param idempotencyKey the {@code Idempotency-Key} required parameter + * @param patchBudgetRequest the request body + * @return the status, headers and body, once received + */ + public CompletableFuture> update( + final String idOrAlias, + final String budgetId, + final String idempotencyKey, + final PatchBudgetRequest patchBudgetRequest) { + return update( + idOrAlias, budgetId, idempotencyKey, patchBudgetRequest, RequestOptions.none()); + } + + /** + * Update a budget + * + *

Changes the amount, thresholds or behavior. Send the version you read as + * expected_version; a newer stored version, for instance after the customer + * edited it, is refused with 409. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param budgetId the {@code budget_id} path parameter + * @param idempotencyKey the {@code Idempotency-Key} required parameter + * @param patchBudgetRequest the request body + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body, once received + */ + public CompletableFuture> update( + final String idOrAlias, + final String budgetId, + final String idempotencyKey, + final PatchBudgetRequest patchBudgetRequest, + final RequestOptions requestOptions) { + return sync.exchangeUpdate( + idOrAlias, budgetId, idempotencyKey, patchBudgetRequest, requestOptions) + .sendRawAsync(); + } + + /** + * Archive a budget + * + *

Stops the budget from sending alerts and, for a HARD budget, from refusing access. + * Archiving an archived budget returns it unchanged. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param budgetId the {@code budget_id} path parameter + * @param idempotencyKey the {@code Idempotency-Key} required parameter + * @return the status, headers and body, once received + */ + public CompletableFuture> archive( + final String idOrAlias, final String budgetId, final String idempotencyKey) { + return archive(idOrAlias, budgetId, idempotencyKey, RequestOptions.none()); + } + + /** + * Archive a budget + * + *

Stops the budget from sending alerts and, for a HARD budget, from refusing access. + * Archiving an archived budget returns it unchanged. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param budgetId the {@code budget_id} path parameter + * @param idempotencyKey the {@code Idempotency-Key} required parameter + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body, once received + */ + public CompletableFuture> archive( + final String idOrAlias, + final String budgetId, + final String idempotencyKey, + final RequestOptions requestOptions) { + return sync.exchangeArchive(idOrAlias, budgetId, idempotencyKey, requestOptions) + .sendRawAsync(); + } + } +} diff --git a/src/main/java/com/meteroid/api/BudgetsListAsyncPage.java b/src/main/java/com/meteroid/api/BudgetsListAsyncPage.java new file mode 100644 index 0000000..8a16090 --- /dev/null +++ b/src/main/java/com/meteroid/api/BudgetsListAsyncPage.java @@ -0,0 +1,66 @@ +// this file is @generated +package com.meteroid.api; + +import com.meteroid.AsyncPage; +import com.meteroid.models.Budget; +import com.meteroid.models.BudgetListResponse; +import com.meteroid.models.PaginationResponse; + +import java.util.List; +import java.util.concurrent.CompletableFuture; +import java.util.function.Supplier; + +/** + * A page of {@link BudgetsAsync#list}: the {@link Budget} items of one response, and the properties + * of its body, {@link BudgetListResponse}. + */ +public final class BudgetsListAsyncPage extends AsyncPage { + private final BudgetListResponse body; + + /** + * A page, built by the SDK. + * + * @param body the response body + * @param items the items of the page + * @param next fetches the next page, or null on the last page + */ + public BudgetsListAsyncPage( + BudgetListResponse body, + List items, + Supplier> next) { + super(items, next); + this.body = body; + } + + /** + * The response body, as received. + * + * @return the body + */ + public BudgetListResponse body() { + return body; + } + + /** + * The {@code data} property. + * + * @return the value, never null + */ + public List data() { + return body.data(); + } + + /** + * The {@code pagination_meta} property. + * + * @return the value, never null + */ + public PaginationResponse paginationMeta() { + return body.paginationMeta(); + } + + @Override + public String toString() { + return "BudgetsListAsyncPage{body=" + body + ", hasNextPage=" + hasNextPage() + "}"; + } +} diff --git a/src/main/java/com/meteroid/api/BudgetsListOptions.java b/src/main/java/com/meteroid/api/BudgetsListOptions.java new file mode 100644 index 0000000..89a5586 --- /dev/null +++ b/src/main/java/com/meteroid/api/BudgetsListOptions.java @@ -0,0 +1,158 @@ +// this file is @generated +package com.meteroid.api; + +import java.util.Objects; +import java.util.Optional; + +/** Optional parameters of {@code list}, immutable: build them with {@link #builder()}. */ +public final class BudgetsListOptions { + private final Boolean includeArchived; + private final Integer page; + private final Integer perPage; + + private BudgetsListOptions(Builder builder) { + this.includeArchived = builder.includeArchived; + this.page = builder.page; + this.perPage = builder.perPage; + } + + /** + * A builder of parameters. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * No parameters. + * + * @return empty parameters + */ + public static BudgetsListOptions none() { + return builder().build(); + } + + /** + * A builder starting from these parameters. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.includeArchived = includeArchived; + builder.page = page; + builder.perPage = perPage; + return builder; + } + + /** + * Defaults to false. + * + * @return the value, empty when unset + */ + public Optional includeArchived() { + return Optional.ofNullable(includeArchived); + } + + /** + * Page number (0-indexed) + * + * @return the value, empty when unset + */ + public Optional page() { + return Optional.ofNullable(page); + } + + /** + * Number of items per page + * + * @return the value, empty when unset + */ + public Optional perPage() { + return Optional.ofNullable(perPage); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + BudgetsListOptions that = (BudgetsListOptions) o; + return Objects.equals(includeArchived, that.includeArchived) + && Objects.equals(page, that.page) + && Objects.equals(perPage, that.perPage); + } + + @Override + public int hashCode() { + return Objects.hash(includeArchived, page, perPage); + } + + @Override + public String toString() { + return "BudgetsListOptions{" + + "includeArchived=" + + includeArchived + + ", page=" + + page + + ", perPage=" + + perPage + + "}"; + } + + /** Builds {@link BudgetsListOptions}. */ + public static final class Builder { + private Boolean includeArchived; + private Integer page; + private Integer perPage; + + private Builder() {} + + /** + * Defaults to false. + * + * @param includeArchived the value, null to leave it out + * @return this builder + */ + public Builder includeArchived(Boolean includeArchived) { + this.includeArchived = includeArchived; + return this; + } + + /** + * Page number (0-indexed) + * + * @param page the value, null to leave it out + * @return this builder + */ + public Builder page(Integer page) { + this.page = page; + return this; + } + + /** + * Number of items per page + * + * @param perPage the value, null to leave it out + * @return this builder + */ + public Builder perPage(Integer perPage) { + this.perPage = perPage; + return this; + } + + /** + * The parameters. + * + * @return immutable parameters + */ + public BudgetsListOptions build() { + return new BudgetsListOptions(this); + } + } +} diff --git a/src/main/java/com/meteroid/api/BudgetsListPage.java b/src/main/java/com/meteroid/api/BudgetsListPage.java new file mode 100644 index 0000000..9fa8044 --- /dev/null +++ b/src/main/java/com/meteroid/api/BudgetsListPage.java @@ -0,0 +1,66 @@ +// this file is @generated +package com.meteroid.api; + +import com.meteroid.Page; +import com.meteroid.models.Budget; +import com.meteroid.models.BudgetListResponse; +import com.meteroid.models.PaginationResponse; + +import java.util.List; +import java.util.function.Supplier; + +/** + * A page of {@link Budgets#list}: the {@link Budget} items of one response, and the properties of + * its body, {@link BudgetListResponse}. + * + *

Iterating it yields every item from this page on, fetching the next pages as the iteration + * goes. + */ +public final class BudgetsListPage extends Page { + private final BudgetListResponse body; + + /** + * A page, built by the SDK. + * + * @param body the response body + * @param items the items of the page + * @param next fetches the next page, or null on the last page + */ + public BudgetsListPage( + BudgetListResponse body, List items, Supplier next) { + super(items, next); + this.body = body; + } + + /** + * The response body, as received. + * + * @return the body + */ + public BudgetListResponse body() { + return body; + } + + /** + * The {@code data} property. + * + * @return the value, never null + */ + public List data() { + return body.data(); + } + + /** + * The {@code pagination_meta} property. + * + * @return the value, never null + */ + public PaginationResponse paginationMeta() { + return body.paginationMeta(); + } + + @Override + public String toString() { + return "BudgetsListPage{body=" + body + ", hasNextPage=" + hasNextPage() + "}"; + } +} diff --git a/src/main/java/com/meteroid/api/Checks.java b/src/main/java/com/meteroid/api/Checks.java new file mode 100644 index 0000000..79c4498 --- /dev/null +++ b/src/main/java/com/meteroid/api/Checks.java @@ -0,0 +1,375 @@ +// this file is @generated +package com.meteroid.api; + +import com.meteroid.ApiResponse; +import com.meteroid.RequestOptions; +import com.meteroid.internal.MeteroidHttpClient; +import com.meteroid.internal.Utils; +import com.meteroid.models.EntitlementCheck; + +import okhttp3.HttpUrl; + +import java.math.BigDecimal; +import java.util.Map; +import java.util.Objects; + +/** + * The {@code checks} operations, blocking. {@link #withRawResponse()} has the same methods + * returning the status and headers along with the body. + */ +public final class Checks { + private final MeteroidHttpClient client; + private final WithRawResponse withRawResponse; + + /** + * The operations, sending through {@code client}. + * + * @param client the HTTP client of the SDK + */ + public Checks(MeteroidHttpClient client) { + this.client = client; + this.withRawResponse = new WithRawResponse(); + } + + /** + * The same operations, returning the status and headers along with the body. + * + * @return the operations + */ + public WithRawResponse withRawResponse() { + return withRawResponse; + } + + /** + * Check customer entitlement + * + *

Whether the customer may consume requested more of a feature right now, given + * their entitlement, the hard budgets that count the feature's usage, and their prepaid credit. + * Boolean features answer from their enabled state; config features grant access and return + * their value. An ALLOW limit never refuses: in_overage + * tells when the requested units go beyond it. Sliding windows send no threshold webhooks. Pass + * the group as group[<property>]=<value>: it is required when the + * entitlement is grouped. Pass subscription_id when the usage belongs to one + * subscription, so that a hard budget on another subscription does not refuse it. + * + *

The answer reflects usage up to as_of: typically less than a minute old, and + * less than 10 seconds old once near_limit is true. A hard limit can therefore be + * exceeded by the usage of those few seconds. While near_limit is true, check + * before every request with its actual requested and do not cache the answer; + * retry_after_ms says when to check again. Use the check to gate access, not to + * bill. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param featureIdOrCode the {@code feature_id_or_code} path parameter + * @return the response body + */ + public EntitlementCheck checkEntitlement(final String idOrAlias, final String featureIdOrCode) { + return checkEntitlement( + idOrAlias, + featureIdOrCode, + ChecksCheckEntitlementOptions.none(), + RequestOptions.none()); + } + + /** + * Check customer entitlement + * + *

Whether the customer may consume requested more of a feature right now, given + * their entitlement, the hard budgets that count the feature's usage, and their prepaid credit. + * Boolean features answer from their enabled state; config features grant access and return + * their value. An ALLOW limit never refuses: in_overage + * tells when the requested units go beyond it. Sliding windows send no threshold webhooks. Pass + * the group as group[<property>]=<value>: it is required when the + * entitlement is grouped. Pass subscription_id when the usage belongs to one + * subscription, so that a hard budget on another subscription does not refuse it. + * + *

The answer reflects usage up to as_of: typically less than a minute old, and + * less than 10 seconds old once near_limit is true. A hard limit can therefore be + * exceeded by the usage of those few seconds. While near_limit is true, check + * before every request with its actual requested and do not cache the answer; + * retry_after_ms says when to check again. Use the check to gate access, not to + * bill. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param featureIdOrCode the {@code feature_id_or_code} path parameter + * @param options the optional parameters + * @return the response body + */ + public EntitlementCheck checkEntitlement( + final String idOrAlias, + final String featureIdOrCode, + final ChecksCheckEntitlementOptions options) { + return checkEntitlement(idOrAlias, featureIdOrCode, options, RequestOptions.none()); + } + + /** + * Check customer entitlement + * + *

Whether the customer may consume requested more of a feature right now, given + * their entitlement, the hard budgets that count the feature's usage, and their prepaid credit. + * Boolean features answer from their enabled state; config features grant access and return + * their value. An ALLOW limit never refuses: in_overage + * tells when the requested units go beyond it. Sliding windows send no threshold webhooks. Pass + * the group as group[<property>]=<value>: it is required when the + * entitlement is grouped. Pass subscription_id when the usage belongs to one + * subscription, so that a hard budget on another subscription does not refuse it. + * + *

The answer reflects usage up to as_of: typically less than a minute old, and + * less than 10 seconds old once near_limit is true. A hard limit can therefore be + * exceeded by the usage of those few seconds. While near_limit is true, check + * before every request with its actual requested and do not cache the answer; + * retry_after_ms says when to check again. Use the check to gate access, not to + * bill. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param featureIdOrCode the {@code feature_id_or_code} path parameter + * @param requestOptions headers, timeout and retries of this call + * @return the response body + */ + public EntitlementCheck checkEntitlement( + final String idOrAlias, + final String featureIdOrCode, + final RequestOptions requestOptions) { + return checkEntitlement( + idOrAlias, featureIdOrCode, ChecksCheckEntitlementOptions.none(), requestOptions); + } + + /** + * Check customer entitlement + * + *

Whether the customer may consume requested more of a feature right now, given + * their entitlement, the hard budgets that count the feature's usage, and their prepaid credit. + * Boolean features answer from their enabled state; config features grant access and return + * their value. An ALLOW limit never refuses: in_overage + * tells when the requested units go beyond it. Sliding windows send no threshold webhooks. Pass + * the group as group[<property>]=<value>: it is required when the + * entitlement is grouped. Pass subscription_id when the usage belongs to one + * subscription, so that a hard budget on another subscription does not refuse it. + * + *

The answer reflects usage up to as_of: typically less than a minute old, and + * less than 10 seconds old once near_limit is true. A hard limit can therefore be + * exceeded by the usage of those few seconds. While near_limit is true, check + * before every request with its actual requested and do not cache the answer; + * retry_after_ms says when to check again. Use the check to gate access, not to + * bill. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param featureIdOrCode the {@code feature_id_or_code} path parameter + * @param options the optional parameters + * @param requestOptions headers, timeout and retries of this call + * @return the response body + */ + public EntitlementCheck checkEntitlement( + final String idOrAlias, + final String featureIdOrCode, + final ChecksCheckEntitlementOptions options, + final RequestOptions requestOptions) { + return exchangeCheckEntitlement(idOrAlias, featureIdOrCode, options, requestOptions).send(); + } + + MeteroidHttpClient.Exchange exchangeCheckEntitlement( + final String idOrAlias, + final String featureIdOrCode, + final ChecksCheckEntitlementOptions options, + final RequestOptions requestOptions) { + Objects.requireNonNull(idOrAlias, "id_or_alias"); + Objects.requireNonNull(featureIdOrCode, "feature_id_or_code"); + Objects.requireNonNull(options, "options"); + HttpUrl.Builder url = + client.newUrlBuilder() + .addPathSegments("api/v1/customers") + .addPathSegment(Utils.pathSegment("id_or_alias", idOrAlias)) + .addPathSegments("entitlements") + .addPathSegment(Utils.pathSegment("feature_id_or_code", featureIdOrCode)) + .addPathSegments("check"); + BigDecimal value1 = options.requested().orElse(null); + if (value1 != null) { + url.addQueryParameter("requested", Utils.serializeQueryParam(value1)); + } + String value2 = options.subscriptionId().orElse(null); + if (value2 != null) { + url.addQueryParameter("subscription_id", value2); + } + Map value3 = options.group().orElse(null); + if (value3 != null) { + Utils.addStructuredQueryParameter(url, "group", value3, true, true); + } + return client.call("GET", url.build()) + .errors( + com.meteroid.models.RestErrorResponse.class, + "400", + "401", + "404", + "429", + "500", + "503") + .options(requestOptions) + .returning(EntitlementCheck.class); + } + + /** The operations, returning the status and headers along with the body. */ + public final class WithRawResponse { + private WithRawResponse() {} + + /** + * Check customer entitlement + * + *

Whether the customer may consume requested more of a feature right now, + * given their entitlement, the hard budgets that count the feature's usage, and their + * prepaid credit. Boolean features answer from their enabled state; config features grant + * access and return their value. An ALLOW limit never refuses: + * in_overage tells when the requested units go beyond it. Sliding windows send + * no threshold webhooks. Pass the group as group[<property>]=<value> + * : it is required when the entitlement is grouped. Pass subscription_id + * when the usage belongs to one subscription, so that a hard budget on another + * subscription does not refuse it. + * + *

The answer reflects usage up to as_of: typically less than a minute old, + * and less than 10 seconds old once near_limit is true. A hard limit can + * therefore be exceeded by the usage of those few seconds. While near_limit is + * true, check before every request with its actual requested and do not cache + * the answer; retry_after_ms says when to check again. Use the check to gate + * access, not to bill. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param featureIdOrCode the {@code feature_id_or_code} path parameter + * @return the status, headers and body + */ + public ApiResponse checkEntitlement( + final String idOrAlias, final String featureIdOrCode) { + return checkEntitlement( + idOrAlias, + featureIdOrCode, + ChecksCheckEntitlementOptions.none(), + RequestOptions.none()); + } + + /** + * Check customer entitlement + * + *

Whether the customer may consume requested more of a feature right now, + * given their entitlement, the hard budgets that count the feature's usage, and their + * prepaid credit. Boolean features answer from their enabled state; config features grant + * access and return their value. An ALLOW limit never refuses: + * in_overage tells when the requested units go beyond it. Sliding windows send + * no threshold webhooks. Pass the group as group[<property>]=<value> + * : it is required when the entitlement is grouped. Pass subscription_id + * when the usage belongs to one subscription, so that a hard budget on another + * subscription does not refuse it. + * + *

The answer reflects usage up to as_of: typically less than a minute old, + * and less than 10 seconds old once near_limit is true. A hard limit can + * therefore be exceeded by the usage of those few seconds. While near_limit is + * true, check before every request with its actual requested and do not cache + * the answer; retry_after_ms says when to check again. Use the check to gate + * access, not to bill. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param featureIdOrCode the {@code feature_id_or_code} path parameter + * @param options the optional parameters + * @return the status, headers and body + */ + public ApiResponse checkEntitlement( + final String idOrAlias, + final String featureIdOrCode, + final ChecksCheckEntitlementOptions options) { + return checkEntitlement(idOrAlias, featureIdOrCode, options, RequestOptions.none()); + } + + /** + * Check customer entitlement + * + *

Whether the customer may consume requested more of a feature right now, + * given their entitlement, the hard budgets that count the feature's usage, and their + * prepaid credit. Boolean features answer from their enabled state; config features grant + * access and return their value. An ALLOW limit never refuses: + * in_overage tells when the requested units go beyond it. Sliding windows send + * no threshold webhooks. Pass the group as group[<property>]=<value> + * : it is required when the entitlement is grouped. Pass subscription_id + * when the usage belongs to one subscription, so that a hard budget on another + * subscription does not refuse it. + * + *

The answer reflects usage up to as_of: typically less than a minute old, + * and less than 10 seconds old once near_limit is true. A hard limit can + * therefore be exceeded by the usage of those few seconds. While near_limit is + * true, check before every request with its actual requested and do not cache + * the answer; retry_after_ms says when to check again. Use the check to gate + * access, not to bill. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param featureIdOrCode the {@code feature_id_or_code} path parameter + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body + */ + public ApiResponse checkEntitlement( + final String idOrAlias, + final String featureIdOrCode, + final RequestOptions requestOptions) { + return checkEntitlement( + idOrAlias, + featureIdOrCode, + ChecksCheckEntitlementOptions.none(), + requestOptions); + } + + /** + * Check customer entitlement + * + *

Whether the customer may consume requested more of a feature right now, + * given their entitlement, the hard budgets that count the feature's usage, and their + * prepaid credit. Boolean features answer from their enabled state; config features grant + * access and return their value. An ALLOW limit never refuses: + * in_overage tells when the requested units go beyond it. Sliding windows send + * no threshold webhooks. Pass the group as group[<property>]=<value> + * : it is required when the entitlement is grouped. Pass subscription_id + * when the usage belongs to one subscription, so that a hard budget on another + * subscription does not refuse it. + * + *

The answer reflects usage up to as_of: typically less than a minute old, + * and less than 10 seconds old once near_limit is true. A hard limit can + * therefore be exceeded by the usage of those few seconds. While near_limit is + * true, check before every request with its actual requested and do not cache + * the answer; retry_after_ms says when to check again. Use the check to gate + * access, not to bill. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param featureIdOrCode the {@code feature_id_or_code} path parameter + * @param options the optional parameters + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body + */ + public ApiResponse checkEntitlement( + final String idOrAlias, + final String featureIdOrCode, + final ChecksCheckEntitlementOptions options, + final RequestOptions requestOptions) { + return Checks.this + .exchangeCheckEntitlement(idOrAlias, featureIdOrCode, options, requestOptions) + .sendRaw(); + } + } +} diff --git a/src/main/java/com/meteroid/api/ChecksAsync.java b/src/main/java/com/meteroid/api/ChecksAsync.java new file mode 100644 index 0000000..6604091 --- /dev/null +++ b/src/main/java/com/meteroid/api/ChecksAsync.java @@ -0,0 +1,331 @@ +// this file is @generated +package com.meteroid.api; + +import com.meteroid.ApiResponse; +import com.meteroid.RequestOptions; +import com.meteroid.models.EntitlementCheck; + +import java.util.concurrent.CompletableFuture; + +/** + * The {@code checks} operations, without blocking: each method returns a {@link CompletableFuture}. + * Obtained from {@code client.async()}. + */ +public final class ChecksAsync { + private final Checks sync; + private final WithRawResponse withRawResponse; + + /** + * The operations, sending through {@code sync}. + * + * @param sync the blocking operations + */ + public ChecksAsync(Checks sync) { + this.sync = sync; + this.withRawResponse = new WithRawResponse(); + } + + /** + * The same operations, returning the status and headers along with the body. + * + * @return the operations + */ + public WithRawResponse withRawResponse() { + return withRawResponse; + } + + /** + * Check customer entitlement + * + *

Whether the customer may consume requested more of a feature right now, given + * their entitlement, the hard budgets that count the feature's usage, and their prepaid credit. + * Boolean features answer from their enabled state; config features grant access and return + * their value. An ALLOW limit never refuses: in_overage + * tells when the requested units go beyond it. Sliding windows send no threshold webhooks. Pass + * the group as group[<property>]=<value>: it is required when the + * entitlement is grouped. Pass subscription_id when the usage belongs to one + * subscription, so that a hard budget on another subscription does not refuse it. + * + *

The answer reflects usage up to as_of: typically less than a minute old, and + * less than 10 seconds old once near_limit is true. A hard limit can therefore be + * exceeded by the usage of those few seconds. While near_limit is true, check + * before every request with its actual requested and do not cache the answer; + * retry_after_ms says when to check again. Use the check to gate access, not to + * bill. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param featureIdOrCode the {@code feature_id_or_code} path parameter + * @return the response body, once received + */ + public CompletableFuture checkEntitlement( + final String idOrAlias, final String featureIdOrCode) { + return checkEntitlement( + idOrAlias, + featureIdOrCode, + ChecksCheckEntitlementOptions.none(), + RequestOptions.none()); + } + + /** + * Check customer entitlement + * + *

Whether the customer may consume requested more of a feature right now, given + * their entitlement, the hard budgets that count the feature's usage, and their prepaid credit. + * Boolean features answer from their enabled state; config features grant access and return + * their value. An ALLOW limit never refuses: in_overage + * tells when the requested units go beyond it. Sliding windows send no threshold webhooks. Pass + * the group as group[<property>]=<value>: it is required when the + * entitlement is grouped. Pass subscription_id when the usage belongs to one + * subscription, so that a hard budget on another subscription does not refuse it. + * + *

The answer reflects usage up to as_of: typically less than a minute old, and + * less than 10 seconds old once near_limit is true. A hard limit can therefore be + * exceeded by the usage of those few seconds. While near_limit is true, check + * before every request with its actual requested and do not cache the answer; + * retry_after_ms says when to check again. Use the check to gate access, not to + * bill. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param featureIdOrCode the {@code feature_id_or_code} path parameter + * @param options the optional parameters + * @return the response body, once received + */ + public CompletableFuture checkEntitlement( + final String idOrAlias, + final String featureIdOrCode, + final ChecksCheckEntitlementOptions options) { + return checkEntitlement(idOrAlias, featureIdOrCode, options, RequestOptions.none()); + } + + /** + * Check customer entitlement + * + *

Whether the customer may consume requested more of a feature right now, given + * their entitlement, the hard budgets that count the feature's usage, and their prepaid credit. + * Boolean features answer from their enabled state; config features grant access and return + * their value. An ALLOW limit never refuses: in_overage + * tells when the requested units go beyond it. Sliding windows send no threshold webhooks. Pass + * the group as group[<property>]=<value>: it is required when the + * entitlement is grouped. Pass subscription_id when the usage belongs to one + * subscription, so that a hard budget on another subscription does not refuse it. + * + *

The answer reflects usage up to as_of: typically less than a minute old, and + * less than 10 seconds old once near_limit is true. A hard limit can therefore be + * exceeded by the usage of those few seconds. While near_limit is true, check + * before every request with its actual requested and do not cache the answer; + * retry_after_ms says when to check again. Use the check to gate access, not to + * bill. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param featureIdOrCode the {@code feature_id_or_code} path parameter + * @param requestOptions headers, timeout and retries of this call + * @return the response body, once received + */ + public CompletableFuture checkEntitlement( + final String idOrAlias, + final String featureIdOrCode, + final RequestOptions requestOptions) { + return checkEntitlement( + idOrAlias, featureIdOrCode, ChecksCheckEntitlementOptions.none(), requestOptions); + } + + /** + * Check customer entitlement + * + *

Whether the customer may consume requested more of a feature right now, given + * their entitlement, the hard budgets that count the feature's usage, and their prepaid credit. + * Boolean features answer from their enabled state; config features grant access and return + * their value. An ALLOW limit never refuses: in_overage + * tells when the requested units go beyond it. Sliding windows send no threshold webhooks. Pass + * the group as group[<property>]=<value>: it is required when the + * entitlement is grouped. Pass subscription_id when the usage belongs to one + * subscription, so that a hard budget on another subscription does not refuse it. + * + *

The answer reflects usage up to as_of: typically less than a minute old, and + * less than 10 seconds old once near_limit is true. A hard limit can therefore be + * exceeded by the usage of those few seconds. While near_limit is true, check + * before every request with its actual requested and do not cache the answer; + * retry_after_ms says when to check again. Use the check to gate access, not to + * bill. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param featureIdOrCode the {@code feature_id_or_code} path parameter + * @param options the optional parameters + * @param requestOptions headers, timeout and retries of this call + * @return the response body, once received + */ + public CompletableFuture checkEntitlement( + final String idOrAlias, + final String featureIdOrCode, + final ChecksCheckEntitlementOptions options, + final RequestOptions requestOptions) { + return sync.exchangeCheckEntitlement(idOrAlias, featureIdOrCode, options, requestOptions) + .sendAsync(); + } + + /** The operations, returning the status and headers along with the body. */ + public final class WithRawResponse { + private WithRawResponse() {} + + /** + * Check customer entitlement + * + *

Whether the customer may consume requested more of a feature right now, + * given their entitlement, the hard budgets that count the feature's usage, and their + * prepaid credit. Boolean features answer from their enabled state; config features grant + * access and return their value. An ALLOW limit never refuses: + * in_overage tells when the requested units go beyond it. Sliding windows send + * no threshold webhooks. Pass the group as group[<property>]=<value> + * : it is required when the entitlement is grouped. Pass subscription_id + * when the usage belongs to one subscription, so that a hard budget on another + * subscription does not refuse it. + * + *

The answer reflects usage up to as_of: typically less than a minute old, + * and less than 10 seconds old once near_limit is true. A hard limit can + * therefore be exceeded by the usage of those few seconds. While near_limit is + * true, check before every request with its actual requested and do not cache + * the answer; retry_after_ms says when to check again. Use the check to gate + * access, not to bill. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param featureIdOrCode the {@code feature_id_or_code} path parameter + * @return the status, headers and body, once received + */ + public CompletableFuture> checkEntitlement( + final String idOrAlias, final String featureIdOrCode) { + return checkEntitlement( + idOrAlias, + featureIdOrCode, + ChecksCheckEntitlementOptions.none(), + RequestOptions.none()); + } + + /** + * Check customer entitlement + * + *

Whether the customer may consume requested more of a feature right now, + * given their entitlement, the hard budgets that count the feature's usage, and their + * prepaid credit. Boolean features answer from their enabled state; config features grant + * access and return their value. An ALLOW limit never refuses: + * in_overage tells when the requested units go beyond it. Sliding windows send + * no threshold webhooks. Pass the group as group[<property>]=<value> + * : it is required when the entitlement is grouped. Pass subscription_id + * when the usage belongs to one subscription, so that a hard budget on another + * subscription does not refuse it. + * + *

The answer reflects usage up to as_of: typically less than a minute old, + * and less than 10 seconds old once near_limit is true. A hard limit can + * therefore be exceeded by the usage of those few seconds. While near_limit is + * true, check before every request with its actual requested and do not cache + * the answer; retry_after_ms says when to check again. Use the check to gate + * access, not to bill. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param featureIdOrCode the {@code feature_id_or_code} path parameter + * @param options the optional parameters + * @return the status, headers and body, once received + */ + public CompletableFuture> checkEntitlement( + final String idOrAlias, + final String featureIdOrCode, + final ChecksCheckEntitlementOptions options) { + return checkEntitlement(idOrAlias, featureIdOrCode, options, RequestOptions.none()); + } + + /** + * Check customer entitlement + * + *

Whether the customer may consume requested more of a feature right now, + * given their entitlement, the hard budgets that count the feature's usage, and their + * prepaid credit. Boolean features answer from their enabled state; config features grant + * access and return their value. An ALLOW limit never refuses: + * in_overage tells when the requested units go beyond it. Sliding windows send + * no threshold webhooks. Pass the group as group[<property>]=<value> + * : it is required when the entitlement is grouped. Pass subscription_id + * when the usage belongs to one subscription, so that a hard budget on another + * subscription does not refuse it. + * + *

The answer reflects usage up to as_of: typically less than a minute old, + * and less than 10 seconds old once near_limit is true. A hard limit can + * therefore be exceeded by the usage of those few seconds. While near_limit is + * true, check before every request with its actual requested and do not cache + * the answer; retry_after_ms says when to check again. Use the check to gate + * access, not to bill. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param featureIdOrCode the {@code feature_id_or_code} path parameter + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body, once received + */ + public CompletableFuture> checkEntitlement( + final String idOrAlias, + final String featureIdOrCode, + final RequestOptions requestOptions) { + return checkEntitlement( + idOrAlias, + featureIdOrCode, + ChecksCheckEntitlementOptions.none(), + requestOptions); + } + + /** + * Check customer entitlement + * + *

Whether the customer may consume requested more of a feature right now, + * given their entitlement, the hard budgets that count the feature's usage, and their + * prepaid credit. Boolean features answer from their enabled state; config features grant + * access and return their value. An ALLOW limit never refuses: + * in_overage tells when the requested units go beyond it. Sliding windows send + * no threshold webhooks. Pass the group as group[<property>]=<value> + * : it is required when the entitlement is grouped. Pass subscription_id + * when the usage belongs to one subscription, so that a hard budget on another + * subscription does not refuse it. + * + *

The answer reflects usage up to as_of: typically less than a minute old, + * and less than 10 seconds old once near_limit is true. A hard limit can + * therefore be exceeded by the usage of those few seconds. While near_limit is + * true, check before every request with its actual requested and do not cache + * the answer; retry_after_ms says when to check again. Use the check to gate + * access, not to bill. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param featureIdOrCode the {@code feature_id_or_code} path parameter + * @param options the optional parameters + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body, once received + */ + public CompletableFuture> checkEntitlement( + final String idOrAlias, + final String featureIdOrCode, + final ChecksCheckEntitlementOptions options, + final RequestOptions requestOptions) { + return sync.exchangeCheckEntitlement( + idOrAlias, featureIdOrCode, options, requestOptions) + .sendRawAsync(); + } + } +} diff --git a/src/main/java/com/meteroid/api/ChecksCheckEntitlementOptions.java b/src/main/java/com/meteroid/api/ChecksCheckEntitlementOptions.java new file mode 100644 index 0000000..1161527 --- /dev/null +++ b/src/main/java/com/meteroid/api/ChecksCheckEntitlementOptions.java @@ -0,0 +1,168 @@ +// this file is @generated +package com.meteroid.api; + +import java.math.BigDecimal; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +/** + * Optional parameters of {@code checkEntitlement}, immutable: build them with {@link #builder()}. + */ +public final class ChecksCheckEntitlementOptions { + private final BigDecimal requested; + private final String subscriptionId; + private final Map group; + + private ChecksCheckEntitlementOptions(Builder builder) { + this.requested = builder.requested; + this.subscriptionId = builder.subscriptionId; + this.group = builder.group; + } + + /** + * A builder of parameters. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * No parameters. + * + * @return empty parameters + */ + public static ChecksCheckEntitlementOptions none() { + return builder().build(); + } + + /** + * A builder starting from these parameters. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.requested = requested; + builder.subscriptionId = subscriptionId; + builder.group = group; + return builder; + } + + /** + * Units the customer is about to consume. Defaults to 1. + * + * @return the value, empty when unset + */ + public Optional requested() { + return Optional.ofNullable(requested); + } + + /** + * The subscription (sub_…) the usage belongs to: only its own budgets and the + * customer-wide ones apply. Without it, a budget on one subscription refuses only once every + * subscription charging the feature's metric is refused by its own budget. + * + * @return the value, empty when unset + */ + public Optional subscriptionId() { + return Optional.ofNullable(subscriptionId); + } + + /** + * The group to check, as group[<property>]=<value>: required when the + * entitlement is grouped + * + * @return the value, empty when unset + */ + public Optional> group() { + return Optional.ofNullable(group); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ChecksCheckEntitlementOptions that = (ChecksCheckEntitlementOptions) o; + return Objects.equals(requested, that.requested) + && Objects.equals(subscriptionId, that.subscriptionId) + && Objects.equals(group, that.group); + } + + @Override + public int hashCode() { + return Objects.hash(requested, subscriptionId, group); + } + + @Override + public String toString() { + return "ChecksCheckEntitlementOptions{" + + "requested=" + + requested + + ", subscriptionId=" + + subscriptionId + + ", group=" + + group + + "}"; + } + + /** Builds {@link ChecksCheckEntitlementOptions}. */ + public static final class Builder { + private BigDecimal requested; + private String subscriptionId; + private Map group; + + private Builder() {} + + /** + * Units the customer is about to consume. Defaults to 1. + * + * @param requested the value, null to leave it out + * @return this builder + */ + public Builder requested(BigDecimal requested) { + this.requested = requested; + return this; + } + + /** + * The subscription (sub_…) the usage belongs to: only its own budgets and the + * customer-wide ones apply. Without it, a budget on one subscription refuses only once + * every subscription charging the feature's metric is refused by its own budget. + * + * @param subscriptionId the value, null to leave it out + * @return this builder + */ + public Builder subscriptionId(String subscriptionId) { + this.subscriptionId = subscriptionId; + return this; + } + + /** + * The group to check, as group[<property>]=<value>: required when + * the entitlement is grouped + * + * @param group the value, null to leave it out + * @return this builder + */ + public Builder group(Map group) { + this.group = group; + return this; + } + + /** + * The parameters. + * + * @return immutable parameters + */ + public ChecksCheckEntitlementOptions build() { + return new ChecksCheckEntitlementOptions(this); + } + } +} diff --git a/src/main/java/com/meteroid/api/Connect.java b/src/main/java/com/meteroid/api/Connect.java index 1c0c56e..c42a646 100644 --- a/src/main/java/com/meteroid/api/Connect.java +++ b/src/main/java/com/meteroid/api/Connect.java @@ -8,6 +8,7 @@ import com.meteroid.models.ConnectedAccount; import com.meteroid.models.ConnectedAccountsResponse; import com.meteroid.models.CreateConnectedAccountRequest; +import com.meteroid.models.CreateConnectedAccountResponse; import com.meteroid.models.CreateOnboardingLinkRequest; import com.meteroid.models.OnboardingLinkResponse; @@ -77,13 +78,13 @@ MeteroidHttpClient.Exchange exchangeListConnectedAcco /** * Create connected account * - *

Create a new connected account (Express flow). Returns the account and an onboarding link - * for the user to complete setup. + *

Create a new pending connected account (Express flow). Returns the account and an + * onboarding link for the user to complete setup. * * @param createConnectedAccountRequest the request body * @return the response body */ - public ConnectedAccount createConnectedAccount( + public CreateConnectedAccountResponse createConnectedAccount( final CreateConnectedAccountRequest createConnectedAccountRequest) { return createConnectedAccount(createConnectedAccountRequest, RequestOptions.none()); } @@ -91,20 +92,20 @@ public ConnectedAccount createConnectedAccount( /** * Create connected account * - *

Create a new connected account (Express flow). Returns the account and an onboarding link - * for the user to complete setup. + *

Create a new pending connected account (Express flow). Returns the account and an + * onboarding link for the user to complete setup. * * @param createConnectedAccountRequest the request body * @param requestOptions headers, timeout and retries of this call * @return the response body */ - public ConnectedAccount createConnectedAccount( + public CreateConnectedAccountResponse createConnectedAccount( final CreateConnectedAccountRequest createConnectedAccountRequest, final RequestOptions requestOptions) { return exchangeCreateConnectedAccount(createConnectedAccountRequest, requestOptions).send(); } - MeteroidHttpClient.Exchange exchangeCreateConnectedAccount( + MeteroidHttpClient.Exchange exchangeCreateConnectedAccount( final CreateConnectedAccountRequest createConnectedAccountRequest, final RequestOptions requestOptions) { Objects.requireNonNull(createConnectedAccountRequest, "body"); @@ -113,7 +114,7 @@ MeteroidHttpClient.Exchange exchangeCreateConnectedAccount( .json(createConnectedAccountRequest) .errors(com.meteroid.models.RestErrorResponse.class, "429") .options(requestOptions) - .returning(ConnectedAccount.class); + .returning(CreateConnectedAccountResponse.class); } /** @@ -276,13 +277,13 @@ public ApiResponse listConnectedAccounts( /** * Create connected account * - *

Create a new connected account (Express flow). Returns the account and an onboarding - * link for the user to complete setup. + *

Create a new pending connected account (Express flow). Returns the account and an + * onboarding link for the user to complete setup. * * @param createConnectedAccountRequest the request body * @return the status, headers and body */ - public ApiResponse createConnectedAccount( + public ApiResponse createConnectedAccount( final CreateConnectedAccountRequest createConnectedAccountRequest) { return createConnectedAccount(createConnectedAccountRequest, RequestOptions.none()); } @@ -290,14 +291,14 @@ public ApiResponse createConnectedAccount( /** * Create connected account * - *

Create a new connected account (Express flow). Returns the account and an onboarding - * link for the user to complete setup. + *

Create a new pending connected account (Express flow). Returns the account and an + * onboarding link for the user to complete setup. * * @param createConnectedAccountRequest the request body * @param requestOptions headers, timeout and retries of this call * @return the status, headers and body */ - public ApiResponse createConnectedAccount( + public ApiResponse createConnectedAccount( final CreateConnectedAccountRequest createConnectedAccountRequest, final RequestOptions requestOptions) { return Connect.this diff --git a/src/main/java/com/meteroid/api/ConnectAsync.java b/src/main/java/com/meteroid/api/ConnectAsync.java index 5c5f024..d7b11f8 100644 --- a/src/main/java/com/meteroid/api/ConnectAsync.java +++ b/src/main/java/com/meteroid/api/ConnectAsync.java @@ -6,6 +6,7 @@ import com.meteroid.models.ConnectedAccount; import com.meteroid.models.ConnectedAccountsResponse; import com.meteroid.models.CreateConnectedAccountRequest; +import com.meteroid.models.CreateConnectedAccountResponse; import com.meteroid.models.CreateOnboardingLinkRequest; import com.meteroid.models.OnboardingLinkResponse; @@ -65,13 +66,13 @@ public CompletableFuture listConnectedAccounts( /** * Create connected account * - *

Create a new connected account (Express flow). Returns the account and an onboarding link - * for the user to complete setup. + *

Create a new pending connected account (Express flow). Returns the account and an + * onboarding link for the user to complete setup. * * @param createConnectedAccountRequest the request body * @return the response body, once received */ - public CompletableFuture createConnectedAccount( + public CompletableFuture createConnectedAccount( final CreateConnectedAccountRequest createConnectedAccountRequest) { return createConnectedAccount(createConnectedAccountRequest, RequestOptions.none()); } @@ -79,14 +80,14 @@ public CompletableFuture createConnectedAccount( /** * Create connected account * - *

Create a new connected account (Express flow). Returns the account and an onboarding link - * for the user to complete setup. + *

Create a new pending connected account (Express flow). Returns the account and an + * onboarding link for the user to complete setup. * * @param createConnectedAccountRequest the request body * @param requestOptions headers, timeout and retries of this call * @return the response body, once received */ - public CompletableFuture createConnectedAccount( + public CompletableFuture createConnectedAccount( final CreateConnectedAccountRequest createConnectedAccountRequest, final RequestOptions requestOptions) { return sync.exchangeCreateConnectedAccount(createConnectedAccountRequest, requestOptions) @@ -210,30 +211,32 @@ public CompletableFuture> listConnectedAc /** * Create connected account * - *

Create a new connected account (Express flow). Returns the account and an onboarding - * link for the user to complete setup. + *

Create a new pending connected account (Express flow). Returns the account and an + * onboarding link for the user to complete setup. * * @param createConnectedAccountRequest the request body * @return the status, headers and body, once received */ - public CompletableFuture> createConnectedAccount( - final CreateConnectedAccountRequest createConnectedAccountRequest) { + public CompletableFuture> + createConnectedAccount( + final CreateConnectedAccountRequest createConnectedAccountRequest) { return createConnectedAccount(createConnectedAccountRequest, RequestOptions.none()); } /** * Create connected account * - *

Create a new connected account (Express flow). Returns the account and an onboarding - * link for the user to complete setup. + *

Create a new pending connected account (Express flow). Returns the account and an + * onboarding link for the user to complete setup. * * @param createConnectedAccountRequest the request body * @param requestOptions headers, timeout and retries of this call * @return the status, headers and body, once received */ - public CompletableFuture> createConnectedAccount( - final CreateConnectedAccountRequest createConnectedAccountRequest, - final RequestOptions requestOptions) { + public CompletableFuture> + createConnectedAccount( + final CreateConnectedAccountRequest createConnectedAccountRequest, + final RequestOptions requestOptions) { return sync.exchangeCreateConnectedAccount( createConnectedAccountRequest, requestOptions) .sendRawAsync(); diff --git a/src/main/java/com/meteroid/api/CreditUnits.java b/src/main/java/com/meteroid/api/CreditUnits.java new file mode 100644 index 0000000..2bcc227 --- /dev/null +++ b/src/main/java/com/meteroid/api/CreditUnits.java @@ -0,0 +1,431 @@ +// this file is @generated +package com.meteroid.api; + +import com.meteroid.ApiResponse; +import com.meteroid.RequestOptions; +import com.meteroid.internal.MeteroidHttpClient; +import com.meteroid.internal.Utils; +import com.meteroid.models.CreditUnit; +import com.meteroid.models.CreditUnitCreateRequest; +import com.meteroid.models.CreditUnitListResponse; +import com.meteroid.models.CreditUnitUpdateRequest; + +import okhttp3.HttpUrl; + +import java.util.Objects; + +/** + * The {@code credit_units} operations, blocking. {@link #withRawResponse()} has the same methods + * returning the status and headers along with the body. + */ +public final class CreditUnits { + private final MeteroidHttpClient client; + private final WithRawResponse withRawResponse; + + private final CreditUnitsPrices prices; + + /** + * The operations, sending through {@code client}. + * + * @param client the HTTP client of the SDK + */ + public CreditUnits(MeteroidHttpClient client) { + this.client = client; + this.withRawResponse = new WithRawResponse(); + + this.prices = new CreditUnitsPrices(client); + } + + /** + * The same operations, returning the status and headers along with the body. + * + * @return the operations + */ + public WithRawResponse withRawResponse() { + return withRawResponse; + } + + /** + * The {@code prices} operations. + * + * @return the operations + */ + public CreditUnitsPrices prices() { + return prices; + } + + /** + * List credit units + * + *

The tenant's credit units (e.g. "Halyard credits"): denominations usage can be priced and + * credit granted in, instead of money, each with its selling prices. + * + * @return the response body + */ + public CreditUnitListResponse list() { + return list(CreditUnitsListOptions.none(), RequestOptions.none()); + } + + /** + * List credit units + * + *

The tenant's credit units (e.g. "Halyard credits"): denominations usage can be priced and + * credit granted in, instead of money, each with its selling prices. + * + * @param options the optional parameters + * @return the response body + */ + public CreditUnitListResponse list(final CreditUnitsListOptions options) { + return list(options, RequestOptions.none()); + } + + /** + * List credit units + * + *

The tenant's credit units (e.g. "Halyard credits"): denominations usage can be priced and + * credit granted in, instead of money, each with its selling prices. + * + * @param requestOptions headers, timeout and retries of this call + * @return the response body + */ + public CreditUnitListResponse list(final RequestOptions requestOptions) { + return list(CreditUnitsListOptions.none(), requestOptions); + } + + /** + * List credit units + * + *

The tenant's credit units (e.g. "Halyard credits"): denominations usage can be priced and + * credit granted in, instead of money, each with its selling prices. + * + * @param options the optional parameters + * @param requestOptions headers, timeout and retries of this call + * @return the response body + */ + public CreditUnitListResponse list( + final CreditUnitsListOptions options, final RequestOptions requestOptions) { + return exchangeList(options, requestOptions).send(); + } + + MeteroidHttpClient.Exchange exchangeList( + final CreditUnitsListOptions options, final RequestOptions requestOptions) { + Objects.requireNonNull(options, "options"); + HttpUrl.Builder url = client.newUrlBuilder().addPathSegments("api/v1/credit-units"); + Boolean value1 = options.includeArchived().orElse(null); + if (value1 != null) { + url.addQueryParameter("include_archived", Utils.serializeQueryParam(value1)); + } + return client.call("GET", url.build()) + .errors(com.meteroid.models.RestErrorResponse.class, "401", "429", "500") + .options(requestOptions) + .returning(CreditUnitListResponse.class); + } + + /** + * Create a credit unit code and precision are immutable once created. + * Price usage in the unit with a plan fee's credit_unit, grant it with a credit + * pack or a credit grant, and sell it with a top-up once it has a product_id and a + * selling price. + * + * @param creditUnitCreateRequest the request body + * @return the response body + */ + public CreditUnit create(final CreditUnitCreateRequest creditUnitCreateRequest) { + return create(creditUnitCreateRequest, RequestOptions.none()); + } + + /** + * Create a credit unit code and precision are immutable once created. + * Price usage in the unit with a plan fee's credit_unit, grant it with a credit + * pack or a credit grant, and sell it with a top-up once it has a product_id and a + * selling price. + * + * @param creditUnitCreateRequest the request body + * @param requestOptions headers, timeout and retries of this call + * @return the response body + */ + public CreditUnit create( + final CreditUnitCreateRequest creditUnitCreateRequest, + final RequestOptions requestOptions) { + return exchangeCreate(creditUnitCreateRequest, requestOptions).send(); + } + + MeteroidHttpClient.Exchange exchangeCreate( + final CreditUnitCreateRequest creditUnitCreateRequest, + final RequestOptions requestOptions) { + Objects.requireNonNull(creditUnitCreateRequest, "body"); + HttpUrl url = client.newUrlBuilder().addPathSegments("api/v1/credit-units").build(); + return client.call("POST", url) + .json(creditUnitCreateRequest) + .errors( + com.meteroid.models.RestErrorResponse.class, + "400", + "401", + "409", + "429", + "500") + .options(requestOptions) + .returning(CreditUnit.class); + } + + /** + * Get a credit unit + * + *

The unit with its active selling prices. + * + * @param id the {@code id} path parameter + * @return the response body + */ + public CreditUnit retrieve(final String id) { + return retrieve(id, RequestOptions.none()); + } + + /** + * Get a credit unit + * + *

The unit with its active selling prices. + * + * @param id the {@code id} path parameter + * @param requestOptions headers, timeout and retries of this call + * @return the response body + */ + public CreditUnit retrieve(final String id, final RequestOptions requestOptions) { + return exchangeRetrieve(id, requestOptions).send(); + } + + MeteroidHttpClient.Exchange exchangeRetrieve( + final String id, final RequestOptions requestOptions) { + Objects.requireNonNull(id, "id"); + HttpUrl url = + client.newUrlBuilder() + .addPathSegments("api/v1/credit-units") + .addPathSegment(Utils.pathSegment("id", id)) + .build(); + return client.call("GET", url) + .errors(com.meteroid.models.RestErrorResponse.class, "401", "404", "429", "500") + .options(requestOptions) + .returning(CreditUnit.class); + } + + /** + * Update a credit unit + * + *

Partial update: an absent field is left unchanged. code and precision + * are immutable and cannot be changed here. Setting archived: true blocks + * the unit from new prices, packs and grants; existing ones keep working. + * + * @param id the {@code id} path parameter + * @param creditUnitUpdateRequest the request body + * @return the response body + */ + public CreditUnit update( + final String id, final CreditUnitUpdateRequest creditUnitUpdateRequest) { + return update(id, creditUnitUpdateRequest, RequestOptions.none()); + } + + /** + * Update a credit unit + * + *

Partial update: an absent field is left unchanged. code and precision + * are immutable and cannot be changed here. Setting archived: true blocks + * the unit from new prices, packs and grants; existing ones keep working. + * + * @param id the {@code id} path parameter + * @param creditUnitUpdateRequest the request body + * @param requestOptions headers, timeout and retries of this call + * @return the response body + */ + public CreditUnit update( + final String id, + final CreditUnitUpdateRequest creditUnitUpdateRequest, + final RequestOptions requestOptions) { + return exchangeUpdate(id, creditUnitUpdateRequest, requestOptions).send(); + } + + MeteroidHttpClient.Exchange exchangeUpdate( + final String id, + final CreditUnitUpdateRequest creditUnitUpdateRequest, + final RequestOptions requestOptions) { + Objects.requireNonNull(id, "id"); + Objects.requireNonNull(creditUnitUpdateRequest, "body"); + HttpUrl url = + client.newUrlBuilder() + .addPathSegments("api/v1/credit-units") + .addPathSegment(Utils.pathSegment("id", id)) + .build(); + return client.call("PATCH", url) + .json(creditUnitUpdateRequest) + .errors( + com.meteroid.models.RestErrorResponse.class, + "400", + "401", + "404", + "409", + "429", + "500") + .options(requestOptions) + .returning(CreditUnit.class); + } + + /** The operations, returning the status and headers along with the body. */ + public final class WithRawResponse { + private WithRawResponse() {} + + /** + * The {@code prices} operations. + * + * @return the operations + */ + public CreditUnitsPrices.WithRawResponse prices() { + return CreditUnits.this.prices.withRawResponse(); + } + + /** + * List credit units + * + *

The tenant's credit units (e.g. "Halyard credits"): denominations usage can be priced + * and credit granted in, instead of money, each with its selling prices. + * + * @return the status, headers and body + */ + public ApiResponse list() { + return list(CreditUnitsListOptions.none(), RequestOptions.none()); + } + + /** + * List credit units + * + *

The tenant's credit units (e.g. "Halyard credits"): denominations usage can be priced + * and credit granted in, instead of money, each with its selling prices. + * + * @param options the optional parameters + * @return the status, headers and body + */ + public ApiResponse list(final CreditUnitsListOptions options) { + return list(options, RequestOptions.none()); + } + + /** + * List credit units + * + *

The tenant's credit units (e.g. "Halyard credits"): denominations usage can be priced + * and credit granted in, instead of money, each with its selling prices. + * + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body + */ + public ApiResponse list(final RequestOptions requestOptions) { + return list(CreditUnitsListOptions.none(), requestOptions); + } + + /** + * List credit units + * + *

The tenant's credit units (e.g. "Halyard credits"): denominations usage can be priced + * and credit granted in, instead of money, each with its selling prices. + * + * @param options the optional parameters + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body + */ + public ApiResponse list( + final CreditUnitsListOptions options, final RequestOptions requestOptions) { + return CreditUnits.this.exchangeList(options, requestOptions).sendRaw(); + } + + /** + * Create a credit unit code and precision are immutable once + * created. Price usage in the unit with a plan fee's credit_unit, grant it + * with a credit pack or a credit grant, and sell it with a top-up once it has a + * product_id and a selling price. + * + * @param creditUnitCreateRequest the request body + * @return the status, headers and body + */ + public ApiResponse create( + final CreditUnitCreateRequest creditUnitCreateRequest) { + return create(creditUnitCreateRequest, RequestOptions.none()); + } + + /** + * Create a credit unit code and precision are immutable once + * created. Price usage in the unit with a plan fee's credit_unit, grant it + * with a credit pack or a credit grant, and sell it with a top-up once it has a + * product_id and a selling price. + * + * @param creditUnitCreateRequest the request body + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body + */ + public ApiResponse create( + final CreditUnitCreateRequest creditUnitCreateRequest, + final RequestOptions requestOptions) { + return CreditUnits.this + .exchangeCreate(creditUnitCreateRequest, requestOptions) + .sendRaw(); + } + + /** + * Get a credit unit + * + *

The unit with its active selling prices. + * + * @param id the {@code id} path parameter + * @return the status, headers and body + */ + public ApiResponse retrieve(final String id) { + return retrieve(id, RequestOptions.none()); + } + + /** + * Get a credit unit + * + *

The unit with its active selling prices. + * + * @param id the {@code id} path parameter + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body + */ + public ApiResponse retrieve( + final String id, final RequestOptions requestOptions) { + return CreditUnits.this.exchangeRetrieve(id, requestOptions).sendRaw(); + } + + /** + * Update a credit unit + * + *

Partial update: an absent field is left unchanged. code and + * precision are immutable and cannot be changed here. Setting archived: true + * blocks the unit from new prices, packs and grants; existing ones keep working. + * + * @param id the {@code id} path parameter + * @param creditUnitUpdateRequest the request body + * @return the status, headers and body + */ + public ApiResponse update( + final String id, final CreditUnitUpdateRequest creditUnitUpdateRequest) { + return update(id, creditUnitUpdateRequest, RequestOptions.none()); + } + + /** + * Update a credit unit + * + *

Partial update: an absent field is left unchanged. code and + * precision are immutable and cannot be changed here. Setting archived: true + * blocks the unit from new prices, packs and grants; existing ones keep working. + * + * @param id the {@code id} path parameter + * @param creditUnitUpdateRequest the request body + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body + */ + public ApiResponse update( + final String id, + final CreditUnitUpdateRequest creditUnitUpdateRequest, + final RequestOptions requestOptions) { + return CreditUnits.this + .exchangeUpdate(id, creditUnitUpdateRequest, requestOptions) + .sendRaw(); + } + } +} diff --git a/src/main/java/com/meteroid/api/CreditUnitsAsync.java b/src/main/java/com/meteroid/api/CreditUnitsAsync.java new file mode 100644 index 0000000..b45d7d8 --- /dev/null +++ b/src/main/java/com/meteroid/api/CreditUnitsAsync.java @@ -0,0 +1,356 @@ +// this file is @generated +package com.meteroid.api; + +import com.meteroid.ApiResponse; +import com.meteroid.RequestOptions; +import com.meteroid.models.CreditUnit; +import com.meteroid.models.CreditUnitCreateRequest; +import com.meteroid.models.CreditUnitListResponse; +import com.meteroid.models.CreditUnitUpdateRequest; + +import java.util.concurrent.CompletableFuture; + +/** + * The {@code credit_units} operations, without blocking: each method returns a {@link + * CompletableFuture}. Obtained from {@code client.async()}. + */ +public final class CreditUnitsAsync { + private final CreditUnits sync; + private final WithRawResponse withRawResponse; + + private final CreditUnitsPricesAsync prices; + + /** + * The operations, sending through {@code sync}. + * + * @param sync the blocking operations + */ + public CreditUnitsAsync(CreditUnits sync) { + this.sync = sync; + this.withRawResponse = new WithRawResponse(); + + this.prices = new CreditUnitsPricesAsync(sync.prices()); + } + + /** + * The same operations, returning the status and headers along with the body. + * + * @return the operations + */ + public WithRawResponse withRawResponse() { + return withRawResponse; + } + + /** + * The {@code prices} operations. + * + * @return the operations + */ + public CreditUnitsPricesAsync prices() { + return prices; + } + + /** + * List credit units + * + *

The tenant's credit units (e.g. "Halyard credits"): denominations usage can be priced and + * credit granted in, instead of money, each with its selling prices. + * + * @return the response body, once received + */ + public CompletableFuture list() { + return list(CreditUnitsListOptions.none(), RequestOptions.none()); + } + + /** + * List credit units + * + *

The tenant's credit units (e.g. "Halyard credits"): denominations usage can be priced and + * credit granted in, instead of money, each with its selling prices. + * + * @param options the optional parameters + * @return the response body, once received + */ + public CompletableFuture list(final CreditUnitsListOptions options) { + return list(options, RequestOptions.none()); + } + + /** + * List credit units + * + *

The tenant's credit units (e.g. "Halyard credits"): denominations usage can be priced and + * credit granted in, instead of money, each with its selling prices. + * + * @param requestOptions headers, timeout and retries of this call + * @return the response body, once received + */ + public CompletableFuture list(final RequestOptions requestOptions) { + return list(CreditUnitsListOptions.none(), requestOptions); + } + + /** + * List credit units + * + *

The tenant's credit units (e.g. "Halyard credits"): denominations usage can be priced and + * credit granted in, instead of money, each with its selling prices. + * + * @param options the optional parameters + * @param requestOptions headers, timeout and retries of this call + * @return the response body, once received + */ + public CompletableFuture list( + final CreditUnitsListOptions options, final RequestOptions requestOptions) { + return sync.exchangeList(options, requestOptions).sendAsync(); + } + + /** + * Create a credit unit code and precision are immutable once created. + * Price usage in the unit with a plan fee's credit_unit, grant it with a credit + * pack or a credit grant, and sell it with a top-up once it has a product_id and a + * selling price. + * + * @param creditUnitCreateRequest the request body + * @return the response body, once received + */ + public CompletableFuture create( + final CreditUnitCreateRequest creditUnitCreateRequest) { + return create(creditUnitCreateRequest, RequestOptions.none()); + } + + /** + * Create a credit unit code and precision are immutable once created. + * Price usage in the unit with a plan fee's credit_unit, grant it with a credit + * pack or a credit grant, and sell it with a top-up once it has a product_id and a + * selling price. + * + * @param creditUnitCreateRequest the request body + * @param requestOptions headers, timeout and retries of this call + * @return the response body, once received + */ + public CompletableFuture create( + final CreditUnitCreateRequest creditUnitCreateRequest, + final RequestOptions requestOptions) { + return sync.exchangeCreate(creditUnitCreateRequest, requestOptions).sendAsync(); + } + + /** + * Get a credit unit + * + *

The unit with its active selling prices. + * + * @param id the {@code id} path parameter + * @return the response body, once received + */ + public CompletableFuture retrieve(final String id) { + return retrieve(id, RequestOptions.none()); + } + + /** + * Get a credit unit + * + *

The unit with its active selling prices. + * + * @param id the {@code id} path parameter + * @param requestOptions headers, timeout and retries of this call + * @return the response body, once received + */ + public CompletableFuture retrieve( + final String id, final RequestOptions requestOptions) { + return sync.exchangeRetrieve(id, requestOptions).sendAsync(); + } + + /** + * Update a credit unit + * + *

Partial update: an absent field is left unchanged. code and precision + * are immutable and cannot be changed here. Setting archived: true blocks + * the unit from new prices, packs and grants; existing ones keep working. + * + * @param id the {@code id} path parameter + * @param creditUnitUpdateRequest the request body + * @return the response body, once received + */ + public CompletableFuture update( + final String id, final CreditUnitUpdateRequest creditUnitUpdateRequest) { + return update(id, creditUnitUpdateRequest, RequestOptions.none()); + } + + /** + * Update a credit unit + * + *

Partial update: an absent field is left unchanged. code and precision + * are immutable and cannot be changed here. Setting archived: true blocks + * the unit from new prices, packs and grants; existing ones keep working. + * + * @param id the {@code id} path parameter + * @param creditUnitUpdateRequest the request body + * @param requestOptions headers, timeout and retries of this call + * @return the response body, once received + */ + public CompletableFuture update( + final String id, + final CreditUnitUpdateRequest creditUnitUpdateRequest, + final RequestOptions requestOptions) { + return sync.exchangeUpdate(id, creditUnitUpdateRequest, requestOptions).sendAsync(); + } + + /** The operations, returning the status and headers along with the body. */ + public final class WithRawResponse { + private WithRawResponse() {} + + /** + * The {@code prices} operations. + * + * @return the operations + */ + public CreditUnitsPricesAsync.WithRawResponse prices() { + return CreditUnitsAsync.this.prices.withRawResponse(); + } + + /** + * List credit units + * + *

The tenant's credit units (e.g. "Halyard credits"): denominations usage can be priced + * and credit granted in, instead of money, each with its selling prices. + * + * @return the status, headers and body, once received + */ + public CompletableFuture> list() { + return list(CreditUnitsListOptions.none(), RequestOptions.none()); + } + + /** + * List credit units + * + *

The tenant's credit units (e.g. "Halyard credits"): denominations usage can be priced + * and credit granted in, instead of money, each with its selling prices. + * + * @param options the optional parameters + * @return the status, headers and body, once received + */ + public CompletableFuture> list( + final CreditUnitsListOptions options) { + return list(options, RequestOptions.none()); + } + + /** + * List credit units + * + *

The tenant's credit units (e.g. "Halyard credits"): denominations usage can be priced + * and credit granted in, instead of money, each with its selling prices. + * + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body, once received + */ + public CompletableFuture> list( + final RequestOptions requestOptions) { + return list(CreditUnitsListOptions.none(), requestOptions); + } + + /** + * List credit units + * + *

The tenant's credit units (e.g. "Halyard credits"): denominations usage can be priced + * and credit granted in, instead of money, each with its selling prices. + * + * @param options the optional parameters + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body, once received + */ + public CompletableFuture> list( + final CreditUnitsListOptions options, final RequestOptions requestOptions) { + return sync.exchangeList(options, requestOptions).sendRawAsync(); + } + + /** + * Create a credit unit code and precision are immutable once + * created. Price usage in the unit with a plan fee's credit_unit, grant it + * with a credit pack or a credit grant, and sell it with a top-up once it has a + * product_id and a selling price. + * + * @param creditUnitCreateRequest the request body + * @return the status, headers and body, once received + */ + public CompletableFuture> create( + final CreditUnitCreateRequest creditUnitCreateRequest) { + return create(creditUnitCreateRequest, RequestOptions.none()); + } + + /** + * Create a credit unit code and precision are immutable once + * created. Price usage in the unit with a plan fee's credit_unit, grant it + * with a credit pack or a credit grant, and sell it with a top-up once it has a + * product_id and a selling price. + * + * @param creditUnitCreateRequest the request body + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body, once received + */ + public CompletableFuture> create( + final CreditUnitCreateRequest creditUnitCreateRequest, + final RequestOptions requestOptions) { + return sync.exchangeCreate(creditUnitCreateRequest, requestOptions).sendRawAsync(); + } + + /** + * Get a credit unit + * + *

The unit with its active selling prices. + * + * @param id the {@code id} path parameter + * @return the status, headers and body, once received + */ + public CompletableFuture> retrieve(final String id) { + return retrieve(id, RequestOptions.none()); + } + + /** + * Get a credit unit + * + *

The unit with its active selling prices. + * + * @param id the {@code id} path parameter + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body, once received + */ + public CompletableFuture> retrieve( + final String id, final RequestOptions requestOptions) { + return sync.exchangeRetrieve(id, requestOptions).sendRawAsync(); + } + + /** + * Update a credit unit + * + *

Partial update: an absent field is left unchanged. code and + * precision are immutable and cannot be changed here. Setting archived: true + * blocks the unit from new prices, packs and grants; existing ones keep working. + * + * @param id the {@code id} path parameter + * @param creditUnitUpdateRequest the request body + * @return the status, headers and body, once received + */ + public CompletableFuture> update( + final String id, final CreditUnitUpdateRequest creditUnitUpdateRequest) { + return update(id, creditUnitUpdateRequest, RequestOptions.none()); + } + + /** + * Update a credit unit + * + *

Partial update: an absent field is left unchanged. code and + * precision are immutable and cannot be changed here. Setting archived: true + * blocks the unit from new prices, packs and grants; existing ones keep working. + * + * @param id the {@code id} path parameter + * @param creditUnitUpdateRequest the request body + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body, once received + */ + public CompletableFuture> update( + final String id, + final CreditUnitUpdateRequest creditUnitUpdateRequest, + final RequestOptions requestOptions) { + return sync.exchangeUpdate(id, creditUnitUpdateRequest, requestOptions).sendRawAsync(); + } + } +} diff --git a/src/main/java/com/meteroid/api/CreditUnitsListOptions.java b/src/main/java/com/meteroid/api/CreditUnitsListOptions.java new file mode 100644 index 0000000..9d3cbc2 --- /dev/null +++ b/src/main/java/com/meteroid/api/CreditUnitsListOptions.java @@ -0,0 +1,101 @@ +// this file is @generated +package com.meteroid.api; + +import java.util.Objects; +import java.util.Optional; + +/** Optional parameters of {@code list}, immutable: build them with {@link #builder()}. */ +public final class CreditUnitsListOptions { + private final Boolean includeArchived; + + private CreditUnitsListOptions(Builder builder) { + this.includeArchived = builder.includeArchived; + } + + /** + * A builder of parameters. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * No parameters. + * + * @return empty parameters + */ + public static CreditUnitsListOptions none() { + return builder().build(); + } + + /** + * A builder starting from these parameters. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.includeArchived = includeArchived; + return builder; + } + + /** + * Include archived units. Defaults to false. + * + * @return the value, empty when unset + */ + public Optional includeArchived() { + return Optional.ofNullable(includeArchived); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CreditUnitsListOptions that = (CreditUnitsListOptions) o; + return Objects.equals(includeArchived, that.includeArchived); + } + + @Override + public int hashCode() { + return Objects.hash(includeArchived); + } + + @Override + public String toString() { + return "CreditUnitsListOptions{" + "includeArchived=" + includeArchived + "}"; + } + + /** Builds {@link CreditUnitsListOptions}. */ + public static final class Builder { + private Boolean includeArchived; + + private Builder() {} + + /** + * Include archived units. Defaults to false. + * + * @param includeArchived the value, null to leave it out + * @return this builder + */ + public Builder includeArchived(Boolean includeArchived) { + this.includeArchived = includeArchived; + return this; + } + + /** + * The parameters. + * + * @return immutable parameters + */ + public CreditUnitsListOptions build() { + return new CreditUnitsListOptions(this); + } + } +} diff --git a/src/main/java/com/meteroid/api/CreditUnitsPrices.java b/src/main/java/com/meteroid/api/CreditUnitsPrices.java new file mode 100644 index 0000000..258c107 --- /dev/null +++ b/src/main/java/com/meteroid/api/CreditUnitsPrices.java @@ -0,0 +1,371 @@ +// this file is @generated +package com.meteroid.api; + +import com.meteroid.ApiResponse; +import com.meteroid.RequestOptions; +import com.meteroid.internal.MeteroidHttpClient; +import com.meteroid.internal.Utils; +import com.meteroid.models.CreditUnitPrice; +import com.meteroid.models.CreditUnitPriceListResponse; +import com.meteroid.models.CreditUnitPriceSetRequest; + +import okhttp3.HttpUrl; + +import java.util.Objects; + +/** + * The {@code credit_units.prices} operations, blocking. {@link #withRawResponse()} has the same + * methods returning the status and headers along with the body. + */ +public final class CreditUnitsPrices { + private final MeteroidHttpClient client; + private final WithRawResponse withRawResponse; + + /** + * The operations, sending through {@code client}. + * + * @param client the HTTP client of the SDK + */ + public CreditUnitsPrices(MeteroidHttpClient client) { + this.client = client; + this.withRawResponse = new WithRawResponse(); + } + + /** + * The same operations, returning the status and headers along with the body. + * + * @return the operations + */ + public WithRawResponse withRawResponse() { + return withRawResponse; + } + + /** + * List a credit unit's selling prices + * + *

The active price per currency, and archived ones when asked, newest first. + * + * @param id the {@code id} path parameter + * @return the response body + */ + public CreditUnitPriceListResponse list(final String id) { + return list(id, CreditUnitsPricesListOptions.none(), RequestOptions.none()); + } + + /** + * List a credit unit's selling prices + * + *

The active price per currency, and archived ones when asked, newest first. + * + * @param id the {@code id} path parameter + * @param options the optional parameters + * @return the response body + */ + public CreditUnitPriceListResponse list( + final String id, final CreditUnitsPricesListOptions options) { + return list(id, options, RequestOptions.none()); + } + + /** + * List a credit unit's selling prices + * + *

The active price per currency, and archived ones when asked, newest first. + * + * @param id the {@code id} path parameter + * @param requestOptions headers, timeout and retries of this call + * @return the response body + */ + public CreditUnitPriceListResponse list(final String id, final RequestOptions requestOptions) { + return list(id, CreditUnitsPricesListOptions.none(), requestOptions); + } + + /** + * List a credit unit's selling prices + * + *

The active price per currency, and archived ones when asked, newest first. + * + * @param id the {@code id} path parameter + * @param options the optional parameters + * @param requestOptions headers, timeout and retries of this call + * @return the response body + */ + public CreditUnitPriceListResponse list( + final String id, + final CreditUnitsPricesListOptions options, + final RequestOptions requestOptions) { + return exchangeList(id, options, requestOptions).send(); + } + + MeteroidHttpClient.Exchange exchangeList( + final String id, + final CreditUnitsPricesListOptions options, + final RequestOptions requestOptions) { + Objects.requireNonNull(id, "id"); + Objects.requireNonNull(options, "options"); + HttpUrl.Builder url = + client.newUrlBuilder() + .addPathSegments("api/v1/credit-units") + .addPathSegment(Utils.pathSegment("id", id)) + .addPathSegments("prices"); + Boolean value1 = options.includeArchived().orElse(null); + if (value1 != null) { + url.addQueryParameter("include_archived", Utils.serializeQueryParam(value1)); + } + return client.call("GET", url.build()) + .errors(com.meteroid.models.RestErrorResponse.class, "401", "404", "429", "500") + .options(requestOptions) + .returning(CreditUnitPriceListResponse.class); + } + + /** + * Set a credit unit's selling price + * + *

The price of one credit in a currency, used to sell the unit through top-ups and automatic + * top-ups (taxed at purchase under the unit's product_id). Replaces the active + * price in that currency, which is archived: a top-up already priced keeps its terms. + * + * @param id the {@code id} path parameter + * @param currency the {@code currency} path parameter + * @param creditUnitPriceSetRequest the request body + * @return the response body + */ + public CreditUnitPrice update( + final String id, + final String currency, + final CreditUnitPriceSetRequest creditUnitPriceSetRequest) { + return update(id, currency, creditUnitPriceSetRequest, RequestOptions.none()); + } + + /** + * Set a credit unit's selling price + * + *

The price of one credit in a currency, used to sell the unit through top-ups and automatic + * top-ups (taxed at purchase under the unit's product_id). Replaces the active + * price in that currency, which is archived: a top-up already priced keeps its terms. + * + * @param id the {@code id} path parameter + * @param currency the {@code currency} path parameter + * @param creditUnitPriceSetRequest the request body + * @param requestOptions headers, timeout and retries of this call + * @return the response body + */ + public CreditUnitPrice update( + final String id, + final String currency, + final CreditUnitPriceSetRequest creditUnitPriceSetRequest, + final RequestOptions requestOptions) { + return exchangeUpdate(id, currency, creditUnitPriceSetRequest, requestOptions).send(); + } + + MeteroidHttpClient.Exchange exchangeUpdate( + final String id, + final String currency, + final CreditUnitPriceSetRequest creditUnitPriceSetRequest, + final RequestOptions requestOptions) { + Objects.requireNonNull(id, "id"); + Objects.requireNonNull(currency, "currency"); + Objects.requireNonNull(creditUnitPriceSetRequest, "body"); + HttpUrl url = + client.newUrlBuilder() + .addPathSegments("api/v1/credit-units") + .addPathSegment(Utils.pathSegment("id", id)) + .addPathSegments("prices") + .addPathSegment(Utils.pathSegment("currency", currency)) + .build(); + return client.call("PUT", url) + .json(creditUnitPriceSetRequest) + .errors( + com.meteroid.models.RestErrorResponse.class, + "400", + "401", + "404", + "409", + "429", + "500") + .options(requestOptions) + .returning(CreditUnitPrice.class); + } + + /** + * Remove a credit unit's selling price + * + *

Archives the active price in a currency: the unit can no longer be sold in it (top-ups and + * automatic top-ups included) until a new price is set. + * + * @param id the {@code id} path parameter + * @param currency the {@code currency} path parameter + * @return the response body + */ + public CreditUnitPrice archive(final String id, final String currency) { + return archive(id, currency, RequestOptions.none()); + } + + /** + * Remove a credit unit's selling price + * + *

Archives the active price in a currency: the unit can no longer be sold in it (top-ups and + * automatic top-ups included) until a new price is set. + * + * @param id the {@code id} path parameter + * @param currency the {@code currency} path parameter + * @param requestOptions headers, timeout and retries of this call + * @return the response body + */ + public CreditUnitPrice archive( + final String id, final String currency, final RequestOptions requestOptions) { + return exchangeArchive(id, currency, requestOptions).send(); + } + + MeteroidHttpClient.Exchange exchangeArchive( + final String id, final String currency, final RequestOptions requestOptions) { + Objects.requireNonNull(id, "id"); + Objects.requireNonNull(currency, "currency"); + HttpUrl url = + client.newUrlBuilder() + .addPathSegments("api/v1/credit-units") + .addPathSegment(Utils.pathSegment("id", id)) + .addPathSegments("prices") + .addPathSegment(Utils.pathSegment("currency", currency)) + .build(); + return client.call("DELETE", url) + .errors(com.meteroid.models.RestErrorResponse.class, "401", "404", "429", "500") + .options(requestOptions) + .returning(CreditUnitPrice.class); + } + + /** The operations, returning the status and headers along with the body. */ + public final class WithRawResponse { + private WithRawResponse() {} + + /** + * List a credit unit's selling prices + * + *

The active price per currency, and archived ones when asked, newest first. + * + * @param id the {@code id} path parameter + * @return the status, headers and body + */ + public ApiResponse list(final String id) { + return list(id, CreditUnitsPricesListOptions.none(), RequestOptions.none()); + } + + /** + * List a credit unit's selling prices + * + *

The active price per currency, and archived ones when asked, newest first. + * + * @param id the {@code id} path parameter + * @param options the optional parameters + * @return the status, headers and body + */ + public ApiResponse list( + final String id, final CreditUnitsPricesListOptions options) { + return list(id, options, RequestOptions.none()); + } + + /** + * List a credit unit's selling prices + * + *

The active price per currency, and archived ones when asked, newest first. + * + * @param id the {@code id} path parameter + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body + */ + public ApiResponse list( + final String id, final RequestOptions requestOptions) { + return list(id, CreditUnitsPricesListOptions.none(), requestOptions); + } + + /** + * List a credit unit's selling prices + * + *

The active price per currency, and archived ones when asked, newest first. + * + * @param id the {@code id} path parameter + * @param options the optional parameters + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body + */ + public ApiResponse list( + final String id, + final CreditUnitsPricesListOptions options, + final RequestOptions requestOptions) { + return CreditUnitsPrices.this.exchangeList(id, options, requestOptions).sendRaw(); + } + + /** + * Set a credit unit's selling price + * + *

The price of one credit in a currency, used to sell the unit through top-ups and + * automatic top-ups (taxed at purchase under the unit's product_id). Replaces + * the active price in that currency, which is archived: a top-up already priced keeps its + * terms. + * + * @param id the {@code id} path parameter + * @param currency the {@code currency} path parameter + * @param creditUnitPriceSetRequest the request body + * @return the status, headers and body + */ + public ApiResponse update( + final String id, + final String currency, + final CreditUnitPriceSetRequest creditUnitPriceSetRequest) { + return update(id, currency, creditUnitPriceSetRequest, RequestOptions.none()); + } + + /** + * Set a credit unit's selling price + * + *

The price of one credit in a currency, used to sell the unit through top-ups and + * automatic top-ups (taxed at purchase under the unit's product_id). Replaces + * the active price in that currency, which is archived: a top-up already priced keeps its + * terms. + * + * @param id the {@code id} path parameter + * @param currency the {@code currency} path parameter + * @param creditUnitPriceSetRequest the request body + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body + */ + public ApiResponse update( + final String id, + final String currency, + final CreditUnitPriceSetRequest creditUnitPriceSetRequest, + final RequestOptions requestOptions) { + return CreditUnitsPrices.this + .exchangeUpdate(id, currency, creditUnitPriceSetRequest, requestOptions) + .sendRaw(); + } + + /** + * Remove a credit unit's selling price + * + *

Archives the active price in a currency: the unit can no longer be sold in it (top-ups + * and automatic top-ups included) until a new price is set. + * + * @param id the {@code id} path parameter + * @param currency the {@code currency} path parameter + * @return the status, headers and body + */ + public ApiResponse archive(final String id, final String currency) { + return archive(id, currency, RequestOptions.none()); + } + + /** + * Remove a credit unit's selling price + * + *

Archives the active price in a currency: the unit can no longer be sold in it (top-ups + * and automatic top-ups included) until a new price is set. + * + * @param id the {@code id} path parameter + * @param currency the {@code currency} path parameter + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body + */ + public ApiResponse archive( + final String id, final String currency, final RequestOptions requestOptions) { + return CreditUnitsPrices.this.exchangeArchive(id, currency, requestOptions).sendRaw(); + } + } +} diff --git a/src/main/java/com/meteroid/api/CreditUnitsPricesAsync.java b/src/main/java/com/meteroid/api/CreditUnitsPricesAsync.java new file mode 100644 index 0000000..84276f7 --- /dev/null +++ b/src/main/java/com/meteroid/api/CreditUnitsPricesAsync.java @@ -0,0 +1,302 @@ +// this file is @generated +package com.meteroid.api; + +import com.meteroid.ApiResponse; +import com.meteroid.RequestOptions; +import com.meteroid.models.CreditUnitPrice; +import com.meteroid.models.CreditUnitPriceListResponse; +import com.meteroid.models.CreditUnitPriceSetRequest; + +import java.util.concurrent.CompletableFuture; + +/** + * The {@code credit_units.prices} operations, without blocking: each method returns a {@link + * CompletableFuture}. Obtained from {@code client.async()}. + */ +public final class CreditUnitsPricesAsync { + private final CreditUnitsPrices sync; + private final WithRawResponse withRawResponse; + + /** + * The operations, sending through {@code sync}. + * + * @param sync the blocking operations + */ + public CreditUnitsPricesAsync(CreditUnitsPrices sync) { + this.sync = sync; + this.withRawResponse = new WithRawResponse(); + } + + /** + * The same operations, returning the status and headers along with the body. + * + * @return the operations + */ + public WithRawResponse withRawResponse() { + return withRawResponse; + } + + /** + * List a credit unit's selling prices + * + *

The active price per currency, and archived ones when asked, newest first. + * + * @param id the {@code id} path parameter + * @return the response body, once received + */ + public CompletableFuture list(final String id) { + return list(id, CreditUnitsPricesListOptions.none(), RequestOptions.none()); + } + + /** + * List a credit unit's selling prices + * + *

The active price per currency, and archived ones when asked, newest first. + * + * @param id the {@code id} path parameter + * @param options the optional parameters + * @return the response body, once received + */ + public CompletableFuture list( + final String id, final CreditUnitsPricesListOptions options) { + return list(id, options, RequestOptions.none()); + } + + /** + * List a credit unit's selling prices + * + *

The active price per currency, and archived ones when asked, newest first. + * + * @param id the {@code id} path parameter + * @param requestOptions headers, timeout and retries of this call + * @return the response body, once received + */ + public CompletableFuture list( + final String id, final RequestOptions requestOptions) { + return list(id, CreditUnitsPricesListOptions.none(), requestOptions); + } + + /** + * List a credit unit's selling prices + * + *

The active price per currency, and archived ones when asked, newest first. + * + * @param id the {@code id} path parameter + * @param options the optional parameters + * @param requestOptions headers, timeout and retries of this call + * @return the response body, once received + */ + public CompletableFuture list( + final String id, + final CreditUnitsPricesListOptions options, + final RequestOptions requestOptions) { + return sync.exchangeList(id, options, requestOptions).sendAsync(); + } + + /** + * Set a credit unit's selling price + * + *

The price of one credit in a currency, used to sell the unit through top-ups and automatic + * top-ups (taxed at purchase under the unit's product_id). Replaces the active + * price in that currency, which is archived: a top-up already priced keeps its terms. + * + * @param id the {@code id} path parameter + * @param currency the {@code currency} path parameter + * @param creditUnitPriceSetRequest the request body + * @return the response body, once received + */ + public CompletableFuture update( + final String id, + final String currency, + final CreditUnitPriceSetRequest creditUnitPriceSetRequest) { + return update(id, currency, creditUnitPriceSetRequest, RequestOptions.none()); + } + + /** + * Set a credit unit's selling price + * + *

The price of one credit in a currency, used to sell the unit through top-ups and automatic + * top-ups (taxed at purchase under the unit's product_id). Replaces the active + * price in that currency, which is archived: a top-up already priced keeps its terms. + * + * @param id the {@code id} path parameter + * @param currency the {@code currency} path parameter + * @param creditUnitPriceSetRequest the request body + * @param requestOptions headers, timeout and retries of this call + * @return the response body, once received + */ + public CompletableFuture update( + final String id, + final String currency, + final CreditUnitPriceSetRequest creditUnitPriceSetRequest, + final RequestOptions requestOptions) { + return sync.exchangeUpdate(id, currency, creditUnitPriceSetRequest, requestOptions) + .sendAsync(); + } + + /** + * Remove a credit unit's selling price + * + *

Archives the active price in a currency: the unit can no longer be sold in it (top-ups and + * automatic top-ups included) until a new price is set. + * + * @param id the {@code id} path parameter + * @param currency the {@code currency} path parameter + * @return the response body, once received + */ + public CompletableFuture archive(final String id, final String currency) { + return archive(id, currency, RequestOptions.none()); + } + + /** + * Remove a credit unit's selling price + * + *

Archives the active price in a currency: the unit can no longer be sold in it (top-ups and + * automatic top-ups included) until a new price is set. + * + * @param id the {@code id} path parameter + * @param currency the {@code currency} path parameter + * @param requestOptions headers, timeout and retries of this call + * @return the response body, once received + */ + public CompletableFuture archive( + final String id, final String currency, final RequestOptions requestOptions) { + return sync.exchangeArchive(id, currency, requestOptions).sendAsync(); + } + + /** The operations, returning the status and headers along with the body. */ + public final class WithRawResponse { + private WithRawResponse() {} + + /** + * List a credit unit's selling prices + * + *

The active price per currency, and archived ones when asked, newest first. + * + * @param id the {@code id} path parameter + * @return the status, headers and body, once received + */ + public CompletableFuture> list(final String id) { + return list(id, CreditUnitsPricesListOptions.none(), RequestOptions.none()); + } + + /** + * List a credit unit's selling prices + * + *

The active price per currency, and archived ones when asked, newest first. + * + * @param id the {@code id} path parameter + * @param options the optional parameters + * @return the status, headers and body, once received + */ + public CompletableFuture> list( + final String id, final CreditUnitsPricesListOptions options) { + return list(id, options, RequestOptions.none()); + } + + /** + * List a credit unit's selling prices + * + *

The active price per currency, and archived ones when asked, newest first. + * + * @param id the {@code id} path parameter + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body, once received + */ + public CompletableFuture> list( + final String id, final RequestOptions requestOptions) { + return list(id, CreditUnitsPricesListOptions.none(), requestOptions); + } + + /** + * List a credit unit's selling prices + * + *

The active price per currency, and archived ones when asked, newest first. + * + * @param id the {@code id} path parameter + * @param options the optional parameters + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body, once received + */ + public CompletableFuture> list( + final String id, + final CreditUnitsPricesListOptions options, + final RequestOptions requestOptions) { + return sync.exchangeList(id, options, requestOptions).sendRawAsync(); + } + + /** + * Set a credit unit's selling price + * + *

The price of one credit in a currency, used to sell the unit through top-ups and + * automatic top-ups (taxed at purchase under the unit's product_id). Replaces + * the active price in that currency, which is archived: a top-up already priced keeps its + * terms. + * + * @param id the {@code id} path parameter + * @param currency the {@code currency} path parameter + * @param creditUnitPriceSetRequest the request body + * @return the status, headers and body, once received + */ + public CompletableFuture> update( + final String id, + final String currency, + final CreditUnitPriceSetRequest creditUnitPriceSetRequest) { + return update(id, currency, creditUnitPriceSetRequest, RequestOptions.none()); + } + + /** + * Set a credit unit's selling price + * + *

The price of one credit in a currency, used to sell the unit through top-ups and + * automatic top-ups (taxed at purchase under the unit's product_id). Replaces + * the active price in that currency, which is archived: a top-up already priced keeps its + * terms. + * + * @param id the {@code id} path parameter + * @param currency the {@code currency} path parameter + * @param creditUnitPriceSetRequest the request body + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body, once received + */ + public CompletableFuture> update( + final String id, + final String currency, + final CreditUnitPriceSetRequest creditUnitPriceSetRequest, + final RequestOptions requestOptions) { + return sync.exchangeUpdate(id, currency, creditUnitPriceSetRequest, requestOptions) + .sendRawAsync(); + } + + /** + * Remove a credit unit's selling price + * + *

Archives the active price in a currency: the unit can no longer be sold in it (top-ups + * and automatic top-ups included) until a new price is set. + * + * @param id the {@code id} path parameter + * @param currency the {@code currency} path parameter + * @return the status, headers and body, once received + */ + public CompletableFuture> archive( + final String id, final String currency) { + return archive(id, currency, RequestOptions.none()); + } + + /** + * Remove a credit unit's selling price + * + *

Archives the active price in a currency: the unit can no longer be sold in it (top-ups + * and automatic top-ups included) until a new price is set. + * + * @param id the {@code id} path parameter + * @param currency the {@code currency} path parameter + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body, once received + */ + public CompletableFuture> archive( + final String id, final String currency, final RequestOptions requestOptions) { + return sync.exchangeArchive(id, currency, requestOptions).sendRawAsync(); + } + } +} diff --git a/src/main/java/com/meteroid/api/CreditUnitsPricesListOptions.java b/src/main/java/com/meteroid/api/CreditUnitsPricesListOptions.java new file mode 100644 index 0000000..237b848 --- /dev/null +++ b/src/main/java/com/meteroid/api/CreditUnitsPricesListOptions.java @@ -0,0 +1,101 @@ +// this file is @generated +package com.meteroid.api; + +import java.util.Objects; +import java.util.Optional; + +/** Optional parameters of {@code list}, immutable: build them with {@link #builder()}. */ +public final class CreditUnitsPricesListOptions { + private final Boolean includeArchived; + + private CreditUnitsPricesListOptions(Builder builder) { + this.includeArchived = builder.includeArchived; + } + + /** + * A builder of parameters. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * No parameters. + * + * @return empty parameters + */ + public static CreditUnitsPricesListOptions none() { + return builder().build(); + } + + /** + * A builder starting from these parameters. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.includeArchived = includeArchived; + return builder; + } + + /** + * Include archived prices. Defaults to false. + * + * @return the value, empty when unset + */ + public Optional includeArchived() { + return Optional.ofNullable(includeArchived); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CreditUnitsPricesListOptions that = (CreditUnitsPricesListOptions) o; + return Objects.equals(includeArchived, that.includeArchived); + } + + @Override + public int hashCode() { + return Objects.hash(includeArchived); + } + + @Override + public String toString() { + return "CreditUnitsPricesListOptions{" + "includeArchived=" + includeArchived + "}"; + } + + /** Builds {@link CreditUnitsPricesListOptions}. */ + public static final class Builder { + private Boolean includeArchived; + + private Builder() {} + + /** + * Include archived prices. Defaults to false. + * + * @param includeArchived the value, null to leave it out + * @return this builder + */ + public Builder includeArchived(Boolean includeArchived) { + this.includeArchived = includeArchived; + return this; + } + + /** + * The parameters. + * + * @return immutable parameters + */ + public CreditUnitsPricesListOptions build() { + return new CreditUnitsPricesListOptions(this); + } + } +} diff --git a/src/main/java/com/meteroid/api/Credits.java b/src/main/java/com/meteroid/api/Credits.java new file mode 100644 index 0000000..818fe75 --- /dev/null +++ b/src/main/java/com/meteroid/api/Credits.java @@ -0,0 +1,453 @@ +// this file is @generated +package com.meteroid.api; + +import com.meteroid.ApiResponse; +import com.meteroid.RequestOptions; +import com.meteroid.internal.MeteroidHttpClient; +import com.meteroid.internal.Utils; +import com.meteroid.models.CreateTopUpRequest; +import com.meteroid.models.Currency; +import com.meteroid.models.LedgerEntry; +import com.meteroid.models.LedgerListResponse; +import com.meteroid.models.TopUpResponse; + +import okhttp3.Headers; +import okhttp3.HttpUrl; + +import java.util.List; +import java.util.Objects; + +/** + * The {@code credits} operations, blocking. {@link #withRawResponse()} has the same methods + * returning the status and headers along with the body. + */ +public final class Credits { + private final MeteroidHttpClient client; + private final WithRawResponse withRawResponse; + + private final CreditsGrants grants; + + private final CreditsWallets wallets; + + /** + * The operations, sending through {@code client}. + * + * @param client the HTTP client of the SDK + */ + public Credits(MeteroidHttpClient client) { + this.client = client; + this.withRawResponse = new WithRawResponse(); + + this.grants = new CreditsGrants(client); + + this.wallets = new CreditsWallets(client); + } + + /** + * The same operations, returning the status and headers along with the body. + * + * @return the operations + */ + public WithRawResponse withRawResponse() { + return withRawResponse; + } + + /** + * The {@code grants} operations. + * + * @return the operations + */ + public CreditsGrants grants() { + return grants; + } + + /** + * The {@code wallets} operations. + * + * @return the operations + */ + public CreditsWallets wallets() { + return wallets; + } + + /** + * List credit ledger entries + * + *

Every movement of a customer's credit in one currency or credit unit, newest first, with + * the credit on account after it: credit granted, applied to invoices, given back, expired or + * rolled over. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @return the page: the response body, its items and the way to the next pages + */ + public CreditsListCustomerCreditLedgerPage listCustomerCreditLedger(final String idOrAlias) { + return listCustomerCreditLedger( + idOrAlias, CreditsListCustomerCreditLedgerOptions.none(), RequestOptions.none()); + } + + /** + * List credit ledger entries + * + *

Every movement of a customer's credit in one currency or credit unit, newest first, with + * the credit on account after it: credit granted, applied to invoices, given back, expired or + * rolled over. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param options the optional parameters + * @return the page: the response body, its items and the way to the next pages + */ + public CreditsListCustomerCreditLedgerPage listCustomerCreditLedger( + final String idOrAlias, final CreditsListCustomerCreditLedgerOptions options) { + return listCustomerCreditLedger(idOrAlias, options, RequestOptions.none()); + } + + /** + * List credit ledger entries + * + *

Every movement of a customer's credit in one currency or credit unit, newest first, with + * the credit on account after it: credit granted, applied to invoices, given back, expired or + * rolled over. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param requestOptions headers, timeout and retries of this call + * @return the page: the response body, its items and the way to the next pages + */ + public CreditsListCustomerCreditLedgerPage listCustomerCreditLedger( + final String idOrAlias, final RequestOptions requestOptions) { + return listCustomerCreditLedger( + idOrAlias, CreditsListCustomerCreditLedgerOptions.none(), requestOptions); + } + + /** + * List credit ledger entries + * + *

Every movement of a customer's credit in one currency or credit unit, newest first, with + * the credit on account after it: credit granted, applied to invoices, given back, expired or + * rolled over. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param options the optional parameters + * @param requestOptions headers, timeout and retries of this call + * @return the page: the response body, its items and the way to the next pages + */ + public CreditsListCustomerCreditLedgerPage listCustomerCreditLedger( + final String idOrAlias, + final CreditsListCustomerCreditLedgerOptions options, + final RequestOptions requestOptions) { + return pageOfListCustomerCreditLedger( + exchangeListCustomerCreditLedger(idOrAlias, options, requestOptions).send(), + idOrAlias, + options, + requestOptions); + } + + MeteroidHttpClient.Exchange exchangeListCustomerCreditLedger( + final String idOrAlias, + final CreditsListCustomerCreditLedgerOptions options, + final RequestOptions requestOptions) { + Objects.requireNonNull(idOrAlias, "id_or_alias"); + Objects.requireNonNull(options, "options"); + HttpUrl.Builder url = + client.newUrlBuilder() + .addPathSegments("api/v1/customers") + .addPathSegment(Utils.pathSegment("id_or_alias", idOrAlias)) + .addPathSegments("credit-ledger"); + Currency value1 = options.currency().orElse(null); + if (value1 != null) { + url.addQueryParameter("currency", Utils.serializeQueryParam(value1)); + } + String value2 = options.creditUnit().orElse(null); + if (value2 != null) { + url.addQueryParameter("credit_unit", value2); + } + Integer value3 = options.page().orElse(null); + if (value3 != null) { + url.addQueryParameter("page", Utils.serializeQueryParam(value3)); + } + Integer value4 = options.perPage().orElse(null); + if (value4 != null) { + url.addQueryParameter("per_page", Utils.serializeQueryParam(value4)); + } + return client.call("GET", url.build()) + .errors( + com.meteroid.models.RestErrorResponse.class, + "400", + "401", + "404", + "429", + "500") + .options(requestOptions) + .returning(LedgerListResponse.class); + } + + private CreditsListCustomerCreditLedgerPage pageOfListCustomerCreditLedger( + LedgerListResponse response, + final String idOrAlias, + final CreditsListCustomerCreditLedgerOptions options, + final RequestOptions requestOptions) { + List items = itemsOfListCustomerCreditLedger(response); + Integer next = nextOfListCustomerCreditLedger(response, items, options.page().orElse(0)); + return new CreditsListCustomerCreditLedgerPage( + response, + items, + next == null + ? null + : () -> + listCustomerCreditLedger( + idOrAlias, + options.toBuilder().page(next).build(), + requestOptions)); + } + + static List itemsOfListCustomerCreditLedger(LedgerListResponse response) { + return Utils.optional(response.data()).orElse(List.of()); + } + + /** The parameter of the page after {@code response}, null after the last one. */ + static Integer nextOfListCustomerCreditLedger( + LedgerListResponse response, List items, Integer current) { + if (items.isEmpty()) { + return null; + } + long pages = + Utils.optional(response.paginationMeta()) + .flatMap(v2 -> Utils.optional(v2.totalPages())) + .map(Number::longValue) + .orElse(Long.MAX_VALUE); + if (current - 0 + 1 >= pages) { + return null; + } + return current + 1; + } + + /** + * Create a top-up + * + *

Sells credit: CHARGE bills a saved payment method now, SEND_INVOICE grants it once paid. + * The credit is PAID and applies to ALL charges. Currency credit is sold one for one, untaxed, + * as its usage is taxed when invoiced. With credit_unit, sells credits of that + * unit at its selling price in the customer's currency, taxed at purchase under the unit's + * product; refused when the unit has no price in that currency or no product. Without a saved + * payment method, CHARGE returns a hosted checkout_url where the customer pays. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param idempotencyKey the {@code Idempotency-Key} required parameter + * @param createTopUpRequest the request body + * @return the response body + */ + public TopUpResponse createCustomerTopUp( + final String idOrAlias, + final String idempotencyKey, + final CreateTopUpRequest createTopUpRequest) { + return createCustomerTopUp( + idOrAlias, idempotencyKey, createTopUpRequest, RequestOptions.none()); + } + + /** + * Create a top-up + * + *

Sells credit: CHARGE bills a saved payment method now, SEND_INVOICE grants it once paid. + * The credit is PAID and applies to ALL charges. Currency credit is sold one for one, untaxed, + * as its usage is taxed when invoiced. With credit_unit, sells credits of that + * unit at its selling price in the customer's currency, taxed at purchase under the unit's + * product; refused when the unit has no price in that currency or no product. Without a saved + * payment method, CHARGE returns a hosted checkout_url where the customer pays. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param idempotencyKey the {@code Idempotency-Key} required parameter + * @param createTopUpRequest the request body + * @param requestOptions headers, timeout and retries of this call + * @return the response body + */ + public TopUpResponse createCustomerTopUp( + final String idOrAlias, + final String idempotencyKey, + final CreateTopUpRequest createTopUpRequest, + final RequestOptions requestOptions) { + return exchangeCreateCustomerTopUp( + idOrAlias, idempotencyKey, createTopUpRequest, requestOptions) + .send(); + } + + MeteroidHttpClient.Exchange exchangeCreateCustomerTopUp( + final String idOrAlias, + final String idempotencyKey, + final CreateTopUpRequest createTopUpRequest, + final RequestOptions requestOptions) { + Objects.requireNonNull(idOrAlias, "id_or_alias"); + Objects.requireNonNull(idempotencyKey, "Idempotency-Key"); + Objects.requireNonNull(createTopUpRequest, "body"); + HttpUrl url = + client.newUrlBuilder() + .addPathSegments("api/v1/customers") + .addPathSegment(Utils.pathSegment("id_or_alias", idOrAlias)) + .addPathSegments("top-ups") + .build(); + Headers.Builder headers = new Headers.Builder(); + headers.set("Idempotency-Key", Utils.serializeQueryParam(idempotencyKey)); + return client.call("POST", url) + .headers(headers.build()) + .json(createTopUpRequest) + .errors( + com.meteroid.models.RestErrorResponse.class, + "400", + "401", + "404", + "409", + "429", + "500") + .options(requestOptions) + .returning(TopUpResponse.class); + } + + /** The operations, returning the status and headers along with the body. */ + public final class WithRawResponse { + private WithRawResponse() {} + + /** + * The {@code grants} operations. + * + * @return the operations + */ + public CreditsGrants.WithRawResponse grants() { + return Credits.this.grants.withRawResponse(); + } + + /** + * The {@code wallets} operations. + * + * @return the operations + */ + public CreditsWallets.WithRawResponse wallets() { + return Credits.this.wallets.withRawResponse(); + } + + /** + * List credit ledger entries + * + *

Every movement of a customer's credit in one currency or credit unit, newest first, + * with the credit on account after it: credit granted, applied to invoices, given back, + * expired or rolled over. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @return the status, headers and page + */ + public ApiResponse listCustomerCreditLedger( + final String idOrAlias) { + return listCustomerCreditLedger( + idOrAlias, + CreditsListCustomerCreditLedgerOptions.none(), + RequestOptions.none()); + } + + /** + * List credit ledger entries + * + *

Every movement of a customer's credit in one currency or credit unit, newest first, + * with the credit on account after it: credit granted, applied to invoices, given back, + * expired or rolled over. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param options the optional parameters + * @return the status, headers and page + */ + public ApiResponse listCustomerCreditLedger( + final String idOrAlias, final CreditsListCustomerCreditLedgerOptions options) { + return listCustomerCreditLedger(idOrAlias, options, RequestOptions.none()); + } + + /** + * List credit ledger entries + * + *

Every movement of a customer's credit in one currency or credit unit, newest first, + * with the credit on account after it: credit granted, applied to invoices, given back, + * expired or rolled over. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and page + */ + public ApiResponse listCustomerCreditLedger( + final String idOrAlias, final RequestOptions requestOptions) { + return listCustomerCreditLedger( + idOrAlias, CreditsListCustomerCreditLedgerOptions.none(), requestOptions); + } + + /** + * List credit ledger entries + * + *

Every movement of a customer's credit in one currency or credit unit, newest first, + * with the credit on account after it: credit granted, applied to invoices, given back, + * expired or rolled over. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param options the optional parameters + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and page + */ + public ApiResponse listCustomerCreditLedger( + final String idOrAlias, + final CreditsListCustomerCreditLedgerOptions options, + final RequestOptions requestOptions) { + ApiResponse response = + exchangeListCustomerCreditLedger(idOrAlias, options, requestOptions).sendRaw(); + return new ApiResponse<>( + response.statusCode(), + response.headers(), + pageOfListCustomerCreditLedger( + response.body(), idOrAlias, options, requestOptions)); + } + + /** + * Create a top-up + * + *

Sells credit: CHARGE bills a saved payment method now, SEND_INVOICE grants it once + * paid. The credit is PAID and applies to ALL charges. Currency credit is sold one for one, + * untaxed, as its usage is taxed when invoiced. With credit_unit, sells + * credits of that unit at its selling price in the customer's currency, taxed at purchase + * under the unit's product; refused when the unit has no price in that currency or no + * product. Without a saved payment method, CHARGE returns a hosted checkout_url + * where the customer pays. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param idempotencyKey the {@code Idempotency-Key} required parameter + * @param createTopUpRequest the request body + * @return the status, headers and body + */ + public ApiResponse createCustomerTopUp( + final String idOrAlias, + final String idempotencyKey, + final CreateTopUpRequest createTopUpRequest) { + return createCustomerTopUp( + idOrAlias, idempotencyKey, createTopUpRequest, RequestOptions.none()); + } + + /** + * Create a top-up + * + *

Sells credit: CHARGE bills a saved payment method now, SEND_INVOICE grants it once + * paid. The credit is PAID and applies to ALL charges. Currency credit is sold one for one, + * untaxed, as its usage is taxed when invoiced. With credit_unit, sells + * credits of that unit at its selling price in the customer's currency, taxed at purchase + * under the unit's product; refused when the unit has no price in that currency or no + * product. Without a saved payment method, CHARGE returns a hosted checkout_url + * where the customer pays. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param idempotencyKey the {@code Idempotency-Key} required parameter + * @param createTopUpRequest the request body + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body + */ + public ApiResponse createCustomerTopUp( + final String idOrAlias, + final String idempotencyKey, + final CreateTopUpRequest createTopUpRequest, + final RequestOptions requestOptions) { + return Credits.this + .exchangeCreateCustomerTopUp( + idOrAlias, idempotencyKey, createTopUpRequest, requestOptions) + .sendRaw(); + } + } +} diff --git a/src/main/java/com/meteroid/api/CreditsAsync.java b/src/main/java/com/meteroid/api/CreditsAsync.java new file mode 100644 index 0000000..a9d921a --- /dev/null +++ b/src/main/java/com/meteroid/api/CreditsAsync.java @@ -0,0 +1,367 @@ +// this file is @generated +package com.meteroid.api; + +import com.meteroid.ApiResponse; +import com.meteroid.RequestOptions; +import com.meteroid.models.CreateTopUpRequest; +import com.meteroid.models.LedgerEntry; +import com.meteroid.models.LedgerListResponse; +import com.meteroid.models.TopUpResponse; + +import java.util.List; +import java.util.concurrent.CompletableFuture; + +/** + * The {@code credits} operations, without blocking: each method returns a {@link + * CompletableFuture}. Obtained from {@code client.async()}. + */ +public final class CreditsAsync { + private final Credits sync; + private final WithRawResponse withRawResponse; + + private final CreditsGrantsAsync grants; + + private final CreditsWalletsAsync wallets; + + /** + * The operations, sending through {@code sync}. + * + * @param sync the blocking operations + */ + public CreditsAsync(Credits sync) { + this.sync = sync; + this.withRawResponse = new WithRawResponse(); + + this.grants = new CreditsGrantsAsync(sync.grants()); + + this.wallets = new CreditsWalletsAsync(sync.wallets()); + } + + /** + * The same operations, returning the status and headers along with the body. + * + * @return the operations + */ + public WithRawResponse withRawResponse() { + return withRawResponse; + } + + /** + * The {@code grants} operations. + * + * @return the operations + */ + public CreditsGrantsAsync grants() { + return grants; + } + + /** + * The {@code wallets} operations. + * + * @return the operations + */ + public CreditsWalletsAsync wallets() { + return wallets; + } + + /** + * List credit ledger entries + * + *

Every movement of a customer's credit in one currency or credit unit, newest first, with + * the credit on account after it: credit granted, applied to invoices, given back, expired or + * rolled over. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @return the page, once received + */ + public CompletableFuture listCustomerCreditLedger( + final String idOrAlias) { + return listCustomerCreditLedger( + idOrAlias, CreditsListCustomerCreditLedgerOptions.none(), RequestOptions.none()); + } + + /** + * List credit ledger entries + * + *

Every movement of a customer's credit in one currency or credit unit, newest first, with + * the credit on account after it: credit granted, applied to invoices, given back, expired or + * rolled over. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param options the optional parameters + * @return the page, once received + */ + public CompletableFuture listCustomerCreditLedger( + final String idOrAlias, final CreditsListCustomerCreditLedgerOptions options) { + return listCustomerCreditLedger(idOrAlias, options, RequestOptions.none()); + } + + /** + * List credit ledger entries + * + *

Every movement of a customer's credit in one currency or credit unit, newest first, with + * the credit on account after it: credit granted, applied to invoices, given back, expired or + * rolled over. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param requestOptions headers, timeout and retries of this call + * @return the page, once received + */ + public CompletableFuture listCustomerCreditLedger( + final String idOrAlias, final RequestOptions requestOptions) { + return listCustomerCreditLedger( + idOrAlias, CreditsListCustomerCreditLedgerOptions.none(), requestOptions); + } + + /** + * List credit ledger entries + * + *

Every movement of a customer's credit in one currency or credit unit, newest first, with + * the credit on account after it: credit granted, applied to invoices, given back, expired or + * rolled over. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param options the optional parameters + * @param requestOptions headers, timeout and retries of this call + * @return the page, once received + */ + public CompletableFuture listCustomerCreditLedger( + final String idOrAlias, + final CreditsListCustomerCreditLedgerOptions options, + final RequestOptions requestOptions) { + return sync.exchangeListCustomerCreditLedger(idOrAlias, options, requestOptions) + .sendAsync() + .thenApply( + response -> + pageOfListCustomerCreditLedger( + response, idOrAlias, options, requestOptions)); + } + + private CreditsListCustomerCreditLedgerAsyncPage pageOfListCustomerCreditLedger( + LedgerListResponse response, + final String idOrAlias, + final CreditsListCustomerCreditLedgerOptions options, + final RequestOptions requestOptions) { + List items = Credits.itemsOfListCustomerCreditLedger(response); + Integer next = + Credits.nextOfListCustomerCreditLedger(response, items, options.page().orElse(0)); + return new CreditsListCustomerCreditLedgerAsyncPage( + response, + items, + next == null + ? null + : () -> + listCustomerCreditLedger( + idOrAlias, + options.toBuilder().page(next).build(), + requestOptions)); + } + + /** + * Create a top-up + * + *

Sells credit: CHARGE bills a saved payment method now, SEND_INVOICE grants it once paid. + * The credit is PAID and applies to ALL charges. Currency credit is sold one for one, untaxed, + * as its usage is taxed when invoiced. With credit_unit, sells credits of that + * unit at its selling price in the customer's currency, taxed at purchase under the unit's + * product; refused when the unit has no price in that currency or no product. Without a saved + * payment method, CHARGE returns a hosted checkout_url where the customer pays. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param idempotencyKey the {@code Idempotency-Key} required parameter + * @param createTopUpRequest the request body + * @return the response body, once received + */ + public CompletableFuture createCustomerTopUp( + final String idOrAlias, + final String idempotencyKey, + final CreateTopUpRequest createTopUpRequest) { + return createCustomerTopUp( + idOrAlias, idempotencyKey, createTopUpRequest, RequestOptions.none()); + } + + /** + * Create a top-up + * + *

Sells credit: CHARGE bills a saved payment method now, SEND_INVOICE grants it once paid. + * The credit is PAID and applies to ALL charges. Currency credit is sold one for one, untaxed, + * as its usage is taxed when invoiced. With credit_unit, sells credits of that + * unit at its selling price in the customer's currency, taxed at purchase under the unit's + * product; refused when the unit has no price in that currency or no product. Without a saved + * payment method, CHARGE returns a hosted checkout_url where the customer pays. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param idempotencyKey the {@code Idempotency-Key} required parameter + * @param createTopUpRequest the request body + * @param requestOptions headers, timeout and retries of this call + * @return the response body, once received + */ + public CompletableFuture createCustomerTopUp( + final String idOrAlias, + final String idempotencyKey, + final CreateTopUpRequest createTopUpRequest, + final RequestOptions requestOptions) { + return sync.exchangeCreateCustomerTopUp( + idOrAlias, idempotencyKey, createTopUpRequest, requestOptions) + .sendAsync(); + } + + /** The operations, returning the status and headers along with the body. */ + public final class WithRawResponse { + private WithRawResponse() {} + + /** + * The {@code grants} operations. + * + * @return the operations + */ + public CreditsGrantsAsync.WithRawResponse grants() { + return CreditsAsync.this.grants.withRawResponse(); + } + + /** + * The {@code wallets} operations. + * + * @return the operations + */ + public CreditsWalletsAsync.WithRawResponse wallets() { + return CreditsAsync.this.wallets.withRawResponse(); + } + + /** + * List credit ledger entries + * + *

Every movement of a customer's credit in one currency or credit unit, newest first, + * with the credit on account after it: credit granted, applied to invoices, given back, + * expired or rolled over. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @return the status, headers and page, once received + */ + public CompletableFuture> + listCustomerCreditLedger(final String idOrAlias) { + return listCustomerCreditLedger( + idOrAlias, + CreditsListCustomerCreditLedgerOptions.none(), + RequestOptions.none()); + } + + /** + * List credit ledger entries + * + *

Every movement of a customer's credit in one currency or credit unit, newest first, + * with the credit on account after it: credit granted, applied to invoices, given back, + * expired or rolled over. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param options the optional parameters + * @return the status, headers and page, once received + */ + public CompletableFuture> + listCustomerCreditLedger( + final String idOrAlias, + final CreditsListCustomerCreditLedgerOptions options) { + return listCustomerCreditLedger(idOrAlias, options, RequestOptions.none()); + } + + /** + * List credit ledger entries + * + *

Every movement of a customer's credit in one currency or credit unit, newest first, + * with the credit on account after it: credit granted, applied to invoices, given back, + * expired or rolled over. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and page, once received + */ + public CompletableFuture> + listCustomerCreditLedger( + final String idOrAlias, final RequestOptions requestOptions) { + return listCustomerCreditLedger( + idOrAlias, CreditsListCustomerCreditLedgerOptions.none(), requestOptions); + } + + /** + * List credit ledger entries + * + *

Every movement of a customer's credit in one currency or credit unit, newest first, + * with the credit on account after it: credit granted, applied to invoices, given back, + * expired or rolled over. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param options the optional parameters + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and page, once received + */ + public CompletableFuture> + listCustomerCreditLedger( + final String idOrAlias, + final CreditsListCustomerCreditLedgerOptions options, + final RequestOptions requestOptions) { + return sync.exchangeListCustomerCreditLedger(idOrAlias, options, requestOptions) + .sendRawAsync() + .thenApply( + response -> + new ApiResponse<>( + response.statusCode(), + response.headers(), + pageOfListCustomerCreditLedger( + response.body(), + idOrAlias, + options, + requestOptions))); + } + + /** + * Create a top-up + * + *

Sells credit: CHARGE bills a saved payment method now, SEND_INVOICE grants it once + * paid. The credit is PAID and applies to ALL charges. Currency credit is sold one for one, + * untaxed, as its usage is taxed when invoiced. With credit_unit, sells + * credits of that unit at its selling price in the customer's currency, taxed at purchase + * under the unit's product; refused when the unit has no price in that currency or no + * product. Without a saved payment method, CHARGE returns a hosted checkout_url + * where the customer pays. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param idempotencyKey the {@code Idempotency-Key} required parameter + * @param createTopUpRequest the request body + * @return the status, headers and body, once received + */ + public CompletableFuture> createCustomerTopUp( + final String idOrAlias, + final String idempotencyKey, + final CreateTopUpRequest createTopUpRequest) { + return createCustomerTopUp( + idOrAlias, idempotencyKey, createTopUpRequest, RequestOptions.none()); + } + + /** + * Create a top-up + * + *

Sells credit: CHARGE bills a saved payment method now, SEND_INVOICE grants it once + * paid. The credit is PAID and applies to ALL charges. Currency credit is sold one for one, + * untaxed, as its usage is taxed when invoiced. With credit_unit, sells + * credits of that unit at its selling price in the customer's currency, taxed at purchase + * under the unit's product; refused when the unit has no price in that currency or no + * product. Without a saved payment method, CHARGE returns a hosted checkout_url + * where the customer pays. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param idempotencyKey the {@code Idempotency-Key} required parameter + * @param createTopUpRequest the request body + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body, once received + */ + public CompletableFuture> createCustomerTopUp( + final String idOrAlias, + final String idempotencyKey, + final CreateTopUpRequest createTopUpRequest, + final RequestOptions requestOptions) { + return sync.exchangeCreateCustomerTopUp( + idOrAlias, idempotencyKey, createTopUpRequest, requestOptions) + .sendRawAsync(); + } + } +} diff --git a/src/main/java/com/meteroid/api/CreditsGrants.java b/src/main/java/com/meteroid/api/CreditsGrants.java new file mode 100644 index 0000000..e78d488 --- /dev/null +++ b/src/main/java/com/meteroid/api/CreditsGrants.java @@ -0,0 +1,406 @@ +// this file is @generated +package com.meteroid.api; + +import com.meteroid.ApiResponse; +import com.meteroid.RequestOptions; +import com.meteroid.internal.MeteroidHttpClient; +import com.meteroid.internal.Utils; +import com.meteroid.models.CreateCreditGrantRequest; +import com.meteroid.models.CreditGrant; +import com.meteroid.models.CreditGrantListResponse; +import com.meteroid.models.CreditGrantStatus; +import com.meteroid.models.Currency; + +import okhttp3.Headers; +import okhttp3.HttpUrl; + +import java.util.List; +import java.util.Objects; + +/** + * The {@code credits.grants} operations, blocking. {@link #withRawResponse()} has the same methods + * returning the status and headers along with the body. + */ +public final class CreditsGrants { + private final MeteroidHttpClient client; + private final WithRawResponse withRawResponse; + + /** + * The operations, sending through {@code client}. + * + * @param client the HTTP client of the SDK + */ + public CreditsGrants(MeteroidHttpClient client) { + this.client = client; + this.withRawResponse = new WithRawResponse(); + } + + /** + * The same operations, returning the status and headers along with the body. + * + * @return the operations + */ + public WithRawResponse withRawResponse() { + return withRawResponse; + } + + /** + * List credit grants + * + *

A customer's credit grants, newest first, in every currency and credit unit unless + * filtered. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @return the page: the response body, its items and the way to the next pages + */ + public CreditsGrantsListPage list(final String idOrAlias) { + return list(idOrAlias, CreditsGrantsListOptions.none(), RequestOptions.none()); + } + + /** + * List credit grants + * + *

A customer's credit grants, newest first, in every currency and credit unit unless + * filtered. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param options the optional parameters + * @return the page: the response body, its items and the way to the next pages + */ + public CreditsGrantsListPage list( + final String idOrAlias, final CreditsGrantsListOptions options) { + return list(idOrAlias, options, RequestOptions.none()); + } + + /** + * List credit grants + * + *

A customer's credit grants, newest first, in every currency and credit unit unless + * filtered. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param requestOptions headers, timeout and retries of this call + * @return the page: the response body, its items and the way to the next pages + */ + public CreditsGrantsListPage list(final String idOrAlias, final RequestOptions requestOptions) { + return list(idOrAlias, CreditsGrantsListOptions.none(), requestOptions); + } + + /** + * List credit grants + * + *

A customer's credit grants, newest first, in every currency and credit unit unless + * filtered. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param options the optional parameters + * @param requestOptions headers, timeout and retries of this call + * @return the page: the response body, its items and the way to the next pages + */ + public CreditsGrantsListPage list( + final String idOrAlias, + final CreditsGrantsListOptions options, + final RequestOptions requestOptions) { + return pageOfList( + exchangeList(idOrAlias, options, requestOptions).send(), + idOrAlias, + options, + requestOptions); + } + + MeteroidHttpClient.Exchange exchangeList( + final String idOrAlias, + final CreditsGrantsListOptions options, + final RequestOptions requestOptions) { + Objects.requireNonNull(idOrAlias, "id_or_alias"); + Objects.requireNonNull(options, "options"); + HttpUrl.Builder url = + client.newUrlBuilder() + .addPathSegments("api/v1/customers") + .addPathSegment(Utils.pathSegment("id_or_alias", idOrAlias)) + .addPathSegments("credit-grants"); + Currency value1 = options.currency().orElse(null); + if (value1 != null) { + url.addQueryParameter("currency", Utils.serializeQueryParam(value1)); + } + String value2 = options.creditUnit().orElse(null); + if (value2 != null) { + url.addQueryParameter("credit_unit", value2); + } + CreditGrantStatus value3 = options.status().orElse(null); + if (value3 != null) { + url.addQueryParameter("status", Utils.serializeQueryParam(value3)); + } + String value4 = options.subscriptionId().orElse(null); + if (value4 != null) { + url.addQueryParameter("subscription_id", value4); + } + String value5 = options.usableBySubscriptionId().orElse(null); + if (value5 != null) { + url.addQueryParameter("usable_by_subscription_id", value5); + } + Integer value6 = options.page().orElse(null); + if (value6 != null) { + url.addQueryParameter("page", Utils.serializeQueryParam(value6)); + } + Integer value7 = options.perPage().orElse(null); + if (value7 != null) { + url.addQueryParameter("per_page", Utils.serializeQueryParam(value7)); + } + return client.call("GET", url.build()) + .errors( + com.meteroid.models.RestErrorResponse.class, + "400", + "401", + "404", + "429", + "500") + .options(requestOptions) + .returning(CreditGrantListResponse.class); + } + + private CreditsGrantsListPage pageOfList( + CreditGrantListResponse response, + final String idOrAlias, + final CreditsGrantsListOptions options, + final RequestOptions requestOptions) { + List items = itemsOfList(response); + Integer next = nextOfList(response, items, options.page().orElse(0)); + return new CreditsGrantsListPage( + response, + items, + next == null + ? null + : () -> + list( + idOrAlias, + options.toBuilder().page(next).build(), + requestOptions)); + } + + static List itemsOfList(CreditGrantListResponse response) { + return Utils.optional(response.data()).orElse(List.of()); + } + + /** The parameter of the page after {@code response}, null after the last one. */ + static Integer nextOfList( + CreditGrantListResponse response, List items, Integer current) { + if (items.isEmpty()) { + return null; + } + long pages = + Utils.optional(response.paginationMeta()) + .flatMap(v2 -> Utils.optional(v2.totalPages())) + .map(Number::longValue) + .orElse(Long.MAX_VALUE); + if (current - 0 + 1 >= pages) { + return null; + } + return current + 1; + } + + /** + * Create a credit grant + * + *

Grants credit without charging or invoicing: PROMOTIONAL credit for free, or PAID credit + * the customer paid for outside Meteroid ("Paid outside Meteroid"). A PAID currency grant whose + * cost is below its amount is split into a PAID grant for the cost + * and a PROMOTIONAL bonus grant for the rest, returned as bonus_grant_id; a + * cost above the amount is refused. For a customer of a French invoicing + * entity, PAID credit that cost more than zero needs a reference to the invoice or + * receipt of its payment. Sell credit through Meteroid with a top-up. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param idempotencyKey the {@code Idempotency-Key} required parameter + * @param createCreditGrantRequest the request body + * @return the response body + */ + public CreditGrant create( + final String idOrAlias, + final String idempotencyKey, + final CreateCreditGrantRequest createCreditGrantRequest) { + return create(idOrAlias, idempotencyKey, createCreditGrantRequest, RequestOptions.none()); + } + + /** + * Create a credit grant + * + *

Grants credit without charging or invoicing: PROMOTIONAL credit for free, or PAID credit + * the customer paid for outside Meteroid ("Paid outside Meteroid"). A PAID currency grant whose + * cost is below its amount is split into a PAID grant for the cost + * and a PROMOTIONAL bonus grant for the rest, returned as bonus_grant_id; a + * cost above the amount is refused. For a customer of a French invoicing + * entity, PAID credit that cost more than zero needs a reference to the invoice or + * receipt of its payment. Sell credit through Meteroid with a top-up. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param idempotencyKey the {@code Idempotency-Key} required parameter + * @param createCreditGrantRequest the request body + * @param requestOptions headers, timeout and retries of this call + * @return the response body + */ + public CreditGrant create( + final String idOrAlias, + final String idempotencyKey, + final CreateCreditGrantRequest createCreditGrantRequest, + final RequestOptions requestOptions) { + return exchangeCreate(idOrAlias, idempotencyKey, createCreditGrantRequest, requestOptions) + .send(); + } + + MeteroidHttpClient.Exchange exchangeCreate( + final String idOrAlias, + final String idempotencyKey, + final CreateCreditGrantRequest createCreditGrantRequest, + final RequestOptions requestOptions) { + Objects.requireNonNull(idOrAlias, "id_or_alias"); + Objects.requireNonNull(idempotencyKey, "Idempotency-Key"); + Objects.requireNonNull(createCreditGrantRequest, "body"); + HttpUrl url = + client.newUrlBuilder() + .addPathSegments("api/v1/customers") + .addPathSegment(Utils.pathSegment("id_or_alias", idOrAlias)) + .addPathSegments("credit-grants") + .build(); + Headers.Builder headers = new Headers.Builder(); + headers.set("Idempotency-Key", Utils.serializeQueryParam(idempotencyKey)); + return client.call("POST", url) + .headers(headers.build()) + .json(createCreditGrantRequest) + .errors( + com.meteroid.models.RestErrorResponse.class, + "400", + "401", + "404", + "409", + "429", + "500") + .options(requestOptions) + .returning(CreditGrant.class); + } + + /** The operations, returning the status and headers along with the body. */ + public final class WithRawResponse { + private WithRawResponse() {} + + /** + * List credit grants + * + *

A customer's credit grants, newest first, in every currency and credit unit unless + * filtered. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @return the status, headers and page + */ + public ApiResponse list(final String idOrAlias) { + return list(idOrAlias, CreditsGrantsListOptions.none(), RequestOptions.none()); + } + + /** + * List credit grants + * + *

A customer's credit grants, newest first, in every currency and credit unit unless + * filtered. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param options the optional parameters + * @return the status, headers and page + */ + public ApiResponse list( + final String idOrAlias, final CreditsGrantsListOptions options) { + return list(idOrAlias, options, RequestOptions.none()); + } + + /** + * List credit grants + * + *

A customer's credit grants, newest first, in every currency and credit unit unless + * filtered. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and page + */ + public ApiResponse list( + final String idOrAlias, final RequestOptions requestOptions) { + return list(idOrAlias, CreditsGrantsListOptions.none(), requestOptions); + } + + /** + * List credit grants + * + *

A customer's credit grants, newest first, in every currency and credit unit unless + * filtered. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param options the optional parameters + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and page + */ + public ApiResponse list( + final String idOrAlias, + final CreditsGrantsListOptions options, + final RequestOptions requestOptions) { + ApiResponse response = + exchangeList(idOrAlias, options, requestOptions).sendRaw(); + return new ApiResponse<>( + response.statusCode(), + response.headers(), + pageOfList(response.body(), idOrAlias, options, requestOptions)); + } + + /** + * Create a credit grant + * + *

Grants credit without charging or invoicing: PROMOTIONAL credit for free, or PAID + * credit the customer paid for outside Meteroid ("Paid outside Meteroid"). A PAID currency + * grant whose cost is below its amount is split into a PAID grant + * for the cost and a PROMOTIONAL bonus grant for the rest, returned as bonus_grant_id + * ; a cost above the amount is refused. For a customer of + * a French invoicing entity, PAID credit that cost more than zero needs a reference + * to the invoice or receipt of its payment. Sell credit through Meteroid with a + * top-up. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param idempotencyKey the {@code Idempotency-Key} required parameter + * @param createCreditGrantRequest the request body + * @return the status, headers and body + */ + public ApiResponse create( + final String idOrAlias, + final String idempotencyKey, + final CreateCreditGrantRequest createCreditGrantRequest) { + return create( + idOrAlias, idempotencyKey, createCreditGrantRequest, RequestOptions.none()); + } + + /** + * Create a credit grant + * + *

Grants credit without charging or invoicing: PROMOTIONAL credit for free, or PAID + * credit the customer paid for outside Meteroid ("Paid outside Meteroid"). A PAID currency + * grant whose cost is below its amount is split into a PAID grant + * for the cost and a PROMOTIONAL bonus grant for the rest, returned as bonus_grant_id + * ; a cost above the amount is refused. For a customer of + * a French invoicing entity, PAID credit that cost more than zero needs a reference + * to the invoice or receipt of its payment. Sell credit through Meteroid with a + * top-up. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param idempotencyKey the {@code Idempotency-Key} required parameter + * @param createCreditGrantRequest the request body + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body + */ + public ApiResponse create( + final String idOrAlias, + final String idempotencyKey, + final CreateCreditGrantRequest createCreditGrantRequest, + final RequestOptions requestOptions) { + return CreditsGrants.this + .exchangeCreate( + idOrAlias, idempotencyKey, createCreditGrantRequest, requestOptions) + .sendRaw(); + } + } +} diff --git a/src/main/java/com/meteroid/api/CreditsGrantsAsync.java b/src/main/java/com/meteroid/api/CreditsGrantsAsync.java new file mode 100644 index 0000000..5724302 --- /dev/null +++ b/src/main/java/com/meteroid/api/CreditsGrantsAsync.java @@ -0,0 +1,302 @@ +// this file is @generated +package com.meteroid.api; + +import com.meteroid.ApiResponse; +import com.meteroid.RequestOptions; +import com.meteroid.models.CreateCreditGrantRequest; +import com.meteroid.models.CreditGrant; +import com.meteroid.models.CreditGrantListResponse; + +import java.util.List; +import java.util.concurrent.CompletableFuture; + +/** + * The {@code credits.grants} operations, without blocking: each method returns a {@link + * CompletableFuture}. Obtained from {@code client.async()}. + */ +public final class CreditsGrantsAsync { + private final CreditsGrants sync; + private final WithRawResponse withRawResponse; + + /** + * The operations, sending through {@code sync}. + * + * @param sync the blocking operations + */ + public CreditsGrantsAsync(CreditsGrants sync) { + this.sync = sync; + this.withRawResponse = new WithRawResponse(); + } + + /** + * The same operations, returning the status and headers along with the body. + * + * @return the operations + */ + public WithRawResponse withRawResponse() { + return withRawResponse; + } + + /** + * List credit grants + * + *

A customer's credit grants, newest first, in every currency and credit unit unless + * filtered. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @return the page, once received + */ + public CompletableFuture list(final String idOrAlias) { + return list(idOrAlias, CreditsGrantsListOptions.none(), RequestOptions.none()); + } + + /** + * List credit grants + * + *

A customer's credit grants, newest first, in every currency and credit unit unless + * filtered. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param options the optional parameters + * @return the page, once received + */ + public CompletableFuture list( + final String idOrAlias, final CreditsGrantsListOptions options) { + return list(idOrAlias, options, RequestOptions.none()); + } + + /** + * List credit grants + * + *

A customer's credit grants, newest first, in every currency and credit unit unless + * filtered. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param requestOptions headers, timeout and retries of this call + * @return the page, once received + */ + public CompletableFuture list( + final String idOrAlias, final RequestOptions requestOptions) { + return list(idOrAlias, CreditsGrantsListOptions.none(), requestOptions); + } + + /** + * List credit grants + * + *

A customer's credit grants, newest first, in every currency and credit unit unless + * filtered. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param options the optional parameters + * @param requestOptions headers, timeout and retries of this call + * @return the page, once received + */ + public CompletableFuture list( + final String idOrAlias, + final CreditsGrantsListOptions options, + final RequestOptions requestOptions) { + return sync.exchangeList(idOrAlias, options, requestOptions) + .sendAsync() + .thenApply(response -> pageOfList(response, idOrAlias, options, requestOptions)); + } + + private CreditsGrantsListAsyncPage pageOfList( + CreditGrantListResponse response, + final String idOrAlias, + final CreditsGrantsListOptions options, + final RequestOptions requestOptions) { + List items = CreditsGrants.itemsOfList(response); + Integer next = CreditsGrants.nextOfList(response, items, options.page().orElse(0)); + return new CreditsGrantsListAsyncPage( + response, + items, + next == null + ? null + : () -> + list( + idOrAlias, + options.toBuilder().page(next).build(), + requestOptions)); + } + + /** + * Create a credit grant + * + *

Grants credit without charging or invoicing: PROMOTIONAL credit for free, or PAID credit + * the customer paid for outside Meteroid ("Paid outside Meteroid"). A PAID currency grant whose + * cost is below its amount is split into a PAID grant for the cost + * and a PROMOTIONAL bonus grant for the rest, returned as bonus_grant_id; a + * cost above the amount is refused. For a customer of a French invoicing + * entity, PAID credit that cost more than zero needs a reference to the invoice or + * receipt of its payment. Sell credit through Meteroid with a top-up. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param idempotencyKey the {@code Idempotency-Key} required parameter + * @param createCreditGrantRequest the request body + * @return the response body, once received + */ + public CompletableFuture create( + final String idOrAlias, + final String idempotencyKey, + final CreateCreditGrantRequest createCreditGrantRequest) { + return create(idOrAlias, idempotencyKey, createCreditGrantRequest, RequestOptions.none()); + } + + /** + * Create a credit grant + * + *

Grants credit without charging or invoicing: PROMOTIONAL credit for free, or PAID credit + * the customer paid for outside Meteroid ("Paid outside Meteroid"). A PAID currency grant whose + * cost is below its amount is split into a PAID grant for the cost + * and a PROMOTIONAL bonus grant for the rest, returned as bonus_grant_id; a + * cost above the amount is refused. For a customer of a French invoicing + * entity, PAID credit that cost more than zero needs a reference to the invoice or + * receipt of its payment. Sell credit through Meteroid with a top-up. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param idempotencyKey the {@code Idempotency-Key} required parameter + * @param createCreditGrantRequest the request body + * @param requestOptions headers, timeout and retries of this call + * @return the response body, once received + */ + public CompletableFuture create( + final String idOrAlias, + final String idempotencyKey, + final CreateCreditGrantRequest createCreditGrantRequest, + final RequestOptions requestOptions) { + return sync.exchangeCreate( + idOrAlias, idempotencyKey, createCreditGrantRequest, requestOptions) + .sendAsync(); + } + + /** The operations, returning the status and headers along with the body. */ + public final class WithRawResponse { + private WithRawResponse() {} + + /** + * List credit grants + * + *

A customer's credit grants, newest first, in every currency and credit unit unless + * filtered. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @return the status, headers and page, once received + */ + public CompletableFuture> list( + final String idOrAlias) { + return list(idOrAlias, CreditsGrantsListOptions.none(), RequestOptions.none()); + } + + /** + * List credit grants + * + *

A customer's credit grants, newest first, in every currency and credit unit unless + * filtered. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param options the optional parameters + * @return the status, headers and page, once received + */ + public CompletableFuture> list( + final String idOrAlias, final CreditsGrantsListOptions options) { + return list(idOrAlias, options, RequestOptions.none()); + } + + /** + * List credit grants + * + *

A customer's credit grants, newest first, in every currency and credit unit unless + * filtered. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and page, once received + */ + public CompletableFuture> list( + final String idOrAlias, final RequestOptions requestOptions) { + return list(idOrAlias, CreditsGrantsListOptions.none(), requestOptions); + } + + /** + * List credit grants + * + *

A customer's credit grants, newest first, in every currency and credit unit unless + * filtered. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param options the optional parameters + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and page, once received + */ + public CompletableFuture> list( + final String idOrAlias, + final CreditsGrantsListOptions options, + final RequestOptions requestOptions) { + return sync.exchangeList(idOrAlias, options, requestOptions) + .sendRawAsync() + .thenApply( + response -> + new ApiResponse<>( + response.statusCode(), + response.headers(), + pageOfList( + response.body(), + idOrAlias, + options, + requestOptions))); + } + + /** + * Create a credit grant + * + *

Grants credit without charging or invoicing: PROMOTIONAL credit for free, or PAID + * credit the customer paid for outside Meteroid ("Paid outside Meteroid"). A PAID currency + * grant whose cost is below its amount is split into a PAID grant + * for the cost and a PROMOTIONAL bonus grant for the rest, returned as bonus_grant_id + * ; a cost above the amount is refused. For a customer of + * a French invoicing entity, PAID credit that cost more than zero needs a reference + * to the invoice or receipt of its payment. Sell credit through Meteroid with a + * top-up. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param idempotencyKey the {@code Idempotency-Key} required parameter + * @param createCreditGrantRequest the request body + * @return the status, headers and body, once received + */ + public CompletableFuture> create( + final String idOrAlias, + final String idempotencyKey, + final CreateCreditGrantRequest createCreditGrantRequest) { + return create( + idOrAlias, idempotencyKey, createCreditGrantRequest, RequestOptions.none()); + } + + /** + * Create a credit grant + * + *

Grants credit without charging or invoicing: PROMOTIONAL credit for free, or PAID + * credit the customer paid for outside Meteroid ("Paid outside Meteroid"). A PAID currency + * grant whose cost is below its amount is split into a PAID grant + * for the cost and a PROMOTIONAL bonus grant for the rest, returned as bonus_grant_id + * ; a cost above the amount is refused. For a customer of + * a French invoicing entity, PAID credit that cost more than zero needs a reference + * to the invoice or receipt of its payment. Sell credit through Meteroid with a + * top-up. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param idempotencyKey the {@code Idempotency-Key} required parameter + * @param createCreditGrantRequest the request body + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body, once received + */ + public CompletableFuture> create( + final String idOrAlias, + final String idempotencyKey, + final CreateCreditGrantRequest createCreditGrantRequest, + final RequestOptions requestOptions) { + return sync.exchangeCreate( + idOrAlias, idempotencyKey, createCreditGrantRequest, requestOptions) + .sendRawAsync(); + } + } +} diff --git a/src/main/java/com/meteroid/api/CreditsGrantsListAsyncPage.java b/src/main/java/com/meteroid/api/CreditsGrantsListAsyncPage.java new file mode 100644 index 0000000..0abb6e5 --- /dev/null +++ b/src/main/java/com/meteroid/api/CreditsGrantsListAsyncPage.java @@ -0,0 +1,67 @@ +// this file is @generated +package com.meteroid.api; + +import com.meteroid.AsyncPage; +import com.meteroid.models.CreditGrant; +import com.meteroid.models.CreditGrantListResponse; +import com.meteroid.models.PaginationResponse; + +import java.util.List; +import java.util.concurrent.CompletableFuture; +import java.util.function.Supplier; + +/** + * A page of {@link CreditsGrantsAsync#list}: the {@link CreditGrant} items of one response, and the + * properties of its body, {@link CreditGrantListResponse}. + */ +public final class CreditsGrantsListAsyncPage + extends AsyncPage { + private final CreditGrantListResponse body; + + /** + * A page, built by the SDK. + * + * @param body the response body + * @param items the items of the page + * @param next fetches the next page, or null on the last page + */ + public CreditsGrantsListAsyncPage( + CreditGrantListResponse body, + List items, + Supplier> next) { + super(items, next); + this.body = body; + } + + /** + * The response body, as received. + * + * @return the body + */ + public CreditGrantListResponse body() { + return body; + } + + /** + * The {@code data} property. + * + * @return the value, never null + */ + public List data() { + return body.data(); + } + + /** + * The {@code pagination_meta} property. + * + * @return the value, never null + */ + public PaginationResponse paginationMeta() { + return body.paginationMeta(); + } + + @Override + public String toString() { + return "CreditsGrantsListAsyncPage{body=" + body + ", hasNextPage=" + hasNextPage() + "}"; + } +} diff --git a/src/main/java/com/meteroid/api/CreditsGrantsListOptions.java b/src/main/java/com/meteroid/api/CreditsGrantsListOptions.java new file mode 100644 index 0000000..7703780 --- /dev/null +++ b/src/main/java/com/meteroid/api/CreditsGrantsListOptions.java @@ -0,0 +1,280 @@ +// this file is @generated +package com.meteroid.api; + +import com.meteroid.models.CreditGrantStatus; +import com.meteroid.models.Currency; + +import java.util.Objects; +import java.util.Optional; + +/** Optional parameters of {@code list}, immutable: build them with {@link #builder()}. */ +public final class CreditsGrantsListOptions { + private final Currency currency; + private final String creditUnit; + private final CreditGrantStatus status; + private final String subscriptionId; + private final String usableBySubscriptionId; + private final Integer page; + private final Integer perPage; + + private CreditsGrantsListOptions(Builder builder) { + this.currency = builder.currency; + this.creditUnit = builder.creditUnit; + this.status = builder.status; + this.subscriptionId = builder.subscriptionId; + this.usableBySubscriptionId = builder.usableBySubscriptionId; + this.page = builder.page; + this.perPage = builder.perPage; + } + + /** + * A builder of parameters. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * No parameters. + * + * @return empty parameters + */ + public static CreditsGrantsListOptions none() { + return builder().build(); + } + + /** + * A builder starting from these parameters. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.currency = currency; + builder.creditUnit = creditUnit; + builder.status = status; + builder.subscriptionId = subscriptionId; + builder.usableBySubscriptionId = usableBySubscriptionId; + builder.page = page; + builder.perPage = perPage; + return builder; + } + + /** + * Only grants in this currency. + * + * @return the value, empty when unset + */ + public Optional currency() { + return Optional.ofNullable(currency); + } + + /** + * Only grants in this credit unit (its code); excludes currency. + * + * @return the value, empty when unset + */ + public Optional creditUnit() { + return Optional.ofNullable(creditUnit); + } + + /** + * The {@code status} parameter. + * + * @return the value, empty when unset + */ + public Optional status() { + return Optional.ofNullable(status); + } + + /** + * Only the grants that belong to this subscription (sub_…); excludes + * usable_by_subscription_id. + * + * @return the value, empty when unset + */ + public Optional subscriptionId() { + return Optional.ofNullable(subscriptionId); + } + + /** + * Only the credit this subscription (sub_…) can use: its own grants and the + * customer's grants that belong to no subscription. Excludes subscription_id. + * + * @return the value, empty when unset + */ + public Optional usableBySubscriptionId() { + return Optional.ofNullable(usableBySubscriptionId); + } + + /** + * Page number (0-indexed) + * + * @return the value, empty when unset + */ + public Optional page() { + return Optional.ofNullable(page); + } + + /** + * Number of items per page + * + * @return the value, empty when unset + */ + public Optional perPage() { + return Optional.ofNullable(perPage); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CreditsGrantsListOptions that = (CreditsGrantsListOptions) o; + return Objects.equals(currency, that.currency) + && Objects.equals(creditUnit, that.creditUnit) + && Objects.equals(status, that.status) + && Objects.equals(subscriptionId, that.subscriptionId) + && Objects.equals(usableBySubscriptionId, that.usableBySubscriptionId) + && Objects.equals(page, that.page) + && Objects.equals(perPage, that.perPage); + } + + @Override + public int hashCode() { + return Objects.hash( + currency, + creditUnit, + status, + subscriptionId, + usableBySubscriptionId, + page, + perPage); + } + + @Override + public String toString() { + return "CreditsGrantsListOptions{" + + "currency=" + + currency + + ", creditUnit=" + + creditUnit + + ", status=" + + status + + ", subscriptionId=" + + subscriptionId + + ", usableBySubscriptionId=" + + usableBySubscriptionId + + ", page=" + + page + + ", perPage=" + + perPage + + "}"; + } + + /** Builds {@link CreditsGrantsListOptions}. */ + public static final class Builder { + private Currency currency; + private String creditUnit; + private CreditGrantStatus status; + private String subscriptionId; + private String usableBySubscriptionId; + private Integer page; + private Integer perPage; + + private Builder() {} + + /** + * Only grants in this currency. + * + * @param currency the value, null to leave it out + * @return this builder + */ + public Builder currency(Currency currency) { + this.currency = currency; + return this; + } + + /** + * Only grants in this credit unit (its code); excludes currency. + * + * @param creditUnit the value, null to leave it out + * @return this builder + */ + public Builder creditUnit(String creditUnit) { + this.creditUnit = creditUnit; + return this; + } + + /** + * The {@code status} parameter. + * + * @param status the value, null to leave it out + * @return this builder + */ + public Builder status(CreditGrantStatus status) { + this.status = status; + return this; + } + + /** + * Only the grants that belong to this subscription (sub_…); excludes + * usable_by_subscription_id. + * + * @param subscriptionId the value, null to leave it out + * @return this builder + */ + public Builder subscriptionId(String subscriptionId) { + this.subscriptionId = subscriptionId; + return this; + } + + /** + * Only the credit this subscription (sub_…) can use: its own grants and the + * customer's grants that belong to no subscription. Excludes subscription_id. + * + * @param usableBySubscriptionId the value, null to leave it out + * @return this builder + */ + public Builder usableBySubscriptionId(String usableBySubscriptionId) { + this.usableBySubscriptionId = usableBySubscriptionId; + return this; + } + + /** + * Page number (0-indexed) + * + * @param page the value, null to leave it out + * @return this builder + */ + public Builder page(Integer page) { + this.page = page; + return this; + } + + /** + * Number of items per page + * + * @param perPage the value, null to leave it out + * @return this builder + */ + public Builder perPage(Integer perPage) { + this.perPage = perPage; + return this; + } + + /** + * The parameters. + * + * @return immutable parameters + */ + public CreditsGrantsListOptions build() { + return new CreditsGrantsListOptions(this); + } + } +} diff --git a/src/main/java/com/meteroid/api/CreditsGrantsListPage.java b/src/main/java/com/meteroid/api/CreditsGrantsListPage.java new file mode 100644 index 0000000..2ece475 --- /dev/null +++ b/src/main/java/com/meteroid/api/CreditsGrantsListPage.java @@ -0,0 +1,68 @@ +// this file is @generated +package com.meteroid.api; + +import com.meteroid.Page; +import com.meteroid.models.CreditGrant; +import com.meteroid.models.CreditGrantListResponse; +import com.meteroid.models.PaginationResponse; + +import java.util.List; +import java.util.function.Supplier; + +/** + * A page of {@link CreditsGrants#list}: the {@link CreditGrant} items of one response, and the + * properties of its body, {@link CreditGrantListResponse}. + * + *

Iterating it yields every item from this page on, fetching the next pages as the iteration + * goes. + */ +public final class CreditsGrantsListPage extends Page { + private final CreditGrantListResponse body; + + /** + * A page, built by the SDK. + * + * @param body the response body + * @param items the items of the page + * @param next fetches the next page, or null on the last page + */ + public CreditsGrantsListPage( + CreditGrantListResponse body, + List items, + Supplier next) { + super(items, next); + this.body = body; + } + + /** + * The response body, as received. + * + * @return the body + */ + public CreditGrantListResponse body() { + return body; + } + + /** + * The {@code data} property. + * + * @return the value, never null + */ + public List data() { + return body.data(); + } + + /** + * The {@code pagination_meta} property. + * + * @return the value, never null + */ + public PaginationResponse paginationMeta() { + return body.paginationMeta(); + } + + @Override + public String toString() { + return "CreditsGrantsListPage{body=" + body + ", hasNextPage=" + hasNextPage() + "}"; + } +} diff --git a/src/main/java/com/meteroid/api/CreditsListCustomerCreditLedgerAsyncPage.java b/src/main/java/com/meteroid/api/CreditsListCustomerCreditLedgerAsyncPage.java new file mode 100644 index 0000000..de403f2 --- /dev/null +++ b/src/main/java/com/meteroid/api/CreditsListCustomerCreditLedgerAsyncPage.java @@ -0,0 +1,71 @@ +// this file is @generated +package com.meteroid.api; + +import com.meteroid.AsyncPage; +import com.meteroid.models.LedgerEntry; +import com.meteroid.models.LedgerListResponse; +import com.meteroid.models.PaginationResponse; + +import java.util.List; +import java.util.concurrent.CompletableFuture; +import java.util.function.Supplier; + +/** + * A page of {@link CreditsAsync#listCustomerCreditLedger}: the {@link LedgerEntry} items of one + * response, and the properties of its body, {@link LedgerListResponse}. + */ +public final class CreditsListCustomerCreditLedgerAsyncPage + extends AsyncPage { + private final LedgerListResponse body; + + /** + * A page, built by the SDK. + * + * @param body the response body + * @param items the items of the page + * @param next fetches the next page, or null on the last page + */ + public CreditsListCustomerCreditLedgerAsyncPage( + LedgerListResponse body, + List items, + Supplier> next) { + super(items, next); + this.body = body; + } + + /** + * The response body, as received. + * + * @return the body + */ + public LedgerListResponse body() { + return body; + } + + /** + * The {@code data} property. + * + * @return the value, never null + */ + public List data() { + return body.data(); + } + + /** + * The {@code pagination_meta} property. + * + * @return the value, never null + */ + public PaginationResponse paginationMeta() { + return body.paginationMeta(); + } + + @Override + public String toString() { + return "CreditsListCustomerCreditLedgerAsyncPage{body=" + + body + + ", hasNextPage=" + + hasNextPage() + + "}"; + } +} diff --git a/src/main/java/com/meteroid/api/CreditsListCustomerCreditLedgerOptions.java b/src/main/java/com/meteroid/api/CreditsListCustomerCreditLedgerOptions.java new file mode 100644 index 0000000..e6fd0d5 --- /dev/null +++ b/src/main/java/com/meteroid/api/CreditsListCustomerCreditLedgerOptions.java @@ -0,0 +1,192 @@ +// this file is @generated +package com.meteroid.api; + +import com.meteroid.models.Currency; + +import java.util.Objects; +import java.util.Optional; + +/** + * Optional parameters of {@code listCustomerCreditLedger}, immutable: build them with {@link + * #builder()}. + */ +public final class CreditsListCustomerCreditLedgerOptions { + private final Currency currency; + private final String creditUnit; + private final Integer page; + private final Integer perPage; + + private CreditsListCustomerCreditLedgerOptions(Builder builder) { + this.currency = builder.currency; + this.creditUnit = builder.creditUnit; + this.page = builder.page; + this.perPage = builder.perPage; + } + + /** + * A builder of parameters. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * No parameters. + * + * @return empty parameters + */ + public static CreditsListCustomerCreditLedgerOptions none() { + return builder().build(); + } + + /** + * A builder starting from these parameters. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.currency = currency; + builder.creditUnit = creditUnit; + builder.page = page; + builder.perPage = perPage; + return builder; + } + + /** + * Defaults to the customer's currency. + * + * @return the value, empty when unset + */ + public Optional currency() { + return Optional.ofNullable(currency); + } + + /** + * The ledger of this credit unit (its code) instead of a currency; excludes currency + * . + * + * @return the value, empty when unset + */ + public Optional creditUnit() { + return Optional.ofNullable(creditUnit); + } + + /** + * Page number (0-indexed) + * + * @return the value, empty when unset + */ + public Optional page() { + return Optional.ofNullable(page); + } + + /** + * Number of items per page + * + * @return the value, empty when unset + */ + public Optional perPage() { + return Optional.ofNullable(perPage); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CreditsListCustomerCreditLedgerOptions that = (CreditsListCustomerCreditLedgerOptions) o; + return Objects.equals(currency, that.currency) + && Objects.equals(creditUnit, that.creditUnit) + && Objects.equals(page, that.page) + && Objects.equals(perPage, that.perPage); + } + + @Override + public int hashCode() { + return Objects.hash(currency, creditUnit, page, perPage); + } + + @Override + public String toString() { + return "CreditsListCustomerCreditLedgerOptions{" + + "currency=" + + currency + + ", creditUnit=" + + creditUnit + + ", page=" + + page + + ", perPage=" + + perPage + + "}"; + } + + /** Builds {@link CreditsListCustomerCreditLedgerOptions}. */ + public static final class Builder { + private Currency currency; + private String creditUnit; + private Integer page; + private Integer perPage; + + private Builder() {} + + /** + * Defaults to the customer's currency. + * + * @param currency the value, null to leave it out + * @return this builder + */ + public Builder currency(Currency currency) { + this.currency = currency; + return this; + } + + /** + * The ledger of this credit unit (its code) instead of a currency; excludes currency + * . + * + * @param creditUnit the value, null to leave it out + * @return this builder + */ + public Builder creditUnit(String creditUnit) { + this.creditUnit = creditUnit; + return this; + } + + /** + * Page number (0-indexed) + * + * @param page the value, null to leave it out + * @return this builder + */ + public Builder page(Integer page) { + this.page = page; + return this; + } + + /** + * Number of items per page + * + * @param perPage the value, null to leave it out + * @return this builder + */ + public Builder perPage(Integer perPage) { + this.perPage = perPage; + return this; + } + + /** + * The parameters. + * + * @return immutable parameters + */ + public CreditsListCustomerCreditLedgerOptions build() { + return new CreditsListCustomerCreditLedgerOptions(this); + } + } +} diff --git a/src/main/java/com/meteroid/api/CreditsListCustomerCreditLedgerPage.java b/src/main/java/com/meteroid/api/CreditsListCustomerCreditLedgerPage.java new file mode 100644 index 0000000..9455de1 --- /dev/null +++ b/src/main/java/com/meteroid/api/CreditsListCustomerCreditLedgerPage.java @@ -0,0 +1,73 @@ +// this file is @generated +package com.meteroid.api; + +import com.meteroid.Page; +import com.meteroid.models.LedgerEntry; +import com.meteroid.models.LedgerListResponse; +import com.meteroid.models.PaginationResponse; + +import java.util.List; +import java.util.function.Supplier; + +/** + * A page of {@link Credits#listCustomerCreditLedger}: the {@link LedgerEntry} items of one + * response, and the properties of its body, {@link LedgerListResponse}. + * + *

Iterating it yields every item from this page on, fetching the next pages as the iteration + * goes. + */ +public final class CreditsListCustomerCreditLedgerPage + extends Page { + private final LedgerListResponse body; + + /** + * A page, built by the SDK. + * + * @param body the response body + * @param items the items of the page + * @param next fetches the next page, or null on the last page + */ + public CreditsListCustomerCreditLedgerPage( + LedgerListResponse body, + List items, + Supplier next) { + super(items, next); + this.body = body; + } + + /** + * The response body, as received. + * + * @return the body + */ + public LedgerListResponse body() { + return body; + } + + /** + * The {@code data} property. + * + * @return the value, never null + */ + public List data() { + return body.data(); + } + + /** + * The {@code pagination_meta} property. + * + * @return the value, never null + */ + public PaginationResponse paginationMeta() { + return body.paginationMeta(); + } + + @Override + public String toString() { + return "CreditsListCustomerCreditLedgerPage{body=" + + body + + ", hasNextPage=" + + hasNextPage() + + "}"; + } +} diff --git a/src/main/java/com/meteroid/api/CreditsWallets.java b/src/main/java/com/meteroid/api/CreditsWallets.java new file mode 100644 index 0000000..88ab4a3 --- /dev/null +++ b/src/main/java/com/meteroid/api/CreditsWallets.java @@ -0,0 +1,554 @@ +// this file is @generated +package com.meteroid.api; + +import com.meteroid.ApiResponse; +import com.meteroid.RequestOptions; +import com.meteroid.internal.MeteroidHttpClient; +import com.meteroid.internal.Utils; +import com.meteroid.models.Currency; +import com.meteroid.models.PatchWalletRequest; +import com.meteroid.models.Wallet; +import com.meteroid.models.WalletCheck; +import com.meteroid.models.WalletListResponse; + +import okhttp3.Headers; +import okhttp3.HttpUrl; + +import java.util.Objects; + +/** + * The {@code credits.wallets} operations, blocking. {@link #withRawResponse()} has the same methods + * returning the status and headers along with the body. + */ +public final class CreditsWallets { + private final MeteroidHttpClient client; + private final WithRawResponse withRawResponse; + + /** + * The operations, sending through {@code client}. + * + * @param client the HTTP client of the SDK + */ + public CreditsWallets(MeteroidHttpClient client) { + this.client = client; + this.withRawResponse = new WithRawResponse(); + } + + /** + * The same operations, returning the status and headers along with the body. + * + * @return the operations + */ + public WithRawResponse withRawResponse() { + return withRawResponse; + } + + /** + * List wallets + * + *

A customer's credit per currency and credit unit: the credit on account, the usage not + * invoiced yet and the balance left after it, with the wallet's alerts and automatic top-up. + * The customer's own currency comes first, even when empty. With subscription_id, + * each wallet counts only the credit that subscription can use. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @return the response body + */ + public WalletListResponse list(final String idOrAlias) { + return list(idOrAlias, CreditsWalletsListOptions.none(), RequestOptions.none()); + } + + /** + * List wallets + * + *

A customer's credit per currency and credit unit: the credit on account, the usage not + * invoiced yet and the balance left after it, with the wallet's alerts and automatic top-up. + * The customer's own currency comes first, even when empty. With subscription_id, + * each wallet counts only the credit that subscription can use. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param options the optional parameters + * @return the response body + */ + public WalletListResponse list( + final String idOrAlias, final CreditsWalletsListOptions options) { + return list(idOrAlias, options, RequestOptions.none()); + } + + /** + * List wallets + * + *

A customer's credit per currency and credit unit: the credit on account, the usage not + * invoiced yet and the balance left after it, with the wallet's alerts and automatic top-up. + * The customer's own currency comes first, even when empty. With subscription_id, + * each wallet counts only the credit that subscription can use. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param requestOptions headers, timeout and retries of this call + * @return the response body + */ + public WalletListResponse list(final String idOrAlias, final RequestOptions requestOptions) { + return list(idOrAlias, CreditsWalletsListOptions.none(), requestOptions); + } + + /** + * List wallets + * + *

A customer's credit per currency and credit unit: the credit on account, the usage not + * invoiced yet and the balance left after it, with the wallet's alerts and automatic top-up. + * The customer's own currency comes first, even when empty. With subscription_id, + * each wallet counts only the credit that subscription can use. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param options the optional parameters + * @param requestOptions headers, timeout and retries of this call + * @return the response body + */ + public WalletListResponse list( + final String idOrAlias, + final CreditsWalletsListOptions options, + final RequestOptions requestOptions) { + return exchangeList(idOrAlias, options, requestOptions).send(); + } + + MeteroidHttpClient.Exchange exchangeList( + final String idOrAlias, + final CreditsWalletsListOptions options, + final RequestOptions requestOptions) { + Objects.requireNonNull(idOrAlias, "id_or_alias"); + Objects.requireNonNull(options, "options"); + HttpUrl.Builder url = + client.newUrlBuilder() + .addPathSegments("api/v1/customers") + .addPathSegment(Utils.pathSegment("id_or_alias", idOrAlias)) + .addPathSegments("wallets"); + String value1 = options.subscriptionId().orElse(null); + if (value1 != null) { + url.addQueryParameter("subscription_id", value1); + } + return client.call("GET", url.build()) + .errors( + com.meteroid.models.RestErrorResponse.class, + "400", + "401", + "404", + "429", + "500") + .options(requestOptions) + .returning(WalletListResponse.class); + } + + /** + * Check wallet access + * + *

Whether the customer's prepaid credit in a currency or credit unit still covers them, net + * of usage not invoiced yet. Denies only when the wallet blocks usage once its credit is used + * up; otherwise access stays allowed and exhausted signals the empty balance on + * its own. With subscription_id, only the credit that subscription can use counts: + * pass it when the customer has several subscriptions, since one subscription's credit cannot + * pay another's usage. The balance follows usage within a few seconds near zero or a threshold, + * within a minute otherwise, and the answer is cached for one second: use it to gate + * consumption, not to bill. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @return the response body + */ + public WalletCheck check(final String idOrAlias) { + return check(idOrAlias, CreditsWalletsCheckOptions.none(), RequestOptions.none()); + } + + /** + * Check wallet access + * + *

Whether the customer's prepaid credit in a currency or credit unit still covers them, net + * of usage not invoiced yet. Denies only when the wallet blocks usage once its credit is used + * up; otherwise access stays allowed and exhausted signals the empty balance on + * its own. With subscription_id, only the credit that subscription can use counts: + * pass it when the customer has several subscriptions, since one subscription's credit cannot + * pay another's usage. The balance follows usage within a few seconds near zero or a threshold, + * within a minute otherwise, and the answer is cached for one second: use it to gate + * consumption, not to bill. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param options the optional parameters + * @return the response body + */ + public WalletCheck check(final String idOrAlias, final CreditsWalletsCheckOptions options) { + return check(idOrAlias, options, RequestOptions.none()); + } + + /** + * Check wallet access + * + *

Whether the customer's prepaid credit in a currency or credit unit still covers them, net + * of usage not invoiced yet. Denies only when the wallet blocks usage once its credit is used + * up; otherwise access stays allowed and exhausted signals the empty balance on + * its own. With subscription_id, only the credit that subscription can use counts: + * pass it when the customer has several subscriptions, since one subscription's credit cannot + * pay another's usage. The balance follows usage within a few seconds near zero or a threshold, + * within a minute otherwise, and the answer is cached for one second: use it to gate + * consumption, not to bill. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param requestOptions headers, timeout and retries of this call + * @return the response body + */ + public WalletCheck check(final String idOrAlias, final RequestOptions requestOptions) { + return check(idOrAlias, CreditsWalletsCheckOptions.none(), requestOptions); + } + + /** + * Check wallet access + * + *

Whether the customer's prepaid credit in a currency or credit unit still covers them, net + * of usage not invoiced yet. Denies only when the wallet blocks usage once its credit is used + * up; otherwise access stays allowed and exhausted signals the empty balance on + * its own. With subscription_id, only the credit that subscription can use counts: + * pass it when the customer has several subscriptions, since one subscription's credit cannot + * pay another's usage. The balance follows usage within a few seconds near zero or a threshold, + * within a minute otherwise, and the answer is cached for one second: use it to gate + * consumption, not to bill. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param options the optional parameters + * @param requestOptions headers, timeout and retries of this call + * @return the response body + */ + public WalletCheck check( + final String idOrAlias, + final CreditsWalletsCheckOptions options, + final RequestOptions requestOptions) { + return exchangeCheck(idOrAlias, options, requestOptions).send(); + } + + MeteroidHttpClient.Exchange exchangeCheck( + final String idOrAlias, + final CreditsWalletsCheckOptions options, + final RequestOptions requestOptions) { + Objects.requireNonNull(idOrAlias, "id_or_alias"); + Objects.requireNonNull(options, "options"); + HttpUrl.Builder url = + client.newUrlBuilder() + .addPathSegments("api/v1/customers") + .addPathSegment(Utils.pathSegment("id_or_alias", idOrAlias)) + .addPathSegments("wallets/check"); + Currency value1 = options.currency().orElse(null); + if (value1 != null) { + url.addQueryParameter("currency", Utils.serializeQueryParam(value1)); + } + String value2 = options.creditUnit().orElse(null); + if (value2 != null) { + url.addQueryParameter("credit_unit", value2); + } + String value3 = options.productId().orElse(null); + if (value3 != null) { + url.addQueryParameter("product_id", value3); + } + String value4 = options.subscriptionId().orElse(null); + if (value4 != null) { + url.addQueryParameter("subscription_id", value4); + } + return client.call("GET", url.build()) + .errors( + com.meteroid.models.RestErrorResponse.class, + "400", + "401", + "404", + "429", + "500") + .options(requestOptions) + .returning(WalletCheck.class); + } + + /** + * Configure a wallet + * + *

Settings of a customer's wallet in one currency or credit unit: whether usage is refused + * once its credit is used up, the balances that fire wallet.balance_low, and its + * automatic top-up. Opens the wallet if it does not exist yet. Partial update: omit a field to + * leave it unchanged. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param currency the {@code currency} path parameter + * @param idempotencyKey the {@code Idempotency-Key} required parameter + * @param patchWalletRequest the request body + * @return the response body + */ + public Wallet update( + final String idOrAlias, + final String currency, + final String idempotencyKey, + final PatchWalletRequest patchWalletRequest) { + return update( + idOrAlias, currency, idempotencyKey, patchWalletRequest, RequestOptions.none()); + } + + /** + * Configure a wallet + * + *

Settings of a customer's wallet in one currency or credit unit: whether usage is refused + * once its credit is used up, the balances that fire wallet.balance_low, and its + * automatic top-up. Opens the wallet if it does not exist yet. Partial update: omit a field to + * leave it unchanged. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param currency the {@code currency} path parameter + * @param idempotencyKey the {@code Idempotency-Key} required parameter + * @param patchWalletRequest the request body + * @param requestOptions headers, timeout and retries of this call + * @return the response body + */ + public Wallet update( + final String idOrAlias, + final String currency, + final String idempotencyKey, + final PatchWalletRequest patchWalletRequest, + final RequestOptions requestOptions) { + return exchangeUpdate( + idOrAlias, currency, idempotencyKey, patchWalletRequest, requestOptions) + .send(); + } + + MeteroidHttpClient.Exchange exchangeUpdate( + final String idOrAlias, + final String currency, + final String idempotencyKey, + final PatchWalletRequest patchWalletRequest, + final RequestOptions requestOptions) { + Objects.requireNonNull(idOrAlias, "id_or_alias"); + Objects.requireNonNull(currency, "currency"); + Objects.requireNonNull(idempotencyKey, "Idempotency-Key"); + Objects.requireNonNull(patchWalletRequest, "body"); + HttpUrl url = + client.newUrlBuilder() + .addPathSegments("api/v1/customers") + .addPathSegment(Utils.pathSegment("id_or_alias", idOrAlias)) + .addPathSegments("wallets") + .addPathSegment(Utils.pathSegment("currency", currency)) + .build(); + Headers.Builder headers = new Headers.Builder(); + headers.set("Idempotency-Key", Utils.serializeQueryParam(idempotencyKey)); + return client.call("PATCH", url) + .headers(headers.build()) + .json(patchWalletRequest) + .errors( + com.meteroid.models.RestErrorResponse.class, + "400", + "401", + "404", + "409", + "429", + "500") + .options(requestOptions) + .returning(Wallet.class); + } + + /** The operations, returning the status and headers along with the body. */ + public final class WithRawResponse { + private WithRawResponse() {} + + /** + * List wallets + * + *

A customer's credit per currency and credit unit: the credit on account, the usage not + * invoiced yet and the balance left after it, with the wallet's alerts and automatic + * top-up. The customer's own currency comes first, even when empty. With + * subscription_id, each wallet counts only the credit that subscription can use. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @return the status, headers and body + */ + public ApiResponse list(final String idOrAlias) { + return list(idOrAlias, CreditsWalletsListOptions.none(), RequestOptions.none()); + } + + /** + * List wallets + * + *

A customer's credit per currency and credit unit: the credit on account, the usage not + * invoiced yet and the balance left after it, with the wallet's alerts and automatic + * top-up. The customer's own currency comes first, even when empty. With + * subscription_id, each wallet counts only the credit that subscription can use. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param options the optional parameters + * @return the status, headers and body + */ + public ApiResponse list( + final String idOrAlias, final CreditsWalletsListOptions options) { + return list(idOrAlias, options, RequestOptions.none()); + } + + /** + * List wallets + * + *

A customer's credit per currency and credit unit: the credit on account, the usage not + * invoiced yet and the balance left after it, with the wallet's alerts and automatic + * top-up. The customer's own currency comes first, even when empty. With + * subscription_id, each wallet counts only the credit that subscription can use. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body + */ + public ApiResponse list( + final String idOrAlias, final RequestOptions requestOptions) { + return list(idOrAlias, CreditsWalletsListOptions.none(), requestOptions); + } + + /** + * List wallets + * + *

A customer's credit per currency and credit unit: the credit on account, the usage not + * invoiced yet and the balance left after it, with the wallet's alerts and automatic + * top-up. The customer's own currency comes first, even when empty. With + * subscription_id, each wallet counts only the credit that subscription can use. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param options the optional parameters + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body + */ + public ApiResponse list( + final String idOrAlias, + final CreditsWalletsListOptions options, + final RequestOptions requestOptions) { + return CreditsWallets.this.exchangeList(idOrAlias, options, requestOptions).sendRaw(); + } + + /** + * Check wallet access + * + *

Whether the customer's prepaid credit in a currency or credit unit still covers them, + * net of usage not invoiced yet. Denies only when the wallet blocks usage once its credit + * is used up; otherwise access stays allowed and exhausted signals the empty + * balance on its own. With subscription_id, only the credit that subscription + * can use counts: pass it when the customer has several subscriptions, since one + * subscription's credit cannot pay another's usage. The balance follows usage within a few + * seconds near zero or a threshold, within a minute otherwise, and the answer is cached for + * one second: use it to gate consumption, not to bill. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @return the status, headers and body + */ + public ApiResponse check(final String idOrAlias) { + return check(idOrAlias, CreditsWalletsCheckOptions.none(), RequestOptions.none()); + } + + /** + * Check wallet access + * + *

Whether the customer's prepaid credit in a currency or credit unit still covers them, + * net of usage not invoiced yet. Denies only when the wallet blocks usage once its credit + * is used up; otherwise access stays allowed and exhausted signals the empty + * balance on its own. With subscription_id, only the credit that subscription + * can use counts: pass it when the customer has several subscriptions, since one + * subscription's credit cannot pay another's usage. The balance follows usage within a few + * seconds near zero or a threshold, within a minute otherwise, and the answer is cached for + * one second: use it to gate consumption, not to bill. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param options the optional parameters + * @return the status, headers and body + */ + public ApiResponse check( + final String idOrAlias, final CreditsWalletsCheckOptions options) { + return check(idOrAlias, options, RequestOptions.none()); + } + + /** + * Check wallet access + * + *

Whether the customer's prepaid credit in a currency or credit unit still covers them, + * net of usage not invoiced yet. Denies only when the wallet blocks usage once its credit + * is used up; otherwise access stays allowed and exhausted signals the empty + * balance on its own. With subscription_id, only the credit that subscription + * can use counts: pass it when the customer has several subscriptions, since one + * subscription's credit cannot pay another's usage. The balance follows usage within a few + * seconds near zero or a threshold, within a minute otherwise, and the answer is cached for + * one second: use it to gate consumption, not to bill. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body + */ + public ApiResponse check( + final String idOrAlias, final RequestOptions requestOptions) { + return check(idOrAlias, CreditsWalletsCheckOptions.none(), requestOptions); + } + + /** + * Check wallet access + * + *

Whether the customer's prepaid credit in a currency or credit unit still covers them, + * net of usage not invoiced yet. Denies only when the wallet blocks usage once its credit + * is used up; otherwise access stays allowed and exhausted signals the empty + * balance on its own. With subscription_id, only the credit that subscription + * can use counts: pass it when the customer has several subscriptions, since one + * subscription's credit cannot pay another's usage. The balance follows usage within a few + * seconds near zero or a threshold, within a minute otherwise, and the answer is cached for + * one second: use it to gate consumption, not to bill. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param options the optional parameters + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body + */ + public ApiResponse check( + final String idOrAlias, + final CreditsWalletsCheckOptions options, + final RequestOptions requestOptions) { + return CreditsWallets.this.exchangeCheck(idOrAlias, options, requestOptions).sendRaw(); + } + + /** + * Configure a wallet + * + *

Settings of a customer's wallet in one currency or credit unit: whether usage is + * refused once its credit is used up, the balances that fire wallet.balance_low + * , and its automatic top-up. Opens the wallet if it does not exist yet. Partial + * update: omit a field to leave it unchanged. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param currency the {@code currency} path parameter + * @param idempotencyKey the {@code Idempotency-Key} required parameter + * @param patchWalletRequest the request body + * @return the status, headers and body + */ + public ApiResponse update( + final String idOrAlias, + final String currency, + final String idempotencyKey, + final PatchWalletRequest patchWalletRequest) { + return update( + idOrAlias, currency, idempotencyKey, patchWalletRequest, RequestOptions.none()); + } + + /** + * Configure a wallet + * + *

Settings of a customer's wallet in one currency or credit unit: whether usage is + * refused once its credit is used up, the balances that fire wallet.balance_low + * , and its automatic top-up. Opens the wallet if it does not exist yet. Partial + * update: omit a field to leave it unchanged. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param currency the {@code currency} path parameter + * @param idempotencyKey the {@code Idempotency-Key} required parameter + * @param patchWalletRequest the request body + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body + */ + public ApiResponse update( + final String idOrAlias, + final String currency, + final String idempotencyKey, + final PatchWalletRequest patchWalletRequest, + final RequestOptions requestOptions) { + return CreditsWallets.this + .exchangeUpdate( + idOrAlias, currency, idempotencyKey, patchWalletRequest, requestOptions) + .sendRaw(); + } + } +} diff --git a/src/main/java/com/meteroid/api/CreditsWalletsAsync.java b/src/main/java/com/meteroid/api/CreditsWalletsAsync.java new file mode 100644 index 0000000..8d3a04d --- /dev/null +++ b/src/main/java/com/meteroid/api/CreditsWalletsAsync.java @@ -0,0 +1,450 @@ +// this file is @generated +package com.meteroid.api; + +import com.meteroid.ApiResponse; +import com.meteroid.RequestOptions; +import com.meteroid.models.PatchWalletRequest; +import com.meteroid.models.Wallet; +import com.meteroid.models.WalletCheck; +import com.meteroid.models.WalletListResponse; + +import java.util.concurrent.CompletableFuture; + +/** + * The {@code credits.wallets} operations, without blocking: each method returns a {@link + * CompletableFuture}. Obtained from {@code client.async()}. + */ +public final class CreditsWalletsAsync { + private final CreditsWallets sync; + private final WithRawResponse withRawResponse; + + /** + * The operations, sending through {@code sync}. + * + * @param sync the blocking operations + */ + public CreditsWalletsAsync(CreditsWallets sync) { + this.sync = sync; + this.withRawResponse = new WithRawResponse(); + } + + /** + * The same operations, returning the status and headers along with the body. + * + * @return the operations + */ + public WithRawResponse withRawResponse() { + return withRawResponse; + } + + /** + * List wallets + * + *

A customer's credit per currency and credit unit: the credit on account, the usage not + * invoiced yet and the balance left after it, with the wallet's alerts and automatic top-up. + * The customer's own currency comes first, even when empty. With subscription_id, + * each wallet counts only the credit that subscription can use. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @return the response body, once received + */ + public CompletableFuture list(final String idOrAlias) { + return list(idOrAlias, CreditsWalletsListOptions.none(), RequestOptions.none()); + } + + /** + * List wallets + * + *

A customer's credit per currency and credit unit: the credit on account, the usage not + * invoiced yet and the balance left after it, with the wallet's alerts and automatic top-up. + * The customer's own currency comes first, even when empty. With subscription_id, + * each wallet counts only the credit that subscription can use. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param options the optional parameters + * @return the response body, once received + */ + public CompletableFuture list( + final String idOrAlias, final CreditsWalletsListOptions options) { + return list(idOrAlias, options, RequestOptions.none()); + } + + /** + * List wallets + * + *

A customer's credit per currency and credit unit: the credit on account, the usage not + * invoiced yet and the balance left after it, with the wallet's alerts and automatic top-up. + * The customer's own currency comes first, even when empty. With subscription_id, + * each wallet counts only the credit that subscription can use. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param requestOptions headers, timeout and retries of this call + * @return the response body, once received + */ + public CompletableFuture list( + final String idOrAlias, final RequestOptions requestOptions) { + return list(idOrAlias, CreditsWalletsListOptions.none(), requestOptions); + } + + /** + * List wallets + * + *

A customer's credit per currency and credit unit: the credit on account, the usage not + * invoiced yet and the balance left after it, with the wallet's alerts and automatic top-up. + * The customer's own currency comes first, even when empty. With subscription_id, + * each wallet counts only the credit that subscription can use. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param options the optional parameters + * @param requestOptions headers, timeout and retries of this call + * @return the response body, once received + */ + public CompletableFuture list( + final String idOrAlias, + final CreditsWalletsListOptions options, + final RequestOptions requestOptions) { + return sync.exchangeList(idOrAlias, options, requestOptions).sendAsync(); + } + + /** + * Check wallet access + * + *

Whether the customer's prepaid credit in a currency or credit unit still covers them, net + * of usage not invoiced yet. Denies only when the wallet blocks usage once its credit is used + * up; otherwise access stays allowed and exhausted signals the empty balance on + * its own. With subscription_id, only the credit that subscription can use counts: + * pass it when the customer has several subscriptions, since one subscription's credit cannot + * pay another's usage. The balance follows usage within a few seconds near zero or a threshold, + * within a minute otherwise, and the answer is cached for one second: use it to gate + * consumption, not to bill. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @return the response body, once received + */ + public CompletableFuture check(final String idOrAlias) { + return check(idOrAlias, CreditsWalletsCheckOptions.none(), RequestOptions.none()); + } + + /** + * Check wallet access + * + *

Whether the customer's prepaid credit in a currency or credit unit still covers them, net + * of usage not invoiced yet. Denies only when the wallet blocks usage once its credit is used + * up; otherwise access stays allowed and exhausted signals the empty balance on + * its own. With subscription_id, only the credit that subscription can use counts: + * pass it when the customer has several subscriptions, since one subscription's credit cannot + * pay another's usage. The balance follows usage within a few seconds near zero or a threshold, + * within a minute otherwise, and the answer is cached for one second: use it to gate + * consumption, not to bill. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param options the optional parameters + * @return the response body, once received + */ + public CompletableFuture check( + final String idOrAlias, final CreditsWalletsCheckOptions options) { + return check(idOrAlias, options, RequestOptions.none()); + } + + /** + * Check wallet access + * + *

Whether the customer's prepaid credit in a currency or credit unit still covers them, net + * of usage not invoiced yet. Denies only when the wallet blocks usage once its credit is used + * up; otherwise access stays allowed and exhausted signals the empty balance on + * its own. With subscription_id, only the credit that subscription can use counts: + * pass it when the customer has several subscriptions, since one subscription's credit cannot + * pay another's usage. The balance follows usage within a few seconds near zero or a threshold, + * within a minute otherwise, and the answer is cached for one second: use it to gate + * consumption, not to bill. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param requestOptions headers, timeout and retries of this call + * @return the response body, once received + */ + public CompletableFuture check( + final String idOrAlias, final RequestOptions requestOptions) { + return check(idOrAlias, CreditsWalletsCheckOptions.none(), requestOptions); + } + + /** + * Check wallet access + * + *

Whether the customer's prepaid credit in a currency or credit unit still covers them, net + * of usage not invoiced yet. Denies only when the wallet blocks usage once its credit is used + * up; otherwise access stays allowed and exhausted signals the empty balance on + * its own. With subscription_id, only the credit that subscription can use counts: + * pass it when the customer has several subscriptions, since one subscription's credit cannot + * pay another's usage. The balance follows usage within a few seconds near zero or a threshold, + * within a minute otherwise, and the answer is cached for one second: use it to gate + * consumption, not to bill. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param options the optional parameters + * @param requestOptions headers, timeout and retries of this call + * @return the response body, once received + */ + public CompletableFuture check( + final String idOrAlias, + final CreditsWalletsCheckOptions options, + final RequestOptions requestOptions) { + return sync.exchangeCheck(idOrAlias, options, requestOptions).sendAsync(); + } + + /** + * Configure a wallet + * + *

Settings of a customer's wallet in one currency or credit unit: whether usage is refused + * once its credit is used up, the balances that fire wallet.balance_low, and its + * automatic top-up. Opens the wallet if it does not exist yet. Partial update: omit a field to + * leave it unchanged. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param currency the {@code currency} path parameter + * @param idempotencyKey the {@code Idempotency-Key} required parameter + * @param patchWalletRequest the request body + * @return the response body, once received + */ + public CompletableFuture update( + final String idOrAlias, + final String currency, + final String idempotencyKey, + final PatchWalletRequest patchWalletRequest) { + return update( + idOrAlias, currency, idempotencyKey, patchWalletRequest, RequestOptions.none()); + } + + /** + * Configure a wallet + * + *

Settings of a customer's wallet in one currency or credit unit: whether usage is refused + * once its credit is used up, the balances that fire wallet.balance_low, and its + * automatic top-up. Opens the wallet if it does not exist yet. Partial update: omit a field to + * leave it unchanged. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param currency the {@code currency} path parameter + * @param idempotencyKey the {@code Idempotency-Key} required parameter + * @param patchWalletRequest the request body + * @param requestOptions headers, timeout and retries of this call + * @return the response body, once received + */ + public CompletableFuture update( + final String idOrAlias, + final String currency, + final String idempotencyKey, + final PatchWalletRequest patchWalletRequest, + final RequestOptions requestOptions) { + return sync.exchangeUpdate( + idOrAlias, currency, idempotencyKey, patchWalletRequest, requestOptions) + .sendAsync(); + } + + /** The operations, returning the status and headers along with the body. */ + public final class WithRawResponse { + private WithRawResponse() {} + + /** + * List wallets + * + *

A customer's credit per currency and credit unit: the credit on account, the usage not + * invoiced yet and the balance left after it, with the wallet's alerts and automatic + * top-up. The customer's own currency comes first, even when empty. With + * subscription_id, each wallet counts only the credit that subscription can use. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @return the status, headers and body, once received + */ + public CompletableFuture> list(final String idOrAlias) { + return list(idOrAlias, CreditsWalletsListOptions.none(), RequestOptions.none()); + } + + /** + * List wallets + * + *

A customer's credit per currency and credit unit: the credit on account, the usage not + * invoiced yet and the balance left after it, with the wallet's alerts and automatic + * top-up. The customer's own currency comes first, even when empty. With + * subscription_id, each wallet counts only the credit that subscription can use. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param options the optional parameters + * @return the status, headers and body, once received + */ + public CompletableFuture> list( + final String idOrAlias, final CreditsWalletsListOptions options) { + return list(idOrAlias, options, RequestOptions.none()); + } + + /** + * List wallets + * + *

A customer's credit per currency and credit unit: the credit on account, the usage not + * invoiced yet and the balance left after it, with the wallet's alerts and automatic + * top-up. The customer's own currency comes first, even when empty. With + * subscription_id, each wallet counts only the credit that subscription can use. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body, once received + */ + public CompletableFuture> list( + final String idOrAlias, final RequestOptions requestOptions) { + return list(idOrAlias, CreditsWalletsListOptions.none(), requestOptions); + } + + /** + * List wallets + * + *

A customer's credit per currency and credit unit: the credit on account, the usage not + * invoiced yet and the balance left after it, with the wallet's alerts and automatic + * top-up. The customer's own currency comes first, even when empty. With + * subscription_id, each wallet counts only the credit that subscription can use. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param options the optional parameters + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body, once received + */ + public CompletableFuture> list( + final String idOrAlias, + final CreditsWalletsListOptions options, + final RequestOptions requestOptions) { + return sync.exchangeList(idOrAlias, options, requestOptions).sendRawAsync(); + } + + /** + * Check wallet access + * + *

Whether the customer's prepaid credit in a currency or credit unit still covers them, + * net of usage not invoiced yet. Denies only when the wallet blocks usage once its credit + * is used up; otherwise access stays allowed and exhausted signals the empty + * balance on its own. With subscription_id, only the credit that subscription + * can use counts: pass it when the customer has several subscriptions, since one + * subscription's credit cannot pay another's usage. The balance follows usage within a few + * seconds near zero or a threshold, within a minute otherwise, and the answer is cached for + * one second: use it to gate consumption, not to bill. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @return the status, headers and body, once received + */ + public CompletableFuture> check(final String idOrAlias) { + return check(idOrAlias, CreditsWalletsCheckOptions.none(), RequestOptions.none()); + } + + /** + * Check wallet access + * + *

Whether the customer's prepaid credit in a currency or credit unit still covers them, + * net of usage not invoiced yet. Denies only when the wallet blocks usage once its credit + * is used up; otherwise access stays allowed and exhausted signals the empty + * balance on its own. With subscription_id, only the credit that subscription + * can use counts: pass it when the customer has several subscriptions, since one + * subscription's credit cannot pay another's usage. The balance follows usage within a few + * seconds near zero or a threshold, within a minute otherwise, and the answer is cached for + * one second: use it to gate consumption, not to bill. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param options the optional parameters + * @return the status, headers and body, once received + */ + public CompletableFuture> check( + final String idOrAlias, final CreditsWalletsCheckOptions options) { + return check(idOrAlias, options, RequestOptions.none()); + } + + /** + * Check wallet access + * + *

Whether the customer's prepaid credit in a currency or credit unit still covers them, + * net of usage not invoiced yet. Denies only when the wallet blocks usage once its credit + * is used up; otherwise access stays allowed and exhausted signals the empty + * balance on its own. With subscription_id, only the credit that subscription + * can use counts: pass it when the customer has several subscriptions, since one + * subscription's credit cannot pay another's usage. The balance follows usage within a few + * seconds near zero or a threshold, within a minute otherwise, and the answer is cached for + * one second: use it to gate consumption, not to bill. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body, once received + */ + public CompletableFuture> check( + final String idOrAlias, final RequestOptions requestOptions) { + return check(idOrAlias, CreditsWalletsCheckOptions.none(), requestOptions); + } + + /** + * Check wallet access + * + *

Whether the customer's prepaid credit in a currency or credit unit still covers them, + * net of usage not invoiced yet. Denies only when the wallet blocks usage once its credit + * is used up; otherwise access stays allowed and exhausted signals the empty + * balance on its own. With subscription_id, only the credit that subscription + * can use counts: pass it when the customer has several subscriptions, since one + * subscription's credit cannot pay another's usage. The balance follows usage within a few + * seconds near zero or a threshold, within a minute otherwise, and the answer is cached for + * one second: use it to gate consumption, not to bill. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param options the optional parameters + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body, once received + */ + public CompletableFuture> check( + final String idOrAlias, + final CreditsWalletsCheckOptions options, + final RequestOptions requestOptions) { + return sync.exchangeCheck(idOrAlias, options, requestOptions).sendRawAsync(); + } + + /** + * Configure a wallet + * + *

Settings of a customer's wallet in one currency or credit unit: whether usage is + * refused once its credit is used up, the balances that fire wallet.balance_low + * , and its automatic top-up. Opens the wallet if it does not exist yet. Partial + * update: omit a field to leave it unchanged. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param currency the {@code currency} path parameter + * @param idempotencyKey the {@code Idempotency-Key} required parameter + * @param patchWalletRequest the request body + * @return the status, headers and body, once received + */ + public CompletableFuture> update( + final String idOrAlias, + final String currency, + final String idempotencyKey, + final PatchWalletRequest patchWalletRequest) { + return update( + idOrAlias, currency, idempotencyKey, patchWalletRequest, RequestOptions.none()); + } + + /** + * Configure a wallet + * + *

Settings of a customer's wallet in one currency or credit unit: whether usage is + * refused once its credit is used up, the balances that fire wallet.balance_low + * , and its automatic top-up. Opens the wallet if it does not exist yet. Partial + * update: omit a field to leave it unchanged. + * + * @param idOrAlias the {@code id_or_alias} path parameter + * @param currency the {@code currency} path parameter + * @param idempotencyKey the {@code Idempotency-Key} required parameter + * @param patchWalletRequest the request body + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body, once received + */ + public CompletableFuture> update( + final String idOrAlias, + final String currency, + final String idempotencyKey, + final PatchWalletRequest patchWalletRequest, + final RequestOptions requestOptions) { + return sync.exchangeUpdate( + idOrAlias, currency, idempotencyKey, patchWalletRequest, requestOptions) + .sendRawAsync(); + } + } +} diff --git a/src/main/java/com/meteroid/api/CreditsWalletsCheckOptions.java b/src/main/java/com/meteroid/api/CreditsWalletsCheckOptions.java new file mode 100644 index 0000000..a65e663 --- /dev/null +++ b/src/main/java/com/meteroid/api/CreditsWalletsCheckOptions.java @@ -0,0 +1,197 @@ +// this file is @generated +package com.meteroid.api; + +import com.meteroid.models.Currency; + +import java.util.Objects; +import java.util.Optional; + +/** Optional parameters of {@code check}, immutable: build them with {@link #builder()}. */ +public final class CreditsWalletsCheckOptions { + private final Currency currency; + private final String creditUnit; + private final String productId; + private final String subscriptionId; + + private CreditsWalletsCheckOptions(Builder builder) { + this.currency = builder.currency; + this.creditUnit = builder.creditUnit; + this.productId = builder.productId; + this.subscriptionId = builder.subscriptionId; + } + + /** + * A builder of parameters. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * No parameters. + * + * @return empty parameters + */ + public static CreditsWalletsCheckOptions none() { + return builder().build(); + } + + /** + * A builder starting from these parameters. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.currency = currency; + builder.creditUnit = creditUnit; + builder.productId = productId; + builder.subscriptionId = subscriptionId; + return builder; + } + + /** + * Defaults to the customer's currency. + * + * @return the value, empty when unset + */ + public Optional currency() { + return Optional.ofNullable(currency); + } + + /** + * Checks the wallet of this credit unit (its code) instead of a currency. + * + * @return the value, empty when unset + */ + public Optional creditUnit() { + return Optional.ofNullable(creditUnit); + } + + /** + * Checks only the credit that can pay for this product: credit not restricted to products, and + * credit restricted to it. Absent checks all credit. + * + * @return the value, empty when unset + */ + public Optional productId() { + return Optional.ofNullable(productId); + } + + /** + * Checks only the credit this subscription (sub_…) can spend, net of its own usage + * no credit pays: the credit that belongs to it and the customer's credit that belongs to no + * subscription, once every subscription's unbilled usage is paid. has_access is + * then the decision the access gate makes for that subscription's usage. Absent checks the + * customer's credit as a whole. + * + * @return the value, empty when unset + */ + public Optional subscriptionId() { + return Optional.ofNullable(subscriptionId); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CreditsWalletsCheckOptions that = (CreditsWalletsCheckOptions) o; + return Objects.equals(currency, that.currency) + && Objects.equals(creditUnit, that.creditUnit) + && Objects.equals(productId, that.productId) + && Objects.equals(subscriptionId, that.subscriptionId); + } + + @Override + public int hashCode() { + return Objects.hash(currency, creditUnit, productId, subscriptionId); + } + + @Override + public String toString() { + return "CreditsWalletsCheckOptions{" + + "currency=" + + currency + + ", creditUnit=" + + creditUnit + + ", productId=" + + productId + + ", subscriptionId=" + + subscriptionId + + "}"; + } + + /** Builds {@link CreditsWalletsCheckOptions}. */ + public static final class Builder { + private Currency currency; + private String creditUnit; + private String productId; + private String subscriptionId; + + private Builder() {} + + /** + * Defaults to the customer's currency. + * + * @param currency the value, null to leave it out + * @return this builder + */ + public Builder currency(Currency currency) { + this.currency = currency; + return this; + } + + /** + * Checks the wallet of this credit unit (its code) instead of a currency. + * + * @param creditUnit the value, null to leave it out + * @return this builder + */ + public Builder creditUnit(String creditUnit) { + this.creditUnit = creditUnit; + return this; + } + + /** + * Checks only the credit that can pay for this product: credit not restricted to products, + * and credit restricted to it. Absent checks all credit. + * + * @param productId the value, null to leave it out + * @return this builder + */ + public Builder productId(String productId) { + this.productId = productId; + return this; + } + + /** + * Checks only the credit this subscription (sub_…) can spend, net of its own + * usage no credit pays: the credit that belongs to it and the customer's credit that + * belongs to no subscription, once every subscription's unbilled usage is paid. + * has_access is then the decision the access gate makes for that subscription's + * usage. Absent checks the customer's credit as a whole. + * + * @param subscriptionId the value, null to leave it out + * @return this builder + */ + public Builder subscriptionId(String subscriptionId) { + this.subscriptionId = subscriptionId; + return this; + } + + /** + * The parameters. + * + * @return immutable parameters + */ + public CreditsWalletsCheckOptions build() { + return new CreditsWalletsCheckOptions(this); + } + } +} diff --git a/src/main/java/com/meteroid/api/CreditsWalletsListOptions.java b/src/main/java/com/meteroid/api/CreditsWalletsListOptions.java new file mode 100644 index 0000000..0ecfe21 --- /dev/null +++ b/src/main/java/com/meteroid/api/CreditsWalletsListOptions.java @@ -0,0 +1,104 @@ +// this file is @generated +package com.meteroid.api; + +import java.util.Objects; +import java.util.Optional; + +/** Optional parameters of {@code list}, immutable: build them with {@link #builder()}. */ +public final class CreditsWalletsListOptions { + private final String subscriptionId; + + private CreditsWalletsListOptions(Builder builder) { + this.subscriptionId = builder.subscriptionId; + } + + /** + * A builder of parameters. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * No parameters. + * + * @return empty parameters + */ + public static CreditsWalletsListOptions none() { + return builder().build(); + } + + /** + * A builder starting from these parameters. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.subscriptionId = subscriptionId; + return builder; + } + + /** + * Only the credit this subscription (sub_…) can use: the credit that belongs to it + * and the customer's credit that belongs to no subscription. Every wallet is still listed. + * + * @return the value, empty when unset + */ + public Optional subscriptionId() { + return Optional.ofNullable(subscriptionId); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CreditsWalletsListOptions that = (CreditsWalletsListOptions) o; + return Objects.equals(subscriptionId, that.subscriptionId); + } + + @Override + public int hashCode() { + return Objects.hash(subscriptionId); + } + + @Override + public String toString() { + return "CreditsWalletsListOptions{" + "subscriptionId=" + subscriptionId + "}"; + } + + /** Builds {@link CreditsWalletsListOptions}. */ + public static final class Builder { + private String subscriptionId; + + private Builder() {} + + /** + * Only the credit this subscription (sub_…) can use: the credit that belongs + * to it and the customer's credit that belongs to no subscription. Every wallet is still + * listed. + * + * @param subscriptionId the value, null to leave it out + * @return this builder + */ + public Builder subscriptionId(String subscriptionId) { + this.subscriptionId = subscriptionId; + return this; + } + + /** + * The parameters. + * + * @return immutable parameters + */ + public CreditsWalletsListOptions build() { + return new CreditsWalletsListOptions(this); + } + } +} diff --git a/src/main/java/com/meteroid/api/Features.java b/src/main/java/com/meteroid/api/Features.java index 8b0ed75..c51c863 100644 --- a/src/main/java/com/meteroid/api/Features.java +++ b/src/main/java/com/meteroid/api/Features.java @@ -267,7 +267,8 @@ MeteroidHttpClient.Exchange exchangeUpdate( /** * Archive a feature * - *

Keeps the feature and its entitlements but hides them from resolution. + *

Turns the feature off and hides it and its entitlements until it is unarchived, and frees + * its code for a new feature. * * @param idOrCode the {@code id_or_code} path parameter */ @@ -278,7 +279,8 @@ public void archive(final String idOrCode) { /** * Archive a feature * - *

Keeps the feature and its entitlements but hides them from resolution. + *

Turns the feature off and hides it and its entitlements until it is unarchived, and frees + * its code for a new feature. * * @param idOrCode the {@code id_or_code} path parameter * @param requestOptions headers, timeout and retries of this call @@ -305,6 +307,9 @@ MeteroidHttpClient.Exchange exchangeArchive( /** * Unarchive a feature * + *

Makes the feature active again with all its entitlements. Fails while another feature uses + * its code. + * * @param idOrCode the {@code id_or_code} path parameter */ public void unarchive(final String idOrCode) { @@ -314,6 +319,9 @@ public void unarchive(final String idOrCode) { /** * Unarchive a feature * + *

Makes the feature active again with all its entitlements. Fails while another feature uses + * its code. + * * @param idOrCode the {@code id_or_code} path parameter * @param requestOptions headers, timeout and retries of this call */ @@ -331,7 +339,7 @@ MeteroidHttpClient.Exchange exchangeUnarchive( .addPathSegments("unarchive") .build(); return client.call("POST", url) - .errors(com.meteroid.models.RestErrorResponse.class, "401", "404", "429") + .errors(com.meteroid.models.RestErrorResponse.class, "401", "404", "409", "429") .options(requestOptions) .returningNothing(); } @@ -467,7 +475,8 @@ public ApiResponse update( /** * Archive a feature * - *

Keeps the feature and its entitlements but hides them from resolution. + *

Turns the feature off and hides it and its entitlements until it is unarchived, and + * frees its code for a new feature. * * @param idOrCode the {@code id_or_code} path parameter * @return the status, headers and body @@ -479,7 +488,8 @@ public ApiResponse archive(final String idOrCode) { /** * Archive a feature * - *

Keeps the feature and its entitlements but hides them from resolution. + *

Turns the feature off and hides it and its entitlements until it is unarchived, and + * frees its code for a new feature. * * @param idOrCode the {@code id_or_code} path parameter * @param requestOptions headers, timeout and retries of this call @@ -493,6 +503,9 @@ public ApiResponse archive( /** * Unarchive a feature * + *

Makes the feature active again with all its entitlements. Fails while another feature + * uses its code. + * * @param idOrCode the {@code id_or_code} path parameter * @return the status, headers and body */ @@ -503,6 +516,9 @@ public ApiResponse unarchive(final String idOrCode) { /** * Unarchive a feature * + *

Makes the feature active again with all its entitlements. Fails while another feature + * uses its code. + * * @param idOrCode the {@code id_or_code} path parameter * @param requestOptions headers, timeout and retries of this call * @return the status, headers and body diff --git a/src/main/java/com/meteroid/api/FeaturesAsync.java b/src/main/java/com/meteroid/api/FeaturesAsync.java index 892a66d..142156e 100644 --- a/src/main/java/com/meteroid/api/FeaturesAsync.java +++ b/src/main/java/com/meteroid/api/FeaturesAsync.java @@ -173,7 +173,8 @@ public CompletableFuture update( /** * Archive a feature * - *

Keeps the feature and its entitlements but hides them from resolution. + *

Turns the feature off and hides it and its entitlements until it is unarchived, and frees + * its code for a new feature. * * @param idOrCode the {@code id_or_code} path parameter * @return the response body, once received @@ -185,7 +186,8 @@ public CompletableFuture archive(final String idOrCode) { /** * Archive a feature * - *

Keeps the feature and its entitlements but hides them from resolution. + *

Turns the feature off and hides it and its entitlements until it is unarchived, and frees + * its code for a new feature. * * @param idOrCode the {@code id_or_code} path parameter * @param requestOptions headers, timeout and retries of this call @@ -199,6 +201,9 @@ public CompletableFuture archive( /** * Unarchive a feature * + *

Makes the feature active again with all its entitlements. Fails while another feature uses + * its code. + * * @param idOrCode the {@code id_or_code} path parameter * @return the response body, once received */ @@ -209,6 +214,9 @@ public CompletableFuture unarchive(final String idOrCode) { /** * Unarchive a feature * + *

Makes the feature active again with all its entitlements. Fails while another feature uses + * its code. + * * @param idOrCode the {@code id_or_code} path parameter * @param requestOptions headers, timeout and retries of this call * @return the response body, once received @@ -353,7 +361,8 @@ public CompletableFuture> update( /** * Archive a feature * - *

Keeps the feature and its entitlements but hides them from resolution. + *

Turns the feature off and hides it and its entitlements until it is unarchived, and + * frees its code for a new feature. * * @param idOrCode the {@code id_or_code} path parameter * @return the status, headers and body, once received @@ -365,7 +374,8 @@ public CompletableFuture> archive(final String idOrCode) { /** * Archive a feature * - *

Keeps the feature and its entitlements but hides them from resolution. + *

Turns the feature off and hides it and its entitlements until it is unarchived, and + * frees its code for a new feature. * * @param idOrCode the {@code id_or_code} path parameter * @param requestOptions headers, timeout and retries of this call @@ -379,6 +389,9 @@ public CompletableFuture> archive( /** * Unarchive a feature * + *

Makes the feature active again with all its entitlements. Fails while another feature + * uses its code. + * * @param idOrCode the {@code id_or_code} path parameter * @return the status, headers and body, once received */ @@ -389,6 +402,9 @@ public CompletableFuture> unarchive(final String idOrCode) { /** * Unarchive a feature * + *

Makes the feature active again with all its entitlements. Fails while another feature + * uses its code. + * * @param idOrCode the {@code id_or_code} path parameter * @param requestOptions headers, timeout and retries of this call * @return the status, headers and body, once received diff --git a/src/main/java/com/meteroid/api/Plans.java b/src/main/java/com/meteroid/api/Plans.java index e8f80e7..c0f4392 100644 --- a/src/main/java/com/meteroid/api/Plans.java +++ b/src/main/java/com/meteroid/api/Plans.java @@ -387,7 +387,9 @@ MeteroidHttpClient.Exchange exchangeRetrieve( * *

Full replacement of a plan's version. On a draft plan, updates in-place. On a published * plan, creates a new version. Set status to DRAFT to stage as a new - * draft without publishing. + * draft without publishing. A usage or capacity component priced in a credit unit must be sent + * with its credit_unit, or the request is refused: omitting it would bill its + * credits as money. * * @param planId the {@code plan_id} path parameter * @param replacePlanRequest the request body @@ -402,7 +404,9 @@ public Plan replace(final String planId, final ReplacePlanRequest replacePlanReq * *

Full replacement of a plan's version. On a draft plan, updates in-place. On a published * plan, creates a new version. Set status to DRAFT to stage as a new - * draft without publishing. + * draft without publishing. A usage or capacity component priced in a credit unit must be sent + * with its credit_unit, or the request is refused: omitting it would bill its + * credits as money. * * @param planId the {@code plan_id} path parameter * @param replacePlanRequest the request body @@ -805,7 +809,9 @@ public ApiResponse retrieve( * *

Full replacement of a plan's version. On a draft plan, updates in-place. On a * published plan, creates a new version. Set status to DRAFT to - * stage as a new draft without publishing. + * stage as a new draft without publishing. A usage or capacity component priced in a credit + * unit must be sent with its credit_unit, or the request is refused: omitting + * it would bill its credits as money. * * @param planId the {@code plan_id} path parameter * @param replacePlanRequest the request body @@ -821,7 +827,9 @@ public ApiResponse replace( * *

Full replacement of a plan's version. On a draft plan, updates in-place. On a * published plan, creates a new version. Set status to DRAFT to - * stage as a new draft without publishing. + * stage as a new draft without publishing. A usage or capacity component priced in a credit + * unit must be sent with its credit_unit, or the request is refused: omitting + * it would bill its credits as money. * * @param planId the {@code plan_id} path parameter * @param replacePlanRequest the request body diff --git a/src/main/java/com/meteroid/api/PlansAsync.java b/src/main/java/com/meteroid/api/PlansAsync.java index f3b0baf..1dd8d42 100644 --- a/src/main/java/com/meteroid/api/PlansAsync.java +++ b/src/main/java/com/meteroid/api/PlansAsync.java @@ -263,7 +263,9 @@ public CompletableFuture retrieve( * *

Full replacement of a plan's version. On a draft plan, updates in-place. On a published * plan, creates a new version. Set status to DRAFT to stage as a new - * draft without publishing. + * draft without publishing. A usage or capacity component priced in a credit unit must be sent + * with its credit_unit, or the request is refused: omitting it would bill its + * credits as money. * * @param planId the {@code plan_id} path parameter * @param replacePlanRequest the request body @@ -279,7 +281,9 @@ public CompletableFuture replace( * *

Full replacement of a plan's version. On a draft plan, updates in-place. On a published * plan, creates a new version. Set status to DRAFT to stage as a new - * draft without publishing. + * draft without publishing. A usage or capacity component priced in a credit unit must be sent + * with its credit_unit, or the request is refused: omitting it would bill its + * credits as money. * * @param planId the {@code plan_id} path parameter * @param replacePlanRequest the request body @@ -614,7 +618,9 @@ public CompletableFuture> retrieve( * *

Full replacement of a plan's version. On a draft plan, updates in-place. On a * published plan, creates a new version. Set status to DRAFT to - * stage as a new draft without publishing. + * stage as a new draft without publishing. A usage or capacity component priced in a credit + * unit must be sent with its credit_unit, or the request is refused: omitting + * it would bill its credits as money. * * @param planId the {@code plan_id} path parameter * @param replacePlanRequest the request body @@ -630,7 +636,9 @@ public CompletableFuture> replace( * *

Full replacement of a plan's version. On a draft plan, updates in-place. On a * published plan, creates a new version. Set status to DRAFT to - * stage as a new draft without publishing. + * stage as a new draft without publishing. A usage or capacity component priced in a credit + * unit must be sent with its credit_unit, or the request is refused: omitting + * it would bill its credits as money. * * @param planId the {@code plan_id} path parameter * @param replacePlanRequest the request body diff --git a/src/main/java/com/meteroid/api/Usage.java b/src/main/java/com/meteroid/api/Usage.java index 2e572b2..abf38af 100644 --- a/src/main/java/com/meteroid/api/Usage.java +++ b/src/main/java/com/meteroid/api/Usage.java @@ -20,6 +20,8 @@ public final class Usage { private final MeteroidHttpClient client; private final WithRawResponse withRawResponse; + private final UsageCustomer customer; + /** * The operations, sending through {@code client}. * @@ -28,6 +30,8 @@ public final class Usage { public Usage(MeteroidHttpClient client) { this.client = client; this.withRawResponse = new WithRawResponse(); + + this.customer = new UsageCustomer(client); } /** @@ -40,121 +44,23 @@ public WithRawResponse withRawResponse() { } /** - * Get customer usage - * - *

Retrieve aggregated usage data for a customer over a specified period. - * - * @param customerId the {@code customer_id} path parameter - * @param startDate the {@code start_date} required parameter - * @param endDate the {@code end_date} required parameter - * @return the response body - */ - public UsageResponse retrieveCustomer( - final String customerId, final LocalDate startDate, final LocalDate endDate) { - return retrieveCustomer( - customerId, - startDate, - endDate, - UsageRetrieveCustomerOptions.none(), - RequestOptions.none()); - } - - /** - * Get customer usage - * - *

Retrieve aggregated usage data for a customer over a specified period. - * - * @param customerId the {@code customer_id} path parameter - * @param startDate the {@code start_date} required parameter - * @param endDate the {@code end_date} required parameter - * @param options the optional parameters - * @return the response body - */ - public UsageResponse retrieveCustomer( - final String customerId, - final LocalDate startDate, - final LocalDate endDate, - final UsageRetrieveCustomerOptions options) { - return retrieveCustomer(customerId, startDate, endDate, options, RequestOptions.none()); - } - - /** - * Get customer usage + * The {@code customer} operations. * - *

Retrieve aggregated usage data for a customer over a specified period. - * - * @param customerId the {@code customer_id} path parameter - * @param startDate the {@code start_date} required parameter - * @param endDate the {@code end_date} required parameter - * @param requestOptions headers, timeout and retries of this call - * @return the response body + * @return the operations */ - public UsageResponse retrieveCustomer( - final String customerId, - final LocalDate startDate, - final LocalDate endDate, - final RequestOptions requestOptions) { - return retrieveCustomer( - customerId, - startDate, - endDate, - UsageRetrieveCustomerOptions.none(), - requestOptions); - } - - /** - * Get customer usage - * - *

Retrieve aggregated usage data for a customer over a specified period. - * - * @param customerId the {@code customer_id} path parameter - * @param startDate the {@code start_date} required parameter - * @param endDate the {@code end_date} required parameter - * @param options the optional parameters - * @param requestOptions headers, timeout and retries of this call - * @return the response body - */ - public UsageResponse retrieveCustomer( - final String customerId, - final LocalDate startDate, - final LocalDate endDate, - final UsageRetrieveCustomerOptions options, - final RequestOptions requestOptions) { - return exchangeRetrieveCustomer(customerId, startDate, endDate, options, requestOptions) - .send(); - } - - MeteroidHttpClient.Exchange exchangeRetrieveCustomer( - final String customerId, - final LocalDate startDate, - final LocalDate endDate, - final UsageRetrieveCustomerOptions options, - final RequestOptions requestOptions) { - Objects.requireNonNull(customerId, "customer_id"); - Objects.requireNonNull(startDate, "start_date"); - Objects.requireNonNull(endDate, "end_date"); - Objects.requireNonNull(options, "options"); - HttpUrl.Builder url = - client.newUrlBuilder() - .addPathSegments("api/v1/usage/customer") - .addPathSegment(Utils.pathSegment("customer_id", customerId)); - url.addQueryParameter("start_date", Utils.serializeQueryParam(startDate)); - url.addQueryParameter("end_date", Utils.serializeQueryParam(endDate)); - String value3 = options.metricId().orElse(null); - if (value3 != null) { - url.addQueryParameter("metric_id", value3); - } - return client.call("GET", url.build()) - .errors(com.meteroid.models.RestErrorResponse.class, "401", "404", "429", "500") - .options(requestOptions) - .returning(UsageResponse.class); + public UsageCustomer customer() { + return customer; } /** * Get subscription usage * *

Retrieve aggregated usage data for a subscription's usage-based components. If - * start_date/end_date are omitted, defaults to the current billing period. + * start_date/end_date are omitted, defaults to the current billing period, and the response + * then carries the running total (beta): what each metric's usage adds so far to the next + * invoice, and what they add up to, before discounts and credits. That reading is shared for up + * to 30 seconds (see computed_at). Counts towards the usage cost reads' rate + * limit. * * @param subscriptionId the {@code subscription_id} path parameter * @return the response body @@ -168,7 +74,11 @@ public UsageResponse retrieveSubscription(final String subscriptionId) { * Get subscription usage * *

Retrieve aggregated usage data for a subscription's usage-based components. If - * start_date/end_date are omitted, defaults to the current billing period. + * start_date/end_date are omitted, defaults to the current billing period, and the response + * then carries the running total (beta): what each metric's usage adds so far to the next + * invoice, and what they add up to, before discounts and credits. That reading is shared for up + * to 30 seconds (see computed_at). Counts towards the usage cost reads' rate + * limit. * * @param subscriptionId the {@code subscription_id} path parameter * @param options the optional parameters @@ -183,7 +93,11 @@ public UsageResponse retrieveSubscription( * Get subscription usage * *

Retrieve aggregated usage data for a subscription's usage-based components. If - * start_date/end_date are omitted, defaults to the current billing period. + * start_date/end_date are omitted, defaults to the current billing period, and the response + * then carries the running total (beta): what each metric's usage adds so far to the next + * invoice, and what they add up to, before discounts and credits. That reading is shared for up + * to 30 seconds (see computed_at). Counts towards the usage cost reads' rate + * limit. * * @param subscriptionId the {@code subscription_id} path parameter * @param requestOptions headers, timeout and retries of this call @@ -199,7 +113,11 @@ public UsageResponse retrieveSubscription( * Get subscription usage * *

Retrieve aggregated usage data for a subscription's usage-based components. If - * start_date/end_date are omitted, defaults to the current billing period. + * start_date/end_date are omitted, defaults to the current billing period, and the response + * then carries the running total (beta): what each metric's usage adds so far to the next + * invoice, and what they add up to, before discounts and credits. That reading is shared for up + * to 30 seconds (see computed_at). Counts towards the usage cost reads' rate + * limit. * * @param subscriptionId the {@code subscription_id} path parameter * @param options the optional parameters @@ -335,97 +253,23 @@ public final class WithRawResponse { private WithRawResponse() {} /** - * Get customer usage - * - *

Retrieve aggregated usage data for a customer over a specified period. - * - * @param customerId the {@code customer_id} path parameter - * @param startDate the {@code start_date} required parameter - * @param endDate the {@code end_date} required parameter - * @return the status, headers and body - */ - public ApiResponse retrieveCustomer( - final String customerId, final LocalDate startDate, final LocalDate endDate) { - return retrieveCustomer( - customerId, - startDate, - endDate, - UsageRetrieveCustomerOptions.none(), - RequestOptions.none()); - } - - /** - * Get customer usage - * - *

Retrieve aggregated usage data for a customer over a specified period. + * The {@code customer} operations. * - * @param customerId the {@code customer_id} path parameter - * @param startDate the {@code start_date} required parameter - * @param endDate the {@code end_date} required parameter - * @param options the optional parameters - * @return the status, headers and body + * @return the operations */ - public ApiResponse retrieveCustomer( - final String customerId, - final LocalDate startDate, - final LocalDate endDate, - final UsageRetrieveCustomerOptions options) { - return retrieveCustomer(customerId, startDate, endDate, options, RequestOptions.none()); - } - - /** - * Get customer usage - * - *

Retrieve aggregated usage data for a customer over a specified period. - * - * @param customerId the {@code customer_id} path parameter - * @param startDate the {@code start_date} required parameter - * @param endDate the {@code end_date} required parameter - * @param requestOptions headers, timeout and retries of this call - * @return the status, headers and body - */ - public ApiResponse retrieveCustomer( - final String customerId, - final LocalDate startDate, - final LocalDate endDate, - final RequestOptions requestOptions) { - return retrieveCustomer( - customerId, - startDate, - endDate, - UsageRetrieveCustomerOptions.none(), - requestOptions); - } - - /** - * Get customer usage - * - *

Retrieve aggregated usage data for a customer over a specified period. - * - * @param customerId the {@code customer_id} path parameter - * @param startDate the {@code start_date} required parameter - * @param endDate the {@code end_date} required parameter - * @param options the optional parameters - * @param requestOptions headers, timeout and retries of this call - * @return the status, headers and body - */ - public ApiResponse retrieveCustomer( - final String customerId, - final LocalDate startDate, - final LocalDate endDate, - final UsageRetrieveCustomerOptions options, - final RequestOptions requestOptions) { - return Usage.this - .exchangeRetrieveCustomer( - customerId, startDate, endDate, options, requestOptions) - .sendRaw(); + public UsageCustomer.WithRawResponse customer() { + return Usage.this.customer.withRawResponse(); } /** * Get subscription usage * *

Retrieve aggregated usage data for a subscription's usage-based components. If - * start_date/end_date are omitted, defaults to the current billing period. + * start_date/end_date are omitted, defaults to the current billing period, and the response + * then carries the running total (beta): what each metric's usage adds so far to the next + * invoice, and what they add up to, before discounts and credits. That reading is shared + * for up to 30 seconds (see computed_at). Counts towards the usage cost reads' + * rate limit. * * @param subscriptionId the {@code subscription_id} path parameter * @return the status, headers and body @@ -439,7 +283,11 @@ public ApiResponse retrieveSubscription(final String subscription * Get subscription usage * *

Retrieve aggregated usage data for a subscription's usage-based components. If - * start_date/end_date are omitted, defaults to the current billing period. + * start_date/end_date are omitted, defaults to the current billing period, and the response + * then carries the running total (beta): what each metric's usage adds so far to the next + * invoice, and what they add up to, before discounts and credits. That reading is shared + * for up to 30 seconds (see computed_at). Counts towards the usage cost reads' + * rate limit. * * @param subscriptionId the {@code subscription_id} path parameter * @param options the optional parameters @@ -454,7 +302,11 @@ public ApiResponse retrieveSubscription( * Get subscription usage * *

Retrieve aggregated usage data for a subscription's usage-based components. If - * start_date/end_date are omitted, defaults to the current billing period. + * start_date/end_date are omitted, defaults to the current billing period, and the response + * then carries the running total (beta): what each metric's usage adds so far to the next + * invoice, and what they add up to, before discounts and credits. That reading is shared + * for up to 30 seconds (see computed_at). Counts towards the usage cost reads' + * rate limit. * * @param subscriptionId the {@code subscription_id} path parameter * @param requestOptions headers, timeout and retries of this call @@ -470,7 +322,11 @@ public ApiResponse retrieveSubscription( * Get subscription usage * *

Retrieve aggregated usage data for a subscription's usage-based components. If - * start_date/end_date are omitted, defaults to the current billing period. + * start_date/end_date are omitted, defaults to the current billing period, and the response + * then carries the running total (beta): what each metric's usage adds so far to the next + * invoice, and what they add up to, before discounts and credits. That reading is shared + * for up to 30 seconds (see computed_at). Counts towards the usage cost reads' + * rate limit. * * @param subscriptionId the {@code subscription_id} path parameter * @param options the optional parameters diff --git a/src/main/java/com/meteroid/api/UsageAsync.java b/src/main/java/com/meteroid/api/UsageAsync.java index 2fe953f..4af2fdd 100644 --- a/src/main/java/com/meteroid/api/UsageAsync.java +++ b/src/main/java/com/meteroid/api/UsageAsync.java @@ -16,6 +16,8 @@ public final class UsageAsync { private final Usage sync; private final WithRawResponse withRawResponse; + private final UsageCustomerAsync customer; + /** * The operations, sending through {@code sync}. * @@ -24,6 +26,8 @@ public final class UsageAsync { public UsageAsync(Usage sync) { this.sync = sync; this.withRawResponse = new WithRawResponse(); + + this.customer = new UsageCustomerAsync(sync.customer()); } /** @@ -36,96 +40,23 @@ public WithRawResponse withRawResponse() { } /** - * Get customer usage - * - *

Retrieve aggregated usage data for a customer over a specified period. - * - * @param customerId the {@code customer_id} path parameter - * @param startDate the {@code start_date} required parameter - * @param endDate the {@code end_date} required parameter - * @return the response body, once received - */ - public CompletableFuture retrieveCustomer( - final String customerId, final LocalDate startDate, final LocalDate endDate) { - return retrieveCustomer( - customerId, - startDate, - endDate, - UsageRetrieveCustomerOptions.none(), - RequestOptions.none()); - } - - /** - * Get customer usage - * - *

Retrieve aggregated usage data for a customer over a specified period. - * - * @param customerId the {@code customer_id} path parameter - * @param startDate the {@code start_date} required parameter - * @param endDate the {@code end_date} required parameter - * @param options the optional parameters - * @return the response body, once received - */ - public CompletableFuture retrieveCustomer( - final String customerId, - final LocalDate startDate, - final LocalDate endDate, - final UsageRetrieveCustomerOptions options) { - return retrieveCustomer(customerId, startDate, endDate, options, RequestOptions.none()); - } - - /** - * Get customer usage + * The {@code customer} operations. * - *

Retrieve aggregated usage data for a customer over a specified period. - * - * @param customerId the {@code customer_id} path parameter - * @param startDate the {@code start_date} required parameter - * @param endDate the {@code end_date} required parameter - * @param requestOptions headers, timeout and retries of this call - * @return the response body, once received + * @return the operations */ - public CompletableFuture retrieveCustomer( - final String customerId, - final LocalDate startDate, - final LocalDate endDate, - final RequestOptions requestOptions) { - return retrieveCustomer( - customerId, - startDate, - endDate, - UsageRetrieveCustomerOptions.none(), - requestOptions); - } - - /** - * Get customer usage - * - *

Retrieve aggregated usage data for a customer over a specified period. - * - * @param customerId the {@code customer_id} path parameter - * @param startDate the {@code start_date} required parameter - * @param endDate the {@code end_date} required parameter - * @param options the optional parameters - * @param requestOptions headers, timeout and retries of this call - * @return the response body, once received - */ - public CompletableFuture retrieveCustomer( - final String customerId, - final LocalDate startDate, - final LocalDate endDate, - final UsageRetrieveCustomerOptions options, - final RequestOptions requestOptions) { - return sync.exchangeRetrieveCustomer( - customerId, startDate, endDate, options, requestOptions) - .sendAsync(); + public UsageCustomerAsync customer() { + return customer; } /** * Get subscription usage * *

Retrieve aggregated usage data for a subscription's usage-based components. If - * start_date/end_date are omitted, defaults to the current billing period. + * start_date/end_date are omitted, defaults to the current billing period, and the response + * then carries the running total (beta): what each metric's usage adds so far to the next + * invoice, and what they add up to, before discounts and credits. That reading is shared for up + * to 30 seconds (see computed_at). Counts towards the usage cost reads' rate + * limit. * * @param subscriptionId the {@code subscription_id} path parameter * @return the response body, once received @@ -139,7 +70,11 @@ public CompletableFuture retrieveSubscription(final String subscr * Get subscription usage * *

Retrieve aggregated usage data for a subscription's usage-based components. If - * start_date/end_date are omitted, defaults to the current billing period. + * start_date/end_date are omitted, defaults to the current billing period, and the response + * then carries the running total (beta): what each metric's usage adds so far to the next + * invoice, and what they add up to, before discounts and credits. That reading is shared for up + * to 30 seconds (see computed_at). Counts towards the usage cost reads' rate + * limit. * * @param subscriptionId the {@code subscription_id} path parameter * @param options the optional parameters @@ -154,7 +89,11 @@ public CompletableFuture retrieveSubscription( * Get subscription usage * *

Retrieve aggregated usage data for a subscription's usage-based components. If - * start_date/end_date are omitted, defaults to the current billing period. + * start_date/end_date are omitted, defaults to the current billing period, and the response + * then carries the running total (beta): what each metric's usage adds so far to the next + * invoice, and what they add up to, before discounts and credits. That reading is shared for up + * to 30 seconds (see computed_at). Counts towards the usage cost reads' rate + * limit. * * @param subscriptionId the {@code subscription_id} path parameter * @param requestOptions headers, timeout and retries of this call @@ -170,7 +109,11 @@ public CompletableFuture retrieveSubscription( * Get subscription usage * *

Retrieve aggregated usage data for a subscription's usage-based components. If - * start_date/end_date are omitted, defaults to the current billing period. + * start_date/end_date are omitted, defaults to the current billing period, and the response + * then carries the running total (beta): what each metric's usage adds so far to the next + * invoice, and what they add up to, before discounts and credits. That reading is shared for up + * to 30 seconds (see computed_at). Counts towards the usage cost reads' rate + * limit. * * @param subscriptionId the {@code subscription_id} path parameter * @param options the optional parameters @@ -260,96 +203,23 @@ public final class WithRawResponse { private WithRawResponse() {} /** - * Get customer usage - * - *

Retrieve aggregated usage data for a customer over a specified period. + * The {@code customer} operations. * - * @param customerId the {@code customer_id} path parameter - * @param startDate the {@code start_date} required parameter - * @param endDate the {@code end_date} required parameter - * @return the status, headers and body, once received + * @return the operations */ - public CompletableFuture> retrieveCustomer( - final String customerId, final LocalDate startDate, final LocalDate endDate) { - return retrieveCustomer( - customerId, - startDate, - endDate, - UsageRetrieveCustomerOptions.none(), - RequestOptions.none()); - } - - /** - * Get customer usage - * - *

Retrieve aggregated usage data for a customer over a specified period. - * - * @param customerId the {@code customer_id} path parameter - * @param startDate the {@code start_date} required parameter - * @param endDate the {@code end_date} required parameter - * @param options the optional parameters - * @return the status, headers and body, once received - */ - public CompletableFuture> retrieveCustomer( - final String customerId, - final LocalDate startDate, - final LocalDate endDate, - final UsageRetrieveCustomerOptions options) { - return retrieveCustomer(customerId, startDate, endDate, options, RequestOptions.none()); - } - - /** - * Get customer usage - * - *

Retrieve aggregated usage data for a customer over a specified period. - * - * @param customerId the {@code customer_id} path parameter - * @param startDate the {@code start_date} required parameter - * @param endDate the {@code end_date} required parameter - * @param requestOptions headers, timeout and retries of this call - * @return the status, headers and body, once received - */ - public CompletableFuture> retrieveCustomer( - final String customerId, - final LocalDate startDate, - final LocalDate endDate, - final RequestOptions requestOptions) { - return retrieveCustomer( - customerId, - startDate, - endDate, - UsageRetrieveCustomerOptions.none(), - requestOptions); - } - - /** - * Get customer usage - * - *

Retrieve aggregated usage data for a customer over a specified period. - * - * @param customerId the {@code customer_id} path parameter - * @param startDate the {@code start_date} required parameter - * @param endDate the {@code end_date} required parameter - * @param options the optional parameters - * @param requestOptions headers, timeout and retries of this call - * @return the status, headers and body, once received - */ - public CompletableFuture> retrieveCustomer( - final String customerId, - final LocalDate startDate, - final LocalDate endDate, - final UsageRetrieveCustomerOptions options, - final RequestOptions requestOptions) { - return sync.exchangeRetrieveCustomer( - customerId, startDate, endDate, options, requestOptions) - .sendRawAsync(); + public UsageCustomerAsync.WithRawResponse customer() { + return UsageAsync.this.customer.withRawResponse(); } /** * Get subscription usage * *

Retrieve aggregated usage data for a subscription's usage-based components. If - * start_date/end_date are omitted, defaults to the current billing period. + * start_date/end_date are omitted, defaults to the current billing period, and the response + * then carries the running total (beta): what each metric's usage adds so far to the next + * invoice, and what they add up to, before discounts and credits. That reading is shared + * for up to 30 seconds (see computed_at). Counts towards the usage cost reads' + * rate limit. * * @param subscriptionId the {@code subscription_id} path parameter * @return the status, headers and body, once received @@ -364,7 +234,11 @@ public CompletableFuture> retrieveSubscription( * Get subscription usage * *

Retrieve aggregated usage data for a subscription's usage-based components. If - * start_date/end_date are omitted, defaults to the current billing period. + * start_date/end_date are omitted, defaults to the current billing period, and the response + * then carries the running total (beta): what each metric's usage adds so far to the next + * invoice, and what they add up to, before discounts and credits. That reading is shared + * for up to 30 seconds (see computed_at). Counts towards the usage cost reads' + * rate limit. * * @param subscriptionId the {@code subscription_id} path parameter * @param options the optional parameters @@ -379,7 +253,11 @@ public CompletableFuture> retrieveSubscription( * Get subscription usage * *

Retrieve aggregated usage data for a subscription's usage-based components. If - * start_date/end_date are omitted, defaults to the current billing period. + * start_date/end_date are omitted, defaults to the current billing period, and the response + * then carries the running total (beta): what each metric's usage adds so far to the next + * invoice, and what they add up to, before discounts and credits. That reading is shared + * for up to 30 seconds (see computed_at). Counts towards the usage cost reads' + * rate limit. * * @param subscriptionId the {@code subscription_id} path parameter * @param requestOptions headers, timeout and retries of this call @@ -395,7 +273,11 @@ public CompletableFuture> retrieveSubscription( * Get subscription usage * *

Retrieve aggregated usage data for a subscription's usage-based components. If - * start_date/end_date are omitted, defaults to the current billing period. + * start_date/end_date are omitted, defaults to the current billing period, and the response + * then carries the running total (beta): what each metric's usage adds so far to the next + * invoice, and what they add up to, before discounts and credits. That reading is shared + * for up to 30 seconds (see computed_at). Counts towards the usage cost reads' + * rate limit. * * @param subscriptionId the {@code subscription_id} path parameter * @param options the optional parameters diff --git a/src/main/java/com/meteroid/api/UsageCosts.java b/src/main/java/com/meteroid/api/UsageCosts.java new file mode 100644 index 0000000..a96de7e --- /dev/null +++ b/src/main/java/com/meteroid/api/UsageCosts.java @@ -0,0 +1,81 @@ +// this file is @generated +package com.meteroid.api; + +import com.meteroid.internal.MeteroidHttpClient; + +/** + * The {@code usage_costs} operations, blocking. {@link #withRawResponse()} has the same methods + * returning the status and headers along with the body. + */ +public final class UsageCosts { + private final MeteroidHttpClient client; + private final WithRawResponse withRawResponse; + + private final UsageCostsCustomer customer; + + private final UsageCostsSubscription subscription; + + /** + * The operations, sending through {@code client}. + * + * @param client the HTTP client of the SDK + */ + public UsageCosts(MeteroidHttpClient client) { + this.client = client; + this.withRawResponse = new WithRawResponse(); + + this.customer = new UsageCostsCustomer(client); + + this.subscription = new UsageCostsSubscription(client); + } + + /** + * The same operations, returning the status and headers along with the body. + * + * @return the operations + */ + public WithRawResponse withRawResponse() { + return withRawResponse; + } + + /** + * The {@code customer} operations. + * + * @return the operations + */ + public UsageCostsCustomer customer() { + return customer; + } + + /** + * The {@code subscription} operations. + * + * @return the operations + */ + public UsageCostsSubscription subscription() { + return subscription; + } + + /** The operations, returning the status and headers along with the body. */ + public final class WithRawResponse { + private WithRawResponse() {} + + /** + * The {@code customer} operations. + * + * @return the operations + */ + public UsageCostsCustomer.WithRawResponse customer() { + return UsageCosts.this.customer.withRawResponse(); + } + + /** + * The {@code subscription} operations. + * + * @return the operations + */ + public UsageCostsSubscription.WithRawResponse subscription() { + return UsageCosts.this.subscription.withRawResponse(); + } + } +} diff --git a/src/main/java/com/meteroid/api/UsageCostsAsync.java b/src/main/java/com/meteroid/api/UsageCostsAsync.java new file mode 100644 index 0000000..43f14dc --- /dev/null +++ b/src/main/java/com/meteroid/api/UsageCostsAsync.java @@ -0,0 +1,81 @@ +// this file is @generated +package com.meteroid.api; + +import java.util.concurrent.CompletableFuture; + +/** + * The {@code usage_costs} operations, without blocking: each method returns a {@link + * CompletableFuture}. Obtained from {@code client.async()}. + */ +public final class UsageCostsAsync { + private final UsageCosts sync; + private final WithRawResponse withRawResponse; + + private final UsageCostsCustomerAsync customer; + + private final UsageCostsSubscriptionAsync subscription; + + /** + * The operations, sending through {@code sync}. + * + * @param sync the blocking operations + */ + public UsageCostsAsync(UsageCosts sync) { + this.sync = sync; + this.withRawResponse = new WithRawResponse(); + + this.customer = new UsageCostsCustomerAsync(sync.customer()); + + this.subscription = new UsageCostsSubscriptionAsync(sync.subscription()); + } + + /** + * The same operations, returning the status and headers along with the body. + * + * @return the operations + */ + public WithRawResponse withRawResponse() { + return withRawResponse; + } + + /** + * The {@code customer} operations. + * + * @return the operations + */ + public UsageCostsCustomerAsync customer() { + return customer; + } + + /** + * The {@code subscription} operations. + * + * @return the operations + */ + public UsageCostsSubscriptionAsync subscription() { + return subscription; + } + + /** The operations, returning the status and headers along with the body. */ + public final class WithRawResponse { + private WithRawResponse() {} + + /** + * The {@code customer} operations. + * + * @return the operations + */ + public UsageCostsCustomerAsync.WithRawResponse customer() { + return UsageCostsAsync.this.customer.withRawResponse(); + } + + /** + * The {@code subscription} operations. + * + * @return the operations + */ + public UsageCostsSubscriptionAsync.WithRawResponse subscription() { + return UsageCostsAsync.this.subscription.withRawResponse(); + } + } +} diff --git a/src/main/java/com/meteroid/api/UsageCostsCustomer.java b/src/main/java/com/meteroid/api/UsageCostsCustomer.java new file mode 100644 index 0000000..82a9f03 --- /dev/null +++ b/src/main/java/com/meteroid/api/UsageCostsCustomer.java @@ -0,0 +1,654 @@ +// this file is @generated +package com.meteroid.api; + +import com.meteroid.ApiResponse; +import com.meteroid.RequestOptions; +import com.meteroid.internal.MeteroidHttpClient; +import com.meteroid.internal.Utils; +import com.meteroid.models.ListCustomerUsageCostsGranularity; +import com.meteroid.models.UsageCostListResponse; +import com.meteroid.models.UsageEventListResponse; + +import okhttp3.HttpUrl; + +import java.time.OffsetDateTime; +import java.util.Objects; + +/** + * The {@code usage_costs.customer} operations, blocking. {@link #withRawResponse()} has the same + * methods returning the status and headers along with the body. + */ +public final class UsageCostsCustomer { + private final MeteroidHttpClient client; + private final WithRawResponse withRawResponse; + + /** + * The operations, sending through {@code client}. + * + * @param client the HTTP client of the SDK + */ + public UsageCostsCustomer(MeteroidHttpClient client) { + this.client = client; + this.withRawResponse = new WithRawResponse(); + } + + /** + * The same operations, returning the status and headers along with the body. + * + * @return the operations + */ + public WithRawResponse withRawResponse() { + return withRawResponse; + } + + /** + * List a customer's usage costs over time + * + *

A customer's usage of one billable metric and what it costs, per hour, day or month, + * optionally split by an event property, summed across the subscriptions that bill it. Buckets + * are cut at UTC boundaries and only cover the customer's billing periods. Per-unit and matrix + * pricing give exact costs. For pricing that depends on the whole period's usage (tiered, + * volume, package, capacity), a bucket's cost is what it adds to the period's price so far and + * exact is false. The range is at most 93 days. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param customerId the {@code customer_id} path parameter + * @param metric the {@code metric} required parameter + * @param granularity the {@code granularity} required parameter + * @param from the {@code from} required parameter + * @param to the {@code to} required parameter + * @return the response body + */ + public UsageCostListResponse listCosts( + final String customerId, + final String metric, + final ListCustomerUsageCostsGranularity granularity, + final OffsetDateTime from, + final OffsetDateTime to) { + return listCosts( + customerId, + metric, + granularity, + from, + to, + UsageCostsCustomerListCostsOptions.none(), + RequestOptions.none()); + } + + /** + * List a customer's usage costs over time + * + *

A customer's usage of one billable metric and what it costs, per hour, day or month, + * optionally split by an event property, summed across the subscriptions that bill it. Buckets + * are cut at UTC boundaries and only cover the customer's billing periods. Per-unit and matrix + * pricing give exact costs. For pricing that depends on the whole period's usage (tiered, + * volume, package, capacity), a bucket's cost is what it adds to the period's price so far and + * exact is false. The range is at most 93 days. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param customerId the {@code customer_id} path parameter + * @param metric the {@code metric} required parameter + * @param granularity the {@code granularity} required parameter + * @param from the {@code from} required parameter + * @param to the {@code to} required parameter + * @param options the optional parameters + * @return the response body + */ + public UsageCostListResponse listCosts( + final String customerId, + final String metric, + final ListCustomerUsageCostsGranularity granularity, + final OffsetDateTime from, + final OffsetDateTime to, + final UsageCostsCustomerListCostsOptions options) { + return listCosts(customerId, metric, granularity, from, to, options, RequestOptions.none()); + } + + /** + * List a customer's usage costs over time + * + *

A customer's usage of one billable metric and what it costs, per hour, day or month, + * optionally split by an event property, summed across the subscriptions that bill it. Buckets + * are cut at UTC boundaries and only cover the customer's billing periods. Per-unit and matrix + * pricing give exact costs. For pricing that depends on the whole period's usage (tiered, + * volume, package, capacity), a bucket's cost is what it adds to the period's price so far and + * exact is false. The range is at most 93 days. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param customerId the {@code customer_id} path parameter + * @param metric the {@code metric} required parameter + * @param granularity the {@code granularity} required parameter + * @param from the {@code from} required parameter + * @param to the {@code to} required parameter + * @param requestOptions headers, timeout and retries of this call + * @return the response body + */ + public UsageCostListResponse listCosts( + final String customerId, + final String metric, + final ListCustomerUsageCostsGranularity granularity, + final OffsetDateTime from, + final OffsetDateTime to, + final RequestOptions requestOptions) { + return listCosts( + customerId, + metric, + granularity, + from, + to, + UsageCostsCustomerListCostsOptions.none(), + requestOptions); + } + + /** + * List a customer's usage costs over time + * + *

A customer's usage of one billable metric and what it costs, per hour, day or month, + * optionally split by an event property, summed across the subscriptions that bill it. Buckets + * are cut at UTC boundaries and only cover the customer's billing periods. Per-unit and matrix + * pricing give exact costs. For pricing that depends on the whole period's usage (tiered, + * volume, package, capacity), a bucket's cost is what it adds to the period's price so far and + * exact is false. The range is at most 93 days. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param customerId the {@code customer_id} path parameter + * @param metric the {@code metric} required parameter + * @param granularity the {@code granularity} required parameter + * @param from the {@code from} required parameter + * @param to the {@code to} required parameter + * @param options the optional parameters + * @param requestOptions headers, timeout and retries of this call + * @return the response body + */ + public UsageCostListResponse listCosts( + final String customerId, + final String metric, + final ListCustomerUsageCostsGranularity granularity, + final OffsetDateTime from, + final OffsetDateTime to, + final UsageCostsCustomerListCostsOptions options, + final RequestOptions requestOptions) { + return exchangeListCosts(customerId, metric, granularity, from, to, options, requestOptions) + .send(); + } + + MeteroidHttpClient.Exchange exchangeListCosts( + final String customerId, + final String metric, + final ListCustomerUsageCostsGranularity granularity, + final OffsetDateTime from, + final OffsetDateTime to, + final UsageCostsCustomerListCostsOptions options, + final RequestOptions requestOptions) { + Objects.requireNonNull(customerId, "customer_id"); + Objects.requireNonNull(metric, "metric"); + Objects.requireNonNull(granularity, "granularity"); + Objects.requireNonNull(from, "from"); + Objects.requireNonNull(to, "to"); + Objects.requireNonNull(options, "options"); + HttpUrl.Builder url = + client.newUrlBuilder() + .addPathSegments("api/v1/usage/customer") + .addPathSegment(Utils.pathSegment("customer_id", customerId)) + .addPathSegments("costs"); + url.addQueryParameter("metric", metric); + String value2 = options.groupBy().orElse(null); + if (value2 != null) { + url.addQueryParameter("group_by", value2); + } + url.addQueryParameter("granularity", Utils.serializeQueryParam(granularity)); + url.addQueryParameter("from", Utils.serializeQueryParam(from)); + url.addQueryParameter("to", Utils.serializeQueryParam(to)); + return client.call("GET", url.build()) + .errors( + com.meteroid.models.RestErrorResponse.class, + "400", + "401", + "404", + "429", + "500") + .options(requestOptions) + .returning(UsageCostListResponse.class); + } + + /** + * List a customer's usage events with their cost + * + *

A customer's events for one billable metric, oldest first, each with the units it adds and + * what they cost at the price in force. The cost is exact for per-unit and matrix pricing and + * absent for pricing that depends on the whole period's usage (tiered, volume, package, + * capacity) and for aggregations that cannot be split per event. The range is at most 93 days. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param customerId the {@code customer_id} path parameter + * @param metric the {@code metric} required parameter + * @param from the {@code from} required parameter + * @param to the {@code to} required parameter + * @return the response body + */ + public UsageEventListResponse listEvents( + final String customerId, + final String metric, + final OffsetDateTime from, + final OffsetDateTime to) { + return listEvents( + customerId, + metric, + from, + to, + UsageCostsCustomerListEventsOptions.none(), + RequestOptions.none()); + } + + /** + * List a customer's usage events with their cost + * + *

A customer's events for one billable metric, oldest first, each with the units it adds and + * what they cost at the price in force. The cost is exact for per-unit and matrix pricing and + * absent for pricing that depends on the whole period's usage (tiered, volume, package, + * capacity) and for aggregations that cannot be split per event. The range is at most 93 days. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param customerId the {@code customer_id} path parameter + * @param metric the {@code metric} required parameter + * @param from the {@code from} required parameter + * @param to the {@code to} required parameter + * @param options the optional parameters + * @return the response body + */ + public UsageEventListResponse listEvents( + final String customerId, + final String metric, + final OffsetDateTime from, + final OffsetDateTime to, + final UsageCostsCustomerListEventsOptions options) { + return listEvents(customerId, metric, from, to, options, RequestOptions.none()); + } + + /** + * List a customer's usage events with their cost + * + *

A customer's events for one billable metric, oldest first, each with the units it adds and + * what they cost at the price in force. The cost is exact for per-unit and matrix pricing and + * absent for pricing that depends on the whole period's usage (tiered, volume, package, + * capacity) and for aggregations that cannot be split per event. The range is at most 93 days. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param customerId the {@code customer_id} path parameter + * @param metric the {@code metric} required parameter + * @param from the {@code from} required parameter + * @param to the {@code to} required parameter + * @param requestOptions headers, timeout and retries of this call + * @return the response body + */ + public UsageEventListResponse listEvents( + final String customerId, + final String metric, + final OffsetDateTime from, + final OffsetDateTime to, + final RequestOptions requestOptions) { + return listEvents( + customerId, + metric, + from, + to, + UsageCostsCustomerListEventsOptions.none(), + requestOptions); + } + + /** + * List a customer's usage events with their cost + * + *

A customer's events for one billable metric, oldest first, each with the units it adds and + * what they cost at the price in force. The cost is exact for per-unit and matrix pricing and + * absent for pricing that depends on the whole period's usage (tiered, volume, package, + * capacity) and for aggregations that cannot be split per event. The range is at most 93 days. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param customerId the {@code customer_id} path parameter + * @param metric the {@code metric} required parameter + * @param from the {@code from} required parameter + * @param to the {@code to} required parameter + * @param options the optional parameters + * @param requestOptions headers, timeout and retries of this call + * @return the response body + */ + public UsageEventListResponse listEvents( + final String customerId, + final String metric, + final OffsetDateTime from, + final OffsetDateTime to, + final UsageCostsCustomerListEventsOptions options, + final RequestOptions requestOptions) { + return exchangeListEvents(customerId, metric, from, to, options, requestOptions).send(); + } + + MeteroidHttpClient.Exchange exchangeListEvents( + final String customerId, + final String metric, + final OffsetDateTime from, + final OffsetDateTime to, + final UsageCostsCustomerListEventsOptions options, + final RequestOptions requestOptions) { + Objects.requireNonNull(customerId, "customer_id"); + Objects.requireNonNull(metric, "metric"); + Objects.requireNonNull(from, "from"); + Objects.requireNonNull(to, "to"); + Objects.requireNonNull(options, "options"); + HttpUrl.Builder url = + client.newUrlBuilder() + .addPathSegments("api/v1/usage/customer") + .addPathSegment(Utils.pathSegment("customer_id", customerId)) + .addPathSegments("events"); + url.addQueryParameter("metric", metric); + url.addQueryParameter("from", Utils.serializeQueryParam(from)); + url.addQueryParameter("to", Utils.serializeQueryParam(to)); + String value4 = options.cursor().orElse(null); + if (value4 != null) { + url.addQueryParameter("cursor", value4); + } + Integer value5 = options.limit().orElse(null); + if (value5 != null) { + url.addQueryParameter("limit", Utils.serializeQueryParam(value5)); + } + return client.call("GET", url.build()) + .errors( + com.meteroid.models.RestErrorResponse.class, + "400", + "401", + "404", + "429", + "500") + .options(requestOptions) + .returning(UsageEventListResponse.class); + } + + /** The operations, returning the status and headers along with the body. */ + public final class WithRawResponse { + private WithRawResponse() {} + + /** + * List a customer's usage costs over time + * + *

A customer's usage of one billable metric and what it costs, per hour, day or month, + * optionally split by an event property, summed across the subscriptions that bill it. + * Buckets are cut at UTC boundaries and only cover the customer's billing periods. Per-unit + * and matrix pricing give exact costs. For pricing that depends on the whole period's usage + * (tiered, volume, package, capacity), a bucket's cost is what it adds to the period's + * price so far and exact is false. The range is at most 93 days. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param customerId the {@code customer_id} path parameter + * @param metric the {@code metric} required parameter + * @param granularity the {@code granularity} required parameter + * @param from the {@code from} required parameter + * @param to the {@code to} required parameter + * @return the status, headers and body + */ + public ApiResponse listCosts( + final String customerId, + final String metric, + final ListCustomerUsageCostsGranularity granularity, + final OffsetDateTime from, + final OffsetDateTime to) { + return listCosts( + customerId, + metric, + granularity, + from, + to, + UsageCostsCustomerListCostsOptions.none(), + RequestOptions.none()); + } + + /** + * List a customer's usage costs over time + * + *

A customer's usage of one billable metric and what it costs, per hour, day or month, + * optionally split by an event property, summed across the subscriptions that bill it. + * Buckets are cut at UTC boundaries and only cover the customer's billing periods. Per-unit + * and matrix pricing give exact costs. For pricing that depends on the whole period's usage + * (tiered, volume, package, capacity), a bucket's cost is what it adds to the period's + * price so far and exact is false. The range is at most 93 days. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param customerId the {@code customer_id} path parameter + * @param metric the {@code metric} required parameter + * @param granularity the {@code granularity} required parameter + * @param from the {@code from} required parameter + * @param to the {@code to} required parameter + * @param options the optional parameters + * @return the status, headers and body + */ + public ApiResponse listCosts( + final String customerId, + final String metric, + final ListCustomerUsageCostsGranularity granularity, + final OffsetDateTime from, + final OffsetDateTime to, + final UsageCostsCustomerListCostsOptions options) { + return listCosts( + customerId, metric, granularity, from, to, options, RequestOptions.none()); + } + + /** + * List a customer's usage costs over time + * + *

A customer's usage of one billable metric and what it costs, per hour, day or month, + * optionally split by an event property, summed across the subscriptions that bill it. + * Buckets are cut at UTC boundaries and only cover the customer's billing periods. Per-unit + * and matrix pricing give exact costs. For pricing that depends on the whole period's usage + * (tiered, volume, package, capacity), a bucket's cost is what it adds to the period's + * price so far and exact is false. The range is at most 93 days. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param customerId the {@code customer_id} path parameter + * @param metric the {@code metric} required parameter + * @param granularity the {@code granularity} required parameter + * @param from the {@code from} required parameter + * @param to the {@code to} required parameter + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body + */ + public ApiResponse listCosts( + final String customerId, + final String metric, + final ListCustomerUsageCostsGranularity granularity, + final OffsetDateTime from, + final OffsetDateTime to, + final RequestOptions requestOptions) { + return listCosts( + customerId, + metric, + granularity, + from, + to, + UsageCostsCustomerListCostsOptions.none(), + requestOptions); + } + + /** + * List a customer's usage costs over time + * + *

A customer's usage of one billable metric and what it costs, per hour, day or month, + * optionally split by an event property, summed across the subscriptions that bill it. + * Buckets are cut at UTC boundaries and only cover the customer's billing periods. Per-unit + * and matrix pricing give exact costs. For pricing that depends on the whole period's usage + * (tiered, volume, package, capacity), a bucket's cost is what it adds to the period's + * price so far and exact is false. The range is at most 93 days. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param customerId the {@code customer_id} path parameter + * @param metric the {@code metric} required parameter + * @param granularity the {@code granularity} required parameter + * @param from the {@code from} required parameter + * @param to the {@code to} required parameter + * @param options the optional parameters + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body + */ + public ApiResponse listCosts( + final String customerId, + final String metric, + final ListCustomerUsageCostsGranularity granularity, + final OffsetDateTime from, + final OffsetDateTime to, + final UsageCostsCustomerListCostsOptions options, + final RequestOptions requestOptions) { + return UsageCostsCustomer.this + .exchangeListCosts( + customerId, metric, granularity, from, to, options, requestOptions) + .sendRaw(); + } + + /** + * List a customer's usage events with their cost + * + *

A customer's events for one billable metric, oldest first, each with the units it adds + * and what they cost at the price in force. The cost is exact for per-unit and matrix + * pricing and absent for pricing that depends on the whole period's usage (tiered, volume, + * package, capacity) and for aggregations that cannot be split per event. The range is at + * most 93 days. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param customerId the {@code customer_id} path parameter + * @param metric the {@code metric} required parameter + * @param from the {@code from} required parameter + * @param to the {@code to} required parameter + * @return the status, headers and body + */ + public ApiResponse listEvents( + final String customerId, + final String metric, + final OffsetDateTime from, + final OffsetDateTime to) { + return listEvents( + customerId, + metric, + from, + to, + UsageCostsCustomerListEventsOptions.none(), + RequestOptions.none()); + } + + /** + * List a customer's usage events with their cost + * + *

A customer's events for one billable metric, oldest first, each with the units it adds + * and what they cost at the price in force. The cost is exact for per-unit and matrix + * pricing and absent for pricing that depends on the whole period's usage (tiered, volume, + * package, capacity) and for aggregations that cannot be split per event. The range is at + * most 93 days. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param customerId the {@code customer_id} path parameter + * @param metric the {@code metric} required parameter + * @param from the {@code from} required parameter + * @param to the {@code to} required parameter + * @param options the optional parameters + * @return the status, headers and body + */ + public ApiResponse listEvents( + final String customerId, + final String metric, + final OffsetDateTime from, + final OffsetDateTime to, + final UsageCostsCustomerListEventsOptions options) { + return listEvents(customerId, metric, from, to, options, RequestOptions.none()); + } + + /** + * List a customer's usage events with their cost + * + *

A customer's events for one billable metric, oldest first, each with the units it adds + * and what they cost at the price in force. The cost is exact for per-unit and matrix + * pricing and absent for pricing that depends on the whole period's usage (tiered, volume, + * package, capacity) and for aggregations that cannot be split per event. The range is at + * most 93 days. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param customerId the {@code customer_id} path parameter + * @param metric the {@code metric} required parameter + * @param from the {@code from} required parameter + * @param to the {@code to} required parameter + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body + */ + public ApiResponse listEvents( + final String customerId, + final String metric, + final OffsetDateTime from, + final OffsetDateTime to, + final RequestOptions requestOptions) { + return listEvents( + customerId, + metric, + from, + to, + UsageCostsCustomerListEventsOptions.none(), + requestOptions); + } + + /** + * List a customer's usage events with their cost + * + *

A customer's events for one billable metric, oldest first, each with the units it adds + * and what they cost at the price in force. The cost is exact for per-unit and matrix + * pricing and absent for pricing that depends on the whole period's usage (tiered, volume, + * package, capacity) and for aggregations that cannot be split per event. The range is at + * most 93 days. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param customerId the {@code customer_id} path parameter + * @param metric the {@code metric} required parameter + * @param from the {@code from} required parameter + * @param to the {@code to} required parameter + * @param options the optional parameters + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body + */ + public ApiResponse listEvents( + final String customerId, + final String metric, + final OffsetDateTime from, + final OffsetDateTime to, + final UsageCostsCustomerListEventsOptions options, + final RequestOptions requestOptions) { + return UsageCostsCustomer.this + .exchangeListEvents(customerId, metric, from, to, options, requestOptions) + .sendRaw(); + } + } +} diff --git a/src/main/java/com/meteroid/api/UsageCostsCustomerAsync.java b/src/main/java/com/meteroid/api/UsageCostsCustomerAsync.java new file mode 100644 index 0000000..3cf0852 --- /dev/null +++ b/src/main/java/com/meteroid/api/UsageCostsCustomerAsync.java @@ -0,0 +1,571 @@ +// this file is @generated +package com.meteroid.api; + +import com.meteroid.ApiResponse; +import com.meteroid.RequestOptions; +import com.meteroid.models.ListCustomerUsageCostsGranularity; +import com.meteroid.models.UsageCostListResponse; +import com.meteroid.models.UsageEventListResponse; + +import java.time.OffsetDateTime; +import java.util.concurrent.CompletableFuture; + +/** + * The {@code usage_costs.customer} operations, without blocking: each method returns a {@link + * CompletableFuture}. Obtained from {@code client.async()}. + */ +public final class UsageCostsCustomerAsync { + private final UsageCostsCustomer sync; + private final WithRawResponse withRawResponse; + + /** + * The operations, sending through {@code sync}. + * + * @param sync the blocking operations + */ + public UsageCostsCustomerAsync(UsageCostsCustomer sync) { + this.sync = sync; + this.withRawResponse = new WithRawResponse(); + } + + /** + * The same operations, returning the status and headers along with the body. + * + * @return the operations + */ + public WithRawResponse withRawResponse() { + return withRawResponse; + } + + /** + * List a customer's usage costs over time + * + *

A customer's usage of one billable metric and what it costs, per hour, day or month, + * optionally split by an event property, summed across the subscriptions that bill it. Buckets + * are cut at UTC boundaries and only cover the customer's billing periods. Per-unit and matrix + * pricing give exact costs. For pricing that depends on the whole period's usage (tiered, + * volume, package, capacity), a bucket's cost is what it adds to the period's price so far and + * exact is false. The range is at most 93 days. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param customerId the {@code customer_id} path parameter + * @param metric the {@code metric} required parameter + * @param granularity the {@code granularity} required parameter + * @param from the {@code from} required parameter + * @param to the {@code to} required parameter + * @return the response body, once received + */ + public CompletableFuture listCosts( + final String customerId, + final String metric, + final ListCustomerUsageCostsGranularity granularity, + final OffsetDateTime from, + final OffsetDateTime to) { + return listCosts( + customerId, + metric, + granularity, + from, + to, + UsageCostsCustomerListCostsOptions.none(), + RequestOptions.none()); + } + + /** + * List a customer's usage costs over time + * + *

A customer's usage of one billable metric and what it costs, per hour, day or month, + * optionally split by an event property, summed across the subscriptions that bill it. Buckets + * are cut at UTC boundaries and only cover the customer's billing periods. Per-unit and matrix + * pricing give exact costs. For pricing that depends on the whole period's usage (tiered, + * volume, package, capacity), a bucket's cost is what it adds to the period's price so far and + * exact is false. The range is at most 93 days. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param customerId the {@code customer_id} path parameter + * @param metric the {@code metric} required parameter + * @param granularity the {@code granularity} required parameter + * @param from the {@code from} required parameter + * @param to the {@code to} required parameter + * @param options the optional parameters + * @return the response body, once received + */ + public CompletableFuture listCosts( + final String customerId, + final String metric, + final ListCustomerUsageCostsGranularity granularity, + final OffsetDateTime from, + final OffsetDateTime to, + final UsageCostsCustomerListCostsOptions options) { + return listCosts(customerId, metric, granularity, from, to, options, RequestOptions.none()); + } + + /** + * List a customer's usage costs over time + * + *

A customer's usage of one billable metric and what it costs, per hour, day or month, + * optionally split by an event property, summed across the subscriptions that bill it. Buckets + * are cut at UTC boundaries and only cover the customer's billing periods. Per-unit and matrix + * pricing give exact costs. For pricing that depends on the whole period's usage (tiered, + * volume, package, capacity), a bucket's cost is what it adds to the period's price so far and + * exact is false. The range is at most 93 days. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param customerId the {@code customer_id} path parameter + * @param metric the {@code metric} required parameter + * @param granularity the {@code granularity} required parameter + * @param from the {@code from} required parameter + * @param to the {@code to} required parameter + * @param requestOptions headers, timeout and retries of this call + * @return the response body, once received + */ + public CompletableFuture listCosts( + final String customerId, + final String metric, + final ListCustomerUsageCostsGranularity granularity, + final OffsetDateTime from, + final OffsetDateTime to, + final RequestOptions requestOptions) { + return listCosts( + customerId, + metric, + granularity, + from, + to, + UsageCostsCustomerListCostsOptions.none(), + requestOptions); + } + + /** + * List a customer's usage costs over time + * + *

A customer's usage of one billable metric and what it costs, per hour, day or month, + * optionally split by an event property, summed across the subscriptions that bill it. Buckets + * are cut at UTC boundaries and only cover the customer's billing periods. Per-unit and matrix + * pricing give exact costs. For pricing that depends on the whole period's usage (tiered, + * volume, package, capacity), a bucket's cost is what it adds to the period's price so far and + * exact is false. The range is at most 93 days. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param customerId the {@code customer_id} path parameter + * @param metric the {@code metric} required parameter + * @param granularity the {@code granularity} required parameter + * @param from the {@code from} required parameter + * @param to the {@code to} required parameter + * @param options the optional parameters + * @param requestOptions headers, timeout and retries of this call + * @return the response body, once received + */ + public CompletableFuture listCosts( + final String customerId, + final String metric, + final ListCustomerUsageCostsGranularity granularity, + final OffsetDateTime from, + final OffsetDateTime to, + final UsageCostsCustomerListCostsOptions options, + final RequestOptions requestOptions) { + return sync.exchangeListCosts( + customerId, metric, granularity, from, to, options, requestOptions) + .sendAsync(); + } + + /** + * List a customer's usage events with their cost + * + *

A customer's events for one billable metric, oldest first, each with the units it adds and + * what they cost at the price in force. The cost is exact for per-unit and matrix pricing and + * absent for pricing that depends on the whole period's usage (tiered, volume, package, + * capacity) and for aggregations that cannot be split per event. The range is at most 93 days. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param customerId the {@code customer_id} path parameter + * @param metric the {@code metric} required parameter + * @param from the {@code from} required parameter + * @param to the {@code to} required parameter + * @return the response body, once received + */ + public CompletableFuture listEvents( + final String customerId, + final String metric, + final OffsetDateTime from, + final OffsetDateTime to) { + return listEvents( + customerId, + metric, + from, + to, + UsageCostsCustomerListEventsOptions.none(), + RequestOptions.none()); + } + + /** + * List a customer's usage events with their cost + * + *

A customer's events for one billable metric, oldest first, each with the units it adds and + * what they cost at the price in force. The cost is exact for per-unit and matrix pricing and + * absent for pricing that depends on the whole period's usage (tiered, volume, package, + * capacity) and for aggregations that cannot be split per event. The range is at most 93 days. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param customerId the {@code customer_id} path parameter + * @param metric the {@code metric} required parameter + * @param from the {@code from} required parameter + * @param to the {@code to} required parameter + * @param options the optional parameters + * @return the response body, once received + */ + public CompletableFuture listEvents( + final String customerId, + final String metric, + final OffsetDateTime from, + final OffsetDateTime to, + final UsageCostsCustomerListEventsOptions options) { + return listEvents(customerId, metric, from, to, options, RequestOptions.none()); + } + + /** + * List a customer's usage events with their cost + * + *

A customer's events for one billable metric, oldest first, each with the units it adds and + * what they cost at the price in force. The cost is exact for per-unit and matrix pricing and + * absent for pricing that depends on the whole period's usage (tiered, volume, package, + * capacity) and for aggregations that cannot be split per event. The range is at most 93 days. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param customerId the {@code customer_id} path parameter + * @param metric the {@code metric} required parameter + * @param from the {@code from} required parameter + * @param to the {@code to} required parameter + * @param requestOptions headers, timeout and retries of this call + * @return the response body, once received + */ + public CompletableFuture listEvents( + final String customerId, + final String metric, + final OffsetDateTime from, + final OffsetDateTime to, + final RequestOptions requestOptions) { + return listEvents( + customerId, + metric, + from, + to, + UsageCostsCustomerListEventsOptions.none(), + requestOptions); + } + + /** + * List a customer's usage events with their cost + * + *

A customer's events for one billable metric, oldest first, each with the units it adds and + * what they cost at the price in force. The cost is exact for per-unit and matrix pricing and + * absent for pricing that depends on the whole period's usage (tiered, volume, package, + * capacity) and for aggregations that cannot be split per event. The range is at most 93 days. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param customerId the {@code customer_id} path parameter + * @param metric the {@code metric} required parameter + * @param from the {@code from} required parameter + * @param to the {@code to} required parameter + * @param options the optional parameters + * @param requestOptions headers, timeout and retries of this call + * @return the response body, once received + */ + public CompletableFuture listEvents( + final String customerId, + final String metric, + final OffsetDateTime from, + final OffsetDateTime to, + final UsageCostsCustomerListEventsOptions options, + final RequestOptions requestOptions) { + return sync.exchangeListEvents(customerId, metric, from, to, options, requestOptions) + .sendAsync(); + } + + /** The operations, returning the status and headers along with the body. */ + public final class WithRawResponse { + private WithRawResponse() {} + + /** + * List a customer's usage costs over time + * + *

A customer's usage of one billable metric and what it costs, per hour, day or month, + * optionally split by an event property, summed across the subscriptions that bill it. + * Buckets are cut at UTC boundaries and only cover the customer's billing periods. Per-unit + * and matrix pricing give exact costs. For pricing that depends on the whole period's usage + * (tiered, volume, package, capacity), a bucket's cost is what it adds to the period's + * price so far and exact is false. The range is at most 93 days. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param customerId the {@code customer_id} path parameter + * @param metric the {@code metric} required parameter + * @param granularity the {@code granularity} required parameter + * @param from the {@code from} required parameter + * @param to the {@code to} required parameter + * @return the status, headers and body, once received + */ + public CompletableFuture> listCosts( + final String customerId, + final String metric, + final ListCustomerUsageCostsGranularity granularity, + final OffsetDateTime from, + final OffsetDateTime to) { + return listCosts( + customerId, + metric, + granularity, + from, + to, + UsageCostsCustomerListCostsOptions.none(), + RequestOptions.none()); + } + + /** + * List a customer's usage costs over time + * + *

A customer's usage of one billable metric and what it costs, per hour, day or month, + * optionally split by an event property, summed across the subscriptions that bill it. + * Buckets are cut at UTC boundaries and only cover the customer's billing periods. Per-unit + * and matrix pricing give exact costs. For pricing that depends on the whole period's usage + * (tiered, volume, package, capacity), a bucket's cost is what it adds to the period's + * price so far and exact is false. The range is at most 93 days. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param customerId the {@code customer_id} path parameter + * @param metric the {@code metric} required parameter + * @param granularity the {@code granularity} required parameter + * @param from the {@code from} required parameter + * @param to the {@code to} required parameter + * @param options the optional parameters + * @return the status, headers and body, once received + */ + public CompletableFuture> listCosts( + final String customerId, + final String metric, + final ListCustomerUsageCostsGranularity granularity, + final OffsetDateTime from, + final OffsetDateTime to, + final UsageCostsCustomerListCostsOptions options) { + return listCosts( + customerId, metric, granularity, from, to, options, RequestOptions.none()); + } + + /** + * List a customer's usage costs over time + * + *

A customer's usage of one billable metric and what it costs, per hour, day or month, + * optionally split by an event property, summed across the subscriptions that bill it. + * Buckets are cut at UTC boundaries and only cover the customer's billing periods. Per-unit + * and matrix pricing give exact costs. For pricing that depends on the whole period's usage + * (tiered, volume, package, capacity), a bucket's cost is what it adds to the period's + * price so far and exact is false. The range is at most 93 days. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param customerId the {@code customer_id} path parameter + * @param metric the {@code metric} required parameter + * @param granularity the {@code granularity} required parameter + * @param from the {@code from} required parameter + * @param to the {@code to} required parameter + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body, once received + */ + public CompletableFuture> listCosts( + final String customerId, + final String metric, + final ListCustomerUsageCostsGranularity granularity, + final OffsetDateTime from, + final OffsetDateTime to, + final RequestOptions requestOptions) { + return listCosts( + customerId, + metric, + granularity, + from, + to, + UsageCostsCustomerListCostsOptions.none(), + requestOptions); + } + + /** + * List a customer's usage costs over time + * + *

A customer's usage of one billable metric and what it costs, per hour, day or month, + * optionally split by an event property, summed across the subscriptions that bill it. + * Buckets are cut at UTC boundaries and only cover the customer's billing periods. Per-unit + * and matrix pricing give exact costs. For pricing that depends on the whole period's usage + * (tiered, volume, package, capacity), a bucket's cost is what it adds to the period's + * price so far and exact is false. The range is at most 93 days. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param customerId the {@code customer_id} path parameter + * @param metric the {@code metric} required parameter + * @param granularity the {@code granularity} required parameter + * @param from the {@code from} required parameter + * @param to the {@code to} required parameter + * @param options the optional parameters + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body, once received + */ + public CompletableFuture> listCosts( + final String customerId, + final String metric, + final ListCustomerUsageCostsGranularity granularity, + final OffsetDateTime from, + final OffsetDateTime to, + final UsageCostsCustomerListCostsOptions options, + final RequestOptions requestOptions) { + return sync.exchangeListCosts( + customerId, metric, granularity, from, to, options, requestOptions) + .sendRawAsync(); + } + + /** + * List a customer's usage events with their cost + * + *

A customer's events for one billable metric, oldest first, each with the units it adds + * and what they cost at the price in force. The cost is exact for per-unit and matrix + * pricing and absent for pricing that depends on the whole period's usage (tiered, volume, + * package, capacity) and for aggregations that cannot be split per event. The range is at + * most 93 days. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param customerId the {@code customer_id} path parameter + * @param metric the {@code metric} required parameter + * @param from the {@code from} required parameter + * @param to the {@code to} required parameter + * @return the status, headers and body, once received + */ + public CompletableFuture> listEvents( + final String customerId, + final String metric, + final OffsetDateTime from, + final OffsetDateTime to) { + return listEvents( + customerId, + metric, + from, + to, + UsageCostsCustomerListEventsOptions.none(), + RequestOptions.none()); + } + + /** + * List a customer's usage events with their cost + * + *

A customer's events for one billable metric, oldest first, each with the units it adds + * and what they cost at the price in force. The cost is exact for per-unit and matrix + * pricing and absent for pricing that depends on the whole period's usage (tiered, volume, + * package, capacity) and for aggregations that cannot be split per event. The range is at + * most 93 days. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param customerId the {@code customer_id} path parameter + * @param metric the {@code metric} required parameter + * @param from the {@code from} required parameter + * @param to the {@code to} required parameter + * @param options the optional parameters + * @return the status, headers and body, once received + */ + public CompletableFuture> listEvents( + final String customerId, + final String metric, + final OffsetDateTime from, + final OffsetDateTime to, + final UsageCostsCustomerListEventsOptions options) { + return listEvents(customerId, metric, from, to, options, RequestOptions.none()); + } + + /** + * List a customer's usage events with their cost + * + *

A customer's events for one billable metric, oldest first, each with the units it adds + * and what they cost at the price in force. The cost is exact for per-unit and matrix + * pricing and absent for pricing that depends on the whole period's usage (tiered, volume, + * package, capacity) and for aggregations that cannot be split per event. The range is at + * most 93 days. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param customerId the {@code customer_id} path parameter + * @param metric the {@code metric} required parameter + * @param from the {@code from} required parameter + * @param to the {@code to} required parameter + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body, once received + */ + public CompletableFuture> listEvents( + final String customerId, + final String metric, + final OffsetDateTime from, + final OffsetDateTime to, + final RequestOptions requestOptions) { + return listEvents( + customerId, + metric, + from, + to, + UsageCostsCustomerListEventsOptions.none(), + requestOptions); + } + + /** + * List a customer's usage events with their cost + * + *

A customer's events for one billable metric, oldest first, each with the units it adds + * and what they cost at the price in force. The cost is exact for per-unit and matrix + * pricing and absent for pricing that depends on the whole period's usage (tiered, volume, + * package, capacity) and for aggregations that cannot be split per event. The range is at + * most 93 days. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param customerId the {@code customer_id} path parameter + * @param metric the {@code metric} required parameter + * @param from the {@code from} required parameter + * @param to the {@code to} required parameter + * @param options the optional parameters + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body, once received + */ + public CompletableFuture> listEvents( + final String customerId, + final String metric, + final OffsetDateTime from, + final OffsetDateTime to, + final UsageCostsCustomerListEventsOptions options, + final RequestOptions requestOptions) { + return sync.exchangeListEvents(customerId, metric, from, to, options, requestOptions) + .sendRawAsync(); + } + } +} diff --git a/src/main/java/com/meteroid/api/UsageCostsCustomerListCostsOptions.java b/src/main/java/com/meteroid/api/UsageCostsCustomerListCostsOptions.java new file mode 100644 index 0000000..5214aba --- /dev/null +++ b/src/main/java/com/meteroid/api/UsageCostsCustomerListCostsOptions.java @@ -0,0 +1,101 @@ +// this file is @generated +package com.meteroid.api; + +import java.util.Objects; +import java.util.Optional; + +/** Optional parameters of {@code listCosts}, immutable: build them with {@link #builder()}. */ +public final class UsageCostsCustomerListCostsOptions { + private final String groupBy; + + private UsageCostsCustomerListCostsOptions(Builder builder) { + this.groupBy = builder.groupBy; + } + + /** + * A builder of parameters. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * No parameters. + * + * @return empty parameters + */ + public static UsageCostsCustomerListCostsOptions none() { + return builder().build(); + } + + /** + * A builder starting from these parameters. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.groupBy = groupBy; + return builder; + } + + /** + * Event property to split the usage by. + * + * @return the value, empty when unset + */ + public Optional groupBy() { + return Optional.ofNullable(groupBy); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + UsageCostsCustomerListCostsOptions that = (UsageCostsCustomerListCostsOptions) o; + return Objects.equals(groupBy, that.groupBy); + } + + @Override + public int hashCode() { + return Objects.hash(groupBy); + } + + @Override + public String toString() { + return "UsageCostsCustomerListCostsOptions{" + "groupBy=" + groupBy + "}"; + } + + /** Builds {@link UsageCostsCustomerListCostsOptions}. */ + public static final class Builder { + private String groupBy; + + private Builder() {} + + /** + * Event property to split the usage by. + * + * @param groupBy the value, null to leave it out + * @return this builder + */ + public Builder groupBy(String groupBy) { + this.groupBy = groupBy; + return this; + } + + /** + * The parameters. + * + * @return immutable parameters + */ + public UsageCostsCustomerListCostsOptions build() { + return new UsageCostsCustomerListCostsOptions(this); + } + } +} diff --git a/src/main/java/com/meteroid/api/UsageCostsCustomerListEventsOptions.java b/src/main/java/com/meteroid/api/UsageCostsCustomerListEventsOptions.java new file mode 100644 index 0000000..4d7a750 --- /dev/null +++ b/src/main/java/com/meteroid/api/UsageCostsCustomerListEventsOptions.java @@ -0,0 +1,130 @@ +// this file is @generated +package com.meteroid.api; + +import java.util.Objects; +import java.util.Optional; + +/** Optional parameters of {@code listEvents}, immutable: build them with {@link #builder()}. */ +public final class UsageCostsCustomerListEventsOptions { + private final String cursor; + private final Integer limit; + + private UsageCostsCustomerListEventsOptions(Builder builder) { + this.cursor = builder.cursor; + this.limit = builder.limit; + } + + /** + * A builder of parameters. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * No parameters. + * + * @return empty parameters + */ + public static UsageCostsCustomerListEventsOptions none() { + return builder().build(); + } + + /** + * A builder starting from these parameters. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.cursor = cursor; + builder.limit = limit; + return builder; + } + + /** + * The next_cursor of the previous page. + * + * @return the value, empty when unset + */ + public Optional cursor() { + return Optional.ofNullable(cursor); + } + + /** + * Page size, 100 by default and 500 at most. + * + * @return the value, empty when unset + */ + public Optional limit() { + return Optional.ofNullable(limit); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + UsageCostsCustomerListEventsOptions that = (UsageCostsCustomerListEventsOptions) o; + return Objects.equals(cursor, that.cursor) && Objects.equals(limit, that.limit); + } + + @Override + public int hashCode() { + return Objects.hash(cursor, limit); + } + + @Override + public String toString() { + return "UsageCostsCustomerListEventsOptions{" + + "cursor=" + + cursor + + ", limit=" + + limit + + "}"; + } + + /** Builds {@link UsageCostsCustomerListEventsOptions}. */ + public static final class Builder { + private String cursor; + private Integer limit; + + private Builder() {} + + /** + * The next_cursor of the previous page. + * + * @param cursor the value, null to leave it out + * @return this builder + */ + public Builder cursor(String cursor) { + this.cursor = cursor; + return this; + } + + /** + * Page size, 100 by default and 500 at most. + * + * @param limit the value, null to leave it out + * @return this builder + */ + public Builder limit(Integer limit) { + this.limit = limit; + return this; + } + + /** + * The parameters. + * + * @return immutable parameters + */ + public UsageCostsCustomerListEventsOptions build() { + return new UsageCostsCustomerListEventsOptions(this); + } + } +} diff --git a/src/main/java/com/meteroid/api/UsageCostsSubscription.java b/src/main/java/com/meteroid/api/UsageCostsSubscription.java new file mode 100644 index 0000000..c62d5b1 --- /dev/null +++ b/src/main/java/com/meteroid/api/UsageCostsSubscription.java @@ -0,0 +1,624 @@ +// this file is @generated +package com.meteroid.api; + +import com.meteroid.ApiResponse; +import com.meteroid.RequestOptions; +import com.meteroid.internal.MeteroidHttpClient; +import com.meteroid.internal.Utils; +import com.meteroid.models.ListSubscriptionUsageCostsGranularity; +import com.meteroid.models.UsageCostListResponse; +import com.meteroid.models.UsageEventListResponse; + +import okhttp3.HttpUrl; + +import java.time.OffsetDateTime; +import java.util.Objects; + +/** + * The {@code usage_costs.subscription} operations, blocking. {@link #withRawResponse()} has the + * same methods returning the status and headers along with the body. + */ +public final class UsageCostsSubscription { + private final MeteroidHttpClient client; + private final WithRawResponse withRawResponse; + + /** + * The operations, sending through {@code client}. + * + * @param client the HTTP client of the SDK + */ + public UsageCostsSubscription(MeteroidHttpClient client) { + this.client = client; + this.withRawResponse = new WithRawResponse(); + } + + /** + * The same operations, returning the status and headers along with the body. + * + * @return the operations + */ + public WithRawResponse withRawResponse() { + return withRawResponse; + } + + /** + * List a subscription's usage costs over time + * + *

The subscription's usage of one billable metric and what it costs, as for a customer but + * counting only the events the subscription bills (see its usage filter) and only its own + * billing periods. The range is at most 93 days. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param subscriptionId the {@code subscription_id} path parameter + * @param metric the {@code metric} required parameter + * @param granularity the {@code granularity} required parameter + * @param from the {@code from} required parameter + * @param to the {@code to} required parameter + * @return the response body + */ + public UsageCostListResponse listCosts( + final String subscriptionId, + final String metric, + final ListSubscriptionUsageCostsGranularity granularity, + final OffsetDateTime from, + final OffsetDateTime to) { + return listCosts( + subscriptionId, + metric, + granularity, + from, + to, + UsageCostsSubscriptionListCostsOptions.none(), + RequestOptions.none()); + } + + /** + * List a subscription's usage costs over time + * + *

The subscription's usage of one billable metric and what it costs, as for a customer but + * counting only the events the subscription bills (see its usage filter) and only its own + * billing periods. The range is at most 93 days. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param subscriptionId the {@code subscription_id} path parameter + * @param metric the {@code metric} required parameter + * @param granularity the {@code granularity} required parameter + * @param from the {@code from} required parameter + * @param to the {@code to} required parameter + * @param options the optional parameters + * @return the response body + */ + public UsageCostListResponse listCosts( + final String subscriptionId, + final String metric, + final ListSubscriptionUsageCostsGranularity granularity, + final OffsetDateTime from, + final OffsetDateTime to, + final UsageCostsSubscriptionListCostsOptions options) { + return listCosts( + subscriptionId, metric, granularity, from, to, options, RequestOptions.none()); + } + + /** + * List a subscription's usage costs over time + * + *

The subscription's usage of one billable metric and what it costs, as for a customer but + * counting only the events the subscription bills (see its usage filter) and only its own + * billing periods. The range is at most 93 days. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param subscriptionId the {@code subscription_id} path parameter + * @param metric the {@code metric} required parameter + * @param granularity the {@code granularity} required parameter + * @param from the {@code from} required parameter + * @param to the {@code to} required parameter + * @param requestOptions headers, timeout and retries of this call + * @return the response body + */ + public UsageCostListResponse listCosts( + final String subscriptionId, + final String metric, + final ListSubscriptionUsageCostsGranularity granularity, + final OffsetDateTime from, + final OffsetDateTime to, + final RequestOptions requestOptions) { + return listCosts( + subscriptionId, + metric, + granularity, + from, + to, + UsageCostsSubscriptionListCostsOptions.none(), + requestOptions); + } + + /** + * List a subscription's usage costs over time + * + *

The subscription's usage of one billable metric and what it costs, as for a customer but + * counting only the events the subscription bills (see its usage filter) and only its own + * billing periods. The range is at most 93 days. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param subscriptionId the {@code subscription_id} path parameter + * @param metric the {@code metric} required parameter + * @param granularity the {@code granularity} required parameter + * @param from the {@code from} required parameter + * @param to the {@code to} required parameter + * @param options the optional parameters + * @param requestOptions headers, timeout and retries of this call + * @return the response body + */ + public UsageCostListResponse listCosts( + final String subscriptionId, + final String metric, + final ListSubscriptionUsageCostsGranularity granularity, + final OffsetDateTime from, + final OffsetDateTime to, + final UsageCostsSubscriptionListCostsOptions options, + final RequestOptions requestOptions) { + return exchangeListCosts( + subscriptionId, metric, granularity, from, to, options, requestOptions) + .send(); + } + + MeteroidHttpClient.Exchange exchangeListCosts( + final String subscriptionId, + final String metric, + final ListSubscriptionUsageCostsGranularity granularity, + final OffsetDateTime from, + final OffsetDateTime to, + final UsageCostsSubscriptionListCostsOptions options, + final RequestOptions requestOptions) { + Objects.requireNonNull(subscriptionId, "subscription_id"); + Objects.requireNonNull(metric, "metric"); + Objects.requireNonNull(granularity, "granularity"); + Objects.requireNonNull(from, "from"); + Objects.requireNonNull(to, "to"); + Objects.requireNonNull(options, "options"); + HttpUrl.Builder url = + client.newUrlBuilder() + .addPathSegments("api/v1/usage/subscription") + .addPathSegment(Utils.pathSegment("subscription_id", subscriptionId)) + .addPathSegments("costs"); + url.addQueryParameter("metric", metric); + String value2 = options.groupBy().orElse(null); + if (value2 != null) { + url.addQueryParameter("group_by", value2); + } + url.addQueryParameter("granularity", Utils.serializeQueryParam(granularity)); + url.addQueryParameter("from", Utils.serializeQueryParam(from)); + url.addQueryParameter("to", Utils.serializeQueryParam(to)); + return client.call("GET", url.build()) + .errors( + com.meteroid.models.RestErrorResponse.class, + "400", + "401", + "404", + "429", + "500") + .options(requestOptions) + .returning(UsageCostListResponse.class); + } + + /** + * List a subscription's usage events with their cost + * + *

The events of one billable metric that the subscription bills, oldest first: with a usage + * filter, only the customer's events matching it; without, those no other subscription's filter + * claims. Costs are as for the customer's events. The range is at most 93 days. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param subscriptionId the {@code subscription_id} path parameter + * @param metric the {@code metric} required parameter + * @param from the {@code from} required parameter + * @param to the {@code to} required parameter + * @return the response body + */ + public UsageEventListResponse listEvents( + final String subscriptionId, + final String metric, + final OffsetDateTime from, + final OffsetDateTime to) { + return listEvents( + subscriptionId, + metric, + from, + to, + UsageCostsSubscriptionListEventsOptions.none(), + RequestOptions.none()); + } + + /** + * List a subscription's usage events with their cost + * + *

The events of one billable metric that the subscription bills, oldest first: with a usage + * filter, only the customer's events matching it; without, those no other subscription's filter + * claims. Costs are as for the customer's events. The range is at most 93 days. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param subscriptionId the {@code subscription_id} path parameter + * @param metric the {@code metric} required parameter + * @param from the {@code from} required parameter + * @param to the {@code to} required parameter + * @param options the optional parameters + * @return the response body + */ + public UsageEventListResponse listEvents( + final String subscriptionId, + final String metric, + final OffsetDateTime from, + final OffsetDateTime to, + final UsageCostsSubscriptionListEventsOptions options) { + return listEvents(subscriptionId, metric, from, to, options, RequestOptions.none()); + } + + /** + * List a subscription's usage events with their cost + * + *

The events of one billable metric that the subscription bills, oldest first: with a usage + * filter, only the customer's events matching it; without, those no other subscription's filter + * claims. Costs are as for the customer's events. The range is at most 93 days. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param subscriptionId the {@code subscription_id} path parameter + * @param metric the {@code metric} required parameter + * @param from the {@code from} required parameter + * @param to the {@code to} required parameter + * @param requestOptions headers, timeout and retries of this call + * @return the response body + */ + public UsageEventListResponse listEvents( + final String subscriptionId, + final String metric, + final OffsetDateTime from, + final OffsetDateTime to, + final RequestOptions requestOptions) { + return listEvents( + subscriptionId, + metric, + from, + to, + UsageCostsSubscriptionListEventsOptions.none(), + requestOptions); + } + + /** + * List a subscription's usage events with their cost + * + *

The events of one billable metric that the subscription bills, oldest first: with a usage + * filter, only the customer's events matching it; without, those no other subscription's filter + * claims. Costs are as for the customer's events. The range is at most 93 days. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param subscriptionId the {@code subscription_id} path parameter + * @param metric the {@code metric} required parameter + * @param from the {@code from} required parameter + * @param to the {@code to} required parameter + * @param options the optional parameters + * @param requestOptions headers, timeout and retries of this call + * @return the response body + */ + public UsageEventListResponse listEvents( + final String subscriptionId, + final String metric, + final OffsetDateTime from, + final OffsetDateTime to, + final UsageCostsSubscriptionListEventsOptions options, + final RequestOptions requestOptions) { + return exchangeListEvents(subscriptionId, metric, from, to, options, requestOptions).send(); + } + + MeteroidHttpClient.Exchange exchangeListEvents( + final String subscriptionId, + final String metric, + final OffsetDateTime from, + final OffsetDateTime to, + final UsageCostsSubscriptionListEventsOptions options, + final RequestOptions requestOptions) { + Objects.requireNonNull(subscriptionId, "subscription_id"); + Objects.requireNonNull(metric, "metric"); + Objects.requireNonNull(from, "from"); + Objects.requireNonNull(to, "to"); + Objects.requireNonNull(options, "options"); + HttpUrl.Builder url = + client.newUrlBuilder() + .addPathSegments("api/v1/usage/subscription") + .addPathSegment(Utils.pathSegment("subscription_id", subscriptionId)) + .addPathSegments("events"); + url.addQueryParameter("metric", metric); + url.addQueryParameter("from", Utils.serializeQueryParam(from)); + url.addQueryParameter("to", Utils.serializeQueryParam(to)); + String value4 = options.cursor().orElse(null); + if (value4 != null) { + url.addQueryParameter("cursor", value4); + } + Integer value5 = options.limit().orElse(null); + if (value5 != null) { + url.addQueryParameter("limit", Utils.serializeQueryParam(value5)); + } + return client.call("GET", url.build()) + .errors( + com.meteroid.models.RestErrorResponse.class, + "400", + "401", + "404", + "429", + "500") + .options(requestOptions) + .returning(UsageEventListResponse.class); + } + + /** The operations, returning the status and headers along with the body. */ + public final class WithRawResponse { + private WithRawResponse() {} + + /** + * List a subscription's usage costs over time + * + *

The subscription's usage of one billable metric and what it costs, as for a customer + * but counting only the events the subscription bills (see its usage filter) and only its + * own billing periods. The range is at most 93 days. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param subscriptionId the {@code subscription_id} path parameter + * @param metric the {@code metric} required parameter + * @param granularity the {@code granularity} required parameter + * @param from the {@code from} required parameter + * @param to the {@code to} required parameter + * @return the status, headers and body + */ + public ApiResponse listCosts( + final String subscriptionId, + final String metric, + final ListSubscriptionUsageCostsGranularity granularity, + final OffsetDateTime from, + final OffsetDateTime to) { + return listCosts( + subscriptionId, + metric, + granularity, + from, + to, + UsageCostsSubscriptionListCostsOptions.none(), + RequestOptions.none()); + } + + /** + * List a subscription's usage costs over time + * + *

The subscription's usage of one billable metric and what it costs, as for a customer + * but counting only the events the subscription bills (see its usage filter) and only its + * own billing periods. The range is at most 93 days. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param subscriptionId the {@code subscription_id} path parameter + * @param metric the {@code metric} required parameter + * @param granularity the {@code granularity} required parameter + * @param from the {@code from} required parameter + * @param to the {@code to} required parameter + * @param options the optional parameters + * @return the status, headers and body + */ + public ApiResponse listCosts( + final String subscriptionId, + final String metric, + final ListSubscriptionUsageCostsGranularity granularity, + final OffsetDateTime from, + final OffsetDateTime to, + final UsageCostsSubscriptionListCostsOptions options) { + return listCosts( + subscriptionId, metric, granularity, from, to, options, RequestOptions.none()); + } + + /** + * List a subscription's usage costs over time + * + *

The subscription's usage of one billable metric and what it costs, as for a customer + * but counting only the events the subscription bills (see its usage filter) and only its + * own billing periods. The range is at most 93 days. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param subscriptionId the {@code subscription_id} path parameter + * @param metric the {@code metric} required parameter + * @param granularity the {@code granularity} required parameter + * @param from the {@code from} required parameter + * @param to the {@code to} required parameter + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body + */ + public ApiResponse listCosts( + final String subscriptionId, + final String metric, + final ListSubscriptionUsageCostsGranularity granularity, + final OffsetDateTime from, + final OffsetDateTime to, + final RequestOptions requestOptions) { + return listCosts( + subscriptionId, + metric, + granularity, + from, + to, + UsageCostsSubscriptionListCostsOptions.none(), + requestOptions); + } + + /** + * List a subscription's usage costs over time + * + *

The subscription's usage of one billable metric and what it costs, as for a customer + * but counting only the events the subscription bills (see its usage filter) and only its + * own billing periods. The range is at most 93 days. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param subscriptionId the {@code subscription_id} path parameter + * @param metric the {@code metric} required parameter + * @param granularity the {@code granularity} required parameter + * @param from the {@code from} required parameter + * @param to the {@code to} required parameter + * @param options the optional parameters + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body + */ + public ApiResponse listCosts( + final String subscriptionId, + final String metric, + final ListSubscriptionUsageCostsGranularity granularity, + final OffsetDateTime from, + final OffsetDateTime to, + final UsageCostsSubscriptionListCostsOptions options, + final RequestOptions requestOptions) { + return UsageCostsSubscription.this + .exchangeListCosts( + subscriptionId, metric, granularity, from, to, options, requestOptions) + .sendRaw(); + } + + /** + * List a subscription's usage events with their cost + * + *

The events of one billable metric that the subscription bills, oldest first: with a + * usage filter, only the customer's events matching it; without, those no other + * subscription's filter claims. Costs are as for the customer's events. The range is at + * most 93 days. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param subscriptionId the {@code subscription_id} path parameter + * @param metric the {@code metric} required parameter + * @param from the {@code from} required parameter + * @param to the {@code to} required parameter + * @return the status, headers and body + */ + public ApiResponse listEvents( + final String subscriptionId, + final String metric, + final OffsetDateTime from, + final OffsetDateTime to) { + return listEvents( + subscriptionId, + metric, + from, + to, + UsageCostsSubscriptionListEventsOptions.none(), + RequestOptions.none()); + } + + /** + * List a subscription's usage events with their cost + * + *

The events of one billable metric that the subscription bills, oldest first: with a + * usage filter, only the customer's events matching it; without, those no other + * subscription's filter claims. Costs are as for the customer's events. The range is at + * most 93 days. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param subscriptionId the {@code subscription_id} path parameter + * @param metric the {@code metric} required parameter + * @param from the {@code from} required parameter + * @param to the {@code to} required parameter + * @param options the optional parameters + * @return the status, headers and body + */ + public ApiResponse listEvents( + final String subscriptionId, + final String metric, + final OffsetDateTime from, + final OffsetDateTime to, + final UsageCostsSubscriptionListEventsOptions options) { + return listEvents(subscriptionId, metric, from, to, options, RequestOptions.none()); + } + + /** + * List a subscription's usage events with their cost + * + *

The events of one billable metric that the subscription bills, oldest first: with a + * usage filter, only the customer's events matching it; without, those no other + * subscription's filter claims. Costs are as for the customer's events. The range is at + * most 93 days. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param subscriptionId the {@code subscription_id} path parameter + * @param metric the {@code metric} required parameter + * @param from the {@code from} required parameter + * @param to the {@code to} required parameter + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body + */ + public ApiResponse listEvents( + final String subscriptionId, + final String metric, + final OffsetDateTime from, + final OffsetDateTime to, + final RequestOptions requestOptions) { + return listEvents( + subscriptionId, + metric, + from, + to, + UsageCostsSubscriptionListEventsOptions.none(), + requestOptions); + } + + /** + * List a subscription's usage events with their cost + * + *

The events of one billable metric that the subscription bills, oldest first: with a + * usage filter, only the customer's events matching it; without, those no other + * subscription's filter claims. Costs are as for the customer's events. The range is at + * most 93 days. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param subscriptionId the {@code subscription_id} path parameter + * @param metric the {@code metric} required parameter + * @param from the {@code from} required parameter + * @param to the {@code to} required parameter + * @param options the optional parameters + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body + */ + public ApiResponse listEvents( + final String subscriptionId, + final String metric, + final OffsetDateTime from, + final OffsetDateTime to, + final UsageCostsSubscriptionListEventsOptions options, + final RequestOptions requestOptions) { + return UsageCostsSubscription.this + .exchangeListEvents(subscriptionId, metric, from, to, options, requestOptions) + .sendRaw(); + } + } +} diff --git a/src/main/java/com/meteroid/api/UsageCostsSubscriptionAsync.java b/src/main/java/com/meteroid/api/UsageCostsSubscriptionAsync.java new file mode 100644 index 0000000..b81a48a --- /dev/null +++ b/src/main/java/com/meteroid/api/UsageCostsSubscriptionAsync.java @@ -0,0 +1,541 @@ +// this file is @generated +package com.meteroid.api; + +import com.meteroid.ApiResponse; +import com.meteroid.RequestOptions; +import com.meteroid.models.ListSubscriptionUsageCostsGranularity; +import com.meteroid.models.UsageCostListResponse; +import com.meteroid.models.UsageEventListResponse; + +import java.time.OffsetDateTime; +import java.util.concurrent.CompletableFuture; + +/** + * The {@code usage_costs.subscription} operations, without blocking: each method returns a {@link + * CompletableFuture}. Obtained from {@code client.async()}. + */ +public final class UsageCostsSubscriptionAsync { + private final UsageCostsSubscription sync; + private final WithRawResponse withRawResponse; + + /** + * The operations, sending through {@code sync}. + * + * @param sync the blocking operations + */ + public UsageCostsSubscriptionAsync(UsageCostsSubscription sync) { + this.sync = sync; + this.withRawResponse = new WithRawResponse(); + } + + /** + * The same operations, returning the status and headers along with the body. + * + * @return the operations + */ + public WithRawResponse withRawResponse() { + return withRawResponse; + } + + /** + * List a subscription's usage costs over time + * + *

The subscription's usage of one billable metric and what it costs, as for a customer but + * counting only the events the subscription bills (see its usage filter) and only its own + * billing periods. The range is at most 93 days. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param subscriptionId the {@code subscription_id} path parameter + * @param metric the {@code metric} required parameter + * @param granularity the {@code granularity} required parameter + * @param from the {@code from} required parameter + * @param to the {@code to} required parameter + * @return the response body, once received + */ + public CompletableFuture listCosts( + final String subscriptionId, + final String metric, + final ListSubscriptionUsageCostsGranularity granularity, + final OffsetDateTime from, + final OffsetDateTime to) { + return listCosts( + subscriptionId, + metric, + granularity, + from, + to, + UsageCostsSubscriptionListCostsOptions.none(), + RequestOptions.none()); + } + + /** + * List a subscription's usage costs over time + * + *

The subscription's usage of one billable metric and what it costs, as for a customer but + * counting only the events the subscription bills (see its usage filter) and only its own + * billing periods. The range is at most 93 days. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param subscriptionId the {@code subscription_id} path parameter + * @param metric the {@code metric} required parameter + * @param granularity the {@code granularity} required parameter + * @param from the {@code from} required parameter + * @param to the {@code to} required parameter + * @param options the optional parameters + * @return the response body, once received + */ + public CompletableFuture listCosts( + final String subscriptionId, + final String metric, + final ListSubscriptionUsageCostsGranularity granularity, + final OffsetDateTime from, + final OffsetDateTime to, + final UsageCostsSubscriptionListCostsOptions options) { + return listCosts( + subscriptionId, metric, granularity, from, to, options, RequestOptions.none()); + } + + /** + * List a subscription's usage costs over time + * + *

The subscription's usage of one billable metric and what it costs, as for a customer but + * counting only the events the subscription bills (see its usage filter) and only its own + * billing periods. The range is at most 93 days. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param subscriptionId the {@code subscription_id} path parameter + * @param metric the {@code metric} required parameter + * @param granularity the {@code granularity} required parameter + * @param from the {@code from} required parameter + * @param to the {@code to} required parameter + * @param requestOptions headers, timeout and retries of this call + * @return the response body, once received + */ + public CompletableFuture listCosts( + final String subscriptionId, + final String metric, + final ListSubscriptionUsageCostsGranularity granularity, + final OffsetDateTime from, + final OffsetDateTime to, + final RequestOptions requestOptions) { + return listCosts( + subscriptionId, + metric, + granularity, + from, + to, + UsageCostsSubscriptionListCostsOptions.none(), + requestOptions); + } + + /** + * List a subscription's usage costs over time + * + *

The subscription's usage of one billable metric and what it costs, as for a customer but + * counting only the events the subscription bills (see its usage filter) and only its own + * billing periods. The range is at most 93 days. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param subscriptionId the {@code subscription_id} path parameter + * @param metric the {@code metric} required parameter + * @param granularity the {@code granularity} required parameter + * @param from the {@code from} required parameter + * @param to the {@code to} required parameter + * @param options the optional parameters + * @param requestOptions headers, timeout and retries of this call + * @return the response body, once received + */ + public CompletableFuture listCosts( + final String subscriptionId, + final String metric, + final ListSubscriptionUsageCostsGranularity granularity, + final OffsetDateTime from, + final OffsetDateTime to, + final UsageCostsSubscriptionListCostsOptions options, + final RequestOptions requestOptions) { + return sync.exchangeListCosts( + subscriptionId, metric, granularity, from, to, options, requestOptions) + .sendAsync(); + } + + /** + * List a subscription's usage events with their cost + * + *

The events of one billable metric that the subscription bills, oldest first: with a usage + * filter, only the customer's events matching it; without, those no other subscription's filter + * claims. Costs are as for the customer's events. The range is at most 93 days. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param subscriptionId the {@code subscription_id} path parameter + * @param metric the {@code metric} required parameter + * @param from the {@code from} required parameter + * @param to the {@code to} required parameter + * @return the response body, once received + */ + public CompletableFuture listEvents( + final String subscriptionId, + final String metric, + final OffsetDateTime from, + final OffsetDateTime to) { + return listEvents( + subscriptionId, + metric, + from, + to, + UsageCostsSubscriptionListEventsOptions.none(), + RequestOptions.none()); + } + + /** + * List a subscription's usage events with their cost + * + *

The events of one billable metric that the subscription bills, oldest first: with a usage + * filter, only the customer's events matching it; without, those no other subscription's filter + * claims. Costs are as for the customer's events. The range is at most 93 days. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param subscriptionId the {@code subscription_id} path parameter + * @param metric the {@code metric} required parameter + * @param from the {@code from} required parameter + * @param to the {@code to} required parameter + * @param options the optional parameters + * @return the response body, once received + */ + public CompletableFuture listEvents( + final String subscriptionId, + final String metric, + final OffsetDateTime from, + final OffsetDateTime to, + final UsageCostsSubscriptionListEventsOptions options) { + return listEvents(subscriptionId, metric, from, to, options, RequestOptions.none()); + } + + /** + * List a subscription's usage events with their cost + * + *

The events of one billable metric that the subscription bills, oldest first: with a usage + * filter, only the customer's events matching it; without, those no other subscription's filter + * claims. Costs are as for the customer's events. The range is at most 93 days. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param subscriptionId the {@code subscription_id} path parameter + * @param metric the {@code metric} required parameter + * @param from the {@code from} required parameter + * @param to the {@code to} required parameter + * @param requestOptions headers, timeout and retries of this call + * @return the response body, once received + */ + public CompletableFuture listEvents( + final String subscriptionId, + final String metric, + final OffsetDateTime from, + final OffsetDateTime to, + final RequestOptions requestOptions) { + return listEvents( + subscriptionId, + metric, + from, + to, + UsageCostsSubscriptionListEventsOptions.none(), + requestOptions); + } + + /** + * List a subscription's usage events with their cost + * + *

The events of one billable metric that the subscription bills, oldest first: with a usage + * filter, only the customer's events matching it; without, those no other subscription's filter + * claims. Costs are as for the customer's events. The range is at most 93 days. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param subscriptionId the {@code subscription_id} path parameter + * @param metric the {@code metric} required parameter + * @param from the {@code from} required parameter + * @param to the {@code to} required parameter + * @param options the optional parameters + * @param requestOptions headers, timeout and retries of this call + * @return the response body, once received + */ + public CompletableFuture listEvents( + final String subscriptionId, + final String metric, + final OffsetDateTime from, + final OffsetDateTime to, + final UsageCostsSubscriptionListEventsOptions options, + final RequestOptions requestOptions) { + return sync.exchangeListEvents(subscriptionId, metric, from, to, options, requestOptions) + .sendAsync(); + } + + /** The operations, returning the status and headers along with the body. */ + public final class WithRawResponse { + private WithRawResponse() {} + + /** + * List a subscription's usage costs over time + * + *

The subscription's usage of one billable metric and what it costs, as for a customer + * but counting only the events the subscription bills (see its usage filter) and only its + * own billing periods. The range is at most 93 days. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param subscriptionId the {@code subscription_id} path parameter + * @param metric the {@code metric} required parameter + * @param granularity the {@code granularity} required parameter + * @param from the {@code from} required parameter + * @param to the {@code to} required parameter + * @return the status, headers and body, once received + */ + public CompletableFuture> listCosts( + final String subscriptionId, + final String metric, + final ListSubscriptionUsageCostsGranularity granularity, + final OffsetDateTime from, + final OffsetDateTime to) { + return listCosts( + subscriptionId, + metric, + granularity, + from, + to, + UsageCostsSubscriptionListCostsOptions.none(), + RequestOptions.none()); + } + + /** + * List a subscription's usage costs over time + * + *

The subscription's usage of one billable metric and what it costs, as for a customer + * but counting only the events the subscription bills (see its usage filter) and only its + * own billing periods. The range is at most 93 days. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param subscriptionId the {@code subscription_id} path parameter + * @param metric the {@code metric} required parameter + * @param granularity the {@code granularity} required parameter + * @param from the {@code from} required parameter + * @param to the {@code to} required parameter + * @param options the optional parameters + * @return the status, headers and body, once received + */ + public CompletableFuture> listCosts( + final String subscriptionId, + final String metric, + final ListSubscriptionUsageCostsGranularity granularity, + final OffsetDateTime from, + final OffsetDateTime to, + final UsageCostsSubscriptionListCostsOptions options) { + return listCosts( + subscriptionId, metric, granularity, from, to, options, RequestOptions.none()); + } + + /** + * List a subscription's usage costs over time + * + *

The subscription's usage of one billable metric and what it costs, as for a customer + * but counting only the events the subscription bills (see its usage filter) and only its + * own billing periods. The range is at most 93 days. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param subscriptionId the {@code subscription_id} path parameter + * @param metric the {@code metric} required parameter + * @param granularity the {@code granularity} required parameter + * @param from the {@code from} required parameter + * @param to the {@code to} required parameter + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body, once received + */ + public CompletableFuture> listCosts( + final String subscriptionId, + final String metric, + final ListSubscriptionUsageCostsGranularity granularity, + final OffsetDateTime from, + final OffsetDateTime to, + final RequestOptions requestOptions) { + return listCosts( + subscriptionId, + metric, + granularity, + from, + to, + UsageCostsSubscriptionListCostsOptions.none(), + requestOptions); + } + + /** + * List a subscription's usage costs over time + * + *

The subscription's usage of one billable metric and what it costs, as for a customer + * but counting only the events the subscription bills (see its usage filter) and only its + * own billing periods. The range is at most 93 days. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param subscriptionId the {@code subscription_id} path parameter + * @param metric the {@code metric} required parameter + * @param granularity the {@code granularity} required parameter + * @param from the {@code from} required parameter + * @param to the {@code to} required parameter + * @param options the optional parameters + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body, once received + */ + public CompletableFuture> listCosts( + final String subscriptionId, + final String metric, + final ListSubscriptionUsageCostsGranularity granularity, + final OffsetDateTime from, + final OffsetDateTime to, + final UsageCostsSubscriptionListCostsOptions options, + final RequestOptions requestOptions) { + return sync.exchangeListCosts( + subscriptionId, metric, granularity, from, to, options, requestOptions) + .sendRawAsync(); + } + + /** + * List a subscription's usage events with their cost + * + *

The events of one billable metric that the subscription bills, oldest first: with a + * usage filter, only the customer's events matching it; without, those no other + * subscription's filter claims. Costs are as for the customer's events. The range is at + * most 93 days. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param subscriptionId the {@code subscription_id} path parameter + * @param metric the {@code metric} required parameter + * @param from the {@code from} required parameter + * @param to the {@code to} required parameter + * @return the status, headers and body, once received + */ + public CompletableFuture> listEvents( + final String subscriptionId, + final String metric, + final OffsetDateTime from, + final OffsetDateTime to) { + return listEvents( + subscriptionId, + metric, + from, + to, + UsageCostsSubscriptionListEventsOptions.none(), + RequestOptions.none()); + } + + /** + * List a subscription's usage events with their cost + * + *

The events of one billable metric that the subscription bills, oldest first: with a + * usage filter, only the customer's events matching it; without, those no other + * subscription's filter claims. Costs are as for the customer's events. The range is at + * most 93 days. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param subscriptionId the {@code subscription_id} path parameter + * @param metric the {@code metric} required parameter + * @param from the {@code from} required parameter + * @param to the {@code to} required parameter + * @param options the optional parameters + * @return the status, headers and body, once received + */ + public CompletableFuture> listEvents( + final String subscriptionId, + final String metric, + final OffsetDateTime from, + final OffsetDateTime to, + final UsageCostsSubscriptionListEventsOptions options) { + return listEvents(subscriptionId, metric, from, to, options, RequestOptions.none()); + } + + /** + * List a subscription's usage events with their cost + * + *

The events of one billable metric that the subscription bills, oldest first: with a + * usage filter, only the customer's events matching it; without, those no other + * subscription's filter claims. Costs are as for the customer's events. The range is at + * most 93 days. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param subscriptionId the {@code subscription_id} path parameter + * @param metric the {@code metric} required parameter + * @param from the {@code from} required parameter + * @param to the {@code to} required parameter + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body, once received + */ + public CompletableFuture> listEvents( + final String subscriptionId, + final String metric, + final OffsetDateTime from, + final OffsetDateTime to, + final RequestOptions requestOptions) { + return listEvents( + subscriptionId, + metric, + from, + to, + UsageCostsSubscriptionListEventsOptions.none(), + requestOptions); + } + + /** + * List a subscription's usage events with their cost + * + *

The events of one billable metric that the subscription bills, oldest first: with a + * usage filter, only the customer's events matching it; without, those no other + * subscription's filter claims. Costs are as for the customer's events. The range is at + * most 93 days. + * + *

Beta: the request and response shapes of this endpoint may change before general + * availability. + * + * @param subscriptionId the {@code subscription_id} path parameter + * @param metric the {@code metric} required parameter + * @param from the {@code from} required parameter + * @param to the {@code to} required parameter + * @param options the optional parameters + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body, once received + */ + public CompletableFuture> listEvents( + final String subscriptionId, + final String metric, + final OffsetDateTime from, + final OffsetDateTime to, + final UsageCostsSubscriptionListEventsOptions options, + final RequestOptions requestOptions) { + return sync.exchangeListEvents( + subscriptionId, metric, from, to, options, requestOptions) + .sendRawAsync(); + } + } +} diff --git a/src/main/java/com/meteroid/api/UsageCostsSubscriptionListCostsOptions.java b/src/main/java/com/meteroid/api/UsageCostsSubscriptionListCostsOptions.java new file mode 100644 index 0000000..474524a --- /dev/null +++ b/src/main/java/com/meteroid/api/UsageCostsSubscriptionListCostsOptions.java @@ -0,0 +1,101 @@ +// this file is @generated +package com.meteroid.api; + +import java.util.Objects; +import java.util.Optional; + +/** Optional parameters of {@code listCosts}, immutable: build them with {@link #builder()}. */ +public final class UsageCostsSubscriptionListCostsOptions { + private final String groupBy; + + private UsageCostsSubscriptionListCostsOptions(Builder builder) { + this.groupBy = builder.groupBy; + } + + /** + * A builder of parameters. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * No parameters. + * + * @return empty parameters + */ + public static UsageCostsSubscriptionListCostsOptions none() { + return builder().build(); + } + + /** + * A builder starting from these parameters. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.groupBy = groupBy; + return builder; + } + + /** + * Event property to split the usage by. + * + * @return the value, empty when unset + */ + public Optional groupBy() { + return Optional.ofNullable(groupBy); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + UsageCostsSubscriptionListCostsOptions that = (UsageCostsSubscriptionListCostsOptions) o; + return Objects.equals(groupBy, that.groupBy); + } + + @Override + public int hashCode() { + return Objects.hash(groupBy); + } + + @Override + public String toString() { + return "UsageCostsSubscriptionListCostsOptions{" + "groupBy=" + groupBy + "}"; + } + + /** Builds {@link UsageCostsSubscriptionListCostsOptions}. */ + public static final class Builder { + private String groupBy; + + private Builder() {} + + /** + * Event property to split the usage by. + * + * @param groupBy the value, null to leave it out + * @return this builder + */ + public Builder groupBy(String groupBy) { + this.groupBy = groupBy; + return this; + } + + /** + * The parameters. + * + * @return immutable parameters + */ + public UsageCostsSubscriptionListCostsOptions build() { + return new UsageCostsSubscriptionListCostsOptions(this); + } + } +} diff --git a/src/main/java/com/meteroid/api/UsageCostsSubscriptionListEventsOptions.java b/src/main/java/com/meteroid/api/UsageCostsSubscriptionListEventsOptions.java new file mode 100644 index 0000000..f9c25c2 --- /dev/null +++ b/src/main/java/com/meteroid/api/UsageCostsSubscriptionListEventsOptions.java @@ -0,0 +1,130 @@ +// this file is @generated +package com.meteroid.api; + +import java.util.Objects; +import java.util.Optional; + +/** Optional parameters of {@code listEvents}, immutable: build them with {@link #builder()}. */ +public final class UsageCostsSubscriptionListEventsOptions { + private final String cursor; + private final Integer limit; + + private UsageCostsSubscriptionListEventsOptions(Builder builder) { + this.cursor = builder.cursor; + this.limit = builder.limit; + } + + /** + * A builder of parameters. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * No parameters. + * + * @return empty parameters + */ + public static UsageCostsSubscriptionListEventsOptions none() { + return builder().build(); + } + + /** + * A builder starting from these parameters. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.cursor = cursor; + builder.limit = limit; + return builder; + } + + /** + * The next_cursor of the previous page. + * + * @return the value, empty when unset + */ + public Optional cursor() { + return Optional.ofNullable(cursor); + } + + /** + * Page size, 100 by default and 500 at most. + * + * @return the value, empty when unset + */ + public Optional limit() { + return Optional.ofNullable(limit); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + UsageCostsSubscriptionListEventsOptions that = (UsageCostsSubscriptionListEventsOptions) o; + return Objects.equals(cursor, that.cursor) && Objects.equals(limit, that.limit); + } + + @Override + public int hashCode() { + return Objects.hash(cursor, limit); + } + + @Override + public String toString() { + return "UsageCostsSubscriptionListEventsOptions{" + + "cursor=" + + cursor + + ", limit=" + + limit + + "}"; + } + + /** Builds {@link UsageCostsSubscriptionListEventsOptions}. */ + public static final class Builder { + private String cursor; + private Integer limit; + + private Builder() {} + + /** + * The next_cursor of the previous page. + * + * @param cursor the value, null to leave it out + * @return this builder + */ + public Builder cursor(String cursor) { + this.cursor = cursor; + return this; + } + + /** + * Page size, 100 by default and 500 at most. + * + * @param limit the value, null to leave it out + * @return this builder + */ + public Builder limit(Integer limit) { + this.limit = limit; + return this; + } + + /** + * The parameters. + * + * @return immutable parameters + */ + public UsageCostsSubscriptionListEventsOptions build() { + return new UsageCostsSubscriptionListEventsOptions(this); + } + } +} diff --git a/src/main/java/com/meteroid/api/UsageCustomer.java b/src/main/java/com/meteroid/api/UsageCustomer.java new file mode 100644 index 0000000..f265953 --- /dev/null +++ b/src/main/java/com/meteroid/api/UsageCustomer.java @@ -0,0 +1,421 @@ +// this file is @generated +package com.meteroid.api; + +import com.meteroid.ApiResponse; +import com.meteroid.RequestOptions; +import com.meteroid.internal.MeteroidHttpClient; +import com.meteroid.internal.Utils; +import com.meteroid.models.UnattributedUsageResponse; +import com.meteroid.models.UsageResponse; + +import okhttp3.HttpUrl; + +import java.time.LocalDate; +import java.util.Objects; + +/** + * The {@code usage.customer} operations, blocking. {@link #withRawResponse()} has the same methods + * returning the status and headers along with the body. + */ +public final class UsageCustomer { + private final MeteroidHttpClient client; + private final WithRawResponse withRawResponse; + + /** + * The operations, sending through {@code client}. + * + * @param client the HTTP client of the SDK + */ + public UsageCustomer(MeteroidHttpClient client) { + this.client = client; + this.withRawResponse = new WithRawResponse(); + } + + /** + * The same operations, returning the status and headers along with the body. + * + * @return the operations + */ + public WithRawResponse withRawResponse() { + return withRawResponse; + } + + /** + * Get customer usage + * + *

Retrieve aggregated usage data for a customer over a specified period. + * + * @param customerId the {@code customer_id} path parameter + * @param startDate the {@code start_date} required parameter + * @param endDate the {@code end_date} required parameter + * @return the response body + */ + public UsageResponse retrieve( + final String customerId, final LocalDate startDate, final LocalDate endDate) { + return retrieve( + customerId, + startDate, + endDate, + UsageCustomerRetrieveOptions.none(), + RequestOptions.none()); + } + + /** + * Get customer usage + * + *

Retrieve aggregated usage data for a customer over a specified period. + * + * @param customerId the {@code customer_id} path parameter + * @param startDate the {@code start_date} required parameter + * @param endDate the {@code end_date} required parameter + * @param options the optional parameters + * @return the response body + */ + public UsageResponse retrieve( + final String customerId, + final LocalDate startDate, + final LocalDate endDate, + final UsageCustomerRetrieveOptions options) { + return retrieve(customerId, startDate, endDate, options, RequestOptions.none()); + } + + /** + * Get customer usage + * + *

Retrieve aggregated usage data for a customer over a specified period. + * + * @param customerId the {@code customer_id} path parameter + * @param startDate the {@code start_date} required parameter + * @param endDate the {@code end_date} required parameter + * @param requestOptions headers, timeout and retries of this call + * @return the response body + */ + public UsageResponse retrieve( + final String customerId, + final LocalDate startDate, + final LocalDate endDate, + final RequestOptions requestOptions) { + return retrieve( + customerId, + startDate, + endDate, + UsageCustomerRetrieveOptions.none(), + requestOptions); + } + + /** + * Get customer usage + * + *

Retrieve aggregated usage data for a customer over a specified period. + * + * @param customerId the {@code customer_id} path parameter + * @param startDate the {@code start_date} required parameter + * @param endDate the {@code end_date} required parameter + * @param options the optional parameters + * @param requestOptions headers, timeout and retries of this call + * @return the response body + */ + public UsageResponse retrieve( + final String customerId, + final LocalDate startDate, + final LocalDate endDate, + final UsageCustomerRetrieveOptions options, + final RequestOptions requestOptions) { + return exchangeRetrieve(customerId, startDate, endDate, options, requestOptions).send(); + } + + MeteroidHttpClient.Exchange exchangeRetrieve( + final String customerId, + final LocalDate startDate, + final LocalDate endDate, + final UsageCustomerRetrieveOptions options, + final RequestOptions requestOptions) { + Objects.requireNonNull(customerId, "customer_id"); + Objects.requireNonNull(startDate, "start_date"); + Objects.requireNonNull(endDate, "end_date"); + Objects.requireNonNull(options, "options"); + HttpUrl.Builder url = + client.newUrlBuilder() + .addPathSegments("api/v1/usage/customer") + .addPathSegment(Utils.pathSegment("customer_id", customerId)); + url.addQueryParameter("start_date", Utils.serializeQueryParam(startDate)); + url.addQueryParameter("end_date", Utils.serializeQueryParam(endDate)); + String value3 = options.metricId().orElse(null); + if (value3 != null) { + url.addQueryParameter("metric_id", value3); + } + return client.call("GET", url.build()) + .errors(com.meteroid.models.RestErrorResponse.class, "401", "404", "429", "500") + .options(requestOptions) + .returning(UsageResponse.class); + } + + /** + * Get unattributed usage + * + *

Retrieve a customer's usage that no subscription bills. When subscriptions of the customer + * pricing a metric set a usage filter, events matching none of the filters are billed by a + * subscription without one; when every such subscription has a filter, those events are kept + * and reported here instead of being billed. + * + * @param customerId the {@code customer_id} path parameter + * @return the response body + */ + public UnattributedUsageResponse retrieveUnattributed(final String customerId) { + return retrieveUnattributed( + customerId, UsageCustomerRetrieveUnattributedOptions.none(), RequestOptions.none()); + } + + /** + * Get unattributed usage + * + *

Retrieve a customer's usage that no subscription bills. When subscriptions of the customer + * pricing a metric set a usage filter, events matching none of the filters are billed by a + * subscription without one; when every such subscription has a filter, those events are kept + * and reported here instead of being billed. + * + * @param customerId the {@code customer_id} path parameter + * @param options the optional parameters + * @return the response body + */ + public UnattributedUsageResponse retrieveUnattributed( + final String customerId, final UsageCustomerRetrieveUnattributedOptions options) { + return retrieveUnattributed(customerId, options, RequestOptions.none()); + } + + /** + * Get unattributed usage + * + *

Retrieve a customer's usage that no subscription bills. When subscriptions of the customer + * pricing a metric set a usage filter, events matching none of the filters are billed by a + * subscription without one; when every such subscription has a filter, those events are kept + * and reported here instead of being billed. + * + * @param customerId the {@code customer_id} path parameter + * @param requestOptions headers, timeout and retries of this call + * @return the response body + */ + public UnattributedUsageResponse retrieveUnattributed( + final String customerId, final RequestOptions requestOptions) { + return retrieveUnattributed( + customerId, UsageCustomerRetrieveUnattributedOptions.none(), requestOptions); + } + + /** + * Get unattributed usage + * + *

Retrieve a customer's usage that no subscription bills. When subscriptions of the customer + * pricing a metric set a usage filter, events matching none of the filters are billed by a + * subscription without one; when every such subscription has a filter, those events are kept + * and reported here instead of being billed. + * + * @param customerId the {@code customer_id} path parameter + * @param options the optional parameters + * @param requestOptions headers, timeout and retries of this call + * @return the response body + */ + public UnattributedUsageResponse retrieveUnattributed( + final String customerId, + final UsageCustomerRetrieveUnattributedOptions options, + final RequestOptions requestOptions) { + return exchangeRetrieveUnattributed(customerId, options, requestOptions).send(); + } + + MeteroidHttpClient.Exchange exchangeRetrieveUnattributed( + final String customerId, + final UsageCustomerRetrieveUnattributedOptions options, + final RequestOptions requestOptions) { + Objects.requireNonNull(customerId, "customer_id"); + Objects.requireNonNull(options, "options"); + HttpUrl.Builder url = + client.newUrlBuilder() + .addPathSegments("api/v1/usage/customer") + .addPathSegment(Utils.pathSegment("customer_id", customerId)) + .addPathSegments("unattributed"); + LocalDate value1 = options.startDate().orElse(null); + if (value1 != null) { + url.addQueryParameter("start_date", Utils.serializeQueryParam(value1)); + } + LocalDate value2 = options.endDate().orElse(null); + if (value2 != null) { + url.addQueryParameter("end_date", Utils.serializeQueryParam(value2)); + } + return client.call("GET", url.build()) + .errors( + com.meteroid.models.RestErrorResponse.class, + "400", + "401", + "404", + "429", + "500") + .options(requestOptions) + .returning(UnattributedUsageResponse.class); + } + + /** The operations, returning the status and headers along with the body. */ + public final class WithRawResponse { + private WithRawResponse() {} + + /** + * Get customer usage + * + *

Retrieve aggregated usage data for a customer over a specified period. + * + * @param customerId the {@code customer_id} path parameter + * @param startDate the {@code start_date} required parameter + * @param endDate the {@code end_date} required parameter + * @return the status, headers and body + */ + public ApiResponse retrieve( + final String customerId, final LocalDate startDate, final LocalDate endDate) { + return retrieve( + customerId, + startDate, + endDate, + UsageCustomerRetrieveOptions.none(), + RequestOptions.none()); + } + + /** + * Get customer usage + * + *

Retrieve aggregated usage data for a customer over a specified period. + * + * @param customerId the {@code customer_id} path parameter + * @param startDate the {@code start_date} required parameter + * @param endDate the {@code end_date} required parameter + * @param options the optional parameters + * @return the status, headers and body + */ + public ApiResponse retrieve( + final String customerId, + final LocalDate startDate, + final LocalDate endDate, + final UsageCustomerRetrieveOptions options) { + return retrieve(customerId, startDate, endDate, options, RequestOptions.none()); + } + + /** + * Get customer usage + * + *

Retrieve aggregated usage data for a customer over a specified period. + * + * @param customerId the {@code customer_id} path parameter + * @param startDate the {@code start_date} required parameter + * @param endDate the {@code end_date} required parameter + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body + */ + public ApiResponse retrieve( + final String customerId, + final LocalDate startDate, + final LocalDate endDate, + final RequestOptions requestOptions) { + return retrieve( + customerId, + startDate, + endDate, + UsageCustomerRetrieveOptions.none(), + requestOptions); + } + + /** + * Get customer usage + * + *

Retrieve aggregated usage data for a customer over a specified period. + * + * @param customerId the {@code customer_id} path parameter + * @param startDate the {@code start_date} required parameter + * @param endDate the {@code end_date} required parameter + * @param options the optional parameters + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body + */ + public ApiResponse retrieve( + final String customerId, + final LocalDate startDate, + final LocalDate endDate, + final UsageCustomerRetrieveOptions options, + final RequestOptions requestOptions) { + return UsageCustomer.this + .exchangeRetrieve(customerId, startDate, endDate, options, requestOptions) + .sendRaw(); + } + + /** + * Get unattributed usage + * + *

Retrieve a customer's usage that no subscription bills. When subscriptions of the + * customer pricing a metric set a usage filter, events matching none of the filters are + * billed by a subscription without one; when every such subscription has a filter, those + * events are kept and reported here instead of being billed. + * + * @param customerId the {@code customer_id} path parameter + * @return the status, headers and body + */ + public ApiResponse retrieveUnattributed( + final String customerId) { + return retrieveUnattributed( + customerId, + UsageCustomerRetrieveUnattributedOptions.none(), + RequestOptions.none()); + } + + /** + * Get unattributed usage + * + *

Retrieve a customer's usage that no subscription bills. When subscriptions of the + * customer pricing a metric set a usage filter, events matching none of the filters are + * billed by a subscription without one; when every such subscription has a filter, those + * events are kept and reported here instead of being billed. + * + * @param customerId the {@code customer_id} path parameter + * @param options the optional parameters + * @return the status, headers and body + */ + public ApiResponse retrieveUnattributed( + final String customerId, final UsageCustomerRetrieveUnattributedOptions options) { + return retrieveUnattributed(customerId, options, RequestOptions.none()); + } + + /** + * Get unattributed usage + * + *

Retrieve a customer's usage that no subscription bills. When subscriptions of the + * customer pricing a metric set a usage filter, events matching none of the filters are + * billed by a subscription without one; when every such subscription has a filter, those + * events are kept and reported here instead of being billed. + * + * @param customerId the {@code customer_id} path parameter + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body + */ + public ApiResponse retrieveUnattributed( + final String customerId, final RequestOptions requestOptions) { + return retrieveUnattributed( + customerId, UsageCustomerRetrieveUnattributedOptions.none(), requestOptions); + } + + /** + * Get unattributed usage + * + *

Retrieve a customer's usage that no subscription bills. When subscriptions of the + * customer pricing a metric set a usage filter, events matching none of the filters are + * billed by a subscription without one; when every such subscription has a filter, those + * events are kept and reported here instead of being billed. + * + * @param customerId the {@code customer_id} path parameter + * @param options the optional parameters + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body + */ + public ApiResponse retrieveUnattributed( + final String customerId, + final UsageCustomerRetrieveUnattributedOptions options, + final RequestOptions requestOptions) { + return UsageCustomer.this + .exchangeRetrieveUnattributed(customerId, options, requestOptions) + .sendRaw(); + } + } +} diff --git a/src/main/java/com/meteroid/api/UsageCustomerAsync.java b/src/main/java/com/meteroid/api/UsageCustomerAsync.java new file mode 100644 index 0000000..8122fb6 --- /dev/null +++ b/src/main/java/com/meteroid/api/UsageCustomerAsync.java @@ -0,0 +1,360 @@ +// this file is @generated +package com.meteroid.api; + +import com.meteroid.ApiResponse; +import com.meteroid.RequestOptions; +import com.meteroid.models.UnattributedUsageResponse; +import com.meteroid.models.UsageResponse; + +import java.time.LocalDate; +import java.util.concurrent.CompletableFuture; + +/** + * The {@code usage.customer} operations, without blocking: each method returns a {@link + * CompletableFuture}. Obtained from {@code client.async()}. + */ +public final class UsageCustomerAsync { + private final UsageCustomer sync; + private final WithRawResponse withRawResponse; + + /** + * The operations, sending through {@code sync}. + * + * @param sync the blocking operations + */ + public UsageCustomerAsync(UsageCustomer sync) { + this.sync = sync; + this.withRawResponse = new WithRawResponse(); + } + + /** + * The same operations, returning the status and headers along with the body. + * + * @return the operations + */ + public WithRawResponse withRawResponse() { + return withRawResponse; + } + + /** + * Get customer usage + * + *

Retrieve aggregated usage data for a customer over a specified period. + * + * @param customerId the {@code customer_id} path parameter + * @param startDate the {@code start_date} required parameter + * @param endDate the {@code end_date} required parameter + * @return the response body, once received + */ + public CompletableFuture retrieve( + final String customerId, final LocalDate startDate, final LocalDate endDate) { + return retrieve( + customerId, + startDate, + endDate, + UsageCustomerRetrieveOptions.none(), + RequestOptions.none()); + } + + /** + * Get customer usage + * + *

Retrieve aggregated usage data for a customer over a specified period. + * + * @param customerId the {@code customer_id} path parameter + * @param startDate the {@code start_date} required parameter + * @param endDate the {@code end_date} required parameter + * @param options the optional parameters + * @return the response body, once received + */ + public CompletableFuture retrieve( + final String customerId, + final LocalDate startDate, + final LocalDate endDate, + final UsageCustomerRetrieveOptions options) { + return retrieve(customerId, startDate, endDate, options, RequestOptions.none()); + } + + /** + * Get customer usage + * + *

Retrieve aggregated usage data for a customer over a specified period. + * + * @param customerId the {@code customer_id} path parameter + * @param startDate the {@code start_date} required parameter + * @param endDate the {@code end_date} required parameter + * @param requestOptions headers, timeout and retries of this call + * @return the response body, once received + */ + public CompletableFuture retrieve( + final String customerId, + final LocalDate startDate, + final LocalDate endDate, + final RequestOptions requestOptions) { + return retrieve( + customerId, + startDate, + endDate, + UsageCustomerRetrieveOptions.none(), + requestOptions); + } + + /** + * Get customer usage + * + *

Retrieve aggregated usage data for a customer over a specified period. + * + * @param customerId the {@code customer_id} path parameter + * @param startDate the {@code start_date} required parameter + * @param endDate the {@code end_date} required parameter + * @param options the optional parameters + * @param requestOptions headers, timeout and retries of this call + * @return the response body, once received + */ + public CompletableFuture retrieve( + final String customerId, + final LocalDate startDate, + final LocalDate endDate, + final UsageCustomerRetrieveOptions options, + final RequestOptions requestOptions) { + return sync.exchangeRetrieve(customerId, startDate, endDate, options, requestOptions) + .sendAsync(); + } + + /** + * Get unattributed usage + * + *

Retrieve a customer's usage that no subscription bills. When subscriptions of the customer + * pricing a metric set a usage filter, events matching none of the filters are billed by a + * subscription without one; when every such subscription has a filter, those events are kept + * and reported here instead of being billed. + * + * @param customerId the {@code customer_id} path parameter + * @return the response body, once received + */ + public CompletableFuture retrieveUnattributed( + final String customerId) { + return retrieveUnattributed( + customerId, UsageCustomerRetrieveUnattributedOptions.none(), RequestOptions.none()); + } + + /** + * Get unattributed usage + * + *

Retrieve a customer's usage that no subscription bills. When subscriptions of the customer + * pricing a metric set a usage filter, events matching none of the filters are billed by a + * subscription without one; when every such subscription has a filter, those events are kept + * and reported here instead of being billed. + * + * @param customerId the {@code customer_id} path parameter + * @param options the optional parameters + * @return the response body, once received + */ + public CompletableFuture retrieveUnattributed( + final String customerId, final UsageCustomerRetrieveUnattributedOptions options) { + return retrieveUnattributed(customerId, options, RequestOptions.none()); + } + + /** + * Get unattributed usage + * + *

Retrieve a customer's usage that no subscription bills. When subscriptions of the customer + * pricing a metric set a usage filter, events matching none of the filters are billed by a + * subscription without one; when every such subscription has a filter, those events are kept + * and reported here instead of being billed. + * + * @param customerId the {@code customer_id} path parameter + * @param requestOptions headers, timeout and retries of this call + * @return the response body, once received + */ + public CompletableFuture retrieveUnattributed( + final String customerId, final RequestOptions requestOptions) { + return retrieveUnattributed( + customerId, UsageCustomerRetrieveUnattributedOptions.none(), requestOptions); + } + + /** + * Get unattributed usage + * + *

Retrieve a customer's usage that no subscription bills. When subscriptions of the customer + * pricing a metric set a usage filter, events matching none of the filters are billed by a + * subscription without one; when every such subscription has a filter, those events are kept + * and reported here instead of being billed. + * + * @param customerId the {@code customer_id} path parameter + * @param options the optional parameters + * @param requestOptions headers, timeout and retries of this call + * @return the response body, once received + */ + public CompletableFuture retrieveUnattributed( + final String customerId, + final UsageCustomerRetrieveUnattributedOptions options, + final RequestOptions requestOptions) { + return sync.exchangeRetrieveUnattributed(customerId, options, requestOptions).sendAsync(); + } + + /** The operations, returning the status and headers along with the body. */ + public final class WithRawResponse { + private WithRawResponse() {} + + /** + * Get customer usage + * + *

Retrieve aggregated usage data for a customer over a specified period. + * + * @param customerId the {@code customer_id} path parameter + * @param startDate the {@code start_date} required parameter + * @param endDate the {@code end_date} required parameter + * @return the status, headers and body, once received + */ + public CompletableFuture> retrieve( + final String customerId, final LocalDate startDate, final LocalDate endDate) { + return retrieve( + customerId, + startDate, + endDate, + UsageCustomerRetrieveOptions.none(), + RequestOptions.none()); + } + + /** + * Get customer usage + * + *

Retrieve aggregated usage data for a customer over a specified period. + * + * @param customerId the {@code customer_id} path parameter + * @param startDate the {@code start_date} required parameter + * @param endDate the {@code end_date} required parameter + * @param options the optional parameters + * @return the status, headers and body, once received + */ + public CompletableFuture> retrieve( + final String customerId, + final LocalDate startDate, + final LocalDate endDate, + final UsageCustomerRetrieveOptions options) { + return retrieve(customerId, startDate, endDate, options, RequestOptions.none()); + } + + /** + * Get customer usage + * + *

Retrieve aggregated usage data for a customer over a specified period. + * + * @param customerId the {@code customer_id} path parameter + * @param startDate the {@code start_date} required parameter + * @param endDate the {@code end_date} required parameter + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body, once received + */ + public CompletableFuture> retrieve( + final String customerId, + final LocalDate startDate, + final LocalDate endDate, + final RequestOptions requestOptions) { + return retrieve( + customerId, + startDate, + endDate, + UsageCustomerRetrieveOptions.none(), + requestOptions); + } + + /** + * Get customer usage + * + *

Retrieve aggregated usage data for a customer over a specified period. + * + * @param customerId the {@code customer_id} path parameter + * @param startDate the {@code start_date} required parameter + * @param endDate the {@code end_date} required parameter + * @param options the optional parameters + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body, once received + */ + public CompletableFuture> retrieve( + final String customerId, + final LocalDate startDate, + final LocalDate endDate, + final UsageCustomerRetrieveOptions options, + final RequestOptions requestOptions) { + return sync.exchangeRetrieve(customerId, startDate, endDate, options, requestOptions) + .sendRawAsync(); + } + + /** + * Get unattributed usage + * + *

Retrieve a customer's usage that no subscription bills. When subscriptions of the + * customer pricing a metric set a usage filter, events matching none of the filters are + * billed by a subscription without one; when every such subscription has a filter, those + * events are kept and reported here instead of being billed. + * + * @param customerId the {@code customer_id} path parameter + * @return the status, headers and body, once received + */ + public CompletableFuture> retrieveUnattributed( + final String customerId) { + return retrieveUnattributed( + customerId, + UsageCustomerRetrieveUnattributedOptions.none(), + RequestOptions.none()); + } + + /** + * Get unattributed usage + * + *

Retrieve a customer's usage that no subscription bills. When subscriptions of the + * customer pricing a metric set a usage filter, events matching none of the filters are + * billed by a subscription without one; when every such subscription has a filter, those + * events are kept and reported here instead of being billed. + * + * @param customerId the {@code customer_id} path parameter + * @param options the optional parameters + * @return the status, headers and body, once received + */ + public CompletableFuture> retrieveUnattributed( + final String customerId, final UsageCustomerRetrieveUnattributedOptions options) { + return retrieveUnattributed(customerId, options, RequestOptions.none()); + } + + /** + * Get unattributed usage + * + *

Retrieve a customer's usage that no subscription bills. When subscriptions of the + * customer pricing a metric set a usage filter, events matching none of the filters are + * billed by a subscription without one; when every such subscription has a filter, those + * events are kept and reported here instead of being billed. + * + * @param customerId the {@code customer_id} path parameter + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body, once received + */ + public CompletableFuture> retrieveUnattributed( + final String customerId, final RequestOptions requestOptions) { + return retrieveUnattributed( + customerId, UsageCustomerRetrieveUnattributedOptions.none(), requestOptions); + } + + /** + * Get unattributed usage + * + *

Retrieve a customer's usage that no subscription bills. When subscriptions of the + * customer pricing a metric set a usage filter, events matching none of the filters are + * billed by a subscription without one; when every such subscription has a filter, those + * events are kept and reported here instead of being billed. + * + * @param customerId the {@code customer_id} path parameter + * @param options the optional parameters + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body, once received + */ + public CompletableFuture> retrieveUnattributed( + final String customerId, + final UsageCustomerRetrieveUnattributedOptions options, + final RequestOptions requestOptions) { + return sync.exchangeRetrieveUnattributed(customerId, options, requestOptions) + .sendRawAsync(); + } + } +} diff --git a/src/main/java/com/meteroid/api/UsageRetrieveCustomerOptions.java b/src/main/java/com/meteroid/api/UsageCustomerRetrieveOptions.java similarity index 76% rename from src/main/java/com/meteroid/api/UsageRetrieveCustomerOptions.java rename to src/main/java/com/meteroid/api/UsageCustomerRetrieveOptions.java index 0479090..f22ffe3 100644 --- a/src/main/java/com/meteroid/api/UsageRetrieveCustomerOptions.java +++ b/src/main/java/com/meteroid/api/UsageCustomerRetrieveOptions.java @@ -4,13 +4,11 @@ import java.util.Objects; import java.util.Optional; -/** - * Optional parameters of {@code retrieveCustomer}, immutable: build them with {@link #builder()}. - */ -public final class UsageRetrieveCustomerOptions { +/** Optional parameters of {@code retrieve}, immutable: build them with {@link #builder()}. */ +public final class UsageCustomerRetrieveOptions { private final String metricId; - private UsageRetrieveCustomerOptions(Builder builder) { + private UsageCustomerRetrieveOptions(Builder builder) { this.metricId = builder.metricId; } @@ -28,7 +26,7 @@ public static Builder builder() { * * @return empty parameters */ - public static UsageRetrieveCustomerOptions none() { + public static UsageCustomerRetrieveOptions none() { return builder().build(); } @@ -60,7 +58,7 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } - UsageRetrieveCustomerOptions that = (UsageRetrieveCustomerOptions) o; + UsageCustomerRetrieveOptions that = (UsageCustomerRetrieveOptions) o; return Objects.equals(metricId, that.metricId); } @@ -71,10 +69,10 @@ public int hashCode() { @Override public String toString() { - return "UsageRetrieveCustomerOptions{" + "metricId=" + metricId + "}"; + return "UsageCustomerRetrieveOptions{" + "metricId=" + metricId + "}"; } - /** Builds {@link UsageRetrieveCustomerOptions}. */ + /** Builds {@link UsageCustomerRetrieveOptions}. */ public static final class Builder { private String metricId; @@ -96,8 +94,8 @@ public Builder metricId(String metricId) { * * @return immutable parameters */ - public UsageRetrieveCustomerOptions build() { - return new UsageRetrieveCustomerOptions(this); + public UsageCustomerRetrieveOptions build() { + return new UsageCustomerRetrieveOptions(this); } } } diff --git a/src/main/java/com/meteroid/api/UsageCustomerRetrieveUnattributedOptions.java b/src/main/java/com/meteroid/api/UsageCustomerRetrieveUnattributedOptions.java new file mode 100644 index 0000000..8662d75 --- /dev/null +++ b/src/main/java/com/meteroid/api/UsageCustomerRetrieveUnattributedOptions.java @@ -0,0 +1,135 @@ +// this file is @generated +package com.meteroid.api; + +import java.time.LocalDate; +import java.util.Objects; +import java.util.Optional; + +/** + * Optional parameters of {@code retrieveUnattributed}, immutable: build them with {@link + * #builder()}. + */ +public final class UsageCustomerRetrieveUnattributedOptions { + private final LocalDate startDate; + private final LocalDate endDate; + + private UsageCustomerRetrieveUnattributedOptions(Builder builder) { + this.startDate = builder.startDate; + this.endDate = builder.endDate; + } + + /** + * A builder of parameters. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * No parameters. + * + * @return empty parameters + */ + public static UsageCustomerRetrieveUnattributedOptions none() { + return builder().build(); + } + + /** + * A builder starting from these parameters. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.startDate = startDate; + builder.endDate = endDate; + return builder; + } + + /** + * First day of the range. Defaults to the first day of the current month (UTC). + * + * @return the value, empty when unset + */ + public Optional startDate() { + return Optional.ofNullable(startDate); + } + + /** + * Day after the range (exclusive). Defaults to the first day of the next month. + * + * @return the value, empty when unset + */ + public Optional endDate() { + return Optional.ofNullable(endDate); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + UsageCustomerRetrieveUnattributedOptions that = + (UsageCustomerRetrieveUnattributedOptions) o; + return Objects.equals(startDate, that.startDate) && Objects.equals(endDate, that.endDate); + } + + @Override + public int hashCode() { + return Objects.hash(startDate, endDate); + } + + @Override + public String toString() { + return "UsageCustomerRetrieveUnattributedOptions{" + + "startDate=" + + startDate + + ", endDate=" + + endDate + + "}"; + } + + /** Builds {@link UsageCustomerRetrieveUnattributedOptions}. */ + public static final class Builder { + private LocalDate startDate; + private LocalDate endDate; + + private Builder() {} + + /** + * First day of the range. Defaults to the first day of the current month (UTC). + * + * @param startDate the value, null to leave it out + * @return this builder + */ + public Builder startDate(LocalDate startDate) { + this.startDate = startDate; + return this; + } + + /** + * Day after the range (exclusive). Defaults to the first day of the next month. + * + * @param endDate the value, null to leave it out + * @return this builder + */ + public Builder endDate(LocalDate endDate) { + this.endDate = endDate; + return this; + } + + /** + * The parameters. + * + * @return immutable parameters + */ + public UsageCustomerRetrieveUnattributedOptions build() { + return new UsageCustomerRetrieveUnattributedOptions(this); + } + } +} diff --git a/src/main/java/com/meteroid/models/Actor.java b/src/main/java/com/meteroid/models/Actor.java new file mode 100644 index 0000000..1b94626 --- /dev/null +++ b/src/main/java/com/meteroid/models/Actor.java @@ -0,0 +1,237 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.JsonField; +import com.meteroid.internal.Utils; + +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +/** + * Who made a change. + * + *

Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonAutoDetect( + getterVisibility = Visibility.NONE, + isGetterVisibility = Visibility.NONE, + setterVisibility = Visibility.NONE) +public final class Actor { + @JsonProperty("id") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField id = JsonField.missing(); + + @JsonProperty("type") + private ActorType type; + + private final Map additionalProperties = new LinkedHashMap<>(); + + private Actor() {} + + private Actor(Builder builder) { + this.id = builder.id; + this.type = builder.type; + this.additionalProperties.putAll(builder.additionalProperties); + } + + /** + * A builder of {@code Actor}. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * A builder starting from this value. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.id = id; + builder.type = type; + builder.additionalProperties.putAll(additionalProperties); + return builder; + } + + /** + * The user's id (usr_…) for USER, the customer's (cus_…) for + * CUSTOMER, the API key's or app's for API_KEY and OAUTH_APP; absent for SYSTEM. + * + * @return the value, empty when unset or null + */ + public Optional id() { + return id.asOptional(); + } + + /** + * USER, CUSTOMER, API_KEY, OAUTH_APP or SYSTEM. + * + * @return the value, never null + */ + public ActorType type() { + return Utils.required(type, "type"); + } + + /** + * Properties this version of the SDK does not know, kept as received and sent back. + * + * @return the properties by name, unmodifiable + */ + public Map additionalProperties() { + return Collections.unmodifiableMap(additionalProperties); + } + + @JsonAnyGetter + private Map anyProperties() { + return additionalProperties; + } + + @JsonAnySetter + private void putAnyProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Actor that = (Actor) o; + return Objects.equals(id, that.id) + && Objects.equals(type, that.type) + && Objects.equals(additionalProperties, that.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(id, type, additionalProperties); + } + + @Override + public String toString() { + return "Actor{" + + "id=" + + id + + ", type=" + + type + + ", additionalProperties=" + + additionalProperties + + "}"; + } + + /** Builds {@link Actor}. */ + public static final class Builder { + private JsonField id = JsonField.missing(); + private ActorType type; + private final Map additionalProperties = new LinkedHashMap<>(); + + private Builder() {} + + /** + * The user's id (usr_…) for USER, the customer's (cus_…) for + * CUSTOMER, the API key's or app's for API_KEY and OAUTH_APP; absent for SYSTEM. + * + * @param id the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder id(String id) { + this.id = JsonField.ofNullable(id); + return this; + } + + /** + * USER, CUSTOMER, API_KEY, OAUTH_APP or SYSTEM. + * + * @param type the value + * @return this builder + */ + public Builder type(ActorType type) { + this.type = type; + return this; + } + + /** + * A property the SDK does not know, sent along. + * + * @param name the property name + * @param value the JSON value + * @return this builder + */ + public Builder putAdditionalProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + return this; + } + + /** + * Properties the SDK does not know, sent along. + * + * @param additionalProperties the properties by name + * @return this builder + */ + public Builder putAllAdditionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + + /** + * Leaves out a property the SDK does not know. + * + * @param name the property name + * @return this builder + */ + public Builder removeAdditionalProperty(String name) { + additionalProperties.remove(name); + return this; + } + + /** + * The {@code Actor}. + * + * @return the immutable value + * @throws IllegalStateException when a required property is not set + */ + public Actor build() { + Utils.checkRequired(type, "type"); + return new Actor(this); + } + } + + /** + * Parse {@code json} as {@code Actor}. + * + * @param json the JSON text + * @return the value + * @throws com.meteroid.exceptions.InvalidDataException if it is not valid JSON of this shape + */ + public static Actor fromJson(String json) { + return Utils.parse(json, Actor.class); + } + + /** + * This value as JSON. + * + * @return the JSON text + */ + public String toJson() { + return Utils.json(this); + } +} diff --git a/src/main/java/com/meteroid/models/ActorType.java b/src/main/java/com/meteroid/models/ActorType.java new file mode 100644 index 0000000..c37d510 --- /dev/null +++ b/src/main/java/com/meteroid/models/ActorType.java @@ -0,0 +1,150 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import com.meteroid.internal.Utils.ToQueryParam; + +import java.util.Map; +import java.util.Objects; + +/** + * Values this version of the SDK does not know are kept, and sent back unchanged: {@link #value()} + * is an enum to switch on, {@code _UNKNOWN} for them, and {@link #known()} throws on them. + */ +public final class ActorType implements ToQueryParam { + /** The value {@code "USER"}. */ + public static final ActorType USER = new ActorType("USER", Value.USER); + + /** The value {@code "CUSTOMER"}. */ + public static final ActorType CUSTOMER = new ActorType("CUSTOMER", Value.CUSTOMER); + + /** The value {@code "SYSTEM"}. */ + public static final ActorType SYSTEM = new ActorType("SYSTEM", Value.SYSTEM); + + /** The value {@code "API_KEY"}. */ + public static final ActorType API_KEY = new ActorType("API_KEY", Value.API_KEY); + + /** The value {@code "OAUTH_APP"}. */ + public static final ActorType OAUTH_APP = new ActorType("OAUTH_APP", Value.OAUTH_APP); + + private static final Map constants = + Map.ofEntries( + Map.entry("USER", USER), + Map.entry("CUSTOMER", CUSTOMER), + Map.entry("SYSTEM", SYSTEM), + Map.entry("API_KEY", API_KEY), + Map.entry("OAUTH_APP", OAUTH_APP)); + + private final String value; + private final Value variant; + + private ActorType(String value, Value variant) { + this.value = value; + this.variant = variant; + } + + /** + * The constant for {@code value}, or an unknown ActorType holding it. + * + * @param value the value + * @return the constant + */ + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static ActorType of(String value) { + ActorType constant = constants.get(Objects.requireNonNull(value, "value")); + return constant != null ? constant : new ActorType(value, Value._UNKNOWN); + } + + /** + * The value as sent. + * + * @return the value + */ + @JsonValue + public String asString() { + return value; + } + + /** + * Whether this version of the SDK knows the value. + * + * @return whether it is known + */ + public boolean isKnown() { + return variant != Value._UNKNOWN; + } + + /** + * The value as an enum to switch on, unknown values included. + * + * @return the enum, {@code _UNKNOWN} when unknown + */ + public Value value() { + return variant; + } + + /** + * The value as an enum of the known values only. + * + * @return the enum + * @throws com.meteroid.exceptions.InvalidDataException when this version of the SDK does not + * know the value + */ + public Known known() { + if (!isKnown()) { + throw new com.meteroid.exceptions.InvalidDataException("unknown ActorType: " + value); + } + return Known.valueOf(variant.name()); + } + + @Override + public String toQueryParam() { + return String.valueOf(value); + } + + @Override + public boolean equals(Object o) { + return o instanceof ActorType && Objects.equals(value, ((ActorType) o).value); + } + + @Override + public int hashCode() { + return Objects.hashCode(value); + } + + @Override + public String toString() { + return String.valueOf(value); + } + + /** The values this version of the SDK knows. */ + public enum Known { + /** The {@code USER} constant. */ + USER, + /** The {@code CUSTOMER} constant. */ + CUSTOMER, + /** The {@code SYSTEM} constant. */ + SYSTEM, + /** The {@code API_KEY} constant. */ + API_KEY, + /** The {@code OAUTH_APP} constant. */ + OAUTH_APP + } + + /** The values this version of the SDK knows, and {@code _UNKNOWN} for the others. */ + public enum Value { + /** The {@code USER} constant. */ + USER, + /** The {@code CUSTOMER} constant. */ + CUSTOMER, + /** The {@code SYSTEM} constant. */ + SYSTEM, + /** The {@code API_KEY} constant. */ + API_KEY, + /** The {@code OAUTH_APP} constant. */ + OAUTH_APP, + /** A value this version of the SDK does not know. */ + _UNKNOWN + } +} diff --git a/src/main/java/com/meteroid/models/AllComponentsScope.java b/src/main/java/com/meteroid/models/AllComponentsScope.java index 27daa3a..86a0e07 100644 --- a/src/main/java/com/meteroid/models/AllComponentsScope.java +++ b/src/main/java/com/meteroid/models/AllComponentsScope.java @@ -7,6 +7,7 @@ import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.JsonNode; import com.meteroid.internal.Utils; @@ -27,11 +28,15 @@ isGetterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE) public final class AllComponentsScope { + @JsonProperty("type") + private String type = "all_components"; + private final Map additionalProperties = new LinkedHashMap<>(); private AllComponentsScope() {} private AllComponentsScope(Builder builder) { + this.type = builder.type; this.additionalProperties.putAll(builder.additionalProperties); } @@ -51,10 +56,20 @@ public static Builder builder() { */ public Builder toBuilder() { Builder builder = new Builder(); + builder.type = type; builder.additionalProperties.putAll(additionalProperties); return builder; } + /** + * The {@code type} property. + * + * @return the value, never null + */ + public String type() { + return Utils.required(type, "type"); + } + /** * Properties this version of the SDK does not know, kept as received and sent back. * @@ -83,25 +98,43 @@ public boolean equals(Object o) { return false; } AllComponentsScope that = (AllComponentsScope) o; - return Objects.equals(additionalProperties, that.additionalProperties); + return Objects.equals(type, that.type) + && Objects.equals(additionalProperties, that.additionalProperties); } @Override public int hashCode() { - return Objects.hash(additionalProperties); + return Objects.hash(type, additionalProperties); } @Override public String toString() { - return "AllComponentsScope{" + "additionalProperties=" + additionalProperties + "}"; + return "AllComponentsScope{" + + "type=" + + type + + ", additionalProperties=" + + additionalProperties + + "}"; } /** Builds {@link AllComponentsScope}. */ public static final class Builder { + private String type = "all_components"; private final Map additionalProperties = new LinkedHashMap<>(); private Builder() {} + /** + * The {@code type} property. + * + * @param type the value + * @return this builder + */ + public Builder type(String type) { + this.type = type; + return this; + } + /** * A property the SDK does not know, sent along. * @@ -143,6 +176,7 @@ public Builder removeAdditionalProperty(String name) { * @throws IllegalStateException when a required property is not set */ public AllComponentsScope build() { + Utils.checkRequired(type, "type"); return new AllComponentsScope(this); } } diff --git a/src/main/java/com/meteroid/models/AutoTopUp.java b/src/main/java/com/meteroid/models/AutoTopUp.java new file mode 100644 index 0000000..c59e15a --- /dev/null +++ b/src/main/java/com/meteroid/models/AutoTopUp.java @@ -0,0 +1,621 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.JsonField; +import com.meteroid.internal.Utils; + +import java.time.OffsetDateTime; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +/** + * Automatic top-up of the credit that applies to ALL charges: it charges the customer's payment + * method when the balance falls below threshold. + * + *

Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonAutoDetect( + getterVisibility = Visibility.NONE, + isGetterVisibility = Visibility.NONE, + setterVisibility = Visibility.NONE) +public final class AutoTopUp { + @JsonProperty("amount") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField amount = JsonField.missing(); + + @JsonProperty("customer_consent_attested_at") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField customerConsentAttestedAt = JsonField.missing(); + + @JsonProperty("daily_cap") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField dailyCap = JsonField.missing(); + + @JsonProperty("last_error") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField lastError = JsonField.missing(); + + @JsonProperty("last_succeeded_at") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField lastSucceededAt = JsonField.missing(); + + @JsonProperty("maximum") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField maximum = JsonField.missing(); + + @JsonProperty("method") + private AutoTopUpMethod method; + + @JsonProperty("minimum") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField minimum = JsonField.missing(); + + @JsonProperty("monthly_cap") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField monthlyCap = JsonField.missing(); + + @JsonProperty("payment_method_id") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField paymentMethodId = JsonField.missing(); + + @JsonProperty("status") + private AutoTopUpStatus status; + + @JsonProperty("suspended_at") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField suspendedAt = JsonField.missing(); + + @JsonProperty("target") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField target = JsonField.missing(); + + @JsonProperty("threshold") + private Long threshold; + + private final Map additionalProperties = new LinkedHashMap<>(); + + private AutoTopUp() {} + + private AutoTopUp(Builder builder) { + this.amount = builder.amount; + this.customerConsentAttestedAt = builder.customerConsentAttestedAt; + this.dailyCap = builder.dailyCap; + this.lastError = builder.lastError; + this.lastSucceededAt = builder.lastSucceededAt; + this.maximum = builder.maximum; + this.method = builder.method; + this.minimum = builder.minimum; + this.monthlyCap = builder.monthlyCap; + this.paymentMethodId = builder.paymentMethodId; + this.status = builder.status; + this.suspendedAt = builder.suspendedAt; + this.target = builder.target; + this.threshold = builder.threshold; + this.additionalProperties.putAll(builder.additionalProperties); + } + + /** + * A builder of {@code AutoTopUp}. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * A builder starting from this value. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.amount = amount; + builder.customerConsentAttestedAt = customerConsentAttestedAt; + builder.dailyCap = dailyCap; + builder.lastError = lastError; + builder.lastSucceededAt = lastSucceededAt; + builder.maximum = maximum; + builder.method = method; + builder.minimum = minimum; + builder.monthlyCap = monthlyCap; + builder.paymentMethodId = paymentMethodId; + builder.status = status; + builder.suspendedAt = suspendedAt; + builder.target = target; + builder.threshold = threshold; + builder.additionalProperties.putAll(additionalProperties); + return builder; + } + + /** + * FIXED only: credit bought each time, in minor units of the wallet. + * + * @return the value, empty when unset or null + */ + public Optional amount() { + return amount.asOptional(); + } + + /** + * When an operator attested that the customer agreed to automatic charges on exactly these + * terms. Absent when the customer confirmed them in their portal, or the terms changed since. + * + * @return the value, empty when unset or null + */ + public Optional customerConsentAttestedAt() { + return customerConsentAttestedAt.asOptional(); + } + + /** + * Most charged in a rolling day, tax included. For a credit unit wallet caps are money, in + * minor units of the customer's currency. + * + * @return the value, empty when unset or null + */ + public Optional dailyCap() { + return dailyCap.asOptional(); + } + + /** + * Why the last charge failed; may carry payment provider detail. + * + * @return the value, empty when unset or null + */ + public Optional lastError() { + return lastError.asOptional(); + } + + /** + * The last charge that succeeded. + * + * @return the value, empty when unset or null + */ + public Optional lastSucceededAt() { + return lastSucceededAt.asOptional(); + } + + /** + * Largest single charge, in the same money as minimum. + * + * @return the value, empty when unset or null + */ + public Optional maximum() { + return maximum.asOptional(); + } + + /** + * FIXED buys amount each time; TO_TARGET buys back up to target. + * + * @return the value, never null + */ + public AutoTopUpMethod method() { + return Utils.required(method, "method"); + } + + /** + * Smallest single charge. For a credit unit wallet it is money (the price before tax, in minor + * units of the customer's currency), like the caps; the threshold, amount and target are + * credits. + * + * @return the value, empty when unset or null + */ + public Optional minimum() { + return minimum.asOptional(); + } + + /** + * Most charged in a calendar month (UTC), tax included. + * + * @return the value, empty when unset or null + */ + public Optional monthlyCap() { + return monthlyCap.asOptional(); + } + + /** + * Absent charges the customer's default payment method. + * + * @return the value, empty when unset or null + */ + public Optional paymentMethodId() { + return paymentMethodId.asOptional(); + } + + /** + * ACTIVE, DISABLED (terms kept) or SUSPENDED after repeated failed charges. + * + * @return the value, never null + */ + public AutoTopUpStatus status() { + return Utils.required(status, "status"); + } + + /** + * Set while SUSPENDED: since when. + * + * @return the value, empty when unset or null + */ + public Optional suspendedAt() { + return suspendedAt.asOptional(); + } + + /** + * TO_TARGET only: the balance a top-up brings the wallet back to, in minor units. + * + * @return the value, empty when unset or null + */ + public Optional target() { + return target.asOptional(); + } + + /** + * Tops up once the balance is at or below this, in minor units of the wallet. + * + * @return the value, never null + */ + public Long threshold() { + return Utils.required(threshold, "threshold"); + } + + /** + * Properties this version of the SDK does not know, kept as received and sent back. + * + * @return the properties by name, unmodifiable + */ + public Map additionalProperties() { + return Collections.unmodifiableMap(additionalProperties); + } + + @JsonAnyGetter + private Map anyProperties() { + return additionalProperties; + } + + @JsonAnySetter + private void putAnyProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AutoTopUp that = (AutoTopUp) o; + return Objects.equals(amount, that.amount) + && Objects.equals(customerConsentAttestedAt, that.customerConsentAttestedAt) + && Objects.equals(dailyCap, that.dailyCap) + && Objects.equals(lastError, that.lastError) + && Objects.equals(lastSucceededAt, that.lastSucceededAt) + && Objects.equals(maximum, that.maximum) + && Objects.equals(method, that.method) + && Objects.equals(minimum, that.minimum) + && Objects.equals(monthlyCap, that.monthlyCap) + && Objects.equals(paymentMethodId, that.paymentMethodId) + && Objects.equals(status, that.status) + && Objects.equals(suspendedAt, that.suspendedAt) + && Objects.equals(target, that.target) + && Objects.equals(threshold, that.threshold) + && Objects.equals(additionalProperties, that.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash( + amount, + customerConsentAttestedAt, + dailyCap, + lastError, + lastSucceededAt, + maximum, + method, + minimum, + monthlyCap, + paymentMethodId, + status, + suspendedAt, + target, + threshold, + additionalProperties); + } + + @Override + public String toString() { + return "AutoTopUp{" + + "amount=" + + amount + + ", customerConsentAttestedAt=" + + customerConsentAttestedAt + + ", dailyCap=" + + dailyCap + + ", lastError=" + + lastError + + ", lastSucceededAt=" + + lastSucceededAt + + ", maximum=" + + maximum + + ", method=" + + method + + ", minimum=" + + minimum + + ", monthlyCap=" + + monthlyCap + + ", paymentMethodId=" + + paymentMethodId + + ", status=" + + status + + ", suspendedAt=" + + suspendedAt + + ", target=" + + target + + ", threshold=" + + threshold + + ", additionalProperties=" + + additionalProperties + + "}"; + } + + /** Builds {@link AutoTopUp}. */ + public static final class Builder { + private JsonField amount = JsonField.missing(); + private JsonField customerConsentAttestedAt = JsonField.missing(); + private JsonField dailyCap = JsonField.missing(); + private JsonField lastError = JsonField.missing(); + private JsonField lastSucceededAt = JsonField.missing(); + private JsonField maximum = JsonField.missing(); + private AutoTopUpMethod method; + private JsonField minimum = JsonField.missing(); + private JsonField monthlyCap = JsonField.missing(); + private JsonField paymentMethodId = JsonField.missing(); + private AutoTopUpStatus status; + private JsonField suspendedAt = JsonField.missing(); + private JsonField target = JsonField.missing(); + private Long threshold; + private final Map additionalProperties = new LinkedHashMap<>(); + + private Builder() {} + + /** + * FIXED only: credit bought each time, in minor units of the wallet. + * + * @param amount the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder amount(Long amount) { + this.amount = JsonField.ofNullable(amount); + return this; + } + + /** + * When an operator attested that the customer agreed to automatic charges on exactly these + * terms. Absent when the customer confirmed them in their portal, or the terms changed + * since. + * + * @param customerConsentAttestedAt the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder customerConsentAttestedAt(OffsetDateTime customerConsentAttestedAt) { + this.customerConsentAttestedAt = JsonField.ofNullable(customerConsentAttestedAt); + return this; + } + + /** + * Most charged in a rolling day, tax included. For a credit unit wallet caps are money, in + * minor units of the customer's currency. + * + * @param dailyCap the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder dailyCap(Long dailyCap) { + this.dailyCap = JsonField.ofNullable(dailyCap); + return this; + } + + /** + * Why the last charge failed; may carry payment provider detail. + * + * @param lastError the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder lastError(String lastError) { + this.lastError = JsonField.ofNullable(lastError); + return this; + } + + /** + * The last charge that succeeded. + * + * @param lastSucceededAt the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder lastSucceededAt(OffsetDateTime lastSucceededAt) { + this.lastSucceededAt = JsonField.ofNullable(lastSucceededAt); + return this; + } + + /** + * Largest single charge, in the same money as minimum. + * + * @param maximum the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder maximum(Long maximum) { + this.maximum = JsonField.ofNullable(maximum); + return this; + } + + /** + * FIXED buys amount each time; TO_TARGET buys back up to target. + * + * @param method the value + * @return this builder + */ + public Builder method(AutoTopUpMethod method) { + this.method = method; + return this; + } + + /** + * Smallest single charge. For a credit unit wallet it is money (the price before tax, in + * minor units of the customer's currency), like the caps; the threshold, amount and target + * are credits. + * + * @param minimum the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder minimum(Long minimum) { + this.minimum = JsonField.ofNullable(minimum); + return this; + } + + /** + * Most charged in a calendar month (UTC), tax included. + * + * @param monthlyCap the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder monthlyCap(Long monthlyCap) { + this.monthlyCap = JsonField.ofNullable(monthlyCap); + return this; + } + + /** + * Absent charges the customer's default payment method. + * + * @param paymentMethodId the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder paymentMethodId(String paymentMethodId) { + this.paymentMethodId = JsonField.ofNullable(paymentMethodId); + return this; + } + + /** + * ACTIVE, DISABLED (terms kept) or SUSPENDED after repeated failed charges. + * + * @param status the value + * @return this builder + */ + public Builder status(AutoTopUpStatus status) { + this.status = status; + return this; + } + + /** + * Set while SUSPENDED: since when. + * + * @param suspendedAt the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder suspendedAt(OffsetDateTime suspendedAt) { + this.suspendedAt = JsonField.ofNullable(suspendedAt); + return this; + } + + /** + * TO_TARGET only: the balance a top-up brings the wallet back to, in minor units. + * + * @param target the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder target(Long target) { + this.target = JsonField.ofNullable(target); + return this; + } + + /** + * Tops up once the balance is at or below this, in minor units of the wallet. + * + * @param threshold the value + * @return this builder + */ + public Builder threshold(Long threshold) { + this.threshold = threshold; + return this; + } + + /** + * A property the SDK does not know, sent along. + * + * @param name the property name + * @param value the JSON value + * @return this builder + */ + public Builder putAdditionalProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + return this; + } + + /** + * Properties the SDK does not know, sent along. + * + * @param additionalProperties the properties by name + * @return this builder + */ + public Builder putAllAdditionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + + /** + * Leaves out a property the SDK does not know. + * + * @param name the property name + * @return this builder + */ + public Builder removeAdditionalProperty(String name) { + additionalProperties.remove(name); + return this; + } + + /** + * The {@code AutoTopUp}. + * + * @return the immutable value + * @throws IllegalStateException when a required property is not set + */ + public AutoTopUp build() { + Utils.checkRequired(method, "method"); + Utils.checkRequired(status, "status"); + Utils.checkRequired(threshold, "threshold"); + return new AutoTopUp(this); + } + } + + /** + * Parse {@code json} as {@code AutoTopUp}. + * + * @param json the JSON text + * @return the value + * @throws com.meteroid.exceptions.InvalidDataException if it is not valid JSON of this shape + */ + public static AutoTopUp fromJson(String json) { + return Utils.parse(json, AutoTopUp.class); + } + + /** + * This value as JSON. + * + * @return the JSON text + */ + public String toJson() { + return Utils.json(this); + } +} diff --git a/src/main/java/com/meteroid/models/AutoTopUpCapReachedEvent.java b/src/main/java/com/meteroid/models/AutoTopUpCapReachedEvent.java new file mode 100644 index 0000000..b18f267 --- /dev/null +++ b/src/main/java/com/meteroid/models/AutoTopUpCapReachedEvent.java @@ -0,0 +1,284 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.Unions; +import com.meteroid.internal.Utils; + +import java.time.OffsetDateTime; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; + +/** Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonAutoDetect( + getterVisibility = Visibility.NONE, + isGetterVisibility = Visibility.NONE, + setterVisibility = Visibility.NONE) +public final class AutoTopUpCapReachedEvent { + @JsonProperty("id") + private String id; + + @JsonProperty("timestamp") + private OffsetDateTime timestamp; + + @JsonProperty("type") + private EventType type; + + private final Map additionalProperties = new LinkedHashMap<>(); + + private AutoTopUpCapReachedEvent() {} + + private AutoTopUpCapReachedEvent(Builder builder) { + this.id = builder.id; + this.timestamp = builder.timestamp; + this.type = builder.type; + this.additionalProperties.putAll(builder.additionalProperties); + } + + /** + * A builder of {@code AutoTopUpCapReachedEvent}. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * A builder starting from this value. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.id = id; + builder.timestamp = timestamp; + builder.type = type; + builder.additionalProperties.putAll(additionalProperties); + return builder; + } + + /** + * The properties of {@link AutoTopUpCapReachedEventData}, which this schema extends. + * + * @return the properties of this part + */ + public AutoTopUpCapReachedEventData autoTopUpCapReachedEventData() { + return Unions.convert(additionalProperties, AutoTopUpCapReachedEventData.class); + } + + /** + * The {@code id} property. + * + * @return the value, never null + */ + public String id() { + return Utils.required(id, "id"); + } + + /** + * The {@code timestamp} property. + * + * @return the value, never null + */ + public OffsetDateTime timestamp() { + return Utils.required(timestamp, "timestamp"); + } + + /** + * The {@code type} property. + * + * @return the value, never null + */ + public EventType type() { + return Utils.required(type, "type"); + } + + /** + * Properties this version of the SDK does not know, kept as received and sent back. + * + * @return the properties by name, unmodifiable + */ + public Map additionalProperties() { + Map unknown = new LinkedHashMap<>(additionalProperties); + unknown.keySet().retainAll(autoTopUpCapReachedEventData().additionalProperties().keySet()); + return Collections.unmodifiableMap(unknown); + } + + @JsonAnyGetter + private Map anyProperties() { + return additionalProperties; + } + + @JsonAnySetter + private void putAnyProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AutoTopUpCapReachedEvent that = (AutoTopUpCapReachedEvent) o; + return Objects.equals(id, that.id) + && Objects.equals(timestamp, that.timestamp) + && Objects.equals(type, that.type) + && Objects.equals(additionalProperties, that.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(id, timestamp, type, additionalProperties); + } + + @Override + public String toString() { + return "AutoTopUpCapReachedEvent{" + + "id=" + + id + + ", timestamp=" + + timestamp + + ", type=" + + type + + ", additionalProperties=" + + additionalProperties + + "}"; + } + + /** Builds {@link AutoTopUpCapReachedEvent}. */ + public static final class Builder { + private String id; + private OffsetDateTime timestamp; + private EventType type; + private final Map additionalProperties = new LinkedHashMap<>(); + + private Builder() {} + + /** + * Sets the properties of {@link AutoTopUpCapReachedEventData}, which this schema extends. + * + * @param autoTopUpCapReachedEventData the properties + * @return this builder + */ + public Builder autoTopUpCapReachedEventData( + AutoTopUpCapReachedEventData autoTopUpCapReachedEventData) { + additionalProperties.putAll(Utils.properties(autoTopUpCapReachedEventData)); + return this; + } + + /** + * The {@code id} property. + * + * @param id the value + * @return this builder + */ + public Builder id(String id) { + this.id = id; + return this; + } + + /** + * The {@code timestamp} property. + * + * @param timestamp the value + * @return this builder + */ + public Builder timestamp(OffsetDateTime timestamp) { + this.timestamp = timestamp; + return this; + } + + /** + * The {@code type} property. + * + * @param type the value + * @return this builder + */ + public Builder type(EventType type) { + this.type = type; + return this; + } + + /** + * A property the SDK does not know, sent along. + * + * @param name the property name + * @param value the JSON value + * @return this builder + */ + public Builder putAdditionalProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + return this; + } + + /** + * Properties the SDK does not know, sent along. + * + * @param additionalProperties the properties by name + * @return this builder + */ + public Builder putAllAdditionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + + /** + * Leaves out a property the SDK does not know. + * + * @param name the property name + * @return this builder + */ + public Builder removeAdditionalProperty(String name) { + additionalProperties.remove(name); + return this; + } + + /** + * The {@code AutoTopUpCapReachedEvent}. + * + * @return the immutable value + * @throws IllegalStateException when a required property is not set + */ + public AutoTopUpCapReachedEvent build() { + Utils.checkRequired(id, "id"); + Utils.checkRequired(timestamp, "timestamp"); + Utils.checkRequired(type, "type"); + return new AutoTopUpCapReachedEvent(this); + } + } + + /** + * Parse {@code json} as {@code AutoTopUpCapReachedEvent}. + * + * @param json the JSON text + * @return the value + * @throws com.meteroid.exceptions.InvalidDataException if it is not valid JSON of this shape + */ + public static AutoTopUpCapReachedEvent fromJson(String json) { + return Utils.parse(json, AutoTopUpCapReachedEvent.class); + } + + /** + * This value as JSON. + * + * @return the JSON text + */ + public String toJson() { + return Utils.json(this); + } +} diff --git a/src/main/java/com/meteroid/models/AutoTopUpCapReachedEventData.java b/src/main/java/com/meteroid/models/AutoTopUpCapReachedEventData.java new file mode 100644 index 0000000..ef6bec4 --- /dev/null +++ b/src/main/java/com/meteroid/models/AutoTopUpCapReachedEventData.java @@ -0,0 +1,396 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.Utils; + +import java.time.OffsetDateTime; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; + +/** + * A spending cap stopped an automatic top-up. + * + *

Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonAutoDetect( + getterVisibility = Visibility.NONE, + isGetterVisibility = Visibility.NONE, + setterVisibility = Visibility.NONE) +public final class AutoTopUpCapReachedEventData { + @JsonProperty("attempted_amount") + private Long attemptedAmount; + + @JsonProperty("cap") + private Long cap; + + @JsonProperty("currency") + private String currency; + + @JsonProperty("customer_id") + private String customerId; + + @JsonProperty("period") + private String period; + + @JsonProperty("period_end") + private OffsetDateTime periodEnd; + + @JsonProperty("period_start") + private OffsetDateTime periodStart; + + private final Map additionalProperties = new LinkedHashMap<>(); + + private AutoTopUpCapReachedEventData() {} + + private AutoTopUpCapReachedEventData(Builder builder) { + this.attemptedAmount = builder.attemptedAmount; + this.cap = builder.cap; + this.currency = builder.currency; + this.customerId = builder.customerId; + this.period = builder.period; + this.periodEnd = builder.periodEnd; + this.periodStart = builder.periodStart; + this.additionalProperties.putAll(builder.additionalProperties); + } + + /** + * A builder of {@code AutoTopUpCapReachedEventData}. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * A builder starting from this value. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.attemptedAmount = attemptedAmount; + builder.cap = cap; + builder.currency = currency; + builder.customerId = customerId; + builder.period = period; + builder.periodEnd = periodEnd; + builder.periodStart = periodStart; + builder.additionalProperties.putAll(additionalProperties); + return builder; + } + + /** + * What the suppressed top-up would have charged, tax included once it was quoted (before tax + * when the cap stopped it before then). Caps are always money: for a credit unit wallet, + * currency is the customer's currency. + * + * @return the value, never null + */ + public Long attemptedAmount() { + return Utils.required(attemptedAmount, "attempted_amount"); + } + + /** + * The cap, tax included, in minor units of currency. + * + * @return the value, never null + */ + public Long cap() { + return Utils.required(cap, "cap"); + } + + /** + * The currency the cap and the charge are in (ISO 4217). + * + * @return the value, never null + */ + public String currency() { + return Utils.required(currency, "currency"); + } + + /** + * The {@code customer_id} property. + * + * @return the value, never null + */ + public String customerId() { + return Utils.required(customerId, "customer_id"); + } + + /** + * DAILY (rolling day) or MONTHLY (calendar month, UTC). + * + * @return the value, never null + */ + public String period() { + return Utils.required(period, "period"); + } + + /** + * End of the capped period. + * + * @return the value, never null + */ + public OffsetDateTime periodEnd() { + return Utils.required(periodEnd, "period_end"); + } + + /** + * Start of the capped period. + * + * @return the value, never null + */ + public OffsetDateTime periodStart() { + return Utils.required(periodStart, "period_start"); + } + + /** + * Properties this version of the SDK does not know, kept as received and sent back. + * + * @return the properties by name, unmodifiable + */ + public Map additionalProperties() { + return Collections.unmodifiableMap(additionalProperties); + } + + @JsonAnyGetter + private Map anyProperties() { + return additionalProperties; + } + + @JsonAnySetter + private void putAnyProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AutoTopUpCapReachedEventData that = (AutoTopUpCapReachedEventData) o; + return Objects.equals(attemptedAmount, that.attemptedAmount) + && Objects.equals(cap, that.cap) + && Objects.equals(currency, that.currency) + && Objects.equals(customerId, that.customerId) + && Objects.equals(period, that.period) + && Objects.equals(periodEnd, that.periodEnd) + && Objects.equals(periodStart, that.periodStart) + && Objects.equals(additionalProperties, that.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash( + attemptedAmount, + cap, + currency, + customerId, + period, + periodEnd, + periodStart, + additionalProperties); + } + + @Override + public String toString() { + return "AutoTopUpCapReachedEventData{" + + "attemptedAmount=" + + attemptedAmount + + ", cap=" + + cap + + ", currency=" + + currency + + ", customerId=" + + customerId + + ", period=" + + period + + ", periodEnd=" + + periodEnd + + ", periodStart=" + + periodStart + + ", additionalProperties=" + + additionalProperties + + "}"; + } + + /** Builds {@link AutoTopUpCapReachedEventData}. */ + public static final class Builder { + private Long attemptedAmount; + private Long cap; + private String currency; + private String customerId; + private String period; + private OffsetDateTime periodEnd; + private OffsetDateTime periodStart; + private final Map additionalProperties = new LinkedHashMap<>(); + + private Builder() {} + + /** + * What the suppressed top-up would have charged, tax included once it was quoted (before + * tax when the cap stopped it before then). Caps are always money: for a credit unit + * wallet, currency is the customer's currency. + * + * @param attemptedAmount the value + * @return this builder + */ + public Builder attemptedAmount(Long attemptedAmount) { + this.attemptedAmount = attemptedAmount; + return this; + } + + /** + * The cap, tax included, in minor units of currency. + * + * @param cap the value + * @return this builder + */ + public Builder cap(Long cap) { + this.cap = cap; + return this; + } + + /** + * The currency the cap and the charge are in (ISO 4217). + * + * @param currency the value + * @return this builder + */ + public Builder currency(String currency) { + this.currency = currency; + return this; + } + + /** + * The {@code customer_id} property. + * + * @param customerId the value + * @return this builder + */ + public Builder customerId(String customerId) { + this.customerId = customerId; + return this; + } + + /** + * DAILY (rolling day) or MONTHLY (calendar month, UTC). + * + * @param period the value + * @return this builder + */ + public Builder period(String period) { + this.period = period; + return this; + } + + /** + * End of the capped period. + * + * @param periodEnd the value + * @return this builder + */ + public Builder periodEnd(OffsetDateTime periodEnd) { + this.periodEnd = periodEnd; + return this; + } + + /** + * Start of the capped period. + * + * @param periodStart the value + * @return this builder + */ + public Builder periodStart(OffsetDateTime periodStart) { + this.periodStart = periodStart; + return this; + } + + /** + * A property the SDK does not know, sent along. + * + * @param name the property name + * @param value the JSON value + * @return this builder + */ + public Builder putAdditionalProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + return this; + } + + /** + * Properties the SDK does not know, sent along. + * + * @param additionalProperties the properties by name + * @return this builder + */ + public Builder putAllAdditionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + + /** + * Leaves out a property the SDK does not know. + * + * @param name the property name + * @return this builder + */ + public Builder removeAdditionalProperty(String name) { + additionalProperties.remove(name); + return this; + } + + /** + * The {@code AutoTopUpCapReachedEventData}. + * + * @return the immutable value + * @throws IllegalStateException when a required property is not set + */ + public AutoTopUpCapReachedEventData build() { + Utils.checkRequired(attemptedAmount, "attempted_amount"); + Utils.checkRequired(cap, "cap"); + Utils.checkRequired(currency, "currency"); + Utils.checkRequired(customerId, "customer_id"); + Utils.checkRequired(period, "period"); + Utils.checkRequired(periodEnd, "period_end"); + Utils.checkRequired(periodStart, "period_start"); + return new AutoTopUpCapReachedEventData(this); + } + } + + /** + * Parse {@code json} as {@code AutoTopUpCapReachedEventData}. + * + * @param json the JSON text + * @return the value + * @throws com.meteroid.exceptions.InvalidDataException if it is not valid JSON of this shape + */ + public static AutoTopUpCapReachedEventData fromJson(String json) { + return Utils.parse(json, AutoTopUpCapReachedEventData.class); + } + + /** + * This value as JSON. + * + * @return the JSON text + */ + public String toJson() { + return Utils.json(this); + } +} diff --git a/src/main/java/com/meteroid/models/AutoTopUpConsentChangedEvent.java b/src/main/java/com/meteroid/models/AutoTopUpConsentChangedEvent.java new file mode 100644 index 0000000..033dc48 --- /dev/null +++ b/src/main/java/com/meteroid/models/AutoTopUpConsentChangedEvent.java @@ -0,0 +1,286 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.Unions; +import com.meteroid.internal.Utils; + +import java.time.OffsetDateTime; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; + +/** Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonAutoDetect( + getterVisibility = Visibility.NONE, + isGetterVisibility = Visibility.NONE, + setterVisibility = Visibility.NONE) +public final class AutoTopUpConsentChangedEvent { + @JsonProperty("id") + private String id; + + @JsonProperty("timestamp") + private OffsetDateTime timestamp; + + @JsonProperty("type") + private EventType type; + + private final Map additionalProperties = new LinkedHashMap<>(); + + private AutoTopUpConsentChangedEvent() {} + + private AutoTopUpConsentChangedEvent(Builder builder) { + this.id = builder.id; + this.timestamp = builder.timestamp; + this.type = builder.type; + this.additionalProperties.putAll(builder.additionalProperties); + } + + /** + * A builder of {@code AutoTopUpConsentChangedEvent}. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * A builder starting from this value. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.id = id; + builder.timestamp = timestamp; + builder.type = type; + builder.additionalProperties.putAll(additionalProperties); + return builder; + } + + /** + * The properties of {@link AutoTopUpConsentChangedEventData}, which this schema extends. + * + * @return the properties of this part + */ + public AutoTopUpConsentChangedEventData autoTopUpConsentChangedEventData() { + return Unions.convert(additionalProperties, AutoTopUpConsentChangedEventData.class); + } + + /** + * The {@code id} property. + * + * @return the value, never null + */ + public String id() { + return Utils.required(id, "id"); + } + + /** + * The {@code timestamp} property. + * + * @return the value, never null + */ + public OffsetDateTime timestamp() { + return Utils.required(timestamp, "timestamp"); + } + + /** + * The {@code type} property. + * + * @return the value, never null + */ + public EventType type() { + return Utils.required(type, "type"); + } + + /** + * Properties this version of the SDK does not know, kept as received and sent back. + * + * @return the properties by name, unmodifiable + */ + public Map additionalProperties() { + Map unknown = new LinkedHashMap<>(additionalProperties); + unknown.keySet() + .retainAll(autoTopUpConsentChangedEventData().additionalProperties().keySet()); + return Collections.unmodifiableMap(unknown); + } + + @JsonAnyGetter + private Map anyProperties() { + return additionalProperties; + } + + @JsonAnySetter + private void putAnyProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AutoTopUpConsentChangedEvent that = (AutoTopUpConsentChangedEvent) o; + return Objects.equals(id, that.id) + && Objects.equals(timestamp, that.timestamp) + && Objects.equals(type, that.type) + && Objects.equals(additionalProperties, that.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(id, timestamp, type, additionalProperties); + } + + @Override + public String toString() { + return "AutoTopUpConsentChangedEvent{" + + "id=" + + id + + ", timestamp=" + + timestamp + + ", type=" + + type + + ", additionalProperties=" + + additionalProperties + + "}"; + } + + /** Builds {@link AutoTopUpConsentChangedEvent}. */ + public static final class Builder { + private String id; + private OffsetDateTime timestamp; + private EventType type; + private final Map additionalProperties = new LinkedHashMap<>(); + + private Builder() {} + + /** + * Sets the properties of {@link AutoTopUpConsentChangedEventData}, which this schema + * extends. + * + * @param autoTopUpConsentChangedEventData the properties + * @return this builder + */ + public Builder autoTopUpConsentChangedEventData( + AutoTopUpConsentChangedEventData autoTopUpConsentChangedEventData) { + additionalProperties.putAll(Utils.properties(autoTopUpConsentChangedEventData)); + return this; + } + + /** + * The {@code id} property. + * + * @param id the value + * @return this builder + */ + public Builder id(String id) { + this.id = id; + return this; + } + + /** + * The {@code timestamp} property. + * + * @param timestamp the value + * @return this builder + */ + public Builder timestamp(OffsetDateTime timestamp) { + this.timestamp = timestamp; + return this; + } + + /** + * The {@code type} property. + * + * @param type the value + * @return this builder + */ + public Builder type(EventType type) { + this.type = type; + return this; + } + + /** + * A property the SDK does not know, sent along. + * + * @param name the property name + * @param value the JSON value + * @return this builder + */ + public Builder putAdditionalProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + return this; + } + + /** + * Properties the SDK does not know, sent along. + * + * @param additionalProperties the properties by name + * @return this builder + */ + public Builder putAllAdditionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + + /** + * Leaves out a property the SDK does not know. + * + * @param name the property name + * @return this builder + */ + public Builder removeAdditionalProperty(String name) { + additionalProperties.remove(name); + return this; + } + + /** + * The {@code AutoTopUpConsentChangedEvent}. + * + * @return the immutable value + * @throws IllegalStateException when a required property is not set + */ + public AutoTopUpConsentChangedEvent build() { + Utils.checkRequired(id, "id"); + Utils.checkRequired(timestamp, "timestamp"); + Utils.checkRequired(type, "type"); + return new AutoTopUpConsentChangedEvent(this); + } + } + + /** + * Parse {@code json} as {@code AutoTopUpConsentChangedEvent}. + * + * @param json the JSON text + * @return the value + * @throws com.meteroid.exceptions.InvalidDataException if it is not valid JSON of this shape + */ + public static AutoTopUpConsentChangedEvent fromJson(String json) { + return Utils.parse(json, AutoTopUpConsentChangedEvent.class); + } + + /** + * This value as JSON. + * + * @return the JSON text + */ + public String toJson() { + return Utils.json(this); + } +} diff --git a/src/main/java/com/meteroid/models/AutoTopUpConsentChangedEventData.java b/src/main/java/com/meteroid/models/AutoTopUpConsentChangedEventData.java new file mode 100644 index 0000000..42f6927 --- /dev/null +++ b/src/main/java/com/meteroid/models/AutoTopUpConsentChangedEventData.java @@ -0,0 +1,459 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.JsonField; +import com.meteroid.internal.Utils; + +import java.time.OffsetDateTime; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +/** + * The authorization of a wallet's automatic top-up was given, changed or withdrawn. + * + *

Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonAutoDetect( + getterVisibility = Visibility.NONE, + isGetterVisibility = Visibility.NONE, + setterVisibility = Visibility.NONE) +public final class AutoTopUpConsentChangedEventData { + @JsonProperty("actor") + private Actor actor; + + @JsonProperty("changed_at") + private OffsetDateTime changedAt; + + @JsonProperty("configuration_revision") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField configurationRevision = JsonField.missing(); + + @JsonProperty("consent_attested_at") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField consentAttestedAt = JsonField.missing(); + + @JsonProperty("consent_attested_by") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField consentAttestedBy = JsonField.missing(); + + @JsonProperty("currency") + private String currency; + + @JsonProperty("customer_id") + private String customerId; + + @JsonProperty("enabled") + private Boolean enabled; + + @JsonProperty("previous_configuration_revision") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField previousConfigurationRevision = JsonField.missing(); + + private final Map additionalProperties = new LinkedHashMap<>(); + + private AutoTopUpConsentChangedEventData() {} + + private AutoTopUpConsentChangedEventData(Builder builder) { + this.actor = builder.actor; + this.changedAt = builder.changedAt; + this.configurationRevision = builder.configurationRevision; + this.consentAttestedAt = builder.consentAttestedAt; + this.consentAttestedBy = builder.consentAttestedBy; + this.currency = builder.currency; + this.customerId = builder.customerId; + this.enabled = builder.enabled; + this.previousConfigurationRevision = builder.previousConfigurationRevision; + this.additionalProperties.putAll(builder.additionalProperties); + } + + /** + * A builder of {@code AutoTopUpConsentChangedEventData}. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * A builder starting from this value. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.actor = actor; + builder.changedAt = changedAt; + builder.configurationRevision = configurationRevision; + builder.consentAttestedAt = consentAttestedAt; + builder.consentAttestedBy = consentAttestedBy; + builder.currency = currency; + builder.customerId = customerId; + builder.enabled = enabled; + builder.previousConfigurationRevision = previousConfigurationRevision; + builder.additionalProperties.putAll(additionalProperties); + return builder; + } + + /** + * Who gave, changed or withdrew the authorization. + * + * @return the value, never null + */ + public Actor actor() { + return Utils.required(actor, "actor"); + } + + /** + * When the authorization changed. + * + * @return the value, never null + */ + public OffsetDateTime changedAt() { + return Utils.required(changedAt, "changed_at"); + } + + /** + * Identifies the terms authorized now, without disclosing payment details; absent when + * withdrawn. + * + * @return the value, empty when unset or null + */ + public Optional configurationRevision() { + return configurationRevision.asOptional(); + } + + /** + * When that attestation was made. + * + * @return the value, empty when unset or null + */ + public Optional consentAttestedAt() { + return consentAttestedAt.asOptional(); + } + + /** + * The {@code consent_attested_by} property. + * + * @return the value, empty when unset or null + */ + public Optional consentAttestedBy() { + return consentAttestedBy.asOptional(); + } + + /** + * The wallet's currency (ISO 4217) or credit unit code. + * + * @return the value, never null + */ + public String currency() { + return Utils.required(currency, "currency"); + } + + /** + * The {@code customer_id} property. + * + * @return the value, never null + */ + public String customerId() { + return Utils.required(customerId, "customer_id"); + } + + /** + * Whether automatic top-up is authorized after this change. + * + * @return the value, never null + */ + public Boolean enabled() { + return Utils.required(enabled, "enabled"); + } + + /** + * Identifies the terms authorized before the change; absent when none were. + * + * @return the value, empty when unset or null + */ + public Optional previousConfigurationRevision() { + return previousConfigurationRevision.asOptional(); + } + + /** + * Properties this version of the SDK does not know, kept as received and sent back. + * + * @return the properties by name, unmodifiable + */ + public Map additionalProperties() { + return Collections.unmodifiableMap(additionalProperties); + } + + @JsonAnyGetter + private Map anyProperties() { + return additionalProperties; + } + + @JsonAnySetter + private void putAnyProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AutoTopUpConsentChangedEventData that = (AutoTopUpConsentChangedEventData) o; + return Objects.equals(actor, that.actor) + && Objects.equals(changedAt, that.changedAt) + && Objects.equals(configurationRevision, that.configurationRevision) + && Objects.equals(consentAttestedAt, that.consentAttestedAt) + && Objects.equals(consentAttestedBy, that.consentAttestedBy) + && Objects.equals(currency, that.currency) + && Objects.equals(customerId, that.customerId) + && Objects.equals(enabled, that.enabled) + && Objects.equals(previousConfigurationRevision, that.previousConfigurationRevision) + && Objects.equals(additionalProperties, that.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash( + actor, + changedAt, + configurationRevision, + consentAttestedAt, + consentAttestedBy, + currency, + customerId, + enabled, + previousConfigurationRevision, + additionalProperties); + } + + @Override + public String toString() { + return "AutoTopUpConsentChangedEventData{" + + "actor=" + + actor + + ", changedAt=" + + changedAt + + ", configurationRevision=" + + configurationRevision + + ", consentAttestedAt=" + + consentAttestedAt + + ", consentAttestedBy=" + + consentAttestedBy + + ", currency=" + + currency + + ", customerId=" + + customerId + + ", enabled=" + + enabled + + ", previousConfigurationRevision=" + + previousConfigurationRevision + + ", additionalProperties=" + + additionalProperties + + "}"; + } + + /** Builds {@link AutoTopUpConsentChangedEventData}. */ + public static final class Builder { + private Actor actor; + private OffsetDateTime changedAt; + private JsonField configurationRevision = JsonField.missing(); + private JsonField consentAttestedAt = JsonField.missing(); + private JsonField consentAttestedBy = JsonField.missing(); + private String currency; + private String customerId; + private Boolean enabled; + private JsonField previousConfigurationRevision = JsonField.missing(); + private final Map additionalProperties = new LinkedHashMap<>(); + + private Builder() {} + + /** + * Who gave, changed or withdrew the authorization. + * + * @param actor the value + * @return this builder + */ + public Builder actor(Actor actor) { + this.actor = actor; + return this; + } + + /** + * When the authorization changed. + * + * @param changedAt the value + * @return this builder + */ + public Builder changedAt(OffsetDateTime changedAt) { + this.changedAt = changedAt; + return this; + } + + /** + * Identifies the terms authorized now, without disclosing payment details; absent when + * withdrawn. + * + * @param configurationRevision the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder configurationRevision(String configurationRevision) { + this.configurationRevision = JsonField.ofNullable(configurationRevision); + return this; + } + + /** + * When that attestation was made. + * + * @param consentAttestedAt the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder consentAttestedAt(OffsetDateTime consentAttestedAt) { + this.consentAttestedAt = JsonField.ofNullable(consentAttestedAt); + return this; + } + + /** + * The {@code consent_attested_by} property. + * + * @param consentAttestedBy the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder consentAttestedBy(Actor consentAttestedBy) { + this.consentAttestedBy = JsonField.ofNullable(consentAttestedBy); + return this; + } + + /** + * The wallet's currency (ISO 4217) or credit unit code. + * + * @param currency the value + * @return this builder + */ + public Builder currency(String currency) { + this.currency = currency; + return this; + } + + /** + * The {@code customer_id} property. + * + * @param customerId the value + * @return this builder + */ + public Builder customerId(String customerId) { + this.customerId = customerId; + return this; + } + + /** + * Whether automatic top-up is authorized after this change. + * + * @param enabled the value + * @return this builder + */ + public Builder enabled(Boolean enabled) { + this.enabled = enabled; + return this; + } + + /** + * Identifies the terms authorized before the change; absent when none were. + * + * @param previousConfigurationRevision the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder previousConfigurationRevision(String previousConfigurationRevision) { + this.previousConfigurationRevision = + JsonField.ofNullable(previousConfigurationRevision); + return this; + } + + /** + * A property the SDK does not know, sent along. + * + * @param name the property name + * @param value the JSON value + * @return this builder + */ + public Builder putAdditionalProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + return this; + } + + /** + * Properties the SDK does not know, sent along. + * + * @param additionalProperties the properties by name + * @return this builder + */ + public Builder putAllAdditionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + + /** + * Leaves out a property the SDK does not know. + * + * @param name the property name + * @return this builder + */ + public Builder removeAdditionalProperty(String name) { + additionalProperties.remove(name); + return this; + } + + /** + * The {@code AutoTopUpConsentChangedEventData}. + * + * @return the immutable value + * @throws IllegalStateException when a required property is not set + */ + public AutoTopUpConsentChangedEventData build() { + Utils.checkRequired(actor, "actor"); + Utils.checkRequired(changedAt, "changed_at"); + Utils.checkRequired(currency, "currency"); + Utils.checkRequired(customerId, "customer_id"); + Utils.checkRequired(enabled, "enabled"); + return new AutoTopUpConsentChangedEventData(this); + } + } + + /** + * Parse {@code json} as {@code AutoTopUpConsentChangedEventData}. + * + * @param json the JSON text + * @return the value + * @throws com.meteroid.exceptions.InvalidDataException if it is not valid JSON of this shape + */ + public static AutoTopUpConsentChangedEventData fromJson(String json) { + return Utils.parse(json, AutoTopUpConsentChangedEventData.class); + } + + /** + * This value as JSON. + * + * @return the JSON text + */ + public String toJson() { + return Utils.json(this); + } +} diff --git a/src/main/java/com/meteroid/models/AutoTopUpEvent.java b/src/main/java/com/meteroid/models/AutoTopUpEvent.java new file mode 100644 index 0000000..c1767f3 --- /dev/null +++ b/src/main/java/com/meteroid/models/AutoTopUpEvent.java @@ -0,0 +1,283 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.Unions; +import com.meteroid.internal.Utils; + +import java.time.OffsetDateTime; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; + +/** Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonAutoDetect( + getterVisibility = Visibility.NONE, + isGetterVisibility = Visibility.NONE, + setterVisibility = Visibility.NONE) +public final class AutoTopUpEvent { + @JsonProperty("id") + private String id; + + @JsonProperty("timestamp") + private OffsetDateTime timestamp; + + @JsonProperty("type") + private EventType type; + + private final Map additionalProperties = new LinkedHashMap<>(); + + private AutoTopUpEvent() {} + + private AutoTopUpEvent(Builder builder) { + this.id = builder.id; + this.timestamp = builder.timestamp; + this.type = builder.type; + this.additionalProperties.putAll(builder.additionalProperties); + } + + /** + * A builder of {@code AutoTopUpEvent}. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * A builder starting from this value. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.id = id; + builder.timestamp = timestamp; + builder.type = type; + builder.additionalProperties.putAll(additionalProperties); + return builder; + } + + /** + * The properties of {@link AutoTopUpEventData}, which this schema extends. + * + * @return the properties of this part + */ + public AutoTopUpEventData autoTopUpEventData() { + return Unions.convert(additionalProperties, AutoTopUpEventData.class); + } + + /** + * The {@code id} property. + * + * @return the value, never null + */ + public String id() { + return Utils.required(id, "id"); + } + + /** + * The {@code timestamp} property. + * + * @return the value, never null + */ + public OffsetDateTime timestamp() { + return Utils.required(timestamp, "timestamp"); + } + + /** + * The {@code type} property. + * + * @return the value, never null + */ + public EventType type() { + return Utils.required(type, "type"); + } + + /** + * Properties this version of the SDK does not know, kept as received and sent back. + * + * @return the properties by name, unmodifiable + */ + public Map additionalProperties() { + Map unknown = new LinkedHashMap<>(additionalProperties); + unknown.keySet().retainAll(autoTopUpEventData().additionalProperties().keySet()); + return Collections.unmodifiableMap(unknown); + } + + @JsonAnyGetter + private Map anyProperties() { + return additionalProperties; + } + + @JsonAnySetter + private void putAnyProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AutoTopUpEvent that = (AutoTopUpEvent) o; + return Objects.equals(id, that.id) + && Objects.equals(timestamp, that.timestamp) + && Objects.equals(type, that.type) + && Objects.equals(additionalProperties, that.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(id, timestamp, type, additionalProperties); + } + + @Override + public String toString() { + return "AutoTopUpEvent{" + + "id=" + + id + + ", timestamp=" + + timestamp + + ", type=" + + type + + ", additionalProperties=" + + additionalProperties + + "}"; + } + + /** Builds {@link AutoTopUpEvent}. */ + public static final class Builder { + private String id; + private OffsetDateTime timestamp; + private EventType type; + private final Map additionalProperties = new LinkedHashMap<>(); + + private Builder() {} + + /** + * Sets the properties of {@link AutoTopUpEventData}, which this schema extends. + * + * @param autoTopUpEventData the properties + * @return this builder + */ + public Builder autoTopUpEventData(AutoTopUpEventData autoTopUpEventData) { + additionalProperties.putAll(Utils.properties(autoTopUpEventData)); + return this; + } + + /** + * The {@code id} property. + * + * @param id the value + * @return this builder + */ + public Builder id(String id) { + this.id = id; + return this; + } + + /** + * The {@code timestamp} property. + * + * @param timestamp the value + * @return this builder + */ + public Builder timestamp(OffsetDateTime timestamp) { + this.timestamp = timestamp; + return this; + } + + /** + * The {@code type} property. + * + * @param type the value + * @return this builder + */ + public Builder type(EventType type) { + this.type = type; + return this; + } + + /** + * A property the SDK does not know, sent along. + * + * @param name the property name + * @param value the JSON value + * @return this builder + */ + public Builder putAdditionalProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + return this; + } + + /** + * Properties the SDK does not know, sent along. + * + * @param additionalProperties the properties by name + * @return this builder + */ + public Builder putAllAdditionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + + /** + * Leaves out a property the SDK does not know. + * + * @param name the property name + * @return this builder + */ + public Builder removeAdditionalProperty(String name) { + additionalProperties.remove(name); + return this; + } + + /** + * The {@code AutoTopUpEvent}. + * + * @return the immutable value + * @throws IllegalStateException when a required property is not set + */ + public AutoTopUpEvent build() { + Utils.checkRequired(id, "id"); + Utils.checkRequired(timestamp, "timestamp"); + Utils.checkRequired(type, "type"); + return new AutoTopUpEvent(this); + } + } + + /** + * Parse {@code json} as {@code AutoTopUpEvent}. + * + * @param json the JSON text + * @return the value + * @throws com.meteroid.exceptions.InvalidDataException if it is not valid JSON of this shape + */ + public static AutoTopUpEvent fromJson(String json) { + return Utils.parse(json, AutoTopUpEvent.class); + } + + /** + * This value as JSON. + * + * @return the JSON text + */ + public String toJson() { + return Utils.json(this); + } +} diff --git a/src/main/java/com/meteroid/models/AutoTopUpEventData.java b/src/main/java/com/meteroid/models/AutoTopUpEventData.java new file mode 100644 index 0000000..cbd68a8 --- /dev/null +++ b/src/main/java/com/meteroid/models/AutoTopUpEventData.java @@ -0,0 +1,371 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.JsonField; +import com.meteroid.internal.Utils; + +import java.time.OffsetDateTime; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +/** + * An automatic top-up charge failed, or the automatic top-up was suspended. + * + *

Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonAutoDetect( + getterVisibility = Visibility.NONE, + isGetterVisibility = Visibility.NONE, + setterVisibility = Visibility.NONE) +public final class AutoTopUpEventData { + @JsonProperty("amount") + private Long amount; + + @JsonProperty("consecutive_failures") + private Integer consecutiveFailures; + + @JsonProperty("currency") + private String currency; + + @JsonProperty("customer_id") + private String customerId; + + @JsonProperty("error") + private String error; + + @JsonProperty("suspended_at") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField suspendedAt = JsonField.missing(); + + private final Map additionalProperties = new LinkedHashMap<>(); + + private AutoTopUpEventData() {} + + private AutoTopUpEventData(Builder builder) { + this.amount = builder.amount; + this.consecutiveFailures = builder.consecutiveFailures; + this.currency = builder.currency; + this.customerId = builder.customerId; + this.error = builder.error; + this.suspendedAt = builder.suspendedAt; + this.additionalProperties.putAll(builder.additionalProperties); + } + + /** + * A builder of {@code AutoTopUpEventData}. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * A builder starting from this value. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.amount = amount; + builder.consecutiveFailures = consecutiveFailures; + builder.currency = currency; + builder.customerId = customerId; + builder.error = error; + builder.suspendedAt = suspendedAt; + builder.additionalProperties.putAll(additionalProperties); + return builder; + } + + /** + * The charge in minor units of currency: the credit it would have added, or for a + * credit unit wallet the price of those credits in the customer's currency. When the credits + * could not be priced (no selling price), the credits themselves, with currency + * the unit code. On a suspension after a top-up payment was refunded or disputed: that + * payment's top-up. + * + * @return the value, never null + */ + public Long amount() { + return Utils.required(amount, "amount"); + } + + /** + * Failed charges in a row, this one included. + * + * @return the value, never null + */ + public Integer consecutiveFailures() { + return Utils.required(consecutiveFailures, "consecutive_failures"); + } + + /** + * The currency charged (ISO 4217), or the credit unit code when the credits had no price. + * + * @return the value, never null + */ + public String currency() { + return Utils.required(currency, "currency"); + } + + /** + * The {@code customer_id} property. + * + * @return the value, never null + */ + public String customerId() { + return Utils.required(customerId, "customer_id"); + } + + /** + * May carry payment provider detail. + * + * @return the value, never null + */ + public String error() { + return Utils.required(error, "error"); + } + + /** + * Set on wallet.auto_top_up_suspended: when it was suspended. + * + * @return the value, empty when unset or null + */ + public Optional suspendedAt() { + return suspendedAt.asOptional(); + } + + /** + * Properties this version of the SDK does not know, kept as received and sent back. + * + * @return the properties by name, unmodifiable + */ + public Map additionalProperties() { + return Collections.unmodifiableMap(additionalProperties); + } + + @JsonAnyGetter + private Map anyProperties() { + return additionalProperties; + } + + @JsonAnySetter + private void putAnyProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AutoTopUpEventData that = (AutoTopUpEventData) o; + return Objects.equals(amount, that.amount) + && Objects.equals(consecutiveFailures, that.consecutiveFailures) + && Objects.equals(currency, that.currency) + && Objects.equals(customerId, that.customerId) + && Objects.equals(error, that.error) + && Objects.equals(suspendedAt, that.suspendedAt) + && Objects.equals(additionalProperties, that.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash( + amount, + consecutiveFailures, + currency, + customerId, + error, + suspendedAt, + additionalProperties); + } + + @Override + public String toString() { + return "AutoTopUpEventData{" + + "amount=" + + amount + + ", consecutiveFailures=" + + consecutiveFailures + + ", currency=" + + currency + + ", customerId=" + + customerId + + ", error=" + + error + + ", suspendedAt=" + + suspendedAt + + ", additionalProperties=" + + additionalProperties + + "}"; + } + + /** Builds {@link AutoTopUpEventData}. */ + public static final class Builder { + private Long amount; + private Integer consecutiveFailures; + private String currency; + private String customerId; + private String error; + private JsonField suspendedAt = JsonField.missing(); + private final Map additionalProperties = new LinkedHashMap<>(); + + private Builder() {} + + /** + * The charge in minor units of currency: the credit it would have added, or + * for a credit unit wallet the price of those credits in the customer's currency. When the + * credits could not be priced (no selling price), the credits themselves, with + * currency the unit code. On a suspension after a top-up payment was refunded or + * disputed: that payment's top-up. + * + * @param amount the value + * @return this builder + */ + public Builder amount(Long amount) { + this.amount = amount; + return this; + } + + /** + * Failed charges in a row, this one included. + * + * @param consecutiveFailures the value + * @return this builder + */ + public Builder consecutiveFailures(Integer consecutiveFailures) { + this.consecutiveFailures = consecutiveFailures; + return this; + } + + /** + * The currency charged (ISO 4217), or the credit unit code when the credits had no price. + * + * @param currency the value + * @return this builder + */ + public Builder currency(String currency) { + this.currency = currency; + return this; + } + + /** + * The {@code customer_id} property. + * + * @param customerId the value + * @return this builder + */ + public Builder customerId(String customerId) { + this.customerId = customerId; + return this; + } + + /** + * May carry payment provider detail. + * + * @param error the value + * @return this builder + */ + public Builder error(String error) { + this.error = error; + return this; + } + + /** + * Set on wallet.auto_top_up_suspended: when it was suspended. + * + * @param suspendedAt the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder suspendedAt(OffsetDateTime suspendedAt) { + this.suspendedAt = JsonField.ofNullable(suspendedAt); + return this; + } + + /** + * A property the SDK does not know, sent along. + * + * @param name the property name + * @param value the JSON value + * @return this builder + */ + public Builder putAdditionalProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + return this; + } + + /** + * Properties the SDK does not know, sent along. + * + * @param additionalProperties the properties by name + * @return this builder + */ + public Builder putAllAdditionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + + /** + * Leaves out a property the SDK does not know. + * + * @param name the property name + * @return this builder + */ + public Builder removeAdditionalProperty(String name) { + additionalProperties.remove(name); + return this; + } + + /** + * The {@code AutoTopUpEventData}. + * + * @return the immutable value + * @throws IllegalStateException when a required property is not set + */ + public AutoTopUpEventData build() { + Utils.checkRequired(amount, "amount"); + Utils.checkRequired(consecutiveFailures, "consecutive_failures"); + Utils.checkRequired(currency, "currency"); + Utils.checkRequired(customerId, "customer_id"); + Utils.checkRequired(error, "error"); + return new AutoTopUpEventData(this); + } + } + + /** + * Parse {@code json} as {@code AutoTopUpEventData}. + * + * @param json the JSON text + * @return the value + * @throws com.meteroid.exceptions.InvalidDataException if it is not valid JSON of this shape + */ + public static AutoTopUpEventData fromJson(String json) { + return Utils.parse(json, AutoTopUpEventData.class); + } + + /** + * This value as JSON. + * + * @return the JSON text + */ + public String toJson() { + return Utils.json(this); + } +} diff --git a/src/main/java/com/meteroid/models/AutoTopUpMethod.java b/src/main/java/com/meteroid/models/AutoTopUpMethod.java new file mode 100644 index 0000000..40714ea --- /dev/null +++ b/src/main/java/com/meteroid/models/AutoTopUpMethod.java @@ -0,0 +1,126 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import com.meteroid.internal.Utils.ToQueryParam; + +import java.util.Map; +import java.util.Objects; + +/** + * Values this version of the SDK does not know are kept, and sent back unchanged: {@link #value()} + * is an enum to switch on, {@code _UNKNOWN} for them, and {@link #known()} throws on them. + */ +public final class AutoTopUpMethod implements ToQueryParam { + /** The value {@code "FIXED"}. */ + public static final AutoTopUpMethod FIXED = new AutoTopUpMethod("FIXED", Value.FIXED); + + /** The value {@code "TO_TARGET"}. */ + public static final AutoTopUpMethod TO_TARGET = + new AutoTopUpMethod("TO_TARGET", Value.TO_TARGET); + + private static final Map constants = + Map.ofEntries(Map.entry("FIXED", FIXED), Map.entry("TO_TARGET", TO_TARGET)); + + private final String value; + private final Value variant; + + private AutoTopUpMethod(String value, Value variant) { + this.value = value; + this.variant = variant; + } + + /** + * The constant for {@code value}, or an unknown AutoTopUpMethod holding it. + * + * @param value the value + * @return the constant + */ + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static AutoTopUpMethod of(String value) { + AutoTopUpMethod constant = constants.get(Objects.requireNonNull(value, "value")); + return constant != null ? constant : new AutoTopUpMethod(value, Value._UNKNOWN); + } + + /** + * The value as sent. + * + * @return the value + */ + @JsonValue + public String asString() { + return value; + } + + /** + * Whether this version of the SDK knows the value. + * + * @return whether it is known + */ + public boolean isKnown() { + return variant != Value._UNKNOWN; + } + + /** + * The value as an enum to switch on, unknown values included. + * + * @return the enum, {@code _UNKNOWN} when unknown + */ + public Value value() { + return variant; + } + + /** + * The value as an enum of the known values only. + * + * @return the enum + * @throws com.meteroid.exceptions.InvalidDataException when this version of the SDK does not + * know the value + */ + public Known known() { + if (!isKnown()) { + throw new com.meteroid.exceptions.InvalidDataException( + "unknown AutoTopUpMethod: " + value); + } + return Known.valueOf(variant.name()); + } + + @Override + public String toQueryParam() { + return String.valueOf(value); + } + + @Override + public boolean equals(Object o) { + return o instanceof AutoTopUpMethod && Objects.equals(value, ((AutoTopUpMethod) o).value); + } + + @Override + public int hashCode() { + return Objects.hashCode(value); + } + + @Override + public String toString() { + return String.valueOf(value); + } + + /** The values this version of the SDK knows. */ + public enum Known { + /** The {@code FIXED} constant. */ + FIXED, + /** The {@code TO_TARGET} constant. */ + TO_TARGET + } + + /** The values this version of the SDK knows, and {@code _UNKNOWN} for the others. */ + public enum Value { + /** The {@code FIXED} constant. */ + FIXED, + /** The {@code TO_TARGET} constant. */ + TO_TARGET, + /** A value this version of the SDK does not know. */ + _UNKNOWN + } +} diff --git a/src/main/java/com/meteroid/models/AutoTopUpStatus.java b/src/main/java/com/meteroid/models/AutoTopUpStatus.java new file mode 100644 index 0000000..fa05560 --- /dev/null +++ b/src/main/java/com/meteroid/models/AutoTopUpStatus.java @@ -0,0 +1,136 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import com.meteroid.internal.Utils.ToQueryParam; + +import java.util.Map; +import java.util.Objects; + +/** + * Values this version of the SDK does not know are kept, and sent back unchanged: {@link #value()} + * is an enum to switch on, {@code _UNKNOWN} for them, and {@link #known()} throws on them. + */ +public final class AutoTopUpStatus implements ToQueryParam { + /** The value {@code "ACTIVE"}. */ + public static final AutoTopUpStatus ACTIVE = new AutoTopUpStatus("ACTIVE", Value.ACTIVE); + + /** The value {@code "DISABLED"}. */ + public static final AutoTopUpStatus DISABLED = new AutoTopUpStatus("DISABLED", Value.DISABLED); + + /** The value {@code "SUSPENDED"}. */ + public static final AutoTopUpStatus SUSPENDED = + new AutoTopUpStatus("SUSPENDED", Value.SUSPENDED); + + private static final Map constants = + Map.ofEntries( + Map.entry("ACTIVE", ACTIVE), + Map.entry("DISABLED", DISABLED), + Map.entry("SUSPENDED", SUSPENDED)); + + private final String value; + private final Value variant; + + private AutoTopUpStatus(String value, Value variant) { + this.value = value; + this.variant = variant; + } + + /** + * The constant for {@code value}, or an unknown AutoTopUpStatus holding it. + * + * @param value the value + * @return the constant + */ + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static AutoTopUpStatus of(String value) { + AutoTopUpStatus constant = constants.get(Objects.requireNonNull(value, "value")); + return constant != null ? constant : new AutoTopUpStatus(value, Value._UNKNOWN); + } + + /** + * The value as sent. + * + * @return the value + */ + @JsonValue + public String asString() { + return value; + } + + /** + * Whether this version of the SDK knows the value. + * + * @return whether it is known + */ + public boolean isKnown() { + return variant != Value._UNKNOWN; + } + + /** + * The value as an enum to switch on, unknown values included. + * + * @return the enum, {@code _UNKNOWN} when unknown + */ + public Value value() { + return variant; + } + + /** + * The value as an enum of the known values only. + * + * @return the enum + * @throws com.meteroid.exceptions.InvalidDataException when this version of the SDK does not + * know the value + */ + public Known known() { + if (!isKnown()) { + throw new com.meteroid.exceptions.InvalidDataException( + "unknown AutoTopUpStatus: " + value); + } + return Known.valueOf(variant.name()); + } + + @Override + public String toQueryParam() { + return String.valueOf(value); + } + + @Override + public boolean equals(Object o) { + return o instanceof AutoTopUpStatus && Objects.equals(value, ((AutoTopUpStatus) o).value); + } + + @Override + public int hashCode() { + return Objects.hashCode(value); + } + + @Override + public String toString() { + return String.valueOf(value); + } + + /** The values this version of the SDK knows. */ + public enum Known { + /** The {@code ACTIVE} constant. */ + ACTIVE, + /** The {@code DISABLED} constant. */ + DISABLED, + /** The {@code SUSPENDED} constant. */ + SUSPENDED + } + + /** The values this version of the SDK knows, and {@code _UNKNOWN} for the others. */ + public enum Value { + /** The {@code ACTIVE} constant. */ + ACTIVE, + /** The {@code DISABLED} constant. */ + DISABLED, + /** The {@code SUSPENDED} constant. */ + SUSPENDED, + /** A value this version of the SDK does not know. */ + _UNKNOWN + } +} diff --git a/src/main/java/com/meteroid/models/AutoTopUpWriteRequest.java b/src/main/java/com/meteroid/models/AutoTopUpWriteRequest.java new file mode 100644 index 0000000..8420fe9 --- /dev/null +++ b/src/main/java/com/meteroid/models/AutoTopUpWriteRequest.java @@ -0,0 +1,541 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.JsonField; +import com.meteroid.internal.Utils; + +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +/** + * An automatic top-up's terms, replaced as a whole. FIXED needs amount and no + * target; TO_TARGET needs target above threshold and no + * amount; amounts are positive. + * + *

Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonAutoDetect( + getterVisibility = Visibility.NONE, + isGetterVisibility = Visibility.NONE, + setterVisibility = Visibility.NONE) +public final class AutoTopUpWriteRequest { + @JsonProperty("amount") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField amount = JsonField.missing(); + + @JsonProperty("at_current_price") + private Boolean atCurrentPrice; + + @JsonProperty("customer_consent_attested") + private Boolean customerConsentAttested; + + @JsonProperty("daily_cap") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField dailyCap = JsonField.missing(); + + @JsonProperty("maximum") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField maximum = JsonField.missing(); + + @JsonProperty("method") + private AutoTopUpMethod method; + + @JsonProperty("minimum") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField minimum = JsonField.missing(); + + @JsonProperty("monthly_cap") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField monthlyCap = JsonField.missing(); + + @JsonProperty("payment_method_id") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField paymentMethodId = JsonField.missing(); + + @JsonProperty("target") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField target = JsonField.missing(); + + @JsonProperty("threshold") + private Long threshold; + + private final Map additionalProperties = new LinkedHashMap<>(); + + private AutoTopUpWriteRequest() {} + + private AutoTopUpWriteRequest(Builder builder) { + this.amount = builder.amount; + this.atCurrentPrice = builder.atCurrentPrice; + this.customerConsentAttested = builder.customerConsentAttested; + this.dailyCap = builder.dailyCap; + this.maximum = builder.maximum; + this.method = builder.method; + this.minimum = builder.minimum; + this.monthlyCap = builder.monthlyCap; + this.paymentMethodId = builder.paymentMethodId; + this.target = builder.target; + this.threshold = builder.threshold; + this.additionalProperties.putAll(builder.additionalProperties); + } + + /** + * A builder of {@code AutoTopUpWriteRequest}. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * A builder starting from this value. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.amount = amount; + builder.atCurrentPrice = atCurrentPrice; + builder.customerConsentAttested = customerConsentAttested; + builder.dailyCap = dailyCap; + builder.maximum = maximum; + builder.method = method; + builder.minimum = minimum; + builder.monthlyCap = monthlyCap; + builder.paymentMethodId = paymentMethodId; + builder.target = target; + builder.threshold = threshold; + builder.additionalProperties.putAll(additionalProperties); + return builder; + } + + /** + * FIXED only: credit bought each time, in minor units of the wallet. + * + * @return the value, empty when unset or null + */ + public Optional amount() { + return amount.asOptional(); + } + + /** + * Credit unit wallets: authorize today's price per credit for these terms, which lifts a stop + * caused by a price increase. When false (the default) the terms keep the price they were + * authorized at, and a rule stopped by a price increase stays stopped. A price at or below the + * authorized one never stops the rule: top-ups charge it. + * + * @return the value, empty when unset + */ + public Optional atCurrentPrice() { + return Optional.ofNullable(atCurrentPrice); + } + + /** + * Attests that the customer agreed to automatic charges on these terms; recorded with the API + * key and the time. Required (true) when the terms turn automatic top-up on, including one the + * customer turned off, or change what it charges. Not needed to resend the stored terms + * unchanged, nor to change terms the customer confirmed in their portal: those stop until the + * customer confirms the new ones. + * + * @return the value, empty when unset + */ + public Optional customerConsentAttested() { + return Optional.ofNullable(customerConsentAttested); + } + + /** + * Most charged in a rolling day, tax included. For a credit unit wallet caps are money, in + * minor units of the customer's currency. + * + * @return the value, empty when unset or null + */ + public Optional dailyCap() { + return dailyCap.asOptional(); + } + + /** + * Largest single charge, in the same money as minimum. + * + * @return the value, empty when unset or null + */ + public Optional maximum() { + return maximum.asOptional(); + } + + /** + * FIXED buys amount each time; TO_TARGET buys back up to target. + * + * @return the value, never null + */ + public AutoTopUpMethod method() { + return Utils.required(method, "method"); + } + + /** + * Smallest single charge. For a credit unit wallet it is money (the price before tax, in minor + * units of the customer's currency), like the caps; the threshold, amount and target are + * credits. + * + * @return the value, empty when unset or null + */ + public Optional minimum() { + return minimum.asOptional(); + } + + /** + * Most charged in a calendar month (UTC), tax included. + * + * @return the value, empty when unset or null + */ + public Optional monthlyCap() { + return monthlyCap.asOptional(); + } + + /** + * Defaults to the customer's default payment method: the customer's agreement, and your + * attestation of it, then cover whichever method is their default at each top-up. + * + * @return the value, empty when unset or null + */ + public Optional paymentMethodId() { + return paymentMethodId.asOptional(); + } + + /** + * TO_TARGET only: the balance a top-up brings the wallet back to; must exceed threshold + * . + * + * @return the value, empty when unset or null + */ + public Optional target() { + return target.asOptional(); + } + + /** + * Tops up once the balance is at or below this, in minor units of the wallet. + * + * @return the value, never null + */ + public Long threshold() { + return Utils.required(threshold, "threshold"); + } + + /** + * Properties this version of the SDK does not know, kept as received and sent back. + * + * @return the properties by name, unmodifiable + */ + public Map additionalProperties() { + return Collections.unmodifiableMap(additionalProperties); + } + + @JsonAnyGetter + private Map anyProperties() { + return additionalProperties; + } + + @JsonAnySetter + private void putAnyProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AutoTopUpWriteRequest that = (AutoTopUpWriteRequest) o; + return Objects.equals(amount, that.amount) + && Objects.equals(atCurrentPrice, that.atCurrentPrice) + && Objects.equals(customerConsentAttested, that.customerConsentAttested) + && Objects.equals(dailyCap, that.dailyCap) + && Objects.equals(maximum, that.maximum) + && Objects.equals(method, that.method) + && Objects.equals(minimum, that.minimum) + && Objects.equals(monthlyCap, that.monthlyCap) + && Objects.equals(paymentMethodId, that.paymentMethodId) + && Objects.equals(target, that.target) + && Objects.equals(threshold, that.threshold) + && Objects.equals(additionalProperties, that.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash( + amount, + atCurrentPrice, + customerConsentAttested, + dailyCap, + maximum, + method, + minimum, + monthlyCap, + paymentMethodId, + target, + threshold, + additionalProperties); + } + + @Override + public String toString() { + return "AutoTopUpWriteRequest{" + + "amount=" + + amount + + ", atCurrentPrice=" + + atCurrentPrice + + ", customerConsentAttested=" + + customerConsentAttested + + ", dailyCap=" + + dailyCap + + ", maximum=" + + maximum + + ", method=" + + method + + ", minimum=" + + minimum + + ", monthlyCap=" + + monthlyCap + + ", paymentMethodId=" + + paymentMethodId + + ", target=" + + target + + ", threshold=" + + threshold + + ", additionalProperties=" + + additionalProperties + + "}"; + } + + /** Builds {@link AutoTopUpWriteRequest}. */ + public static final class Builder { + private JsonField amount = JsonField.missing(); + private Boolean atCurrentPrice; + private Boolean customerConsentAttested; + private JsonField dailyCap = JsonField.missing(); + private JsonField maximum = JsonField.missing(); + private AutoTopUpMethod method; + private JsonField minimum = JsonField.missing(); + private JsonField monthlyCap = JsonField.missing(); + private JsonField paymentMethodId = JsonField.missing(); + private JsonField target = JsonField.missing(); + private Long threshold; + private final Map additionalProperties = new LinkedHashMap<>(); + + private Builder() {} + + /** + * FIXED only: credit bought each time, in minor units of the wallet. + * + * @param amount the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder amount(Long amount) { + this.amount = JsonField.ofNullable(amount); + return this; + } + + /** + * Credit unit wallets: authorize today's price per credit for these terms, which lifts a + * stop caused by a price increase. When false (the default) the terms keep the price they + * were authorized at, and a rule stopped by a price increase stays stopped. A price at or + * below the authorized one never stops the rule: top-ups charge it. + * + * @param atCurrentPrice the value + * @return this builder + */ + public Builder atCurrentPrice(Boolean atCurrentPrice) { + this.atCurrentPrice = atCurrentPrice; + return this; + } + + /** + * Attests that the customer agreed to automatic charges on these terms; recorded with the + * API key and the time. Required (true) when the terms turn automatic top-up on, including + * one the customer turned off, or change what it charges. Not needed to resend the stored + * terms unchanged, nor to change terms the customer confirmed in their portal: those stop + * until the customer confirms the new ones. + * + * @param customerConsentAttested the value + * @return this builder + */ + public Builder customerConsentAttested(Boolean customerConsentAttested) { + this.customerConsentAttested = customerConsentAttested; + return this; + } + + /** + * Most charged in a rolling day, tax included. For a credit unit wallet caps are money, in + * minor units of the customer's currency. + * + * @param dailyCap the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder dailyCap(Long dailyCap) { + this.dailyCap = JsonField.ofNullable(dailyCap); + return this; + } + + /** + * Largest single charge, in the same money as minimum. + * + * @param maximum the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder maximum(Long maximum) { + this.maximum = JsonField.ofNullable(maximum); + return this; + } + + /** + * FIXED buys amount each time; TO_TARGET buys back up to target. + * + * @param method the value + * @return this builder + */ + public Builder method(AutoTopUpMethod method) { + this.method = method; + return this; + } + + /** + * Smallest single charge. For a credit unit wallet it is money (the price before tax, in + * minor units of the customer's currency), like the caps; the threshold, amount and target + * are credits. + * + * @param minimum the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder minimum(Long minimum) { + this.minimum = JsonField.ofNullable(minimum); + return this; + } + + /** + * Most charged in a calendar month (UTC), tax included. + * + * @param monthlyCap the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder monthlyCap(Long monthlyCap) { + this.monthlyCap = JsonField.ofNullable(monthlyCap); + return this; + } + + /** + * Defaults to the customer's default payment method: the customer's agreement, and your + * attestation of it, then cover whichever method is their default at each top-up. + * + * @param paymentMethodId the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder paymentMethodId(String paymentMethodId) { + this.paymentMethodId = JsonField.ofNullable(paymentMethodId); + return this; + } + + /** + * TO_TARGET only: the balance a top-up brings the wallet back to; must exceed + * threshold. + * + * @param target the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder target(Long target) { + this.target = JsonField.ofNullable(target); + return this; + } + + /** + * Tops up once the balance is at or below this, in minor units of the wallet. + * + * @param threshold the value + * @return this builder + */ + public Builder threshold(Long threshold) { + this.threshold = threshold; + return this; + } + + /** + * A property the SDK does not know, sent along. + * + * @param name the property name + * @param value the JSON value + * @return this builder + */ + public Builder putAdditionalProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + return this; + } + + /** + * Properties the SDK does not know, sent along. + * + * @param additionalProperties the properties by name + * @return this builder + */ + public Builder putAllAdditionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + + /** + * Leaves out a property the SDK does not know. + * + * @param name the property name + * @return this builder + */ + public Builder removeAdditionalProperty(String name) { + additionalProperties.remove(name); + return this; + } + + /** + * The {@code AutoTopUpWriteRequest}. + * + * @return the immutable value + * @throws IllegalStateException when a required property is not set + */ + public AutoTopUpWriteRequest build() { + Utils.checkRequired(method, "method"); + Utils.checkRequired(threshold, "threshold"); + return new AutoTopUpWriteRequest(this); + } + } + + /** + * Parse {@code json} as {@code AutoTopUpWriteRequest}. + * + * @param json the JSON text + * @return the value + * @throws com.meteroid.exceptions.InvalidDataException if it is not valid JSON of this shape + */ + public static AutoTopUpWriteRequest fromJson(String json) { + return Utils.parse(json, AutoTopUpWriteRequest.class); + } + + /** + * This value as JSON. + * + * @return the JSON text + */ + public String toJson() { + return Utils.json(this); + } +} diff --git a/src/main/java/com/meteroid/models/BankTransferPaymentMethodConfig.java b/src/main/java/com/meteroid/models/BankTransferPaymentMethodConfig.java index 91159ec..c0af784 100644 --- a/src/main/java/com/meteroid/models/BankTransferPaymentMethodConfig.java +++ b/src/main/java/com/meteroid/models/BankTransferPaymentMethodConfig.java @@ -30,12 +30,16 @@ public final class BankTransferPaymentMethodConfig { @JsonInclude(JsonInclude.Include.NON_EMPTY) private JsonField accountId = JsonField.missing(); + @JsonProperty("type") + private String type = "bank_transfer"; + private final Map additionalProperties = new LinkedHashMap<>(); private BankTransferPaymentMethodConfig() {} private BankTransferPaymentMethodConfig(Builder builder) { this.accountId = builder.accountId; + this.type = builder.type; this.additionalProperties.putAll(builder.additionalProperties); } @@ -56,6 +60,7 @@ public static Builder builder() { public Builder toBuilder() { Builder builder = new Builder(); builder.accountId = accountId; + builder.type = type; builder.additionalProperties.putAll(additionalProperties); return builder; } @@ -69,6 +74,15 @@ public Optional accountId() { return accountId.asOptional(); } + /** + * The {@code type} property. + * + * @return the value, never null + */ + public String type() { + return Utils.required(type, "type"); + } + /** * Properties this version of the SDK does not know, kept as received and sent back. * @@ -98,12 +112,13 @@ public boolean equals(Object o) { } BankTransferPaymentMethodConfig that = (BankTransferPaymentMethodConfig) o; return Objects.equals(accountId, that.accountId) + && Objects.equals(type, that.type) && Objects.equals(additionalProperties, that.additionalProperties); } @Override public int hashCode() { - return Objects.hash(accountId, additionalProperties); + return Objects.hash(accountId, type, additionalProperties); } @Override @@ -111,6 +126,8 @@ public String toString() { return "BankTransferPaymentMethodConfig{" + "accountId=" + accountId + + ", type=" + + type + ", additionalProperties=" + additionalProperties + "}"; @@ -119,6 +136,7 @@ public String toString() { /** Builds {@link BankTransferPaymentMethodConfig}. */ public static final class Builder { private JsonField accountId = JsonField.missing(); + private String type = "bank_transfer"; private final Map additionalProperties = new LinkedHashMap<>(); private Builder() {} @@ -134,6 +152,17 @@ public Builder accountId(String accountId) { return this; } + /** + * The {@code type} property. + * + * @param type the value + * @return this builder + */ + public Builder type(String type) { + this.type = type; + return this; + } + /** * A property the SDK does not know, sent along. * @@ -175,6 +204,7 @@ public Builder removeAdditionalProperty(String name) { * @throws IllegalStateException when a required property is not set */ public BankTransferPaymentMethodConfig build() { + Utils.checkRequired(type, "type"); return new BankTransferPaymentMethodConfig(this); } } diff --git a/src/main/java/com/meteroid/models/BillingCycleResetPeriod.java b/src/main/java/com/meteroid/models/BillingCycleResetPeriod.java index 96afc8a..2aff0c5 100644 --- a/src/main/java/com/meteroid/models/BillingCycleResetPeriod.java +++ b/src/main/java/com/meteroid/models/BillingCycleResetPeriod.java @@ -7,6 +7,7 @@ import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.JsonNode; import com.meteroid.internal.Utils; @@ -27,11 +28,15 @@ isGetterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE) public final class BillingCycleResetPeriod { + @JsonProperty("type") + private String type = "BILLING_CYCLE"; + private final Map additionalProperties = new LinkedHashMap<>(); private BillingCycleResetPeriod() {} private BillingCycleResetPeriod(Builder builder) { + this.type = builder.type; this.additionalProperties.putAll(builder.additionalProperties); } @@ -51,10 +56,20 @@ public static Builder builder() { */ public Builder toBuilder() { Builder builder = new Builder(); + builder.type = type; builder.additionalProperties.putAll(additionalProperties); return builder; } + /** + * The {@code type} property. + * + * @return the value, never null + */ + public String type() { + return Utils.required(type, "type"); + } + /** * Properties this version of the SDK does not know, kept as received and sent back. * @@ -83,25 +98,43 @@ public boolean equals(Object o) { return false; } BillingCycleResetPeriod that = (BillingCycleResetPeriod) o; - return Objects.equals(additionalProperties, that.additionalProperties); + return Objects.equals(type, that.type) + && Objects.equals(additionalProperties, that.additionalProperties); } @Override public int hashCode() { - return Objects.hash(additionalProperties); + return Objects.hash(type, additionalProperties); } @Override public String toString() { - return "BillingCycleResetPeriod{" + "additionalProperties=" + additionalProperties + "}"; + return "BillingCycleResetPeriod{" + + "type=" + + type + + ", additionalProperties=" + + additionalProperties + + "}"; } /** Builds {@link BillingCycleResetPeriod}. */ public static final class Builder { + private String type = "BILLING_CYCLE"; private final Map additionalProperties = new LinkedHashMap<>(); private Builder() {} + /** + * The {@code type} property. + * + * @param type the value + * @return this builder + */ + public Builder type(String type) { + this.type = type; + return this; + } + /** * A property the SDK does not know, sent along. * @@ -143,6 +176,7 @@ public Builder removeAdditionalProperty(String name) { * @throws IllegalStateException when a required property is not set */ public BillingCycleResetPeriod build() { + Utils.checkRequired(type, "type"); return new BillingCycleResetPeriod(this); } } diff --git a/src/main/java/com/meteroid/models/BooleanConfigValue.java b/src/main/java/com/meteroid/models/BooleanConfigValue.java index 15f0616..b49e267 100644 --- a/src/main/java/com/meteroid/models/BooleanConfigValue.java +++ b/src/main/java/com/meteroid/models/BooleanConfigValue.java @@ -28,6 +28,9 @@ isGetterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE) public final class BooleanConfigValue { + @JsonProperty("kind") + private String kind = "BOOLEAN"; + @JsonProperty("value") private Boolean value; @@ -36,6 +39,7 @@ public final class BooleanConfigValue { private BooleanConfigValue() {} private BooleanConfigValue(Builder builder) { + this.kind = builder.kind; this.value = builder.value; this.additionalProperties.putAll(builder.additionalProperties); } @@ -56,11 +60,21 @@ public static Builder builder() { */ public Builder toBuilder() { Builder builder = new Builder(); + builder.kind = kind; builder.value = value; builder.additionalProperties.putAll(additionalProperties); return builder; } + /** + * The {@code kind} property. + * + * @return the value, never null + */ + public String kind() { + return Utils.required(kind, "kind"); + } + /** * The {@code value} property. * @@ -98,19 +112,22 @@ public boolean equals(Object o) { return false; } BooleanConfigValue that = (BooleanConfigValue) o; - return Objects.equals(value, that.value) + return Objects.equals(kind, that.kind) + && Objects.equals(value, that.value) && Objects.equals(additionalProperties, that.additionalProperties); } @Override public int hashCode() { - return Objects.hash(value, additionalProperties); + return Objects.hash(kind, value, additionalProperties); } @Override public String toString() { return "BooleanConfigValue{" - + "value=" + + "kind=" + + kind + + ", value=" + value + ", additionalProperties=" + additionalProperties @@ -119,11 +136,23 @@ public String toString() { /** Builds {@link BooleanConfigValue}. */ public static final class Builder { + private String kind = "BOOLEAN"; private Boolean value; private final Map additionalProperties = new LinkedHashMap<>(); private Builder() {} + /** + * The {@code kind} property. + * + * @param kind the value + * @return this builder + */ + public Builder kind(String kind) { + this.kind = kind; + return this; + } + /** * The {@code value} property. * @@ -176,6 +205,7 @@ public Builder removeAdditionalProperty(String name) { * @throws IllegalStateException when a required property is not set */ public BooleanConfigValue build() { + Utils.checkRequired(kind, "kind"); Utils.checkRequired(value, "value"); return new BooleanConfigValue(this); } diff --git a/src/main/java/com/meteroid/models/BooleanEffectiveEntitlementValue.java b/src/main/java/com/meteroid/models/BooleanEffectiveEntitlementValue.java index 5ca215e..1233cd4 100644 --- a/src/main/java/com/meteroid/models/BooleanEffectiveEntitlementValue.java +++ b/src/main/java/com/meteroid/models/BooleanEffectiveEntitlementValue.java @@ -27,12 +27,16 @@ public final class BooleanEffectiveEntitlementValue { @JsonProperty("enabled") private Boolean enabled; + @JsonProperty("type") + private String type = "BOOLEAN"; + private final Map additionalProperties = new LinkedHashMap<>(); private BooleanEffectiveEntitlementValue() {} private BooleanEffectiveEntitlementValue(Builder builder) { this.enabled = builder.enabled; + this.type = builder.type; this.additionalProperties.putAll(builder.additionalProperties); } @@ -53,6 +57,7 @@ public static Builder builder() { public Builder toBuilder() { Builder builder = new Builder(); builder.enabled = enabled; + builder.type = type; builder.additionalProperties.putAll(additionalProperties); return builder; } @@ -66,6 +71,15 @@ public Boolean enabled() { return Utils.required(enabled, "enabled"); } + /** + * The {@code type} property. + * + * @return the value, never null + */ + public String type() { + return Utils.required(type, "type"); + } + /** * Properties this version of the SDK does not know, kept as received and sent back. * @@ -95,12 +109,13 @@ public boolean equals(Object o) { } BooleanEffectiveEntitlementValue that = (BooleanEffectiveEntitlementValue) o; return Objects.equals(enabled, that.enabled) + && Objects.equals(type, that.type) && Objects.equals(additionalProperties, that.additionalProperties); } @Override public int hashCode() { - return Objects.hash(enabled, additionalProperties); + return Objects.hash(enabled, type, additionalProperties); } @Override @@ -108,6 +123,8 @@ public String toString() { return "BooleanEffectiveEntitlementValue{" + "enabled=" + enabled + + ", type=" + + type + ", additionalProperties=" + additionalProperties + "}"; @@ -116,6 +133,7 @@ public String toString() { /** Builds {@link BooleanEffectiveEntitlementValue}. */ public static final class Builder { private Boolean enabled; + private String type = "BOOLEAN"; private final Map additionalProperties = new LinkedHashMap<>(); private Builder() {} @@ -131,6 +149,17 @@ public Builder enabled(Boolean enabled) { return this; } + /** + * The {@code type} property. + * + * @param type the value + * @return this builder + */ + public Builder type(String type) { + this.type = type; + return this; + } + /** * A property the SDK does not know, sent along. * @@ -173,6 +202,7 @@ public Builder removeAdditionalProperty(String name) { */ public BooleanEffectiveEntitlementValue build() { Utils.checkRequired(enabled, "enabled"); + Utils.checkRequired(type, "type"); return new BooleanEffectiveEntitlementValue(this); } } diff --git a/src/main/java/com/meteroid/models/BooleanEntitlementValue.java b/src/main/java/com/meteroid/models/BooleanEntitlementValue.java index aeea85f..9496d92 100644 --- a/src/main/java/com/meteroid/models/BooleanEntitlementValue.java +++ b/src/main/java/com/meteroid/models/BooleanEntitlementValue.java @@ -27,12 +27,16 @@ public final class BooleanEntitlementValue { @JsonProperty("enabled") private Boolean enabled; + @JsonProperty("type") + private String type = "BOOLEAN"; + private final Map additionalProperties = new LinkedHashMap<>(); private BooleanEntitlementValue() {} private BooleanEntitlementValue(Builder builder) { this.enabled = builder.enabled; + this.type = builder.type; this.additionalProperties.putAll(builder.additionalProperties); } @@ -53,6 +57,7 @@ public static Builder builder() { public Builder toBuilder() { Builder builder = new Builder(); builder.enabled = enabled; + builder.type = type; builder.additionalProperties.putAll(additionalProperties); return builder; } @@ -66,6 +71,15 @@ public Boolean enabled() { return Utils.required(enabled, "enabled"); } + /** + * The {@code type} property. + * + * @return the value, never null + */ + public String type() { + return Utils.required(type, "type"); + } + /** * Properties this version of the SDK does not know, kept as received and sent back. * @@ -95,12 +109,13 @@ public boolean equals(Object o) { } BooleanEntitlementValue that = (BooleanEntitlementValue) o; return Objects.equals(enabled, that.enabled) + && Objects.equals(type, that.type) && Objects.equals(additionalProperties, that.additionalProperties); } @Override public int hashCode() { - return Objects.hash(enabled, additionalProperties); + return Objects.hash(enabled, type, additionalProperties); } @Override @@ -108,6 +123,8 @@ public String toString() { return "BooleanEntitlementValue{" + "enabled=" + enabled + + ", type=" + + type + ", additionalProperties=" + additionalProperties + "}"; @@ -116,6 +133,7 @@ public String toString() { /** Builds {@link BooleanEntitlementValue}. */ public static final class Builder { private Boolean enabled; + private String type = "BOOLEAN"; private final Map additionalProperties = new LinkedHashMap<>(); private Builder() {} @@ -131,6 +149,17 @@ public Builder enabled(Boolean enabled) { return this; } + /** + * The {@code type} property. + * + * @param type the value + * @return this builder + */ + public Builder type(String type) { + this.type = type; + return this; + } + /** * A property the SDK does not know, sent along. * @@ -173,6 +202,7 @@ public Builder removeAdditionalProperty(String name) { */ public BooleanEntitlementValue build() { Utils.checkRequired(enabled, "enabled"); + Utils.checkRequired(type, "type"); return new BooleanEntitlementValue(this); } } diff --git a/src/main/java/com/meteroid/models/BooleanFeatureType.java b/src/main/java/com/meteroid/models/BooleanFeatureType.java index 5d33da0..a1e6786 100644 --- a/src/main/java/com/meteroid/models/BooleanFeatureType.java +++ b/src/main/java/com/meteroid/models/BooleanFeatureType.java @@ -7,6 +7,7 @@ import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.JsonNode; import com.meteroid.internal.Utils; @@ -23,11 +24,15 @@ isGetterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE) public final class BooleanFeatureType { + @JsonProperty("type") + private String type = "BOOLEAN"; + private final Map additionalProperties = new LinkedHashMap<>(); private BooleanFeatureType() {} private BooleanFeatureType(Builder builder) { + this.type = builder.type; this.additionalProperties.putAll(builder.additionalProperties); } @@ -47,10 +52,20 @@ public static Builder builder() { */ public Builder toBuilder() { Builder builder = new Builder(); + builder.type = type; builder.additionalProperties.putAll(additionalProperties); return builder; } + /** + * The {@code type} property. + * + * @return the value, never null + */ + public String type() { + return Utils.required(type, "type"); + } + /** * Properties this version of the SDK does not know, kept as received and sent back. * @@ -79,25 +94,43 @@ public boolean equals(Object o) { return false; } BooleanFeatureType that = (BooleanFeatureType) o; - return Objects.equals(additionalProperties, that.additionalProperties); + return Objects.equals(type, that.type) + && Objects.equals(additionalProperties, that.additionalProperties); } @Override public int hashCode() { - return Objects.hash(additionalProperties); + return Objects.hash(type, additionalProperties); } @Override public String toString() { - return "BooleanFeatureType{" + "additionalProperties=" + additionalProperties + "}"; + return "BooleanFeatureType{" + + "type=" + + type + + ", additionalProperties=" + + additionalProperties + + "}"; } /** Builds {@link BooleanFeatureType}. */ public static final class Builder { + private String type = "BOOLEAN"; private final Map additionalProperties = new LinkedHashMap<>(); private Builder() {} + /** + * The {@code type} property. + * + * @param type the value + * @return this builder + */ + public Builder type(String type) { + this.type = type; + return this; + } + /** * A property the SDK does not know, sent along. * @@ -139,6 +172,7 @@ public Builder removeAdditionalProperty(String name) { * @throws IllegalStateException when a required property is not set */ public BooleanFeatureType build() { + Utils.checkRequired(type, "type"); return new BooleanFeatureType(this); } } diff --git a/src/main/java/com/meteroid/models/BooleanResolvedEntitlementValue.java b/src/main/java/com/meteroid/models/BooleanResolvedEntitlementValue.java index 9d71dee..3e15505 100644 --- a/src/main/java/com/meteroid/models/BooleanResolvedEntitlementValue.java +++ b/src/main/java/com/meteroid/models/BooleanResolvedEntitlementValue.java @@ -27,12 +27,16 @@ public final class BooleanResolvedEntitlementValue { @JsonProperty("enabled") private Boolean enabled; + @JsonProperty("type") + private String type = "BOOLEAN"; + private final Map additionalProperties = new LinkedHashMap<>(); private BooleanResolvedEntitlementValue() {} private BooleanResolvedEntitlementValue(Builder builder) { this.enabled = builder.enabled; + this.type = builder.type; this.additionalProperties.putAll(builder.additionalProperties); } @@ -53,6 +57,7 @@ public static Builder builder() { public Builder toBuilder() { Builder builder = new Builder(); builder.enabled = enabled; + builder.type = type; builder.additionalProperties.putAll(additionalProperties); return builder; } @@ -66,6 +71,15 @@ public Boolean enabled() { return Utils.required(enabled, "enabled"); } + /** + * The {@code type} property. + * + * @return the value, never null + */ + public String type() { + return Utils.required(type, "type"); + } + /** * Properties this version of the SDK does not know, kept as received and sent back. * @@ -95,12 +109,13 @@ public boolean equals(Object o) { } BooleanResolvedEntitlementValue that = (BooleanResolvedEntitlementValue) o; return Objects.equals(enabled, that.enabled) + && Objects.equals(type, that.type) && Objects.equals(additionalProperties, that.additionalProperties); } @Override public int hashCode() { - return Objects.hash(enabled, additionalProperties); + return Objects.hash(enabled, type, additionalProperties); } @Override @@ -108,6 +123,8 @@ public String toString() { return "BooleanResolvedEntitlementValue{" + "enabled=" + enabled + + ", type=" + + type + ", additionalProperties=" + additionalProperties + "}"; @@ -116,6 +133,7 @@ public String toString() { /** Builds {@link BooleanResolvedEntitlementValue}. */ public static final class Builder { private Boolean enabled; + private String type = "BOOLEAN"; private final Map additionalProperties = new LinkedHashMap<>(); private Builder() {} @@ -131,6 +149,17 @@ public Builder enabled(Boolean enabled) { return this; } + /** + * The {@code type} property. + * + * @param type the value + * @return this builder + */ + public Builder type(String type) { + this.type = type; + return this; + } + /** * A property the SDK does not know, sent along. * @@ -173,6 +202,7 @@ public Builder removeAdditionalProperty(String name) { */ public BooleanResolvedEntitlementValue build() { Utils.checkRequired(enabled, "enabled"); + Utils.checkRequired(type, "type"); return new BooleanResolvedEntitlementValue(this); } } diff --git a/src/main/java/com/meteroid/models/Budget.java b/src/main/java/com/meteroid/models/Budget.java new file mode 100644 index 0000000..f027609 --- /dev/null +++ b/src/main/java/com/meteroid/models/Budget.java @@ -0,0 +1,724 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.JsonField; +import com.meteroid.internal.Utils; + +import java.time.OffsetDateTime; +import java.util.ArrayList; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +/** + * A spending limit for one currency, set by you or by the customer, with alerts at percentages of + * it. It counts the customer's whole spend, or one subscription's. A HARD budget also refuses + * access once reached. A budget never charges the customer. + * + *

Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonAutoDetect( + getterVisibility = Visibility.NONE, + isGetterVisibility = Visibility.NONE, + setterVisibility = Visibility.NONE) +public final class Budget { + @JsonProperty("amount") + private Long amount; + + @JsonProperty("archived_at") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField archivedAt = JsonField.missing(); + + @JsonProperty("as_of") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField asOf = JsonField.missing(); + + @JsonProperty("behavior") + private BudgetBehavior behavior; + + @JsonProperty("created_at") + private OffsetDateTime createdAt; + + @JsonProperty("created_by") + private BudgetAuthor createdBy; + + @JsonProperty("credit_unit") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField creditUnit = JsonField.missing(); + + @JsonProperty("credit_unit_precision") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField creditUnitPrecision = JsonField.missing(); + + @JsonProperty("currency") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField currency = JsonField.missing(); + + @JsonProperty("estimated_spend") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField estimatedSpend = JsonField.missing(); + + @JsonProperty("exact") + private Boolean exact; + + @JsonProperty("id") + private String id; + + @JsonProperty("period") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField period = JsonField.missing(); + + @JsonProperty("subscription_id") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField subscriptionId = JsonField.missing(); + + @JsonProperty("thresholds") + private List thresholds; + + @JsonProperty("updated_at") + private OffsetDateTime updatedAt; + + @JsonProperty("version") + private Integer version; + + private final Map additionalProperties = new LinkedHashMap<>(); + + private Budget() {} + + private Budget(Builder builder) { + this.amount = builder.amount; + this.archivedAt = builder.archivedAt; + this.asOf = builder.asOf; + this.behavior = builder.behavior; + this.createdAt = builder.createdAt; + this.createdBy = builder.createdBy; + this.creditUnit = builder.creditUnit; + this.creditUnitPrecision = builder.creditUnitPrecision; + this.currency = builder.currency; + this.estimatedSpend = builder.estimatedSpend; + this.exact = builder.exact; + this.id = builder.id; + this.period = builder.period; + this.subscriptionId = builder.subscriptionId; + this.thresholds = Utils.copyList(builder.thresholds); + this.updatedAt = builder.updatedAt; + this.version = builder.version; + this.additionalProperties.putAll(builder.additionalProperties); + } + + /** + * A builder of {@code Budget}. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * A builder starting from this value. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.amount = amount; + builder.archivedAt = archivedAt; + builder.asOf = asOf; + builder.behavior = behavior; + builder.createdAt = createdAt; + builder.createdBy = createdBy; + builder.creditUnit = creditUnit; + builder.creditUnitPrecision = creditUnitPrecision; + builder.currency = currency; + builder.estimatedSpend = estimatedSpend; + builder.exact = exact; + builder.id = id; + builder.period = period; + builder.subscriptionId = subscriptionId; + builder.thresholds = Utils.mutableList(thresholds); + builder.updatedAt = updatedAt; + builder.version = version; + builder.additionalProperties.putAll(additionalProperties); + return builder; + } + + /** + * In minor units of the currency or credit unit. + * + * @return the value, never null + */ + public Long amount() { + return Utils.required(amount, "amount"); + } + + /** + * The {@code archived_at} property. + * + * @return the value, empty when unset or null + */ + public Optional archivedAt() { + return archivedAt.asOptional(); + } + + /** + * When estimated_spend was last measured. + * + * @return the value, empty when unset or null + */ + public Optional asOf() { + return asOf.asOptional(); + } + + /** + * The {@code behavior} property. + * + * @return the value, never null + */ + public BudgetBehavior behavior() { + return Utils.required(behavior, "behavior"); + } + + /** + * The {@code created_at} property. + * + * @return the value, never null + */ + public OffsetDateTime createdAt() { + return Utils.required(createdAt, "created_at"); + } + + /** + * The {@code created_by} property. + * + * @return the value, never null + */ + public BudgetAuthor createdBy() { + return Utils.required(createdBy, "created_by"); + } + + /** + * The credit unit (its code) whose usage the budget counts; absent for a currency. + * + * @return the value, empty when unset or null + */ + public Optional creditUnit() { + return creditUnit.asOptional(); + } + + /** + * Decimal places of credit_unit: amounts are integers of 10^-precision credit. + * + * @return the value, empty when unset or null + */ + public Optional creditUnitPrecision() { + return creditUnitPrecision.asOptional(); + } + + /** + * The {@code currency} property. + * + * @return the value, empty when unset or null + */ + public Optional currency() { + return currency.asOptional(); + } + + /** + * Spend in the current billing period, including usage not invoiced yet, in minor units. Absent + * until first measured. + * + * @return the value, empty when unset or null + */ + public Optional estimatedSpend() { + return estimatedSpend.asOptional(); + } + + /** + * Always false: the estimate prices usage that is not yet invoiced. + * + * @return the value, never null + */ + public Boolean exact() { + return Utils.required(exact, "exact"); + } + + /** + * The {@code id} property. + * + * @return the value, never null + */ + public String id() { + return Utils.required(id, "id"); + } + + /** + * The {@code period} property. + * + * @return the value, empty when unset or null + */ + public Optional period() { + return period.asOptional(); + } + + /** + * The subscription whose spend the budget counts; null when it counts the whole customer's. + * + * @return the value, empty when unset or null + */ + public Optional subscriptionId() { + return subscriptionId.asOptional(); + } + + /** + * Percentages of the amount at which an alert is sent. + * + * @return the value, never null + */ + public List thresholds() { + return Utils.required(thresholds, "thresholds"); + } + + /** + * The {@code updated_at} property. + * + * @return the value, never null + */ + public OffsetDateTime updatedAt() { + return Utils.required(updatedAt, "updated_at"); + } + + /** + * Send it back as expected_version when patching. + * + * @return the value, never null + */ + public Integer version() { + return Utils.required(version, "version"); + } + + /** + * Properties this version of the SDK does not know, kept as received and sent back. + * + * @return the properties by name, unmodifiable + */ + public Map additionalProperties() { + return Collections.unmodifiableMap(additionalProperties); + } + + @JsonAnyGetter + private Map anyProperties() { + return additionalProperties; + } + + @JsonAnySetter + private void putAnyProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Budget that = (Budget) o; + return Objects.equals(amount, that.amount) + && Objects.equals(archivedAt, that.archivedAt) + && Objects.equals(asOf, that.asOf) + && Objects.equals(behavior, that.behavior) + && Objects.equals(createdAt, that.createdAt) + && Objects.equals(createdBy, that.createdBy) + && Objects.equals(creditUnit, that.creditUnit) + && Objects.equals(creditUnitPrecision, that.creditUnitPrecision) + && Objects.equals(currency, that.currency) + && Objects.equals(estimatedSpend, that.estimatedSpend) + && Objects.equals(exact, that.exact) + && Objects.equals(id, that.id) + && Objects.equals(period, that.period) + && Objects.equals(subscriptionId, that.subscriptionId) + && Objects.equals(thresholds, that.thresholds) + && Objects.equals(updatedAt, that.updatedAt) + && Objects.equals(version, that.version) + && Objects.equals(additionalProperties, that.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash( + amount, + archivedAt, + asOf, + behavior, + createdAt, + createdBy, + creditUnit, + creditUnitPrecision, + currency, + estimatedSpend, + exact, + id, + period, + subscriptionId, + thresholds, + updatedAt, + version, + additionalProperties); + } + + @Override + public String toString() { + return "Budget{" + + "amount=" + + amount + + ", archivedAt=" + + archivedAt + + ", asOf=" + + asOf + + ", behavior=" + + behavior + + ", createdAt=" + + createdAt + + ", createdBy=" + + createdBy + + ", creditUnit=" + + creditUnit + + ", creditUnitPrecision=" + + creditUnitPrecision + + ", currency=" + + currency + + ", estimatedSpend=" + + estimatedSpend + + ", exact=" + + exact + + ", id=" + + id + + ", period=" + + period + + ", subscriptionId=" + + subscriptionId + + ", thresholds=" + + thresholds + + ", updatedAt=" + + updatedAt + + ", version=" + + version + + ", additionalProperties=" + + additionalProperties + + "}"; + } + + /** Builds {@link Budget}. */ + public static final class Builder { + private Long amount; + private JsonField archivedAt = JsonField.missing(); + private JsonField asOf = JsonField.missing(); + private BudgetBehavior behavior; + private OffsetDateTime createdAt; + private BudgetAuthor createdBy; + private JsonField creditUnit = JsonField.missing(); + private JsonField creditUnitPrecision = JsonField.missing(); + private JsonField currency = JsonField.missing(); + private JsonField estimatedSpend = JsonField.missing(); + private Boolean exact; + private String id; + private JsonField period = JsonField.missing(); + private JsonField subscriptionId = JsonField.missing(); + private List thresholds; + private OffsetDateTime updatedAt; + private Integer version; + private final Map additionalProperties = new LinkedHashMap<>(); + + private Builder() {} + + /** + * In minor units of the currency or credit unit. + * + * @param amount the value + * @return this builder + */ + public Builder amount(Long amount) { + this.amount = amount; + return this; + } + + /** + * The {@code archived_at} property. + * + * @param archivedAt the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder archivedAt(OffsetDateTime archivedAt) { + this.archivedAt = JsonField.ofNullable(archivedAt); + return this; + } + + /** + * When estimated_spend was last measured. + * + * @param asOf the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder asOf(OffsetDateTime asOf) { + this.asOf = JsonField.ofNullable(asOf); + return this; + } + + /** + * The {@code behavior} property. + * + * @param behavior the value + * @return this builder + */ + public Builder behavior(BudgetBehavior behavior) { + this.behavior = behavior; + return this; + } + + /** + * The {@code created_at} property. + * + * @param createdAt the value + * @return this builder + */ + public Builder createdAt(OffsetDateTime createdAt) { + this.createdAt = createdAt; + return this; + } + + /** + * The {@code created_by} property. + * + * @param createdBy the value + * @return this builder + */ + public Builder createdBy(BudgetAuthor createdBy) { + this.createdBy = createdBy; + return this; + } + + /** + * The credit unit (its code) whose usage the budget counts; absent for a currency. + * + * @param creditUnit the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder creditUnit(String creditUnit) { + this.creditUnit = JsonField.ofNullable(creditUnit); + return this; + } + + /** + * Decimal places of credit_unit: amounts are integers of 10^-precision credit. + * + * @param creditUnitPrecision the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder creditUnitPrecision(Integer creditUnitPrecision) { + this.creditUnitPrecision = JsonField.ofNullable(creditUnitPrecision); + return this; + } + + /** + * The {@code currency} property. + * + * @param currency the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder currency(Currency currency) { + this.currency = JsonField.ofNullable(currency); + return this; + } + + /** + * Spend in the current billing period, including usage not invoiced yet, in minor units. + * Absent until first measured. + * + * @param estimatedSpend the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder estimatedSpend(Long estimatedSpend) { + this.estimatedSpend = JsonField.ofNullable(estimatedSpend); + return this; + } + + /** + * Always false: the estimate prices usage that is not yet invoiced. + * + * @param exact the value + * @return this builder + */ + public Builder exact(Boolean exact) { + this.exact = exact; + return this; + } + + /** + * The {@code id} property. + * + * @param id the value + * @return this builder + */ + public Builder id(String id) { + this.id = id; + return this; + } + + /** + * The {@code period} property. + * + * @param period the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder period(BudgetPeriod period) { + this.period = JsonField.ofNullable(period); + return this; + } + + /** + * The subscription whose spend the budget counts; null when it counts the whole customer's. + * + * @param subscriptionId the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder subscriptionId(String subscriptionId) { + this.subscriptionId = JsonField.ofNullable(subscriptionId); + return this; + } + + /** + * Percentages of the amount at which an alert is sent. + * + * @param thresholds the value + * @return this builder + */ + public Builder thresholds(List thresholds) { + this.thresholds = Utils.mutableList(thresholds); + return this; + } + + /** + * Adds an item to {@code thresholds}. + * + * @param item the item + * @return this builder + */ + public Builder addThresholdsItem(Integer item) { + if (this.thresholds == null) { + this.thresholds = new ArrayList<>(); + } + this.thresholds.add(item); + return this; + } + + /** + * The {@code updated_at} property. + * + * @param updatedAt the value + * @return this builder + */ + public Builder updatedAt(OffsetDateTime updatedAt) { + this.updatedAt = updatedAt; + return this; + } + + /** + * Send it back as expected_version when patching. + * + * @param version the value + * @return this builder + */ + public Builder version(Integer version) { + this.version = version; + return this; + } + + /** + * A property the SDK does not know, sent along. + * + * @param name the property name + * @param value the JSON value + * @return this builder + */ + public Builder putAdditionalProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + return this; + } + + /** + * Properties the SDK does not know, sent along. + * + * @param additionalProperties the properties by name + * @return this builder + */ + public Builder putAllAdditionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + + /** + * Leaves out a property the SDK does not know. + * + * @param name the property name + * @return this builder + */ + public Builder removeAdditionalProperty(String name) { + additionalProperties.remove(name); + return this; + } + + /** + * The {@code Budget}. + * + * @return the immutable value + * @throws IllegalStateException when a required property is not set + */ + public Budget build() { + Utils.checkRequired(amount, "amount"); + Utils.checkRequired(behavior, "behavior"); + Utils.checkRequired(createdAt, "created_at"); + Utils.checkRequired(createdBy, "created_by"); + Utils.checkRequired(exact, "exact"); + Utils.checkRequired(id, "id"); + Utils.checkRequired(thresholds, "thresholds"); + Utils.checkRequired(updatedAt, "updated_at"); + Utils.checkRequired(version, "version"); + return new Budget(this); + } + } + + /** + * Parse {@code json} as {@code Budget}. + * + * @param json the JSON text + * @return the value + * @throws com.meteroid.exceptions.InvalidDataException if it is not valid JSON of this shape + */ + public static Budget fromJson(String json) { + return Utils.parse(json, Budget.class); + } + + /** + * This value as JSON. + * + * @return the JSON text + */ + public String toJson() { + return Utils.json(this); + } +} diff --git a/src/main/java/com/meteroid/models/BudgetAuthor.java b/src/main/java/com/meteroid/models/BudgetAuthor.java new file mode 100644 index 0000000..6ada299 --- /dev/null +++ b/src/main/java/com/meteroid/models/BudgetAuthor.java @@ -0,0 +1,128 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import com.meteroid.internal.Utils.ToQueryParam; + +import java.util.Map; +import java.util.Objects; + +/** + * Who set the budget: you (TENANT) or the customer, from the portal (CUSTOMER). + * + *

Values this version of the SDK does not know are kept, and sent back unchanged: {@link + * #value()} is an enum to switch on, {@code _UNKNOWN} for them, and {@link #known()} throws on + * them. + */ +public final class BudgetAuthor implements ToQueryParam { + /** The value {@code "TENANT"}. */ + public static final BudgetAuthor TENANT = new BudgetAuthor("TENANT", Value.TENANT); + + /** The value {@code "CUSTOMER"}. */ + public static final BudgetAuthor CUSTOMER = new BudgetAuthor("CUSTOMER", Value.CUSTOMER); + + private static final Map constants = + Map.ofEntries(Map.entry("TENANT", TENANT), Map.entry("CUSTOMER", CUSTOMER)); + + private final String value; + private final Value variant; + + private BudgetAuthor(String value, Value variant) { + this.value = value; + this.variant = variant; + } + + /** + * The constant for {@code value}, or an unknown BudgetAuthor holding it. + * + * @param value the value + * @return the constant + */ + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static BudgetAuthor of(String value) { + BudgetAuthor constant = constants.get(Objects.requireNonNull(value, "value")); + return constant != null ? constant : new BudgetAuthor(value, Value._UNKNOWN); + } + + /** + * The value as sent. + * + * @return the value + */ + @JsonValue + public String asString() { + return value; + } + + /** + * Whether this version of the SDK knows the value. + * + * @return whether it is known + */ + public boolean isKnown() { + return variant != Value._UNKNOWN; + } + + /** + * The value as an enum to switch on, unknown values included. + * + * @return the enum, {@code _UNKNOWN} when unknown + */ + public Value value() { + return variant; + } + + /** + * The value as an enum of the known values only. + * + * @return the enum + * @throws com.meteroid.exceptions.InvalidDataException when this version of the SDK does not + * know the value + */ + public Known known() { + if (!isKnown()) { + throw new com.meteroid.exceptions.InvalidDataException( + "unknown BudgetAuthor: " + value); + } + return Known.valueOf(variant.name()); + } + + @Override + public String toQueryParam() { + return String.valueOf(value); + } + + @Override + public boolean equals(Object o) { + return o instanceof BudgetAuthor && Objects.equals(value, ((BudgetAuthor) o).value); + } + + @Override + public int hashCode() { + return Objects.hashCode(value); + } + + @Override + public String toString() { + return String.valueOf(value); + } + + /** The values this version of the SDK knows. */ + public enum Known { + /** The {@code TENANT} constant. */ + TENANT, + /** The {@code CUSTOMER} constant. */ + CUSTOMER + } + + /** The values this version of the SDK knows, and {@code _UNKNOWN} for the others. */ + public enum Value { + /** The {@code TENANT} constant. */ + TENANT, + /** The {@code CUSTOMER} constant. */ + CUSTOMER, + /** A value this version of the SDK does not know. */ + _UNKNOWN + } +} diff --git a/src/main/java/com/meteroid/models/BudgetBehavior.java b/src/main/java/com/meteroid/models/BudgetBehavior.java new file mode 100644 index 0000000..3fd5665 --- /dev/null +++ b/src/main/java/com/meteroid/models/BudgetBehavior.java @@ -0,0 +1,131 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import com.meteroid.internal.Utils.ToQueryParam; + +import java.util.Map; +import java.util.Objects; + +/** + * What reaching the amount does. A SOFT budget only sends alerts; a HARD budget also makes the + * entitlement check answer BUDGET_EXCEEDED for the features whose usage counts in its spend. A HARD + * budget on one subscription refuses the checks naming that subscription, and the checks naming + * none once every subscription charging the feature's metric is refused by its own. + * + *

Values this version of the SDK does not know are kept, and sent back unchanged: {@link + * #value()} is an enum to switch on, {@code _UNKNOWN} for them, and {@link #known()} throws on + * them. + */ +public final class BudgetBehavior implements ToQueryParam { + /** The value {@code "SOFT"}. */ + public static final BudgetBehavior SOFT = new BudgetBehavior("SOFT", Value.SOFT); + + /** The value {@code "HARD"}. */ + public static final BudgetBehavior HARD = new BudgetBehavior("HARD", Value.HARD); + + private static final Map constants = + Map.ofEntries(Map.entry("SOFT", SOFT), Map.entry("HARD", HARD)); + + private final String value; + private final Value variant; + + private BudgetBehavior(String value, Value variant) { + this.value = value; + this.variant = variant; + } + + /** + * The constant for {@code value}, or an unknown BudgetBehavior holding it. + * + * @param value the value + * @return the constant + */ + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static BudgetBehavior of(String value) { + BudgetBehavior constant = constants.get(Objects.requireNonNull(value, "value")); + return constant != null ? constant : new BudgetBehavior(value, Value._UNKNOWN); + } + + /** + * The value as sent. + * + * @return the value + */ + @JsonValue + public String asString() { + return value; + } + + /** + * Whether this version of the SDK knows the value. + * + * @return whether it is known + */ + public boolean isKnown() { + return variant != Value._UNKNOWN; + } + + /** + * The value as an enum to switch on, unknown values included. + * + * @return the enum, {@code _UNKNOWN} when unknown + */ + public Value value() { + return variant; + } + + /** + * The value as an enum of the known values only. + * + * @return the enum + * @throws com.meteroid.exceptions.InvalidDataException when this version of the SDK does not + * know the value + */ + public Known known() { + if (!isKnown()) { + throw new com.meteroid.exceptions.InvalidDataException( + "unknown BudgetBehavior: " + value); + } + return Known.valueOf(variant.name()); + } + + @Override + public String toQueryParam() { + return String.valueOf(value); + } + + @Override + public boolean equals(Object o) { + return o instanceof BudgetBehavior && Objects.equals(value, ((BudgetBehavior) o).value); + } + + @Override + public int hashCode() { + return Objects.hashCode(value); + } + + @Override + public String toString() { + return String.valueOf(value); + } + + /** The values this version of the SDK knows. */ + public enum Known { + /** The {@code SOFT} constant. */ + SOFT, + /** The {@code HARD} constant. */ + HARD + } + + /** The values this version of the SDK knows, and {@code _UNKNOWN} for the others. */ + public enum Value { + /** The {@code SOFT} constant. */ + SOFT, + /** The {@code HARD} constant. */ + HARD, + /** A value this version of the SDK does not know. */ + _UNKNOWN + } +} diff --git a/src/main/java/com/meteroid/models/BudgetListResponse.java b/src/main/java/com/meteroid/models/BudgetListResponse.java new file mode 100644 index 0000000..d9d092e --- /dev/null +++ b/src/main/java/com/meteroid/models/BudgetListResponse.java @@ -0,0 +1,245 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.Utils; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonAutoDetect( + getterVisibility = Visibility.NONE, + isGetterVisibility = Visibility.NONE, + setterVisibility = Visibility.NONE) +public final class BudgetListResponse { + @JsonProperty("data") + private List data; + + @JsonProperty("pagination_meta") + private PaginationResponse paginationMeta; + + private final Map additionalProperties = new LinkedHashMap<>(); + + private BudgetListResponse() {} + + private BudgetListResponse(Builder builder) { + this.data = Utils.copyList(builder.data); + this.paginationMeta = builder.paginationMeta; + this.additionalProperties.putAll(builder.additionalProperties); + } + + /** + * A builder of {@code BudgetListResponse}. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * A builder starting from this value. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.data = Utils.mutableList(data); + builder.paginationMeta = paginationMeta; + builder.additionalProperties.putAll(additionalProperties); + return builder; + } + + /** + * The {@code data} property. + * + * @return the value, never null + */ + public List data() { + return Utils.required(data, "data"); + } + + /** + * The {@code pagination_meta} property. + * + * @return the value, never null + */ + public PaginationResponse paginationMeta() { + return Utils.required(paginationMeta, "pagination_meta"); + } + + /** + * Properties this version of the SDK does not know, kept as received and sent back. + * + * @return the properties by name, unmodifiable + */ + public Map additionalProperties() { + return Collections.unmodifiableMap(additionalProperties); + } + + @JsonAnyGetter + private Map anyProperties() { + return additionalProperties; + } + + @JsonAnySetter + private void putAnyProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + BudgetListResponse that = (BudgetListResponse) o; + return Objects.equals(data, that.data) + && Objects.equals(paginationMeta, that.paginationMeta) + && Objects.equals(additionalProperties, that.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(data, paginationMeta, additionalProperties); + } + + @Override + public String toString() { + return "BudgetListResponse{" + + "data=" + + data + + ", paginationMeta=" + + paginationMeta + + ", additionalProperties=" + + additionalProperties + + "}"; + } + + /** Builds {@link BudgetListResponse}. */ + public static final class Builder { + private List data; + private PaginationResponse paginationMeta; + private final Map additionalProperties = new LinkedHashMap<>(); + + private Builder() {} + + /** + * The {@code data} property. + * + * @param data the value + * @return this builder + */ + public Builder data(List data) { + this.data = Utils.mutableList(data); + return this; + } + + /** + * Adds an item to {@code data}. + * + * @param item the item + * @return this builder + */ + public Builder addDataItem(Budget item) { + if (this.data == null) { + this.data = new ArrayList<>(); + } + this.data.add(item); + return this; + } + + /** + * The {@code pagination_meta} property. + * + * @param paginationMeta the value + * @return this builder + */ + public Builder paginationMeta(PaginationResponse paginationMeta) { + this.paginationMeta = paginationMeta; + return this; + } + + /** + * A property the SDK does not know, sent along. + * + * @param name the property name + * @param value the JSON value + * @return this builder + */ + public Builder putAdditionalProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + return this; + } + + /** + * Properties the SDK does not know, sent along. + * + * @param additionalProperties the properties by name + * @return this builder + */ + public Builder putAllAdditionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + + /** + * Leaves out a property the SDK does not know. + * + * @param name the property name + * @return this builder + */ + public Builder removeAdditionalProperty(String name) { + additionalProperties.remove(name); + return this; + } + + /** + * The {@code BudgetListResponse}. + * + * @return the immutable value + * @throws IllegalStateException when a required property is not set + */ + public BudgetListResponse build() { + Utils.checkRequired(data, "data"); + Utils.checkRequired(paginationMeta, "pagination_meta"); + return new BudgetListResponse(this); + } + } + + /** + * Parse {@code json} as {@code BudgetListResponse}. + * + * @param json the JSON text + * @return the value + * @throws com.meteroid.exceptions.InvalidDataException if it is not valid JSON of this shape + */ + public static BudgetListResponse fromJson(String json) { + return Utils.parse(json, BudgetListResponse.class); + } + + /** + * This value as JSON. + * + * @return the JSON text + */ + public String toJson() { + return Utils.json(this); + } +} diff --git a/src/main/java/com/meteroid/models/BudgetPeriod.java b/src/main/java/com/meteroid/models/BudgetPeriod.java new file mode 100644 index 0000000..179b2fb --- /dev/null +++ b/src/main/java/com/meteroid/models/BudgetPeriod.java @@ -0,0 +1,232 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.JsonField; +import com.meteroid.internal.Utils; + +import java.time.LocalDate; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +/** Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonAutoDetect( + getterVisibility = Visibility.NONE, + isGetterVisibility = Visibility.NONE, + setterVisibility = Visibility.NONE) +public final class BudgetPeriod { + @JsonProperty("end") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField end = JsonField.missing(); + + @JsonProperty("start") + private LocalDate start; + + private final Map additionalProperties = new LinkedHashMap<>(); + + private BudgetPeriod() {} + + private BudgetPeriod(Builder builder) { + this.end = builder.end; + this.start = builder.start; + this.additionalProperties.putAll(builder.additionalProperties); + } + + /** + * A builder of {@code BudgetPeriod}. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * A builder starting from this value. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.end = end; + builder.start = start; + builder.additionalProperties.putAll(additionalProperties); + return builder; + } + + /** + * Absent when the period never ends. + * + * @return the value, empty when unset or null + */ + public Optional end() { + return end.asOptional(); + } + + /** + * The {@code start} property. + * + * @return the value, never null + */ + public LocalDate start() { + return Utils.required(start, "start"); + } + + /** + * Properties this version of the SDK does not know, kept as received and sent back. + * + * @return the properties by name, unmodifiable + */ + public Map additionalProperties() { + return Collections.unmodifiableMap(additionalProperties); + } + + @JsonAnyGetter + private Map anyProperties() { + return additionalProperties; + } + + @JsonAnySetter + private void putAnyProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + BudgetPeriod that = (BudgetPeriod) o; + return Objects.equals(end, that.end) + && Objects.equals(start, that.start) + && Objects.equals(additionalProperties, that.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(end, start, additionalProperties); + } + + @Override + public String toString() { + return "BudgetPeriod{" + + "end=" + + end + + ", start=" + + start + + ", additionalProperties=" + + additionalProperties + + "}"; + } + + /** Builds {@link BudgetPeriod}. */ + public static final class Builder { + private JsonField end = JsonField.missing(); + private LocalDate start; + private final Map additionalProperties = new LinkedHashMap<>(); + + private Builder() {} + + /** + * Absent when the period never ends. + * + * @param end the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder end(LocalDate end) { + this.end = JsonField.ofNullable(end); + return this; + } + + /** + * The {@code start} property. + * + * @param start the value + * @return this builder + */ + public Builder start(LocalDate start) { + this.start = start; + return this; + } + + /** + * A property the SDK does not know, sent along. + * + * @param name the property name + * @param value the JSON value + * @return this builder + */ + public Builder putAdditionalProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + return this; + } + + /** + * Properties the SDK does not know, sent along. + * + * @param additionalProperties the properties by name + * @return this builder + */ + public Builder putAllAdditionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + + /** + * Leaves out a property the SDK does not know. + * + * @param name the property name + * @return this builder + */ + public Builder removeAdditionalProperty(String name) { + additionalProperties.remove(name); + return this; + } + + /** + * The {@code BudgetPeriod}. + * + * @return the immutable value + * @throws IllegalStateException when a required property is not set + */ + public BudgetPeriod build() { + Utils.checkRequired(start, "start"); + return new BudgetPeriod(this); + } + } + + /** + * Parse {@code json} as {@code BudgetPeriod}. + * + * @param json the JSON text + * @return the value + * @throws com.meteroid.exceptions.InvalidDataException if it is not valid JSON of this shape + */ + public static BudgetPeriod fromJson(String json) { + return Utils.parse(json, BudgetPeriod.class); + } + + /** + * This value as JSON. + * + * @return the JSON text + */ + public String toJson() { + return Utils.json(this); + } +} diff --git a/src/main/java/com/meteroid/models/CalendarResetPeriod.java b/src/main/java/com/meteroid/models/CalendarResetPeriod.java index f3d99af..db578a6 100644 --- a/src/main/java/com/meteroid/models/CalendarResetPeriod.java +++ b/src/main/java/com/meteroid/models/CalendarResetPeriod.java @@ -32,6 +32,9 @@ public final class CalendarResetPeriod { @JsonProperty("interval") private Integer interval; + @JsonProperty("type") + private String type = "CALENDAR"; + @JsonProperty("unit") private CalendarUnit unit; @@ -41,6 +44,7 @@ private CalendarResetPeriod() {} private CalendarResetPeriod(Builder builder) { this.interval = builder.interval; + this.type = builder.type; this.unit = builder.unit; this.additionalProperties.putAll(builder.additionalProperties); } @@ -62,6 +66,7 @@ public static Builder builder() { public Builder toBuilder() { Builder builder = new Builder(); builder.interval = interval; + builder.type = type; builder.unit = unit; builder.additionalProperties.putAll(additionalProperties); return builder; @@ -76,6 +81,15 @@ public Integer interval() { return Utils.required(interval, "interval"); } + /** + * The {@code type} property. + * + * @return the value, never null + */ + public String type() { + return Utils.required(type, "type"); + } + /** * The {@code unit} property. * @@ -114,13 +128,14 @@ public boolean equals(Object o) { } CalendarResetPeriod that = (CalendarResetPeriod) o; return Objects.equals(interval, that.interval) + && Objects.equals(type, that.type) && Objects.equals(unit, that.unit) && Objects.equals(additionalProperties, that.additionalProperties); } @Override public int hashCode() { - return Objects.hash(interval, unit, additionalProperties); + return Objects.hash(interval, type, unit, additionalProperties); } @Override @@ -128,6 +143,8 @@ public String toString() { return "CalendarResetPeriod{" + "interval=" + interval + + ", type=" + + type + ", unit=" + unit + ", additionalProperties=" @@ -138,6 +155,7 @@ public String toString() { /** Builds {@link CalendarResetPeriod}. */ public static final class Builder { private Integer interval; + private String type = "CALENDAR"; private CalendarUnit unit; private final Map additionalProperties = new LinkedHashMap<>(); @@ -154,6 +172,17 @@ public Builder interval(Integer interval) { return this; } + /** + * The {@code type} property. + * + * @param type the value + * @return this builder + */ + public Builder type(String type) { + this.type = type; + return this; + } + /** * The {@code unit} property. * @@ -207,6 +236,7 @@ public Builder removeAdditionalProperty(String name) { */ public CalendarResetPeriod build() { Utils.checkRequired(interval, "interval"); + Utils.checkRequired(type, "type"); Utils.checkRequired(unit, "unit"); return new CalendarResetPeriod(this); } diff --git a/src/main/java/com/meteroid/models/CapacityFee.java b/src/main/java/com/meteroid/models/CapacityFee.java index 95072b7..a3d35b4 100644 --- a/src/main/java/com/meteroid/models/CapacityFee.java +++ b/src/main/java/com/meteroid/models/CapacityFee.java @@ -9,6 +9,7 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.JsonField; import com.meteroid.internal.Utils; import java.math.BigDecimal; @@ -16,6 +17,7 @@ import java.util.LinkedHashMap; import java.util.Map; import java.util.Objects; +import java.util.Optional; /** Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. */ @JsonInclude(JsonInclude.Include.NON_NULL) @@ -25,6 +27,10 @@ isGetterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE) public final class CapacityFee { + @JsonProperty("credit_unit") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField creditUnit = JsonField.missing(); + @JsonProperty("included") private Long included; @@ -37,15 +43,20 @@ public final class CapacityFee { @JsonProperty("rate") private BigDecimal rate; + @JsonProperty("type") + private String type = "CAPACITY"; + private final Map additionalProperties = new LinkedHashMap<>(); private CapacityFee() {} private CapacityFee(Builder builder) { + this.creditUnit = builder.creditUnit; this.included = builder.included; this.metricId = builder.metricId; this.overageRate = builder.overageRate; this.rate = builder.rate; + this.type = builder.type; this.additionalProperties.putAll(builder.additionalProperties); } @@ -65,14 +76,25 @@ public static Builder builder() { */ public Builder toBuilder() { Builder builder = new Builder(); + builder.creditUnit = creditUnit; builder.included = included; builder.metricId = metricId; builder.overageRate = overageRate; builder.rate = rate; + builder.type = type; builder.additionalProperties.putAll(additionalProperties); return builder; } + /** + * The {@code credit_unit} property. + * + * @return the value, empty when unset or null + */ + public Optional creditUnit() { + return creditUnit.asOptional(); + } + /** * The {@code included} property. * @@ -109,6 +131,15 @@ public BigDecimal rate() { return Utils.required(rate, "rate"); } + /** + * The {@code type} property. + * + * @return the value, never null + */ + public String type() { + return Utils.required(type, "type"); + } + /** * Properties this version of the SDK does not know, kept as received and sent back. * @@ -137,22 +168,27 @@ public boolean equals(Object o) { return false; } CapacityFee that = (CapacityFee) o; - return Objects.equals(included, that.included) + return Objects.equals(creditUnit, that.creditUnit) + && Objects.equals(included, that.included) && Objects.equals(metricId, that.metricId) && Objects.equals(overageRate, that.overageRate) && Objects.equals(rate, that.rate) + && Objects.equals(type, that.type) && Objects.equals(additionalProperties, that.additionalProperties); } @Override public int hashCode() { - return Objects.hash(included, metricId, overageRate, rate, additionalProperties); + return Objects.hash( + creditUnit, included, metricId, overageRate, rate, type, additionalProperties); } @Override public String toString() { return "CapacityFee{" - + "included=" + + "creditUnit=" + + creditUnit + + ", included=" + included + ", metricId=" + metricId @@ -160,6 +196,8 @@ public String toString() { + overageRate + ", rate=" + rate + + ", type=" + + type + ", additionalProperties=" + additionalProperties + "}"; @@ -167,14 +205,27 @@ public String toString() { /** Builds {@link CapacityFee}. */ public static final class Builder { + private JsonField creditUnit = JsonField.missing(); private Long included; private String metricId; private BigDecimal overageRate; private BigDecimal rate; + private String type = "CAPACITY"; private final Map additionalProperties = new LinkedHashMap<>(); private Builder() {} + /** + * The {@code credit_unit} property. + * + * @param creditUnit the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder creditUnit(FeeCreditUnit creditUnit) { + this.creditUnit = JsonField.ofNullable(creditUnit); + return this; + } + /** * The {@code included} property. * @@ -219,6 +270,17 @@ public Builder rate(BigDecimal rate) { return this; } + /** + * The {@code type} property. + * + * @param type the value + * @return this builder + */ + public Builder type(String type) { + this.type = type; + return this; + } + /** * A property the SDK does not know, sent along. * @@ -264,6 +326,7 @@ public CapacityFee build() { Utils.checkRequired(metricId, "metric_id"); Utils.checkRequired(overageRate, "overage_rate"); Utils.checkRequired(rate, "rate"); + Utils.checkRequired(type, "type"); return new CapacityFee(this); } } diff --git a/src/main/java/com/meteroid/models/CapacityFeeStructure.java b/src/main/java/com/meteroid/models/CapacityFeeStructure.java index 5359b03..4337736 100644 --- a/src/main/java/com/meteroid/models/CapacityFeeStructure.java +++ b/src/main/java/com/meteroid/models/CapacityFeeStructure.java @@ -27,12 +27,16 @@ public final class CapacityFeeStructure { @JsonProperty("metric_id") private String metricId; + @JsonProperty("type") + private String type = "CAPACITY"; + private final Map additionalProperties = new LinkedHashMap<>(); private CapacityFeeStructure() {} private CapacityFeeStructure(Builder builder) { this.metricId = builder.metricId; + this.type = builder.type; this.additionalProperties.putAll(builder.additionalProperties); } @@ -53,6 +57,7 @@ public static Builder builder() { public Builder toBuilder() { Builder builder = new Builder(); builder.metricId = metricId; + builder.type = type; builder.additionalProperties.putAll(additionalProperties); return builder; } @@ -66,6 +71,15 @@ public String metricId() { return Utils.required(metricId, "metric_id"); } + /** + * The {@code type} property. + * + * @return the value, never null + */ + public String type() { + return Utils.required(type, "type"); + } + /** * Properties this version of the SDK does not know, kept as received and sent back. * @@ -95,12 +109,13 @@ public boolean equals(Object o) { } CapacityFeeStructure that = (CapacityFeeStructure) o; return Objects.equals(metricId, that.metricId) + && Objects.equals(type, that.type) && Objects.equals(additionalProperties, that.additionalProperties); } @Override public int hashCode() { - return Objects.hash(metricId, additionalProperties); + return Objects.hash(metricId, type, additionalProperties); } @Override @@ -108,6 +123,8 @@ public String toString() { return "CapacityFeeStructure{" + "metricId=" + metricId + + ", type=" + + type + ", additionalProperties=" + additionalProperties + "}"; @@ -116,6 +133,7 @@ public String toString() { /** Builds {@link CapacityFeeStructure}. */ public static final class Builder { private String metricId; + private String type = "CAPACITY"; private final Map additionalProperties = new LinkedHashMap<>(); private Builder() {} @@ -131,6 +149,17 @@ public Builder metricId(String metricId) { return this; } + /** + * The {@code type} property. + * + * @param type the value + * @return this builder + */ + public Builder type(String type) { + this.type = type; + return this; + } + /** * A property the SDK does not know, sent along. * @@ -173,6 +202,7 @@ public Builder removeAdditionalProperty(String name) { */ public CapacityFeeStructure build() { Utils.checkRequired(metricId, "metric_id"); + Utils.checkRequired(type, "type"); return new CapacityFeeStructure(this); } } diff --git a/src/main/java/com/meteroid/models/CapacityPlanFee.java b/src/main/java/com/meteroid/models/CapacityPlanFee.java index b2d6b38..ba88eba 100644 --- a/src/main/java/com/meteroid/models/CapacityPlanFee.java +++ b/src/main/java/com/meteroid/models/CapacityPlanFee.java @@ -9,6 +9,7 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.JsonField; import com.meteroid.internal.Utils; import java.util.ArrayList; @@ -17,6 +18,7 @@ import java.util.List; import java.util.Map; import java.util.Objects; +import java.util.Optional; /** * Capacity-based fee with included committed usage and overage @@ -33,20 +35,29 @@ public final class CapacityPlanFee { @JsonProperty("cadence") private BillingPeriodEnum cadence; + @JsonProperty("credit_unit") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField creditUnit = JsonField.missing(); + @JsonProperty("metric_id") private String metricId; @JsonProperty("thresholds") private List thresholds; + @JsonProperty("type") + private String type = "CAPACITY"; + private final Map additionalProperties = new LinkedHashMap<>(); private CapacityPlanFee() {} private CapacityPlanFee(Builder builder) { this.cadence = builder.cadence; + this.creditUnit = builder.creditUnit; this.metricId = builder.metricId; this.thresholds = Utils.copyList(builder.thresholds); + this.type = builder.type; this.additionalProperties.putAll(builder.additionalProperties); } @@ -67,8 +78,10 @@ public static Builder builder() { public Builder toBuilder() { Builder builder = new Builder(); builder.cadence = cadence; + builder.creditUnit = creditUnit; builder.metricId = metricId; builder.thresholds = Utils.mutableList(thresholds); + builder.type = type; builder.additionalProperties.putAll(additionalProperties); return builder; } @@ -82,6 +95,15 @@ public BillingPeriodEnum cadence() { return Utils.required(cadence, "cadence"); } + /** + * The {@code credit_unit} property. + * + * @return the value, empty when unset or null + */ + public Optional creditUnit() { + return creditUnit.asOptional(); + } + /** * The {@code metric_id} property. * @@ -100,6 +122,15 @@ public List thresholds() { return Utils.required(thresholds, "thresholds"); } + /** + * The {@code type} property. + * + * @return the value, never null + */ + public String type() { + return Utils.required(type, "type"); + } + /** * Properties this version of the SDK does not know, kept as received and sent back. * @@ -129,14 +160,16 @@ public boolean equals(Object o) { } CapacityPlanFee that = (CapacityPlanFee) o; return Objects.equals(cadence, that.cadence) + && Objects.equals(creditUnit, that.creditUnit) && Objects.equals(metricId, that.metricId) && Objects.equals(thresholds, that.thresholds) + && Objects.equals(type, that.type) && Objects.equals(additionalProperties, that.additionalProperties); } @Override public int hashCode() { - return Objects.hash(cadence, metricId, thresholds, additionalProperties); + return Objects.hash(cadence, creditUnit, metricId, thresholds, type, additionalProperties); } @Override @@ -144,10 +177,14 @@ public String toString() { return "CapacityPlanFee{" + "cadence=" + cadence + + ", creditUnit=" + + creditUnit + ", metricId=" + metricId + ", thresholds=" + thresholds + + ", type=" + + type + ", additionalProperties=" + additionalProperties + "}"; @@ -156,8 +193,10 @@ public String toString() { /** Builds {@link CapacityPlanFee}. */ public static final class Builder { private BillingPeriodEnum cadence; + private JsonField creditUnit = JsonField.missing(); private String metricId; private List thresholds; + private String type = "CAPACITY"; private final Map additionalProperties = new LinkedHashMap<>(); private Builder() {} @@ -173,6 +212,17 @@ public Builder cadence(BillingPeriodEnum cadence) { return this; } + /** + * The {@code credit_unit} property. + * + * @param creditUnit the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder creditUnit(PlanFeeCreditUnit creditUnit) { + this.creditUnit = JsonField.ofNullable(creditUnit); + return this; + } + /** * The {@code metric_id} property. * @@ -209,6 +259,17 @@ public Builder addThresholdsItem(CapacityThreshold item) { return this; } + /** + * The {@code type} property. + * + * @param type the value + * @return this builder + */ + public Builder type(String type) { + this.type = type; + return this; + } + /** * A property the SDK does not know, sent along. * @@ -253,6 +314,7 @@ public CapacityPlanFee build() { Utils.checkRequired(cadence, "cadence"); Utils.checkRequired(metricId, "metric_id"); Utils.checkRequired(thresholds, "thresholds"); + Utils.checkRequired(type, "type"); return new CapacityPlanFee(this); } } diff --git a/src/main/java/com/meteroid/models/CapacityPricing.java b/src/main/java/com/meteroid/models/CapacityPricing.java index 354f75c..c715e42 100644 --- a/src/main/java/com/meteroid/models/CapacityPricing.java +++ b/src/main/java/com/meteroid/models/CapacityPricing.java @@ -34,6 +34,9 @@ public final class CapacityPricing { @JsonProperty("rate") private BigDecimal rate; + @JsonProperty("type") + private String type = "CAPACITY"; + private final Map additionalProperties = new LinkedHashMap<>(); private CapacityPricing() {} @@ -42,6 +45,7 @@ private CapacityPricing(Builder builder) { this.included = builder.included; this.overageRate = builder.overageRate; this.rate = builder.rate; + this.type = builder.type; this.additionalProperties.putAll(builder.additionalProperties); } @@ -64,6 +68,7 @@ public Builder toBuilder() { builder.included = included; builder.overageRate = overageRate; builder.rate = rate; + builder.type = type; builder.additionalProperties.putAll(additionalProperties); return builder; } @@ -95,6 +100,15 @@ public BigDecimal rate() { return Utils.required(rate, "rate"); } + /** + * The {@code type} property. + * + * @return the value, never null + */ + public String type() { + return Utils.required(type, "type"); + } + /** * Properties this version of the SDK does not know, kept as received and sent back. * @@ -126,12 +140,13 @@ public boolean equals(Object o) { return Objects.equals(included, that.included) && Objects.equals(overageRate, that.overageRate) && Objects.equals(rate, that.rate) + && Objects.equals(type, that.type) && Objects.equals(additionalProperties, that.additionalProperties); } @Override public int hashCode() { - return Objects.hash(included, overageRate, rate, additionalProperties); + return Objects.hash(included, overageRate, rate, type, additionalProperties); } @Override @@ -143,6 +158,8 @@ public String toString() { + overageRate + ", rate=" + rate + + ", type=" + + type + ", additionalProperties=" + additionalProperties + "}"; @@ -153,6 +170,7 @@ public static final class Builder { private Long included; private BigDecimal overageRate; private BigDecimal rate; + private String type = "CAPACITY"; private final Map additionalProperties = new LinkedHashMap<>(); private Builder() {} @@ -190,6 +208,17 @@ public Builder rate(BigDecimal rate) { return this; } + /** + * The {@code type} property. + * + * @param type the value + * @return this builder + */ + public Builder type(String type) { + this.type = type; + return this; + } + /** * A property the SDK does not know, sent along. * @@ -234,6 +263,7 @@ public CapacityPricing build() { Utils.checkRequired(included, "included"); Utils.checkRequired(overageRate, "overage_rate"); Utils.checkRequired(rate, "rate"); + Utils.checkRequired(type, "type"); return new CapacityPricing(this); } } diff --git a/src/main/java/com/meteroid/models/ComponentsScope.java b/src/main/java/com/meteroid/models/ComponentsScope.java index 55474ff..a59b6e4 100644 --- a/src/main/java/com/meteroid/models/ComponentsScope.java +++ b/src/main/java/com/meteroid/models/ComponentsScope.java @@ -33,12 +33,16 @@ public final class ComponentsScope { @JsonProperty("component_names") private List componentNames; + @JsonProperty("type") + private String type = "components"; + private final Map additionalProperties = new LinkedHashMap<>(); private ComponentsScope() {} private ComponentsScope(Builder builder) { this.componentNames = Utils.copyList(builder.componentNames); + this.type = builder.type; this.additionalProperties.putAll(builder.additionalProperties); } @@ -59,6 +63,7 @@ public static Builder builder() { public Builder toBuilder() { Builder builder = new Builder(); builder.componentNames = Utils.mutableList(componentNames); + builder.type = type; builder.additionalProperties.putAll(additionalProperties); return builder; } @@ -72,6 +77,15 @@ public List componentNames() { return Utils.required(componentNames, "component_names"); } + /** + * The {@code type} property. + * + * @return the value, never null + */ + public String type() { + return Utils.required(type, "type"); + } + /** * Properties this version of the SDK does not know, kept as received and sent back. * @@ -101,12 +115,13 @@ public boolean equals(Object o) { } ComponentsScope that = (ComponentsScope) o; return Objects.equals(componentNames, that.componentNames) + && Objects.equals(type, that.type) && Objects.equals(additionalProperties, that.additionalProperties); } @Override public int hashCode() { - return Objects.hash(componentNames, additionalProperties); + return Objects.hash(componentNames, type, additionalProperties); } @Override @@ -114,6 +129,8 @@ public String toString() { return "ComponentsScope{" + "componentNames=" + componentNames + + ", type=" + + type + ", additionalProperties=" + additionalProperties + "}"; @@ -122,6 +139,7 @@ public String toString() { /** Builds {@link ComponentsScope}. */ public static final class Builder { private List componentNames; + private String type = "components"; private final Map additionalProperties = new LinkedHashMap<>(); private Builder() {} @@ -151,6 +169,17 @@ public Builder addComponentNamesItem(String item) { return this; } + /** + * The {@code type} property. + * + * @param type the value + * @return this builder + */ + public Builder type(String type) { + this.type = type; + return this; + } + /** * A property the SDK does not know, sent along. * @@ -193,6 +222,7 @@ public Builder removeAdditionalProperty(String name) { */ public ComponentsScope build() { Utils.checkRequired(componentNames, "component_names"); + Utils.checkRequired(type, "type"); return new ComponentsScope(this); } } diff --git a/src/main/java/com/meteroid/models/ConfigEffectiveEntitlementValue.java b/src/main/java/com/meteroid/models/ConfigEffectiveEntitlementValue.java index a593387..2423583 100644 --- a/src/main/java/com/meteroid/models/ConfigEffectiveEntitlementValue.java +++ b/src/main/java/com/meteroid/models/ConfigEffectiveEntitlementValue.java @@ -24,6 +24,9 @@ isGetterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE) public final class ConfigEffectiveEntitlementValue { + @JsonProperty("type") + private String type = "CONFIG"; + @JsonProperty("value") private ConfigValue value; @@ -32,6 +35,7 @@ public final class ConfigEffectiveEntitlementValue { private ConfigEffectiveEntitlementValue() {} private ConfigEffectiveEntitlementValue(Builder builder) { + this.type = builder.type; this.value = builder.value; this.additionalProperties.putAll(builder.additionalProperties); } @@ -52,11 +56,21 @@ public static Builder builder() { */ public Builder toBuilder() { Builder builder = new Builder(); + builder.type = type; builder.value = value; builder.additionalProperties.putAll(additionalProperties); return builder; } + /** + * The {@code type} property. + * + * @return the value, never null + */ + public String type() { + return Utils.required(type, "type"); + } + /** * The {@code value} property. * @@ -94,19 +108,22 @@ public boolean equals(Object o) { return false; } ConfigEffectiveEntitlementValue that = (ConfigEffectiveEntitlementValue) o; - return Objects.equals(value, that.value) + return Objects.equals(type, that.type) + && Objects.equals(value, that.value) && Objects.equals(additionalProperties, that.additionalProperties); } @Override public int hashCode() { - return Objects.hash(value, additionalProperties); + return Objects.hash(type, value, additionalProperties); } @Override public String toString() { return "ConfigEffectiveEntitlementValue{" - + "value=" + + "type=" + + type + + ", value=" + value + ", additionalProperties=" + additionalProperties @@ -115,11 +132,23 @@ public String toString() { /** Builds {@link ConfigEffectiveEntitlementValue}. */ public static final class Builder { + private String type = "CONFIG"; private ConfigValue value; private final Map additionalProperties = new LinkedHashMap<>(); private Builder() {} + /** + * The {@code type} property. + * + * @param type the value + * @return this builder + */ + public Builder type(String type) { + this.type = type; + return this; + } + /** * The {@code value} property. * @@ -172,6 +201,7 @@ public Builder removeAdditionalProperty(String name) { * @throws IllegalStateException when a required property is not set */ public ConfigEffectiveEntitlementValue build() { + Utils.checkRequired(type, "type"); Utils.checkRequired(value, "value"); return new ConfigEffectiveEntitlementValue(this); } diff --git a/src/main/java/com/meteroid/models/ConfigEntitlementValue.java b/src/main/java/com/meteroid/models/ConfigEntitlementValue.java index 06e5f02..a2d4c01 100644 --- a/src/main/java/com/meteroid/models/ConfigEntitlementValue.java +++ b/src/main/java/com/meteroid/models/ConfigEntitlementValue.java @@ -24,6 +24,9 @@ isGetterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE) public final class ConfigEntitlementValue { + @JsonProperty("type") + private String type = "CONFIG"; + @JsonProperty("value") private ConfigValue value; @@ -32,6 +35,7 @@ public final class ConfigEntitlementValue { private ConfigEntitlementValue() {} private ConfigEntitlementValue(Builder builder) { + this.type = builder.type; this.value = builder.value; this.additionalProperties.putAll(builder.additionalProperties); } @@ -52,11 +56,21 @@ public static Builder builder() { */ public Builder toBuilder() { Builder builder = new Builder(); + builder.type = type; builder.value = value; builder.additionalProperties.putAll(additionalProperties); return builder; } + /** + * The {@code type} property. + * + * @return the value, never null + */ + public String type() { + return Utils.required(type, "type"); + } + /** * The {@code value} property. * @@ -94,19 +108,22 @@ public boolean equals(Object o) { return false; } ConfigEntitlementValue that = (ConfigEntitlementValue) o; - return Objects.equals(value, that.value) + return Objects.equals(type, that.type) + && Objects.equals(value, that.value) && Objects.equals(additionalProperties, that.additionalProperties); } @Override public int hashCode() { - return Objects.hash(value, additionalProperties); + return Objects.hash(type, value, additionalProperties); } @Override public String toString() { return "ConfigEntitlementValue{" - + "value=" + + "type=" + + type + + ", value=" + value + ", additionalProperties=" + additionalProperties @@ -115,11 +132,23 @@ public String toString() { /** Builds {@link ConfigEntitlementValue}. */ public static final class Builder { + private String type = "CONFIG"; private ConfigValue value; private final Map additionalProperties = new LinkedHashMap<>(); private Builder() {} + /** + * The {@code type} property. + * + * @param type the value + * @return this builder + */ + public Builder type(String type) { + this.type = type; + return this; + } + /** * The {@code value} property. * @@ -172,6 +201,7 @@ public Builder removeAdditionalProperty(String name) { * @throws IllegalStateException when a required property is not set */ public ConfigEntitlementValue build() { + Utils.checkRequired(type, "type"); Utils.checkRequired(value, "value"); return new ConfigEntitlementValue(this); } diff --git a/src/main/java/com/meteroid/models/ConfigFeatureType.java b/src/main/java/com/meteroid/models/ConfigFeatureType.java index ef36047..b9adca5 100644 --- a/src/main/java/com/meteroid/models/ConfigFeatureType.java +++ b/src/main/java/com/meteroid/models/ConfigFeatureType.java @@ -34,6 +34,9 @@ public final class ConfigFeatureType { @JsonProperty("options") private List options; + @JsonProperty("type") + private String type = "CONFIG"; + @JsonProperty("value_type") private ConfigValueType valueType; @@ -43,6 +46,7 @@ private ConfigFeatureType() {} private ConfigFeatureType(Builder builder) { this.options = Utils.copyList(builder.options); + this.type = builder.type; this.valueType = builder.valueType; this.additionalProperties.putAll(builder.additionalProperties); } @@ -64,6 +68,7 @@ public static Builder builder() { public Builder toBuilder() { Builder builder = new Builder(); builder.options = Utils.mutableList(options); + builder.type = type; builder.valueType = valueType; builder.additionalProperties.putAll(additionalProperties); return builder; @@ -78,6 +83,15 @@ public Optional> options() { return Optional.ofNullable(options); } + /** + * The {@code type} property. + * + * @return the value, never null + */ + public String type() { + return Utils.required(type, "type"); + } + /** * The feature's value type, fixed at creation. * @@ -116,13 +130,14 @@ public boolean equals(Object o) { } ConfigFeatureType that = (ConfigFeatureType) o; return Objects.equals(options, that.options) + && Objects.equals(type, that.type) && Objects.equals(valueType, that.valueType) && Objects.equals(additionalProperties, that.additionalProperties); } @Override public int hashCode() { - return Objects.hash(options, valueType, additionalProperties); + return Objects.hash(options, type, valueType, additionalProperties); } @Override @@ -130,6 +145,8 @@ public String toString() { return "ConfigFeatureType{" + "options=" + options + + ", type=" + + type + ", valueType=" + valueType + ", additionalProperties=" @@ -140,6 +157,7 @@ public String toString() { /** Builds {@link ConfigFeatureType}. */ public static final class Builder { private List options; + private String type = "CONFIG"; private ConfigValueType valueType; private final Map additionalProperties = new LinkedHashMap<>(); @@ -170,6 +188,17 @@ public Builder addOptionsItem(String item) { return this; } + /** + * The {@code type} property. + * + * @param type the value + * @return this builder + */ + public Builder type(String type) { + this.type = type; + return this; + } + /** * The feature's value type, fixed at creation. * @@ -222,6 +251,7 @@ public Builder removeAdditionalProperty(String name) { * @throws IllegalStateException when a required property is not set */ public ConfigFeatureType build() { + Utils.checkRequired(type, "type"); Utils.checkRequired(valueType, "value_type"); return new ConfigFeatureType(this); } diff --git a/src/main/java/com/meteroid/models/ConfigResolvedEntitlementValue.java b/src/main/java/com/meteroid/models/ConfigResolvedEntitlementValue.java index 1197f2e..3537c77 100644 --- a/src/main/java/com/meteroid/models/ConfigResolvedEntitlementValue.java +++ b/src/main/java/com/meteroid/models/ConfigResolvedEntitlementValue.java @@ -24,6 +24,9 @@ isGetterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE) public final class ConfigResolvedEntitlementValue { + @JsonProperty("type") + private String type = "CONFIG"; + @JsonProperty("value") private ConfigValue value; @@ -32,6 +35,7 @@ public final class ConfigResolvedEntitlementValue { private ConfigResolvedEntitlementValue() {} private ConfigResolvedEntitlementValue(Builder builder) { + this.type = builder.type; this.value = builder.value; this.additionalProperties.putAll(builder.additionalProperties); } @@ -52,11 +56,21 @@ public static Builder builder() { */ public Builder toBuilder() { Builder builder = new Builder(); + builder.type = type; builder.value = value; builder.additionalProperties.putAll(additionalProperties); return builder; } + /** + * The {@code type} property. + * + * @return the value, never null + */ + public String type() { + return Utils.required(type, "type"); + } + /** * The {@code value} property. * @@ -94,19 +108,22 @@ public boolean equals(Object o) { return false; } ConfigResolvedEntitlementValue that = (ConfigResolvedEntitlementValue) o; - return Objects.equals(value, that.value) + return Objects.equals(type, that.type) + && Objects.equals(value, that.value) && Objects.equals(additionalProperties, that.additionalProperties); } @Override public int hashCode() { - return Objects.hash(value, additionalProperties); + return Objects.hash(type, value, additionalProperties); } @Override public String toString() { return "ConfigResolvedEntitlementValue{" - + "value=" + + "type=" + + type + + ", value=" + value + ", additionalProperties=" + additionalProperties @@ -115,11 +132,23 @@ public String toString() { /** Builds {@link ConfigResolvedEntitlementValue}. */ public static final class Builder { + private String type = "CONFIG"; private ConfigValue value; private final Map additionalProperties = new LinkedHashMap<>(); private Builder() {} + /** + * The {@code type} property. + * + * @param type the value + * @return this builder + */ + public Builder type(String type) { + this.type = type; + return this; + } + /** * The {@code value} property. * @@ -172,6 +201,7 @@ public Builder removeAdditionalProperty(String name) { * @throws IllegalStateException when a required property is not set */ public ConfigResolvedEntitlementValue build() { + Utils.checkRequired(type, "type"); Utils.checkRequired(value, "value"); return new ConfigResolvedEntitlementValue(this); } diff --git a/src/main/java/com/meteroid/models/Coupon.java b/src/main/java/com/meteroid/models/Coupon.java index 7fe3d8a..856e230 100644 --- a/src/main/java/com/meteroid/models/Coupon.java +++ b/src/main/java/com/meteroid/models/Coupon.java @@ -137,7 +137,10 @@ public Optional archivedAt() { } /** - * The {@code code} property. + * A promotional-credit (CREDIT) code is stored upper-case; other codes as written. + * A code is redeemed by the coupon with exactly that code, else by the only live coupon equal + * to it ignoring the case of ASCII letters; several such coupons and no exact match make it + * ambiguous. * * @return the value, never null */ @@ -372,7 +375,10 @@ public Builder archivedAt(OffsetDateTime archivedAt) { } /** - * The {@code code} property. + * A promotional-credit (CREDIT) code is stored upper-case; other codes as + * written. A code is redeemed by the coupon with exactly that code, else by the only live + * coupon equal to it ignoring the case of ASCII letters; several such coupons and no exact + * match make it ambiguous. * * @param code the value * @return this builder diff --git a/src/main/java/com/meteroid/models/CouponCreditScope.java b/src/main/java/com/meteroid/models/CouponCreditScope.java new file mode 100644 index 0000000..3a36500 --- /dev/null +++ b/src/main/java/com/meteroid/models/CouponCreditScope.java @@ -0,0 +1,131 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import com.meteroid.internal.Utils.ToQueryParam; + +import java.util.Map; +import java.util.Objects; + +/** + * Which subscriptions a promotional credit coupon's credit pays. + * + *

Values this version of the SDK does not know are kept, and sent back unchanged: {@link + * #value()} is an enum to switch on, {@code _UNKNOWN} for them, and {@link #known()} throws on + * them. + */ +public final class CouponCreditScope implements ToQueryParam { + /** The value {@code "CUSTOMER"}. */ + public static final CouponCreditScope CUSTOMER = + new CouponCreditScope("CUSTOMER", Value.CUSTOMER); + + /** The value {@code "SUBSCRIPTION"}. */ + public static final CouponCreditScope SUBSCRIPTION = + new CouponCreditScope("SUBSCRIPTION", Value.SUBSCRIPTION); + + private static final Map constants = + Map.ofEntries(Map.entry("CUSTOMER", CUSTOMER), Map.entry("SUBSCRIPTION", SUBSCRIPTION)); + + private final String value; + private final Value variant; + + private CouponCreditScope(String value, Value variant) { + this.value = value; + this.variant = variant; + } + + /** + * The constant for {@code value}, or an unknown CouponCreditScope holding it. + * + * @param value the value + * @return the constant + */ + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static CouponCreditScope of(String value) { + CouponCreditScope constant = constants.get(Objects.requireNonNull(value, "value")); + return constant != null ? constant : new CouponCreditScope(value, Value._UNKNOWN); + } + + /** + * The value as sent. + * + * @return the value + */ + @JsonValue + public String asString() { + return value; + } + + /** + * Whether this version of the SDK knows the value. + * + * @return whether it is known + */ + public boolean isKnown() { + return variant != Value._UNKNOWN; + } + + /** + * The value as an enum to switch on, unknown values included. + * + * @return the enum, {@code _UNKNOWN} when unknown + */ + public Value value() { + return variant; + } + + /** + * The value as an enum of the known values only. + * + * @return the enum + * @throws com.meteroid.exceptions.InvalidDataException when this version of the SDK does not + * know the value + */ + public Known known() { + if (!isKnown()) { + throw new com.meteroid.exceptions.InvalidDataException( + "unknown CouponCreditScope: " + value); + } + return Known.valueOf(variant.name()); + } + + @Override + public String toQueryParam() { + return String.valueOf(value); + } + + @Override + public boolean equals(Object o) { + return o instanceof CouponCreditScope + && Objects.equals(value, ((CouponCreditScope) o).value); + } + + @Override + public int hashCode() { + return Objects.hashCode(value); + } + + @Override + public String toString() { + return String.valueOf(value); + } + + /** The values this version of the SDK knows. */ + public enum Known { + /** The {@code CUSTOMER} constant. */ + CUSTOMER, + /** The {@code SUBSCRIPTION} constant. */ + SUBSCRIPTION + } + + /** The values this version of the SDK knows, and {@code _UNKNOWN} for the others. */ + public enum Value { + /** The {@code CUSTOMER} constant. */ + CUSTOMER, + /** The {@code SUBSCRIPTION} constant. */ + SUBSCRIPTION, + /** A value this version of the SDK does not know. */ + _UNKNOWN + } +} diff --git a/src/main/java/com/meteroid/models/CouponDiscount.java b/src/main/java/com/meteroid/models/CouponDiscount.java index 1de8ec9..d4a2dc7 100644 --- a/src/main/java/com/meteroid/models/CouponDiscount.java +++ b/src/main/java/com/meteroid/models/CouponDiscount.java @@ -32,7 +32,8 @@ defaultImpl = CouponDiscount.Unrecognized.class) @JsonSubTypes({ @JsonSubTypes.Type(value = CouponDiscount.Percentage.class, name = "PERCENTAGE"), - @JsonSubTypes.Type(value = CouponDiscount.Fixed.class, name = "FIXED") + @JsonSubTypes.Type(value = CouponDiscount.Fixed.class, name = "FIXED"), + @JsonSubTypes.Type(value = CouponDiscount.Credit.class, name = "CREDIT") }) @JsonInclude(JsonInclude.Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) @@ -96,6 +97,28 @@ public final Fixed asFixed() { throw new IllegalStateException("not the FIXED variant: " + type()); } + /** + * Whether this is the {@code CREDIT} variant. + * + * @return whether it is + */ + public final boolean isCredit() { + return this instanceof Credit; + } + + /** + * This value as the {@code CREDIT} variant. + * + * @return the variant + * @throws IllegalStateException if this is another variant + */ + public final Credit asCredit() { + if (this instanceof Credit) { + return (Credit) this; + } + throw new IllegalStateException("not the CREDIT variant: " + type()); + } + /** * Whether this is a variant this version of the SDK does not know. * @@ -149,6 +172,14 @@ public interface Visitor { */ R visitFixed(FixedDiscount value); + /** + * Visits the {@code CREDIT} variant. + * + * @param value the variant + * @return the result + */ + R visitCredit(CreditDiscount value); + /** * Visits a variant this version of the SDK does not know. * @@ -324,6 +355,77 @@ public R accept(Visitor visitor) { } } + /** The {@code CREDIT} variant. */ + @JsonTypeName("CREDIT") + public static final class Credit extends CouponDiscount { + @JsonUnwrapped + @JsonIgnoreProperties(value = "type", allowSetters = true) + private CreditDiscount data; + + private Credit() {} + + /** + * The variant holding {@code data}. + * + * @param data the value of the variant + */ + public Credit(CreditDiscount data) { + this.data = Objects.requireNonNull(data, "data"); + } + + /** + * The variant holding {@code data}. + * + * @param data the value of the variant + * @return the variant + */ + public static Credit of(CreditDiscount data) { + return new Credit(data); + } + + @Override + @JsonProperty("type") + public String type() { + return "CREDIT"; + } + + /** + * The value of the variant. + * + * @return the value + */ + public CreditDiscount data() { + return data; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Credit that = (Credit) o; + return Objects.equals(data, that.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + return "Credit{" + "data=" + data + "}"; + } + + @Override + public R accept(Visitor visitor) { + return visitor.visitCredit(data); + } + } + /** A variant this version of the SDK does not know. */ public static final class Unrecognized extends CouponDiscount { @JsonProperty("type") diff --git a/src/main/java/com/meteroid/models/CreateBudgetRequest.java b/src/main/java/com/meteroid/models/CreateBudgetRequest.java new file mode 100644 index 0000000..f853dbf --- /dev/null +++ b/src/main/java/com/meteroid/models/CreateBudgetRequest.java @@ -0,0 +1,380 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.JsonField; +import com.meteroid.internal.Utils; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +/** Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonAutoDetect( + getterVisibility = Visibility.NONE, + isGetterVisibility = Visibility.NONE, + setterVisibility = Visibility.NONE) +public final class CreateBudgetRequest { + @JsonProperty("amount") + private Long amount; + + @JsonProperty("behavior") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField behavior = JsonField.missing(); + + @JsonProperty("credit_unit") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField creditUnit = JsonField.missing(); + + @JsonProperty("currency") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField currency = JsonField.missing(); + + @JsonProperty("subscription_id") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField subscriptionId = JsonField.missing(); + + @JsonProperty("thresholds") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField> thresholds = JsonField.missing(); + + private final Map additionalProperties = new LinkedHashMap<>(); + + private CreateBudgetRequest() {} + + private CreateBudgetRequest(Builder builder) { + this.amount = builder.amount; + this.behavior = builder.behavior; + this.creditUnit = builder.creditUnit; + this.currency = builder.currency; + this.subscriptionId = builder.subscriptionId; + this.thresholds = builder.thresholds.map(Utils::copyList); + this.additionalProperties.putAll(builder.additionalProperties); + } + + /** + * A builder of {@code CreateBudgetRequest}. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * A builder starting from this value. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.amount = amount; + builder.behavior = behavior; + builder.creditUnit = creditUnit; + builder.currency = currency; + builder.subscriptionId = subscriptionId; + builder.thresholds = thresholds.map(Utils::mutableList); + builder.additionalProperties.putAll(additionalProperties); + return builder; + } + + /** + * In minor units of the currency or credit unit. + * + * @return the value, never null + */ + public Long amount() { + return Utils.required(amount, "amount"); + } + + /** + * The {@code behavior} property. + * + * @return the value, empty when unset or null + */ + public Optional behavior() { + return behavior.asOptional(); + } + + /** + * A credit unit (its code): the budget counts the usage priced in that unit, in its minor + * units. + * + * @return the value, empty when unset or null + */ + public Optional creditUnit() { + return creditUnit.asOptional(); + } + + /** + * The {@code currency} property. + * + * @return the value, empty when unset or null + */ + public Optional currency() { + return currency.asOptional(); + } + + /** + * An active subscription of the customer (sub_…): the budget then counts only that + * subscription's spend, in its currency. Absent counts the whole customer's. + * + * @return the value, empty when unset or null + */ + public Optional subscriptionId() { + return subscriptionId.asOptional(); + } + + /** + * Percentages of the amount (1 to 100, at most 10). Defaults to 50, 80 and 100. + * + * @return the value, empty when unset or null + */ + public Optional> thresholds() { + return thresholds.asOptional(); + } + + /** + * Properties this version of the SDK does not know, kept as received and sent back. + * + * @return the properties by name, unmodifiable + */ + public Map additionalProperties() { + return Collections.unmodifiableMap(additionalProperties); + } + + @JsonAnyGetter + private Map anyProperties() { + return additionalProperties; + } + + @JsonAnySetter + private void putAnyProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CreateBudgetRequest that = (CreateBudgetRequest) o; + return Objects.equals(amount, that.amount) + && Objects.equals(behavior, that.behavior) + && Objects.equals(creditUnit, that.creditUnit) + && Objects.equals(currency, that.currency) + && Objects.equals(subscriptionId, that.subscriptionId) + && Objects.equals(thresholds, that.thresholds) + && Objects.equals(additionalProperties, that.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash( + amount, + behavior, + creditUnit, + currency, + subscriptionId, + thresholds, + additionalProperties); + } + + @Override + public String toString() { + return "CreateBudgetRequest{" + + "amount=" + + amount + + ", behavior=" + + behavior + + ", creditUnit=" + + creditUnit + + ", currency=" + + currency + + ", subscriptionId=" + + subscriptionId + + ", thresholds=" + + thresholds + + ", additionalProperties=" + + additionalProperties + + "}"; + } + + /** Builds {@link CreateBudgetRequest}. */ + public static final class Builder { + private Long amount; + private JsonField behavior = JsonField.missing(); + private JsonField creditUnit = JsonField.missing(); + private JsonField currency = JsonField.missing(); + private JsonField subscriptionId = JsonField.missing(); + private JsonField> thresholds = JsonField.missing(); + private final Map additionalProperties = new LinkedHashMap<>(); + + private Builder() {} + + /** + * In minor units of the currency or credit unit. + * + * @param amount the value + * @return this builder + */ + public Builder amount(Long amount) { + this.amount = amount; + return this; + } + + /** + * The {@code behavior} property. + * + * @param behavior the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder behavior(BudgetBehavior behavior) { + this.behavior = JsonField.ofNullable(behavior); + return this; + } + + /** + * A credit unit (its code): the budget counts the usage priced in that unit, in its minor + * units. + * + * @param creditUnit the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder creditUnit(String creditUnit) { + this.creditUnit = JsonField.ofNullable(creditUnit); + return this; + } + + /** + * The {@code currency} property. + * + * @param currency the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder currency(Currency currency) { + this.currency = JsonField.ofNullable(currency); + return this; + } + + /** + * An active subscription of the customer (sub_…): the budget then counts only + * that subscription's spend, in its currency. Absent counts the whole customer's. + * + * @param subscriptionId the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder subscriptionId(String subscriptionId) { + this.subscriptionId = JsonField.ofNullable(subscriptionId); + return this; + } + + /** + * Percentages of the amount (1 to 100, at most 10). Defaults to 50, 80 and 100. + * + * @param thresholds the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder thresholds(List thresholds) { + this.thresholds = JsonField.ofNullable(Utils.mutableList(thresholds)); + return this; + } + + /** + * Adds an item to {@code thresholds}. + * + * @param item the item + * @return this builder + */ + public Builder addThresholdsItem(Integer item) { + List items = this.thresholds.orNull(); + if (items == null) { + items = new ArrayList<>(); + this.thresholds = JsonField.ofNullable(items); + } + items.add(item); + return this; + } + + /** + * A property the SDK does not know, sent along. + * + * @param name the property name + * @param value the JSON value + * @return this builder + */ + public Builder putAdditionalProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + return this; + } + + /** + * Properties the SDK does not know, sent along. + * + * @param additionalProperties the properties by name + * @return this builder + */ + public Builder putAllAdditionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + + /** + * Leaves out a property the SDK does not know. + * + * @param name the property name + * @return this builder + */ + public Builder removeAdditionalProperty(String name) { + additionalProperties.remove(name); + return this; + } + + /** + * The {@code CreateBudgetRequest}. + * + * @return the immutable value + * @throws IllegalStateException when a required property is not set + */ + public CreateBudgetRequest build() { + Utils.checkRequired(amount, "amount"); + return new CreateBudgetRequest(this); + } + } + + /** + * Parse {@code json} as {@code CreateBudgetRequest}. + * + * @param json the JSON text + * @return the value + * @throws com.meteroid.exceptions.InvalidDataException if it is not valid JSON of this shape + */ + public static CreateBudgetRequest fromJson(String json) { + return Utils.parse(json, CreateBudgetRequest.class); + } + + /** + * This value as JSON. + * + * @return the JSON text + */ + public String toJson() { + return Utils.json(this); + } +} diff --git a/src/main/java/com/meteroid/models/CreateCheckoutSessionRequest.java b/src/main/java/com/meteroid/models/CreateCheckoutSessionRequest.java index e715e0a..aa7f0df 100644 --- a/src/main/java/com/meteroid/models/CreateCheckoutSessionRequest.java +++ b/src/main/java/com/meteroid/models/CreateCheckoutSessionRequest.java @@ -245,7 +245,10 @@ public Optional components() { } /** - * The {@code coupon_code} property. + * Code of the coupon to apply, used only when coupon_ids is empty. It names the + * coupon with exactly that code, else the only live coupon equal to it ignoring the case of + * ASCII letters. An unknown or ambiguous code is refused with 400. If the code no longer names + * a usable coupon when the customer pays, the payment is refused and nothing is charged. * * @return the value, empty when unset or null */ @@ -624,7 +627,11 @@ public Builder components(CreateSubscriptionComponents components) { } /** - * The {@code coupon_code} property. + * Code of the coupon to apply, used only when coupon_ids is empty. It names + * the coupon with exactly that code, else the only live coupon equal to it ignoring the + * case of ASCII letters. An unknown or ambiguous code is refused with 400. If the code no + * longer names a usable coupon when the customer pays, the payment is refused and nothing + * is charged. * * @param couponCode the value, null to send an explicit {@code null} * @return this builder diff --git a/src/main/java/com/meteroid/models/CreateConnectedAccountRequest.java b/src/main/java/com/meteroid/models/CreateConnectedAccountRequest.java index d833b88..c9935b4 100644 --- a/src/main/java/com/meteroid/models/CreateConnectedAccountRequest.java +++ b/src/main/java/com/meteroid/models/CreateConnectedAccountRequest.java @@ -17,7 +17,6 @@ import java.util.Map; import java.util.Objects; import java.util.Optional; -import java.util.UUID; /** Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. */ @JsonInclude(JsonInclude.Include.NON_NULL) @@ -27,29 +26,38 @@ isGetterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE) public final class CreateConnectedAccountRequest { - @JsonProperty("connected_organization_id") - private UUID connectedOrganizationId; - - @JsonProperty("connection_type") + @JsonProperty("country") @JsonInclude(JsonInclude.Include.NON_EMPTY) - private JsonField connectionType = JsonField.missing(); + private JsonField country = JsonField.missing(); + + @JsonProperty("email") + private String email; @JsonProperty("metadata") private Object metadata; - @JsonProperty("platform_customer_id") + @JsonProperty("mode") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField mode = JsonField.missing(); + + @JsonProperty("organization_name") + private String organizationName; + + @JsonProperty("redirect_url") @JsonInclude(JsonInclude.Include.NON_EMPTY) - private JsonField platformCustomerId = JsonField.missing(); + private JsonField redirectUrl = JsonField.missing(); private final Map additionalProperties = new LinkedHashMap<>(); private CreateConnectedAccountRequest() {} private CreateConnectedAccountRequest(Builder builder) { - this.connectedOrganizationId = builder.connectedOrganizationId; - this.connectionType = builder.connectionType; + this.country = builder.country; + this.email = builder.email; this.metadata = builder.metadata; - this.platformCustomerId = builder.platformCustomerId; + this.mode = builder.mode; + this.organizationName = builder.organizationName; + this.redirectUrl = builder.redirectUrl; this.additionalProperties.putAll(builder.additionalProperties); } @@ -69,30 +77,32 @@ public static Builder builder() { */ public Builder toBuilder() { Builder builder = new Builder(); - builder.connectedOrganizationId = connectedOrganizationId; - builder.connectionType = connectionType; + builder.country = country; + builder.email = email; builder.metadata = metadata; - builder.platformCustomerId = platformCustomerId; + builder.mode = mode; + builder.organizationName = organizationName; + builder.redirectUrl = redirectUrl; builder.additionalProperties.putAll(additionalProperties); return builder; } /** - * The {@code connected_organization_id} property. + * The {@code country} property. * - * @return the value, never null + * @return the value, empty when unset or null */ - public UUID connectedOrganizationId() { - return Utils.required(connectedOrganizationId, "connected_organization_id"); + public Optional country() { + return country.asOptional(); } /** - * The {@code connection_type} property. + * The {@code email} property. * - * @return the value, empty when unset or null + * @return the value, never null */ - public Optional connectionType() { - return connectionType.asOptional(); + public String email() { + return Utils.required(email, "email"); } /** @@ -105,12 +115,30 @@ public Optional metadata() { } /** - * The {@code platform_customer_id} property. + * The {@code mode} property. * * @return the value, empty when unset or null */ - public Optional platformCustomerId() { - return platformCustomerId.asOptional(); + public Optional mode() { + return mode.asOptional(); + } + + /** + * The {@code organization_name} property. + * + * @return the value, never null + */ + public String organizationName() { + return Utils.required(organizationName, "organization_name"); + } + + /** + * The {@code redirect_url} property. + * + * @return the value, empty when unset or null + */ + public Optional redirectUrl() { + return redirectUrl.asOptional(); } /** @@ -141,34 +169,42 @@ public boolean equals(Object o) { return false; } CreateConnectedAccountRequest that = (CreateConnectedAccountRequest) o; - return Objects.equals(connectedOrganizationId, that.connectedOrganizationId) - && Objects.equals(connectionType, that.connectionType) + return Objects.equals(country, that.country) + && Objects.equals(email, that.email) && Objects.equals(metadata, that.metadata) - && Objects.equals(platformCustomerId, that.platformCustomerId) + && Objects.equals(mode, that.mode) + && Objects.equals(organizationName, that.organizationName) + && Objects.equals(redirectUrl, that.redirectUrl) && Objects.equals(additionalProperties, that.additionalProperties); } @Override public int hashCode() { return Objects.hash( - connectedOrganizationId, - connectionType, + country, + email, metadata, - platformCustomerId, + mode, + organizationName, + redirectUrl, additionalProperties); } @Override public String toString() { return "CreateConnectedAccountRequest{" - + "connectedOrganizationId=" - + connectedOrganizationId - + ", connectionType=" - + connectionType + + "country=" + + country + + ", email=" + + email + ", metadata=" + metadata - + ", platformCustomerId=" - + platformCustomerId + + ", mode=" + + mode + + ", organizationName=" + + organizationName + + ", redirectUrl=" + + redirectUrl + ", additionalProperties=" + additionalProperties + "}"; @@ -176,33 +212,35 @@ public String toString() { /** Builds {@link CreateConnectedAccountRequest}. */ public static final class Builder { - private UUID connectedOrganizationId; - private JsonField connectionType = JsonField.missing(); + private JsonField country = JsonField.missing(); + private String email; private Object metadata; - private JsonField platformCustomerId = JsonField.missing(); + private JsonField mode = JsonField.missing(); + private String organizationName; + private JsonField redirectUrl = JsonField.missing(); private final Map additionalProperties = new LinkedHashMap<>(); private Builder() {} /** - * The {@code connected_organization_id} property. + * The {@code country} property. * - * @param connectedOrganizationId the value + * @param country the value, null to send an explicit {@code null} * @return this builder */ - public Builder connectedOrganizationId(UUID connectedOrganizationId) { - this.connectedOrganizationId = connectedOrganizationId; + public Builder country(String country) { + this.country = JsonField.ofNullable(country); return this; } /** - * The {@code connection_type} property. + * The {@code email} property. * - * @param connectionType the value, null to send an explicit {@code null} + * @param email the value * @return this builder */ - public Builder connectionType(ConnectionType connectionType) { - this.connectionType = JsonField.ofNullable(connectionType); + public Builder email(String email) { + this.email = email; return this; } @@ -218,13 +256,35 @@ public Builder metadata(Object metadata) { } /** - * The {@code platform_customer_id} property. + * The {@code mode} property. + * + * @param mode the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder mode(OnboardingMode mode) { + this.mode = JsonField.ofNullable(mode); + return this; + } + + /** + * The {@code organization_name} property. + * + * @param organizationName the value + * @return this builder + */ + public Builder organizationName(String organizationName) { + this.organizationName = organizationName; + return this; + } + + /** + * The {@code redirect_url} property. * - * @param platformCustomerId the value, null to send an explicit {@code null} + * @param redirectUrl the value, null to send an explicit {@code null} * @return this builder */ - public Builder platformCustomerId(String platformCustomerId) { - this.platformCustomerId = JsonField.ofNullable(platformCustomerId); + public Builder redirectUrl(String redirectUrl) { + this.redirectUrl = JsonField.ofNullable(redirectUrl); return this; } @@ -269,7 +329,8 @@ public Builder removeAdditionalProperty(String name) { * @throws IllegalStateException when a required property is not set */ public CreateConnectedAccountRequest build() { - Utils.checkRequired(connectedOrganizationId, "connected_organization_id"); + Utils.checkRequired(email, "email"); + Utils.checkRequired(organizationName, "organization_name"); return new CreateConnectedAccountRequest(this); } } diff --git a/src/main/java/com/meteroid/models/CreateConnectedAccountResponse.java b/src/main/java/com/meteroid/models/CreateConnectedAccountResponse.java new file mode 100644 index 0000000..cbba27c --- /dev/null +++ b/src/main/java/com/meteroid/models/CreateConnectedAccountResponse.java @@ -0,0 +1,226 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.Unions; +import com.meteroid.internal.Utils; + +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; + +/** + * The created account (same fields as ConnectedAccount) plus its onboarding link. + * + *

Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonAutoDetect( + getterVisibility = Visibility.NONE, + isGetterVisibility = Visibility.NONE, + setterVisibility = Visibility.NONE) +public final class CreateConnectedAccountResponse { + @JsonProperty("onboarding_link") + private OnboardingLinkResponse onboardingLink; + + private final Map additionalProperties = new LinkedHashMap<>(); + + private CreateConnectedAccountResponse() {} + + private CreateConnectedAccountResponse(Builder builder) { + this.onboardingLink = builder.onboardingLink; + this.additionalProperties.putAll(builder.additionalProperties); + } + + /** + * A builder of {@code CreateConnectedAccountResponse}. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * A builder starting from this value. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.onboardingLink = onboardingLink; + builder.additionalProperties.putAll(additionalProperties); + return builder; + } + + /** + * The properties of {@link ConnectedAccount}, which this schema extends. + * + * @return the properties of this part + */ + public ConnectedAccount connectedAccount() { + return Unions.convert(additionalProperties, ConnectedAccount.class); + } + + /** + * The {@code onboarding_link} property. + * + * @return the value, never null + */ + public OnboardingLinkResponse onboardingLink() { + return Utils.required(onboardingLink, "onboarding_link"); + } + + /** + * Properties this version of the SDK does not know, kept as received and sent back. + * + * @return the properties by name, unmodifiable + */ + public Map additionalProperties() { + Map unknown = new LinkedHashMap<>(additionalProperties); + unknown.keySet().retainAll(connectedAccount().additionalProperties().keySet()); + return Collections.unmodifiableMap(unknown); + } + + @JsonAnyGetter + private Map anyProperties() { + return additionalProperties; + } + + @JsonAnySetter + private void putAnyProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CreateConnectedAccountResponse that = (CreateConnectedAccountResponse) o; + return Objects.equals(onboardingLink, that.onboardingLink) + && Objects.equals(additionalProperties, that.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(onboardingLink, additionalProperties); + } + + @Override + public String toString() { + return "CreateConnectedAccountResponse{" + + "onboardingLink=" + + onboardingLink + + ", additionalProperties=" + + additionalProperties + + "}"; + } + + /** Builds {@link CreateConnectedAccountResponse}. */ + public static final class Builder { + private OnboardingLinkResponse onboardingLink; + private final Map additionalProperties = new LinkedHashMap<>(); + + private Builder() {} + + /** + * Sets the properties of {@link ConnectedAccount}, which this schema extends. + * + * @param connectedAccount the properties + * @return this builder + */ + public Builder connectedAccount(ConnectedAccount connectedAccount) { + additionalProperties.putAll(Utils.properties(connectedAccount)); + return this; + } + + /** + * The {@code onboarding_link} property. + * + * @param onboardingLink the value + * @return this builder + */ + public Builder onboardingLink(OnboardingLinkResponse onboardingLink) { + this.onboardingLink = onboardingLink; + return this; + } + + /** + * A property the SDK does not know, sent along. + * + * @param name the property name + * @param value the JSON value + * @return this builder + */ + public Builder putAdditionalProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + return this; + } + + /** + * Properties the SDK does not know, sent along. + * + * @param additionalProperties the properties by name + * @return this builder + */ + public Builder putAllAdditionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + + /** + * Leaves out a property the SDK does not know. + * + * @param name the property name + * @return this builder + */ + public Builder removeAdditionalProperty(String name) { + additionalProperties.remove(name); + return this; + } + + /** + * The {@code CreateConnectedAccountResponse}. + * + * @return the immutable value + * @throws IllegalStateException when a required property is not set + */ + public CreateConnectedAccountResponse build() { + Utils.checkRequired(onboardingLink, "onboarding_link"); + return new CreateConnectedAccountResponse(this); + } + } + + /** + * Parse {@code json} as {@code CreateConnectedAccountResponse}. + * + * @param json the JSON text + * @return the value + * @throws com.meteroid.exceptions.InvalidDataException if it is not valid JSON of this shape + */ + public static CreateConnectedAccountResponse fromJson(String json) { + return Utils.parse(json, CreateConnectedAccountResponse.class); + } + + /** + * This value as JSON. + * + * @return the JSON text + */ + public String toJson() { + return Utils.json(this); + } +} diff --git a/src/main/java/com/meteroid/models/CreateCouponRequest.java b/src/main/java/com/meteroid/models/CreateCouponRequest.java index 8150cb7..e27e271 100644 --- a/src/main/java/com/meteroid/models/CreateCouponRequest.java +++ b/src/main/java/com/meteroid/models/CreateCouponRequest.java @@ -102,7 +102,9 @@ public Builder toBuilder() { } /** - * The {@code code} property. + * 1 to 64 ASCII letters, digits, hyphens or underscores. A promotional-credit (CREDIT + * ) code is stored upper-case. Codes are matched as described on Coupon.code + * . * * @return the value, never null */ @@ -165,7 +167,8 @@ public Optional redemptionLimit() { } /** - * The {@code reusable} property. + * Whether one customer may redeem the coupon more than once. Must be false for a + * promotional-credit (CREDIT) coupon. * * @return the value, empty when unset */ @@ -265,7 +268,9 @@ public static final class Builder { private Builder() {} /** - * The {@code code} property. + * 1 to 64 ASCII letters, digits, hyphens or underscores. A promotional-credit (CREDIT + * ) code is stored upper-case. Codes are matched as described on Coupon.code + * . * * @param code the value * @return this builder @@ -356,7 +361,8 @@ public Builder redemptionLimit(Integer redemptionLimit) { } /** - * The {@code reusable} property. + * Whether one customer may redeem the coupon more than once. Must be false for a + * promotional-credit (CREDIT) coupon. * * @param reusable the value * @return this builder diff --git a/src/main/java/com/meteroid/models/CreateCreditGrantRequest.java b/src/main/java/com/meteroid/models/CreateCreditGrantRequest.java new file mode 100644 index 0000000..26fe808 --- /dev/null +++ b/src/main/java/com/meteroid/models/CreateCreditGrantRequest.java @@ -0,0 +1,599 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.JsonField; +import com.meteroid.internal.Utils; + +import java.time.OffsetDateTime; +import java.util.ArrayList; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +/** + * Credit granted without charging or invoicing. + * + *

Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonAutoDetect( + getterVisibility = Visibility.NONE, + isGetterVisibility = Visibility.NONE, + setterVisibility = Visibility.NONE) +public final class CreateCreditGrantRequest { + @JsonProperty("amount") + private Long amount; + + @JsonProperty("applicable_product_ids") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField> applicableProductIds = JsonField.missing(); + + @JsonProperty("applies_to") + private CreditAppliesTo appliesTo; + + @JsonProperty("cost") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField cost = JsonField.missing(); + + @JsonProperty("credit_unit") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField creditUnit = JsonField.missing(); + + @JsonProperty("currency") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField currency = JsonField.missing(); + + @JsonProperty("expires_at") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField expiresAt = JsonField.missing(); + + @JsonProperty("priority") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField priority = JsonField.missing(); + + @JsonProperty("reason") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField reason = JsonField.missing(); + + @JsonProperty("reference") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField reference = JsonField.missing(); + + @JsonProperty("subscription_id") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField subscriptionId = JsonField.missing(); + + @JsonProperty("type") + private CreditGrantType type; + + private final Map additionalProperties = new LinkedHashMap<>(); + + private CreateCreditGrantRequest() {} + + private CreateCreditGrantRequest(Builder builder) { + this.amount = builder.amount; + this.applicableProductIds = builder.applicableProductIds.map(Utils::copyList); + this.appliesTo = builder.appliesTo; + this.cost = builder.cost; + this.creditUnit = builder.creditUnit; + this.currency = builder.currency; + this.expiresAt = builder.expiresAt; + this.priority = builder.priority; + this.reason = builder.reason; + this.reference = builder.reference; + this.subscriptionId = builder.subscriptionId; + this.type = builder.type; + this.additionalProperties.putAll(builder.additionalProperties); + } + + /** + * A builder of {@code CreateCreditGrantRequest}. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * A builder starting from this value. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.amount = amount; + builder.applicableProductIds = applicableProductIds.map(Utils::mutableList); + builder.appliesTo = appliesTo; + builder.cost = cost; + builder.creditUnit = creditUnit; + builder.currency = currency; + builder.expiresAt = expiresAt; + builder.priority = priority; + builder.reason = reason; + builder.reference = reference; + builder.subscriptionId = subscriptionId; + builder.type = type; + builder.additionalProperties.putAll(additionalProperties); + return builder; + } + + /** + * Credit granted, in minor units of currency, or of credit_unit when + * set (e.g. 500000 is 5,000.00 credits of a unit with precision 2). Positive. + * + * @return the value, never null + */ + public Long amount() { + return Utils.required(amount, "amount"); + } + + /** + * Restricts the credit to charges of these products; absent applies to every product. Combined + * with applies_to. Not available for credit units. + * + * @return the value, empty when unset or null + */ + public Optional> applicableProductIds() { + return applicableProductIds.asOptional(); + } + + /** + * ALL pays any charge on an invoice; USAGE only usage charges. + * + * @return the value, empty when unset + */ + public Optional appliesTo() { + return Optional.ofNullable(appliesTo); + } + + /** + * The {@code cost} property. + * + * @return the value, empty when unset or null + */ + public Optional cost() { + return cost.asOptional(); + } + + /** + * Grants in this credit unit (its code) instead of a currency; excludes currency. + * Credit in a credit unit pays the usage priced in that unit, so applies_to must + * stay ALL. + * + * @return the value, empty when unset or null + */ + public Optional creditUnit() { + return creditUnit.asOptional(); + } + + /** + * The {@code currency} property. + * + * @return the value, empty when unset or null + */ + public Optional currency() { + return currency.asOptional(); + } + + /** + * When unspent credit lapses; absent never expires. + * + * @return the value, empty when unset or null + */ + public Optional expiresAt() { + return expiresAt.asOptional(); + } + + /** + * Lower values are drawn first among grants of the same type that pay the same charges; + * defaults to 100. + * + * @return the value, empty when unset or null + */ + public Optional priority() { + return priority.asOptional(); + } + + /** + * Shown on the credit ledger. + * + * @return the value, empty when unset or null + */ + public Optional reason() { + return reason.asOptional(); + } + + /** + * Your own reference, e.g. a contract or support ticket. Required for PAID credit that cost + * more than zero when the customer's invoicing entity is in France: the number of the invoice + * or receipt for the payment, as French law requires a supporting document for every accounting + * entry. Refused with 400 when missing. + * + * @return the value, empty when unset or null + */ + public Optional reference() { + return reference.asOptional(); + } + + /** + * The customer's subscription (sub_…) the credit belongs to: it pays only that + * subscription's charges and lapses when the subscription ends. It must not have ended, and its + * currency must be the grant's. Absent pays any of the customer's subscriptions. + * + * @return the value, empty when unset or null + */ + public Optional subscriptionId() { + return subscriptionId.asOptional(); + } + + /** + * PROMOTIONAL gives credit for free (a goodwill or marketing grant). PAID records credit the + * customer paid for outside of Meteroid: nothing is charged or invoiced, and the grant is shown + * as "Paid outside Meteroid". Usage paid with PAID currency credit is taxed on the invoice that + * bills it, so do not charge tax on the external sale of currency credit, or the customer is + * taxed twice. Credit in a credit unit is the exception: its usage is billed in credits, + * untaxed, so tax its sale as you would any other. Use a top-up to sell credit through + * Meteroid. + * + * @return the value, never null + */ + public CreditGrantType type() { + return Utils.required(type, "type"); + } + + /** + * Properties this version of the SDK does not know, kept as received and sent back. + * + * @return the properties by name, unmodifiable + */ + public Map additionalProperties() { + return Collections.unmodifiableMap(additionalProperties); + } + + @JsonAnyGetter + private Map anyProperties() { + return additionalProperties; + } + + @JsonAnySetter + private void putAnyProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CreateCreditGrantRequest that = (CreateCreditGrantRequest) o; + return Objects.equals(amount, that.amount) + && Objects.equals(applicableProductIds, that.applicableProductIds) + && Objects.equals(appliesTo, that.appliesTo) + && Objects.equals(cost, that.cost) + && Objects.equals(creditUnit, that.creditUnit) + && Objects.equals(currency, that.currency) + && Objects.equals(expiresAt, that.expiresAt) + && Objects.equals(priority, that.priority) + && Objects.equals(reason, that.reason) + && Objects.equals(reference, that.reference) + && Objects.equals(subscriptionId, that.subscriptionId) + && Objects.equals(type, that.type) + && Objects.equals(additionalProperties, that.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash( + amount, + applicableProductIds, + appliesTo, + cost, + creditUnit, + currency, + expiresAt, + priority, + reason, + reference, + subscriptionId, + type, + additionalProperties); + } + + @Override + public String toString() { + return "CreateCreditGrantRequest{" + + "amount=" + + amount + + ", applicableProductIds=" + + applicableProductIds + + ", appliesTo=" + + appliesTo + + ", cost=" + + cost + + ", creditUnit=" + + creditUnit + + ", currency=" + + currency + + ", expiresAt=" + + expiresAt + + ", priority=" + + priority + + ", reason=" + + reason + + ", reference=" + + reference + + ", subscriptionId=" + + subscriptionId + + ", type=" + + type + + ", additionalProperties=" + + additionalProperties + + "}"; + } + + /** Builds {@link CreateCreditGrantRequest}. */ + public static final class Builder { + private Long amount; + private JsonField> applicableProductIds = JsonField.missing(); + private CreditAppliesTo appliesTo; + private JsonField cost = JsonField.missing(); + private JsonField creditUnit = JsonField.missing(); + private JsonField currency = JsonField.missing(); + private JsonField expiresAt = JsonField.missing(); + private JsonField priority = JsonField.missing(); + private JsonField reason = JsonField.missing(); + private JsonField reference = JsonField.missing(); + private JsonField subscriptionId = JsonField.missing(); + private CreditGrantType type; + private final Map additionalProperties = new LinkedHashMap<>(); + + private Builder() {} + + /** + * Credit granted, in minor units of currency, or of credit_unit + * when set (e.g. 500000 is 5,000.00 credits of a unit with precision 2). Positive. + * + * @param amount the value + * @return this builder + */ + public Builder amount(Long amount) { + this.amount = amount; + return this; + } + + /** + * Restricts the credit to charges of these products; absent applies to every product. + * Combined with applies_to. Not available for credit units. + * + * @param applicableProductIds the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder applicableProductIds(List applicableProductIds) { + this.applicableProductIds = + JsonField.ofNullable(Utils.mutableList(applicableProductIds)); + return this; + } + + /** + * Adds an item to {@code applicable_product_ids}. + * + * @param item the item + * @return this builder + */ + public Builder addApplicableProductIdsItem(String item) { + List items = this.applicableProductIds.orNull(); + if (items == null) { + items = new ArrayList<>(); + this.applicableProductIds = JsonField.ofNullable(items); + } + items.add(item); + return this; + } + + /** + * ALL pays any charge on an invoice; USAGE only usage charges. + * + * @param appliesTo the value + * @return this builder + */ + public Builder appliesTo(CreditAppliesTo appliesTo) { + this.appliesTo = appliesTo; + return this; + } + + /** + * The {@code cost} property. + * + * @param cost the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder cost(CreditCostRequest cost) { + this.cost = JsonField.ofNullable(cost); + return this; + } + + /** + * Grants in this credit unit (its code) instead of a currency; excludes currency + * . Credit in a credit unit pays the usage priced in that unit, so applies_to + * must stay ALL. + * + * @param creditUnit the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder creditUnit(String creditUnit) { + this.creditUnit = JsonField.ofNullable(creditUnit); + return this; + } + + /** + * The {@code currency} property. + * + * @param currency the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder currency(Currency currency) { + this.currency = JsonField.ofNullable(currency); + return this; + } + + /** + * When unspent credit lapses; absent never expires. + * + * @param expiresAt the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder expiresAt(OffsetDateTime expiresAt) { + this.expiresAt = JsonField.ofNullable(expiresAt); + return this; + } + + /** + * Lower values are drawn first among grants of the same type that pay the same charges; + * defaults to 100. + * + * @param priority the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder priority(Integer priority) { + this.priority = JsonField.ofNullable(priority); + return this; + } + + /** + * Shown on the credit ledger. + * + * @param reason the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder reason(String reason) { + this.reason = JsonField.ofNullable(reason); + return this; + } + + /** + * Your own reference, e.g. a contract or support ticket. Required for PAID credit that cost + * more than zero when the customer's invoicing entity is in France: the number of the + * invoice or receipt for the payment, as French law requires a supporting document for + * every accounting entry. Refused with 400 when missing. + * + * @param reference the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder reference(String reference) { + this.reference = JsonField.ofNullable(reference); + return this; + } + + /** + * The customer's subscription (sub_…) the credit belongs to: it pays only that + * subscription's charges and lapses when the subscription ends. It must not have ended, and + * its currency must be the grant's. Absent pays any of the customer's subscriptions. + * + * @param subscriptionId the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder subscriptionId(String subscriptionId) { + this.subscriptionId = JsonField.ofNullable(subscriptionId); + return this; + } + + /** + * PROMOTIONAL gives credit for free (a goodwill or marketing grant). PAID records credit + * the customer paid for outside of Meteroid: nothing is charged or invoiced, and the grant + * is shown as "Paid outside Meteroid". Usage paid with PAID currency credit is taxed on the + * invoice that bills it, so do not charge tax on the external sale of currency credit, or + * the customer is taxed twice. Credit in a credit unit is the exception: its usage is + * billed in credits, untaxed, so tax its sale as you would any other. Use a top-up to sell + * credit through Meteroid. + * + * @param type the value + * @return this builder + */ + public Builder type(CreditGrantType type) { + this.type = type; + return this; + } + + /** + * A property the SDK does not know, sent along. + * + * @param name the property name + * @param value the JSON value + * @return this builder + */ + public Builder putAdditionalProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + return this; + } + + /** + * Properties the SDK does not know, sent along. + * + * @param additionalProperties the properties by name + * @return this builder + */ + public Builder putAllAdditionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + + /** + * Leaves out a property the SDK does not know. + * + * @param name the property name + * @return this builder + */ + public Builder removeAdditionalProperty(String name) { + additionalProperties.remove(name); + return this; + } + + /** + * The {@code CreateCreditGrantRequest}. + * + * @return the immutable value + * @throws IllegalStateException when a required property is not set + */ + public CreateCreditGrantRequest build() { + Utils.checkRequired(amount, "amount"); + Utils.checkRequired(type, "type"); + return new CreateCreditGrantRequest(this); + } + } + + /** + * Parse {@code json} as {@code CreateCreditGrantRequest}. + * + * @param json the JSON text + * @return the value + * @throws com.meteroid.exceptions.InvalidDataException if it is not valid JSON of this shape + */ + public static CreateCreditGrantRequest fromJson(String json) { + return Utils.parse(json, CreateCreditGrantRequest.class); + } + + /** + * This value as JSON. + * + * @return the JSON text + */ + public String toJson() { + return Utils.json(this); + } +} diff --git a/src/main/java/com/meteroid/models/CreateMetricRequest.java b/src/main/java/com/meteroid/models/CreateMetricRequest.java index 2dc61f1..4c17896 100644 --- a/src/main/java/com/meteroid/models/CreateMetricRequest.java +++ b/src/main/java/com/meteroid/models/CreateMetricRequest.java @@ -64,6 +64,14 @@ public final class CreateMetricRequest { @JsonInclude(JsonInclude.Include.NON_EMPTY) private JsonField unitConversion = JsonField.missing(); + @JsonProperty("unit_plural") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField unitPlural = JsonField.missing(); + + @JsonProperty("unit_singular") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField unitSingular = JsonField.missing(); + @JsonProperty("usage_group_key") @JsonInclude(JsonInclude.Include.NON_EMPTY) private JsonField usageGroupKey = JsonField.missing(); @@ -83,6 +91,8 @@ private CreateMetricRequest(Builder builder) { this.productId = builder.productId; this.segmentationMatrix = builder.segmentationMatrix; this.unitConversion = builder.unitConversion; + this.unitPlural = builder.unitPlural; + this.unitSingular = builder.unitSingular; this.usageGroupKey = builder.usageGroupKey; this.additionalProperties.putAll(builder.additionalProperties); } @@ -113,6 +123,8 @@ public Builder toBuilder() { builder.productId = productId; builder.segmentationMatrix = segmentationMatrix; builder.unitConversion = unitConversion; + builder.unitPlural = unitPlural; + builder.unitSingular = unitSingular; builder.usageGroupKey = usageGroupKey; builder.additionalProperties.putAll(additionalProperties); return builder; @@ -208,6 +220,27 @@ public Optional unitConversion() { return unitConversion.asOptional(); } + /** + * What several units of the metric are called, e.g. tokens. Set together with + * unit_singular. Trimmed; at most 32 characters. + * + * @return the value, empty when unset or null + */ + public Optional unitPlural() { + return unitPlural.asOptional(); + } + + /** + * What one unit of the metric is called, e.g. token, used to label quantities and + * prices ("$12.00 per 1M tokens"). Set both unit_singular and unit_plural + * , or neither. Trimmed; at most 32 characters. + * + * @return the value, empty when unset or null + */ + public Optional unitSingular() { + return unitSingular.asOptional(); + } + /** * The {@code usage_group_key} property. * @@ -255,6 +288,8 @@ public boolean equals(Object o) { && Objects.equals(productId, that.productId) && Objects.equals(segmentationMatrix, that.segmentationMatrix) && Objects.equals(unitConversion, that.unitConversion) + && Objects.equals(unitPlural, that.unitPlural) + && Objects.equals(unitSingular, that.unitSingular) && Objects.equals(usageGroupKey, that.usageGroupKey) && Objects.equals(additionalProperties, that.additionalProperties); } @@ -272,6 +307,8 @@ public int hashCode() { productId, segmentationMatrix, unitConversion, + unitPlural, + unitSingular, usageGroupKey, additionalProperties); } @@ -299,6 +336,10 @@ public String toString() { + segmentationMatrix + ", unitConversion=" + unitConversion + + ", unitPlural=" + + unitPlural + + ", unitSingular=" + + unitSingular + ", usageGroupKey=" + usageGroupKey + ", additionalProperties=" @@ -318,6 +359,8 @@ public static final class Builder { private JsonField productId = JsonField.missing(); private JsonField segmentationMatrix = JsonField.missing(); private JsonField unitConversion = JsonField.missing(); + private JsonField unitPlural = JsonField.missing(); + private JsonField unitSingular = JsonField.missing(); private JsonField usageGroupKey = JsonField.missing(); private final Map additionalProperties = new LinkedHashMap<>(); @@ -449,6 +492,31 @@ public Builder unitConversion(UnitConversion unitConversion) { return this; } + /** + * What several units of the metric are called, e.g. tokens. Set together with + * unit_singular. Trimmed; at most 32 characters. + * + * @param unitPlural the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder unitPlural(String unitPlural) { + this.unitPlural = JsonField.ofNullable(unitPlural); + return this; + } + + /** + * What one unit of the metric is called, e.g. token, used to label quantities + * and prices ("$12.00 per 1M tokens"). Set both unit_singular and + * unit_plural, or neither. Trimmed; at most 32 characters. + * + * @param unitSingular the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder unitSingular(String unitSingular) { + this.unitSingular = JsonField.ofNullable(unitSingular); + return this; + } + /** * The {@code usage_group_key} property. * diff --git a/src/main/java/com/meteroid/models/CreatePlanRequest.java b/src/main/java/com/meteroid/models/CreatePlanRequest.java index 24ac74b..751a84b 100644 --- a/src/main/java/com/meteroid/models/CreatePlanRequest.java +++ b/src/main/java/com/meteroid/models/CreatePlanRequest.java @@ -38,6 +38,10 @@ public final class CreatePlanRequest { @JsonProperty("components") private List components; + @JsonProperty("credit_exhausted_rule") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField creditExhaustedRule = JsonField.missing(); + @JsonProperty("currency") private String currency; @@ -79,6 +83,7 @@ private CreatePlanRequest(Builder builder) { this.addOns = Utils.copyList(builder.addOns); this.billing = builder.billing; this.components = Utils.copyList(builder.components); + this.creditExhaustedRule = builder.creditExhaustedRule; this.currency = builder.currency; this.description = builder.description; this.entitlements = Utils.copyList(builder.entitlements); @@ -111,6 +116,7 @@ public Builder toBuilder() { builder.addOns = Utils.mutableList(addOns); builder.billing = billing; builder.components = Utils.mutableList(components); + builder.creditExhaustedRule = creditExhaustedRule; builder.currency = currency; builder.description = description; builder.entitlements = Utils.mutableList(entitlements); @@ -152,6 +158,15 @@ public List components() { return Utils.required(components, "components"); } + /** + * The {@code credit_exhausted_rule} property. + * + * @return the value, empty when unset or null + */ + public Optional creditExhaustedRule() { + return creditExhaustedRule.asOptional(); + } + /** * The {@code currency} property. * @@ -278,6 +293,7 @@ public boolean equals(Object o) { return Objects.equals(addOns, that.addOns) && Objects.equals(billing, that.billing) && Objects.equals(components, that.components) + && Objects.equals(creditExhaustedRule, that.creditExhaustedRule) && Objects.equals(currency, that.currency) && Objects.equals(description, that.description) && Objects.equals(entitlements, that.entitlements) @@ -297,6 +313,7 @@ public int hashCode() { addOns, billing, components, + creditExhaustedRule, currency, description, entitlements, @@ -319,6 +336,8 @@ public String toString() { + billing + ", components=" + components + + ", creditExhaustedRule=" + + creditExhaustedRule + ", currency=" + currency + ", description=" @@ -349,6 +368,7 @@ public static final class Builder { private List addOns; private JsonField billing = JsonField.missing(); private List components; + private JsonField creditExhaustedRule = JsonField.missing(); private String currency; private JsonField description = JsonField.missing(); private List entitlements; @@ -424,6 +444,17 @@ public Builder addComponentsItem(PriceComponentInput item) { return this; } + /** + * The {@code credit_exhausted_rule} property. + * + * @param creditExhaustedRule the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder creditExhaustedRule(CreditExhaustedRule creditExhaustedRule) { + this.creditExhaustedRule = JsonField.ofNullable(creditExhaustedRule); + return this; + } + /** * The {@code currency} property. * diff --git a/src/main/java/com/meteroid/models/CreateTopUpRequest.java b/src/main/java/com/meteroid/models/CreateTopUpRequest.java new file mode 100644 index 0000000..05ea57f --- /dev/null +++ b/src/main/java/com/meteroid/models/CreateTopUpRequest.java @@ -0,0 +1,414 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.JsonField; +import com.meteroid.internal.Utils; + +import java.time.OffsetDateTime; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +/** + * Credit sold to the customer, charged or invoiced. + * + *

Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonAutoDetect( + getterVisibility = Visibility.NONE, + isGetterVisibility = Visibility.NONE, + setterVisibility = Visibility.NONE) +public final class CreateTopUpRequest { + @JsonProperty("amount") + private Long amount; + + @JsonProperty("collection") + private TopUpCollection collection; + + @JsonProperty("credit_unit") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField creditUnit = JsonField.missing(); + + @JsonProperty("currency") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField currency = JsonField.missing(); + + @JsonProperty("expires_at") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField expiresAt = JsonField.missing(); + + @JsonProperty("payment_method_id") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField paymentMethodId = JsonField.missing(); + + @JsonProperty("unit_price") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField unitPrice = JsonField.missing(); + + private final Map additionalProperties = new LinkedHashMap<>(); + + private CreateTopUpRequest() {} + + private CreateTopUpRequest(Builder builder) { + this.amount = builder.amount; + this.collection = builder.collection; + this.creditUnit = builder.creditUnit; + this.currency = builder.currency; + this.expiresAt = builder.expiresAt; + this.paymentMethodId = builder.paymentMethodId; + this.unitPrice = builder.unitPrice; + this.additionalProperties.putAll(builder.additionalProperties); + } + + /** + * A builder of {@code CreateTopUpRequest}. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * A builder starting from this value. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.amount = amount; + builder.collection = collection; + builder.creditUnit = creditUnit; + builder.currency = currency; + builder.expiresAt = expiresAt; + builder.paymentMethodId = paymentMethodId; + builder.unitPrice = unitPrice; + builder.additionalProperties.putAll(additionalProperties); + return builder; + } + + /** + * Credit to buy, positive, applying to ALL charges. In minor units of currency, + * charged one for one without tax: the usage it pays is taxed on the invoice that bills it. + * With credit_unit, in minor units of that unit (e.g. 500000 is 5,000.00 credits + * of a unit with precision 2), charged at the unit's price per credit in the customer's + * currency, plus tax under the unit's product. + * + * @return the value, never null + */ + public Long amount() { + return Utils.required(amount, "amount"); + } + + /** + * CHARGE (default) charges a saved payment method now; SEND_INVOICE issues an invoice and + * grants the credit once it is paid. + * + * @return the value, empty when unset + */ + public Optional collection() { + return Optional.ofNullable(collection); + } + + /** + * Buy credits of this credit unit (its code) instead of money; excludes currency. + * They are charged in the customer's currency at the customer's agreed price for the unit (the + * wallet's unit_price), else its list price, plus tax, under the unit's product. + * + * @return the value, empty when unset or null + */ + public Optional creditUnit() { + return creditUnit.asOptional(); + } + + /** + * The {@code currency} property. + * + * @return the value, empty when unset or null + */ + public Optional currency() { + return currency.asOptional(); + } + + /** + * Absolute expiry of the purchased credit; unset never expires. + * + * @return the value, empty when unset or null + */ + public Optional expiresAt() { + return expiresAt.asOptional(); + } + + /** + * CHARGE only; defaults to the customer's default payment method. + * + * @return the value, empty when unset or null + */ + public Optional paymentMethodId() { + return paymentMethodId.asOptional(); + } + + /** + * With credit_unit: the negotiated price of one credit for this purchase, in major + * units of the customer's currency, as a decimal string (e.g. "0.0008"). Defaults to the + * wallet's unit_price when set, else the list price; the unit must still have a + * list price in that currency. + * + * @return the value, empty when unset or null + */ + public Optional unitPrice() { + return unitPrice.asOptional(); + } + + /** + * Properties this version of the SDK does not know, kept as received and sent back. + * + * @return the properties by name, unmodifiable + */ + public Map additionalProperties() { + return Collections.unmodifiableMap(additionalProperties); + } + + @JsonAnyGetter + private Map anyProperties() { + return additionalProperties; + } + + @JsonAnySetter + private void putAnyProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CreateTopUpRequest that = (CreateTopUpRequest) o; + return Objects.equals(amount, that.amount) + && Objects.equals(collection, that.collection) + && Objects.equals(creditUnit, that.creditUnit) + && Objects.equals(currency, that.currency) + && Objects.equals(expiresAt, that.expiresAt) + && Objects.equals(paymentMethodId, that.paymentMethodId) + && Objects.equals(unitPrice, that.unitPrice) + && Objects.equals(additionalProperties, that.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash( + amount, + collection, + creditUnit, + currency, + expiresAt, + paymentMethodId, + unitPrice, + additionalProperties); + } + + @Override + public String toString() { + return "CreateTopUpRequest{" + + "amount=" + + amount + + ", collection=" + + collection + + ", creditUnit=" + + creditUnit + + ", currency=" + + currency + + ", expiresAt=" + + expiresAt + + ", paymentMethodId=" + + paymentMethodId + + ", unitPrice=" + + unitPrice + + ", additionalProperties=" + + additionalProperties + + "}"; + } + + /** Builds {@link CreateTopUpRequest}. */ + public static final class Builder { + private Long amount; + private TopUpCollection collection; + private JsonField creditUnit = JsonField.missing(); + private JsonField currency = JsonField.missing(); + private JsonField expiresAt = JsonField.missing(); + private JsonField paymentMethodId = JsonField.missing(); + private JsonField unitPrice = JsonField.missing(); + private final Map additionalProperties = new LinkedHashMap<>(); + + private Builder() {} + + /** + * Credit to buy, positive, applying to ALL charges. In minor units of currency + * , charged one for one without tax: the usage it pays is taxed on the invoice that bills + * it. With credit_unit, in minor units of that unit (e.g. 500000 is 5,000.00 + * credits of a unit with precision 2), charged at the unit's price per credit in the + * customer's currency, plus tax under the unit's product. + * + * @param amount the value + * @return this builder + */ + public Builder amount(Long amount) { + this.amount = amount; + return this; + } + + /** + * CHARGE (default) charges a saved payment method now; SEND_INVOICE issues an invoice and + * grants the credit once it is paid. + * + * @param collection the value + * @return this builder + */ + public Builder collection(TopUpCollection collection) { + this.collection = collection; + return this; + } + + /** + * Buy credits of this credit unit (its code) instead of money; excludes currency + * . They are charged in the customer's currency at the customer's agreed price for + * the unit (the wallet's unit_price), else its list price, plus tax, under the + * unit's product. + * + * @param creditUnit the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder creditUnit(String creditUnit) { + this.creditUnit = JsonField.ofNullable(creditUnit); + return this; + } + + /** + * The {@code currency} property. + * + * @param currency the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder currency(Currency currency) { + this.currency = JsonField.ofNullable(currency); + return this; + } + + /** + * Absolute expiry of the purchased credit; unset never expires. + * + * @param expiresAt the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder expiresAt(OffsetDateTime expiresAt) { + this.expiresAt = JsonField.ofNullable(expiresAt); + return this; + } + + /** + * CHARGE only; defaults to the customer's default payment method. + * + * @param paymentMethodId the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder paymentMethodId(String paymentMethodId) { + this.paymentMethodId = JsonField.ofNullable(paymentMethodId); + return this; + } + + /** + * With credit_unit: the negotiated price of one credit for this purchase, in + * major units of the customer's currency, as a decimal string (e.g. "0.0008"). Defaults to + * the wallet's unit_price when set, else the list price; the unit must still + * have a list price in that currency. + * + * @param unitPrice the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder unitPrice(String unitPrice) { + this.unitPrice = JsonField.ofNullable(unitPrice); + return this; + } + + /** + * A property the SDK does not know, sent along. + * + * @param name the property name + * @param value the JSON value + * @return this builder + */ + public Builder putAdditionalProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + return this; + } + + /** + * Properties the SDK does not know, sent along. + * + * @param additionalProperties the properties by name + * @return this builder + */ + public Builder putAllAdditionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + + /** + * Leaves out a property the SDK does not know. + * + * @param name the property name + * @return this builder + */ + public Builder removeAdditionalProperty(String name) { + additionalProperties.remove(name); + return this; + } + + /** + * The {@code CreateTopUpRequest}. + * + * @return the immutable value + * @throws IllegalStateException when a required property is not set + */ + public CreateTopUpRequest build() { + Utils.checkRequired(amount, "amount"); + return new CreateTopUpRequest(this); + } + } + + /** + * Parse {@code json} as {@code CreateTopUpRequest}. + * + * @param json the JSON text + * @return the value + * @throws com.meteroid.exceptions.InvalidDataException if it is not valid JSON of this shape + */ + public static CreateTopUpRequest fromJson(String json) { + return Utils.parse(json, CreateTopUpRequest.class); + } + + /** + * This value as JSON. + * + * @return the JSON text + */ + public String toJson() { + return Utils.json(this); + } +} diff --git a/src/main/java/com/meteroid/models/CreateWebhookEndpointRequest.java b/src/main/java/com/meteroid/models/CreateWebhookEndpointRequest.java index 176c733..c8334b3 100644 --- a/src/main/java/com/meteroid/models/CreateWebhookEndpointRequest.java +++ b/src/main/java/com/meteroid/models/CreateWebhookEndpointRequest.java @@ -93,7 +93,8 @@ public Optional description() { } /** - * Event types to subscribe to. Omit or leave empty to receive every event type. + * Event types to subscribe to. Omit or leave empty to receive every event type except Beta + * ones, which are sent only to endpoints that list them. * * @return the value, empty when unset */ @@ -212,7 +213,8 @@ public Builder description(String description) { } /** - * Event types to subscribe to. Omit or leave empty to receive every event type. + * Event types to subscribe to. Omit or leave empty to receive every event type except Beta + * ones, which are sent only to endpoints that list them. * * @param eventTypes the value * @return this builder diff --git a/src/main/java/com/meteroid/models/CreditAppliesTo.java b/src/main/java/com/meteroid/models/CreditAppliesTo.java new file mode 100644 index 0000000..49d1ef0 --- /dev/null +++ b/src/main/java/com/meteroid/models/CreditAppliesTo.java @@ -0,0 +1,128 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import com.meteroid.internal.Utils.ToQueryParam; + +import java.util.Map; +import java.util.Objects; + +/** + * Which charges credit pays: ALL pays any part of an invoice, USAGE only its usage charges. + * + *

Values this version of the SDK does not know are kept, and sent back unchanged: {@link + * #value()} is an enum to switch on, {@code _UNKNOWN} for them, and {@link #known()} throws on + * them. + */ +public final class CreditAppliesTo implements ToQueryParam { + /** The value {@code "ALL"}. */ + public static final CreditAppliesTo ALL = new CreditAppliesTo("ALL", Value.ALL); + + /** The value {@code "USAGE"}. */ + public static final CreditAppliesTo USAGE = new CreditAppliesTo("USAGE", Value.USAGE); + + private static final Map constants = + Map.ofEntries(Map.entry("ALL", ALL), Map.entry("USAGE", USAGE)); + + private final String value; + private final Value variant; + + private CreditAppliesTo(String value, Value variant) { + this.value = value; + this.variant = variant; + } + + /** + * The constant for {@code value}, or an unknown CreditAppliesTo holding it. + * + * @param value the value + * @return the constant + */ + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static CreditAppliesTo of(String value) { + CreditAppliesTo constant = constants.get(Objects.requireNonNull(value, "value")); + return constant != null ? constant : new CreditAppliesTo(value, Value._UNKNOWN); + } + + /** + * The value as sent. + * + * @return the value + */ + @JsonValue + public String asString() { + return value; + } + + /** + * Whether this version of the SDK knows the value. + * + * @return whether it is known + */ + public boolean isKnown() { + return variant != Value._UNKNOWN; + } + + /** + * The value as an enum to switch on, unknown values included. + * + * @return the enum, {@code _UNKNOWN} when unknown + */ + public Value value() { + return variant; + } + + /** + * The value as an enum of the known values only. + * + * @return the enum + * @throws com.meteroid.exceptions.InvalidDataException when this version of the SDK does not + * know the value + */ + public Known known() { + if (!isKnown()) { + throw new com.meteroid.exceptions.InvalidDataException( + "unknown CreditAppliesTo: " + value); + } + return Known.valueOf(variant.name()); + } + + @Override + public String toQueryParam() { + return String.valueOf(value); + } + + @Override + public boolean equals(Object o) { + return o instanceof CreditAppliesTo && Objects.equals(value, ((CreditAppliesTo) o).value); + } + + @Override + public int hashCode() { + return Objects.hashCode(value); + } + + @Override + public String toString() { + return String.valueOf(value); + } + + /** The values this version of the SDK knows. */ + public enum Known { + /** The {@code ALL} constant. */ + ALL, + /** The {@code USAGE} constant. */ + USAGE + } + + /** The values this version of the SDK knows, and {@code _UNKNOWN} for the others. */ + public enum Value { + /** The {@code ALL} constant. */ + ALL, + /** The {@code USAGE} constant. */ + USAGE, + /** A value this version of the SDK does not know. */ + _UNKNOWN + } +} diff --git a/src/main/java/com/meteroid/models/CreditCap.java b/src/main/java/com/meteroid/models/CreditCap.java new file mode 100644 index 0000000..322b69e --- /dev/null +++ b/src/main/java/com/meteroid/models/CreditCap.java @@ -0,0 +1,231 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.Utils; + +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; + +/** Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonAutoDetect( + getterVisibility = Visibility.NONE, + isGetterVisibility = Visibility.NONE, + setterVisibility = Visibility.NONE) +public final class CreditCap { + @JsonProperty("amount") + private Long amount; + + @JsonProperty("denomination") + private String denomination; + + private final Map additionalProperties = new LinkedHashMap<>(); + + private CreditCap() {} + + private CreditCap(Builder builder) { + this.amount = builder.amount; + this.denomination = builder.denomination; + this.additionalProperties.putAll(builder.additionalProperties); + } + + /** + * A builder of {@code CreditCap}. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * A builder starting from this value. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.amount = amount; + builder.denomination = denomination; + builder.additionalProperties.putAll(additionalProperties); + return builder; + } + + /** + * Usage beyond the credit invoiced per billing period, in minor units of denomination + * . + * + * @return the value, never null + */ + public Long amount() { + return Utils.required(amount, "amount"); + } + + /** + * A currency or credit unit code. + * + * @return the value, never null + */ + public String denomination() { + return Utils.required(denomination, "denomination"); + } + + /** + * Properties this version of the SDK does not know, kept as received and sent back. + * + * @return the properties by name, unmodifiable + */ + public Map additionalProperties() { + return Collections.unmodifiableMap(additionalProperties); + } + + @JsonAnyGetter + private Map anyProperties() { + return additionalProperties; + } + + @JsonAnySetter + private void putAnyProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CreditCap that = (CreditCap) o; + return Objects.equals(amount, that.amount) + && Objects.equals(denomination, that.denomination) + && Objects.equals(additionalProperties, that.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(amount, denomination, additionalProperties); + } + + @Override + public String toString() { + return "CreditCap{" + + "amount=" + + amount + + ", denomination=" + + denomination + + ", additionalProperties=" + + additionalProperties + + "}"; + } + + /** Builds {@link CreditCap}. */ + public static final class Builder { + private Long amount; + private String denomination; + private final Map additionalProperties = new LinkedHashMap<>(); + + private Builder() {} + + /** + * Usage beyond the credit invoiced per billing period, in minor units of denomination + * . + * + * @param amount the value + * @return this builder + */ + public Builder amount(Long amount) { + this.amount = amount; + return this; + } + + /** + * A currency or credit unit code. + * + * @param denomination the value + * @return this builder + */ + public Builder denomination(String denomination) { + this.denomination = denomination; + return this; + } + + /** + * A property the SDK does not know, sent along. + * + * @param name the property name + * @param value the JSON value + * @return this builder + */ + public Builder putAdditionalProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + return this; + } + + /** + * Properties the SDK does not know, sent along. + * + * @param additionalProperties the properties by name + * @return this builder + */ + public Builder putAllAdditionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + + /** + * Leaves out a property the SDK does not know. + * + * @param name the property name + * @return this builder + */ + public Builder removeAdditionalProperty(String name) { + additionalProperties.remove(name); + return this; + } + + /** + * The {@code CreditCap}. + * + * @return the immutable value + * @throws IllegalStateException when a required property is not set + */ + public CreditCap build() { + Utils.checkRequired(amount, "amount"); + Utils.checkRequired(denomination, "denomination"); + return new CreditCap(this); + } + } + + /** + * Parse {@code json} as {@code CreditCap}. + * + * @param json the JSON text + * @return the value + * @throws com.meteroid.exceptions.InvalidDataException if it is not valid JSON of this shape + */ + public static CreditCap fromJson(String json) { + return Utils.parse(json, CreditCap.class); + } + + /** + * This value as JSON. + * + * @return the JSON text + */ + public String toJson() { + return Utils.json(this); + } +} diff --git a/src/main/java/com/meteroid/models/CreditCaps.java b/src/main/java/com/meteroid/models/CreditCaps.java new file mode 100644 index 0000000..e4b3956 --- /dev/null +++ b/src/main/java/com/meteroid/models/CreditCaps.java @@ -0,0 +1,245 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.Utils; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonAutoDetect( + getterVisibility = Visibility.NONE, + isGetterVisibility = Visibility.NONE, + setterVisibility = Visibility.NONE) +public final class CreditCaps { + @JsonProperty("caps") + private List caps; + + @JsonProperty("type") + private String type = "invoice_up_to"; + + private final Map additionalProperties = new LinkedHashMap<>(); + + private CreditCaps() {} + + private CreditCaps(Builder builder) { + this.caps = Utils.copyList(builder.caps); + this.type = builder.type; + this.additionalProperties.putAll(builder.additionalProperties); + } + + /** + * A builder of {@code CreditCaps}. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * A builder starting from this value. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.caps = Utils.mutableList(caps); + builder.type = type; + builder.additionalProperties.putAll(additionalProperties); + return builder; + } + + /** + * One per denomination; usage charged in a denomination without a cap pauses at zero. + * + * @return the value, never null + */ + public List caps() { + return Utils.required(caps, "caps"); + } + + /** + * The {@code type} property. + * + * @return the value, never null + */ + public String type() { + return Utils.required(type, "type"); + } + + /** + * Properties this version of the SDK does not know, kept as received and sent back. + * + * @return the properties by name, unmodifiable + */ + public Map additionalProperties() { + return Collections.unmodifiableMap(additionalProperties); + } + + @JsonAnyGetter + private Map anyProperties() { + return additionalProperties; + } + + @JsonAnySetter + private void putAnyProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CreditCaps that = (CreditCaps) o; + return Objects.equals(caps, that.caps) + && Objects.equals(type, that.type) + && Objects.equals(additionalProperties, that.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(caps, type, additionalProperties); + } + + @Override + public String toString() { + return "CreditCaps{" + + "caps=" + + caps + + ", type=" + + type + + ", additionalProperties=" + + additionalProperties + + "}"; + } + + /** Builds {@link CreditCaps}. */ + public static final class Builder { + private List caps; + private String type = "invoice_up_to"; + private final Map additionalProperties = new LinkedHashMap<>(); + + private Builder() {} + + /** + * One per denomination; usage charged in a denomination without a cap pauses at zero. + * + * @param caps the value + * @return this builder + */ + public Builder caps(List caps) { + this.caps = Utils.mutableList(caps); + return this; + } + + /** + * Adds an item to {@code caps}. + * + * @param item the item + * @return this builder + */ + public Builder addCapsItem(CreditCap item) { + if (this.caps == null) { + this.caps = new ArrayList<>(); + } + this.caps.add(item); + return this; + } + + /** + * The {@code type} property. + * + * @param type the value + * @return this builder + */ + public Builder type(String type) { + this.type = type; + return this; + } + + /** + * A property the SDK does not know, sent along. + * + * @param name the property name + * @param value the JSON value + * @return this builder + */ + public Builder putAdditionalProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + return this; + } + + /** + * Properties the SDK does not know, sent along. + * + * @param additionalProperties the properties by name + * @return this builder + */ + public Builder putAllAdditionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + + /** + * Leaves out a property the SDK does not know. + * + * @param name the property name + * @return this builder + */ + public Builder removeAdditionalProperty(String name) { + additionalProperties.remove(name); + return this; + } + + /** + * The {@code CreditCaps}. + * + * @return the immutable value + * @throws IllegalStateException when a required property is not set + */ + public CreditCaps build() { + Utils.checkRequired(caps, "caps"); + Utils.checkRequired(type, "type"); + return new CreditCaps(this); + } + } + + /** + * Parse {@code json} as {@code CreditCaps}. + * + * @param json the JSON text + * @return the value + * @throws com.meteroid.exceptions.InvalidDataException if it is not valid JSON of this shape + */ + public static CreditCaps fromJson(String json) { + return Utils.parse(json, CreditCaps.class); + } + + /** + * This value as JSON. + * + * @return the JSON text + */ + public String toJson() { + return Utils.json(this); + } +} diff --git a/src/main/java/com/meteroid/models/CreditCost.java b/src/main/java/com/meteroid/models/CreditCost.java new file mode 100644 index 0000000..ceef266 --- /dev/null +++ b/src/main/java/com/meteroid/models/CreditCost.java @@ -0,0 +1,233 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.Utils; + +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; + +/** + * Money in minor units of currency, net of tax. + * + *

Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonAutoDetect( + getterVisibility = Visibility.NONE, + isGetterVisibility = Visibility.NONE, + setterVisibility = Visibility.NONE) +public final class CreditCost { + @JsonProperty("amount") + private Long amount; + + @JsonProperty("currency") + private Currency currency; + + private final Map additionalProperties = new LinkedHashMap<>(); + + private CreditCost() {} + + private CreditCost(Builder builder) { + this.amount = builder.amount; + this.currency = builder.currency; + this.additionalProperties.putAll(builder.additionalProperties); + } + + /** + * A builder of {@code CreditCost}. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * A builder starting from this value. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.amount = amount; + builder.currency = currency; + builder.additionalProperties.putAll(additionalProperties); + return builder; + } + + /** + * In minor units of currency. + * + * @return the value, never null + */ + public Long amount() { + return Utils.required(amount, "amount"); + } + + /** + * The {@code currency} property. + * + * @return the value, never null + */ + public Currency currency() { + return Utils.required(currency, "currency"); + } + + /** + * Properties this version of the SDK does not know, kept as received and sent back. + * + * @return the properties by name, unmodifiable + */ + public Map additionalProperties() { + return Collections.unmodifiableMap(additionalProperties); + } + + @JsonAnyGetter + private Map anyProperties() { + return additionalProperties; + } + + @JsonAnySetter + private void putAnyProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CreditCost that = (CreditCost) o; + return Objects.equals(amount, that.amount) + && Objects.equals(currency, that.currency) + && Objects.equals(additionalProperties, that.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(amount, currency, additionalProperties); + } + + @Override + public String toString() { + return "CreditCost{" + + "amount=" + + amount + + ", currency=" + + currency + + ", additionalProperties=" + + additionalProperties + + "}"; + } + + /** Builds {@link CreditCost}. */ + public static final class Builder { + private Long amount; + private Currency currency; + private final Map additionalProperties = new LinkedHashMap<>(); + + private Builder() {} + + /** + * In minor units of currency. + * + * @param amount the value + * @return this builder + */ + public Builder amount(Long amount) { + this.amount = amount; + return this; + } + + /** + * The {@code currency} property. + * + * @param currency the value + * @return this builder + */ + public Builder currency(Currency currency) { + this.currency = currency; + return this; + } + + /** + * A property the SDK does not know, sent along. + * + * @param name the property name + * @param value the JSON value + * @return this builder + */ + public Builder putAdditionalProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + return this; + } + + /** + * Properties the SDK does not know, sent along. + * + * @param additionalProperties the properties by name + * @return this builder + */ + public Builder putAllAdditionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + + /** + * Leaves out a property the SDK does not know. + * + * @param name the property name + * @return this builder + */ + public Builder removeAdditionalProperty(String name) { + additionalProperties.remove(name); + return this; + } + + /** + * The {@code CreditCost}. + * + * @return the immutable value + * @throws IllegalStateException when a required property is not set + */ + public CreditCost build() { + Utils.checkRequired(amount, "amount"); + Utils.checkRequired(currency, "currency"); + return new CreditCost(this); + } + } + + /** + * Parse {@code json} as {@code CreditCost}. + * + * @param json the JSON text + * @return the value + * @throws com.meteroid.exceptions.InvalidDataException if it is not valid JSON of this shape + */ + public static CreditCost fromJson(String json) { + return Utils.parse(json, CreditCost.class); + } + + /** + * This value as JSON. + * + * @return the JSON text + */ + public String toJson() { + return Utils.json(this); + } +} diff --git a/src/main/java/com/meteroid/models/CreditCostRequest.java b/src/main/java/com/meteroid/models/CreditCostRequest.java new file mode 100644 index 0000000..404132a --- /dev/null +++ b/src/main/java/com/meteroid/models/CreditCostRequest.java @@ -0,0 +1,233 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.Utils; + +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; + +/** + * Money in minor units of currency, net of tax. + * + *

Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonAutoDetect( + getterVisibility = Visibility.NONE, + isGetterVisibility = Visibility.NONE, + setterVisibility = Visibility.NONE) +public final class CreditCostRequest { + @JsonProperty("amount") + private Long amount; + + @JsonProperty("currency") + private Currency currency; + + private final Map additionalProperties = new LinkedHashMap<>(); + + private CreditCostRequest() {} + + private CreditCostRequest(Builder builder) { + this.amount = builder.amount; + this.currency = builder.currency; + this.additionalProperties.putAll(builder.additionalProperties); + } + + /** + * A builder of {@code CreditCostRequest}. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * A builder starting from this value. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.amount = amount; + builder.currency = currency; + builder.additionalProperties.putAll(additionalProperties); + return builder; + } + + /** + * In minor units of currency; zero or positive. + * + * @return the value, never null + */ + public Long amount() { + return Utils.required(amount, "amount"); + } + + /** + * The {@code currency} property. + * + * @return the value, never null + */ + public Currency currency() { + return Utils.required(currency, "currency"); + } + + /** + * Properties this version of the SDK does not know, kept as received and sent back. + * + * @return the properties by name, unmodifiable + */ + public Map additionalProperties() { + return Collections.unmodifiableMap(additionalProperties); + } + + @JsonAnyGetter + private Map anyProperties() { + return additionalProperties; + } + + @JsonAnySetter + private void putAnyProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CreditCostRequest that = (CreditCostRequest) o; + return Objects.equals(amount, that.amount) + && Objects.equals(currency, that.currency) + && Objects.equals(additionalProperties, that.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(amount, currency, additionalProperties); + } + + @Override + public String toString() { + return "CreditCostRequest{" + + "amount=" + + amount + + ", currency=" + + currency + + ", additionalProperties=" + + additionalProperties + + "}"; + } + + /** Builds {@link CreditCostRequest}. */ + public static final class Builder { + private Long amount; + private Currency currency; + private final Map additionalProperties = new LinkedHashMap<>(); + + private Builder() {} + + /** + * In minor units of currency; zero or positive. + * + * @param amount the value + * @return this builder + */ + public Builder amount(Long amount) { + this.amount = amount; + return this; + } + + /** + * The {@code currency} property. + * + * @param currency the value + * @return this builder + */ + public Builder currency(Currency currency) { + this.currency = currency; + return this; + } + + /** + * A property the SDK does not know, sent along. + * + * @param name the property name + * @param value the JSON value + * @return this builder + */ + public Builder putAdditionalProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + return this; + } + + /** + * Properties the SDK does not know, sent along. + * + * @param additionalProperties the properties by name + * @return this builder + */ + public Builder putAllAdditionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + + /** + * Leaves out a property the SDK does not know. + * + * @param name the property name + * @return this builder + */ + public Builder removeAdditionalProperty(String name) { + additionalProperties.remove(name); + return this; + } + + /** + * The {@code CreditCostRequest}. + * + * @return the immutable value + * @throws IllegalStateException when a required property is not set + */ + public CreditCostRequest build() { + Utils.checkRequired(amount, "amount"); + Utils.checkRequired(currency, "currency"); + return new CreditCostRequest(this); + } + } + + /** + * Parse {@code json} as {@code CreditCostRequest}. + * + * @param json the JSON text + * @return the value + * @throws com.meteroid.exceptions.InvalidDataException if it is not valid JSON of this shape + */ + public static CreditCostRequest fromJson(String json) { + return Utils.parse(json, CreditCostRequest.class); + } + + /** + * This value as JSON. + * + * @return the JSON text + */ + public String toJson() { + return Utils.json(this); + } +} diff --git a/src/main/java/com/meteroid/models/CreditDiscount.java b/src/main/java/com/meteroid/models/CreditDiscount.java new file mode 100644 index 0000000..aff3835 --- /dev/null +++ b/src/main/java/com/meteroid/models/CreditDiscount.java @@ -0,0 +1,329 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.JsonField; +import com.meteroid.internal.Utils; + +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +/** + * Promotional credit added to the customer's credit balance when the subscription the coupon is + * redeemed on starts. It never discounts an invoice and applies before tax. A customer redeems it + * at most once, so the coupon cannot be reusable. Its code is case-insensitive: it is + * stored upper-case and redeemed whatever the case. + * + *

Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonAutoDetect( + getterVisibility = Visibility.NONE, + isGetterVisibility = Visibility.NONE, + setterVisibility = Visibility.NONE) +public final class CreditDiscount { + @JsonProperty("amount") + private String amount; + + @JsonProperty("currency") + private String currency; + + @JsonProperty("expires_in_days") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField expiresInDays = JsonField.missing(); + + @JsonProperty("scope") + private CouponCreditScope scope; + + @JsonProperty("type") + private String type = "CREDIT"; + + private final Map additionalProperties = new LinkedHashMap<>(); + + private CreditDiscount() {} + + private CreditDiscount(Builder builder) { + this.amount = builder.amount; + this.currency = builder.currency; + this.expiresInDays = builder.expiresInDays; + this.scope = builder.scope; + this.type = builder.type; + this.additionalProperties.putAll(builder.additionalProperties); + } + + /** + * A builder of {@code CreditDiscount}. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * A builder starting from this value. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.amount = amount; + builder.currency = currency; + builder.expiresInDays = expiresInDays; + builder.scope = scope; + builder.type = type; + builder.additionalProperties.putAll(additionalProperties); + return builder; + } + + /** + * Credit added per redemption, in major units (e.g. "25.00"). + * + * @return the value, never null + */ + public String amount() { + return Utils.required(amount, "amount"); + } + + /** + * ISO 4217 code; it must match the currency of the subscription the coupon is redeemed on. + * + * @return the value, never null + */ + public String currency() { + return Utils.required(currency, "currency"); + } + + /** + * Days the credit stays spendable after redemption, 1 to 3660. Absent: it never expires. + * + * @return the value, empty when unset or null + */ + public Optional expiresInDays() { + return expiresInDays.asOptional(); + } + + /** + * CUSTOMER (default): the credit pays any of the customer's subscriptions. SUBSCRIPTION: the + * credit pays only the subscription the code is redeemed on, and ends with it. + * + * @return the value, empty when unset + */ + public Optional scope() { + return Optional.ofNullable(scope); + } + + /** + * The {@code type} property. + * + * @return the value, never null + */ + public String type() { + return Utils.required(type, "type"); + } + + /** + * Properties this version of the SDK does not know, kept as received and sent back. + * + * @return the properties by name, unmodifiable + */ + public Map additionalProperties() { + return Collections.unmodifiableMap(additionalProperties); + } + + @JsonAnyGetter + private Map anyProperties() { + return additionalProperties; + } + + @JsonAnySetter + private void putAnyProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CreditDiscount that = (CreditDiscount) o; + return Objects.equals(amount, that.amount) + && Objects.equals(currency, that.currency) + && Objects.equals(expiresInDays, that.expiresInDays) + && Objects.equals(scope, that.scope) + && Objects.equals(type, that.type) + && Objects.equals(additionalProperties, that.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(amount, currency, expiresInDays, scope, type, additionalProperties); + } + + @Override + public String toString() { + return "CreditDiscount{" + + "amount=" + + amount + + ", currency=" + + currency + + ", expiresInDays=" + + expiresInDays + + ", scope=" + + scope + + ", type=" + + type + + ", additionalProperties=" + + additionalProperties + + "}"; + } + + /** Builds {@link CreditDiscount}. */ + public static final class Builder { + private String amount; + private String currency; + private JsonField expiresInDays = JsonField.missing(); + private CouponCreditScope scope; + private String type = "CREDIT"; + private final Map additionalProperties = new LinkedHashMap<>(); + + private Builder() {} + + /** + * Credit added per redemption, in major units (e.g. "25.00"). + * + * @param amount the value + * @return this builder + */ + public Builder amount(String amount) { + this.amount = amount; + return this; + } + + /** + * ISO 4217 code; it must match the currency of the subscription the coupon is redeemed on. + * + * @param currency the value + * @return this builder + */ + public Builder currency(String currency) { + this.currency = currency; + return this; + } + + /** + * Days the credit stays spendable after redemption, 1 to 3660. Absent: it never expires. + * + * @param expiresInDays the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder expiresInDays(Integer expiresInDays) { + this.expiresInDays = JsonField.ofNullable(expiresInDays); + return this; + } + + /** + * CUSTOMER (default): the credit pays any of the customer's subscriptions. SUBSCRIPTION: + * the credit pays only the subscription the code is redeemed on, and ends with it. + * + * @param scope the value + * @return this builder + */ + public Builder scope(CouponCreditScope scope) { + this.scope = scope; + return this; + } + + /** + * The {@code type} property. + * + * @param type the value + * @return this builder + */ + public Builder type(String type) { + this.type = type; + return this; + } + + /** + * A property the SDK does not know, sent along. + * + * @param name the property name + * @param value the JSON value + * @return this builder + */ + public Builder putAdditionalProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + return this; + } + + /** + * Properties the SDK does not know, sent along. + * + * @param additionalProperties the properties by name + * @return this builder + */ + public Builder putAllAdditionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + + /** + * Leaves out a property the SDK does not know. + * + * @param name the property name + * @return this builder + */ + public Builder removeAdditionalProperty(String name) { + additionalProperties.remove(name); + return this; + } + + /** + * The {@code CreditDiscount}. + * + * @return the immutable value + * @throws IllegalStateException when a required property is not set + */ + public CreditDiscount build() { + Utils.checkRequired(amount, "amount"); + Utils.checkRequired(currency, "currency"); + Utils.checkRequired(type, "type"); + return new CreditDiscount(this); + } + } + + /** + * Parse {@code json} as {@code CreditDiscount}. + * + * @param json the JSON text + * @return the value + * @throws com.meteroid.exceptions.InvalidDataException if it is not valid JSON of this shape + */ + public static CreditDiscount fromJson(String json) { + return Utils.parse(json, CreditDiscount.class); + } + + /** + * This value as JSON. + * + * @return the JSON text + */ + public String toJson() { + return Utils.json(this); + } +} diff --git a/src/main/java/com/meteroid/models/CreditExhaustedRule.java b/src/main/java/com/meteroid/models/CreditExhaustedRule.java new file mode 100644 index 0000000..1789a1d --- /dev/null +++ b/src/main/java/com/meteroid/models/CreditExhaustedRule.java @@ -0,0 +1,495 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonUnwrapped; +import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.Utils; + +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; + +/** + * What usage does once the credit it draws on runs out, for every denomination (currency or credit + * unit) the plan charges usage in. A customer's wallet can override it. + * + *

One of the variants below, told apart by {@code type}. A value this version of the SDK does + * not know parses as {@link Unrecognized}, which keeps its properties. + */ +@JsonTypeInfo( + use = JsonTypeInfo.Id.NAME, + include = JsonTypeInfo.As.EXISTING_PROPERTY, + property = "type", + visible = true, + defaultImpl = CreditExhaustedRule.Unrecognized.class) +@JsonSubTypes({ + @JsonSubTypes.Type(value = CreditExhaustedRule.Invoice.class, name = "invoice"), + @JsonSubTypes.Type(value = CreditExhaustedRule.Pause.class, name = "pause"), + @JsonSubTypes.Type(value = CreditExhaustedRule.InvoiceUpTo.class, name = "invoice_up_to") +}) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonAutoDetect( + getterVisibility = Visibility.NONE, + isGetterVisibility = Visibility.NONE, + setterVisibility = Visibility.NONE) +public abstract class CreditExhaustedRule { + + private CreditExhaustedRule() {} + + /** + * The discriminator value identifying this variant. + * + * @return the {@code type} value + */ + @JsonProperty("type") + public abstract String type(); + + /** + * Whether this is the {@code invoice} variant. + * + * @return whether it is + */ + public final boolean isInvoice() { + return this instanceof Invoice; + } + + /** + * This value as the {@code invoice} variant. + * + * @return the variant + * @throws IllegalStateException if this is another variant + */ + public final Invoice asInvoice() { + if (this instanceof Invoice) { + return (Invoice) this; + } + throw new IllegalStateException("not the invoice variant: " + type()); + } + + /** + * Whether this is the {@code pause} variant. + * + * @return whether it is + */ + public final boolean isPause() { + return this instanceof Pause; + } + + /** + * This value as the {@code pause} variant. + * + * @return the variant + * @throws IllegalStateException if this is another variant + */ + public final Pause asPause() { + if (this instanceof Pause) { + return (Pause) this; + } + throw new IllegalStateException("not the pause variant: " + type()); + } + + /** + * Whether this is the {@code invoice_up_to} variant. + * + * @return whether it is + */ + public final boolean isInvoiceUpTo() { + return this instanceof InvoiceUpTo; + } + + /** + * This value as the {@code invoice_up_to} variant. + * + * @return the variant + * @throws IllegalStateException if this is another variant + */ + public final InvoiceUpTo asInvoiceUpTo() { + if (this instanceof InvoiceUpTo) { + return (InvoiceUpTo) this; + } + throw new IllegalStateException("not the invoice_up_to variant: " + type()); + } + + /** + * Whether this is a variant this version of the SDK does not know. + * + * @return whether it is + */ + public final boolean isUnrecognized() { + return this instanceof Unrecognized; + } + + /** + * This value as a variant this version of the SDK does not know. + * + * @return the variant + * @throws IllegalStateException if this is another variant + */ + public final Unrecognized asUnrecognized() { + if (this instanceof Unrecognized) { + return (Unrecognized) this; + } + throw new IllegalStateException("not a known variant: " + type()); + } + + /** + * Calls the method of {@code visitor} for this variant. + * + * @param the result type + * @param visitor the visitor + * @return the result of the visitor + */ + public abstract R accept(Visitor visitor); + + /** + * A function of each variant, called by {@link #accept}. + * + * @param the result type + */ + public interface Visitor { + /** + * Visits the {@code invoice} variant. + * + * @param value the variant + * @return the result + */ + R visitInvoice(CreditExhaustedRuleInvoiceVariant value); + + /** + * Visits the {@code pause} variant. + * + * @param value the variant + * @return the result + */ + R visitPause(CreditExhaustedRulePauseVariant value); + + /** + * Visits the {@code invoice_up_to} variant. + * + * @param value the variant + * @return the result + */ + R visitInvoiceUpTo(CreditCaps value); + + /** + * Visits a variant this version of the SDK does not know. + * + * @param value the variant, with its properties + * @return the result + * @throws com.meteroid.exceptions.InvalidDataException unless overridden + */ + default R visitUnknown(Unrecognized value) { + throw new com.meteroid.exceptions.InvalidDataException( + "unknown CreditExhaustedRule variant: " + value.type()); + } + } + + /** + * Parse {@code json} as {@code CreditExhaustedRule}. + * + * @param json the JSON text + * @return the value + * @throws com.meteroid.exceptions.InvalidDataException if it is not valid JSON of this shape + */ + public static CreditExhaustedRule fromJson(String json) { + return Utils.parse(json, CreditExhaustedRule.class); + } + + /** + * This value as JSON. + * + * @return the JSON text + */ + public String toJson() { + return Utils.json(this); + } + + /** The {@code invoice} variant. */ + @JsonTypeName("invoice") + public static final class Invoice extends CreditExhaustedRule { + @JsonUnwrapped + @JsonIgnoreProperties(value = "type", allowSetters = true) + private CreditExhaustedRuleInvoiceVariant data; + + private Invoice() {} + + /** + * The variant holding {@code data}. + * + * @param data the value of the variant + */ + public Invoice(CreditExhaustedRuleInvoiceVariant data) { + this.data = Objects.requireNonNull(data, "data"); + } + + /** + * The variant holding {@code data}. + * + * @param data the value of the variant + * @return the variant + */ + public static Invoice of(CreditExhaustedRuleInvoiceVariant data) { + return new Invoice(data); + } + + @Override + @JsonProperty("type") + public String type() { + return "invoice"; + } + + /** + * The value of the variant. + * + * @return the value + */ + public CreditExhaustedRuleInvoiceVariant data() { + return data; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Invoice that = (Invoice) o; + return Objects.equals(data, that.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + return "Invoice{" + "data=" + data + "}"; + } + + @Override + public R accept(Visitor visitor) { + return visitor.visitInvoice(data); + } + } + + /** The {@code pause} variant. */ + @JsonTypeName("pause") + public static final class Pause extends CreditExhaustedRule { + @JsonUnwrapped + @JsonIgnoreProperties(value = "type", allowSetters = true) + private CreditExhaustedRulePauseVariant data; + + private Pause() {} + + /** + * The variant holding {@code data}. + * + * @param data the value of the variant + */ + public Pause(CreditExhaustedRulePauseVariant data) { + this.data = Objects.requireNonNull(data, "data"); + } + + /** + * The variant holding {@code data}. + * + * @param data the value of the variant + * @return the variant + */ + public static Pause of(CreditExhaustedRulePauseVariant data) { + return new Pause(data); + } + + @Override + @JsonProperty("type") + public String type() { + return "pause"; + } + + /** + * The value of the variant. + * + * @return the value + */ + public CreditExhaustedRulePauseVariant data() { + return data; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Pause that = (Pause) o; + return Objects.equals(data, that.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + return "Pause{" + "data=" + data + "}"; + } + + @Override + public R accept(Visitor visitor) { + return visitor.visitPause(data); + } + } + + /** The {@code invoice_up_to} variant. */ + @JsonTypeName("invoice_up_to") + public static final class InvoiceUpTo extends CreditExhaustedRule { + @JsonUnwrapped + @JsonIgnoreProperties(value = "type", allowSetters = true) + private CreditCaps data; + + private InvoiceUpTo() {} + + /** + * The variant holding {@code data}. + * + * @param data the value of the variant + */ + public InvoiceUpTo(CreditCaps data) { + this.data = Objects.requireNonNull(data, "data"); + } + + /** + * The variant holding {@code data}. + * + * @param data the value of the variant + * @return the variant + */ + public static InvoiceUpTo of(CreditCaps data) { + return new InvoiceUpTo(data); + } + + @Override + @JsonProperty("type") + public String type() { + return "invoice_up_to"; + } + + /** + * The value of the variant. + * + * @return the value + */ + public CreditCaps data() { + return data; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + InvoiceUpTo that = (InvoiceUpTo) o; + return Objects.equals(data, that.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + return "InvoiceUpTo{" + "data=" + data + "}"; + } + + @Override + public R accept(Visitor visitor) { + return visitor.visitInvoiceUpTo(data); + } + } + + /** A variant this version of the SDK does not know. */ + public static final class Unrecognized extends CreditExhaustedRule { + @JsonProperty("type") + private String discriminator; + + private final Map properties = new LinkedHashMap<>(); + + private Unrecognized() {} + + @Override + @JsonProperty("type") + public String type() { + return discriminator; + } + + @Override + public R accept(Visitor visitor) { + return visitor.visitUnknown(this); + } + + /** + * Every other property of the variant. + * + * @return the properties by name, unmodifiable + */ + @JsonAnyGetter + public Map properties() { + return Collections.unmodifiableMap(properties); + } + + @JsonAnySetter + private void putProperty(String name, JsonNode value) { + properties.put(name, value); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Unrecognized that = (Unrecognized) o; + return Objects.equals(discriminator, that.discriminator) + && Objects.equals(properties, that.properties); + } + + @Override + public int hashCode() { + return Objects.hash(discriminator, properties); + } + + @Override + public String toString() { + return "Unrecognized{" + + "discriminator=" + + discriminator + + ", properties=" + + properties + + "}"; + } + } +} diff --git a/src/main/java/com/meteroid/models/CreditExhaustedRuleInvoiceVariant.java b/src/main/java/com/meteroid/models/CreditExhaustedRuleInvoiceVariant.java new file mode 100644 index 0000000..42765c1 --- /dev/null +++ b/src/main/java/com/meteroid/models/CreditExhaustedRuleInvoiceVariant.java @@ -0,0 +1,203 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.Utils; + +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; + +/** + * Usage beyond the credit is invoiced. + * + *

Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonAutoDetect( + getterVisibility = Visibility.NONE, + isGetterVisibility = Visibility.NONE, + setterVisibility = Visibility.NONE) +public final class CreditExhaustedRuleInvoiceVariant { + @JsonProperty("type") + private String type = "invoice"; + + private final Map additionalProperties = new LinkedHashMap<>(); + + private CreditExhaustedRuleInvoiceVariant() {} + + private CreditExhaustedRuleInvoiceVariant(Builder builder) { + this.type = builder.type; + this.additionalProperties.putAll(builder.additionalProperties); + } + + /** + * A builder of {@code CreditExhaustedRuleInvoiceVariant}. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * A builder starting from this value. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.type = type; + builder.additionalProperties.putAll(additionalProperties); + return builder; + } + + /** + * The {@code type} property. + * + * @return the value, never null + */ + public String type() { + return Utils.required(type, "type"); + } + + /** + * Properties this version of the SDK does not know, kept as received and sent back. + * + * @return the properties by name, unmodifiable + */ + public Map additionalProperties() { + return Collections.unmodifiableMap(additionalProperties); + } + + @JsonAnyGetter + private Map anyProperties() { + return additionalProperties; + } + + @JsonAnySetter + private void putAnyProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CreditExhaustedRuleInvoiceVariant that = (CreditExhaustedRuleInvoiceVariant) o; + return Objects.equals(type, that.type) + && Objects.equals(additionalProperties, that.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(type, additionalProperties); + } + + @Override + public String toString() { + return "CreditExhaustedRuleInvoiceVariant{" + + "type=" + + type + + ", additionalProperties=" + + additionalProperties + + "}"; + } + + /** Builds {@link CreditExhaustedRuleInvoiceVariant}. */ + public static final class Builder { + private String type = "invoice"; + private final Map additionalProperties = new LinkedHashMap<>(); + + private Builder() {} + + /** + * The {@code type} property. + * + * @param type the value + * @return this builder + */ + public Builder type(String type) { + this.type = type; + return this; + } + + /** + * A property the SDK does not know, sent along. + * + * @param name the property name + * @param value the JSON value + * @return this builder + */ + public Builder putAdditionalProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + return this; + } + + /** + * Properties the SDK does not know, sent along. + * + * @param additionalProperties the properties by name + * @return this builder + */ + public Builder putAllAdditionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + + /** + * Leaves out a property the SDK does not know. + * + * @param name the property name + * @return this builder + */ + public Builder removeAdditionalProperty(String name) { + additionalProperties.remove(name); + return this; + } + + /** + * The {@code CreditExhaustedRuleInvoiceVariant}. + * + * @return the immutable value + * @throws IllegalStateException when a required property is not set + */ + public CreditExhaustedRuleInvoiceVariant build() { + Utils.checkRequired(type, "type"); + return new CreditExhaustedRuleInvoiceVariant(this); + } + } + + /** + * Parse {@code json} as {@code CreditExhaustedRuleInvoiceVariant}. + * + * @param json the JSON text + * @return the value + * @throws com.meteroid.exceptions.InvalidDataException if it is not valid JSON of this shape + */ + public static CreditExhaustedRuleInvoiceVariant fromJson(String json) { + return Utils.parse(json, CreditExhaustedRuleInvoiceVariant.class); + } + + /** + * This value as JSON. + * + * @return the JSON text + */ + public String toJson() { + return Utils.json(this); + } +} diff --git a/src/main/java/com/meteroid/models/CreditExhaustedRulePauseVariant.java b/src/main/java/com/meteroid/models/CreditExhaustedRulePauseVariant.java new file mode 100644 index 0000000..94eca79 --- /dev/null +++ b/src/main/java/com/meteroid/models/CreditExhaustedRulePauseVariant.java @@ -0,0 +1,203 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.Utils; + +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; + +/** + * Access checks refuse usage once the credit the subscription can spend is used up. + * + *

Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonAutoDetect( + getterVisibility = Visibility.NONE, + isGetterVisibility = Visibility.NONE, + setterVisibility = Visibility.NONE) +public final class CreditExhaustedRulePauseVariant { + @JsonProperty("type") + private String type = "pause"; + + private final Map additionalProperties = new LinkedHashMap<>(); + + private CreditExhaustedRulePauseVariant() {} + + private CreditExhaustedRulePauseVariant(Builder builder) { + this.type = builder.type; + this.additionalProperties.putAll(builder.additionalProperties); + } + + /** + * A builder of {@code CreditExhaustedRulePauseVariant}. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * A builder starting from this value. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.type = type; + builder.additionalProperties.putAll(additionalProperties); + return builder; + } + + /** + * The {@code type} property. + * + * @return the value, never null + */ + public String type() { + return Utils.required(type, "type"); + } + + /** + * Properties this version of the SDK does not know, kept as received and sent back. + * + * @return the properties by name, unmodifiable + */ + public Map additionalProperties() { + return Collections.unmodifiableMap(additionalProperties); + } + + @JsonAnyGetter + private Map anyProperties() { + return additionalProperties; + } + + @JsonAnySetter + private void putAnyProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CreditExhaustedRulePauseVariant that = (CreditExhaustedRulePauseVariant) o; + return Objects.equals(type, that.type) + && Objects.equals(additionalProperties, that.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(type, additionalProperties); + } + + @Override + public String toString() { + return "CreditExhaustedRulePauseVariant{" + + "type=" + + type + + ", additionalProperties=" + + additionalProperties + + "}"; + } + + /** Builds {@link CreditExhaustedRulePauseVariant}. */ + public static final class Builder { + private String type = "pause"; + private final Map additionalProperties = new LinkedHashMap<>(); + + private Builder() {} + + /** + * The {@code type} property. + * + * @param type the value + * @return this builder + */ + public Builder type(String type) { + this.type = type; + return this; + } + + /** + * A property the SDK does not know, sent along. + * + * @param name the property name + * @param value the JSON value + * @return this builder + */ + public Builder putAdditionalProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + return this; + } + + /** + * Properties the SDK does not know, sent along. + * + * @param additionalProperties the properties by name + * @return this builder + */ + public Builder putAllAdditionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + + /** + * Leaves out a property the SDK does not know. + * + * @param name the property name + * @return this builder + */ + public Builder removeAdditionalProperty(String name) { + additionalProperties.remove(name); + return this; + } + + /** + * The {@code CreditExhaustedRulePauseVariant}. + * + * @return the immutable value + * @throws IllegalStateException when a required property is not set + */ + public CreditExhaustedRulePauseVariant build() { + Utils.checkRequired(type, "type"); + return new CreditExhaustedRulePauseVariant(this); + } + } + + /** + * Parse {@code json} as {@code CreditExhaustedRulePauseVariant}. + * + * @param json the JSON text + * @return the value + * @throws com.meteroid.exceptions.InvalidDataException if it is not valid JSON of this shape + */ + public static CreditExhaustedRulePauseVariant fromJson(String json) { + return Utils.parse(json, CreditExhaustedRulePauseVariant.class); + } + + /** + * This value as JSON. + * + * @return the JSON text + */ + public String toJson() { + return Utils.json(this); + } +} diff --git a/src/main/java/com/meteroid/models/CreditExpiryUnit.java b/src/main/java/com/meteroid/models/CreditExpiryUnit.java new file mode 100644 index 0000000..cfb1d56 --- /dev/null +++ b/src/main/java/com/meteroid/models/CreditExpiryUnit.java @@ -0,0 +1,136 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import com.meteroid.internal.Utils.ToQueryParam; + +import java.util.Map; +import java.util.Objects; + +/** + * Values this version of the SDK does not know are kept, and sent back unchanged: {@link #value()} + * is an enum to switch on, {@code _UNKNOWN} for them, and {@link #known()} throws on them. + */ +public final class CreditExpiryUnit implements ToQueryParam { + /** The value {@code "DAY"}. */ + public static final CreditExpiryUnit DAY = new CreditExpiryUnit("DAY", Value.DAY); + + /** The value {@code "MONTH"}. */ + public static final CreditExpiryUnit MONTH = new CreditExpiryUnit("MONTH", Value.MONTH); + + /** The value {@code "BILLING_PERIOD"}. */ + public static final CreditExpiryUnit BILLING_PERIOD = + new CreditExpiryUnit("BILLING_PERIOD", Value.BILLING_PERIOD); + + private static final Map constants = + Map.ofEntries( + Map.entry("DAY", DAY), + Map.entry("MONTH", MONTH), + Map.entry("BILLING_PERIOD", BILLING_PERIOD)); + + private final String value; + private final Value variant; + + private CreditExpiryUnit(String value, Value variant) { + this.value = value; + this.variant = variant; + } + + /** + * The constant for {@code value}, or an unknown CreditExpiryUnit holding it. + * + * @param value the value + * @return the constant + */ + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static CreditExpiryUnit of(String value) { + CreditExpiryUnit constant = constants.get(Objects.requireNonNull(value, "value")); + return constant != null ? constant : new CreditExpiryUnit(value, Value._UNKNOWN); + } + + /** + * The value as sent. + * + * @return the value + */ + @JsonValue + public String asString() { + return value; + } + + /** + * Whether this version of the SDK knows the value. + * + * @return whether it is known + */ + public boolean isKnown() { + return variant != Value._UNKNOWN; + } + + /** + * The value as an enum to switch on, unknown values included. + * + * @return the enum, {@code _UNKNOWN} when unknown + */ + public Value value() { + return variant; + } + + /** + * The value as an enum of the known values only. + * + * @return the enum + * @throws com.meteroid.exceptions.InvalidDataException when this version of the SDK does not + * know the value + */ + public Known known() { + if (!isKnown()) { + throw new com.meteroid.exceptions.InvalidDataException( + "unknown CreditExpiryUnit: " + value); + } + return Known.valueOf(variant.name()); + } + + @Override + public String toQueryParam() { + return String.valueOf(value); + } + + @Override + public boolean equals(Object o) { + return o instanceof CreditExpiryUnit && Objects.equals(value, ((CreditExpiryUnit) o).value); + } + + @Override + public int hashCode() { + return Objects.hashCode(value); + } + + @Override + public String toString() { + return String.valueOf(value); + } + + /** The values this version of the SDK knows. */ + public enum Known { + /** The {@code DAY} constant. */ + DAY, + /** The {@code MONTH} constant. */ + MONTH, + /** The {@code BILLING_PERIOD} constant. */ + BILLING_PERIOD + } + + /** The values this version of the SDK knows, and {@code _UNKNOWN} for the others. */ + public enum Value { + /** The {@code DAY} constant. */ + DAY, + /** The {@code MONTH} constant. */ + MONTH, + /** The {@code BILLING_PERIOD} constant. */ + BILLING_PERIOD, + /** A value this version of the SDK does not know. */ + _UNKNOWN + } +} diff --git a/src/main/java/com/meteroid/models/CreditFee.java b/src/main/java/com/meteroid/models/CreditFee.java new file mode 100644 index 0000000..633abf9 --- /dev/null +++ b/src/main/java/com/meteroid/models/CreditFee.java @@ -0,0 +1,432 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.JsonField; +import com.meteroid.internal.Utils; + +import java.math.BigDecimal; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +/** + * A credit pack: charged like a fixed fee, it grants credit_amount × quantity + * of credit once paid, in the subscription currency or in credit_unit. A zero + * unit_price makes it credit included with the plan (promotional). A currency pack + * priced below its credit grants the price paid as paid credit and the difference as promotional + * bonus credit, which applies before tax. + * + *

Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonAutoDetect( + getterVisibility = Visibility.NONE, + isGetterVisibility = Visibility.NONE, + setterVisibility = Visibility.NONE) +public final class CreditFee { + @JsonProperty("credit_amount") + private BigDecimal creditAmount; + + @JsonProperty("credit_unit") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField creditUnit = JsonField.missing(); + + @JsonProperty("expiry") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField expiry = JsonField.missing(); + + @JsonProperty("once") + private Boolean once; + + @JsonProperty("quantity") + private Integer quantity; + + @JsonProperty("rollover") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField rollover = JsonField.missing(); + + @JsonProperty("type") + private String type = "CREDIT"; + + @JsonProperty("unit_price") + private BigDecimal unitPrice; + + private final Map additionalProperties = new LinkedHashMap<>(); + + private CreditFee() {} + + private CreditFee(Builder builder) { + this.creditAmount = builder.creditAmount; + this.creditUnit = builder.creditUnit; + this.expiry = builder.expiry; + this.once = builder.once; + this.quantity = builder.quantity; + this.rollover = builder.rollover; + this.type = builder.type; + this.unitPrice = builder.unitPrice; + this.additionalProperties.putAll(builder.additionalProperties); + } + + /** + * A builder of {@code CreditFee}. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * A builder starting from this value. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.creditAmount = creditAmount; + builder.creditUnit = creditUnit; + builder.expiry = expiry; + builder.once = once; + builder.quantity = quantity; + builder.rollover = rollover; + builder.type = type; + builder.unitPrice = unitPrice; + builder.additionalProperties.putAll(additionalProperties); + return builder; + } + + /** + * Credit granted per pack, in major units of the subscription currency, or a number of credits + * of credit_unit when set. + * + * @return the value, never null + */ + public BigDecimal creditAmount() { + return Utils.required(creditAmount, "credit_amount"); + } + + /** + * The {@code credit_unit} property. + * + * @return the value, empty when unset or null + */ + public Optional creditUnit() { + return creditUnit.asOptional(); + } + + /** + * The {@code expiry} property. + * + * @return the value, empty when unset or null + */ + public Optional expiry() { + return expiry.asOptional(); + } + + /** + * When true, billed and granted once, on the subscription's first invoice, instead of every + * period. + * + * @return the value, empty when unset + */ + public Optional once() { + return Optional.ofNullable(once); + } + + /** + * Packs billed and granted each time. + * + * @return the value, never null + */ + public Integer quantity() { + return Utils.required(quantity, "quantity"); + } + + /** + * The {@code rollover} property. + * + * @return the value, empty when unset or null + */ + public Optional rollover() { + return rollover.asOptional(); + } + + /** + * The {@code type} property. + * + * @return the value, never null + */ + public String type() { + return Utils.required(type, "type"); + } + + /** + * Price of one pack, in major units of the subscription currency. + * + * @return the value, never null + */ + public BigDecimal unitPrice() { + return Utils.required(unitPrice, "unit_price"); + } + + /** + * Properties this version of the SDK does not know, kept as received and sent back. + * + * @return the properties by name, unmodifiable + */ + public Map additionalProperties() { + return Collections.unmodifiableMap(additionalProperties); + } + + @JsonAnyGetter + private Map anyProperties() { + return additionalProperties; + } + + @JsonAnySetter + private void putAnyProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CreditFee that = (CreditFee) o; + return Objects.equals(creditAmount, that.creditAmount) + && Objects.equals(creditUnit, that.creditUnit) + && Objects.equals(expiry, that.expiry) + && Objects.equals(once, that.once) + && Objects.equals(quantity, that.quantity) + && Objects.equals(rollover, that.rollover) + && Objects.equals(type, that.type) + && Objects.equals(unitPrice, that.unitPrice) + && Objects.equals(additionalProperties, that.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash( + creditAmount, + creditUnit, + expiry, + once, + quantity, + rollover, + type, + unitPrice, + additionalProperties); + } + + @Override + public String toString() { + return "CreditFee{" + + "creditAmount=" + + creditAmount + + ", creditUnit=" + + creditUnit + + ", expiry=" + + expiry + + ", once=" + + once + + ", quantity=" + + quantity + + ", rollover=" + + rollover + + ", type=" + + type + + ", unitPrice=" + + unitPrice + + ", additionalProperties=" + + additionalProperties + + "}"; + } + + /** Builds {@link CreditFee}. */ + public static final class Builder { + private BigDecimal creditAmount; + private JsonField creditUnit = JsonField.missing(); + private JsonField expiry = JsonField.missing(); + private Boolean once; + private Integer quantity; + private JsonField rollover = JsonField.missing(); + private String type = "CREDIT"; + private BigDecimal unitPrice; + private final Map additionalProperties = new LinkedHashMap<>(); + + private Builder() {} + + /** + * Credit granted per pack, in major units of the subscription currency, or a number of + * credits of credit_unit when set. + * + * @param creditAmount the value + * @return this builder + */ + public Builder creditAmount(BigDecimal creditAmount) { + this.creditAmount = creditAmount; + return this; + } + + /** + * The {@code credit_unit} property. + * + * @param creditUnit the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder creditUnit(CreditPackUnit creditUnit) { + this.creditUnit = JsonField.ofNullable(creditUnit); + return this; + } + + /** + * The {@code expiry} property. + * + * @param expiry the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder expiry(CreditPackExpiry expiry) { + this.expiry = JsonField.ofNullable(expiry); + return this; + } + + /** + * When true, billed and granted once, on the subscription's first invoice, instead of every + * period. + * + * @param once the value + * @return this builder + */ + public Builder once(Boolean once) { + this.once = once; + return this; + } + + /** + * Packs billed and granted each time. + * + * @param quantity the value + * @return this builder + */ + public Builder quantity(Integer quantity) { + this.quantity = quantity; + return this; + } + + /** + * The {@code rollover} property. + * + * @param rollover the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder rollover(CreditPackRollover rollover) { + this.rollover = JsonField.ofNullable(rollover); + return this; + } + + /** + * The {@code type} property. + * + * @param type the value + * @return this builder + */ + public Builder type(String type) { + this.type = type; + return this; + } + + /** + * Price of one pack, in major units of the subscription currency. + * + * @param unitPrice the value + * @return this builder + */ + public Builder unitPrice(BigDecimal unitPrice) { + this.unitPrice = unitPrice; + return this; + } + + /** + * A property the SDK does not know, sent along. + * + * @param name the property name + * @param value the JSON value + * @return this builder + */ + public Builder putAdditionalProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + return this; + } + + /** + * Properties the SDK does not know, sent along. + * + * @param additionalProperties the properties by name + * @return this builder + */ + public Builder putAllAdditionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + + /** + * Leaves out a property the SDK does not know. + * + * @param name the property name + * @return this builder + */ + public Builder removeAdditionalProperty(String name) { + additionalProperties.remove(name); + return this; + } + + /** + * The {@code CreditFee}. + * + * @return the immutable value + * @throws IllegalStateException when a required property is not set + */ + public CreditFee build() { + Utils.checkRequired(creditAmount, "credit_amount"); + Utils.checkRequired(quantity, "quantity"); + Utils.checkRequired(type, "type"); + Utils.checkRequired(unitPrice, "unit_price"); + return new CreditFee(this); + } + } + + /** + * Parse {@code json} as {@code CreditFee}. + * + * @param json the JSON text + * @return the value + * @throws com.meteroid.exceptions.InvalidDataException if it is not valid JSON of this shape + */ + public static CreditFee fromJson(String json) { + return Utils.parse(json, CreditFee.class); + } + + /** + * This value as JSON. + * + * @return the JSON text + */ + public String toJson() { + return Utils.json(this); + } +} diff --git a/src/main/java/com/meteroid/models/CreditFeeStructure.java b/src/main/java/com/meteroid/models/CreditFeeStructure.java new file mode 100644 index 0000000..881b179 --- /dev/null +++ b/src/main/java/com/meteroid/models/CreditFeeStructure.java @@ -0,0 +1,199 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.Utils; + +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; + +/** Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonAutoDetect( + getterVisibility = Visibility.NONE, + isGetterVisibility = Visibility.NONE, + setterVisibility = Visibility.NONE) +public final class CreditFeeStructure { + @JsonProperty("type") + private String type = "CREDIT"; + + private final Map additionalProperties = new LinkedHashMap<>(); + + private CreditFeeStructure() {} + + private CreditFeeStructure(Builder builder) { + this.type = builder.type; + this.additionalProperties.putAll(builder.additionalProperties); + } + + /** + * A builder of {@code CreditFeeStructure}. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * A builder starting from this value. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.type = type; + builder.additionalProperties.putAll(additionalProperties); + return builder; + } + + /** + * The {@code type} property. + * + * @return the value, never null + */ + public String type() { + return Utils.required(type, "type"); + } + + /** + * Properties this version of the SDK does not know, kept as received and sent back. + * + * @return the properties by name, unmodifiable + */ + public Map additionalProperties() { + return Collections.unmodifiableMap(additionalProperties); + } + + @JsonAnyGetter + private Map anyProperties() { + return additionalProperties; + } + + @JsonAnySetter + private void putAnyProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CreditFeeStructure that = (CreditFeeStructure) o; + return Objects.equals(type, that.type) + && Objects.equals(additionalProperties, that.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(type, additionalProperties); + } + + @Override + public String toString() { + return "CreditFeeStructure{" + + "type=" + + type + + ", additionalProperties=" + + additionalProperties + + "}"; + } + + /** Builds {@link CreditFeeStructure}. */ + public static final class Builder { + private String type = "CREDIT"; + private final Map additionalProperties = new LinkedHashMap<>(); + + private Builder() {} + + /** + * The {@code type} property. + * + * @param type the value + * @return this builder + */ + public Builder type(String type) { + this.type = type; + return this; + } + + /** + * A property the SDK does not know, sent along. + * + * @param name the property name + * @param value the JSON value + * @return this builder + */ + public Builder putAdditionalProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + return this; + } + + /** + * Properties the SDK does not know, sent along. + * + * @param additionalProperties the properties by name + * @return this builder + */ + public Builder putAllAdditionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + + /** + * Leaves out a property the SDK does not know. + * + * @param name the property name + * @return this builder + */ + public Builder removeAdditionalProperty(String name) { + additionalProperties.remove(name); + return this; + } + + /** + * The {@code CreditFeeStructure}. + * + * @return the immutable value + * @throws IllegalStateException when a required property is not set + */ + public CreditFeeStructure build() { + Utils.checkRequired(type, "type"); + return new CreditFeeStructure(this); + } + } + + /** + * Parse {@code json} as {@code CreditFeeStructure}. + * + * @param json the JSON text + * @return the value + * @throws com.meteroid.exceptions.InvalidDataException if it is not valid JSON of this shape + */ + public static CreditFeeStructure fromJson(String json) { + return Utils.parse(json, CreditFeeStructure.class); + } + + /** + * This value as JSON. + * + * @return the JSON text + */ + public String toJson() { + return Utils.json(this); + } +} diff --git a/src/main/java/com/meteroid/models/CreditGrant.java b/src/main/java/com/meteroid/models/CreditGrant.java new file mode 100644 index 0000000..bf7db9e --- /dev/null +++ b/src/main/java/com/meteroid/models/CreditGrant.java @@ -0,0 +1,1052 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.JsonField; +import com.meteroid.internal.Utils; + +import java.time.OffsetDateTime; +import java.util.ArrayList; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +/** + * A lot of credit given to or bought by a customer. An invoice applies promotional currency credit + * before tax and paid credit after it. Within each, it draws the grants that belong to the invoiced + * subscription first, then grants restricted to products (the fewest products first), then + * usage-only grants, then the others; then by lowest priority, then the soonest to + * lapse. + * + *

Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonAutoDetect( + getterVisibility = Visibility.NONE, + isGetterVisibility = Visibility.NONE, + setterVisibility = Visibility.NONE) +public final class CreditGrant { + @JsonProperty("amount") + private Long amount; + + @JsonProperty("applicable_product_ids") + private List applicableProductIds; + + @JsonProperty("applies_to") + private CreditAppliesTo appliesTo; + + @JsonProperty("bonus_grant_id") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField bonusGrantId = JsonField.missing(); + + @JsonProperty("cost") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField cost = JsonField.missing(); + + @JsonProperty("cost_basis") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField costBasis = JsonField.missing(); + + @JsonProperty("created_at") + private OffsetDateTime createdAt; + + @JsonProperty("credit_note_id") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField creditNoteId = JsonField.missing(); + + @JsonProperty("credit_unit") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField creditUnit = JsonField.missing(); + + @JsonProperty("credit_unit_precision") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField creditUnitPrecision = JsonField.missing(); + + @JsonProperty("currency") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField currency = JsonField.missing(); + + @JsonProperty("effective_at") + private OffsetDateTime effectiveAt; + + @JsonProperty("ended_at") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField endedAt = JsonField.missing(); + + @JsonProperty("expired_amount") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField expiredAmount = JsonField.missing(); + + @JsonProperty("expires_at") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField expiresAt = JsonField.missing(); + + @JsonProperty("id") + private String id; + + @JsonProperty("invoice_id") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField invoiceId = JsonField.missing(); + + @JsonProperty("kind") + private CreditGrantKind kind; + + @JsonProperty("kind_label") + private String kindLabel; + + @JsonProperty("priority") + private Integer priority; + + @JsonProperty("reason") + private String reason; + + @JsonProperty("reference") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField reference = JsonField.missing(); + + @JsonProperty("remaining") + private Long remaining; + + @JsonProperty("source") + private CreditGrantSource source; + + @JsonProperty("status") + private CreditGrantStatus status; + + @JsonProperty("subscription_id") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField subscriptionId = JsonField.missing(); + + @JsonProperty("type") + private CreditGrantType type; + + private final Map additionalProperties = new LinkedHashMap<>(); + + private CreditGrant() {} + + private CreditGrant(Builder builder) { + this.amount = builder.amount; + this.applicableProductIds = Utils.copyList(builder.applicableProductIds); + this.appliesTo = builder.appliesTo; + this.bonusGrantId = builder.bonusGrantId; + this.cost = builder.cost; + this.costBasis = builder.costBasis; + this.createdAt = builder.createdAt; + this.creditNoteId = builder.creditNoteId; + this.creditUnit = builder.creditUnit; + this.creditUnitPrecision = builder.creditUnitPrecision; + this.currency = builder.currency; + this.effectiveAt = builder.effectiveAt; + this.endedAt = builder.endedAt; + this.expiredAmount = builder.expiredAmount; + this.expiresAt = builder.expiresAt; + this.id = builder.id; + this.invoiceId = builder.invoiceId; + this.kind = builder.kind; + this.kindLabel = builder.kindLabel; + this.priority = builder.priority; + this.reason = builder.reason; + this.reference = builder.reference; + this.remaining = builder.remaining; + this.source = builder.source; + this.status = builder.status; + this.subscriptionId = builder.subscriptionId; + this.type = builder.type; + this.additionalProperties.putAll(builder.additionalProperties); + } + + /** + * A builder of {@code CreditGrant}. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * A builder starting from this value. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.amount = amount; + builder.applicableProductIds = Utils.mutableList(applicableProductIds); + builder.appliesTo = appliesTo; + builder.bonusGrantId = bonusGrantId; + builder.cost = cost; + builder.costBasis = costBasis; + builder.createdAt = createdAt; + builder.creditNoteId = creditNoteId; + builder.creditUnit = creditUnit; + builder.creditUnitPrecision = creditUnitPrecision; + builder.currency = currency; + builder.effectiveAt = effectiveAt; + builder.endedAt = endedAt; + builder.expiredAmount = expiredAmount; + builder.expiresAt = expiresAt; + builder.id = id; + builder.invoiceId = invoiceId; + builder.kind = kind; + builder.kindLabel = kindLabel; + builder.priority = priority; + builder.reason = reason; + builder.reference = reference; + builder.remaining = remaining; + builder.source = source; + builder.status = status; + builder.subscriptionId = subscriptionId; + builder.type = type; + builder.additionalProperties.putAll(additionalProperties); + return builder; + } + + /** + * Amount granted, in minor units of currency or credit_unit. + * + * @return the value, never null + */ + public Long amount() { + return Utils.required(amount, "amount"); + } + + /** + * The products whose charges the credit pays, combined with applies_to; empty when + * it applies to every product. + * + * @return the value, never null + */ + public List applicableProductIds() { + return Utils.required(applicableProductIds, "applicable_product_ids"); + } + + /** + * ALL pays any charge on an invoice; USAGE only usage charges. + * + * @return the value, never null + */ + public CreditAppliesTo appliesTo() { + return Utils.required(appliesTo, "applies_to"); + } + + /** + * Only on the response that created a PAID currency grant whose cost was below its + * amount: the PROMOTIONAL "Bonus credit" grant created beside it for the difference, with the + * same expiry, scope and priority. + * + * @return the value, empty when unset or null + */ + public Optional bonusGrantId() { + return bonusGrantId.asOptional(); + } + + /** + * The {@code cost} property. + * + * @return the value, empty when unset or null + */ + public Optional cost() { + return cost.asOptional(); + } + + /** + * cost per one major unit of credit, in major units of the cost currency (e.g. + * "0.008"), rounded to 12 decimal places, for display only. + * + * @return the value, empty when unset or null + */ + public Optional costBasis() { + return costBasis.asOptional(); + } + + /** + * When the grant was recorded. + * + * @return the value, never null + */ + public OffsetDateTime createdAt() { + return Utils.required(createdAt, "created_at"); + } + + /** + * The credit note that gave the credit back. + * + * @return the value, empty when unset or null + */ + public Optional creditNoteId() { + return creditNoteId.asOptional(); + } + + /** + * The credit unit (its code) the amounts are in; absent for a currency. + * + * @return the value, empty when unset or null + */ + public Optional creditUnit() { + return creditUnit.asOptional(); + } + + /** + * Decimal places of credit_unit: amounts are integers of 10^-precision credit. + * + * @return the value, empty when unset or null + */ + public Optional creditUnitPrecision() { + return creditUnitPrecision.asOptional(); + } + + /** + * The {@code currency} property. + * + * @return the value, empty when unset or null + */ + public Optional currency() { + return currency.asOptional(); + } + + /** + * When the credit became spendable. + * + * @return the value, never null + */ + public OffsetDateTime effectiveAt() { + return Utils.required(effectiveAt, "effective_at"); + } + + /** + * When the subscription the grant belongs to ended, if it ended. Unspent credit lapses then + * (status EXPIRED), even before expires_at. + * + * @return the value, empty when unset or null + */ + public Optional endedAt() { + return endedAt.asOptional(); + } + + /** + * Lost to expiry; present only on an expired grant. + * + * @return the value, empty when unset or null + */ + public Optional expiredAmount() { + return expiredAmount.asOptional(); + } + + /** + * When unspent credit lapses; absent never expires. + * + * @return the value, empty when unset or null + */ + public Optional expiresAt() { + return expiresAt.asOptional(); + } + + /** + * The grant's id (cgr_…). + * + * @return the value, never null + */ + public String id() { + return Utils.required(id, "id"); + } + + /** + * The invoice that sold the credit, or whose void or negative total gave it back. + * + * @return the value, empty when unset or null + */ + public Optional invoiceId() { + return invoiceId.asOptional(); + } + + /** + * The group the grant is shown in: INCLUDED, PREPAID, BONUS or ACCOUNT_BALANCE. + * + * @return the value, never null + */ + public CreditGrantKind kind() { + return Utils.required(kind, "kind"); + } + + /** + * The group's name as Meteroid shows it: "Included with <plan>", "Purchased credit", + * "Free credit" or "Account balance". + * + * @return the value, never null + */ + public String kindLabel() { + return Utils.required(kindLabel, "kind_label"); + } + + /** + * Lower values are drawn first among grants of the same type that pay the same charges; 100 by + * default. + * + * @return the value, never null + */ + public Integer priority() { + return Utils.required(priority, "priority"); + } + + /** + * Shown on the credit ledger. + * + * @return the value, never null + */ + public String reason() { + return Utils.required(reason, "reason"); + } + + /** + * Your own reference, e.g. a contract or support ticket. + * + * @return the value, empty when unset or null + */ + public Optional reference() { + return reference.asOptional(); + } + + /** + * Not spent yet, in the same minor units. + * + * @return the value, never null + */ + public Long remaining() { + return Utils.required(remaining, "remaining"); + } + + /** + * Where the credit came from. + * + * @return the value, never null + */ + public CreditGrantSource source() { + return Utils.required(source, "source"); + } + + /** + * PENDING until effective_at, then ACTIVE, DEPLETED once spent, or EXPIRED. + * + * @return the value, never null + */ + public CreditGrantStatus status() { + return Utils.required(status, "status"); + } + + /** + * The subscription the grant belongs to (sub_…): it pays only that subscription's + * charges, and lapses when the subscription ends. Null when it pays any of the customer's + * subscriptions. + * + * @return the value, empty when unset or null + */ + public Optional subscriptionId() { + return subscriptionId.asOptional(); + } + + /** + * PAID or PROMOTIONAL: whether it applies after or before tax. + * + * @return the value, never null + */ + public CreditGrantType type() { + return Utils.required(type, "type"); + } + + /** + * Properties this version of the SDK does not know, kept as received and sent back. + * + * @return the properties by name, unmodifiable + */ + public Map additionalProperties() { + return Collections.unmodifiableMap(additionalProperties); + } + + @JsonAnyGetter + private Map anyProperties() { + return additionalProperties; + } + + @JsonAnySetter + private void putAnyProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CreditGrant that = (CreditGrant) o; + return Objects.equals(amount, that.amount) + && Objects.equals(applicableProductIds, that.applicableProductIds) + && Objects.equals(appliesTo, that.appliesTo) + && Objects.equals(bonusGrantId, that.bonusGrantId) + && Objects.equals(cost, that.cost) + && Objects.equals(costBasis, that.costBasis) + && Objects.equals(createdAt, that.createdAt) + && Objects.equals(creditNoteId, that.creditNoteId) + && Objects.equals(creditUnit, that.creditUnit) + && Objects.equals(creditUnitPrecision, that.creditUnitPrecision) + && Objects.equals(currency, that.currency) + && Objects.equals(effectiveAt, that.effectiveAt) + && Objects.equals(endedAt, that.endedAt) + && Objects.equals(expiredAmount, that.expiredAmount) + && Objects.equals(expiresAt, that.expiresAt) + && Objects.equals(id, that.id) + && Objects.equals(invoiceId, that.invoiceId) + && Objects.equals(kind, that.kind) + && Objects.equals(kindLabel, that.kindLabel) + && Objects.equals(priority, that.priority) + && Objects.equals(reason, that.reason) + && Objects.equals(reference, that.reference) + && Objects.equals(remaining, that.remaining) + && Objects.equals(source, that.source) + && Objects.equals(status, that.status) + && Objects.equals(subscriptionId, that.subscriptionId) + && Objects.equals(type, that.type) + && Objects.equals(additionalProperties, that.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash( + amount, + applicableProductIds, + appliesTo, + bonusGrantId, + cost, + costBasis, + createdAt, + creditNoteId, + creditUnit, + creditUnitPrecision, + currency, + effectiveAt, + endedAt, + expiredAmount, + expiresAt, + id, + invoiceId, + kind, + kindLabel, + priority, + reason, + reference, + remaining, + source, + status, + subscriptionId, + type, + additionalProperties); + } + + @Override + public String toString() { + return "CreditGrant{" + + "amount=" + + amount + + ", applicableProductIds=" + + applicableProductIds + + ", appliesTo=" + + appliesTo + + ", bonusGrantId=" + + bonusGrantId + + ", cost=" + + cost + + ", costBasis=" + + costBasis + + ", createdAt=" + + createdAt + + ", creditNoteId=" + + creditNoteId + + ", creditUnit=" + + creditUnit + + ", creditUnitPrecision=" + + creditUnitPrecision + + ", currency=" + + currency + + ", effectiveAt=" + + effectiveAt + + ", endedAt=" + + endedAt + + ", expiredAmount=" + + expiredAmount + + ", expiresAt=" + + expiresAt + + ", id=" + + id + + ", invoiceId=" + + invoiceId + + ", kind=" + + kind + + ", kindLabel=" + + kindLabel + + ", priority=" + + priority + + ", reason=" + + reason + + ", reference=" + + reference + + ", remaining=" + + remaining + + ", source=" + + source + + ", status=" + + status + + ", subscriptionId=" + + subscriptionId + + ", type=" + + type + + ", additionalProperties=" + + additionalProperties + + "}"; + } + + /** Builds {@link CreditGrant}. */ + public static final class Builder { + private Long amount; + private List applicableProductIds; + private CreditAppliesTo appliesTo; + private JsonField bonusGrantId = JsonField.missing(); + private JsonField cost = JsonField.missing(); + private JsonField costBasis = JsonField.missing(); + private OffsetDateTime createdAt; + private JsonField creditNoteId = JsonField.missing(); + private JsonField creditUnit = JsonField.missing(); + private JsonField creditUnitPrecision = JsonField.missing(); + private JsonField currency = JsonField.missing(); + private OffsetDateTime effectiveAt; + private JsonField endedAt = JsonField.missing(); + private JsonField expiredAmount = JsonField.missing(); + private JsonField expiresAt = JsonField.missing(); + private String id; + private JsonField invoiceId = JsonField.missing(); + private CreditGrantKind kind; + private String kindLabel; + private Integer priority; + private String reason; + private JsonField reference = JsonField.missing(); + private Long remaining; + private CreditGrantSource source; + private CreditGrantStatus status; + private JsonField subscriptionId = JsonField.missing(); + private CreditGrantType type; + private final Map additionalProperties = new LinkedHashMap<>(); + + private Builder() {} + + /** + * Amount granted, in minor units of currency or credit_unit. + * + * @param amount the value + * @return this builder + */ + public Builder amount(Long amount) { + this.amount = amount; + return this; + } + + /** + * The products whose charges the credit pays, combined with applies_to; empty + * when it applies to every product. + * + * @param applicableProductIds the value + * @return this builder + */ + public Builder applicableProductIds(List applicableProductIds) { + this.applicableProductIds = Utils.mutableList(applicableProductIds); + return this; + } + + /** + * Adds an item to {@code applicable_product_ids}. + * + * @param item the item + * @return this builder + */ + public Builder addApplicableProductIdsItem(String item) { + if (this.applicableProductIds == null) { + this.applicableProductIds = new ArrayList<>(); + } + this.applicableProductIds.add(item); + return this; + } + + /** + * ALL pays any charge on an invoice; USAGE only usage charges. + * + * @param appliesTo the value + * @return this builder + */ + public Builder appliesTo(CreditAppliesTo appliesTo) { + this.appliesTo = appliesTo; + return this; + } + + /** + * Only on the response that created a PAID currency grant whose cost was below + * its amount: the PROMOTIONAL "Bonus credit" grant created beside it for the difference, + * with the same expiry, scope and priority. + * + * @param bonusGrantId the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder bonusGrantId(String bonusGrantId) { + this.bonusGrantId = JsonField.ofNullable(bonusGrantId); + return this; + } + + /** + * The {@code cost} property. + * + * @param cost the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder cost(CreditCost cost) { + this.cost = JsonField.ofNullable(cost); + return this; + } + + /** + * cost per one major unit of credit, in major units of the cost currency (e.g. + * "0.008"), rounded to 12 decimal places, for display only. + * + * @param costBasis the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder costBasis(String costBasis) { + this.costBasis = JsonField.ofNullable(costBasis); + return this; + } + + /** + * When the grant was recorded. + * + * @param createdAt the value + * @return this builder + */ + public Builder createdAt(OffsetDateTime createdAt) { + this.createdAt = createdAt; + return this; + } + + /** + * The credit note that gave the credit back. + * + * @param creditNoteId the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder creditNoteId(String creditNoteId) { + this.creditNoteId = JsonField.ofNullable(creditNoteId); + return this; + } + + /** + * The credit unit (its code) the amounts are in; absent for a currency. + * + * @param creditUnit the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder creditUnit(String creditUnit) { + this.creditUnit = JsonField.ofNullable(creditUnit); + return this; + } + + /** + * Decimal places of credit_unit: amounts are integers of 10^-precision credit. + * + * @param creditUnitPrecision the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder creditUnitPrecision(Integer creditUnitPrecision) { + this.creditUnitPrecision = JsonField.ofNullable(creditUnitPrecision); + return this; + } + + /** + * The {@code currency} property. + * + * @param currency the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder currency(Currency currency) { + this.currency = JsonField.ofNullable(currency); + return this; + } + + /** + * When the credit became spendable. + * + * @param effectiveAt the value + * @return this builder + */ + public Builder effectiveAt(OffsetDateTime effectiveAt) { + this.effectiveAt = effectiveAt; + return this; + } + + /** + * When the subscription the grant belongs to ended, if it ended. Unspent credit lapses then + * (status EXPIRED), even before expires_at. + * + * @param endedAt the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder endedAt(OffsetDateTime endedAt) { + this.endedAt = JsonField.ofNullable(endedAt); + return this; + } + + /** + * Lost to expiry; present only on an expired grant. + * + * @param expiredAmount the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder expiredAmount(Long expiredAmount) { + this.expiredAmount = JsonField.ofNullable(expiredAmount); + return this; + } + + /** + * When unspent credit lapses; absent never expires. + * + * @param expiresAt the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder expiresAt(OffsetDateTime expiresAt) { + this.expiresAt = JsonField.ofNullable(expiresAt); + return this; + } + + /** + * The grant's id (cgr_…). + * + * @param id the value + * @return this builder + */ + public Builder id(String id) { + this.id = id; + return this; + } + + /** + * The invoice that sold the credit, or whose void or negative total gave it back. + * + * @param invoiceId the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder invoiceId(String invoiceId) { + this.invoiceId = JsonField.ofNullable(invoiceId); + return this; + } + + /** + * The group the grant is shown in: INCLUDED, PREPAID, BONUS or ACCOUNT_BALANCE. + * + * @param kind the value + * @return this builder + */ + public Builder kind(CreditGrantKind kind) { + this.kind = kind; + return this; + } + + /** + * The group's name as Meteroid shows it: "Included with <plan>", "Purchased credit", + * "Free credit" or "Account balance". + * + * @param kindLabel the value + * @return this builder + */ + public Builder kindLabel(String kindLabel) { + this.kindLabel = kindLabel; + return this; + } + + /** + * Lower values are drawn first among grants of the same type that pay the same charges; 100 + * by default. + * + * @param priority the value + * @return this builder + */ + public Builder priority(Integer priority) { + this.priority = priority; + return this; + } + + /** + * Shown on the credit ledger. + * + * @param reason the value + * @return this builder + */ + public Builder reason(String reason) { + this.reason = reason; + return this; + } + + /** + * Your own reference, e.g. a contract or support ticket. + * + * @param reference the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder reference(String reference) { + this.reference = JsonField.ofNullable(reference); + return this; + } + + /** + * Not spent yet, in the same minor units. + * + * @param remaining the value + * @return this builder + */ + public Builder remaining(Long remaining) { + this.remaining = remaining; + return this; + } + + /** + * Where the credit came from. + * + * @param source the value + * @return this builder + */ + public Builder source(CreditGrantSource source) { + this.source = source; + return this; + } + + /** + * PENDING until effective_at, then ACTIVE, DEPLETED once spent, or EXPIRED. + * + * @param status the value + * @return this builder + */ + public Builder status(CreditGrantStatus status) { + this.status = status; + return this; + } + + /** + * The subscription the grant belongs to (sub_…): it pays only that + * subscription's charges, and lapses when the subscription ends. Null when it pays any of + * the customer's subscriptions. + * + * @param subscriptionId the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder subscriptionId(String subscriptionId) { + this.subscriptionId = JsonField.ofNullable(subscriptionId); + return this; + } + + /** + * PAID or PROMOTIONAL: whether it applies after or before tax. + * + * @param type the value + * @return this builder + */ + public Builder type(CreditGrantType type) { + this.type = type; + return this; + } + + /** + * A property the SDK does not know, sent along. + * + * @param name the property name + * @param value the JSON value + * @return this builder + */ + public Builder putAdditionalProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + return this; + } + + /** + * Properties the SDK does not know, sent along. + * + * @param additionalProperties the properties by name + * @return this builder + */ + public Builder putAllAdditionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + + /** + * Leaves out a property the SDK does not know. + * + * @param name the property name + * @return this builder + */ + public Builder removeAdditionalProperty(String name) { + additionalProperties.remove(name); + return this; + } + + /** + * The {@code CreditGrant}. + * + * @return the immutable value + * @throws IllegalStateException when a required property is not set + */ + public CreditGrant build() { + Utils.checkRequired(amount, "amount"); + Utils.checkRequired(applicableProductIds, "applicable_product_ids"); + Utils.checkRequired(appliesTo, "applies_to"); + Utils.checkRequired(createdAt, "created_at"); + Utils.checkRequired(effectiveAt, "effective_at"); + Utils.checkRequired(id, "id"); + Utils.checkRequired(kind, "kind"); + Utils.checkRequired(kindLabel, "kind_label"); + Utils.checkRequired(priority, "priority"); + Utils.checkRequired(reason, "reason"); + Utils.checkRequired(remaining, "remaining"); + Utils.checkRequired(source, "source"); + Utils.checkRequired(status, "status"); + Utils.checkRequired(type, "type"); + return new CreditGrant(this); + } + } + + /** + * Parse {@code json} as {@code CreditGrant}. + * + * @param json the JSON text + * @return the value + * @throws com.meteroid.exceptions.InvalidDataException if it is not valid JSON of this shape + */ + public static CreditGrant fromJson(String json) { + return Utils.parse(json, CreditGrant.class); + } + + /** + * This value as JSON. + * + * @return the JSON text + */ + public String toJson() { + return Utils.json(this); + } +} diff --git a/src/main/java/com/meteroid/models/CreditGrantExpiredEvent.java b/src/main/java/com/meteroid/models/CreditGrantExpiredEvent.java new file mode 100644 index 0000000..4f676a5 --- /dev/null +++ b/src/main/java/com/meteroid/models/CreditGrantExpiredEvent.java @@ -0,0 +1,284 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.Unions; +import com.meteroid.internal.Utils; + +import java.time.OffsetDateTime; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; + +/** Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonAutoDetect( + getterVisibility = Visibility.NONE, + isGetterVisibility = Visibility.NONE, + setterVisibility = Visibility.NONE) +public final class CreditGrantExpiredEvent { + @JsonProperty("id") + private String id; + + @JsonProperty("timestamp") + private OffsetDateTime timestamp; + + @JsonProperty("type") + private EventType type; + + private final Map additionalProperties = new LinkedHashMap<>(); + + private CreditGrantExpiredEvent() {} + + private CreditGrantExpiredEvent(Builder builder) { + this.id = builder.id; + this.timestamp = builder.timestamp; + this.type = builder.type; + this.additionalProperties.putAll(builder.additionalProperties); + } + + /** + * A builder of {@code CreditGrantExpiredEvent}. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * A builder starting from this value. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.id = id; + builder.timestamp = timestamp; + builder.type = type; + builder.additionalProperties.putAll(additionalProperties); + return builder; + } + + /** + * The properties of {@link CreditGrantExpiredEventData}, which this schema extends. + * + * @return the properties of this part + */ + public CreditGrantExpiredEventData creditGrantExpiredEventData() { + return Unions.convert(additionalProperties, CreditGrantExpiredEventData.class); + } + + /** + * The {@code id} property. + * + * @return the value, never null + */ + public String id() { + return Utils.required(id, "id"); + } + + /** + * The {@code timestamp} property. + * + * @return the value, never null + */ + public OffsetDateTime timestamp() { + return Utils.required(timestamp, "timestamp"); + } + + /** + * The {@code type} property. + * + * @return the value, never null + */ + public EventType type() { + return Utils.required(type, "type"); + } + + /** + * Properties this version of the SDK does not know, kept as received and sent back. + * + * @return the properties by name, unmodifiable + */ + public Map additionalProperties() { + Map unknown = new LinkedHashMap<>(additionalProperties); + unknown.keySet().retainAll(creditGrantExpiredEventData().additionalProperties().keySet()); + return Collections.unmodifiableMap(unknown); + } + + @JsonAnyGetter + private Map anyProperties() { + return additionalProperties; + } + + @JsonAnySetter + private void putAnyProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CreditGrantExpiredEvent that = (CreditGrantExpiredEvent) o; + return Objects.equals(id, that.id) + && Objects.equals(timestamp, that.timestamp) + && Objects.equals(type, that.type) + && Objects.equals(additionalProperties, that.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(id, timestamp, type, additionalProperties); + } + + @Override + public String toString() { + return "CreditGrantExpiredEvent{" + + "id=" + + id + + ", timestamp=" + + timestamp + + ", type=" + + type + + ", additionalProperties=" + + additionalProperties + + "}"; + } + + /** Builds {@link CreditGrantExpiredEvent}. */ + public static final class Builder { + private String id; + private OffsetDateTime timestamp; + private EventType type; + private final Map additionalProperties = new LinkedHashMap<>(); + + private Builder() {} + + /** + * Sets the properties of {@link CreditGrantExpiredEventData}, which this schema extends. + * + * @param creditGrantExpiredEventData the properties + * @return this builder + */ + public Builder creditGrantExpiredEventData( + CreditGrantExpiredEventData creditGrantExpiredEventData) { + additionalProperties.putAll(Utils.properties(creditGrantExpiredEventData)); + return this; + } + + /** + * The {@code id} property. + * + * @param id the value + * @return this builder + */ + public Builder id(String id) { + this.id = id; + return this; + } + + /** + * The {@code timestamp} property. + * + * @param timestamp the value + * @return this builder + */ + public Builder timestamp(OffsetDateTime timestamp) { + this.timestamp = timestamp; + return this; + } + + /** + * The {@code type} property. + * + * @param type the value + * @return this builder + */ + public Builder type(EventType type) { + this.type = type; + return this; + } + + /** + * A property the SDK does not know, sent along. + * + * @param name the property name + * @param value the JSON value + * @return this builder + */ + public Builder putAdditionalProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + return this; + } + + /** + * Properties the SDK does not know, sent along. + * + * @param additionalProperties the properties by name + * @return this builder + */ + public Builder putAllAdditionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + + /** + * Leaves out a property the SDK does not know. + * + * @param name the property name + * @return this builder + */ + public Builder removeAdditionalProperty(String name) { + additionalProperties.remove(name); + return this; + } + + /** + * The {@code CreditGrantExpiredEvent}. + * + * @return the immutable value + * @throws IllegalStateException when a required property is not set + */ + public CreditGrantExpiredEvent build() { + Utils.checkRequired(id, "id"); + Utils.checkRequired(timestamp, "timestamp"); + Utils.checkRequired(type, "type"); + return new CreditGrantExpiredEvent(this); + } + } + + /** + * Parse {@code json} as {@code CreditGrantExpiredEvent}. + * + * @param json the JSON text + * @return the value + * @throws com.meteroid.exceptions.InvalidDataException if it is not valid JSON of this shape + */ + public static CreditGrantExpiredEvent fromJson(String json) { + return Utils.parse(json, CreditGrantExpiredEvent.class); + } + + /** + * This value as JSON. + * + * @return the JSON text + */ + public String toJson() { + return Utils.json(this); + } +} diff --git a/src/main/java/com/meteroid/models/CreditGrantExpiredEventData.java b/src/main/java/com/meteroid/models/CreditGrantExpiredEventData.java new file mode 100644 index 0000000..330eab3 --- /dev/null +++ b/src/main/java/com/meteroid/models/CreditGrantExpiredEventData.java @@ -0,0 +1,571 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.JsonField; +import com.meteroid.internal.Utils; + +import java.time.OffsetDateTime; +import java.util.ArrayList; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +/** + * A credit grant expired, or the subscription it belongs to ended, with credit left, which lapsed. + * + *

Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonAutoDetect( + getterVisibility = Visibility.NONE, + isGetterVisibility = Visibility.NONE, + setterVisibility = Visibility.NONE) +public final class CreditGrantExpiredEventData { + @JsonProperty("applicable_product_ids") + private List applicableProductIds; + + @JsonProperty("applies_to") + private CreditAppliesTo appliesTo; + + @JsonProperty("credit_grant_id") + private String creditGrantId; + + @JsonProperty("credit_unit") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField creditUnit = JsonField.missing(); + + @JsonProperty("credit_unit_precision") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField creditUnitPrecision = JsonField.missing(); + + @JsonProperty("currency") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField currency = JsonField.missing(); + + @JsonProperty("customer_id") + private String customerId; + + @JsonProperty("expired_amount") + private Long expiredAmount; + + @JsonProperty("expired_at") + private OffsetDateTime expiredAt; + + @JsonProperty("ledger_entry_id") + private String ledgerEntryId; + + @JsonProperty("reason") + private CreditGrantLapseReason reason; + + @JsonProperty("subscription_id") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField subscriptionId = JsonField.missing(); + + private final Map additionalProperties = new LinkedHashMap<>(); + + private CreditGrantExpiredEventData() {} + + private CreditGrantExpiredEventData(Builder builder) { + this.applicableProductIds = Utils.copyList(builder.applicableProductIds); + this.appliesTo = builder.appliesTo; + this.creditGrantId = builder.creditGrantId; + this.creditUnit = builder.creditUnit; + this.creditUnitPrecision = builder.creditUnitPrecision; + this.currency = builder.currency; + this.customerId = builder.customerId; + this.expiredAmount = builder.expiredAmount; + this.expiredAt = builder.expiredAt; + this.ledgerEntryId = builder.ledgerEntryId; + this.reason = builder.reason; + this.subscriptionId = builder.subscriptionId; + this.additionalProperties.putAll(builder.additionalProperties); + } + + /** + * A builder of {@code CreditGrantExpiredEventData}. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * A builder starting from this value. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.applicableProductIds = Utils.mutableList(applicableProductIds); + builder.appliesTo = appliesTo; + builder.creditGrantId = creditGrantId; + builder.creditUnit = creditUnit; + builder.creditUnitPrecision = creditUnitPrecision; + builder.currency = currency; + builder.customerId = customerId; + builder.expiredAmount = expiredAmount; + builder.expiredAt = expiredAt; + builder.ledgerEntryId = ledgerEntryId; + builder.reason = reason; + builder.subscriptionId = subscriptionId; + builder.additionalProperties.putAll(additionalProperties); + return builder; + } + + /** + * The products whose charges the grant pays; empty when it pays every product. + * + * @return the value, never null + */ + public List applicableProductIds() { + return Utils.required(applicableProductIds, "applicable_product_ids"); + } + + /** + * What the grant pays: ALL any charge, USAGE only usage charges. + * + * @return the value, never null + */ + public CreditAppliesTo appliesTo() { + return Utils.required(appliesTo, "applies_to"); + } + + /** + * The grant that expired. + * + * @return the value, never null + */ + public String creditGrantId() { + return Utils.required(creditGrantId, "credit_grant_id"); + } + + /** + * The credit unit (its code) the amounts are in; absent for a currency. + * + * @return the value, empty when unset or null + */ + public Optional creditUnit() { + return creditUnit.asOptional(); + } + + /** + * Decimal places of credit_unit: amounts are integers of 10^-precision credit. + * + * @return the value, empty when unset or null + */ + public Optional creditUnitPrecision() { + return creditUnitPrecision.asOptional(); + } + + /** + * Absent when the amounts are in a credit unit. + * + * @return the value, empty when unset or null + */ + public Optional currency() { + return currency.asOptional(); + } + + /** + * The {@code customer_id} property. + * + * @return the value, never null + */ + public String customerId() { + return Utils.required(customerId, "customer_id"); + } + + /** + * Unspent credit that lapsed, in minor units of currency or credit_unit + * . + * + * @return the value, never null + */ + public Long expiredAmount() { + return Utils.required(expiredAmount, "expired_amount"); + } + + /** + * When the grant expired, or its subscription ended. + * + * @return the value, never null + */ + public OffsetDateTime expiredAt() { + return Utils.required(expiredAt, "expired_at"); + } + + /** + * The credit ledger entry recording the expiry. + * + * @return the value, never null + */ + public String ledgerEntryId() { + return Utils.required(ledgerEntryId, "ledger_entry_id"); + } + + /** + * SUBSCRIPTION_ENDED when the subscription the grant belongs to ended at or before the grant's + * expiry, EXPIRED otherwise. + * + * @return the value, never null + */ + public CreditGrantLapseReason reason() { + return Utils.required(reason, "reason"); + } + + /** + * The subscription the grant belongs to: it pays only that subscription's charges. Null when it + * pays any of the customer's subscriptions. + * + * @return the value, empty when unset or null + */ + public Optional subscriptionId() { + return subscriptionId.asOptional(); + } + + /** + * Properties this version of the SDK does not know, kept as received and sent back. + * + * @return the properties by name, unmodifiable + */ + public Map additionalProperties() { + return Collections.unmodifiableMap(additionalProperties); + } + + @JsonAnyGetter + private Map anyProperties() { + return additionalProperties; + } + + @JsonAnySetter + private void putAnyProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CreditGrantExpiredEventData that = (CreditGrantExpiredEventData) o; + return Objects.equals(applicableProductIds, that.applicableProductIds) + && Objects.equals(appliesTo, that.appliesTo) + && Objects.equals(creditGrantId, that.creditGrantId) + && Objects.equals(creditUnit, that.creditUnit) + && Objects.equals(creditUnitPrecision, that.creditUnitPrecision) + && Objects.equals(currency, that.currency) + && Objects.equals(customerId, that.customerId) + && Objects.equals(expiredAmount, that.expiredAmount) + && Objects.equals(expiredAt, that.expiredAt) + && Objects.equals(ledgerEntryId, that.ledgerEntryId) + && Objects.equals(reason, that.reason) + && Objects.equals(subscriptionId, that.subscriptionId) + && Objects.equals(additionalProperties, that.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash( + applicableProductIds, + appliesTo, + creditGrantId, + creditUnit, + creditUnitPrecision, + currency, + customerId, + expiredAmount, + expiredAt, + ledgerEntryId, + reason, + subscriptionId, + additionalProperties); + } + + @Override + public String toString() { + return "CreditGrantExpiredEventData{" + + "applicableProductIds=" + + applicableProductIds + + ", appliesTo=" + + appliesTo + + ", creditGrantId=" + + creditGrantId + + ", creditUnit=" + + creditUnit + + ", creditUnitPrecision=" + + creditUnitPrecision + + ", currency=" + + currency + + ", customerId=" + + customerId + + ", expiredAmount=" + + expiredAmount + + ", expiredAt=" + + expiredAt + + ", ledgerEntryId=" + + ledgerEntryId + + ", reason=" + + reason + + ", subscriptionId=" + + subscriptionId + + ", additionalProperties=" + + additionalProperties + + "}"; + } + + /** Builds {@link CreditGrantExpiredEventData}. */ + public static final class Builder { + private List applicableProductIds; + private CreditAppliesTo appliesTo; + private String creditGrantId; + private JsonField creditUnit = JsonField.missing(); + private JsonField creditUnitPrecision = JsonField.missing(); + private JsonField currency = JsonField.missing(); + private String customerId; + private Long expiredAmount; + private OffsetDateTime expiredAt; + private String ledgerEntryId; + private CreditGrantLapseReason reason; + private JsonField subscriptionId = JsonField.missing(); + private final Map additionalProperties = new LinkedHashMap<>(); + + private Builder() {} + + /** + * The products whose charges the grant pays; empty when it pays every product. + * + * @param applicableProductIds the value + * @return this builder + */ + public Builder applicableProductIds(List applicableProductIds) { + this.applicableProductIds = Utils.mutableList(applicableProductIds); + return this; + } + + /** + * Adds an item to {@code applicable_product_ids}. + * + * @param item the item + * @return this builder + */ + public Builder addApplicableProductIdsItem(String item) { + if (this.applicableProductIds == null) { + this.applicableProductIds = new ArrayList<>(); + } + this.applicableProductIds.add(item); + return this; + } + + /** + * What the grant pays: ALL any charge, USAGE only usage charges. + * + * @param appliesTo the value + * @return this builder + */ + public Builder appliesTo(CreditAppliesTo appliesTo) { + this.appliesTo = appliesTo; + return this; + } + + /** + * The grant that expired. + * + * @param creditGrantId the value + * @return this builder + */ + public Builder creditGrantId(String creditGrantId) { + this.creditGrantId = creditGrantId; + return this; + } + + /** + * The credit unit (its code) the amounts are in; absent for a currency. + * + * @param creditUnit the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder creditUnit(String creditUnit) { + this.creditUnit = JsonField.ofNullable(creditUnit); + return this; + } + + /** + * Decimal places of credit_unit: amounts are integers of 10^-precision credit. + * + * @param creditUnitPrecision the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder creditUnitPrecision(Integer creditUnitPrecision) { + this.creditUnitPrecision = JsonField.ofNullable(creditUnitPrecision); + return this; + } + + /** + * Absent when the amounts are in a credit unit. + * + * @param currency the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder currency(String currency) { + this.currency = JsonField.ofNullable(currency); + return this; + } + + /** + * The {@code customer_id} property. + * + * @param customerId the value + * @return this builder + */ + public Builder customerId(String customerId) { + this.customerId = customerId; + return this; + } + + /** + * Unspent credit that lapsed, in minor units of currency or credit_unit + * . + * + * @param expiredAmount the value + * @return this builder + */ + public Builder expiredAmount(Long expiredAmount) { + this.expiredAmount = expiredAmount; + return this; + } + + /** + * When the grant expired, or its subscription ended. + * + * @param expiredAt the value + * @return this builder + */ + public Builder expiredAt(OffsetDateTime expiredAt) { + this.expiredAt = expiredAt; + return this; + } + + /** + * The credit ledger entry recording the expiry. + * + * @param ledgerEntryId the value + * @return this builder + */ + public Builder ledgerEntryId(String ledgerEntryId) { + this.ledgerEntryId = ledgerEntryId; + return this; + } + + /** + * SUBSCRIPTION_ENDED when the subscription the grant belongs to ended at or before the + * grant's expiry, EXPIRED otherwise. + * + * @param reason the value + * @return this builder + */ + public Builder reason(CreditGrantLapseReason reason) { + this.reason = reason; + return this; + } + + /** + * The subscription the grant belongs to: it pays only that subscription's charges. Null + * when it pays any of the customer's subscriptions. + * + * @param subscriptionId the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder subscriptionId(String subscriptionId) { + this.subscriptionId = JsonField.ofNullable(subscriptionId); + return this; + } + + /** + * A property the SDK does not know, sent along. + * + * @param name the property name + * @param value the JSON value + * @return this builder + */ + public Builder putAdditionalProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + return this; + } + + /** + * Properties the SDK does not know, sent along. + * + * @param additionalProperties the properties by name + * @return this builder + */ + public Builder putAllAdditionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + + /** + * Leaves out a property the SDK does not know. + * + * @param name the property name + * @return this builder + */ + public Builder removeAdditionalProperty(String name) { + additionalProperties.remove(name); + return this; + } + + /** + * The {@code CreditGrantExpiredEventData}. + * + * @return the immutable value + * @throws IllegalStateException when a required property is not set + */ + public CreditGrantExpiredEventData build() { + Utils.checkRequired(applicableProductIds, "applicable_product_ids"); + Utils.checkRequired(appliesTo, "applies_to"); + Utils.checkRequired(creditGrantId, "credit_grant_id"); + Utils.checkRequired(customerId, "customer_id"); + Utils.checkRequired(expiredAmount, "expired_amount"); + Utils.checkRequired(expiredAt, "expired_at"); + Utils.checkRequired(ledgerEntryId, "ledger_entry_id"); + Utils.checkRequired(reason, "reason"); + return new CreditGrantExpiredEventData(this); + } + } + + /** + * Parse {@code json} as {@code CreditGrantExpiredEventData}. + * + * @param json the JSON text + * @return the value + * @throws com.meteroid.exceptions.InvalidDataException if it is not valid JSON of this shape + */ + public static CreditGrantExpiredEventData fromJson(String json) { + return Utils.parse(json, CreditGrantExpiredEventData.class); + } + + /** + * This value as JSON. + * + * @return the JSON text + */ + public String toJson() { + return Utils.json(this); + } +} diff --git a/src/main/java/com/meteroid/models/CreditGrantKind.java b/src/main/java/com/meteroid/models/CreditGrantKind.java new file mode 100644 index 0000000..cbe0fa8 --- /dev/null +++ b/src/main/java/com/meteroid/models/CreditGrantKind.java @@ -0,0 +1,152 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import com.meteroid.internal.Utils.ToQueryParam; + +import java.util.Map; +import java.util.Objects; + +/** + * The group a grant is shown in, from where it came from and what it pays: - INCLUDED: credit a + * subscription's plan includes, which renews with it; - PREPAID: credit bought (purchases, top-ups, + * paid packs, credit paid for outside Meteroid); - BONUS: credit given (the bonus part of + * discounted credit, promo codes, welcome credit); - ACCOUNT_BALANCE: the customer's money that + * pays any invoice (credit notes, returned invoices, the balance carried from before credit grants, + * credit added for any charge). + * + *

Values this version of the SDK does not know are kept, and sent back unchanged: {@link + * #value()} is an enum to switch on, {@code _UNKNOWN} for them, and {@link #known()} throws on + * them. + */ +public final class CreditGrantKind implements ToQueryParam { + /** The value {@code "INCLUDED"}. */ + public static final CreditGrantKind INCLUDED = new CreditGrantKind("INCLUDED", Value.INCLUDED); + + /** The value {@code "PREPAID"}. */ + public static final CreditGrantKind PREPAID = new CreditGrantKind("PREPAID", Value.PREPAID); + + /** The value {@code "BONUS"}. */ + public static final CreditGrantKind BONUS = new CreditGrantKind("BONUS", Value.BONUS); + + /** The value {@code "ACCOUNT_BALANCE"}. */ + public static final CreditGrantKind ACCOUNT_BALANCE = + new CreditGrantKind("ACCOUNT_BALANCE", Value.ACCOUNT_BALANCE); + + private static final Map constants = + Map.ofEntries( + Map.entry("INCLUDED", INCLUDED), + Map.entry("PREPAID", PREPAID), + Map.entry("BONUS", BONUS), + Map.entry("ACCOUNT_BALANCE", ACCOUNT_BALANCE)); + + private final String value; + private final Value variant; + + private CreditGrantKind(String value, Value variant) { + this.value = value; + this.variant = variant; + } + + /** + * The constant for {@code value}, or an unknown CreditGrantKind holding it. + * + * @param value the value + * @return the constant + */ + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static CreditGrantKind of(String value) { + CreditGrantKind constant = constants.get(Objects.requireNonNull(value, "value")); + return constant != null ? constant : new CreditGrantKind(value, Value._UNKNOWN); + } + + /** + * The value as sent. + * + * @return the value + */ + @JsonValue + public String asString() { + return value; + } + + /** + * Whether this version of the SDK knows the value. + * + * @return whether it is known + */ + public boolean isKnown() { + return variant != Value._UNKNOWN; + } + + /** + * The value as an enum to switch on, unknown values included. + * + * @return the enum, {@code _UNKNOWN} when unknown + */ + public Value value() { + return variant; + } + + /** + * The value as an enum of the known values only. + * + * @return the enum + * @throws com.meteroid.exceptions.InvalidDataException when this version of the SDK does not + * know the value + */ + public Known known() { + if (!isKnown()) { + throw new com.meteroid.exceptions.InvalidDataException( + "unknown CreditGrantKind: " + value); + } + return Known.valueOf(variant.name()); + } + + @Override + public String toQueryParam() { + return String.valueOf(value); + } + + @Override + public boolean equals(Object o) { + return o instanceof CreditGrantKind && Objects.equals(value, ((CreditGrantKind) o).value); + } + + @Override + public int hashCode() { + return Objects.hashCode(value); + } + + @Override + public String toString() { + return String.valueOf(value); + } + + /** The values this version of the SDK knows. */ + public enum Known { + /** The {@code INCLUDED} constant. */ + INCLUDED, + /** The {@code PREPAID} constant. */ + PREPAID, + /** The {@code BONUS} constant. */ + BONUS, + /** The {@code ACCOUNT_BALANCE} constant. */ + ACCOUNT_BALANCE + } + + /** The values this version of the SDK knows, and {@code _UNKNOWN} for the others. */ + public enum Value { + /** The {@code INCLUDED} constant. */ + INCLUDED, + /** The {@code PREPAID} constant. */ + PREPAID, + /** The {@code BONUS} constant. */ + BONUS, + /** The {@code ACCOUNT_BALANCE} constant. */ + ACCOUNT_BALANCE, + /** A value this version of the SDK does not know. */ + _UNKNOWN + } +} diff --git a/src/main/java/com/meteroid/models/CreditGrantLapseReason.java b/src/main/java/com/meteroid/models/CreditGrantLapseReason.java new file mode 100644 index 0000000..abea799 --- /dev/null +++ b/src/main/java/com/meteroid/models/CreditGrantLapseReason.java @@ -0,0 +1,133 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import com.meteroid.internal.Utils.ToQueryParam; + +import java.util.Map; +import java.util.Objects; + +/** + * Why a credit grant's unspent credit lapsed. + * + *

Values this version of the SDK does not know are kept, and sent back unchanged: {@link + * #value()} is an enum to switch on, {@code _UNKNOWN} for them, and {@link #known()} throws on + * them. + */ +public final class CreditGrantLapseReason implements ToQueryParam { + /** The value {@code "EXPIRED"}. */ + public static final CreditGrantLapseReason EXPIRED = + new CreditGrantLapseReason("EXPIRED", Value.EXPIRED); + + /** The value {@code "SUBSCRIPTION_ENDED"}. */ + public static final CreditGrantLapseReason SUBSCRIPTION_ENDED = + new CreditGrantLapseReason("SUBSCRIPTION_ENDED", Value.SUBSCRIPTION_ENDED); + + private static final Map constants = + Map.ofEntries( + Map.entry("EXPIRED", EXPIRED), + Map.entry("SUBSCRIPTION_ENDED", SUBSCRIPTION_ENDED)); + + private final String value; + private final Value variant; + + private CreditGrantLapseReason(String value, Value variant) { + this.value = value; + this.variant = variant; + } + + /** + * The constant for {@code value}, or an unknown CreditGrantLapseReason holding it. + * + * @param value the value + * @return the constant + */ + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static CreditGrantLapseReason of(String value) { + CreditGrantLapseReason constant = constants.get(Objects.requireNonNull(value, "value")); + return constant != null ? constant : new CreditGrantLapseReason(value, Value._UNKNOWN); + } + + /** + * The value as sent. + * + * @return the value + */ + @JsonValue + public String asString() { + return value; + } + + /** + * Whether this version of the SDK knows the value. + * + * @return whether it is known + */ + public boolean isKnown() { + return variant != Value._UNKNOWN; + } + + /** + * The value as an enum to switch on, unknown values included. + * + * @return the enum, {@code _UNKNOWN} when unknown + */ + public Value value() { + return variant; + } + + /** + * The value as an enum of the known values only. + * + * @return the enum + * @throws com.meteroid.exceptions.InvalidDataException when this version of the SDK does not + * know the value + */ + public Known known() { + if (!isKnown()) { + throw new com.meteroid.exceptions.InvalidDataException( + "unknown CreditGrantLapseReason: " + value); + } + return Known.valueOf(variant.name()); + } + + @Override + public String toQueryParam() { + return String.valueOf(value); + } + + @Override + public boolean equals(Object o) { + return o instanceof CreditGrantLapseReason + && Objects.equals(value, ((CreditGrantLapseReason) o).value); + } + + @Override + public int hashCode() { + return Objects.hashCode(value); + } + + @Override + public String toString() { + return String.valueOf(value); + } + + /** The values this version of the SDK knows. */ + public enum Known { + /** The {@code EXPIRED} constant. */ + EXPIRED, + /** The {@code SUBSCRIPTION_ENDED} constant. */ + SUBSCRIPTION_ENDED + } + + /** The values this version of the SDK knows, and {@code _UNKNOWN} for the others. */ + public enum Value { + /** The {@code EXPIRED} constant. */ + EXPIRED, + /** The {@code SUBSCRIPTION_ENDED} constant. */ + SUBSCRIPTION_ENDED, + /** A value this version of the SDK does not know. */ + _UNKNOWN + } +} diff --git a/src/main/java/com/meteroid/models/CreditGrantListResponse.java b/src/main/java/com/meteroid/models/CreditGrantListResponse.java new file mode 100644 index 0000000..ea45b61 --- /dev/null +++ b/src/main/java/com/meteroid/models/CreditGrantListResponse.java @@ -0,0 +1,249 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.Utils; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * A page of credit grants. + * + *

Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonAutoDetect( + getterVisibility = Visibility.NONE, + isGetterVisibility = Visibility.NONE, + setterVisibility = Visibility.NONE) +public final class CreditGrantListResponse { + @JsonProperty("data") + private List data; + + @JsonProperty("pagination_meta") + private PaginationResponse paginationMeta; + + private final Map additionalProperties = new LinkedHashMap<>(); + + private CreditGrantListResponse() {} + + private CreditGrantListResponse(Builder builder) { + this.data = Utils.copyList(builder.data); + this.paginationMeta = builder.paginationMeta; + this.additionalProperties.putAll(builder.additionalProperties); + } + + /** + * A builder of {@code CreditGrantListResponse}. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * A builder starting from this value. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.data = Utils.mutableList(data); + builder.paginationMeta = paginationMeta; + builder.additionalProperties.putAll(additionalProperties); + return builder; + } + + /** + * The {@code data} property. + * + * @return the value, never null + */ + public List data() { + return Utils.required(data, "data"); + } + + /** + * The {@code pagination_meta} property. + * + * @return the value, never null + */ + public PaginationResponse paginationMeta() { + return Utils.required(paginationMeta, "pagination_meta"); + } + + /** + * Properties this version of the SDK does not know, kept as received and sent back. + * + * @return the properties by name, unmodifiable + */ + public Map additionalProperties() { + return Collections.unmodifiableMap(additionalProperties); + } + + @JsonAnyGetter + private Map anyProperties() { + return additionalProperties; + } + + @JsonAnySetter + private void putAnyProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CreditGrantListResponse that = (CreditGrantListResponse) o; + return Objects.equals(data, that.data) + && Objects.equals(paginationMeta, that.paginationMeta) + && Objects.equals(additionalProperties, that.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(data, paginationMeta, additionalProperties); + } + + @Override + public String toString() { + return "CreditGrantListResponse{" + + "data=" + + data + + ", paginationMeta=" + + paginationMeta + + ", additionalProperties=" + + additionalProperties + + "}"; + } + + /** Builds {@link CreditGrantListResponse}. */ + public static final class Builder { + private List data; + private PaginationResponse paginationMeta; + private final Map additionalProperties = new LinkedHashMap<>(); + + private Builder() {} + + /** + * The {@code data} property. + * + * @param data the value + * @return this builder + */ + public Builder data(List data) { + this.data = Utils.mutableList(data); + return this; + } + + /** + * Adds an item to {@code data}. + * + * @param item the item + * @return this builder + */ + public Builder addDataItem(CreditGrant item) { + if (this.data == null) { + this.data = new ArrayList<>(); + } + this.data.add(item); + return this; + } + + /** + * The {@code pagination_meta} property. + * + * @param paginationMeta the value + * @return this builder + */ + public Builder paginationMeta(PaginationResponse paginationMeta) { + this.paginationMeta = paginationMeta; + return this; + } + + /** + * A property the SDK does not know, sent along. + * + * @param name the property name + * @param value the JSON value + * @return this builder + */ + public Builder putAdditionalProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + return this; + } + + /** + * Properties the SDK does not know, sent along. + * + * @param additionalProperties the properties by name + * @return this builder + */ + public Builder putAllAdditionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + + /** + * Leaves out a property the SDK does not know. + * + * @param name the property name + * @return this builder + */ + public Builder removeAdditionalProperty(String name) { + additionalProperties.remove(name); + return this; + } + + /** + * The {@code CreditGrantListResponse}. + * + * @return the immutable value + * @throws IllegalStateException when a required property is not set + */ + public CreditGrantListResponse build() { + Utils.checkRequired(data, "data"); + Utils.checkRequired(paginationMeta, "pagination_meta"); + return new CreditGrantListResponse(this); + } + } + + /** + * Parse {@code json} as {@code CreditGrantListResponse}. + * + * @param json the JSON text + * @return the value + * @throws com.meteroid.exceptions.InvalidDataException if it is not valid JSON of this shape + */ + public static CreditGrantListResponse fromJson(String json) { + return Utils.parse(json, CreditGrantListResponse.class); + } + + /** + * This value as JSON. + * + * @return the JSON text + */ + public String toJson() { + return Utils.json(this); + } +} diff --git a/src/main/java/com/meteroid/models/CreditGrantSource.java b/src/main/java/com/meteroid/models/CreditGrantSource.java new file mode 100644 index 0000000..4bda033 --- /dev/null +++ b/src/main/java/com/meteroid/models/CreditGrantSource.java @@ -0,0 +1,190 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import com.meteroid.internal.Utils.ToQueryParam; + +import java.util.Map; +import java.util.Objects; + +/** + * Values this version of the SDK does not know are kept, and sent back unchanged: {@link #value()} + * is an enum to switch on, {@code _UNKNOWN} for them, and {@link #known()} throws on them. + */ +public final class CreditGrantSource implements ToQueryParam { + /** The value {@code "MANUAL"}. */ + public static final CreditGrantSource MANUAL = new CreditGrantSource("MANUAL", Value.MANUAL); + + /** The value {@code "PURCHASE"}. */ + public static final CreditGrantSource PURCHASE = + new CreditGrantSource("PURCHASE", Value.PURCHASE); + + /** The value {@code "PLAN"}. */ + public static final CreditGrantSource PLAN = new CreditGrantSource("PLAN", Value.PLAN); + + /** The value {@code "CREDIT_NOTE"}. */ + public static final CreditGrantSource CREDIT_NOTE = + new CreditGrantSource("CREDIT_NOTE", Value.CREDIT_NOTE); + + /** The value {@code "ADJUSTMENT"}. */ + public static final CreditGrantSource ADJUSTMENT = + new CreditGrantSource("ADJUSTMENT", Value.ADJUSTMENT); + + /** The value {@code "MIGRATED"}. */ + public static final CreditGrantSource MIGRATED = + new CreditGrantSource("MIGRATED", Value.MIGRATED); + + /** The value {@code "ROLLOVER"}. */ + public static final CreditGrantSource ROLLOVER = + new CreditGrantSource("ROLLOVER", Value.ROLLOVER); + + /** The value {@code "COUPON"}. */ + public static final CreditGrantSource COUPON = new CreditGrantSource("COUPON", Value.COUPON); + + /** The value {@code "OVERPAYMENT"}. */ + public static final CreditGrantSource OVERPAYMENT = + new CreditGrantSource("OVERPAYMENT", Value.OVERPAYMENT); + + private static final Map constants = + Map.ofEntries( + Map.entry("MANUAL", MANUAL), + Map.entry("PURCHASE", PURCHASE), + Map.entry("PLAN", PLAN), + Map.entry("CREDIT_NOTE", CREDIT_NOTE), + Map.entry("ADJUSTMENT", ADJUSTMENT), + Map.entry("MIGRATED", MIGRATED), + Map.entry("ROLLOVER", ROLLOVER), + Map.entry("COUPON", COUPON), + Map.entry("OVERPAYMENT", OVERPAYMENT)); + + private final String value; + private final Value variant; + + private CreditGrantSource(String value, Value variant) { + this.value = value; + this.variant = variant; + } + + /** + * The constant for {@code value}, or an unknown CreditGrantSource holding it. + * + * @param value the value + * @return the constant + */ + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static CreditGrantSource of(String value) { + CreditGrantSource constant = constants.get(Objects.requireNonNull(value, "value")); + return constant != null ? constant : new CreditGrantSource(value, Value._UNKNOWN); + } + + /** + * The value as sent. + * + * @return the value + */ + @JsonValue + public String asString() { + return value; + } + + /** + * Whether this version of the SDK knows the value. + * + * @return whether it is known + */ + public boolean isKnown() { + return variant != Value._UNKNOWN; + } + + /** + * The value as an enum to switch on, unknown values included. + * + * @return the enum, {@code _UNKNOWN} when unknown + */ + public Value value() { + return variant; + } + + /** + * The value as an enum of the known values only. + * + * @return the enum + * @throws com.meteroid.exceptions.InvalidDataException when this version of the SDK does not + * know the value + */ + public Known known() { + if (!isKnown()) { + throw new com.meteroid.exceptions.InvalidDataException( + "unknown CreditGrantSource: " + value); + } + return Known.valueOf(variant.name()); + } + + @Override + public String toQueryParam() { + return String.valueOf(value); + } + + @Override + public boolean equals(Object o) { + return o instanceof CreditGrantSource + && Objects.equals(value, ((CreditGrantSource) o).value); + } + + @Override + public int hashCode() { + return Objects.hashCode(value); + } + + @Override + public String toString() { + return String.valueOf(value); + } + + /** The values this version of the SDK knows. */ + public enum Known { + /** The {@code MANUAL} constant. */ + MANUAL, + /** The {@code PURCHASE} constant. */ + PURCHASE, + /** The {@code PLAN} constant. */ + PLAN, + /** The {@code CREDIT_NOTE} constant. */ + CREDIT_NOTE, + /** The {@code ADJUSTMENT} constant. */ + ADJUSTMENT, + /** The {@code MIGRATED} constant. */ + MIGRATED, + /** The {@code ROLLOVER} constant. */ + ROLLOVER, + /** The {@code COUPON} constant. */ + COUPON, + /** The {@code OVERPAYMENT} constant. */ + OVERPAYMENT + } + + /** The values this version of the SDK knows, and {@code _UNKNOWN} for the others. */ + public enum Value { + /** The {@code MANUAL} constant. */ + MANUAL, + /** The {@code PURCHASE} constant. */ + PURCHASE, + /** The {@code PLAN} constant. */ + PLAN, + /** The {@code CREDIT_NOTE} constant. */ + CREDIT_NOTE, + /** The {@code ADJUSTMENT} constant. */ + ADJUSTMENT, + /** The {@code MIGRATED} constant. */ + MIGRATED, + /** The {@code ROLLOVER} constant. */ + ROLLOVER, + /** The {@code COUPON} constant. */ + COUPON, + /** The {@code OVERPAYMENT} constant. */ + OVERPAYMENT, + /** A value this version of the SDK does not know. */ + _UNKNOWN + } +} diff --git a/src/main/java/com/meteroid/models/CreditGrantStatus.java b/src/main/java/com/meteroid/models/CreditGrantStatus.java new file mode 100644 index 0000000..ae81f0d --- /dev/null +++ b/src/main/java/com/meteroid/models/CreditGrantStatus.java @@ -0,0 +1,145 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import com.meteroid.internal.Utils.ToQueryParam; + +import java.util.Map; +import java.util.Objects; + +/** + * Values this version of the SDK does not know are kept, and sent back unchanged: {@link #value()} + * is an enum to switch on, {@code _UNKNOWN} for them, and {@link #known()} throws on them. + */ +public final class CreditGrantStatus implements ToQueryParam { + /** The value {@code "PENDING"}. */ + public static final CreditGrantStatus PENDING = new CreditGrantStatus("PENDING", Value.PENDING); + + /** The value {@code "ACTIVE"}. */ + public static final CreditGrantStatus ACTIVE = new CreditGrantStatus("ACTIVE", Value.ACTIVE); + + /** The value {@code "DEPLETED"}. */ + public static final CreditGrantStatus DEPLETED = + new CreditGrantStatus("DEPLETED", Value.DEPLETED); + + /** The value {@code "EXPIRED"}. */ + public static final CreditGrantStatus EXPIRED = new CreditGrantStatus("EXPIRED", Value.EXPIRED); + + private static final Map constants = + Map.ofEntries( + Map.entry("PENDING", PENDING), + Map.entry("ACTIVE", ACTIVE), + Map.entry("DEPLETED", DEPLETED), + Map.entry("EXPIRED", EXPIRED)); + + private final String value; + private final Value variant; + + private CreditGrantStatus(String value, Value variant) { + this.value = value; + this.variant = variant; + } + + /** + * The constant for {@code value}, or an unknown CreditGrantStatus holding it. + * + * @param value the value + * @return the constant + */ + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static CreditGrantStatus of(String value) { + CreditGrantStatus constant = constants.get(Objects.requireNonNull(value, "value")); + return constant != null ? constant : new CreditGrantStatus(value, Value._UNKNOWN); + } + + /** + * The value as sent. + * + * @return the value + */ + @JsonValue + public String asString() { + return value; + } + + /** + * Whether this version of the SDK knows the value. + * + * @return whether it is known + */ + public boolean isKnown() { + return variant != Value._UNKNOWN; + } + + /** + * The value as an enum to switch on, unknown values included. + * + * @return the enum, {@code _UNKNOWN} when unknown + */ + public Value value() { + return variant; + } + + /** + * The value as an enum of the known values only. + * + * @return the enum + * @throws com.meteroid.exceptions.InvalidDataException when this version of the SDK does not + * know the value + */ + public Known known() { + if (!isKnown()) { + throw new com.meteroid.exceptions.InvalidDataException( + "unknown CreditGrantStatus: " + value); + } + return Known.valueOf(variant.name()); + } + + @Override + public String toQueryParam() { + return String.valueOf(value); + } + + @Override + public boolean equals(Object o) { + return o instanceof CreditGrantStatus + && Objects.equals(value, ((CreditGrantStatus) o).value); + } + + @Override + public int hashCode() { + return Objects.hashCode(value); + } + + @Override + public String toString() { + return String.valueOf(value); + } + + /** The values this version of the SDK knows. */ + public enum Known { + /** The {@code PENDING} constant. */ + PENDING, + /** The {@code ACTIVE} constant. */ + ACTIVE, + /** The {@code DEPLETED} constant. */ + DEPLETED, + /** The {@code EXPIRED} constant. */ + EXPIRED + } + + /** The values this version of the SDK knows, and {@code _UNKNOWN} for the others. */ + public enum Value { + /** The {@code PENDING} constant. */ + PENDING, + /** The {@code ACTIVE} constant. */ + ACTIVE, + /** The {@code DEPLETED} constant. */ + DEPLETED, + /** The {@code EXPIRED} constant. */ + EXPIRED, + /** A value this version of the SDK does not know. */ + _UNKNOWN + } +} diff --git a/src/main/java/com/meteroid/models/CreditGrantType.java b/src/main/java/com/meteroid/models/CreditGrantType.java new file mode 100644 index 0000000..261e076 --- /dev/null +++ b/src/main/java/com/meteroid/models/CreditGrantType.java @@ -0,0 +1,132 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import com.meteroid.internal.Utils.ToQueryParam; + +import java.util.Map; +import java.util.Objects; + +/** + * PAID credit was bought, through Meteroid or outside it, and applies after tax like a payment. + * PROMOTIONAL credit was given (included with a plan, a coupon, bonus credit, a goodwill grant): it + * applies before tax, like a discount, so it is spent before paid credit. Credit-unit grants are + * drawn together, whatever their type. + * + *

Values this version of the SDK does not know are kept, and sent back unchanged: {@link + * #value()} is an enum to switch on, {@code _UNKNOWN} for them, and {@link #known()} throws on + * them. + */ +public final class CreditGrantType implements ToQueryParam { + /** The value {@code "PAID"}. */ + public static final CreditGrantType PAID = new CreditGrantType("PAID", Value.PAID); + + /** The value {@code "PROMOTIONAL"}. */ + public static final CreditGrantType PROMOTIONAL = + new CreditGrantType("PROMOTIONAL", Value.PROMOTIONAL); + + private static final Map constants = + Map.ofEntries(Map.entry("PAID", PAID), Map.entry("PROMOTIONAL", PROMOTIONAL)); + + private final String value; + private final Value variant; + + private CreditGrantType(String value, Value variant) { + this.value = value; + this.variant = variant; + } + + /** + * The constant for {@code value}, or an unknown CreditGrantType holding it. + * + * @param value the value + * @return the constant + */ + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static CreditGrantType of(String value) { + CreditGrantType constant = constants.get(Objects.requireNonNull(value, "value")); + return constant != null ? constant : new CreditGrantType(value, Value._UNKNOWN); + } + + /** + * The value as sent. + * + * @return the value + */ + @JsonValue + public String asString() { + return value; + } + + /** + * Whether this version of the SDK knows the value. + * + * @return whether it is known + */ + public boolean isKnown() { + return variant != Value._UNKNOWN; + } + + /** + * The value as an enum to switch on, unknown values included. + * + * @return the enum, {@code _UNKNOWN} when unknown + */ + public Value value() { + return variant; + } + + /** + * The value as an enum of the known values only. + * + * @return the enum + * @throws com.meteroid.exceptions.InvalidDataException when this version of the SDK does not + * know the value + */ + public Known known() { + if (!isKnown()) { + throw new com.meteroid.exceptions.InvalidDataException( + "unknown CreditGrantType: " + value); + } + return Known.valueOf(variant.name()); + } + + @Override + public String toQueryParam() { + return String.valueOf(value); + } + + @Override + public boolean equals(Object o) { + return o instanceof CreditGrantType && Objects.equals(value, ((CreditGrantType) o).value); + } + + @Override + public int hashCode() { + return Objects.hashCode(value); + } + + @Override + public String toString() { + return String.valueOf(value); + } + + /** The values this version of the SDK knows. */ + public enum Known { + /** The {@code PAID} constant. */ + PAID, + /** The {@code PROMOTIONAL} constant. */ + PROMOTIONAL + } + + /** The values this version of the SDK knows, and {@code _UNKNOWN} for the others. */ + public enum Value { + /** The {@code PAID} constant. */ + PAID, + /** The {@code PROMOTIONAL} constant. */ + PROMOTIONAL, + /** A value this version of the SDK does not know. */ + _UNKNOWN + } +} diff --git a/src/main/java/com/meteroid/models/CreditPackExpiry.java b/src/main/java/com/meteroid/models/CreditPackExpiry.java new file mode 100644 index 0000000..e6b1d4c --- /dev/null +++ b/src/main/java/com/meteroid/models/CreditPackExpiry.java @@ -0,0 +1,233 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.Utils; + +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; + +/** + * How long funded credit stays spendable. BILLING_PERIOD takes value 1. + * + *

Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonAutoDetect( + getterVisibility = Visibility.NONE, + isGetterVisibility = Visibility.NONE, + setterVisibility = Visibility.NONE) +public final class CreditPackExpiry { + @JsonProperty("unit") + private CreditExpiryUnit unit; + + @JsonProperty("value") + private Integer value; + + private final Map additionalProperties = new LinkedHashMap<>(); + + private CreditPackExpiry() {} + + private CreditPackExpiry(Builder builder) { + this.unit = builder.unit; + this.value = builder.value; + this.additionalProperties.putAll(builder.additionalProperties); + } + + /** + * A builder of {@code CreditPackExpiry}. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * A builder starting from this value. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.unit = unit; + builder.value = value; + builder.additionalProperties.putAll(additionalProperties); + return builder; + } + + /** + * DAY, MONTH or BILLING_PERIOD. + * + * @return the value, never null + */ + public CreditExpiryUnit unit() { + return Utils.required(unit, "unit"); + } + + /** + * How many days or months; 1 for BILLING_PERIOD. + * + * @return the value, never null + */ + public Integer value() { + return Utils.required(value, "value"); + } + + /** + * Properties this version of the SDK does not know, kept as received and sent back. + * + * @return the properties by name, unmodifiable + */ + public Map additionalProperties() { + return Collections.unmodifiableMap(additionalProperties); + } + + @JsonAnyGetter + private Map anyProperties() { + return additionalProperties; + } + + @JsonAnySetter + private void putAnyProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CreditPackExpiry that = (CreditPackExpiry) o; + return Objects.equals(unit, that.unit) + && Objects.equals(value, that.value) + && Objects.equals(additionalProperties, that.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(unit, value, additionalProperties); + } + + @Override + public String toString() { + return "CreditPackExpiry{" + + "unit=" + + unit + + ", value=" + + value + + ", additionalProperties=" + + additionalProperties + + "}"; + } + + /** Builds {@link CreditPackExpiry}. */ + public static final class Builder { + private CreditExpiryUnit unit; + private Integer value; + private final Map additionalProperties = new LinkedHashMap<>(); + + private Builder() {} + + /** + * DAY, MONTH or BILLING_PERIOD. + * + * @param unit the value + * @return this builder + */ + public Builder unit(CreditExpiryUnit unit) { + this.unit = unit; + return this; + } + + /** + * How many days or months; 1 for BILLING_PERIOD. + * + * @param value the value + * @return this builder + */ + public Builder value(Integer value) { + this.value = value; + return this; + } + + /** + * A property the SDK does not know, sent along. + * + * @param name the property name + * @param value the JSON value + * @return this builder + */ + public Builder putAdditionalProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + return this; + } + + /** + * Properties the SDK does not know, sent along. + * + * @param additionalProperties the properties by name + * @return this builder + */ + public Builder putAllAdditionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + + /** + * Leaves out a property the SDK does not know. + * + * @param name the property name + * @return this builder + */ + public Builder removeAdditionalProperty(String name) { + additionalProperties.remove(name); + return this; + } + + /** + * The {@code CreditPackExpiry}. + * + * @return the immutable value + * @throws IllegalStateException when a required property is not set + */ + public CreditPackExpiry build() { + Utils.checkRequired(unit, "unit"); + Utils.checkRequired(value, "value"); + return new CreditPackExpiry(this); + } + } + + /** + * Parse {@code json} as {@code CreditPackExpiry}. + * + * @param json the JSON text + * @return the value + * @throws com.meteroid.exceptions.InvalidDataException if it is not valid JSON of this shape + */ + public static CreditPackExpiry fromJson(String json) { + return Utils.parse(json, CreditPackExpiry.class); + } + + /** + * This value as JSON. + * + * @return the JSON text + */ + public String toJson() { + return Utils.json(this); + } +} diff --git a/src/main/java/com/meteroid/models/CreditPackRollover.java b/src/main/java/com/meteroid/models/CreditPackRollover.java new file mode 100644 index 0000000..f559277 --- /dev/null +++ b/src/main/java/com/meteroid/models/CreditPackRollover.java @@ -0,0 +1,237 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.JsonField; +import com.meteroid.internal.Utils; + +import java.math.BigDecimal; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +/** + * Unspent included credit carried once into a new grant when it expires, spent before the next + * period's credit. + * + *

Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonAutoDetect( + getterVisibility = Visibility.NONE, + isGetterVisibility = Visibility.NONE, + setterVisibility = Visibility.NONE) +public final class CreditPackRollover { + @JsonProperty("expiry") + private CreditPackExpiry expiry; + + @JsonProperty("max_amount") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField maxAmount = JsonField.missing(); + + private final Map additionalProperties = new LinkedHashMap<>(); + + private CreditPackRollover() {} + + private CreditPackRollover(Builder builder) { + this.expiry = builder.expiry; + this.maxAmount = builder.maxAmount; + this.additionalProperties.putAll(builder.additionalProperties); + } + + /** + * A builder of {@code CreditPackRollover}. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * A builder starting from this value. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.expiry = expiry; + builder.maxAmount = maxAmount; + builder.additionalProperties.putAll(additionalProperties); + return builder; + } + + /** + * Term of the rolled credit from the original expiry: DAY or MONTH. + * + * @return the value, never null + */ + public CreditPackExpiry expiry() { + return Utils.required(expiry, "expiry"); + } + + /** + * Cap per pack, in the pack's credit; absent carries all that is left. + * + * @return the value, empty when unset or null + */ + public Optional maxAmount() { + return maxAmount.asOptional(); + } + + /** + * Properties this version of the SDK does not know, kept as received and sent back. + * + * @return the properties by name, unmodifiable + */ + public Map additionalProperties() { + return Collections.unmodifiableMap(additionalProperties); + } + + @JsonAnyGetter + private Map anyProperties() { + return additionalProperties; + } + + @JsonAnySetter + private void putAnyProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CreditPackRollover that = (CreditPackRollover) o; + return Objects.equals(expiry, that.expiry) + && Objects.equals(maxAmount, that.maxAmount) + && Objects.equals(additionalProperties, that.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(expiry, maxAmount, additionalProperties); + } + + @Override + public String toString() { + return "CreditPackRollover{" + + "expiry=" + + expiry + + ", maxAmount=" + + maxAmount + + ", additionalProperties=" + + additionalProperties + + "}"; + } + + /** Builds {@link CreditPackRollover}. */ + public static final class Builder { + private CreditPackExpiry expiry; + private JsonField maxAmount = JsonField.missing(); + private final Map additionalProperties = new LinkedHashMap<>(); + + private Builder() {} + + /** + * Term of the rolled credit from the original expiry: DAY or MONTH. + * + * @param expiry the value + * @return this builder + */ + public Builder expiry(CreditPackExpiry expiry) { + this.expiry = expiry; + return this; + } + + /** + * Cap per pack, in the pack's credit; absent carries all that is left. + * + * @param maxAmount the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder maxAmount(BigDecimal maxAmount) { + this.maxAmount = JsonField.ofNullable(maxAmount); + return this; + } + + /** + * A property the SDK does not know, sent along. + * + * @param name the property name + * @param value the JSON value + * @return this builder + */ + public Builder putAdditionalProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + return this; + } + + /** + * Properties the SDK does not know, sent along. + * + * @param additionalProperties the properties by name + * @return this builder + */ + public Builder putAllAdditionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + + /** + * Leaves out a property the SDK does not know. + * + * @param name the property name + * @return this builder + */ + public Builder removeAdditionalProperty(String name) { + additionalProperties.remove(name); + return this; + } + + /** + * The {@code CreditPackRollover}. + * + * @return the immutable value + * @throws IllegalStateException when a required property is not set + */ + public CreditPackRollover build() { + Utils.checkRequired(expiry, "expiry"); + return new CreditPackRollover(this); + } + } + + /** + * Parse {@code json} as {@code CreditPackRollover}. + * + * @param json the JSON text + * @return the value + * @throws com.meteroid.exceptions.InvalidDataException if it is not valid JSON of this shape + */ + public static CreditPackRollover fromJson(String json) { + return Utils.parse(json, CreditPackRollover.class); + } + + /** + * This value as JSON. + * + * @return the JSON text + */ + public String toJson() { + return Utils.json(this); + } +} diff --git a/src/main/java/com/meteroid/models/CreditPackUnit.java b/src/main/java/com/meteroid/models/CreditPackUnit.java new file mode 100644 index 0000000..7e227ba --- /dev/null +++ b/src/main/java/com/meteroid/models/CreditPackUnit.java @@ -0,0 +1,265 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.Utils; + +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; + +/** + * The credit unit a credit pack grants. + * + *

Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonAutoDetect( + getterVisibility = Visibility.NONE, + isGetterVisibility = Visibility.NONE, + setterVisibility = Visibility.NONE) +public final class CreditPackUnit { + @JsonProperty("code") + private String code; + + @JsonProperty("credit_unit_id") + private String creditUnitId; + + @JsonProperty("precision") + private Integer precision; + + private final Map additionalProperties = new LinkedHashMap<>(); + + private CreditPackUnit() {} + + private CreditPackUnit(Builder builder) { + this.code = builder.code; + this.creditUnitId = builder.creditUnitId; + this.precision = builder.precision; + this.additionalProperties.putAll(builder.additionalProperties); + } + + /** + * A builder of {@code CreditPackUnit}. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * A builder starting from this value. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.code = code; + builder.creditUnitId = creditUnitId; + builder.precision = precision; + builder.additionalProperties.putAll(additionalProperties); + return builder; + } + + /** + * The credit unit's code, e.g. CREDITS. + * + * @return the value, never null + */ + public String code() { + return Utils.required(code, "code"); + } + + /** + * The credit unit's id (cun_…). + * + * @return the value, never null + */ + public String creditUnitId() { + return Utils.required(creditUnitId, "credit_unit_id"); + } + + /** + * Decimal places of the unit: credit balances and ledger amounts in it are integers of + * 10^-precision credit. + * + * @return the value, never null + */ + public Integer precision() { + return Utils.required(precision, "precision"); + } + + /** + * Properties this version of the SDK does not know, kept as received and sent back. + * + * @return the properties by name, unmodifiable + */ + public Map additionalProperties() { + return Collections.unmodifiableMap(additionalProperties); + } + + @JsonAnyGetter + private Map anyProperties() { + return additionalProperties; + } + + @JsonAnySetter + private void putAnyProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CreditPackUnit that = (CreditPackUnit) o; + return Objects.equals(code, that.code) + && Objects.equals(creditUnitId, that.creditUnitId) + && Objects.equals(precision, that.precision) + && Objects.equals(additionalProperties, that.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(code, creditUnitId, precision, additionalProperties); + } + + @Override + public String toString() { + return "CreditPackUnit{" + + "code=" + + code + + ", creditUnitId=" + + creditUnitId + + ", precision=" + + precision + + ", additionalProperties=" + + additionalProperties + + "}"; + } + + /** Builds {@link CreditPackUnit}. */ + public static final class Builder { + private String code; + private String creditUnitId; + private Integer precision; + private final Map additionalProperties = new LinkedHashMap<>(); + + private Builder() {} + + /** + * The credit unit's code, e.g. CREDITS. + * + * @param code the value + * @return this builder + */ + public Builder code(String code) { + this.code = code; + return this; + } + + /** + * The credit unit's id (cun_…). + * + * @param creditUnitId the value + * @return this builder + */ + public Builder creditUnitId(String creditUnitId) { + this.creditUnitId = creditUnitId; + return this; + } + + /** + * Decimal places of the unit: credit balances and ledger amounts in it are integers of + * 10^-precision credit. + * + * @param precision the value + * @return this builder + */ + public Builder precision(Integer precision) { + this.precision = precision; + return this; + } + + /** + * A property the SDK does not know, sent along. + * + * @param name the property name + * @param value the JSON value + * @return this builder + */ + public Builder putAdditionalProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + return this; + } + + /** + * Properties the SDK does not know, sent along. + * + * @param additionalProperties the properties by name + * @return this builder + */ + public Builder putAllAdditionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + + /** + * Leaves out a property the SDK does not know. + * + * @param name the property name + * @return this builder + */ + public Builder removeAdditionalProperty(String name) { + additionalProperties.remove(name); + return this; + } + + /** + * The {@code CreditPackUnit}. + * + * @return the immutable value + * @throws IllegalStateException when a required property is not set + */ + public CreditPackUnit build() { + Utils.checkRequired(code, "code"); + Utils.checkRequired(creditUnitId, "credit_unit_id"); + Utils.checkRequired(precision, "precision"); + return new CreditPackUnit(this); + } + } + + /** + * Parse {@code json} as {@code CreditPackUnit}. + * + * @param json the JSON text + * @return the value + * @throws com.meteroid.exceptions.InvalidDataException if it is not valid JSON of this shape + */ + public static CreditPackUnit fromJson(String json) { + return Utils.parse(json, CreditPackUnit.class); + } + + /** + * This value as JSON. + * + * @return the JSON text + */ + public String toJson() { + return Utils.json(this); + } +} diff --git a/src/main/java/com/meteroid/models/CreditPlanFee.java b/src/main/java/com/meteroid/models/CreditPlanFee.java new file mode 100644 index 0000000..1b93bf9 --- /dev/null +++ b/src/main/java/com/meteroid/models/CreditPlanFee.java @@ -0,0 +1,470 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.JsonField; +import com.meteroid.internal.Utils; + +import java.math.BigDecimal; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +/** + * Credit pack: charged unit_price × quantity in advance each billing + * period, it grants credit_amount × quantity of credit, in the plan + * currency or in credit_unit_id, once paid. A zero unit_price makes it + * credit included with the plan (promotional). A currency pack priced below its credit (e.g. 500.00 + * buys 550.00) grants the price paid as paid credit and the difference as promotional bonus credit, + * which applies before tax. + * + *

Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonAutoDetect( + getterVisibility = Visibility.NONE, + isGetterVisibility = Visibility.NONE, + setterVisibility = Visibility.NONE) +public final class CreditPlanFee { + @JsonProperty("cadence") + private BillingPeriodEnum cadence; + + @JsonProperty("credit_amount") + private BigDecimal creditAmount; + + @JsonProperty("credit_unit_id") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField creditUnitId = JsonField.missing(); + + @JsonProperty("expiry") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField expiry = JsonField.missing(); + + @JsonProperty("once") + private Boolean once; + + @JsonProperty("quantity") + private Integer quantity; + + @JsonProperty("rollover") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField rollover = JsonField.missing(); + + @JsonProperty("type") + private String type = "CREDIT"; + + @JsonProperty("unit_price") + private BigDecimal unitPrice; + + private final Map additionalProperties = new LinkedHashMap<>(); + + private CreditPlanFee() {} + + private CreditPlanFee(Builder builder) { + this.cadence = builder.cadence; + this.creditAmount = builder.creditAmount; + this.creditUnitId = builder.creditUnitId; + this.expiry = builder.expiry; + this.once = builder.once; + this.quantity = builder.quantity; + this.rollover = builder.rollover; + this.type = builder.type; + this.unitPrice = builder.unitPrice; + this.additionalProperties.putAll(builder.additionalProperties); + } + + /** + * A builder of {@code CreditPlanFee}. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * A builder starting from this value. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.cadence = cadence; + builder.creditAmount = creditAmount; + builder.creditUnitId = creditUnitId; + builder.expiry = expiry; + builder.once = once; + builder.quantity = quantity; + builder.rollover = rollover; + builder.type = type; + builder.unitPrice = unitPrice; + builder.additionalProperties.putAll(additionalProperties); + return builder; + } + + /** + * The {@code cadence} property. + * + * @return the value, never null + */ + public BillingPeriodEnum cadence() { + return Utils.required(cadence, "cadence"); + } + + /** + * The {@code credit_amount} property. + * + * @return the value, never null + */ + public BigDecimal creditAmount() { + return Utils.required(creditAmount, "credit_amount"); + } + + /** + * The credit unit credit_amount is granted in; absent grants the plan currency. + * The pack is paid in the plan currency, and taxed when sold if it grants a credit unit. + * + * @return the value, empty when unset or null + */ + public Optional creditUnitId() { + return creditUnitId.asOptional(); + } + + /** + * The {@code expiry} property. + * + * @return the value, empty when unset or null + */ + public Optional expiry() { + return expiry.asOptional(); + } + + /** + * When true, the pack is billed and its credit granted once, on the subscription's first + * invoice, instead of every period (e.g. a welcome credit). A plan change grants it on the next + * invoice only if the subscription never received a one-time credit of the same product; credit + * packs billed every period don't count. Cannot be combined with rollover. + * + * @return the value, empty when unset + */ + public Optional once() { + return Optional.ofNullable(once); + } + + /** + * The {@code quantity} property. + * + * @return the value, never null + */ + public Integer quantity() { + return Utils.required(quantity, "quantity"); + } + + /** + * The {@code rollover} property. + * + * @return the value, empty when unset or null + */ + public Optional rollover() { + return rollover.asOptional(); + } + + /** + * The {@code type} property. + * + * @return the value, never null + */ + public String type() { + return Utils.required(type, "type"); + } + + /** + * The {@code unit_price} property. + * + * @return the value, never null + */ + public BigDecimal unitPrice() { + return Utils.required(unitPrice, "unit_price"); + } + + /** + * Properties this version of the SDK does not know, kept as received and sent back. + * + * @return the properties by name, unmodifiable + */ + public Map additionalProperties() { + return Collections.unmodifiableMap(additionalProperties); + } + + @JsonAnyGetter + private Map anyProperties() { + return additionalProperties; + } + + @JsonAnySetter + private void putAnyProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CreditPlanFee that = (CreditPlanFee) o; + return Objects.equals(cadence, that.cadence) + && Objects.equals(creditAmount, that.creditAmount) + && Objects.equals(creditUnitId, that.creditUnitId) + && Objects.equals(expiry, that.expiry) + && Objects.equals(once, that.once) + && Objects.equals(quantity, that.quantity) + && Objects.equals(rollover, that.rollover) + && Objects.equals(type, that.type) + && Objects.equals(unitPrice, that.unitPrice) + && Objects.equals(additionalProperties, that.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash( + cadence, + creditAmount, + creditUnitId, + expiry, + once, + quantity, + rollover, + type, + unitPrice, + additionalProperties); + } + + @Override + public String toString() { + return "CreditPlanFee{" + + "cadence=" + + cadence + + ", creditAmount=" + + creditAmount + + ", creditUnitId=" + + creditUnitId + + ", expiry=" + + expiry + + ", once=" + + once + + ", quantity=" + + quantity + + ", rollover=" + + rollover + + ", type=" + + type + + ", unitPrice=" + + unitPrice + + ", additionalProperties=" + + additionalProperties + + "}"; + } + + /** Builds {@link CreditPlanFee}. */ + public static final class Builder { + private BillingPeriodEnum cadence; + private BigDecimal creditAmount; + private JsonField creditUnitId = JsonField.missing(); + private JsonField expiry = JsonField.missing(); + private Boolean once; + private Integer quantity; + private JsonField rollover = JsonField.missing(); + private String type = "CREDIT"; + private BigDecimal unitPrice; + private final Map additionalProperties = new LinkedHashMap<>(); + + private Builder() {} + + /** + * The {@code cadence} property. + * + * @param cadence the value + * @return this builder + */ + public Builder cadence(BillingPeriodEnum cadence) { + this.cadence = cadence; + return this; + } + + /** + * The {@code credit_amount} property. + * + * @param creditAmount the value + * @return this builder + */ + public Builder creditAmount(BigDecimal creditAmount) { + this.creditAmount = creditAmount; + return this; + } + + /** + * The credit unit credit_amount is granted in; absent grants the plan + * currency. The pack is paid in the plan currency, and taxed when sold if it grants a + * credit unit. + * + * @param creditUnitId the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder creditUnitId(String creditUnitId) { + this.creditUnitId = JsonField.ofNullable(creditUnitId); + return this; + } + + /** + * The {@code expiry} property. + * + * @param expiry the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder expiry(CreditPackExpiry expiry) { + this.expiry = JsonField.ofNullable(expiry); + return this; + } + + /** + * When true, the pack is billed and its credit granted once, on the subscription's first + * invoice, instead of every period (e.g. a welcome credit). A plan change grants it on the + * next invoice only if the subscription never received a one-time credit of the same + * product; credit packs billed every period don't count. Cannot be combined with + * rollover. + * + * @param once the value + * @return this builder + */ + public Builder once(Boolean once) { + this.once = once; + return this; + } + + /** + * The {@code quantity} property. + * + * @param quantity the value + * @return this builder + */ + public Builder quantity(Integer quantity) { + this.quantity = quantity; + return this; + } + + /** + * The {@code rollover} property. + * + * @param rollover the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder rollover(CreditPackRollover rollover) { + this.rollover = JsonField.ofNullable(rollover); + return this; + } + + /** + * The {@code type} property. + * + * @param type the value + * @return this builder + */ + public Builder type(String type) { + this.type = type; + return this; + } + + /** + * The {@code unit_price} property. + * + * @param unitPrice the value + * @return this builder + */ + public Builder unitPrice(BigDecimal unitPrice) { + this.unitPrice = unitPrice; + return this; + } + + /** + * A property the SDK does not know, sent along. + * + * @param name the property name + * @param value the JSON value + * @return this builder + */ + public Builder putAdditionalProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + return this; + } + + /** + * Properties the SDK does not know, sent along. + * + * @param additionalProperties the properties by name + * @return this builder + */ + public Builder putAllAdditionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + + /** + * Leaves out a property the SDK does not know. + * + * @param name the property name + * @return this builder + */ + public Builder removeAdditionalProperty(String name) { + additionalProperties.remove(name); + return this; + } + + /** + * The {@code CreditPlanFee}. + * + * @return the immutable value + * @throws IllegalStateException when a required property is not set + */ + public CreditPlanFee build() { + Utils.checkRequired(cadence, "cadence"); + Utils.checkRequired(creditAmount, "credit_amount"); + Utils.checkRequired(quantity, "quantity"); + Utils.checkRequired(type, "type"); + Utils.checkRequired(unitPrice, "unit_price"); + return new CreditPlanFee(this); + } + } + + /** + * Parse {@code json} as {@code CreditPlanFee}. + * + * @param json the JSON text + * @return the value + * @throws com.meteroid.exceptions.InvalidDataException if it is not valid JSON of this shape + */ + public static CreditPlanFee fromJson(String json) { + return Utils.parse(json, CreditPlanFee.class); + } + + /** + * This value as JSON. + * + * @return the JSON text + */ + public String toJson() { + return Utils.json(this); + } +} diff --git a/src/main/java/com/meteroid/models/CreditUnit.java b/src/main/java/com/meteroid/models/CreditUnit.java new file mode 100644 index 0000000..fff15a2 --- /dev/null +++ b/src/main/java/com/meteroid/models/CreditUnit.java @@ -0,0 +1,475 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.JsonField; +import com.meteroid.internal.Utils; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +/** + * A tenant-defined denomination usage can be priced or credit granted in, instead of money. + * code and precision are immutable once created. + * + *

Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonAutoDetect( + getterVisibility = Visibility.NONE, + isGetterVisibility = Visibility.NONE, + setterVisibility = Visibility.NONE) +public final class CreditUnit { + @JsonProperty("archived") + private Boolean archived; + + @JsonProperty("code") + private String code; + + @JsonProperty("id") + private String id; + + @JsonProperty("name") + private String name; + + @JsonProperty("plural_name") + private String pluralName; + + @JsonProperty("precision") + private Integer precision; + + @JsonProperty("prices") + private List prices; + + @JsonProperty("product_id") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField productId = JsonField.missing(); + + @JsonProperty("symbol") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField symbol = JsonField.missing(); + + private final Map additionalProperties = new LinkedHashMap<>(); + + private CreditUnit() {} + + private CreditUnit(Builder builder) { + this.archived = builder.archived; + this.code = builder.code; + this.id = builder.id; + this.name = builder.name; + this.pluralName = builder.pluralName; + this.precision = builder.precision; + this.prices = Utils.copyList(builder.prices); + this.productId = builder.productId; + this.symbol = builder.symbol; + this.additionalProperties.putAll(builder.additionalProperties); + } + + /** + * A builder of {@code CreditUnit}. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * A builder starting from this value. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.archived = archived; + builder.code = code; + builder.id = id; + builder.name = name; + builder.pluralName = pluralName; + builder.precision = precision; + builder.prices = Utils.mutableList(prices); + builder.productId = productId; + builder.symbol = symbol; + builder.additionalProperties.putAll(additionalProperties); + return builder; + } + + /** + * Archived units take no new prices, packs or grants; existing ones keep working. + * + * @return the value, never null + */ + public Boolean archived() { + return Utils.required(archived, "archived"); + } + + /** + * Upper-case code naming the unit in wallets, grants and webhooks, e.g. CREDITS. + * + * @return the value, never null + */ + public String code() { + return Utils.required(code, "code"); + } + + /** + * The unit's id (cun_…). + * + * @return the value, never null + */ + public String id() { + return Utils.required(id, "id"); + } + + /** + * Singular display name, e.g. "Credit". + * + * @return the value, never null + */ + public String name() { + return Utils.required(name, "name"); + } + + /** + * Plural display name, e.g. "Credits". + * + * @return the value, never null + */ + public String pluralName() { + return Utils.required(pluralName, "plural_name"); + } + + /** + * Minor-unit exponent: amounts of this unit are integers of 10^-precision credit. + * + * @return the value, never null + */ + public Integer precision() { + return Utils.required(precision, "precision"); + } + + /** + * The active selling prices, one per currency. + * + * @return the value, never null + */ + public List prices() { + return Utils.required(prices, "prices"); + } + + /** + * The product sales of this unit are booked under: their tax category and accounting code. The + * unit can be sold (top-ups) only once it is set. + * + * @return the value, empty when unset or null + */ + public Optional productId() { + return productId.asOptional(); + } + + /** + * Short display symbol, e.g. "cr". + * + * @return the value, empty when unset or null + */ + public Optional symbol() { + return symbol.asOptional(); + } + + /** + * Properties this version of the SDK does not know, kept as received and sent back. + * + * @return the properties by name, unmodifiable + */ + public Map additionalProperties() { + return Collections.unmodifiableMap(additionalProperties); + } + + @JsonAnyGetter + private Map anyProperties() { + return additionalProperties; + } + + @JsonAnySetter + private void putAnyProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CreditUnit that = (CreditUnit) o; + return Objects.equals(archived, that.archived) + && Objects.equals(code, that.code) + && Objects.equals(id, that.id) + && Objects.equals(name, that.name) + && Objects.equals(pluralName, that.pluralName) + && Objects.equals(precision, that.precision) + && Objects.equals(prices, that.prices) + && Objects.equals(productId, that.productId) + && Objects.equals(symbol, that.symbol) + && Objects.equals(additionalProperties, that.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash( + archived, + code, + id, + name, + pluralName, + precision, + prices, + productId, + symbol, + additionalProperties); + } + + @Override + public String toString() { + return "CreditUnit{" + + "archived=" + + archived + + ", code=" + + code + + ", id=" + + id + + ", name=" + + name + + ", pluralName=" + + pluralName + + ", precision=" + + precision + + ", prices=" + + prices + + ", productId=" + + productId + + ", symbol=" + + symbol + + ", additionalProperties=" + + additionalProperties + + "}"; + } + + /** Builds {@link CreditUnit}. */ + public static final class Builder { + private Boolean archived; + private String code; + private String id; + private String name; + private String pluralName; + private Integer precision; + private List prices; + private JsonField productId = JsonField.missing(); + private JsonField symbol = JsonField.missing(); + private final Map additionalProperties = new LinkedHashMap<>(); + + private Builder() {} + + /** + * Archived units take no new prices, packs or grants; existing ones keep working. + * + * @param archived the value + * @return this builder + */ + public Builder archived(Boolean archived) { + this.archived = archived; + return this; + } + + /** + * Upper-case code naming the unit in wallets, grants and webhooks, e.g. CREDITS + * . + * + * @param code the value + * @return this builder + */ + public Builder code(String code) { + this.code = code; + return this; + } + + /** + * The unit's id (cun_…). + * + * @param id the value + * @return this builder + */ + public Builder id(String id) { + this.id = id; + return this; + } + + /** + * Singular display name, e.g. "Credit". + * + * @param name the value + * @return this builder + */ + public Builder name(String name) { + this.name = name; + return this; + } + + /** + * Plural display name, e.g. "Credits". + * + * @param pluralName the value + * @return this builder + */ + public Builder pluralName(String pluralName) { + this.pluralName = pluralName; + return this; + } + + /** + * Minor-unit exponent: amounts of this unit are integers of 10^-precision credit. + * + * @param precision the value + * @return this builder + */ + public Builder precision(Integer precision) { + this.precision = precision; + return this; + } + + /** + * The active selling prices, one per currency. + * + * @param prices the value + * @return this builder + */ + public Builder prices(List prices) { + this.prices = Utils.mutableList(prices); + return this; + } + + /** + * Adds an item to {@code prices}. + * + * @param item the item + * @return this builder + */ + public Builder addPricesItem(CreditUnitPrice item) { + if (this.prices == null) { + this.prices = new ArrayList<>(); + } + this.prices.add(item); + return this; + } + + /** + * The product sales of this unit are booked under: their tax category and accounting code. + * The unit can be sold (top-ups) only once it is set. + * + * @param productId the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder productId(String productId) { + this.productId = JsonField.ofNullable(productId); + return this; + } + + /** + * Short display symbol, e.g. "cr". + * + * @param symbol the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder symbol(String symbol) { + this.symbol = JsonField.ofNullable(symbol); + return this; + } + + /** + * A property the SDK does not know, sent along. + * + * @param name the property name + * @param value the JSON value + * @return this builder + */ + public Builder putAdditionalProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + return this; + } + + /** + * Properties the SDK does not know, sent along. + * + * @param additionalProperties the properties by name + * @return this builder + */ + public Builder putAllAdditionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + + /** + * Leaves out a property the SDK does not know. + * + * @param name the property name + * @return this builder + */ + public Builder removeAdditionalProperty(String name) { + additionalProperties.remove(name); + return this; + } + + /** + * The {@code CreditUnit}. + * + * @return the immutable value + * @throws IllegalStateException when a required property is not set + */ + public CreditUnit build() { + Utils.checkRequired(archived, "archived"); + Utils.checkRequired(code, "code"); + Utils.checkRequired(id, "id"); + Utils.checkRequired(name, "name"); + Utils.checkRequired(pluralName, "plural_name"); + Utils.checkRequired(precision, "precision"); + Utils.checkRequired(prices, "prices"); + return new CreditUnit(this); + } + } + + /** + * Parse {@code json} as {@code CreditUnit}. + * + * @param json the JSON text + * @return the value + * @throws com.meteroid.exceptions.InvalidDataException if it is not valid JSON of this shape + */ + public static CreditUnit fromJson(String json) { + return Utils.parse(json, CreditUnit.class); + } + + /** + * This value as JSON. + * + * @return the JSON text + */ + public String toJson() { + return Utils.json(this); + } +} diff --git a/src/main/java/com/meteroid/models/CreditUnitCreateRequest.java b/src/main/java/com/meteroid/models/CreditUnitCreateRequest.java new file mode 100644 index 0000000..6242fda --- /dev/null +++ b/src/main/java/com/meteroid/models/CreditUnitCreateRequest.java @@ -0,0 +1,327 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.JsonField; +import com.meteroid.internal.Utils; + +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +/** + * A new credit unit. + * + *

Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonAutoDetect( + getterVisibility = Visibility.NONE, + isGetterVisibility = Visibility.NONE, + setterVisibility = Visibility.NONE) +public final class CreditUnitCreateRequest { + @JsonProperty("code") + private String code; + + @JsonProperty("name") + private String name; + + @JsonProperty("plural_name") + private String pluralName; + + @JsonProperty("precision") + private Integer precision; + + @JsonProperty("symbol") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField symbol = JsonField.missing(); + + private final Map additionalProperties = new LinkedHashMap<>(); + + private CreditUnitCreateRequest() {} + + private CreditUnitCreateRequest(Builder builder) { + this.code = builder.code; + this.name = builder.name; + this.pluralName = builder.pluralName; + this.precision = builder.precision; + this.symbol = builder.symbol; + this.additionalProperties.putAll(builder.additionalProperties); + } + + /** + * A builder of {@code CreditUnitCreateRequest}. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * A builder starting from this value. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.code = code; + builder.name = name; + builder.pluralName = pluralName; + builder.precision = precision; + builder.symbol = symbol; + builder.additionalProperties.putAll(additionalProperties); + return builder; + } + + /** + * Immutable once created: 4 to 16 characters, A-Z/0-9/_, starting with a letter. Never an ISO + * currency code (those are always 3 letters). + * + * @return the value, never null + */ + public String code() { + return Utils.required(code, "code"); + } + + /** + * Singular display name, 1 to 64 characters, e.g. "Credit". + * + * @return the value, never null + */ + public String name() { + return Utils.required(name, "name"); + } + + /** + * Plural display name, 1 to 64 characters, e.g. "Credits". + * + * @return the value, never null + */ + public String pluralName() { + return Utils.required(pluralName, "plural_name"); + } + + /** + * Immutable once created: 0 to 6. + * + * @return the value, never null + */ + public Integer precision() { + return Utils.required(precision, "precision"); + } + + /** + * Short display symbol, at most 8 characters. + * + * @return the value, empty when unset or null + */ + public Optional symbol() { + return symbol.asOptional(); + } + + /** + * Properties this version of the SDK does not know, kept as received and sent back. + * + * @return the properties by name, unmodifiable + */ + public Map additionalProperties() { + return Collections.unmodifiableMap(additionalProperties); + } + + @JsonAnyGetter + private Map anyProperties() { + return additionalProperties; + } + + @JsonAnySetter + private void putAnyProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CreditUnitCreateRequest that = (CreditUnitCreateRequest) o; + return Objects.equals(code, that.code) + && Objects.equals(name, that.name) + && Objects.equals(pluralName, that.pluralName) + && Objects.equals(precision, that.precision) + && Objects.equals(symbol, that.symbol) + && Objects.equals(additionalProperties, that.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(code, name, pluralName, precision, symbol, additionalProperties); + } + + @Override + public String toString() { + return "CreditUnitCreateRequest{" + + "code=" + + code + + ", name=" + + name + + ", pluralName=" + + pluralName + + ", precision=" + + precision + + ", symbol=" + + symbol + + ", additionalProperties=" + + additionalProperties + + "}"; + } + + /** Builds {@link CreditUnitCreateRequest}. */ + public static final class Builder { + private String code; + private String name; + private String pluralName; + private Integer precision; + private JsonField symbol = JsonField.missing(); + private final Map additionalProperties = new LinkedHashMap<>(); + + private Builder() {} + + /** + * Immutable once created: 4 to 16 characters, A-Z/0-9/_, starting with a letter. Never an + * ISO currency code (those are always 3 letters). + * + * @param code the value + * @return this builder + */ + public Builder code(String code) { + this.code = code; + return this; + } + + /** + * Singular display name, 1 to 64 characters, e.g. "Credit". + * + * @param name the value + * @return this builder + */ + public Builder name(String name) { + this.name = name; + return this; + } + + /** + * Plural display name, 1 to 64 characters, e.g. "Credits". + * + * @param pluralName the value + * @return this builder + */ + public Builder pluralName(String pluralName) { + this.pluralName = pluralName; + return this; + } + + /** + * Immutable once created: 0 to 6. + * + * @param precision the value + * @return this builder + */ + public Builder precision(Integer precision) { + this.precision = precision; + return this; + } + + /** + * Short display symbol, at most 8 characters. + * + * @param symbol the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder symbol(String symbol) { + this.symbol = JsonField.ofNullable(symbol); + return this; + } + + /** + * A property the SDK does not know, sent along. + * + * @param name the property name + * @param value the JSON value + * @return this builder + */ + public Builder putAdditionalProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + return this; + } + + /** + * Properties the SDK does not know, sent along. + * + * @param additionalProperties the properties by name + * @return this builder + */ + public Builder putAllAdditionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + + /** + * Leaves out a property the SDK does not know. + * + * @param name the property name + * @return this builder + */ + public Builder removeAdditionalProperty(String name) { + additionalProperties.remove(name); + return this; + } + + /** + * The {@code CreditUnitCreateRequest}. + * + * @return the immutable value + * @throws IllegalStateException when a required property is not set + */ + public CreditUnitCreateRequest build() { + Utils.checkRequired(code, "code"); + Utils.checkRequired(name, "name"); + Utils.checkRequired(pluralName, "plural_name"); + Utils.checkRequired(precision, "precision"); + return new CreditUnitCreateRequest(this); + } + } + + /** + * Parse {@code json} as {@code CreditUnitCreateRequest}. + * + * @param json the JSON text + * @return the value + * @throws com.meteroid.exceptions.InvalidDataException if it is not valid JSON of this shape + */ + public static CreditUnitCreateRequest fromJson(String json) { + return Utils.parse(json, CreditUnitCreateRequest.class); + } + + /** + * This value as JSON. + * + * @return the JSON text + */ + public String toJson() { + return Utils.json(this); + } +} diff --git a/src/main/java/com/meteroid/models/CreditUnitListResponse.java b/src/main/java/com/meteroid/models/CreditUnitListResponse.java new file mode 100644 index 0000000..182d48a --- /dev/null +++ b/src/main/java/com/meteroid/models/CreditUnitListResponse.java @@ -0,0 +1,219 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.Utils; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * The tenant's credit units. + * + *

Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonAutoDetect( + getterVisibility = Visibility.NONE, + isGetterVisibility = Visibility.NONE, + setterVisibility = Visibility.NONE) +public final class CreditUnitListResponse { + @JsonProperty("data") + private List data; + + private final Map additionalProperties = new LinkedHashMap<>(); + + private CreditUnitListResponse() {} + + private CreditUnitListResponse(Builder builder) { + this.data = Utils.copyList(builder.data); + this.additionalProperties.putAll(builder.additionalProperties); + } + + /** + * A builder of {@code CreditUnitListResponse}. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * A builder starting from this value. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.data = Utils.mutableList(data); + builder.additionalProperties.putAll(additionalProperties); + return builder; + } + + /** + * The {@code data} property. + * + * @return the value, never null + */ + public List data() { + return Utils.required(data, "data"); + } + + /** + * Properties this version of the SDK does not know, kept as received and sent back. + * + * @return the properties by name, unmodifiable + */ + public Map additionalProperties() { + return Collections.unmodifiableMap(additionalProperties); + } + + @JsonAnyGetter + private Map anyProperties() { + return additionalProperties; + } + + @JsonAnySetter + private void putAnyProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CreditUnitListResponse that = (CreditUnitListResponse) o; + return Objects.equals(data, that.data) + && Objects.equals(additionalProperties, that.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(data, additionalProperties); + } + + @Override + public String toString() { + return "CreditUnitListResponse{" + + "data=" + + data + + ", additionalProperties=" + + additionalProperties + + "}"; + } + + /** Builds {@link CreditUnitListResponse}. */ + public static final class Builder { + private List data; + private final Map additionalProperties = new LinkedHashMap<>(); + + private Builder() {} + + /** + * The {@code data} property. + * + * @param data the value + * @return this builder + */ + public Builder data(List data) { + this.data = Utils.mutableList(data); + return this; + } + + /** + * Adds an item to {@code data}. + * + * @param item the item + * @return this builder + */ + public Builder addDataItem(CreditUnit item) { + if (this.data == null) { + this.data = new ArrayList<>(); + } + this.data.add(item); + return this; + } + + /** + * A property the SDK does not know, sent along. + * + * @param name the property name + * @param value the JSON value + * @return this builder + */ + public Builder putAdditionalProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + return this; + } + + /** + * Properties the SDK does not know, sent along. + * + * @param additionalProperties the properties by name + * @return this builder + */ + public Builder putAllAdditionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + + /** + * Leaves out a property the SDK does not know. + * + * @param name the property name + * @return this builder + */ + public Builder removeAdditionalProperty(String name) { + additionalProperties.remove(name); + return this; + } + + /** + * The {@code CreditUnitListResponse}. + * + * @return the immutable value + * @throws IllegalStateException when a required property is not set + */ + public CreditUnitListResponse build() { + Utils.checkRequired(data, "data"); + return new CreditUnitListResponse(this); + } + } + + /** + * Parse {@code json} as {@code CreditUnitListResponse}. + * + * @param json the JSON text + * @return the value + * @throws com.meteroid.exceptions.InvalidDataException if it is not valid JSON of this shape + */ + public static CreditUnitListResponse fromJson(String json) { + return Utils.parse(json, CreditUnitListResponse.class); + } + + /** + * This value as JSON. + * + * @return the JSON text + */ + public String toJson() { + return Utils.json(this); + } +} diff --git a/src/main/java/com/meteroid/models/CreditUnitPrice.java b/src/main/java/com/meteroid/models/CreditUnitPrice.java new file mode 100644 index 0000000..583a94b --- /dev/null +++ b/src/main/java/com/meteroid/models/CreditUnitPrice.java @@ -0,0 +1,327 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.JsonField; +import com.meteroid.internal.Utils; + +import java.time.OffsetDateTime; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +/** + * What one credit sells for in a currency. A price is never edited: setting a new one for the same + * currency archives it. + * + *

Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonAutoDetect( + getterVisibility = Visibility.NONE, + isGetterVisibility = Visibility.NONE, + setterVisibility = Visibility.NONE) +public final class CreditUnitPrice { + @JsonProperty("archived_at") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField archivedAt = JsonField.missing(); + + @JsonProperty("created_at") + private OffsetDateTime createdAt; + + @JsonProperty("currency") + private String currency; + + @JsonProperty("id") + private String id; + + @JsonProperty("unit_price") + private String unitPrice; + + private final Map additionalProperties = new LinkedHashMap<>(); + + private CreditUnitPrice() {} + + private CreditUnitPrice(Builder builder) { + this.archivedAt = builder.archivedAt; + this.createdAt = builder.createdAt; + this.currency = builder.currency; + this.id = builder.id; + this.unitPrice = builder.unitPrice; + this.additionalProperties.putAll(builder.additionalProperties); + } + + /** + * A builder of {@code CreditUnitPrice}. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * A builder starting from this value. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.archivedAt = archivedAt; + builder.createdAt = createdAt; + builder.currency = currency; + builder.id = id; + builder.unitPrice = unitPrice; + builder.additionalProperties.putAll(additionalProperties); + return builder; + } + + /** + * When a newer price, or its removal, replaced it; absent while active. + * + * @return the value, empty when unset or null + */ + public Optional archivedAt() { + return archivedAt.asOptional(); + } + + /** + * When the price was set. + * + * @return the value, never null + */ + public OffsetDateTime createdAt() { + return Utils.required(createdAt, "created_at"); + } + + /** + * ISO 4217 code of the currency the unit sells in. + * + * @return the value, never null + */ + public String currency() { + return Utils.required(currency, "currency"); + } + + /** + * The price's id (cup_…). + * + * @return the value, never null + */ + public String id() { + return Utils.required(id, "id"); + } + + /** + * Major units of currency per credit, as a decimal string (e.g. "0.001"). + * + * @return the value, never null + */ + public String unitPrice() { + return Utils.required(unitPrice, "unit_price"); + } + + /** + * Properties this version of the SDK does not know, kept as received and sent back. + * + * @return the properties by name, unmodifiable + */ + public Map additionalProperties() { + return Collections.unmodifiableMap(additionalProperties); + } + + @JsonAnyGetter + private Map anyProperties() { + return additionalProperties; + } + + @JsonAnySetter + private void putAnyProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CreditUnitPrice that = (CreditUnitPrice) o; + return Objects.equals(archivedAt, that.archivedAt) + && Objects.equals(createdAt, that.createdAt) + && Objects.equals(currency, that.currency) + && Objects.equals(id, that.id) + && Objects.equals(unitPrice, that.unitPrice) + && Objects.equals(additionalProperties, that.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(archivedAt, createdAt, currency, id, unitPrice, additionalProperties); + } + + @Override + public String toString() { + return "CreditUnitPrice{" + + "archivedAt=" + + archivedAt + + ", createdAt=" + + createdAt + + ", currency=" + + currency + + ", id=" + + id + + ", unitPrice=" + + unitPrice + + ", additionalProperties=" + + additionalProperties + + "}"; + } + + /** Builds {@link CreditUnitPrice}. */ + public static final class Builder { + private JsonField archivedAt = JsonField.missing(); + private OffsetDateTime createdAt; + private String currency; + private String id; + private String unitPrice; + private final Map additionalProperties = new LinkedHashMap<>(); + + private Builder() {} + + /** + * When a newer price, or its removal, replaced it; absent while active. + * + * @param archivedAt the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder archivedAt(OffsetDateTime archivedAt) { + this.archivedAt = JsonField.ofNullable(archivedAt); + return this; + } + + /** + * When the price was set. + * + * @param createdAt the value + * @return this builder + */ + public Builder createdAt(OffsetDateTime createdAt) { + this.createdAt = createdAt; + return this; + } + + /** + * ISO 4217 code of the currency the unit sells in. + * + * @param currency the value + * @return this builder + */ + public Builder currency(String currency) { + this.currency = currency; + return this; + } + + /** + * The price's id (cup_…). + * + * @param id the value + * @return this builder + */ + public Builder id(String id) { + this.id = id; + return this; + } + + /** + * Major units of currency per credit, as a decimal string (e.g. "0.001"). + * + * @param unitPrice the value + * @return this builder + */ + public Builder unitPrice(String unitPrice) { + this.unitPrice = unitPrice; + return this; + } + + /** + * A property the SDK does not know, sent along. + * + * @param name the property name + * @param value the JSON value + * @return this builder + */ + public Builder putAdditionalProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + return this; + } + + /** + * Properties the SDK does not know, sent along. + * + * @param additionalProperties the properties by name + * @return this builder + */ + public Builder putAllAdditionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + + /** + * Leaves out a property the SDK does not know. + * + * @param name the property name + * @return this builder + */ + public Builder removeAdditionalProperty(String name) { + additionalProperties.remove(name); + return this; + } + + /** + * The {@code CreditUnitPrice}. + * + * @return the immutable value + * @throws IllegalStateException when a required property is not set + */ + public CreditUnitPrice build() { + Utils.checkRequired(createdAt, "created_at"); + Utils.checkRequired(currency, "currency"); + Utils.checkRequired(id, "id"); + Utils.checkRequired(unitPrice, "unit_price"); + return new CreditUnitPrice(this); + } + } + + /** + * Parse {@code json} as {@code CreditUnitPrice}. + * + * @param json the JSON text + * @return the value + * @throws com.meteroid.exceptions.InvalidDataException if it is not valid JSON of this shape + */ + public static CreditUnitPrice fromJson(String json) { + return Utils.parse(json, CreditUnitPrice.class); + } + + /** + * This value as JSON. + * + * @return the JSON text + */ + public String toJson() { + return Utils.json(this); + } +} diff --git a/src/main/java/com/meteroid/models/CreditUnitPriceListResponse.java b/src/main/java/com/meteroid/models/CreditUnitPriceListResponse.java new file mode 100644 index 0000000..b944d99 --- /dev/null +++ b/src/main/java/com/meteroid/models/CreditUnitPriceListResponse.java @@ -0,0 +1,219 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.Utils; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * A credit unit's selling prices, newest first. + * + *

Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonAutoDetect( + getterVisibility = Visibility.NONE, + isGetterVisibility = Visibility.NONE, + setterVisibility = Visibility.NONE) +public final class CreditUnitPriceListResponse { + @JsonProperty("data") + private List data; + + private final Map additionalProperties = new LinkedHashMap<>(); + + private CreditUnitPriceListResponse() {} + + private CreditUnitPriceListResponse(Builder builder) { + this.data = Utils.copyList(builder.data); + this.additionalProperties.putAll(builder.additionalProperties); + } + + /** + * A builder of {@code CreditUnitPriceListResponse}. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * A builder starting from this value. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.data = Utils.mutableList(data); + builder.additionalProperties.putAll(additionalProperties); + return builder; + } + + /** + * The {@code data} property. + * + * @return the value, never null + */ + public List data() { + return Utils.required(data, "data"); + } + + /** + * Properties this version of the SDK does not know, kept as received and sent back. + * + * @return the properties by name, unmodifiable + */ + public Map additionalProperties() { + return Collections.unmodifiableMap(additionalProperties); + } + + @JsonAnyGetter + private Map anyProperties() { + return additionalProperties; + } + + @JsonAnySetter + private void putAnyProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CreditUnitPriceListResponse that = (CreditUnitPriceListResponse) o; + return Objects.equals(data, that.data) + && Objects.equals(additionalProperties, that.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(data, additionalProperties); + } + + @Override + public String toString() { + return "CreditUnitPriceListResponse{" + + "data=" + + data + + ", additionalProperties=" + + additionalProperties + + "}"; + } + + /** Builds {@link CreditUnitPriceListResponse}. */ + public static final class Builder { + private List data; + private final Map additionalProperties = new LinkedHashMap<>(); + + private Builder() {} + + /** + * The {@code data} property. + * + * @param data the value + * @return this builder + */ + public Builder data(List data) { + this.data = Utils.mutableList(data); + return this; + } + + /** + * Adds an item to {@code data}. + * + * @param item the item + * @return this builder + */ + public Builder addDataItem(CreditUnitPrice item) { + if (this.data == null) { + this.data = new ArrayList<>(); + } + this.data.add(item); + return this; + } + + /** + * A property the SDK does not know, sent along. + * + * @param name the property name + * @param value the JSON value + * @return this builder + */ + public Builder putAdditionalProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + return this; + } + + /** + * Properties the SDK does not know, sent along. + * + * @param additionalProperties the properties by name + * @return this builder + */ + public Builder putAllAdditionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + + /** + * Leaves out a property the SDK does not know. + * + * @param name the property name + * @return this builder + */ + public Builder removeAdditionalProperty(String name) { + additionalProperties.remove(name); + return this; + } + + /** + * The {@code CreditUnitPriceListResponse}. + * + * @return the immutable value + * @throws IllegalStateException when a required property is not set + */ + public CreditUnitPriceListResponse build() { + Utils.checkRequired(data, "data"); + return new CreditUnitPriceListResponse(this); + } + } + + /** + * Parse {@code json} as {@code CreditUnitPriceListResponse}. + * + * @param json the JSON text + * @return the value + * @throws com.meteroid.exceptions.InvalidDataException if it is not valid JSON of this shape + */ + public static CreditUnitPriceListResponse fromJson(String json) { + return Utils.parse(json, CreditUnitPriceListResponse.class); + } + + /** + * This value as JSON. + * + * @return the JSON text + */ + public String toJson() { + return Utils.json(this); + } +} diff --git a/src/main/java/com/meteroid/models/CreditUnitPriceSetRequest.java b/src/main/java/com/meteroid/models/CreditUnitPriceSetRequest.java new file mode 100644 index 0000000..380a2cb --- /dev/null +++ b/src/main/java/com/meteroid/models/CreditUnitPriceSetRequest.java @@ -0,0 +1,205 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.Utils; + +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; + +/** + * The new price of one credit in a currency. + * + *

Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonAutoDetect( + getterVisibility = Visibility.NONE, + isGetterVisibility = Visibility.NONE, + setterVisibility = Visibility.NONE) +public final class CreditUnitPriceSetRequest { + @JsonProperty("unit_price") + private String unitPrice; + + private final Map additionalProperties = new LinkedHashMap<>(); + + private CreditUnitPriceSetRequest() {} + + private CreditUnitPriceSetRequest(Builder builder) { + this.unitPrice = builder.unitPrice; + this.additionalProperties.putAll(builder.additionalProperties); + } + + /** + * A builder of {@code CreditUnitPriceSetRequest}. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * A builder starting from this value. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.unitPrice = unitPrice; + builder.additionalProperties.putAll(additionalProperties); + return builder; + } + + /** + * Major units of the currency per credit, as a decimal string: positive, at most 12 decimal + * places. + * + * @return the value, never null + */ + public String unitPrice() { + return Utils.required(unitPrice, "unit_price"); + } + + /** + * Properties this version of the SDK does not know, kept as received and sent back. + * + * @return the properties by name, unmodifiable + */ + public Map additionalProperties() { + return Collections.unmodifiableMap(additionalProperties); + } + + @JsonAnyGetter + private Map anyProperties() { + return additionalProperties; + } + + @JsonAnySetter + private void putAnyProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CreditUnitPriceSetRequest that = (CreditUnitPriceSetRequest) o; + return Objects.equals(unitPrice, that.unitPrice) + && Objects.equals(additionalProperties, that.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(unitPrice, additionalProperties); + } + + @Override + public String toString() { + return "CreditUnitPriceSetRequest{" + + "unitPrice=" + + unitPrice + + ", additionalProperties=" + + additionalProperties + + "}"; + } + + /** Builds {@link CreditUnitPriceSetRequest}. */ + public static final class Builder { + private String unitPrice; + private final Map additionalProperties = new LinkedHashMap<>(); + + private Builder() {} + + /** + * Major units of the currency per credit, as a decimal string: positive, at most 12 decimal + * places. + * + * @param unitPrice the value + * @return this builder + */ + public Builder unitPrice(String unitPrice) { + this.unitPrice = unitPrice; + return this; + } + + /** + * A property the SDK does not know, sent along. + * + * @param name the property name + * @param value the JSON value + * @return this builder + */ + public Builder putAdditionalProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + return this; + } + + /** + * Properties the SDK does not know, sent along. + * + * @param additionalProperties the properties by name + * @return this builder + */ + public Builder putAllAdditionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + + /** + * Leaves out a property the SDK does not know. + * + * @param name the property name + * @return this builder + */ + public Builder removeAdditionalProperty(String name) { + additionalProperties.remove(name); + return this; + } + + /** + * The {@code CreditUnitPriceSetRequest}. + * + * @return the immutable value + * @throws IllegalStateException when a required property is not set + */ + public CreditUnitPriceSetRequest build() { + Utils.checkRequired(unitPrice, "unit_price"); + return new CreditUnitPriceSetRequest(this); + } + } + + /** + * Parse {@code json} as {@code CreditUnitPriceSetRequest}. + * + * @param json the JSON text + * @return the value + * @throws com.meteroid.exceptions.InvalidDataException if it is not valid JSON of this shape + */ + public static CreditUnitPriceSetRequest fromJson(String json) { + return Utils.parse(json, CreditUnitPriceSetRequest.class); + } + + /** + * This value as JSON. + * + * @return the JSON text + */ + public String toJson() { + return Utils.json(this); + } +} diff --git a/src/main/java/com/meteroid/models/CreditUnitUpdateRequest.java b/src/main/java/com/meteroid/models/CreditUnitUpdateRequest.java new file mode 100644 index 0000000..146bcc9 --- /dev/null +++ b/src/main/java/com/meteroid/models/CreditUnitUpdateRequest.java @@ -0,0 +1,330 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.JsonField; +import com.meteroid.internal.Utils; + +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +/** + * Partial update: an absent field is left unchanged. code and precision + * have no field here, they are immutable. symbol set to null clears it. + * + *

Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonAutoDetect( + getterVisibility = Visibility.NONE, + isGetterVisibility = Visibility.NONE, + setterVisibility = Visibility.NONE) +public final class CreditUnitUpdateRequest { + @JsonProperty("archived") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField archived = JsonField.missing(); + + @JsonProperty("name") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField name = JsonField.missing(); + + @JsonProperty("plural_name") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField pluralName = JsonField.missing(); + + @JsonProperty("product_id") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField productId = JsonField.missing(); + + @JsonProperty("symbol") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField symbol = JsonField.missing(); + + private final Map additionalProperties = new LinkedHashMap<>(); + + private CreditUnitUpdateRequest() {} + + private CreditUnitUpdateRequest(Builder builder) { + this.archived = builder.archived; + this.name = builder.name; + this.pluralName = builder.pluralName; + this.productId = builder.productId; + this.symbol = builder.symbol; + this.additionalProperties.putAll(builder.additionalProperties); + } + + /** + * A builder of {@code CreditUnitUpdateRequest}. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * A builder starting from this value. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.archived = archived; + builder.name = name; + builder.pluralName = pluralName; + builder.productId = productId; + builder.symbol = symbol; + builder.additionalProperties.putAll(additionalProperties); + return builder; + } + + /** + * Blocks the unit from new prices, packs and grants; existing ones keep working. + * + * @return the value, empty when unset or null + */ + public Optional archived() { + return archived.asOptional(); + } + + /** + * Singular display name, 1 to 64 characters. + * + * @return the value, empty when unset or null + */ + public Optional name() { + return name.asOptional(); + } + + /** + * Plural display name, 1 to 64 characters. + * + * @return the value, empty when unset or null + */ + public Optional pluralName() { + return pluralName.asOptional(); + } + + /** + * The product sales of the unit are booked under; null clears it, which stops the + * unit from being sold. + * + * @return the value, empty when unset or null + */ + public Optional productId() { + return productId.asOptional(); + } + + /** + * Validated by the store (trimmed, at most 8 characters) rather than here: validator + * has no built-in support for a double Option. + * + * @return the value, empty when unset or null + */ + public Optional symbol() { + return symbol.asOptional(); + } + + /** + * Properties this version of the SDK does not know, kept as received and sent back. + * + * @return the properties by name, unmodifiable + */ + public Map additionalProperties() { + return Collections.unmodifiableMap(additionalProperties); + } + + @JsonAnyGetter + private Map anyProperties() { + return additionalProperties; + } + + @JsonAnySetter + private void putAnyProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CreditUnitUpdateRequest that = (CreditUnitUpdateRequest) o; + return Objects.equals(archived, that.archived) + && Objects.equals(name, that.name) + && Objects.equals(pluralName, that.pluralName) + && Objects.equals(productId, that.productId) + && Objects.equals(symbol, that.symbol) + && Objects.equals(additionalProperties, that.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(archived, name, pluralName, productId, symbol, additionalProperties); + } + + @Override + public String toString() { + return "CreditUnitUpdateRequest{" + + "archived=" + + archived + + ", name=" + + name + + ", pluralName=" + + pluralName + + ", productId=" + + productId + + ", symbol=" + + symbol + + ", additionalProperties=" + + additionalProperties + + "}"; + } + + /** Builds {@link CreditUnitUpdateRequest}. */ + public static final class Builder { + private JsonField archived = JsonField.missing(); + private JsonField name = JsonField.missing(); + private JsonField pluralName = JsonField.missing(); + private JsonField productId = JsonField.missing(); + private JsonField symbol = JsonField.missing(); + private final Map additionalProperties = new LinkedHashMap<>(); + + private Builder() {} + + /** + * Blocks the unit from new prices, packs and grants; existing ones keep working. + * + * @param archived the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder archived(Boolean archived) { + this.archived = JsonField.ofNullable(archived); + return this; + } + + /** + * Singular display name, 1 to 64 characters. + * + * @param name the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder name(String name) { + this.name = JsonField.ofNullable(name); + return this; + } + + /** + * Plural display name, 1 to 64 characters. + * + * @param pluralName the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder pluralName(String pluralName) { + this.pluralName = JsonField.ofNullable(pluralName); + return this; + } + + /** + * The product sales of the unit are booked under; null clears it, which stops + * the unit from being sold. + * + * @param productId the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder productId(String productId) { + this.productId = JsonField.ofNullable(productId); + return this; + } + + /** + * Validated by the store (trimmed, at most 8 characters) rather than here: validator + * has no built-in support for a double Option. + * + * @param symbol the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder symbol(String symbol) { + this.symbol = JsonField.ofNullable(symbol); + return this; + } + + /** + * A property the SDK does not know, sent along. + * + * @param name the property name + * @param value the JSON value + * @return this builder + */ + public Builder putAdditionalProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + return this; + } + + /** + * Properties the SDK does not know, sent along. + * + * @param additionalProperties the properties by name + * @return this builder + */ + public Builder putAllAdditionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + + /** + * Leaves out a property the SDK does not know. + * + * @param name the property name + * @return this builder + */ + public Builder removeAdditionalProperty(String name) { + additionalProperties.remove(name); + return this; + } + + /** + * The {@code CreditUnitUpdateRequest}. + * + * @return the immutable value + * @throws IllegalStateException when a required property is not set + */ + public CreditUnitUpdateRequest build() { + return new CreditUnitUpdateRequest(this); + } + } + + /** + * Parse {@code json} as {@code CreditUnitUpdateRequest}. + * + * @param json the JSON text + * @return the value + * @throws com.meteroid.exceptions.InvalidDataException if it is not valid JSON of this shape + */ + public static CreditUnitUpdateRequest fromJson(String json) { + return Utils.parse(json, CreditUnitUpdateRequest.class); + } + + /** + * This value as JSON. + * + * @return the JSON text + */ + public String toJson() { + return Utils.json(this); + } +} diff --git a/src/main/java/com/meteroid/models/DeclineKind.java b/src/main/java/com/meteroid/models/DeclineKind.java index 3ecf761..e079a31 100644 --- a/src/main/java/com/meteroid/models/DeclineKind.java +++ b/src/main/java/com/meteroid/models/DeclineKind.java @@ -46,6 +46,10 @@ public final class DeclineKind implements ToQueryParam { /** The value {@code "OTHER"}. */ public static final DeclineKind OTHER = new DeclineKind("OTHER", Value.OTHER); + /** The value {@code "DO_NOT_RETRY"}. */ + public static final DeclineKind DO_NOT_RETRY = + new DeclineKind("DO_NOT_RETRY", Value.DO_NOT_RETRY); + private static final Map constants = Map.ofEntries( Map.entry("INSUFFICIENT_FUNDS", INSUFFICIENT_FUNDS), @@ -55,7 +59,8 @@ public final class DeclineKind implements ToQueryParam { Map.entry("MANDATE_INACTIVE", MANDATE_INACTIVE), Map.entry("FRAUD", FRAUD), Map.entry("PROCESSING_ERROR", PROCESSING_ERROR), - Map.entry("OTHER", OTHER)); + Map.entry("OTHER", OTHER), + Map.entry("DO_NOT_RETRY", DO_NOT_RETRY)); private final String value; private final Value variant; @@ -156,7 +161,9 @@ public enum Known { /** The {@code PROCESSING_ERROR} constant. */ PROCESSING_ERROR, /** The {@code OTHER} constant. */ - OTHER + OTHER, + /** The {@code DO_NOT_RETRY} constant. */ + DO_NOT_RETRY } /** The values this version of the SDK knows, and {@code _UNKNOWN} for the others. */ @@ -177,6 +184,8 @@ public enum Value { PROCESSING_ERROR, /** The {@code OTHER} constant. */ OTHER, + /** The {@code DO_NOT_RETRY} constant. */ + DO_NOT_RETRY, /** A value this version of the SDK does not know. */ _UNKNOWN } diff --git a/src/main/java/com/meteroid/models/DoubleSegmentationMatrix.java b/src/main/java/com/meteroid/models/DoubleSegmentationMatrix.java index 9963723..f84a1b8 100644 --- a/src/main/java/com/meteroid/models/DoubleSegmentationMatrix.java +++ b/src/main/java/com/meteroid/models/DoubleSegmentationMatrix.java @@ -30,6 +30,9 @@ public final class DoubleSegmentationMatrix { @JsonProperty("dimension2") private MetricDimension dimension2; + @JsonProperty("type") + private String type = "DOUBLE"; + private final Map additionalProperties = new LinkedHashMap<>(); private DoubleSegmentationMatrix() {} @@ -37,6 +40,7 @@ private DoubleSegmentationMatrix() {} private DoubleSegmentationMatrix(Builder builder) { this.dimension1 = builder.dimension1; this.dimension2 = builder.dimension2; + this.type = builder.type; this.additionalProperties.putAll(builder.additionalProperties); } @@ -58,6 +62,7 @@ public Builder toBuilder() { Builder builder = new Builder(); builder.dimension1 = dimension1; builder.dimension2 = dimension2; + builder.type = type; builder.additionalProperties.putAll(additionalProperties); return builder; } @@ -80,6 +85,15 @@ public MetricDimension dimension2() { return Utils.required(dimension2, "dimension2"); } + /** + * The {@code type} property. + * + * @return the value, never null + */ + public String type() { + return Utils.required(type, "type"); + } + /** * Properties this version of the SDK does not know, kept as received and sent back. * @@ -110,12 +124,13 @@ public boolean equals(Object o) { DoubleSegmentationMatrix that = (DoubleSegmentationMatrix) o; return Objects.equals(dimension1, that.dimension1) && Objects.equals(dimension2, that.dimension2) + && Objects.equals(type, that.type) && Objects.equals(additionalProperties, that.additionalProperties); } @Override public int hashCode() { - return Objects.hash(dimension1, dimension2, additionalProperties); + return Objects.hash(dimension1, dimension2, type, additionalProperties); } @Override @@ -125,6 +140,8 @@ public String toString() { + dimension1 + ", dimension2=" + dimension2 + + ", type=" + + type + ", additionalProperties=" + additionalProperties + "}"; @@ -134,6 +151,7 @@ public String toString() { public static final class Builder { private MetricDimension dimension1; private MetricDimension dimension2; + private String type = "DOUBLE"; private final Map additionalProperties = new LinkedHashMap<>(); private Builder() {} @@ -160,6 +178,17 @@ public Builder dimension2(MetricDimension dimension2) { return this; } + /** + * The {@code type} property. + * + * @param type the value + * @return this builder + */ + public Builder type(String type) { + this.type = type; + return this; + } + /** * A property the SDK does not know, sent along. * @@ -203,6 +232,7 @@ public Builder removeAdditionalProperty(String name) { public DoubleSegmentationMatrix build() { Utils.checkRequired(dimension1, "dimension1"); Utils.checkRequired(dimension2, "dimension2"); + Utils.checkRequired(type, "type"); return new DoubleSegmentationMatrix(this); } } diff --git a/src/main/java/com/meteroid/models/EntitlementCheck.java b/src/main/java/com/meteroid/models/EntitlementCheck.java new file mode 100644 index 0000000..0ec79a6 --- /dev/null +++ b/src/main/java/com/meteroid/models/EntitlementCheck.java @@ -0,0 +1,677 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.JsonField; +import com.meteroid.internal.Utils; + +import java.math.BigDecimal; +import java.time.OffsetDateTime; +import java.util.ArrayList; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +/** + * Whether a customer may consume more of a feature now. + * + *

Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonAutoDetect( + getterVisibility = Visibility.NONE, + isGetterVisibility = Visibility.NONE, + setterVisibility = Visibility.NONE) +public final class EntitlementCheck { + @JsonProperty("as_of") + private OffsetDateTime asOf; + + @JsonProperty("exact") + private Boolean exact; + + @JsonProperty("feature") + private EntitlementCheckFeature feature; + + @JsonProperty("has_access") + private Boolean hasAccess; + + @JsonProperty("in_overage") + private Boolean inOverage; + + @JsonProperty("lag_ms") + private Long lagMs; + + @JsonProperty("limit") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField limit = JsonField.missing(); + + @JsonProperty("limits") + private List limits; + + @JsonProperty("near_limit") + private Boolean nearLimit; + + @JsonProperty("period") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField period = JsonField.missing(); + + @JsonProperty("reason") + private EntitlementCheckReason reason; + + @JsonProperty("remaining") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField remaining = JsonField.missing(); + + @JsonProperty("retry_after_ms") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField retryAfterMs = JsonField.missing(); + + @JsonProperty("used") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField used = JsonField.missing(); + + @JsonProperty("value") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField value = JsonField.missing(); + + private final Map additionalProperties = new LinkedHashMap<>(); + + private EntitlementCheck() {} + + private EntitlementCheck(Builder builder) { + this.asOf = builder.asOf; + this.exact = builder.exact; + this.feature = builder.feature; + this.hasAccess = builder.hasAccess; + this.inOverage = builder.inOverage; + this.lagMs = builder.lagMs; + this.limit = builder.limit; + this.limits = Utils.copyList(builder.limits); + this.nearLimit = builder.nearLimit; + this.period = builder.period; + this.reason = builder.reason; + this.remaining = builder.remaining; + this.retryAfterMs = builder.retryAfterMs; + this.used = builder.used; + this.value = builder.value; + this.additionalProperties.putAll(builder.additionalProperties); + } + + /** + * A builder of {@code EntitlementCheck}. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * A builder starting from this value. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.asOf = asOf; + builder.exact = exact; + builder.feature = feature; + builder.hasAccess = hasAccess; + builder.inOverage = inOverage; + builder.lagMs = lagMs; + builder.limit = limit; + builder.limits = Utils.mutableList(limits); + builder.nearLimit = nearLimit; + builder.period = period; + builder.reason = reason; + builder.remaining = remaining; + builder.retryAfterMs = retryAfterMs; + builder.used = used; + builder.value = value; + builder.additionalProperties.putAll(additionalProperties); + return builder; + } + + /** + * When the usage behind the answer was measured. + * + * @return the value, never null + */ + public OffsetDateTime asOf() { + return Utils.required(asOf, "as_of"); + } + + /** + * Always false: the answer reflects usage up to as_of. + * + * @return the value, never null + */ + public Boolean exact() { + return Utils.required(exact, "exact"); + } + + /** + * The {@code feature} property. + * + * @return the value, never null + */ + public EntitlementCheckFeature feature() { + return Utils.required(feature, "feature"); + } + + /** + * The {@code has_access} property. + * + * @return the value, never null + */ + public Boolean hasAccess() { + return Utils.required(hasAccess, "has_access"); + } + + /** + * The entitlement allows overage (ALLOW) and the requested units go beyond its + * limit: access is granted, and the overage is billed. + * + * @return the value, never null + */ + public Boolean inOverage() { + return Utils.required(inOverage, "in_overage"); + } + + /** + * Age of that usage, in milliseconds. + * + * @return the value, never null + */ + public Long lagMs() { + return Utils.required(lagMs, "lag_ms"); + } + + /** + * The {@code limit} property. + * + * @return the value, empty when unset or null + */ + public Optional limit() { + return limit.asOptional(); + } + + /** + * Deprecated: always empty. Customer-specific limits are entitlement overrides, reported in + * used, limit and remaining. + * + * @return the value, never null + */ + public List limits() { + return Utils.required(limits, "limits"); + } + + /** + * True when a hard limit is within 5% of being reached, reached, or refuses the request. While + * true, check before every request with its actual requested, and do not cache an + * answer that grants access. + * + * @return the value, never null + */ + public Boolean nearLimit() { + return Utils.required(nearLimit, "near_limit"); + } + + /** + * The {@code period} property. + * + * @return the value, empty when unset or null + */ + public Optional period() { + return period.asOptional(); + } + + /** + * The {@code reason} property. + * + * @return the value, never null + */ + public EntitlementCheckReason reason() { + return Utils.required(reason, "reason"); + } + + /** + * Units left before the limit, grace excluded: 0 while has_access is true when + * usage is within the grace allowance. + * + * @return the value, empty when unset or null + */ + public Optional remaining() { + return remaining.asOptional(); + } + + /** + * When to check again, in milliseconds. After a refusal by a limit whose period ends within 24 + * hours: the time until it ends (a smaller requested may still be allowed sooner); + * absent after a refusal by a sliding window, whose usage leaves it gradually. While + * near_limit is true and access is granted: 1000. + * + * @return the value, empty when unset or null + */ + public Optional retryAfterMs() { + return retryAfterMs.asOptional(); + } + + /** + * used, limit, remaining and period report + * the entitlement's limit. Absent when the entitlement has no limit. + * + * @return the value, empty when unset or null + */ + public Optional used() { + return used.asOptional(); + } + + /** + * The {@code value} property. + * + * @return the value, empty when unset or null + */ + public Optional value() { + return value.asOptional(); + } + + /** + * Properties this version of the SDK does not know, kept as received and sent back. + * + * @return the properties by name, unmodifiable + */ + public Map additionalProperties() { + return Collections.unmodifiableMap(additionalProperties); + } + + @JsonAnyGetter + private Map anyProperties() { + return additionalProperties; + } + + @JsonAnySetter + private void putAnyProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EntitlementCheck that = (EntitlementCheck) o; + return Objects.equals(asOf, that.asOf) + && Objects.equals(exact, that.exact) + && Objects.equals(feature, that.feature) + && Objects.equals(hasAccess, that.hasAccess) + && Objects.equals(inOverage, that.inOverage) + && Objects.equals(lagMs, that.lagMs) + && Objects.equals(limit, that.limit) + && Objects.equals(limits, that.limits) + && Objects.equals(nearLimit, that.nearLimit) + && Objects.equals(period, that.period) + && Objects.equals(reason, that.reason) + && Objects.equals(remaining, that.remaining) + && Objects.equals(retryAfterMs, that.retryAfterMs) + && Objects.equals(used, that.used) + && Objects.equals(value, that.value) + && Objects.equals(additionalProperties, that.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash( + asOf, + exact, + feature, + hasAccess, + inOverage, + lagMs, + limit, + limits, + nearLimit, + period, + reason, + remaining, + retryAfterMs, + used, + value, + additionalProperties); + } + + @Override + public String toString() { + return "EntitlementCheck{" + + "asOf=" + + asOf + + ", exact=" + + exact + + ", feature=" + + feature + + ", hasAccess=" + + hasAccess + + ", inOverage=" + + inOverage + + ", lagMs=" + + lagMs + + ", limit=" + + limit + + ", limits=" + + limits + + ", nearLimit=" + + nearLimit + + ", period=" + + period + + ", reason=" + + reason + + ", remaining=" + + remaining + + ", retryAfterMs=" + + retryAfterMs + + ", used=" + + used + + ", value=" + + value + + ", additionalProperties=" + + additionalProperties + + "}"; + } + + /** Builds {@link EntitlementCheck}. */ + public static final class Builder { + private OffsetDateTime asOf; + private Boolean exact; + private EntitlementCheckFeature feature; + private Boolean hasAccess; + private Boolean inOverage; + private Long lagMs; + private JsonField limit = JsonField.missing(); + private List limits; + private Boolean nearLimit; + private JsonField period = JsonField.missing(); + private EntitlementCheckReason reason; + private JsonField remaining = JsonField.missing(); + private JsonField retryAfterMs = JsonField.missing(); + private JsonField used = JsonField.missing(); + private JsonField value = JsonField.missing(); + private final Map additionalProperties = new LinkedHashMap<>(); + + private Builder() {} + + /** + * When the usage behind the answer was measured. + * + * @param asOf the value + * @return this builder + */ + public Builder asOf(OffsetDateTime asOf) { + this.asOf = asOf; + return this; + } + + /** + * Always false: the answer reflects usage up to as_of. + * + * @param exact the value + * @return this builder + */ + public Builder exact(Boolean exact) { + this.exact = exact; + return this; + } + + /** + * The {@code feature} property. + * + * @param feature the value + * @return this builder + */ + public Builder feature(EntitlementCheckFeature feature) { + this.feature = feature; + return this; + } + + /** + * The {@code has_access} property. + * + * @param hasAccess the value + * @return this builder + */ + public Builder hasAccess(Boolean hasAccess) { + this.hasAccess = hasAccess; + return this; + } + + /** + * The entitlement allows overage (ALLOW) and the requested units go beyond its + * limit: access is granted, and the overage is billed. + * + * @param inOverage the value + * @return this builder + */ + public Builder inOverage(Boolean inOverage) { + this.inOverage = inOverage; + return this; + } + + /** + * Age of that usage, in milliseconds. + * + * @param lagMs the value + * @return this builder + */ + public Builder lagMs(Long lagMs) { + this.lagMs = lagMs; + return this; + } + + /** + * The {@code limit} property. + * + * @param limit the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder limit(BigDecimal limit) { + this.limit = JsonField.ofNullable(limit); + return this; + } + + /** + * Deprecated: always empty. Customer-specific limits are entitlement overrides, reported in + * used, limit and remaining. + * + * @param limits the value + * @return this builder + */ + public Builder limits(List limits) { + this.limits = Utils.mutableList(limits); + return this; + } + + /** + * Adds an item to {@code limits}. + * + * @param item the item + * @return this builder + */ + public Builder addLimitsItem(EntitlementCheckLimit item) { + if (this.limits == null) { + this.limits = new ArrayList<>(); + } + this.limits.add(item); + return this; + } + + /** + * True when a hard limit is within 5% of being reached, reached, or refuses the request. + * While true, check before every request with its actual requested, and do not + * cache an answer that grants access. + * + * @param nearLimit the value + * @return this builder + */ + public Builder nearLimit(Boolean nearLimit) { + this.nearLimit = nearLimit; + return this; + } + + /** + * The {@code period} property. + * + * @param period the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder period(EntitlementCheckPeriod period) { + this.period = JsonField.ofNullable(period); + return this; + } + + /** + * The {@code reason} property. + * + * @param reason the value + * @return this builder + */ + public Builder reason(EntitlementCheckReason reason) { + this.reason = reason; + return this; + } + + /** + * Units left before the limit, grace excluded: 0 while has_access is true when + * usage is within the grace allowance. + * + * @param remaining the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder remaining(BigDecimal remaining) { + this.remaining = JsonField.ofNullable(remaining); + return this; + } + + /** + * When to check again, in milliseconds. After a refusal by a limit whose period ends within + * 24 hours: the time until it ends (a smaller requested may still be allowed + * sooner); absent after a refusal by a sliding window, whose usage leaves it gradually. + * While near_limit is true and access is granted: 1000. + * + * @param retryAfterMs the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder retryAfterMs(Long retryAfterMs) { + this.retryAfterMs = JsonField.ofNullable(retryAfterMs); + return this; + } + + /** + * used, limit, remaining and period + * report the entitlement's limit. Absent when the entitlement has no limit. + * + * @param used the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder used(BigDecimal used) { + this.used = JsonField.ofNullable(used); + return this; + } + + /** + * The {@code value} property. + * + * @param value the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder value(ConfigValue value) { + this.value = JsonField.ofNullable(value); + return this; + } + + /** + * A property the SDK does not know, sent along. + * + * @param name the property name + * @param value the JSON value + * @return this builder + */ + public Builder putAdditionalProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + return this; + } + + /** + * Properties the SDK does not know, sent along. + * + * @param additionalProperties the properties by name + * @return this builder + */ + public Builder putAllAdditionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + + /** + * Leaves out a property the SDK does not know. + * + * @param name the property name + * @return this builder + */ + public Builder removeAdditionalProperty(String name) { + additionalProperties.remove(name); + return this; + } + + /** + * The {@code EntitlementCheck}. + * + * @return the immutable value + * @throws IllegalStateException when a required property is not set + */ + public EntitlementCheck build() { + Utils.checkRequired(asOf, "as_of"); + Utils.checkRequired(exact, "exact"); + Utils.checkRequired(feature, "feature"); + Utils.checkRequired(hasAccess, "has_access"); + Utils.checkRequired(inOverage, "in_overage"); + Utils.checkRequired(lagMs, "lag_ms"); + Utils.checkRequired(limits, "limits"); + Utils.checkRequired(nearLimit, "near_limit"); + Utils.checkRequired(reason, "reason"); + return new EntitlementCheck(this); + } + } + + /** + * Parse {@code json} as {@code EntitlementCheck}. + * + * @param json the JSON text + * @return the value + * @throws com.meteroid.exceptions.InvalidDataException if it is not valid JSON of this shape + */ + public static EntitlementCheck fromJson(String json) { + return Utils.parse(json, EntitlementCheck.class); + } + + /** + * This value as JSON. + * + * @return the JSON text + */ + public String toJson() { + return Utils.json(this); + } +} diff --git a/src/main/java/com/meteroid/models/EntitlementCheckFeature.java b/src/main/java/com/meteroid/models/EntitlementCheckFeature.java new file mode 100644 index 0000000..db621de --- /dev/null +++ b/src/main/java/com/meteroid/models/EntitlementCheckFeature.java @@ -0,0 +1,229 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.Utils; + +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; + +/** Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonAutoDetect( + getterVisibility = Visibility.NONE, + isGetterVisibility = Visibility.NONE, + setterVisibility = Visibility.NONE) +public final class EntitlementCheckFeature { + @JsonProperty("code") + private String code; + + @JsonProperty("id") + private String id; + + private final Map additionalProperties = new LinkedHashMap<>(); + + private EntitlementCheckFeature() {} + + private EntitlementCheckFeature(Builder builder) { + this.code = builder.code; + this.id = builder.id; + this.additionalProperties.putAll(builder.additionalProperties); + } + + /** + * A builder of {@code EntitlementCheckFeature}. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * A builder starting from this value. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.code = code; + builder.id = id; + builder.additionalProperties.putAll(additionalProperties); + return builder; + } + + /** + * The {@code code} property. + * + * @return the value, never null + */ + public String code() { + return Utils.required(code, "code"); + } + + /** + * The {@code id} property. + * + * @return the value, never null + */ + public String id() { + return Utils.required(id, "id"); + } + + /** + * Properties this version of the SDK does not know, kept as received and sent back. + * + * @return the properties by name, unmodifiable + */ + public Map additionalProperties() { + return Collections.unmodifiableMap(additionalProperties); + } + + @JsonAnyGetter + private Map anyProperties() { + return additionalProperties; + } + + @JsonAnySetter + private void putAnyProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EntitlementCheckFeature that = (EntitlementCheckFeature) o; + return Objects.equals(code, that.code) + && Objects.equals(id, that.id) + && Objects.equals(additionalProperties, that.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(code, id, additionalProperties); + } + + @Override + public String toString() { + return "EntitlementCheckFeature{" + + "code=" + + code + + ", id=" + + id + + ", additionalProperties=" + + additionalProperties + + "}"; + } + + /** Builds {@link EntitlementCheckFeature}. */ + public static final class Builder { + private String code; + private String id; + private final Map additionalProperties = new LinkedHashMap<>(); + + private Builder() {} + + /** + * The {@code code} property. + * + * @param code the value + * @return this builder + */ + public Builder code(String code) { + this.code = code; + return this; + } + + /** + * The {@code id} property. + * + * @param id the value + * @return this builder + */ + public Builder id(String id) { + this.id = id; + return this; + } + + /** + * A property the SDK does not know, sent along. + * + * @param name the property name + * @param value the JSON value + * @return this builder + */ + public Builder putAdditionalProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + return this; + } + + /** + * Properties the SDK does not know, sent along. + * + * @param additionalProperties the properties by name + * @return this builder + */ + public Builder putAllAdditionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + + /** + * Leaves out a property the SDK does not know. + * + * @param name the property name + * @return this builder + */ + public Builder removeAdditionalProperty(String name) { + additionalProperties.remove(name); + return this; + } + + /** + * The {@code EntitlementCheckFeature}. + * + * @return the immutable value + * @throws IllegalStateException when a required property is not set + */ + public EntitlementCheckFeature build() { + Utils.checkRequired(code, "code"); + Utils.checkRequired(id, "id"); + return new EntitlementCheckFeature(this); + } + } + + /** + * Parse {@code json} as {@code EntitlementCheckFeature}. + * + * @param json the JSON text + * @return the value + * @throws com.meteroid.exceptions.InvalidDataException if it is not valid JSON of this shape + */ + public static EntitlementCheckFeature fromJson(String json) { + return Utils.parse(json, EntitlementCheckFeature.class); + } + + /** + * This value as JSON. + * + * @return the JSON text + */ + public String toJson() { + return Utils.json(this); + } +} diff --git a/src/main/java/com/meteroid/models/EntitlementCheckLimit.java b/src/main/java/com/meteroid/models/EntitlementCheckLimit.java new file mode 100644 index 0000000..5859c86 --- /dev/null +++ b/src/main/java/com/meteroid/models/EntitlementCheckLimit.java @@ -0,0 +1,411 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.JsonField; +import com.meteroid.internal.Utils; + +import java.math.BigDecimal; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +/** + * Deprecated: customer usage limits were replaced by entitlement overrides; never returned. + * + *

Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonAutoDetect( + getterVisibility = Visibility.NONE, + isGetterVisibility = Visibility.NONE, + setterVisibility = Visibility.NONE) +public final class EntitlementCheckLimit { + @JsonProperty("behavior") + private EntitlementCheckLimitBehavior behavior; + + @JsonProperty("group") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField> group = JsonField.missing(); + + @JsonProperty("has_access") + private Boolean hasAccess; + + @JsonProperty("limit") + private BigDecimal limit; + + @JsonProperty("remaining") + private BigDecimal remaining; + + @JsonProperty("usage_limit_id") + private String usageLimitId; + + @JsonProperty("used") + private BigDecimal used; + + private final Map additionalProperties = new LinkedHashMap<>(); + + private EntitlementCheckLimit() {} + + private EntitlementCheckLimit(Builder builder) { + this.behavior = builder.behavior; + this.group = builder.group.map(Utils::copyMap); + this.hasAccess = builder.hasAccess; + this.limit = builder.limit; + this.remaining = builder.remaining; + this.usageLimitId = builder.usageLimitId; + this.used = builder.used; + this.additionalProperties.putAll(builder.additionalProperties); + } + + /** + * A builder of {@code EntitlementCheckLimit}. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * A builder starting from this value. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.behavior = behavior; + builder.group = group.map(Utils::mutableMap); + builder.hasAccess = hasAccess; + builder.limit = limit; + builder.remaining = remaining; + builder.usageLimitId = usageLimitId; + builder.used = used; + builder.additionalProperties.putAll(additionalProperties); + return builder; + } + + /** + * The {@code behavior} property. + * + * @return the value, never null + */ + public EntitlementCheckLimitBehavior behavior() { + return Utils.required(behavior, "behavior"); + } + + /** + * The group the limit was evaluated for, when the limit is grouped. + * + * @return the value, empty when unset or null + */ + public Optional> group() { + return group.asOptional(); + } + + /** + * The {@code has_access} property. + * + * @return the value, never null + */ + public Boolean hasAccess() { + return Utils.required(hasAccess, "has_access"); + } + + /** + * The {@code limit} property. + * + * @return the value, never null + */ + public BigDecimal limit() { + return Utils.required(limit, "limit"); + } + + /** + * The {@code remaining} property. + * + * @return the value, never null + */ + public BigDecimal remaining() { + return Utils.required(remaining, "remaining"); + } + + /** + * The {@code usage_limit_id} property. + * + * @return the value, never null + */ + public String usageLimitId() { + return Utils.required(usageLimitId, "usage_limit_id"); + } + + /** + * The {@code used} property. + * + * @return the value, never null + */ + public BigDecimal used() { + return Utils.required(used, "used"); + } + + /** + * Properties this version of the SDK does not know, kept as received and sent back. + * + * @return the properties by name, unmodifiable + */ + public Map additionalProperties() { + return Collections.unmodifiableMap(additionalProperties); + } + + @JsonAnyGetter + private Map anyProperties() { + return additionalProperties; + } + + @JsonAnySetter + private void putAnyProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EntitlementCheckLimit that = (EntitlementCheckLimit) o; + return Objects.equals(behavior, that.behavior) + && Objects.equals(group, that.group) + && Objects.equals(hasAccess, that.hasAccess) + && Objects.equals(limit, that.limit) + && Objects.equals(remaining, that.remaining) + && Objects.equals(usageLimitId, that.usageLimitId) + && Objects.equals(used, that.used) + && Objects.equals(additionalProperties, that.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash( + behavior, + group, + hasAccess, + limit, + remaining, + usageLimitId, + used, + additionalProperties); + } + + @Override + public String toString() { + return "EntitlementCheckLimit{" + + "behavior=" + + behavior + + ", group=" + + group + + ", hasAccess=" + + hasAccess + + ", limit=" + + limit + + ", remaining=" + + remaining + + ", usageLimitId=" + + usageLimitId + + ", used=" + + used + + ", additionalProperties=" + + additionalProperties + + "}"; + } + + /** Builds {@link EntitlementCheckLimit}. */ + public static final class Builder { + private EntitlementCheckLimitBehavior behavior; + private JsonField> group = JsonField.missing(); + private Boolean hasAccess; + private BigDecimal limit; + private BigDecimal remaining; + private String usageLimitId; + private BigDecimal used; + private final Map additionalProperties = new LinkedHashMap<>(); + + private Builder() {} + + /** + * The {@code behavior} property. + * + * @param behavior the value + * @return this builder + */ + public Builder behavior(EntitlementCheckLimitBehavior behavior) { + this.behavior = behavior; + return this; + } + + /** + * The group the limit was evaluated for, when the limit is grouped. + * + * @param group the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder group(Map group) { + this.group = JsonField.ofNullable(Utils.mutableMap(group)); + return this; + } + + /** + * Puts an entry in {@code group}. + * + * @param key the key + * @param item the item + * @return this builder + */ + public Builder putGroupItem(String key, String item) { + Map items = this.group.orNull(); + if (items == null) { + items = new LinkedHashMap<>(); + this.group = JsonField.ofNullable(items); + } + items.put(key, item); + return this; + } + + /** + * The {@code has_access} property. + * + * @param hasAccess the value + * @return this builder + */ + public Builder hasAccess(Boolean hasAccess) { + this.hasAccess = hasAccess; + return this; + } + + /** + * The {@code limit} property. + * + * @param limit the value + * @return this builder + */ + public Builder limit(BigDecimal limit) { + this.limit = limit; + return this; + } + + /** + * The {@code remaining} property. + * + * @param remaining the value + * @return this builder + */ + public Builder remaining(BigDecimal remaining) { + this.remaining = remaining; + return this; + } + + /** + * The {@code usage_limit_id} property. + * + * @param usageLimitId the value + * @return this builder + */ + public Builder usageLimitId(String usageLimitId) { + this.usageLimitId = usageLimitId; + return this; + } + + /** + * The {@code used} property. + * + * @param used the value + * @return this builder + */ + public Builder used(BigDecimal used) { + this.used = used; + return this; + } + + /** + * A property the SDK does not know, sent along. + * + * @param name the property name + * @param value the JSON value + * @return this builder + */ + public Builder putAdditionalProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + return this; + } + + /** + * Properties the SDK does not know, sent along. + * + * @param additionalProperties the properties by name + * @return this builder + */ + public Builder putAllAdditionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + + /** + * Leaves out a property the SDK does not know. + * + * @param name the property name + * @return this builder + */ + public Builder removeAdditionalProperty(String name) { + additionalProperties.remove(name); + return this; + } + + /** + * The {@code EntitlementCheckLimit}. + * + * @return the immutable value + * @throws IllegalStateException when a required property is not set + */ + public EntitlementCheckLimit build() { + Utils.checkRequired(behavior, "behavior"); + Utils.checkRequired(hasAccess, "has_access"); + Utils.checkRequired(limit, "limit"); + Utils.checkRequired(remaining, "remaining"); + Utils.checkRequired(usageLimitId, "usage_limit_id"); + Utils.checkRequired(used, "used"); + return new EntitlementCheckLimit(this); + } + } + + /** + * Parse {@code json} as {@code EntitlementCheckLimit}. + * + * @param json the JSON text + * @return the value + * @throws com.meteroid.exceptions.InvalidDataException if it is not valid JSON of this shape + */ + public static EntitlementCheckLimit fromJson(String json) { + return Utils.parse(json, EntitlementCheckLimit.class); + } + + /** + * This value as JSON. + * + * @return the JSON text + */ + public String toJson() { + return Utils.json(this); + } +} diff --git a/src/main/java/com/meteroid/models/EntitlementCheckLimitBehavior.java b/src/main/java/com/meteroid/models/EntitlementCheckLimitBehavior.java new file mode 100644 index 0000000..414e3a0 --- /dev/null +++ b/src/main/java/com/meteroid/models/EntitlementCheckLimitBehavior.java @@ -0,0 +1,140 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import com.meteroid.internal.Utils.ToQueryParam; + +import java.util.Map; +import java.util.Objects; + +/** + * Values this version of the SDK does not know are kept, and sent back unchanged: {@link #value()} + * is an enum to switch on, {@code _UNKNOWN} for them, and {@link #known()} throws on them. + */ +public final class EntitlementCheckLimitBehavior implements ToQueryParam { + /** The value {@code "TRACK"}. */ + public static final EntitlementCheckLimitBehavior TRACK = + new EntitlementCheckLimitBehavior("TRACK", Value.TRACK); + + /** The value {@code "SOFT"}. */ + public static final EntitlementCheckLimitBehavior SOFT = + new EntitlementCheckLimitBehavior("SOFT", Value.SOFT); + + /** The value {@code "HARD"}. */ + public static final EntitlementCheckLimitBehavior HARD = + new EntitlementCheckLimitBehavior("HARD", Value.HARD); + + private static final Map constants = + Map.ofEntries( + Map.entry("TRACK", TRACK), Map.entry("SOFT", SOFT), Map.entry("HARD", HARD)); + + private final String value; + private final Value variant; + + private EntitlementCheckLimitBehavior(String value, Value variant) { + this.value = value; + this.variant = variant; + } + + /** + * The constant for {@code value}, or an unknown EntitlementCheckLimitBehavior holding it. + * + * @param value the value + * @return the constant + */ + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static EntitlementCheckLimitBehavior of(String value) { + EntitlementCheckLimitBehavior constant = + constants.get(Objects.requireNonNull(value, "value")); + return constant != null + ? constant + : new EntitlementCheckLimitBehavior(value, Value._UNKNOWN); + } + + /** + * The value as sent. + * + * @return the value + */ + @JsonValue + public String asString() { + return value; + } + + /** + * Whether this version of the SDK knows the value. + * + * @return whether it is known + */ + public boolean isKnown() { + return variant != Value._UNKNOWN; + } + + /** + * The value as an enum to switch on, unknown values included. + * + * @return the enum, {@code _UNKNOWN} when unknown + */ + public Value value() { + return variant; + } + + /** + * The value as an enum of the known values only. + * + * @return the enum + * @throws com.meteroid.exceptions.InvalidDataException when this version of the SDK does not + * know the value + */ + public Known known() { + if (!isKnown()) { + throw new com.meteroid.exceptions.InvalidDataException( + "unknown EntitlementCheckLimitBehavior: " + value); + } + return Known.valueOf(variant.name()); + } + + @Override + public String toQueryParam() { + return String.valueOf(value); + } + + @Override + public boolean equals(Object o) { + return o instanceof EntitlementCheckLimitBehavior + && Objects.equals(value, ((EntitlementCheckLimitBehavior) o).value); + } + + @Override + public int hashCode() { + return Objects.hashCode(value); + } + + @Override + public String toString() { + return String.valueOf(value); + } + + /** The values this version of the SDK knows. */ + public enum Known { + /** The {@code TRACK} constant. */ + TRACK, + /** The {@code SOFT} constant. */ + SOFT, + /** The {@code HARD} constant. */ + HARD + } + + /** The values this version of the SDK knows, and {@code _UNKNOWN} for the others. */ + public enum Value { + /** The {@code TRACK} constant. */ + TRACK, + /** The {@code SOFT} constant. */ + SOFT, + /** The {@code HARD} constant. */ + HARD, + /** A value this version of the SDK does not know. */ + _UNKNOWN + } +} diff --git a/src/main/java/com/meteroid/models/EntitlementCheckPeriod.java b/src/main/java/com/meteroid/models/EntitlementCheckPeriod.java new file mode 100644 index 0000000..70b30ec --- /dev/null +++ b/src/main/java/com/meteroid/models/EntitlementCheckPeriod.java @@ -0,0 +1,232 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.JsonField; +import com.meteroid.internal.Utils; + +import java.time.OffsetDateTime; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +/** Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonAutoDetect( + getterVisibility = Visibility.NONE, + isGetterVisibility = Visibility.NONE, + setterVisibility = Visibility.NONE) +public final class EntitlementCheckPeriod { + @JsonProperty("end") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField end = JsonField.missing(); + + @JsonProperty("start") + private OffsetDateTime start; + + private final Map additionalProperties = new LinkedHashMap<>(); + + private EntitlementCheckPeriod() {} + + private EntitlementCheckPeriod(Builder builder) { + this.end = builder.end; + this.start = builder.start; + this.additionalProperties.putAll(builder.additionalProperties); + } + + /** + * A builder of {@code EntitlementCheckPeriod}. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * A builder starting from this value. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.end = end; + builder.start = start; + builder.additionalProperties.putAll(additionalProperties); + return builder; + } + + /** + * Absent when the period never ends. + * + * @return the value, empty when unset or null + */ + public Optional end() { + return end.asOptional(); + } + + /** + * The {@code start} property. + * + * @return the value, never null + */ + public OffsetDateTime start() { + return Utils.required(start, "start"); + } + + /** + * Properties this version of the SDK does not know, kept as received and sent back. + * + * @return the properties by name, unmodifiable + */ + public Map additionalProperties() { + return Collections.unmodifiableMap(additionalProperties); + } + + @JsonAnyGetter + private Map anyProperties() { + return additionalProperties; + } + + @JsonAnySetter + private void putAnyProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EntitlementCheckPeriod that = (EntitlementCheckPeriod) o; + return Objects.equals(end, that.end) + && Objects.equals(start, that.start) + && Objects.equals(additionalProperties, that.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(end, start, additionalProperties); + } + + @Override + public String toString() { + return "EntitlementCheckPeriod{" + + "end=" + + end + + ", start=" + + start + + ", additionalProperties=" + + additionalProperties + + "}"; + } + + /** Builds {@link EntitlementCheckPeriod}. */ + public static final class Builder { + private JsonField end = JsonField.missing(); + private OffsetDateTime start; + private final Map additionalProperties = new LinkedHashMap<>(); + + private Builder() {} + + /** + * Absent when the period never ends. + * + * @param end the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder end(OffsetDateTime end) { + this.end = JsonField.ofNullable(end); + return this; + } + + /** + * The {@code start} property. + * + * @param start the value + * @return this builder + */ + public Builder start(OffsetDateTime start) { + this.start = start; + return this; + } + + /** + * A property the SDK does not know, sent along. + * + * @param name the property name + * @param value the JSON value + * @return this builder + */ + public Builder putAdditionalProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + return this; + } + + /** + * Properties the SDK does not know, sent along. + * + * @param additionalProperties the properties by name + * @return this builder + */ + public Builder putAllAdditionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + + /** + * Leaves out a property the SDK does not know. + * + * @param name the property name + * @return this builder + */ + public Builder removeAdditionalProperty(String name) { + additionalProperties.remove(name); + return this; + } + + /** + * The {@code EntitlementCheckPeriod}. + * + * @return the immutable value + * @throws IllegalStateException when a required property is not set + */ + public EntitlementCheckPeriod build() { + Utils.checkRequired(start, "start"); + return new EntitlementCheckPeriod(this); + } + } + + /** + * Parse {@code json} as {@code EntitlementCheckPeriod}. + * + * @param json the JSON text + * @return the value + * @throws com.meteroid.exceptions.InvalidDataException if it is not valid JSON of this shape + */ + public static EntitlementCheckPeriod fromJson(String json) { + return Utils.parse(json, EntitlementCheckPeriod.class); + } + + /** + * This value as JSON. + * + * @return the JSON text + */ + public String toJson() { + return Utils.json(this); + } +} diff --git a/src/main/java/com/meteroid/models/EntitlementCheckReason.java b/src/main/java/com/meteroid/models/EntitlementCheckReason.java new file mode 100644 index 0000000..e140aeb --- /dev/null +++ b/src/main/java/com/meteroid/models/EntitlementCheckReason.java @@ -0,0 +1,175 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import com.meteroid.internal.Utils.ToQueryParam; + +import java.util.Map; +import java.util.Objects; + +/** + * Values this version of the SDK does not know are kept, and sent back unchanged: {@link #value()} + * is an enum to switch on, {@code _UNKNOWN} for them, and {@link #known()} throws on them. + */ +public final class EntitlementCheckReason implements ToQueryParam { + /** The value {@code "WITHIN_LIMIT"}. */ + public static final EntitlementCheckReason WITHIN_LIMIT = + new EntitlementCheckReason("WITHIN_LIMIT", Value.WITHIN_LIMIT); + + /** The value {@code "LIMIT_REACHED"}. */ + public static final EntitlementCheckReason LIMIT_REACHED = + new EntitlementCheckReason("LIMIT_REACHED", Value.LIMIT_REACHED); + + /** The value {@code "NO_ENTITLEMENT"}. */ + public static final EntitlementCheckReason NO_ENTITLEMENT = + new EntitlementCheckReason("NO_ENTITLEMENT", Value.NO_ENTITLEMENT); + + /** The value {@code "DISABLED"}. */ + public static final EntitlementCheckReason DISABLED = + new EntitlementCheckReason("DISABLED", Value.DISABLED); + + /** The value {@code "BUDGET_EXCEEDED"}. */ + public static final EntitlementCheckReason BUDGET_EXCEEDED = + new EntitlementCheckReason("BUDGET_EXCEEDED", Value.BUDGET_EXCEEDED); + + /** The value {@code "INSUFFICIENT_BALANCE"}. */ + public static final EntitlementCheckReason INSUFFICIENT_BALANCE = + new EntitlementCheckReason("INSUFFICIENT_BALANCE", Value.INSUFFICIENT_BALANCE); + + /** The value {@code "TOO_MANY_GROUPS"}. */ + public static final EntitlementCheckReason TOO_MANY_GROUPS = + new EntitlementCheckReason("TOO_MANY_GROUPS", Value.TOO_MANY_GROUPS); + + private static final Map constants = + Map.ofEntries( + Map.entry("WITHIN_LIMIT", WITHIN_LIMIT), + Map.entry("LIMIT_REACHED", LIMIT_REACHED), + Map.entry("NO_ENTITLEMENT", NO_ENTITLEMENT), + Map.entry("DISABLED", DISABLED), + Map.entry("BUDGET_EXCEEDED", BUDGET_EXCEEDED), + Map.entry("INSUFFICIENT_BALANCE", INSUFFICIENT_BALANCE), + Map.entry("TOO_MANY_GROUPS", TOO_MANY_GROUPS)); + + private final String value; + private final Value variant; + + private EntitlementCheckReason(String value, Value variant) { + this.value = value; + this.variant = variant; + } + + /** + * The constant for {@code value}, or an unknown EntitlementCheckReason holding it. + * + * @param value the value + * @return the constant + */ + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static EntitlementCheckReason of(String value) { + EntitlementCheckReason constant = constants.get(Objects.requireNonNull(value, "value")); + return constant != null ? constant : new EntitlementCheckReason(value, Value._UNKNOWN); + } + + /** + * The value as sent. + * + * @return the value + */ + @JsonValue + public String asString() { + return value; + } + + /** + * Whether this version of the SDK knows the value. + * + * @return whether it is known + */ + public boolean isKnown() { + return variant != Value._UNKNOWN; + } + + /** + * The value as an enum to switch on, unknown values included. + * + * @return the enum, {@code _UNKNOWN} when unknown + */ + public Value value() { + return variant; + } + + /** + * The value as an enum of the known values only. + * + * @return the enum + * @throws com.meteroid.exceptions.InvalidDataException when this version of the SDK does not + * know the value + */ + public Known known() { + if (!isKnown()) { + throw new com.meteroid.exceptions.InvalidDataException( + "unknown EntitlementCheckReason: " + value); + } + return Known.valueOf(variant.name()); + } + + @Override + public String toQueryParam() { + return String.valueOf(value); + } + + @Override + public boolean equals(Object o) { + return o instanceof EntitlementCheckReason + && Objects.equals(value, ((EntitlementCheckReason) o).value); + } + + @Override + public int hashCode() { + return Objects.hashCode(value); + } + + @Override + public String toString() { + return String.valueOf(value); + } + + /** The values this version of the SDK knows. */ + public enum Known { + /** The {@code WITHIN_LIMIT} constant. */ + WITHIN_LIMIT, + /** The {@code LIMIT_REACHED} constant. */ + LIMIT_REACHED, + /** The {@code NO_ENTITLEMENT} constant. */ + NO_ENTITLEMENT, + /** The {@code DISABLED} constant. */ + DISABLED, + /** The {@code BUDGET_EXCEEDED} constant. */ + BUDGET_EXCEEDED, + /** The {@code INSUFFICIENT_BALANCE} constant. */ + INSUFFICIENT_BALANCE, + /** The {@code TOO_MANY_GROUPS} constant. */ + TOO_MANY_GROUPS + } + + /** The values this version of the SDK knows, and {@code _UNKNOWN} for the others. */ + public enum Value { + /** The {@code WITHIN_LIMIT} constant. */ + WITHIN_LIMIT, + /** The {@code LIMIT_REACHED} constant. */ + LIMIT_REACHED, + /** The {@code NO_ENTITLEMENT} constant. */ + NO_ENTITLEMENT, + /** The {@code DISABLED} constant. */ + DISABLED, + /** The {@code BUDGET_EXCEEDED} constant. */ + BUDGET_EXCEEDED, + /** The {@code INSUFFICIENT_BALANCE} constant. */ + INSUFFICIENT_BALANCE, + /** The {@code TOO_MANY_GROUPS} constant. */ + TOO_MANY_GROUPS, + /** A value this version of the SDK does not know. */ + _UNKNOWN + } +} diff --git a/src/main/java/com/meteroid/models/EntitlementOverageBehavior.java b/src/main/java/com/meteroid/models/EntitlementOverageBehavior.java new file mode 100644 index 0000000..3daa214 --- /dev/null +++ b/src/main/java/com/meteroid/models/EntitlementOverageBehavior.java @@ -0,0 +1,131 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import com.meteroid.internal.Utils.ToQueryParam; + +import java.util.Map; +import java.util.Objects; + +/** + * What happens once usage reaches the limit. + * + *

Values this version of the SDK does not know are kept, and sent back unchanged: {@link + * #value()} is an enum to switch on, {@code _UNKNOWN} for them, and {@link #known()} throws on + * them. + */ +public final class EntitlementOverageBehavior implements ToQueryParam { + /** The value {@code "BLOCK"}. */ + public static final EntitlementOverageBehavior BLOCK = + new EntitlementOverageBehavior("BLOCK", Value.BLOCK); + + /** The value {@code "ALLOW"}. */ + public static final EntitlementOverageBehavior ALLOW = + new EntitlementOverageBehavior("ALLOW", Value.ALLOW); + + private static final Map constants = + Map.ofEntries(Map.entry("BLOCK", BLOCK), Map.entry("ALLOW", ALLOW)); + + private final String value; + private final Value variant; + + private EntitlementOverageBehavior(String value, Value variant) { + this.value = value; + this.variant = variant; + } + + /** + * The constant for {@code value}, or an unknown EntitlementOverageBehavior holding it. + * + * @param value the value + * @return the constant + */ + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static EntitlementOverageBehavior of(String value) { + EntitlementOverageBehavior constant = constants.get(Objects.requireNonNull(value, "value")); + return constant != null ? constant : new EntitlementOverageBehavior(value, Value._UNKNOWN); + } + + /** + * The value as sent. + * + * @return the value + */ + @JsonValue + public String asString() { + return value; + } + + /** + * Whether this version of the SDK knows the value. + * + * @return whether it is known + */ + public boolean isKnown() { + return variant != Value._UNKNOWN; + } + + /** + * The value as an enum to switch on, unknown values included. + * + * @return the enum, {@code _UNKNOWN} when unknown + */ + public Value value() { + return variant; + } + + /** + * The value as an enum of the known values only. + * + * @return the enum + * @throws com.meteroid.exceptions.InvalidDataException when this version of the SDK does not + * know the value + */ + public Known known() { + if (!isKnown()) { + throw new com.meteroid.exceptions.InvalidDataException( + "unknown EntitlementOverageBehavior: " + value); + } + return Known.valueOf(variant.name()); + } + + @Override + public String toQueryParam() { + return String.valueOf(value); + } + + @Override + public boolean equals(Object o) { + return o instanceof EntitlementOverageBehavior + && Objects.equals(value, ((EntitlementOverageBehavior) o).value); + } + + @Override + public int hashCode() { + return Objects.hashCode(value); + } + + @Override + public String toString() { + return String.valueOf(value); + } + + /** The values this version of the SDK knows. */ + public enum Known { + /** The {@code BLOCK} constant. */ + BLOCK, + /** The {@code ALLOW} constant. */ + ALLOW + } + + /** The values this version of the SDK knows, and {@code _UNKNOWN} for the others. */ + public enum Value { + /** The {@code BLOCK} constant. */ + BLOCK, + /** The {@code ALLOW} constant. */ + ALLOW, + /** A value this version of the SDK does not know. */ + _UNKNOWN + } +} diff --git a/src/main/java/com/meteroid/models/EventType.java b/src/main/java/com/meteroid/models/EventType.java index 1ad16d5..b345a48 100644 --- a/src/main/java/com/meteroid/models/EventType.java +++ b/src/main/java/com/meteroid/models/EventType.java @@ -160,10 +160,63 @@ public final class EventType implements ToQueryParam { public static final EventType PAYMENT_REVERSED = new EventType("payment.reversed", Value.PAYMENT_REVERSED); + /** The value {@code "payment.reinstated"}. */ + public static final EventType PAYMENT_REINSTATED = + new EventType("payment.reinstated", Value.PAYMENT_REINSTATED); + /** The value {@code "payment.failed"}. */ public static final EventType PAYMENT_FAILED = new EventType("payment.failed", Value.PAYMENT_FAILED); + /** The value {@code "wallet.funded"}. */ + public static final EventType WALLET_FUNDED = + new EventType("wallet.funded", Value.WALLET_FUNDED); + + /** The value {@code "wallet.debited"}. */ + public static final EventType WALLET_DEBITED = + new EventType("wallet.debited", Value.WALLET_DEBITED); + + /** The value {@code "wallet.balance_low"}. */ + public static final EventType WALLET_BALANCE_LOW = + new EventType("wallet.balance_low", Value.WALLET_BALANCE_LOW); + + /** The value {@code "wallet.credit_unrecovered"}. */ + public static final EventType WALLET_CREDIT_UNRECOVERED = + new EventType("wallet.credit_unrecovered", Value.WALLET_CREDIT_UNRECOVERED); + + /** The value {@code "wallet.credit_recovered"}. */ + public static final EventType WALLET_CREDIT_RECOVERED = + new EventType("wallet.credit_recovered", Value.WALLET_CREDIT_RECOVERED); + + /** The value {@code "wallet.auto_top_up_failed"}. */ + public static final EventType WALLET_AUTO_TOP_UP_FAILED = + new EventType("wallet.auto_top_up_failed", Value.WALLET_AUTO_TOP_UP_FAILED); + + /** The value {@code "wallet.auto_top_up_suspended"}. */ + public static final EventType WALLET_AUTO_TOP_UP_SUSPENDED = + new EventType("wallet.auto_top_up_suspended", Value.WALLET_AUTO_TOP_UP_SUSPENDED); + + /** The value {@code "wallet.auto_top_up_consent_changed"}. */ + public static final EventType WALLET_AUTO_TOP_UP_CONSENT_CHANGED = + new EventType( + "wallet.auto_top_up_consent_changed", Value.WALLET_AUTO_TOP_UP_CONSENT_CHANGED); + + /** The value {@code "wallet.depleted"}. */ + public static final EventType WALLET_DEPLETED = + new EventType("wallet.depleted", Value.WALLET_DEPLETED); + + /** The value {@code "wallet.recovered"}. */ + public static final EventType WALLET_RECOVERED = + new EventType("wallet.recovered", Value.WALLET_RECOVERED); + + /** The value {@code "wallet.auto_top_up_cap_reached"}. */ + public static final EventType WALLET_AUTO_TOP_UP_CAP_REACHED = + new EventType("wallet.auto_top_up_cap_reached", Value.WALLET_AUTO_TOP_UP_CAP_REACHED); + + /** The value {@code "credit_grant.expired"}. */ + public static final EventType CREDIT_GRANT_EXPIRED = + new EventType("credit_grant.expired", Value.CREDIT_GRANT_EXPIRED); + private static final Map constants = Map.ofEntries( Map.entry("metric.created", METRIC_CREATED), @@ -203,7 +256,22 @@ public final class EventType implements ToQueryParam { Map.entry("refund.settled", REFUND_SETTLED), Map.entry("refund.failed", REFUND_FAILED), Map.entry("payment.reversed", PAYMENT_REVERSED), - Map.entry("payment.failed", PAYMENT_FAILED)); + Map.entry("payment.reinstated", PAYMENT_REINSTATED), + Map.entry("payment.failed", PAYMENT_FAILED), + Map.entry("wallet.funded", WALLET_FUNDED), + Map.entry("wallet.debited", WALLET_DEBITED), + Map.entry("wallet.balance_low", WALLET_BALANCE_LOW), + Map.entry("wallet.credit_unrecovered", WALLET_CREDIT_UNRECOVERED), + Map.entry("wallet.credit_recovered", WALLET_CREDIT_RECOVERED), + Map.entry("wallet.auto_top_up_failed", WALLET_AUTO_TOP_UP_FAILED), + Map.entry("wallet.auto_top_up_suspended", WALLET_AUTO_TOP_UP_SUSPENDED), + Map.entry( + "wallet.auto_top_up_consent_changed", + WALLET_AUTO_TOP_UP_CONSENT_CHANGED), + Map.entry("wallet.depleted", WALLET_DEPLETED), + Map.entry("wallet.recovered", WALLET_RECOVERED), + Map.entry("wallet.auto_top_up_cap_reached", WALLET_AUTO_TOP_UP_CAP_REACHED), + Map.entry("credit_grant.expired", CREDIT_GRANT_EXPIRED)); private final String value; private final Value variant; @@ -363,8 +431,34 @@ public enum Known { REFUND_FAILED, /** The {@code PAYMENT_REVERSED} constant. */ PAYMENT_REVERSED, + /** The {@code PAYMENT_REINSTATED} constant. */ + PAYMENT_REINSTATED, /** The {@code PAYMENT_FAILED} constant. */ - PAYMENT_FAILED + PAYMENT_FAILED, + /** The {@code WALLET_FUNDED} constant. */ + WALLET_FUNDED, + /** The {@code WALLET_DEBITED} constant. */ + WALLET_DEBITED, + /** The {@code WALLET_BALANCE_LOW} constant. */ + WALLET_BALANCE_LOW, + /** The {@code WALLET_CREDIT_UNRECOVERED} constant. */ + WALLET_CREDIT_UNRECOVERED, + /** The {@code WALLET_CREDIT_RECOVERED} constant. */ + WALLET_CREDIT_RECOVERED, + /** The {@code WALLET_AUTO_TOP_UP_FAILED} constant. */ + WALLET_AUTO_TOP_UP_FAILED, + /** The {@code WALLET_AUTO_TOP_UP_SUSPENDED} constant. */ + WALLET_AUTO_TOP_UP_SUSPENDED, + /** The {@code WALLET_AUTO_TOP_UP_CONSENT_CHANGED} constant. */ + WALLET_AUTO_TOP_UP_CONSENT_CHANGED, + /** The {@code WALLET_DEPLETED} constant. */ + WALLET_DEPLETED, + /** The {@code WALLET_RECOVERED} constant. */ + WALLET_RECOVERED, + /** The {@code WALLET_AUTO_TOP_UP_CAP_REACHED} constant. */ + WALLET_AUTO_TOP_UP_CAP_REACHED, + /** The {@code CREDIT_GRANT_EXPIRED} constant. */ + CREDIT_GRANT_EXPIRED } /** The values this version of the SDK knows, and {@code _UNKNOWN} for the others. */ @@ -443,8 +537,34 @@ public enum Value { REFUND_FAILED, /** The {@code PAYMENT_REVERSED} constant. */ PAYMENT_REVERSED, + /** The {@code PAYMENT_REINSTATED} constant. */ + PAYMENT_REINSTATED, /** The {@code PAYMENT_FAILED} constant. */ PAYMENT_FAILED, + /** The {@code WALLET_FUNDED} constant. */ + WALLET_FUNDED, + /** The {@code WALLET_DEBITED} constant. */ + WALLET_DEBITED, + /** The {@code WALLET_BALANCE_LOW} constant. */ + WALLET_BALANCE_LOW, + /** The {@code WALLET_CREDIT_UNRECOVERED} constant. */ + WALLET_CREDIT_UNRECOVERED, + /** The {@code WALLET_CREDIT_RECOVERED} constant. */ + WALLET_CREDIT_RECOVERED, + /** The {@code WALLET_AUTO_TOP_UP_FAILED} constant. */ + WALLET_AUTO_TOP_UP_FAILED, + /** The {@code WALLET_AUTO_TOP_UP_SUSPENDED} constant. */ + WALLET_AUTO_TOP_UP_SUSPENDED, + /** The {@code WALLET_AUTO_TOP_UP_CONSENT_CHANGED} constant. */ + WALLET_AUTO_TOP_UP_CONSENT_CHANGED, + /** The {@code WALLET_DEPLETED} constant. */ + WALLET_DEPLETED, + /** The {@code WALLET_RECOVERED} constant. */ + WALLET_RECOVERED, + /** The {@code WALLET_AUTO_TOP_UP_CAP_REACHED} constant. */ + WALLET_AUTO_TOP_UP_CAP_REACHED, + /** The {@code CREDIT_GRANT_EXPIRED} constant. */ + CREDIT_GRANT_EXPIRED, /** A value this version of the SDK does not know. */ _UNKNOWN } diff --git a/src/main/java/com/meteroid/models/ExistingPriceRef.java b/src/main/java/com/meteroid/models/ExistingPriceRef.java index 8be91ff..55f4ada 100644 --- a/src/main/java/com/meteroid/models/ExistingPriceRef.java +++ b/src/main/java/com/meteroid/models/ExistingPriceRef.java @@ -27,12 +27,16 @@ public final class ExistingPriceRef { @JsonProperty("id") private String id; + @JsonProperty("type") + private String type = "EXISTING"; + private final Map additionalProperties = new LinkedHashMap<>(); private ExistingPriceRef() {} private ExistingPriceRef(Builder builder) { this.id = builder.id; + this.type = builder.type; this.additionalProperties.putAll(builder.additionalProperties); } @@ -53,6 +57,7 @@ public static Builder builder() { public Builder toBuilder() { Builder builder = new Builder(); builder.id = id; + builder.type = type; builder.additionalProperties.putAll(additionalProperties); return builder; } @@ -66,6 +71,15 @@ public String id() { return Utils.required(id, "id"); } + /** + * The {@code type} property. + * + * @return the value, never null + */ + public String type() { + return Utils.required(type, "type"); + } + /** * Properties this version of the SDK does not know, kept as received and sent back. * @@ -95,12 +109,13 @@ public boolean equals(Object o) { } ExistingPriceRef that = (ExistingPriceRef) o; return Objects.equals(id, that.id) + && Objects.equals(type, that.type) && Objects.equals(additionalProperties, that.additionalProperties); } @Override public int hashCode() { - return Objects.hash(id, additionalProperties); + return Objects.hash(id, type, additionalProperties); } @Override @@ -108,6 +123,8 @@ public String toString() { return "ExistingPriceRef{" + "id=" + id + + ", type=" + + type + ", additionalProperties=" + additionalProperties + "}"; @@ -116,6 +133,7 @@ public String toString() { /** Builds {@link ExistingPriceRef}. */ public static final class Builder { private String id; + private String type = "EXISTING"; private final Map additionalProperties = new LinkedHashMap<>(); private Builder() {} @@ -131,6 +149,17 @@ public Builder id(String id) { return this; } + /** + * The {@code type} property. + * + * @param type the value + * @return this builder + */ + public Builder type(String type) { + this.type = type; + return this; + } + /** * A property the SDK does not know, sent along. * @@ -173,6 +202,7 @@ public Builder removeAdditionalProperty(String name) { */ public ExistingPriceRef build() { Utils.checkRequired(id, "id"); + Utils.checkRequired(type, "type"); return new ExistingPriceRef(this); } } diff --git a/src/main/java/com/meteroid/models/ExistingProductRef.java b/src/main/java/com/meteroid/models/ExistingProductRef.java index 8d556b7..ac49a56 100644 --- a/src/main/java/com/meteroid/models/ExistingProductRef.java +++ b/src/main/java/com/meteroid/models/ExistingProductRef.java @@ -27,12 +27,16 @@ public final class ExistingProductRef { @JsonProperty("id") private String id; + @JsonProperty("type") + private String type = "EXISTING"; + private final Map additionalProperties = new LinkedHashMap<>(); private ExistingProductRef() {} private ExistingProductRef(Builder builder) { this.id = builder.id; + this.type = builder.type; this.additionalProperties.putAll(builder.additionalProperties); } @@ -53,6 +57,7 @@ public static Builder builder() { public Builder toBuilder() { Builder builder = new Builder(); builder.id = id; + builder.type = type; builder.additionalProperties.putAll(additionalProperties); return builder; } @@ -66,6 +71,15 @@ public String id() { return Utils.required(id, "id"); } + /** + * The {@code type} property. + * + * @return the value, never null + */ + public String type() { + return Utils.required(type, "type"); + } + /** * Properties this version of the SDK does not know, kept as received and sent back. * @@ -95,12 +109,13 @@ public boolean equals(Object o) { } ExistingProductRef that = (ExistingProductRef) o; return Objects.equals(id, that.id) + && Objects.equals(type, that.type) && Objects.equals(additionalProperties, that.additionalProperties); } @Override public int hashCode() { - return Objects.hash(id, additionalProperties); + return Objects.hash(id, type, additionalProperties); } @Override @@ -108,6 +123,8 @@ public String toString() { return "ExistingProductRef{" + "id=" + id + + ", type=" + + type + ", additionalProperties=" + additionalProperties + "}"; @@ -116,6 +133,7 @@ public String toString() { /** Builds {@link ExistingProductRef}. */ public static final class Builder { private String id; + private String type = "EXISTING"; private final Map additionalProperties = new LinkedHashMap<>(); private Builder() {} @@ -131,6 +149,17 @@ public Builder id(String id) { return this; } + /** + * The {@code type} property. + * + * @param type the value + * @return this builder + */ + public Builder type(String type) { + this.type = type; + return this; + } + /** * A property the SDK does not know, sent along. * @@ -173,6 +202,7 @@ public Builder removeAdditionalProperty(String name) { */ public ExistingProductRef build() { Utils.checkRequired(id, "id"); + Utils.checkRequired(type, "type"); return new ExistingProductRef(this); } } diff --git a/src/main/java/com/meteroid/models/ExternalPaymentMethodConfig.java b/src/main/java/com/meteroid/models/ExternalPaymentMethodConfig.java index 8d75e1e..297bd18 100644 --- a/src/main/java/com/meteroid/models/ExternalPaymentMethodConfig.java +++ b/src/main/java/com/meteroid/models/ExternalPaymentMethodConfig.java @@ -7,6 +7,7 @@ import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.JsonNode; import com.meteroid.internal.Utils; @@ -23,11 +24,15 @@ isGetterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE) public final class ExternalPaymentMethodConfig { + @JsonProperty("type") + private String type = "external"; + private final Map additionalProperties = new LinkedHashMap<>(); private ExternalPaymentMethodConfig() {} private ExternalPaymentMethodConfig(Builder builder) { + this.type = builder.type; this.additionalProperties.putAll(builder.additionalProperties); } @@ -47,10 +52,20 @@ public static Builder builder() { */ public Builder toBuilder() { Builder builder = new Builder(); + builder.type = type; builder.additionalProperties.putAll(additionalProperties); return builder; } + /** + * The {@code type} property. + * + * @return the value, never null + */ + public String type() { + return Utils.required(type, "type"); + } + /** * Properties this version of the SDK does not know, kept as received and sent back. * @@ -79,28 +94,43 @@ public boolean equals(Object o) { return false; } ExternalPaymentMethodConfig that = (ExternalPaymentMethodConfig) o; - return Objects.equals(additionalProperties, that.additionalProperties); + return Objects.equals(type, that.type) + && Objects.equals(additionalProperties, that.additionalProperties); } @Override public int hashCode() { - return Objects.hash(additionalProperties); + return Objects.hash(type, additionalProperties); } @Override public String toString() { return "ExternalPaymentMethodConfig{" - + "additionalProperties=" + + "type=" + + type + + ", additionalProperties=" + additionalProperties + "}"; } /** Builds {@link ExternalPaymentMethodConfig}. */ public static final class Builder { + private String type = "external"; private final Map additionalProperties = new LinkedHashMap<>(); private Builder() {} + /** + * The {@code type} property. + * + * @param type the value + * @return this builder + */ + public Builder type(String type) { + this.type = type; + return this; + } + /** * A property the SDK does not know, sent along. * @@ -142,6 +172,7 @@ public Builder removeAdditionalProperty(String name) { * @throws IllegalStateException when a required property is not set */ public ExternalPaymentMethodConfig build() { + Utils.checkRequired(type, "type"); return new ExternalPaymentMethodConfig(this); } } diff --git a/src/main/java/com/meteroid/models/ExtraRecurringFeeStructure.java b/src/main/java/com/meteroid/models/ExtraRecurringFeeStructure.java index 6e69375..7278e65 100644 --- a/src/main/java/com/meteroid/models/ExtraRecurringFeeStructure.java +++ b/src/main/java/com/meteroid/models/ExtraRecurringFeeStructure.java @@ -27,12 +27,16 @@ public final class ExtraRecurringFeeStructure { @JsonProperty("billing_type") private ExtraRecurringBillingTypeEnum billingType; + @JsonProperty("type") + private String type = "EXTRA_RECURRING"; + private final Map additionalProperties = new LinkedHashMap<>(); private ExtraRecurringFeeStructure() {} private ExtraRecurringFeeStructure(Builder builder) { this.billingType = builder.billingType; + this.type = builder.type; this.additionalProperties.putAll(builder.additionalProperties); } @@ -53,6 +57,7 @@ public static Builder builder() { public Builder toBuilder() { Builder builder = new Builder(); builder.billingType = billingType; + builder.type = type; builder.additionalProperties.putAll(additionalProperties); return builder; } @@ -66,6 +71,15 @@ public ExtraRecurringBillingTypeEnum billingType() { return Utils.required(billingType, "billing_type"); } + /** + * The {@code type} property. + * + * @return the value, never null + */ + public String type() { + return Utils.required(type, "type"); + } + /** * Properties this version of the SDK does not know, kept as received and sent back. * @@ -95,12 +109,13 @@ public boolean equals(Object o) { } ExtraRecurringFeeStructure that = (ExtraRecurringFeeStructure) o; return Objects.equals(billingType, that.billingType) + && Objects.equals(type, that.type) && Objects.equals(additionalProperties, that.additionalProperties); } @Override public int hashCode() { - return Objects.hash(billingType, additionalProperties); + return Objects.hash(billingType, type, additionalProperties); } @Override @@ -108,6 +123,8 @@ public String toString() { return "ExtraRecurringFeeStructure{" + "billingType=" + billingType + + ", type=" + + type + ", additionalProperties=" + additionalProperties + "}"; @@ -116,6 +133,7 @@ public String toString() { /** Builds {@link ExtraRecurringFeeStructure}. */ public static final class Builder { private ExtraRecurringBillingTypeEnum billingType; + private String type = "EXTRA_RECURRING"; private final Map additionalProperties = new LinkedHashMap<>(); private Builder() {} @@ -131,6 +149,17 @@ public Builder billingType(ExtraRecurringBillingTypeEnum billingType) { return this; } + /** + * The {@code type} property. + * + * @param type the value + * @return this builder + */ + public Builder type(String type) { + this.type = type; + return this; + } + /** * A property the SDK does not know, sent along. * @@ -173,6 +202,7 @@ public Builder removeAdditionalProperty(String name) { */ public ExtraRecurringFeeStructure build() { Utils.checkRequired(billingType, "billing_type"); + Utils.checkRequired(type, "type"); return new ExtraRecurringFeeStructure(this); } } diff --git a/src/main/java/com/meteroid/models/ExtraRecurringPlanFee.java b/src/main/java/com/meteroid/models/ExtraRecurringPlanFee.java index 6af06c7..1fb8ba5 100644 --- a/src/main/java/com/meteroid/models/ExtraRecurringPlanFee.java +++ b/src/main/java/com/meteroid/models/ExtraRecurringPlanFee.java @@ -38,6 +38,9 @@ public final class ExtraRecurringPlanFee { @JsonProperty("quantity") private Integer quantity; + @JsonProperty("type") + private String type = "EXTRA_RECURRING"; + @JsonProperty("unit_price") private BigDecimal unitPrice; @@ -49,6 +52,7 @@ private ExtraRecurringPlanFee(Builder builder) { this.billingType = builder.billingType; this.cadence = builder.cadence; this.quantity = builder.quantity; + this.type = builder.type; this.unitPrice = builder.unitPrice; this.additionalProperties.putAll(builder.additionalProperties); } @@ -72,6 +76,7 @@ public Builder toBuilder() { builder.billingType = billingType; builder.cadence = cadence; builder.quantity = quantity; + builder.type = type; builder.unitPrice = unitPrice; builder.additionalProperties.putAll(additionalProperties); return builder; @@ -104,6 +109,15 @@ public Integer quantity() { return Utils.required(quantity, "quantity"); } + /** + * The {@code type} property. + * + * @return the value, never null + */ + public String type() { + return Utils.required(type, "type"); + } + /** * The {@code unit_price} property. * @@ -144,13 +158,14 @@ public boolean equals(Object o) { return Objects.equals(billingType, that.billingType) && Objects.equals(cadence, that.cadence) && Objects.equals(quantity, that.quantity) + && Objects.equals(type, that.type) && Objects.equals(unitPrice, that.unitPrice) && Objects.equals(additionalProperties, that.additionalProperties); } @Override public int hashCode() { - return Objects.hash(billingType, cadence, quantity, unitPrice, additionalProperties); + return Objects.hash(billingType, cadence, quantity, type, unitPrice, additionalProperties); } @Override @@ -162,6 +177,8 @@ public String toString() { + cadence + ", quantity=" + quantity + + ", type=" + + type + ", unitPrice=" + unitPrice + ", additionalProperties=" @@ -174,6 +191,7 @@ public static final class Builder { private BillingType billingType; private BillingPeriodEnum cadence; private Integer quantity; + private String type = "EXTRA_RECURRING"; private BigDecimal unitPrice; private final Map additionalProperties = new LinkedHashMap<>(); @@ -212,6 +230,17 @@ public Builder quantity(Integer quantity) { return this; } + /** + * The {@code type} property. + * + * @param type the value + * @return this builder + */ + public Builder type(String type) { + this.type = type; + return this; + } + /** * The {@code unit_price} property. * @@ -267,6 +296,7 @@ public ExtraRecurringPlanFee build() { Utils.checkRequired(billingType, "billing_type"); Utils.checkRequired(cadence, "cadence"); Utils.checkRequired(quantity, "quantity"); + Utils.checkRequired(type, "type"); Utils.checkRequired(unitPrice, "unit_price"); return new ExtraRecurringPlanFee(this); } diff --git a/src/main/java/com/meteroid/models/ExtraRecurringPricing.java b/src/main/java/com/meteroid/models/ExtraRecurringPricing.java index 112d8c4..6084695 100644 --- a/src/main/java/com/meteroid/models/ExtraRecurringPricing.java +++ b/src/main/java/com/meteroid/models/ExtraRecurringPricing.java @@ -28,6 +28,9 @@ public final class ExtraRecurringPricing { @JsonProperty("quantity") private Integer quantity; + @JsonProperty("type") + private String type = "EXTRA_RECURRING"; + @JsonProperty("unit_price") private BigDecimal unitPrice; @@ -37,6 +40,7 @@ private ExtraRecurringPricing() {} private ExtraRecurringPricing(Builder builder) { this.quantity = builder.quantity; + this.type = builder.type; this.unitPrice = builder.unitPrice; this.additionalProperties.putAll(builder.additionalProperties); } @@ -58,6 +62,7 @@ public static Builder builder() { public Builder toBuilder() { Builder builder = new Builder(); builder.quantity = quantity; + builder.type = type; builder.unitPrice = unitPrice; builder.additionalProperties.putAll(additionalProperties); return builder; @@ -72,6 +77,15 @@ public Integer quantity() { return Utils.required(quantity, "quantity"); } + /** + * The {@code type} property. + * + * @return the value, never null + */ + public String type() { + return Utils.required(type, "type"); + } + /** * The {@code unit_price} property. * @@ -110,13 +124,14 @@ public boolean equals(Object o) { } ExtraRecurringPricing that = (ExtraRecurringPricing) o; return Objects.equals(quantity, that.quantity) + && Objects.equals(type, that.type) && Objects.equals(unitPrice, that.unitPrice) && Objects.equals(additionalProperties, that.additionalProperties); } @Override public int hashCode() { - return Objects.hash(quantity, unitPrice, additionalProperties); + return Objects.hash(quantity, type, unitPrice, additionalProperties); } @Override @@ -124,6 +139,8 @@ public String toString() { return "ExtraRecurringPricing{" + "quantity=" + quantity + + ", type=" + + type + ", unitPrice=" + unitPrice + ", additionalProperties=" @@ -134,6 +151,7 @@ public String toString() { /** Builds {@link ExtraRecurringPricing}. */ public static final class Builder { private Integer quantity; + private String type = "EXTRA_RECURRING"; private BigDecimal unitPrice; private final Map additionalProperties = new LinkedHashMap<>(); @@ -150,6 +168,17 @@ public Builder quantity(Integer quantity) { return this; } + /** + * The {@code type} property. + * + * @param type the value + * @return this builder + */ + public Builder type(String type) { + this.type = type; + return this; + } + /** * The {@code unit_price} property. * @@ -203,6 +232,7 @@ public Builder removeAdditionalProperty(String name) { */ public ExtraRecurringPricing build() { Utils.checkRequired(quantity, "quantity"); + Utils.checkRequired(type, "type"); Utils.checkRequired(unitPrice, "unit_price"); return new ExtraRecurringPricing(this); } diff --git a/src/main/java/com/meteroid/models/Fee.java b/src/main/java/com/meteroid/models/Fee.java index 17bc762..97b5347 100644 --- a/src/main/java/com/meteroid/models/Fee.java +++ b/src/main/java/com/meteroid/models/Fee.java @@ -36,7 +36,8 @@ @JsonSubTypes.Type(value = Fee.Capacity.class, name = "CAPACITY"), @JsonSubTypes.Type(value = Fee.Usage.class, name = "USAGE"), @JsonSubTypes.Type(value = Fee.ExtraRecurring.class, name = "EXTRA_RECURRING"), - @JsonSubTypes.Type(value = Fee.OneTime.class, name = "ONE_TIME") + @JsonSubTypes.Type(value = Fee.OneTime.class, name = "ONE_TIME"), + @JsonSubTypes.Type(value = Fee.Credit.class, name = "CREDIT") }) @JsonInclude(JsonInclude.Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) @@ -188,6 +189,28 @@ public final OneTime asOneTime() { throw new IllegalStateException("not the ONE_TIME variant: " + type()); } + /** + * Whether this is the {@code CREDIT} variant. + * + * @return whether it is + */ + public final boolean isCredit() { + return this instanceof Credit; + } + + /** + * This value as the {@code CREDIT} variant. + * + * @return the variant + * @throws IllegalStateException if this is another variant + */ + public final Credit asCredit() { + if (this instanceof Credit) { + return (Credit) this; + } + throw new IllegalStateException("not the CREDIT variant: " + type()); + } + /** * Whether this is a variant this version of the SDK does not know. * @@ -273,6 +296,14 @@ public interface Visitor { */ R visitOneTime(OneTimePlanFee value); + /** + * Visits the {@code CREDIT} variant. + * + * @param value the variant + * @return the result + */ + R visitCredit(CreditPlanFee value); + /** * Visits a variant this version of the SDK does not know. * @@ -732,6 +763,77 @@ public R accept(Visitor visitor) { } } + /** The {@code CREDIT} variant. */ + @JsonTypeName("CREDIT") + public static final class Credit extends Fee { + @JsonUnwrapped + @JsonIgnoreProperties(value = "type", allowSetters = true) + private CreditPlanFee data; + + private Credit() {} + + /** + * The variant holding {@code data}. + * + * @param data the value of the variant + */ + public Credit(CreditPlanFee data) { + this.data = Objects.requireNonNull(data, "data"); + } + + /** + * The variant holding {@code data}. + * + * @param data the value of the variant + * @return the variant + */ + public static Credit of(CreditPlanFee data) { + return new Credit(data); + } + + @Override + @JsonProperty("type") + public String type() { + return "CREDIT"; + } + + /** + * The value of the variant. + * + * @return the value + */ + public CreditPlanFee data() { + return data; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Credit that = (Credit) o; + return Objects.equals(data, that.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + return "Credit{" + "data=" + data + "}"; + } + + @Override + public R accept(Visitor visitor) { + return visitor.visitCredit(data); + } + } + /** A variant this version of the SDK does not know. */ public static final class Unrecognized extends Fee { @JsonProperty("type") diff --git a/src/main/java/com/meteroid/models/FeeCreditUnit.java b/src/main/java/com/meteroid/models/FeeCreditUnit.java new file mode 100644 index 0000000..1f8fe5c --- /dev/null +++ b/src/main/java/com/meteroid/models/FeeCreditUnit.java @@ -0,0 +1,299 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.Utils; + +import java.math.BigDecimal; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; + +/** + * The credit unit a usage fee's amounts are expressed in, with its value in the subscription + * currency. + * + *

Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonAutoDetect( + getterVisibility = Visibility.NONE, + isGetterVisibility = Visibility.NONE, + setterVisibility = Visibility.NONE) +public final class FeeCreditUnit { + @JsonProperty("code") + private String code; + + @JsonProperty("credit_unit_id") + private String creditUnitId; + + @JsonProperty("precision") + private Integer precision; + + @JsonProperty("rate") + private BigDecimal rate; + + private final Map additionalProperties = new LinkedHashMap<>(); + + private FeeCreditUnit() {} + + private FeeCreditUnit(Builder builder) { + this.code = builder.code; + this.creditUnitId = builder.creditUnitId; + this.precision = builder.precision; + this.rate = builder.rate; + this.additionalProperties.putAll(builder.additionalProperties); + } + + /** + * A builder of {@code FeeCreditUnit}. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * A builder starting from this value. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.code = code; + builder.creditUnitId = creditUnitId; + builder.precision = precision; + builder.rate = rate; + builder.additionalProperties.putAll(additionalProperties); + return builder; + } + + /** + * The credit unit's code, e.g. CREDITS. + * + * @return the value, never null + */ + public String code() { + return Utils.required(code, "code"); + } + + /** + * The credit unit's id (cun_…). + * + * @return the value, never null + */ + public String creditUnitId() { + return Utils.required(creditUnitId, "credit_unit_id"); + } + + /** + * Decimal places of the unit: credit balances and ledger amounts in it are integers of + * 10^-precision credit. + * + * @return the value, never null + */ + public Integer precision() { + return Utils.required(precision, "precision"); + } + + /** + * Subscription-currency major units per credit: the money billed, before tax, for each credit + * the customer's balance in the unit does not cover. + * + * @return the value, never null + */ + public BigDecimal rate() { + return Utils.required(rate, "rate"); + } + + /** + * Properties this version of the SDK does not know, kept as received and sent back. + * + * @return the properties by name, unmodifiable + */ + public Map additionalProperties() { + return Collections.unmodifiableMap(additionalProperties); + } + + @JsonAnyGetter + private Map anyProperties() { + return additionalProperties; + } + + @JsonAnySetter + private void putAnyProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + FeeCreditUnit that = (FeeCreditUnit) o; + return Objects.equals(code, that.code) + && Objects.equals(creditUnitId, that.creditUnitId) + && Objects.equals(precision, that.precision) + && Objects.equals(rate, that.rate) + && Objects.equals(additionalProperties, that.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(code, creditUnitId, precision, rate, additionalProperties); + } + + @Override + public String toString() { + return "FeeCreditUnit{" + + "code=" + + code + + ", creditUnitId=" + + creditUnitId + + ", precision=" + + precision + + ", rate=" + + rate + + ", additionalProperties=" + + additionalProperties + + "}"; + } + + /** Builds {@link FeeCreditUnit}. */ + public static final class Builder { + private String code; + private String creditUnitId; + private Integer precision; + private BigDecimal rate; + private final Map additionalProperties = new LinkedHashMap<>(); + + private Builder() {} + + /** + * The credit unit's code, e.g. CREDITS. + * + * @param code the value + * @return this builder + */ + public Builder code(String code) { + this.code = code; + return this; + } + + /** + * The credit unit's id (cun_…). + * + * @param creditUnitId the value + * @return this builder + */ + public Builder creditUnitId(String creditUnitId) { + this.creditUnitId = creditUnitId; + return this; + } + + /** + * Decimal places of the unit: credit balances and ledger amounts in it are integers of + * 10^-precision credit. + * + * @param precision the value + * @return this builder + */ + public Builder precision(Integer precision) { + this.precision = precision; + return this; + } + + /** + * Subscription-currency major units per credit: the money billed, before tax, for each + * credit the customer's balance in the unit does not cover. + * + * @param rate the value + * @return this builder + */ + public Builder rate(BigDecimal rate) { + this.rate = rate; + return this; + } + + /** + * A property the SDK does not know, sent along. + * + * @param name the property name + * @param value the JSON value + * @return this builder + */ + public Builder putAdditionalProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + return this; + } + + /** + * Properties the SDK does not know, sent along. + * + * @param additionalProperties the properties by name + * @return this builder + */ + public Builder putAllAdditionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + + /** + * Leaves out a property the SDK does not know. + * + * @param name the property name + * @return this builder + */ + public Builder removeAdditionalProperty(String name) { + additionalProperties.remove(name); + return this; + } + + /** + * The {@code FeeCreditUnit}. + * + * @return the immutable value + * @throws IllegalStateException when a required property is not set + */ + public FeeCreditUnit build() { + Utils.checkRequired(code, "code"); + Utils.checkRequired(creditUnitId, "credit_unit_id"); + Utils.checkRequired(precision, "precision"); + Utils.checkRequired(rate, "rate"); + return new FeeCreditUnit(this); + } + } + + /** + * Parse {@code json} as {@code FeeCreditUnit}. + * + * @param json the JSON text + * @return the value + * @throws com.meteroid.exceptions.InvalidDataException if it is not valid JSON of this shape + */ + public static FeeCreditUnit fromJson(String json) { + return Utils.parse(json, FeeCreditUnit.class); + } + + /** + * This value as JSON. + * + * @return the JSON text + */ + public String toJson() { + return Utils.json(this); + } +} diff --git a/src/main/java/com/meteroid/models/FixedDiscount.java b/src/main/java/com/meteroid/models/FixedDiscount.java index fb92ec4..5135459 100644 --- a/src/main/java/com/meteroid/models/FixedDiscount.java +++ b/src/main/java/com/meteroid/models/FixedDiscount.java @@ -30,6 +30,9 @@ public final class FixedDiscount { @JsonProperty("currency") private String currency; + @JsonProperty("type") + private String type = "FIXED"; + private final Map additionalProperties = new LinkedHashMap<>(); private FixedDiscount() {} @@ -37,6 +40,7 @@ private FixedDiscount() {} private FixedDiscount(Builder builder) { this.amount = builder.amount; this.currency = builder.currency; + this.type = builder.type; this.additionalProperties.putAll(builder.additionalProperties); } @@ -58,6 +62,7 @@ public Builder toBuilder() { Builder builder = new Builder(); builder.amount = amount; builder.currency = currency; + builder.type = type; builder.additionalProperties.putAll(additionalProperties); return builder; } @@ -80,6 +85,15 @@ public String currency() { return Utils.required(currency, "currency"); } + /** + * The {@code type} property. + * + * @return the value, never null + */ + public String type() { + return Utils.required(type, "type"); + } + /** * Properties this version of the SDK does not know, kept as received and sent back. * @@ -110,12 +124,13 @@ public boolean equals(Object o) { FixedDiscount that = (FixedDiscount) o; return Objects.equals(amount, that.amount) && Objects.equals(currency, that.currency) + && Objects.equals(type, that.type) && Objects.equals(additionalProperties, that.additionalProperties); } @Override public int hashCode() { - return Objects.hash(amount, currency, additionalProperties); + return Objects.hash(amount, currency, type, additionalProperties); } @Override @@ -125,6 +140,8 @@ public String toString() { + amount + ", currency=" + currency + + ", type=" + + type + ", additionalProperties=" + additionalProperties + "}"; @@ -134,6 +151,7 @@ public String toString() { public static final class Builder { private String amount; private String currency; + private String type = "FIXED"; private final Map additionalProperties = new LinkedHashMap<>(); private Builder() {} @@ -160,6 +178,17 @@ public Builder currency(String currency) { return this; } + /** + * The {@code type} property. + * + * @param type the value + * @return this builder + */ + public Builder type(String type) { + this.type = type; + return this; + } + /** * A property the SDK does not know, sent along. * @@ -203,6 +232,7 @@ public Builder removeAdditionalProperty(String name) { public FixedDiscount build() { Utils.checkRequired(amount, "amount"); Utils.checkRequired(currency, "currency"); + Utils.checkRequired(type, "type"); return new FixedDiscount(this); } } diff --git a/src/main/java/com/meteroid/models/FixedWindowResetPeriod.java b/src/main/java/com/meteroid/models/FixedWindowResetPeriod.java index 99fe6cd..c7e0fa4 100644 --- a/src/main/java/com/meteroid/models/FixedWindowResetPeriod.java +++ b/src/main/java/com/meteroid/models/FixedWindowResetPeriod.java @@ -31,6 +31,9 @@ public final class FixedWindowResetPeriod { @JsonProperty("interval") private Integer interval; + @JsonProperty("type") + private String type = "FIXED_WINDOW"; + @JsonProperty("unit") private CalendarUnit unit; @@ -40,6 +43,7 @@ private FixedWindowResetPeriod() {} private FixedWindowResetPeriod(Builder builder) { this.interval = builder.interval; + this.type = builder.type; this.unit = builder.unit; this.additionalProperties.putAll(builder.additionalProperties); } @@ -61,6 +65,7 @@ public static Builder builder() { public Builder toBuilder() { Builder builder = new Builder(); builder.interval = interval; + builder.type = type; builder.unit = unit; builder.additionalProperties.putAll(additionalProperties); return builder; @@ -75,6 +80,15 @@ public Integer interval() { return Utils.required(interval, "interval"); } + /** + * The {@code type} property. + * + * @return the value, never null + */ + public String type() { + return Utils.required(type, "type"); + } + /** * The {@code unit} property. * @@ -113,13 +127,14 @@ public boolean equals(Object o) { } FixedWindowResetPeriod that = (FixedWindowResetPeriod) o; return Objects.equals(interval, that.interval) + && Objects.equals(type, that.type) && Objects.equals(unit, that.unit) && Objects.equals(additionalProperties, that.additionalProperties); } @Override public int hashCode() { - return Objects.hash(interval, unit, additionalProperties); + return Objects.hash(interval, type, unit, additionalProperties); } @Override @@ -127,6 +142,8 @@ public String toString() { return "FixedWindowResetPeriod{" + "interval=" + interval + + ", type=" + + type + ", unit=" + unit + ", additionalProperties=" @@ -137,6 +154,7 @@ public String toString() { /** Builds {@link FixedWindowResetPeriod}. */ public static final class Builder { private Integer interval; + private String type = "FIXED_WINDOW"; private CalendarUnit unit; private final Map additionalProperties = new LinkedHashMap<>(); @@ -153,6 +171,17 @@ public Builder interval(Integer interval) { return this; } + /** + * The {@code type} property. + * + * @param type the value + * @return this builder + */ + public Builder type(String type) { + this.type = type; + return this; + } + /** * The {@code unit} property. * @@ -206,6 +235,7 @@ public Builder removeAdditionalProperty(String name) { */ public FixedWindowResetPeriod build() { Utils.checkRequired(interval, "interval"); + Utils.checkRequired(type, "type"); Utils.checkRequired(unit, "unit"); return new FixedWindowResetPeriod(this); } diff --git a/src/main/java/com/meteroid/models/Invoice.java b/src/main/java/com/meteroid/models/Invoice.java index 1a68ccb..e8d825b 100644 --- a/src/main/java/com/meteroid/models/Invoice.java +++ b/src/main/java/com/meteroid/models/Invoice.java @@ -108,9 +108,16 @@ public final class Invoice { @JsonInclude(JsonInclude.Include.NON_EMPTY) private JsonField parentInvoiceId = JsonField.missing(); + @JsonProperty("payment_disputed_at") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField paymentDisputedAt = JsonField.missing(); + @JsonProperty("payment_status") private InvoicePaymentStatus paymentStatus; + @JsonProperty("promotional_credits") + private Long promotionalCredits; + @JsonProperty("purchase_order") @JsonInclude(JsonInclude.Include.NON_EMPTY) private JsonField purchaseOrder = JsonField.missing(); @@ -119,6 +126,9 @@ public final class Invoice { @JsonInclude(JsonInclude.Include.NON_EMPTY) private JsonField reference = JsonField.missing(); + @JsonProperty("settled_by_credit_notes") + private Boolean settledByCreditNotes; + @JsonProperty("status") private InvoiceStatus status; @@ -183,9 +193,12 @@ private Invoice(Builder builder) { this.netTerms = builder.netTerms; this.paidAt = builder.paidAt; this.parentInvoiceId = builder.parentInvoiceId; + this.paymentDisputedAt = builder.paymentDisputedAt; this.paymentStatus = builder.paymentStatus; + this.promotionalCredits = builder.promotionalCredits; this.purchaseOrder = builder.purchaseOrder; this.reference = builder.reference; + this.settledByCreditNotes = builder.settledByCreditNotes; this.status = builder.status; this.subscriptionId = builder.subscriptionId; this.subtotal = builder.subtotal; @@ -239,9 +252,12 @@ public Builder toBuilder() { builder.netTerms = netTerms; builder.paidAt = paidAt; builder.parentInvoiceId = parentInvoiceId; + builder.paymentDisputedAt = paymentDisputedAt; builder.paymentStatus = paymentStatus; + builder.promotionalCredits = promotionalCredits; builder.purchaseOrder = purchaseOrder; builder.reference = reference; + builder.settledByCreditNotes = settledByCreditNotes; builder.status = status; builder.subscriptionId = subscriptionId; builder.subtotal = subtotal; @@ -267,7 +283,8 @@ public Long amountDue() { } /** - * The {@code applied_credits} property. + * Paid credit applied after tax, in minor units of the invoice currency: it settles part of + * total like a payment, and amount_due is net of it. * * @return the value, never null */ @@ -466,6 +483,16 @@ public Optional parentInvoiceId() { return parentInvoiceId.asOptional(); } + /** + * When a dispute or chargeback first took money still lost on this invoice's payments. The + * invoice stays paid; absent when nothing is disputed. + * + * @return the value, empty when unset or null + */ + public Optional paymentDisputedAt() { + return paymentDisputedAt.asOptional(); + } + /** * The {@code payment_status} property. * @@ -475,6 +502,19 @@ public InvoicePaymentStatus paymentStatus() { return Utils.required(paymentStatus, "payment_status"); } + /** + * Promotional credit applied before tax (credit included with the plan, coupon credit, bonus + * credit), in minor units of the invoice currency. Like a discount, it reduces the taxable + * amount: tax_amount and total already exclude it, subtotal + * does not. Unlike applied_credits, which settles part of the total + * after tax. + * + * @return the value, empty when unset + */ + public Optional promotionalCredits() { + return Optional.ofNullable(promotionalCredits); + } + /** * The {@code purchase_order} property. * @@ -493,6 +533,16 @@ public Optional reference() { return reference.asOptional(); } + /** + * True when the invoice is PAID without any payment: finalized credit notes + * cancelled its whole total. Nothing was collected, so it books no cash. + * + * @return the value, never null + */ + public Boolean settledByCreditNotes() { + return Utils.required(settledByCreditNotes, "settled_by_credit_notes"); + } + /** * The {@code status} property. * @@ -644,9 +694,12 @@ public boolean equals(Object o) { && Objects.equals(netTerms, that.netTerms) && Objects.equals(paidAt, that.paidAt) && Objects.equals(parentInvoiceId, that.parentInvoiceId) + && Objects.equals(paymentDisputedAt, that.paymentDisputedAt) && Objects.equals(paymentStatus, that.paymentStatus) + && Objects.equals(promotionalCredits, that.promotionalCredits) && Objects.equals(purchaseOrder, that.purchaseOrder) && Objects.equals(reference, that.reference) + && Objects.equals(settledByCreditNotes, that.settledByCreditNotes) && Objects.equals(status, that.status) && Objects.equals(subscriptionId, that.subscriptionId) && Objects.equals(subtotal, that.subtotal) @@ -687,9 +740,12 @@ public int hashCode() { netTerms, paidAt, parentInvoiceId, + paymentDisputedAt, paymentStatus, + promotionalCredits, purchaseOrder, reference, + settledByCreditNotes, status, subscriptionId, subtotal, @@ -753,12 +809,18 @@ public String toString() { + paidAt + ", parentInvoiceId=" + parentInvoiceId + + ", paymentDisputedAt=" + + paymentDisputedAt + ", paymentStatus=" + paymentStatus + + ", promotionalCredits=" + + promotionalCredits + ", purchaseOrder=" + purchaseOrder + ", reference=" + reference + + ", settledByCreditNotes=" + + settledByCreditNotes + ", status=" + status + ", subscriptionId=" @@ -811,9 +873,12 @@ public static final class Builder { private Integer netTerms; private JsonField paidAt = JsonField.missing(); private JsonField parentInvoiceId = JsonField.missing(); + private JsonField paymentDisputedAt = JsonField.missing(); private InvoicePaymentStatus paymentStatus; + private Long promotionalCredits; private JsonField purchaseOrder = JsonField.missing(); private JsonField reference = JsonField.missing(); + private Boolean settledByCreditNotes; private InvoiceStatus status; private JsonField subscriptionId = JsonField.missing(); private Long subtotal; @@ -841,7 +906,8 @@ public Builder amountDue(Long amountDue) { } /** - * The {@code applied_credits} property. + * Paid credit applied after tax, in minor units of the invoice currency: it settles part of + * total like a payment, and amount_due is net of it. * * @param appliedCredits the value * @return this builder @@ -1112,6 +1178,18 @@ public Builder parentInvoiceId(String parentInvoiceId) { return this; } + /** + * When a dispute or chargeback first took money still lost on this invoice's payments. The + * invoice stays paid; absent when nothing is disputed. + * + * @param paymentDisputedAt the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder paymentDisputedAt(OffsetDateTime paymentDisputedAt) { + this.paymentDisputedAt = JsonField.ofNullable(paymentDisputedAt); + return this; + } + /** * The {@code payment_status} property. * @@ -1123,6 +1201,21 @@ public Builder paymentStatus(InvoicePaymentStatus paymentStatus) { return this; } + /** + * Promotional credit applied before tax (credit included with the plan, coupon credit, + * bonus credit), in minor units of the invoice currency. Like a discount, it reduces the + * taxable amount: tax_amount and total already exclude it, + * subtotal does not. Unlike applied_credits, which settles part of the + * total after tax. + * + * @param promotionalCredits the value + * @return this builder + */ + public Builder promotionalCredits(Long promotionalCredits) { + this.promotionalCredits = promotionalCredits; + return this; + } + /** * The {@code purchase_order} property. * @@ -1145,6 +1238,18 @@ public Builder reference(String reference) { return this; } + /** + * True when the invoice is PAID without any payment: finalized credit notes + * cancelled its whole total. Nothing was collected, so it books no cash. + * + * @param settledByCreditNotes the value + * @return this builder + */ + public Builder settledByCreditNotes(Boolean settledByCreditNotes) { + this.settledByCreditNotes = settledByCreditNotes; + return this; + } + /** * The {@code status} property. * @@ -1351,6 +1456,7 @@ public Invoice build() { Utils.checkRequired(lineItems, "line_items"); Utils.checkRequired(netTerms, "net_terms"); Utils.checkRequired(paymentStatus, "payment_status"); + Utils.checkRequired(settledByCreditNotes, "settled_by_credit_notes"); Utils.checkRequired(status, "status"); Utils.checkRequired(subtotal, "subtotal"); Utils.checkRequired(subtotalRecurring, "subtotal_recurring"); diff --git a/src/main/java/com/meteroid/models/InvoiceEventData.java b/src/main/java/com/meteroid/models/InvoiceEventData.java index 1b83332..d6d6d7d 100644 --- a/src/main/java/com/meteroid/models/InvoiceEventData.java +++ b/src/main/java/com/meteroid/models/InvoiceEventData.java @@ -54,6 +54,9 @@ public final class InvoiceEventData { @JsonInclude(JsonInclude.Include.NON_EMPTY) private JsonField parentInvoiceId = JsonField.missing(); + @JsonProperty("settled_by_credit_notes") + private Boolean settledByCreditNotes; + @JsonProperty("status") private InvoiceStatus status; @@ -76,6 +79,7 @@ private InvoiceEventData(Builder builder) { this.invoiceId = builder.invoiceId; this.invoiceNumber = builder.invoiceNumber; this.parentInvoiceId = builder.parentInvoiceId; + this.settledByCreditNotes = builder.settledByCreditNotes; this.status = builder.status; this.taxAmount = builder.taxAmount; this.total = builder.total; @@ -106,6 +110,7 @@ public Builder toBuilder() { builder.invoiceId = invoiceId; builder.invoiceNumber = invoiceNumber; builder.parentInvoiceId = parentInvoiceId; + builder.settledByCreditNotes = settledByCreditNotes; builder.status = status; builder.taxAmount = taxAmount; builder.total = total; @@ -185,6 +190,17 @@ public Optional parentInvoiceId() { return parentInvoiceId.asOptional(); } + /** + * On invoice.paid: true when finalized credit notes, not a payment, settled the + * invoice's whole total. Nothing was collected, so it books no cash. False on every other + * event. + * + * @return the value, never null + */ + public Boolean settledByCreditNotes() { + return Utils.required(settledByCreditNotes, "settled_by_credit_notes"); + } + /** * The {@code status} property. * @@ -248,6 +264,7 @@ public boolean equals(Object o) { && Objects.equals(invoiceId, that.invoiceId) && Objects.equals(invoiceNumber, that.invoiceNumber) && Objects.equals(parentInvoiceId, that.parentInvoiceId) + && Objects.equals(settledByCreditNotes, that.settledByCreditNotes) && Objects.equals(status, that.status) && Objects.equals(taxAmount, that.taxAmount) && Objects.equals(total, that.total) @@ -265,6 +282,7 @@ public int hashCode() { invoiceId, invoiceNumber, parentInvoiceId, + settledByCreditNotes, status, taxAmount, total, @@ -290,6 +308,8 @@ public String toString() { + invoiceNumber + ", parentInvoiceId=" + parentInvoiceId + + ", settledByCreditNotes=" + + settledByCreditNotes + ", status=" + status + ", taxAmount=" @@ -311,6 +331,7 @@ public static final class Builder { private String invoiceId; private JsonField invoiceNumber = JsonField.missing(); private JsonField parentInvoiceId = JsonField.missing(); + private Boolean settledByCreditNotes; private InvoiceStatus status; private Long taxAmount; private Long total; @@ -406,6 +427,19 @@ public Builder parentInvoiceId(String parentInvoiceId) { return this; } + /** + * On invoice.paid: true when finalized credit notes, not a payment, settled + * the invoice's whole total. Nothing was collected, so it books no cash. False on every + * other event. + * + * @param settledByCreditNotes the value + * @return this builder + */ + public Builder settledByCreditNotes(Boolean settledByCreditNotes) { + this.settledByCreditNotes = settledByCreditNotes; + return this; + } + /** * The {@code status} property. * @@ -485,6 +519,7 @@ public InvoiceEventData build() { Utils.checkRequired(customProperties, "custom_properties"); Utils.checkRequired(customerId, "customer_id"); Utils.checkRequired(invoiceId, "invoice_id"); + Utils.checkRequired(settledByCreditNotes, "settled_by_credit_notes"); Utils.checkRequired(status, "status"); Utils.checkRequired(taxAmount, "tax_amount"); Utils.checkRequired(total, "total"); diff --git a/src/main/java/com/meteroid/models/InvoiceLineCreditUnit.java b/src/main/java/com/meteroid/models/InvoiceLineCreditUnit.java new file mode 100644 index 0000000..4bb888b --- /dev/null +++ b/src/main/java/com/meteroid/models/InvoiceLineCreditUnit.java @@ -0,0 +1,358 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.JsonField; +import com.meteroid.internal.Utils; + +import java.math.BigDecimal; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +/** + * How a usage line priced in a credit unit was paid: the credits it consumed, those the customer's + * balance in the unit covered, and the rate the rest was billed at. + * + *

Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonAutoDetect( + getterVisibility = Visibility.NONE, + isGetterVisibility = Visibility.NONE, + setterVisibility = Visibility.NONE) +public final class InvoiceLineCreditUnit { + @JsonProperty("code") + private String code; + + @JsonProperty("consumed") + private Long consumed; + + @JsonProperty("covered") + private Long covered; + + @JsonProperty("precision") + private Integer precision; + + @JsonProperty("rate") + private BigDecimal rate; + + @JsonProperty("unit_price") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField unitPrice = JsonField.missing(); + + private final Map additionalProperties = new LinkedHashMap<>(); + + private InvoiceLineCreditUnit() {} + + private InvoiceLineCreditUnit(Builder builder) { + this.code = builder.code; + this.consumed = builder.consumed; + this.covered = builder.covered; + this.precision = builder.precision; + this.rate = builder.rate; + this.unitPrice = builder.unitPrice; + this.additionalProperties.putAll(builder.additionalProperties); + } + + /** + * A builder of {@code InvoiceLineCreditUnit}. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * A builder starting from this value. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.code = code; + builder.consumed = consumed; + builder.covered = covered; + builder.precision = precision; + builder.rate = rate; + builder.unitPrice = unitPrice; + builder.additionalProperties.putAll(additionalProperties); + return builder; + } + + /** + * The credit unit's code, e.g. CREDITS. + * + * @return the value, never null + */ + public String code() { + return Utils.required(code, "code"); + } + + /** + * Credits the usage priced. + * + * @return the value, never null + */ + public Long consumed() { + return Utils.required(consumed, "consumed"); + } + + /** + * Of which paid by the customer's credit wallet. + * + * @return the value, never null + */ + public Long covered() { + return Utils.required(covered, "covered"); + } + + /** + * Credit amounts are integers in 10^-precision credit. + * + * @return the value, never null + */ + public Integer precision() { + return Utils.required(precision, "precision"); + } + + /** + * Invoice-currency major units per credit. + * + * @return the value, never null + */ + public BigDecimal rate() { + return Utils.required(rate, "rate"); + } + + /** + * Credits per usage unit. + * + * @return the value, empty when unset or null + */ + public Optional unitPrice() { + return unitPrice.asOptional(); + } + + /** + * Properties this version of the SDK does not know, kept as received and sent back. + * + * @return the properties by name, unmodifiable + */ + public Map additionalProperties() { + return Collections.unmodifiableMap(additionalProperties); + } + + @JsonAnyGetter + private Map anyProperties() { + return additionalProperties; + } + + @JsonAnySetter + private void putAnyProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + InvoiceLineCreditUnit that = (InvoiceLineCreditUnit) o; + return Objects.equals(code, that.code) + && Objects.equals(consumed, that.consumed) + && Objects.equals(covered, that.covered) + && Objects.equals(precision, that.precision) + && Objects.equals(rate, that.rate) + && Objects.equals(unitPrice, that.unitPrice) + && Objects.equals(additionalProperties, that.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash( + code, consumed, covered, precision, rate, unitPrice, additionalProperties); + } + + @Override + public String toString() { + return "InvoiceLineCreditUnit{" + + "code=" + + code + + ", consumed=" + + consumed + + ", covered=" + + covered + + ", precision=" + + precision + + ", rate=" + + rate + + ", unitPrice=" + + unitPrice + + ", additionalProperties=" + + additionalProperties + + "}"; + } + + /** Builds {@link InvoiceLineCreditUnit}. */ + public static final class Builder { + private String code; + private Long consumed; + private Long covered; + private Integer precision; + private BigDecimal rate; + private JsonField unitPrice = JsonField.missing(); + private final Map additionalProperties = new LinkedHashMap<>(); + + private Builder() {} + + /** + * The credit unit's code, e.g. CREDITS. + * + * @param code the value + * @return this builder + */ + public Builder code(String code) { + this.code = code; + return this; + } + + /** + * Credits the usage priced. + * + * @param consumed the value + * @return this builder + */ + public Builder consumed(Long consumed) { + this.consumed = consumed; + return this; + } + + /** + * Of which paid by the customer's credit wallet. + * + * @param covered the value + * @return this builder + */ + public Builder covered(Long covered) { + this.covered = covered; + return this; + } + + /** + * Credit amounts are integers in 10^-precision credit. + * + * @param precision the value + * @return this builder + */ + public Builder precision(Integer precision) { + this.precision = precision; + return this; + } + + /** + * Invoice-currency major units per credit. + * + * @param rate the value + * @return this builder + */ + public Builder rate(BigDecimal rate) { + this.rate = rate; + return this; + } + + /** + * Credits per usage unit. + * + * @param unitPrice the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder unitPrice(BigDecimal unitPrice) { + this.unitPrice = JsonField.ofNullable(unitPrice); + return this; + } + + /** + * A property the SDK does not know, sent along. + * + * @param name the property name + * @param value the JSON value + * @return this builder + */ + public Builder putAdditionalProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + return this; + } + + /** + * Properties the SDK does not know, sent along. + * + * @param additionalProperties the properties by name + * @return this builder + */ + public Builder putAllAdditionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + + /** + * Leaves out a property the SDK does not know. + * + * @param name the property name + * @return this builder + */ + public Builder removeAdditionalProperty(String name) { + additionalProperties.remove(name); + return this; + } + + /** + * The {@code InvoiceLineCreditUnit}. + * + * @return the immutable value + * @throws IllegalStateException when a required property is not set + */ + public InvoiceLineCreditUnit build() { + Utils.checkRequired(code, "code"); + Utils.checkRequired(consumed, "consumed"); + Utils.checkRequired(covered, "covered"); + Utils.checkRequired(precision, "precision"); + Utils.checkRequired(rate, "rate"); + return new InvoiceLineCreditUnit(this); + } + } + + /** + * Parse {@code json} as {@code InvoiceLineCreditUnit}. + * + * @param json the JSON text + * @return the value + * @throws com.meteroid.exceptions.InvalidDataException if it is not valid JSON of this shape + */ + public static InvoiceLineCreditUnit fromJson(String json) { + return Utils.parse(json, InvoiceLineCreditUnit.class); + } + + /** + * This value as JSON. + * + * @return the JSON text + */ + public String toJson() { + return Utils.json(this); + } +} diff --git a/src/main/java/com/meteroid/models/InvoiceLineItem.java b/src/main/java/com/meteroid/models/InvoiceLineItem.java index fe2642b..b0c32e4 100644 --- a/src/main/java/com/meteroid/models/InvoiceLineItem.java +++ b/src/main/java/com/meteroid/models/InvoiceLineItem.java @@ -33,6 +33,10 @@ public final class InvoiceLineItem { @JsonProperty("amount_total") private Long amountTotal; + @JsonProperty("credit_unit") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField creditUnit = JsonField.missing(); + @JsonProperty("description") @JsonInclude(JsonInclude.Include.NON_EMPTY) private JsonField description = JsonField.missing(); @@ -67,6 +71,7 @@ private InvoiceLineItem() {} private InvoiceLineItem(Builder builder) { this.amountTotal = builder.amountTotal; + this.creditUnit = builder.creditUnit; this.description = builder.description; this.endDate = builder.endDate; this.name = builder.name; @@ -96,6 +101,7 @@ public static Builder builder() { public Builder toBuilder() { Builder builder = new Builder(); builder.amountTotal = amountTotal; + builder.creditUnit = creditUnit; builder.description = description; builder.endDate = endDate; builder.name = name; @@ -118,6 +124,15 @@ public Long amountTotal() { return Utils.required(amountTotal, "amount_total"); } + /** + * The {@code credit_unit} property. + * + * @return the value, empty when unset or null + */ + public Optional creditUnit() { + return creditUnit.asOptional(); + } + /** * The {@code description} property. * @@ -229,6 +244,7 @@ public boolean equals(Object o) { } InvoiceLineItem that = (InvoiceLineItem) o; return Objects.equals(amountTotal, that.amountTotal) + && Objects.equals(creditUnit, that.creditUnit) && Objects.equals(description, that.description) && Objects.equals(endDate, that.endDate) && Objects.equals(name, that.name) @@ -245,6 +261,7 @@ public boolean equals(Object o) { public int hashCode() { return Objects.hash( amountTotal, + creditUnit, description, endDate, name, @@ -262,6 +279,8 @@ public String toString() { return "InvoiceLineItem{" + "amountTotal=" + amountTotal + + ", creditUnit=" + + creditUnit + ", description=" + description + ", endDate=" @@ -288,6 +307,7 @@ public String toString() { /** Builds {@link InvoiceLineItem}. */ public static final class Builder { private Long amountTotal; + private JsonField creditUnit = JsonField.missing(); private JsonField description = JsonField.missing(); private LocalDate endDate; private String name; @@ -312,6 +332,17 @@ public Builder amountTotal(Long amountTotal) { return this; } + /** + * The {@code credit_unit} property. + * + * @param creditUnit the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder creditUnit(InvoiceLineCreditUnit creditUnit) { + this.creditUnit = JsonField.ofNullable(creditUnit); + return this; + } + /** * The {@code description} property. * diff --git a/src/main/java/com/meteroid/models/JsonConfigValue.java b/src/main/java/com/meteroid/models/JsonConfigValue.java index 367e795..141cf8c 100644 --- a/src/main/java/com/meteroid/models/JsonConfigValue.java +++ b/src/main/java/com/meteroid/models/JsonConfigValue.java @@ -28,6 +28,9 @@ isGetterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE) public final class JsonConfigValue { + @JsonProperty("kind") + private String kind = "JSON"; + @JsonProperty("value") private Object value; @@ -36,6 +39,7 @@ public final class JsonConfigValue { private JsonConfigValue() {} private JsonConfigValue(Builder builder) { + this.kind = builder.kind; this.value = builder.value; this.additionalProperties.putAll(builder.additionalProperties); } @@ -56,11 +60,21 @@ public static Builder builder() { */ public Builder toBuilder() { Builder builder = new Builder(); + builder.kind = kind; builder.value = value; builder.additionalProperties.putAll(additionalProperties); return builder; } + /** + * The {@code kind} property. + * + * @return the value, never null + */ + public String kind() { + return Utils.required(kind, "kind"); + } + /** * The {@code value} property. * @@ -98,19 +112,22 @@ public boolean equals(Object o) { return false; } JsonConfigValue that = (JsonConfigValue) o; - return Objects.equals(value, that.value) + return Objects.equals(kind, that.kind) + && Objects.equals(value, that.value) && Objects.equals(additionalProperties, that.additionalProperties); } @Override public int hashCode() { - return Objects.hash(value, additionalProperties); + return Objects.hash(kind, value, additionalProperties); } @Override public String toString() { return "JsonConfigValue{" - + "value=" + + "kind=" + + kind + + ", value=" + value + ", additionalProperties=" + additionalProperties @@ -119,11 +136,23 @@ public String toString() { /** Builds {@link JsonConfigValue}. */ public static final class Builder { + private String kind = "JSON"; private Object value; private final Map additionalProperties = new LinkedHashMap<>(); private Builder() {} + /** + * The {@code kind} property. + * + * @param kind the value + * @return this builder + */ + public Builder kind(String kind) { + this.kind = kind; + return this; + } + /** * The {@code value} property. * @@ -176,6 +205,7 @@ public Builder removeAdditionalProperty(String name) { * @throws IllegalStateException when a required property is not set */ public JsonConfigValue build() { + Utils.checkRequired(kind, "kind"); Utils.checkRequired(value, "value"); return new JsonConfigValue(this); } diff --git a/src/main/java/com/meteroid/models/LedgerEntry.java b/src/main/java/com/meteroid/models/LedgerEntry.java new file mode 100644 index 0000000..9805f23 --- /dev/null +++ b/src/main/java/com/meteroid/models/LedgerEntry.java @@ -0,0 +1,741 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.JsonField; +import com.meteroid.internal.Utils; + +import java.time.OffsetDateTime; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +/** + * One movement of a customer's credit. + * + *

Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonAutoDetect( + getterVisibility = Visibility.NONE, + isGetterVisibility = Visibility.NONE, + setterVisibility = Visibility.NONE) +public final class LedgerEntry { + @JsonProperty("amount") + private Long amount; + + @JsonProperty("applies_to") + private CreditAppliesTo appliesTo; + + @JsonProperty("balance_after") + private Long balanceAfter; + + @JsonProperty("cost") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField cost = JsonField.missing(); + + @JsonProperty("credit_grant_id") + private String creditGrantId; + + @JsonProperty("credit_note_id") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField creditNoteId = JsonField.missing(); + + @JsonProperty("credit_unit") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField creditUnit = JsonField.missing(); + + @JsonProperty("credit_unit_precision") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField creditUnitPrecision = JsonField.missing(); + + @JsonProperty("currency") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField currency = JsonField.missing(); + + @JsonProperty("effective_at") + private OffsetDateTime effectiveAt; + + @JsonProperty("id") + private String id; + + @JsonProperty("invoice_id") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField invoiceId = JsonField.missing(); + + @JsonProperty("reason") + private String reason; + + @JsonProperty("recorded_at") + private OffsetDateTime recordedAt; + + @JsonProperty("reference") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField reference = JsonField.missing(); + + @JsonProperty("sequence") + private Long sequence; + + @JsonProperty("subscription_id") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField subscriptionId = JsonField.missing(); + + @JsonProperty("type") + private LedgerEntryType type; + + private final Map additionalProperties = new LinkedHashMap<>(); + + private LedgerEntry() {} + + private LedgerEntry(Builder builder) { + this.amount = builder.amount; + this.appliesTo = builder.appliesTo; + this.balanceAfter = builder.balanceAfter; + this.cost = builder.cost; + this.creditGrantId = builder.creditGrantId; + this.creditNoteId = builder.creditNoteId; + this.creditUnit = builder.creditUnit; + this.creditUnitPrecision = builder.creditUnitPrecision; + this.currency = builder.currency; + this.effectiveAt = builder.effectiveAt; + this.id = builder.id; + this.invoiceId = builder.invoiceId; + this.reason = builder.reason; + this.recordedAt = builder.recordedAt; + this.reference = builder.reference; + this.sequence = builder.sequence; + this.subscriptionId = builder.subscriptionId; + this.type = builder.type; + this.additionalProperties.putAll(builder.additionalProperties); + } + + /** + * A builder of {@code LedgerEntry}. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * A builder starting from this value. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.amount = amount; + builder.appliesTo = appliesTo; + builder.balanceAfter = balanceAfter; + builder.cost = cost; + builder.creditGrantId = creditGrantId; + builder.creditNoteId = creditNoteId; + builder.creditUnit = creditUnit; + builder.creditUnitPrecision = creditUnitPrecision; + builder.currency = currency; + builder.effectiveAt = effectiveAt; + builder.id = id; + builder.invoiceId = invoiceId; + builder.reason = reason; + builder.recordedAt = recordedAt; + builder.reference = reference; + builder.sequence = sequence; + builder.subscriptionId = subscriptionId; + builder.type = type; + builder.additionalProperties.putAll(additionalProperties); + return builder; + } + + /** + * Signed change to the credit on account, in minor units. + * + * @return the value, never null + */ + public Long amount() { + return Utils.required(amount, "amount"); + } + + /** + * What the moved credit's grant pays: ALL any charge, USAGE only usage charges. + * + * @return the value, never null + */ + public CreditAppliesTo appliesTo() { + return Utils.required(appliesTo, "applies_to"); + } + + /** + * The credit on account after this entry, whatever it applies to. + * + * @return the value, never null + */ + public Long balanceAfter() { + return Utils.required(balanceAfter, "balance_after"); + } + + /** + * The {@code cost} property. + * + * @return the value, empty when unset or null + */ + public Optional cost() { + return cost.asOptional(); + } + + /** + * The grant the credit moved in or out of. + * + * @return the value, never null + */ + public String creditGrantId() { + return Utils.required(creditGrantId, "credit_grant_id"); + } + + /** + * The credit note that gave the credit back or took it back. + * + * @return the value, empty when unset or null + */ + public Optional creditNoteId() { + return creditNoteId.asOptional(); + } + + /** + * The credit unit (its code) the amounts are in; absent for a currency. + * + * @return the value, empty when unset or null + */ + public Optional creditUnit() { + return creditUnit.asOptional(); + } + + /** + * Decimal places of credit_unit: amounts are integers of 10^-precision credit. + * + * @return the value, empty when unset or null + */ + public Optional creditUnitPrecision() { + return creditUnitPrecision.asOptional(); + } + + /** + * The {@code currency} property. + * + * @return the value, empty when unset or null + */ + public Optional currency() { + return currency.asOptional(); + } + + /** + * When the movement took effect; the ledger is ordered by it. + * + * @return the value, never null + */ + public OffsetDateTime effectiveAt() { + return Utils.required(effectiveAt, "effective_at"); + } + + /** + * The entry's id (wle_…). + * + * @return the value, never null + */ + public String id() { + return Utils.required(id, "id"); + } + + /** + * The invoice the credit was applied to, bought on, or given back by. + * + * @return the value, empty when unset or null + */ + public Optional invoiceId() { + return invoiceId.asOptional(); + } + + /** + * Why the credit moved, as shown on the ledger. + * + * @return the value, never null + */ + public String reason() { + return Utils.required(reason, "reason"); + } + + /** + * When the movement was recorded. + * + * @return the value, never null + */ + public OffsetDateTime recordedAt() { + return Utils.required(recordedAt, "recorded_at"); + } + + /** + * Your own reference, e.g. a contract or support ticket. + * + * @return the value, empty when unset or null + */ + public Optional reference() { + return reference.asOptional(); + } + + /** + * Position within the currency's ledger in the order the movements took effect, from 1. A + * movement recorded later with an earlier date shifts the positions after it: identify an entry + * by its id. + * + * @return the value, never null + */ + public Long sequence() { + return Utils.required(sequence, "sequence"); + } + + /** + * The subscription the moved credit's grant belongs to; null when it pays any of the customer's + * subscriptions. + * + * @return the value, empty when unset or null + */ + public Optional subscriptionId() { + return subscriptionId.asOptional(); + } + + /** + * What moved the credit. + * + * @return the value, never null + */ + public LedgerEntryType type() { + return Utils.required(type, "type"); + } + + /** + * Properties this version of the SDK does not know, kept as received and sent back. + * + * @return the properties by name, unmodifiable + */ + public Map additionalProperties() { + return Collections.unmodifiableMap(additionalProperties); + } + + @JsonAnyGetter + private Map anyProperties() { + return additionalProperties; + } + + @JsonAnySetter + private void putAnyProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + LedgerEntry that = (LedgerEntry) o; + return Objects.equals(amount, that.amount) + && Objects.equals(appliesTo, that.appliesTo) + && Objects.equals(balanceAfter, that.balanceAfter) + && Objects.equals(cost, that.cost) + && Objects.equals(creditGrantId, that.creditGrantId) + && Objects.equals(creditNoteId, that.creditNoteId) + && Objects.equals(creditUnit, that.creditUnit) + && Objects.equals(creditUnitPrecision, that.creditUnitPrecision) + && Objects.equals(currency, that.currency) + && Objects.equals(effectiveAt, that.effectiveAt) + && Objects.equals(id, that.id) + && Objects.equals(invoiceId, that.invoiceId) + && Objects.equals(reason, that.reason) + && Objects.equals(recordedAt, that.recordedAt) + && Objects.equals(reference, that.reference) + && Objects.equals(sequence, that.sequence) + && Objects.equals(subscriptionId, that.subscriptionId) + && Objects.equals(type, that.type) + && Objects.equals(additionalProperties, that.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash( + amount, + appliesTo, + balanceAfter, + cost, + creditGrantId, + creditNoteId, + creditUnit, + creditUnitPrecision, + currency, + effectiveAt, + id, + invoiceId, + reason, + recordedAt, + reference, + sequence, + subscriptionId, + type, + additionalProperties); + } + + @Override + public String toString() { + return "LedgerEntry{" + + "amount=" + + amount + + ", appliesTo=" + + appliesTo + + ", balanceAfter=" + + balanceAfter + + ", cost=" + + cost + + ", creditGrantId=" + + creditGrantId + + ", creditNoteId=" + + creditNoteId + + ", creditUnit=" + + creditUnit + + ", creditUnitPrecision=" + + creditUnitPrecision + + ", currency=" + + currency + + ", effectiveAt=" + + effectiveAt + + ", id=" + + id + + ", invoiceId=" + + invoiceId + + ", reason=" + + reason + + ", recordedAt=" + + recordedAt + + ", reference=" + + reference + + ", sequence=" + + sequence + + ", subscriptionId=" + + subscriptionId + + ", type=" + + type + + ", additionalProperties=" + + additionalProperties + + "}"; + } + + /** Builds {@link LedgerEntry}. */ + public static final class Builder { + private Long amount; + private CreditAppliesTo appliesTo; + private Long balanceAfter; + private JsonField cost = JsonField.missing(); + private String creditGrantId; + private JsonField creditNoteId = JsonField.missing(); + private JsonField creditUnit = JsonField.missing(); + private JsonField creditUnitPrecision = JsonField.missing(); + private JsonField currency = JsonField.missing(); + private OffsetDateTime effectiveAt; + private String id; + private JsonField invoiceId = JsonField.missing(); + private String reason; + private OffsetDateTime recordedAt; + private JsonField reference = JsonField.missing(); + private Long sequence; + private JsonField subscriptionId = JsonField.missing(); + private LedgerEntryType type; + private final Map additionalProperties = new LinkedHashMap<>(); + + private Builder() {} + + /** + * Signed change to the credit on account, in minor units. + * + * @param amount the value + * @return this builder + */ + public Builder amount(Long amount) { + this.amount = amount; + return this; + } + + /** + * What the moved credit's grant pays: ALL any charge, USAGE only usage charges. + * + * @param appliesTo the value + * @return this builder + */ + public Builder appliesTo(CreditAppliesTo appliesTo) { + this.appliesTo = appliesTo; + return this; + } + + /** + * The credit on account after this entry, whatever it applies to. + * + * @param balanceAfter the value + * @return this builder + */ + public Builder balanceAfter(Long balanceAfter) { + this.balanceAfter = balanceAfter; + return this; + } + + /** + * The {@code cost} property. + * + * @param cost the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder cost(CreditCost cost) { + this.cost = JsonField.ofNullable(cost); + return this; + } + + /** + * The grant the credit moved in or out of. + * + * @param creditGrantId the value + * @return this builder + */ + public Builder creditGrantId(String creditGrantId) { + this.creditGrantId = creditGrantId; + return this; + } + + /** + * The credit note that gave the credit back or took it back. + * + * @param creditNoteId the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder creditNoteId(String creditNoteId) { + this.creditNoteId = JsonField.ofNullable(creditNoteId); + return this; + } + + /** + * The credit unit (its code) the amounts are in; absent for a currency. + * + * @param creditUnit the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder creditUnit(String creditUnit) { + this.creditUnit = JsonField.ofNullable(creditUnit); + return this; + } + + /** + * Decimal places of credit_unit: amounts are integers of 10^-precision credit. + * + * @param creditUnitPrecision the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder creditUnitPrecision(Integer creditUnitPrecision) { + this.creditUnitPrecision = JsonField.ofNullable(creditUnitPrecision); + return this; + } + + /** + * The {@code currency} property. + * + * @param currency the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder currency(Currency currency) { + this.currency = JsonField.ofNullable(currency); + return this; + } + + /** + * When the movement took effect; the ledger is ordered by it. + * + * @param effectiveAt the value + * @return this builder + */ + public Builder effectiveAt(OffsetDateTime effectiveAt) { + this.effectiveAt = effectiveAt; + return this; + } + + /** + * The entry's id (wle_…). + * + * @param id the value + * @return this builder + */ + public Builder id(String id) { + this.id = id; + return this; + } + + /** + * The invoice the credit was applied to, bought on, or given back by. + * + * @param invoiceId the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder invoiceId(String invoiceId) { + this.invoiceId = JsonField.ofNullable(invoiceId); + return this; + } + + /** + * Why the credit moved, as shown on the ledger. + * + * @param reason the value + * @return this builder + */ + public Builder reason(String reason) { + this.reason = reason; + return this; + } + + /** + * When the movement was recorded. + * + * @param recordedAt the value + * @return this builder + */ + public Builder recordedAt(OffsetDateTime recordedAt) { + this.recordedAt = recordedAt; + return this; + } + + /** + * Your own reference, e.g. a contract or support ticket. + * + * @param reference the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder reference(String reference) { + this.reference = JsonField.ofNullable(reference); + return this; + } + + /** + * Position within the currency's ledger in the order the movements took effect, from 1. A + * movement recorded later with an earlier date shifts the positions after it: identify an + * entry by its id. + * + * @param sequence the value + * @return this builder + */ + public Builder sequence(Long sequence) { + this.sequence = sequence; + return this; + } + + /** + * The subscription the moved credit's grant belongs to; null when it pays any of the + * customer's subscriptions. + * + * @param subscriptionId the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder subscriptionId(String subscriptionId) { + this.subscriptionId = JsonField.ofNullable(subscriptionId); + return this; + } + + /** + * What moved the credit. + * + * @param type the value + * @return this builder + */ + public Builder type(LedgerEntryType type) { + this.type = type; + return this; + } + + /** + * A property the SDK does not know, sent along. + * + * @param name the property name + * @param value the JSON value + * @return this builder + */ + public Builder putAdditionalProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + return this; + } + + /** + * Properties the SDK does not know, sent along. + * + * @param additionalProperties the properties by name + * @return this builder + */ + public Builder putAllAdditionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + + /** + * Leaves out a property the SDK does not know. + * + * @param name the property name + * @return this builder + */ + public Builder removeAdditionalProperty(String name) { + additionalProperties.remove(name); + return this; + } + + /** + * The {@code LedgerEntry}. + * + * @return the immutable value + * @throws IllegalStateException when a required property is not set + */ + public LedgerEntry build() { + Utils.checkRequired(amount, "amount"); + Utils.checkRequired(appliesTo, "applies_to"); + Utils.checkRequired(balanceAfter, "balance_after"); + Utils.checkRequired(creditGrantId, "credit_grant_id"); + Utils.checkRequired(effectiveAt, "effective_at"); + Utils.checkRequired(id, "id"); + Utils.checkRequired(reason, "reason"); + Utils.checkRequired(recordedAt, "recorded_at"); + Utils.checkRequired(sequence, "sequence"); + Utils.checkRequired(type, "type"); + return new LedgerEntry(this); + } + } + + /** + * Parse {@code json} as {@code LedgerEntry}. + * + * @param json the JSON text + * @return the value + * @throws com.meteroid.exceptions.InvalidDataException if it is not valid JSON of this shape + */ + public static LedgerEntry fromJson(String json) { + return Utils.parse(json, LedgerEntry.class); + } + + /** + * This value as JSON. + * + * @return the JSON text + */ + public String toJson() { + return Utils.json(this); + } +} diff --git a/src/main/java/com/meteroid/models/LedgerEntryType.java b/src/main/java/com/meteroid/models/LedgerEntryType.java new file mode 100644 index 0000000..5861e73 --- /dev/null +++ b/src/main/java/com/meteroid/models/LedgerEntryType.java @@ -0,0 +1,173 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import com.meteroid.internal.Utils.ToQueryParam; + +import java.util.Map; +import java.util.Objects; + +/** + * Values this version of the SDK does not know are kept, and sent back unchanged: {@link #value()} + * is an enum to switch on, {@code _UNKNOWN} for them, and {@link #known()} throws on them. + */ +public final class LedgerEntryType implements ToQueryParam { + /** The value {@code "CREDIT"}. */ + public static final LedgerEntryType CREDIT = new LedgerEntryType("CREDIT", Value.CREDIT); + + /** The value {@code "INVOICE_APPLICATION"}. */ + public static final LedgerEntryType INVOICE_APPLICATION = + new LedgerEntryType("INVOICE_APPLICATION", Value.INVOICE_APPLICATION); + + /** The value {@code "INVOICE_RETURN"}. */ + public static final LedgerEntryType INVOICE_RETURN = + new LedgerEntryType("INVOICE_RETURN", Value.INVOICE_RETURN); + + /** The value {@code "CREDIT_REVERSAL"}. */ + public static final LedgerEntryType CREDIT_REVERSAL = + new LedgerEntryType("CREDIT_REVERSAL", Value.CREDIT_REVERSAL); + + /** The value {@code "CREDIT_REINSTATEMENT"}. */ + public static final LedgerEntryType CREDIT_REINSTATEMENT = + new LedgerEntryType("CREDIT_REINSTATEMENT", Value.CREDIT_REINSTATEMENT); + + /** The value {@code "CREDIT_EXPIRY"}. */ + public static final LedgerEntryType CREDIT_EXPIRY = + new LedgerEntryType("CREDIT_EXPIRY", Value.CREDIT_EXPIRY); + + /** The value {@code "CREDIT_ROLLOVER"}. */ + public static final LedgerEntryType CREDIT_ROLLOVER = + new LedgerEntryType("CREDIT_ROLLOVER", Value.CREDIT_ROLLOVER); + + private static final Map constants = + Map.ofEntries( + Map.entry("CREDIT", CREDIT), + Map.entry("INVOICE_APPLICATION", INVOICE_APPLICATION), + Map.entry("INVOICE_RETURN", INVOICE_RETURN), + Map.entry("CREDIT_REVERSAL", CREDIT_REVERSAL), + Map.entry("CREDIT_REINSTATEMENT", CREDIT_REINSTATEMENT), + Map.entry("CREDIT_EXPIRY", CREDIT_EXPIRY), + Map.entry("CREDIT_ROLLOVER", CREDIT_ROLLOVER)); + + private final String value; + private final Value variant; + + private LedgerEntryType(String value, Value variant) { + this.value = value; + this.variant = variant; + } + + /** + * The constant for {@code value}, or an unknown LedgerEntryType holding it. + * + * @param value the value + * @return the constant + */ + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static LedgerEntryType of(String value) { + LedgerEntryType constant = constants.get(Objects.requireNonNull(value, "value")); + return constant != null ? constant : new LedgerEntryType(value, Value._UNKNOWN); + } + + /** + * The value as sent. + * + * @return the value + */ + @JsonValue + public String asString() { + return value; + } + + /** + * Whether this version of the SDK knows the value. + * + * @return whether it is known + */ + public boolean isKnown() { + return variant != Value._UNKNOWN; + } + + /** + * The value as an enum to switch on, unknown values included. + * + * @return the enum, {@code _UNKNOWN} when unknown + */ + public Value value() { + return variant; + } + + /** + * The value as an enum of the known values only. + * + * @return the enum + * @throws com.meteroid.exceptions.InvalidDataException when this version of the SDK does not + * know the value + */ + public Known known() { + if (!isKnown()) { + throw new com.meteroid.exceptions.InvalidDataException( + "unknown LedgerEntryType: " + value); + } + return Known.valueOf(variant.name()); + } + + @Override + public String toQueryParam() { + return String.valueOf(value); + } + + @Override + public boolean equals(Object o) { + return o instanceof LedgerEntryType && Objects.equals(value, ((LedgerEntryType) o).value); + } + + @Override + public int hashCode() { + return Objects.hashCode(value); + } + + @Override + public String toString() { + return String.valueOf(value); + } + + /** The values this version of the SDK knows. */ + public enum Known { + /** The {@code CREDIT} constant. */ + CREDIT, + /** The {@code INVOICE_APPLICATION} constant. */ + INVOICE_APPLICATION, + /** The {@code INVOICE_RETURN} constant. */ + INVOICE_RETURN, + /** The {@code CREDIT_REVERSAL} constant. */ + CREDIT_REVERSAL, + /** The {@code CREDIT_REINSTATEMENT} constant. */ + CREDIT_REINSTATEMENT, + /** The {@code CREDIT_EXPIRY} constant. */ + CREDIT_EXPIRY, + /** The {@code CREDIT_ROLLOVER} constant. */ + CREDIT_ROLLOVER + } + + /** The values this version of the SDK knows, and {@code _UNKNOWN} for the others. */ + public enum Value { + /** The {@code CREDIT} constant. */ + CREDIT, + /** The {@code INVOICE_APPLICATION} constant. */ + INVOICE_APPLICATION, + /** The {@code INVOICE_RETURN} constant. */ + INVOICE_RETURN, + /** The {@code CREDIT_REVERSAL} constant. */ + CREDIT_REVERSAL, + /** The {@code CREDIT_REINSTATEMENT} constant. */ + CREDIT_REINSTATEMENT, + /** The {@code CREDIT_EXPIRY} constant. */ + CREDIT_EXPIRY, + /** The {@code CREDIT_ROLLOVER} constant. */ + CREDIT_ROLLOVER, + /** A value this version of the SDK does not know. */ + _UNKNOWN + } +} diff --git a/src/main/java/com/meteroid/models/LedgerListResponse.java b/src/main/java/com/meteroid/models/LedgerListResponse.java new file mode 100644 index 0000000..b0cc24f --- /dev/null +++ b/src/main/java/com/meteroid/models/LedgerListResponse.java @@ -0,0 +1,249 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.Utils; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * A page of ledger entries, newest first. + * + *

Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonAutoDetect( + getterVisibility = Visibility.NONE, + isGetterVisibility = Visibility.NONE, + setterVisibility = Visibility.NONE) +public final class LedgerListResponse { + @JsonProperty("data") + private List data; + + @JsonProperty("pagination_meta") + private PaginationResponse paginationMeta; + + private final Map additionalProperties = new LinkedHashMap<>(); + + private LedgerListResponse() {} + + private LedgerListResponse(Builder builder) { + this.data = Utils.copyList(builder.data); + this.paginationMeta = builder.paginationMeta; + this.additionalProperties.putAll(builder.additionalProperties); + } + + /** + * A builder of {@code LedgerListResponse}. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * A builder starting from this value. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.data = Utils.mutableList(data); + builder.paginationMeta = paginationMeta; + builder.additionalProperties.putAll(additionalProperties); + return builder; + } + + /** + * The {@code data} property. + * + * @return the value, never null + */ + public List data() { + return Utils.required(data, "data"); + } + + /** + * The {@code pagination_meta} property. + * + * @return the value, never null + */ + public PaginationResponse paginationMeta() { + return Utils.required(paginationMeta, "pagination_meta"); + } + + /** + * Properties this version of the SDK does not know, kept as received and sent back. + * + * @return the properties by name, unmodifiable + */ + public Map additionalProperties() { + return Collections.unmodifiableMap(additionalProperties); + } + + @JsonAnyGetter + private Map anyProperties() { + return additionalProperties; + } + + @JsonAnySetter + private void putAnyProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + LedgerListResponse that = (LedgerListResponse) o; + return Objects.equals(data, that.data) + && Objects.equals(paginationMeta, that.paginationMeta) + && Objects.equals(additionalProperties, that.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(data, paginationMeta, additionalProperties); + } + + @Override + public String toString() { + return "LedgerListResponse{" + + "data=" + + data + + ", paginationMeta=" + + paginationMeta + + ", additionalProperties=" + + additionalProperties + + "}"; + } + + /** Builds {@link LedgerListResponse}. */ + public static final class Builder { + private List data; + private PaginationResponse paginationMeta; + private final Map additionalProperties = new LinkedHashMap<>(); + + private Builder() {} + + /** + * The {@code data} property. + * + * @param data the value + * @return this builder + */ + public Builder data(List data) { + this.data = Utils.mutableList(data); + return this; + } + + /** + * Adds an item to {@code data}. + * + * @param item the item + * @return this builder + */ + public Builder addDataItem(LedgerEntry item) { + if (this.data == null) { + this.data = new ArrayList<>(); + } + this.data.add(item); + return this; + } + + /** + * The {@code pagination_meta} property. + * + * @param paginationMeta the value + * @return this builder + */ + public Builder paginationMeta(PaginationResponse paginationMeta) { + this.paginationMeta = paginationMeta; + return this; + } + + /** + * A property the SDK does not know, sent along. + * + * @param name the property name + * @param value the JSON value + * @return this builder + */ + public Builder putAdditionalProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + return this; + } + + /** + * Properties the SDK does not know, sent along. + * + * @param additionalProperties the properties by name + * @return this builder + */ + public Builder putAllAdditionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + + /** + * Leaves out a property the SDK does not know. + * + * @param name the property name + * @return this builder + */ + public Builder removeAdditionalProperty(String name) { + additionalProperties.remove(name); + return this; + } + + /** + * The {@code LedgerListResponse}. + * + * @return the immutable value + * @throws IllegalStateException when a required property is not set + */ + public LedgerListResponse build() { + Utils.checkRequired(data, "data"); + Utils.checkRequired(paginationMeta, "pagination_meta"); + return new LedgerListResponse(this); + } + } + + /** + * Parse {@code json} as {@code LedgerListResponse}. + * + * @param json the JSON text + * @return the value + * @throws com.meteroid.exceptions.InvalidDataException if it is not valid JSON of this shape + */ + public static LedgerListResponse fromJson(String json) { + return Utils.parse(json, LedgerListResponse.class); + } + + /** + * This value as JSON. + * + * @return the JSON text + */ + public String toJson() { + return Utils.json(this); + } +} diff --git a/src/main/java/com/meteroid/models/LinkedSegmentationMatrix.java b/src/main/java/com/meteroid/models/LinkedSegmentationMatrix.java index ba90f22..ee81a23 100644 --- a/src/main/java/com/meteroid/models/LinkedSegmentationMatrix.java +++ b/src/main/java/com/meteroid/models/LinkedSegmentationMatrix.java @@ -31,6 +31,9 @@ public final class LinkedSegmentationMatrix { @JsonProperty("dimension2_key") private String dimension2Key; + @JsonProperty("type") + private String type = "LINKED"; + @JsonProperty("values") private Map> values; @@ -41,6 +44,7 @@ private LinkedSegmentationMatrix() {} private LinkedSegmentationMatrix(Builder builder) { this.dimension1Key = builder.dimension1Key; this.dimension2Key = builder.dimension2Key; + this.type = builder.type; this.values = Utils.copyMap(builder.values); this.additionalProperties.putAll(builder.additionalProperties); } @@ -63,6 +67,7 @@ public Builder toBuilder() { Builder builder = new Builder(); builder.dimension1Key = dimension1Key; builder.dimension2Key = dimension2Key; + builder.type = type; builder.values = Utils.mutableMap(values); builder.additionalProperties.putAll(additionalProperties); return builder; @@ -86,6 +91,15 @@ public String dimension2Key() { return Utils.required(dimension2Key, "dimension2_key"); } + /** + * The {@code type} property. + * + * @return the value, never null + */ + public String type() { + return Utils.required(type, "type"); + } + /** * The {@code values} property. * @@ -125,13 +139,14 @@ public boolean equals(Object o) { LinkedSegmentationMatrix that = (LinkedSegmentationMatrix) o; return Objects.equals(dimension1Key, that.dimension1Key) && Objects.equals(dimension2Key, that.dimension2Key) + && Objects.equals(type, that.type) && Objects.equals(values, that.values) && Objects.equals(additionalProperties, that.additionalProperties); } @Override public int hashCode() { - return Objects.hash(dimension1Key, dimension2Key, values, additionalProperties); + return Objects.hash(dimension1Key, dimension2Key, type, values, additionalProperties); } @Override @@ -141,6 +156,8 @@ public String toString() { + dimension1Key + ", dimension2Key=" + dimension2Key + + ", type=" + + type + ", values=" + values + ", additionalProperties=" @@ -152,6 +169,7 @@ public String toString() { public static final class Builder { private String dimension1Key; private String dimension2Key; + private String type = "LINKED"; private Map> values; private final Map additionalProperties = new LinkedHashMap<>(); @@ -179,6 +197,17 @@ public Builder dimension2Key(String dimension2Key) { return this; } + /** + * The {@code type} property. + * + * @param type the value + * @return this builder + */ + public Builder type(String type) { + this.type = type; + return this; + } + /** * The {@code values} property. * @@ -248,6 +277,7 @@ public Builder removeAdditionalProperty(String name) { public LinkedSegmentationMatrix build() { Utils.checkRequired(dimension1Key, "dimension1_key"); Utils.checkRequired(dimension2Key, "dimension2_key"); + Utils.checkRequired(type, "type"); Utils.checkRequired(values, "values"); return new LinkedSegmentationMatrix(this); } diff --git a/src/main/java/com/meteroid/models/ListCustomerUsageCostsGranularity.java b/src/main/java/com/meteroid/models/ListCustomerUsageCostsGranularity.java new file mode 100644 index 0000000..0022f8a --- /dev/null +++ b/src/main/java/com/meteroid/models/ListCustomerUsageCostsGranularity.java @@ -0,0 +1,140 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import com.meteroid.internal.Utils.ToQueryParam; + +import java.util.Map; +import java.util.Objects; + +/** + * Values this version of the SDK does not know are kept, and sent back unchanged: {@link #value()} + * is an enum to switch on, {@code _UNKNOWN} for them, and {@link #known()} throws on them. + */ +public final class ListCustomerUsageCostsGranularity implements ToQueryParam { + /** The value {@code "HOUR"}. */ + public static final ListCustomerUsageCostsGranularity HOUR = + new ListCustomerUsageCostsGranularity("HOUR", Value.HOUR); + + /** The value {@code "DAY"}. */ + public static final ListCustomerUsageCostsGranularity DAY = + new ListCustomerUsageCostsGranularity("DAY", Value.DAY); + + /** The value {@code "MONTH"}. */ + public static final ListCustomerUsageCostsGranularity MONTH = + new ListCustomerUsageCostsGranularity("MONTH", Value.MONTH); + + private static final Map constants = + Map.ofEntries( + Map.entry("HOUR", HOUR), Map.entry("DAY", DAY), Map.entry("MONTH", MONTH)); + + private final String value; + private final Value variant; + + private ListCustomerUsageCostsGranularity(String value, Value variant) { + this.value = value; + this.variant = variant; + } + + /** + * The constant for {@code value}, or an unknown ListCustomerUsageCostsGranularity holding it. + * + * @param value the value + * @return the constant + */ + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static ListCustomerUsageCostsGranularity of(String value) { + ListCustomerUsageCostsGranularity constant = + constants.get(Objects.requireNonNull(value, "value")); + return constant != null + ? constant + : new ListCustomerUsageCostsGranularity(value, Value._UNKNOWN); + } + + /** + * The value as sent. + * + * @return the value + */ + @JsonValue + public String asString() { + return value; + } + + /** + * Whether this version of the SDK knows the value. + * + * @return whether it is known + */ + public boolean isKnown() { + return variant != Value._UNKNOWN; + } + + /** + * The value as an enum to switch on, unknown values included. + * + * @return the enum, {@code _UNKNOWN} when unknown + */ + public Value value() { + return variant; + } + + /** + * The value as an enum of the known values only. + * + * @return the enum + * @throws com.meteroid.exceptions.InvalidDataException when this version of the SDK does not + * know the value + */ + public Known known() { + if (!isKnown()) { + throw new com.meteroid.exceptions.InvalidDataException( + "unknown ListCustomerUsageCostsGranularity: " + value); + } + return Known.valueOf(variant.name()); + } + + @Override + public String toQueryParam() { + return String.valueOf(value); + } + + @Override + public boolean equals(Object o) { + return o instanceof ListCustomerUsageCostsGranularity + && Objects.equals(value, ((ListCustomerUsageCostsGranularity) o).value); + } + + @Override + public int hashCode() { + return Objects.hashCode(value); + } + + @Override + public String toString() { + return String.valueOf(value); + } + + /** The values this version of the SDK knows. */ + public enum Known { + /** The {@code HOUR} constant. */ + HOUR, + /** The {@code DAY} constant. */ + DAY, + /** The {@code MONTH} constant. */ + MONTH + } + + /** The values this version of the SDK knows, and {@code _UNKNOWN} for the others. */ + public enum Value { + /** The {@code HOUR} constant. */ + HOUR, + /** The {@code DAY} constant. */ + DAY, + /** The {@code MONTH} constant. */ + MONTH, + /** A value this version of the SDK does not know. */ + _UNKNOWN + } +} diff --git a/src/main/java/com/meteroid/models/ListSubscriptionUsageCostsGranularity.java b/src/main/java/com/meteroid/models/ListSubscriptionUsageCostsGranularity.java new file mode 100644 index 0000000..4107254 --- /dev/null +++ b/src/main/java/com/meteroid/models/ListSubscriptionUsageCostsGranularity.java @@ -0,0 +1,141 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import com.meteroid.internal.Utils.ToQueryParam; + +import java.util.Map; +import java.util.Objects; + +/** + * Values this version of the SDK does not know are kept, and sent back unchanged: {@link #value()} + * is an enum to switch on, {@code _UNKNOWN} for them, and {@link #known()} throws on them. + */ +public final class ListSubscriptionUsageCostsGranularity implements ToQueryParam { + /** The value {@code "HOUR"}. */ + public static final ListSubscriptionUsageCostsGranularity HOUR = + new ListSubscriptionUsageCostsGranularity("HOUR", Value.HOUR); + + /** The value {@code "DAY"}. */ + public static final ListSubscriptionUsageCostsGranularity DAY = + new ListSubscriptionUsageCostsGranularity("DAY", Value.DAY); + + /** The value {@code "MONTH"}. */ + public static final ListSubscriptionUsageCostsGranularity MONTH = + new ListSubscriptionUsageCostsGranularity("MONTH", Value.MONTH); + + private static final Map constants = + Map.ofEntries( + Map.entry("HOUR", HOUR), Map.entry("DAY", DAY), Map.entry("MONTH", MONTH)); + + private final String value; + private final Value variant; + + private ListSubscriptionUsageCostsGranularity(String value, Value variant) { + this.value = value; + this.variant = variant; + } + + /** + * The constant for {@code value}, or an unknown ListSubscriptionUsageCostsGranularity holding + * it. + * + * @param value the value + * @return the constant + */ + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static ListSubscriptionUsageCostsGranularity of(String value) { + ListSubscriptionUsageCostsGranularity constant = + constants.get(Objects.requireNonNull(value, "value")); + return constant != null + ? constant + : new ListSubscriptionUsageCostsGranularity(value, Value._UNKNOWN); + } + + /** + * The value as sent. + * + * @return the value + */ + @JsonValue + public String asString() { + return value; + } + + /** + * Whether this version of the SDK knows the value. + * + * @return whether it is known + */ + public boolean isKnown() { + return variant != Value._UNKNOWN; + } + + /** + * The value as an enum to switch on, unknown values included. + * + * @return the enum, {@code _UNKNOWN} when unknown + */ + public Value value() { + return variant; + } + + /** + * The value as an enum of the known values only. + * + * @return the enum + * @throws com.meteroid.exceptions.InvalidDataException when this version of the SDK does not + * know the value + */ + public Known known() { + if (!isKnown()) { + throw new com.meteroid.exceptions.InvalidDataException( + "unknown ListSubscriptionUsageCostsGranularity: " + value); + } + return Known.valueOf(variant.name()); + } + + @Override + public String toQueryParam() { + return String.valueOf(value); + } + + @Override + public boolean equals(Object o) { + return o instanceof ListSubscriptionUsageCostsGranularity + && Objects.equals(value, ((ListSubscriptionUsageCostsGranularity) o).value); + } + + @Override + public int hashCode() { + return Objects.hashCode(value); + } + + @Override + public String toString() { + return String.valueOf(value); + } + + /** The values this version of the SDK knows. */ + public enum Known { + /** The {@code HOUR} constant. */ + HOUR, + /** The {@code DAY} constant. */ + DAY, + /** The {@code MONTH} constant. */ + MONTH + } + + /** The values this version of the SDK knows, and {@code _UNKNOWN} for the others. */ + public enum Value { + /** The {@code HOUR} constant. */ + HOUR, + /** The {@code DAY} constant. */ + DAY, + /** The {@code MONTH} constant. */ + MONTH, + /** A value this version of the SDK does not know. */ + _UNKNOWN + } +} diff --git a/src/main/java/com/meteroid/models/MatrixPlanPricing.java b/src/main/java/com/meteroid/models/MatrixPlanPricing.java index 766ea41..a7281ac 100644 --- a/src/main/java/com/meteroid/models/MatrixPlanPricing.java +++ b/src/main/java/com/meteroid/models/MatrixPlanPricing.java @@ -29,12 +29,16 @@ public final class MatrixPlanPricing { @JsonProperty("rates") private List rates; + @JsonProperty("type") + private String type = "MATRIX"; + private final Map additionalProperties = new LinkedHashMap<>(); private MatrixPlanPricing() {} private MatrixPlanPricing(Builder builder) { this.rates = Utils.copyList(builder.rates); + this.type = builder.type; this.additionalProperties.putAll(builder.additionalProperties); } @@ -55,6 +59,7 @@ public static Builder builder() { public Builder toBuilder() { Builder builder = new Builder(); builder.rates = Utils.mutableList(rates); + builder.type = type; builder.additionalProperties.putAll(additionalProperties); return builder; } @@ -68,6 +73,15 @@ public List rates() { return Utils.required(rates, "rates"); } + /** + * The {@code type} property. + * + * @return the value, never null + */ + public String type() { + return Utils.required(type, "type"); + } + /** * Properties this version of the SDK does not know, kept as received and sent back. * @@ -97,12 +111,13 @@ public boolean equals(Object o) { } MatrixPlanPricing that = (MatrixPlanPricing) o; return Objects.equals(rates, that.rates) + && Objects.equals(type, that.type) && Objects.equals(additionalProperties, that.additionalProperties); } @Override public int hashCode() { - return Objects.hash(rates, additionalProperties); + return Objects.hash(rates, type, additionalProperties); } @Override @@ -110,6 +125,8 @@ public String toString() { return "MatrixPlanPricing{" + "rates=" + rates + + ", type=" + + type + ", additionalProperties=" + additionalProperties + "}"; @@ -118,6 +135,7 @@ public String toString() { /** Builds {@link MatrixPlanPricing}. */ public static final class Builder { private List rates; + private String type = "MATRIX"; private final Map additionalProperties = new LinkedHashMap<>(); private Builder() {} @@ -147,6 +165,17 @@ public Builder addRatesItem(MatrixRow item) { return this; } + /** + * The {@code type} property. + * + * @param type the value + * @return this builder + */ + public Builder type(String type) { + this.type = type; + return this; + } + /** * A property the SDK does not know, sent along. * @@ -189,6 +218,7 @@ public Builder removeAdditionalProperty(String name) { */ public MatrixPlanPricing build() { Utils.checkRequired(rates, "rates"); + Utils.checkRequired(type, "type"); return new MatrixPlanPricing(this); } } diff --git a/src/main/java/com/meteroid/models/MatrixPricing.java b/src/main/java/com/meteroid/models/MatrixPricing.java index b4e50c9..a7a3432 100644 --- a/src/main/java/com/meteroid/models/MatrixPricing.java +++ b/src/main/java/com/meteroid/models/MatrixPricing.java @@ -29,12 +29,16 @@ public final class MatrixPricing { @JsonProperty("rates") private List rates; + @JsonProperty("type") + private String type = "MATRIX"; + private final Map additionalProperties = new LinkedHashMap<>(); private MatrixPricing() {} private MatrixPricing(Builder builder) { this.rates = Utils.copyList(builder.rates); + this.type = builder.type; this.additionalProperties.putAll(builder.additionalProperties); } @@ -55,6 +59,7 @@ public static Builder builder() { public Builder toBuilder() { Builder builder = new Builder(); builder.rates = Utils.mutableList(rates); + builder.type = type; builder.additionalProperties.putAll(additionalProperties); return builder; } @@ -68,6 +73,15 @@ public List rates() { return Utils.required(rates, "rates"); } + /** + * The {@code type} property. + * + * @return the value, never null + */ + public String type() { + return Utils.required(type, "type"); + } + /** * Properties this version of the SDK does not know, kept as received and sent back. * @@ -97,12 +111,13 @@ public boolean equals(Object o) { } MatrixPricing that = (MatrixPricing) o; return Objects.equals(rates, that.rates) + && Objects.equals(type, that.type) && Objects.equals(additionalProperties, that.additionalProperties); } @Override public int hashCode() { - return Objects.hash(rates, additionalProperties); + return Objects.hash(rates, type, additionalProperties); } @Override @@ -110,6 +125,8 @@ public String toString() { return "MatrixPricing{" + "rates=" + rates + + ", type=" + + type + ", additionalProperties=" + additionalProperties + "}"; @@ -118,6 +135,7 @@ public String toString() { /** Builds {@link MatrixPricing}. */ public static final class Builder { private List rates; + private String type = "MATRIX"; private final Map additionalProperties = new LinkedHashMap<>(); private Builder() {} @@ -147,6 +165,17 @@ public Builder addRatesItem(MatrixRow item) { return this; } + /** + * The {@code type} property. + * + * @param type the value + * @return this builder + */ + public Builder type(String type) { + this.type = type; + return this; + } + /** * A property the SDK does not know, sent along. * @@ -189,6 +218,7 @@ public Builder removeAdditionalProperty(String name) { */ public MatrixPricing build() { Utils.checkRequired(rates, "rates"); + Utils.checkRequired(type, "type"); return new MatrixPricing(this); } } diff --git a/src/main/java/com/meteroid/models/MeteredEffectiveEntitlementValue.java b/src/main/java/com/meteroid/models/MeteredEffectiveEntitlementValue.java index b5b8de0..c268dc3 100644 --- a/src/main/java/com/meteroid/models/MeteredEffectiveEntitlementValue.java +++ b/src/main/java/com/meteroid/models/MeteredEffectiveEntitlementValue.java @@ -27,6 +27,9 @@ public final class MeteredEffectiveEntitlementValue { @JsonProperty("spec") private MeteredEntitlementSpec spec; + @JsonProperty("type") + private String type = "METERED"; + @JsonProperty("usage") private MeteredEntitlementUsage usage; @@ -36,6 +39,7 @@ private MeteredEffectiveEntitlementValue() {} private MeteredEffectiveEntitlementValue(Builder builder) { this.spec = builder.spec; + this.type = builder.type; this.usage = builder.usage; this.additionalProperties.putAll(builder.additionalProperties); } @@ -57,6 +61,7 @@ public static Builder builder() { public Builder toBuilder() { Builder builder = new Builder(); builder.spec = spec; + builder.type = type; builder.usage = usage; builder.additionalProperties.putAll(additionalProperties); return builder; @@ -71,6 +76,15 @@ public MeteredEntitlementSpec spec() { return Utils.required(spec, "spec"); } + /** + * The {@code type} property. + * + * @return the value, never null + */ + public String type() { + return Utils.required(type, "type"); + } + /** * The {@code usage} property. * @@ -109,13 +123,14 @@ public boolean equals(Object o) { } MeteredEffectiveEntitlementValue that = (MeteredEffectiveEntitlementValue) o; return Objects.equals(spec, that.spec) + && Objects.equals(type, that.type) && Objects.equals(usage, that.usage) && Objects.equals(additionalProperties, that.additionalProperties); } @Override public int hashCode() { - return Objects.hash(spec, usage, additionalProperties); + return Objects.hash(spec, type, usage, additionalProperties); } @Override @@ -123,6 +138,8 @@ public String toString() { return "MeteredEffectiveEntitlementValue{" + "spec=" + spec + + ", type=" + + type + ", usage=" + usage + ", additionalProperties=" @@ -133,6 +150,7 @@ public String toString() { /** Builds {@link MeteredEffectiveEntitlementValue}. */ public static final class Builder { private MeteredEntitlementSpec spec; + private String type = "METERED"; private MeteredEntitlementUsage usage; private final Map additionalProperties = new LinkedHashMap<>(); @@ -149,6 +167,17 @@ public Builder spec(MeteredEntitlementSpec spec) { return this; } + /** + * The {@code type} property. + * + * @param type the value + * @return this builder + */ + public Builder type(String type) { + this.type = type; + return this; + } + /** * The {@code usage} property. * @@ -202,6 +231,7 @@ public Builder removeAdditionalProperty(String name) { */ public MeteredEffectiveEntitlementValue build() { Utils.checkRequired(spec, "spec"); + Utils.checkRequired(type, "type"); Utils.checkRequired(usage, "usage"); return new MeteredEffectiveEntitlementValue(this); } diff --git a/src/main/java/com/meteroid/models/MeteredEntitlementSpec.java b/src/main/java/com/meteroid/models/MeteredEntitlementSpec.java index 4c29f69..0cc8240 100644 --- a/src/main/java/com/meteroid/models/MeteredEntitlementSpec.java +++ b/src/main/java/com/meteroid/models/MeteredEntitlementSpec.java @@ -13,8 +13,10 @@ import com.meteroid.internal.Utils; import java.math.BigDecimal; +import java.util.ArrayList; import java.util.Collections; import java.util.LinkedHashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -30,6 +32,14 @@ public final class MeteredEntitlementSpec { @JsonProperty("enabled") private Boolean enabled; + @JsonProperty("grace_pct") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField gracePct = JsonField.missing(); + + @JsonProperty("group_by") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField groupBy = JsonField.missing(); + @JsonProperty("limit") @JsonInclude(JsonInclude.Include.NON_EMPTY) private JsonField limit = JsonField.missing(); @@ -37,18 +47,35 @@ public final class MeteredEntitlementSpec { @JsonProperty("metric_id") private String metricId; + @JsonProperty("overage_behavior") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField overageBehavior = JsonField.missing(); + @JsonProperty("reset_period") private ResetPeriod resetPeriod; + @JsonProperty("thresholds") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField> thresholds = JsonField.missing(); + + @JsonProperty("warning_threshold_pct") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField warningThresholdPct = JsonField.missing(); + private final Map additionalProperties = new LinkedHashMap<>(); private MeteredEntitlementSpec() {} private MeteredEntitlementSpec(Builder builder) { this.enabled = builder.enabled; + this.gracePct = builder.gracePct; + this.groupBy = builder.groupBy; this.limit = builder.limit; this.metricId = builder.metricId; + this.overageBehavior = builder.overageBehavior; this.resetPeriod = builder.resetPeriod; + this.thresholds = builder.thresholds.map(Utils::copyList); + this.warningThresholdPct = builder.warningThresholdPct; this.additionalProperties.putAll(builder.additionalProperties); } @@ -69,15 +96,21 @@ public static Builder builder() { public Builder toBuilder() { Builder builder = new Builder(); builder.enabled = enabled; + builder.gracePct = gracePct; + builder.groupBy = groupBy; builder.limit = limit; builder.metricId = metricId; + builder.overageBehavior = overageBehavior; builder.resetPeriod = resetPeriod; + builder.thresholds = thresholds.map(Utils::mutableList); + builder.warningThresholdPct = warningThresholdPct; builder.additionalProperties.putAll(additionalProperties); return builder; } /** - * The {@code enabled} property. + * False when switched off, or once a BLOCK limit (plus its grace) is reached. An + * ALLOW limit never turns it off. * * @return the value, never null */ @@ -85,6 +118,25 @@ public Boolean enabled() { return Utils.required(enabled, "enabled"); } + /** + * BLOCK only: usage allowed beyond the limit before it is refused, in percent of + * it. + * + * @return the value, empty when unset or null + */ + public Optional gracePct() { + return gracePct.asOptional(); + } + + /** + * Event property the limit applies to separately; usage is then the largest value's. + * + * @return the value, empty when unset or null + */ + public Optional groupBy() { + return groupBy.asOptional(); + } + /** * The {@code limit} property. * @@ -103,6 +155,15 @@ public String metricId() { return Utils.required(metricId, "metric_id"); } + /** + * The {@code overage_behavior} property. + * + * @return the value, empty when unset or null + */ + public Optional overageBehavior() { + return overageBehavior.asOptional(); + } + /** * The {@code reset_period} property. * @@ -112,6 +173,24 @@ public ResetPeriod resetPeriod() { return Utils.required(resetPeriod, "reset_period"); } + /** + * Percents of the limit at which an alert is sent, ascending. + * + * @return the value, empty when unset or null + */ + public Optional> thresholds() { + return thresholds.asOptional(); + } + + /** + * Deprecated: the lowest of thresholds. + * + * @return the value, empty when unset or null + */ + public Optional warningThresholdPct() { + return warningThresholdPct.asOptional(); + } + /** * Properties this version of the SDK does not know, kept as received and sent back. * @@ -141,15 +220,30 @@ public boolean equals(Object o) { } MeteredEntitlementSpec that = (MeteredEntitlementSpec) o; return Objects.equals(enabled, that.enabled) + && Objects.equals(gracePct, that.gracePct) + && Objects.equals(groupBy, that.groupBy) && Objects.equals(limit, that.limit) && Objects.equals(metricId, that.metricId) + && Objects.equals(overageBehavior, that.overageBehavior) && Objects.equals(resetPeriod, that.resetPeriod) + && Objects.equals(thresholds, that.thresholds) + && Objects.equals(warningThresholdPct, that.warningThresholdPct) && Objects.equals(additionalProperties, that.additionalProperties); } @Override public int hashCode() { - return Objects.hash(enabled, limit, metricId, resetPeriod, additionalProperties); + return Objects.hash( + enabled, + gracePct, + groupBy, + limit, + metricId, + overageBehavior, + resetPeriod, + thresholds, + warningThresholdPct, + additionalProperties); } @Override @@ -157,12 +251,22 @@ public String toString() { return "MeteredEntitlementSpec{" + "enabled=" + enabled + + ", gracePct=" + + gracePct + + ", groupBy=" + + groupBy + ", limit=" + limit + ", metricId=" + metricId + + ", overageBehavior=" + + overageBehavior + ", resetPeriod=" + resetPeriod + + ", thresholds=" + + thresholds + + ", warningThresholdPct=" + + warningThresholdPct + ", additionalProperties=" + additionalProperties + "}"; @@ -171,15 +275,21 @@ public String toString() { /** Builds {@link MeteredEntitlementSpec}. */ public static final class Builder { private Boolean enabled; + private JsonField gracePct = JsonField.missing(); + private JsonField groupBy = JsonField.missing(); private JsonField limit = JsonField.missing(); private String metricId; + private JsonField overageBehavior = JsonField.missing(); private ResetPeriod resetPeriod; + private JsonField> thresholds = JsonField.missing(); + private JsonField warningThresholdPct = JsonField.missing(); private final Map additionalProperties = new LinkedHashMap<>(); private Builder() {} /** - * The {@code enabled} property. + * False when switched off, or once a BLOCK limit (plus its grace) is reached. + * An ALLOW limit never turns it off. * * @param enabled the value * @return this builder @@ -189,6 +299,29 @@ public Builder enabled(Boolean enabled) { return this; } + /** + * BLOCK only: usage allowed beyond the limit before it is refused, in percent + * of it. + * + * @param gracePct the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder gracePct(Integer gracePct) { + this.gracePct = JsonField.ofNullable(gracePct); + return this; + } + + /** + * Event property the limit applies to separately; usage is then the largest value's. + * + * @param groupBy the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder groupBy(String groupBy) { + this.groupBy = JsonField.ofNullable(groupBy); + return this; + } + /** * The {@code limit} property. * @@ -211,6 +344,17 @@ public Builder metricId(String metricId) { return this; } + /** + * The {@code overage_behavior} property. + * + * @param overageBehavior the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder overageBehavior(EntitlementOverageBehavior overageBehavior) { + this.overageBehavior = JsonField.ofNullable(overageBehavior); + return this; + } + /** * The {@code reset_period} property. * @@ -222,6 +366,44 @@ public Builder resetPeriod(ResetPeriod resetPeriod) { return this; } + /** + * Percents of the limit at which an alert is sent, ascending. + * + * @param thresholds the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder thresholds(List thresholds) { + this.thresholds = JsonField.ofNullable(Utils.mutableList(thresholds)); + return this; + } + + /** + * Adds an item to {@code thresholds}. + * + * @param item the item + * @return this builder + */ + public Builder addThresholdsItem(Integer item) { + List items = this.thresholds.orNull(); + if (items == null) { + items = new ArrayList<>(); + this.thresholds = JsonField.ofNullable(items); + } + items.add(item); + return this; + } + + /** + * Deprecated: the lowest of thresholds. + * + * @param warningThresholdPct the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder warningThresholdPct(Integer warningThresholdPct) { + this.warningThresholdPct = JsonField.ofNullable(warningThresholdPct); + return this; + } + /** * A property the SDK does not know, sent along. * diff --git a/src/main/java/com/meteroid/models/MeteredEntitlementUsage.java b/src/main/java/com/meteroid/models/MeteredEntitlementUsage.java index 5db9144..f7f4919 100644 --- a/src/main/java/com/meteroid/models/MeteredEntitlementUsage.java +++ b/src/main/java/com/meteroid/models/MeteredEntitlementUsage.java @@ -32,6 +32,10 @@ public final class MeteredEntitlementUsage { @JsonInclude(JsonInclude.Include.NON_EMPTY) private JsonField consumed = JsonField.missing(); + @JsonProperty("limit_reached") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField limitReached = JsonField.missing(); + @JsonProperty("remaining") @JsonInclude(JsonInclude.Include.NON_EMPTY) private JsonField remaining = JsonField.missing(); @@ -46,6 +50,7 @@ private MeteredEntitlementUsage() {} private MeteredEntitlementUsage(Builder builder) { this.consumed = builder.consumed; + this.limitReached = builder.limitReached; this.remaining = builder.remaining; this.resetAt = builder.resetAt; this.additionalProperties.putAll(builder.additionalProperties); @@ -68,6 +73,7 @@ public static Builder builder() { public Builder toBuilder() { Builder builder = new Builder(); builder.consumed = consumed; + builder.limitReached = limitReached; builder.remaining = remaining; builder.resetAt = resetAt; builder.additionalProperties.putAll(additionalProperties); @@ -83,6 +89,16 @@ public Optional consumed() { return consumed.asOptional(); } + /** + * Switched on, but refused: the BLOCK limit (plus its grace) is reached, so + * enabled is false until the window resets. Never set for a limit grouped by a property. + * + * @return the value, empty when unset or null + */ + public Optional limitReached() { + return limitReached.asOptional(); + } + /** * The {@code remaining} property. * @@ -130,6 +146,7 @@ public boolean equals(Object o) { } MeteredEntitlementUsage that = (MeteredEntitlementUsage) o; return Objects.equals(consumed, that.consumed) + && Objects.equals(limitReached, that.limitReached) && Objects.equals(remaining, that.remaining) && Objects.equals(resetAt, that.resetAt) && Objects.equals(additionalProperties, that.additionalProperties); @@ -137,7 +154,7 @@ public boolean equals(Object o) { @Override public int hashCode() { - return Objects.hash(consumed, remaining, resetAt, additionalProperties); + return Objects.hash(consumed, limitReached, remaining, resetAt, additionalProperties); } @Override @@ -145,6 +162,8 @@ public String toString() { return "MeteredEntitlementUsage{" + "consumed=" + consumed + + ", limitReached=" + + limitReached + ", remaining=" + remaining + ", resetAt=" @@ -157,6 +176,7 @@ public String toString() { /** Builds {@link MeteredEntitlementUsage}. */ public static final class Builder { private JsonField consumed = JsonField.missing(); + private JsonField limitReached = JsonField.missing(); private JsonField remaining = JsonField.missing(); private JsonField resetAt = JsonField.missing(); private final Map additionalProperties = new LinkedHashMap<>(); @@ -174,6 +194,19 @@ public Builder consumed(BigDecimal consumed) { return this; } + /** + * Switched on, but refused: the BLOCK limit (plus its grace) is reached, so + * enabled is false until the window resets. Never set for a limit grouped by a + * property. + * + * @param limitReached the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder limitReached(Boolean limitReached) { + this.limitReached = JsonField.ofNullable(limitReached); + return this; + } + /** * The {@code remaining} property. * diff --git a/src/main/java/com/meteroid/models/MeteredEntitlementValue.java b/src/main/java/com/meteroid/models/MeteredEntitlementValue.java index b097252..d3392c6 100644 --- a/src/main/java/com/meteroid/models/MeteredEntitlementValue.java +++ b/src/main/java/com/meteroid/models/MeteredEntitlementValue.java @@ -13,8 +13,10 @@ import com.meteroid.internal.Utils; import java.math.BigDecimal; +import java.util.ArrayList; import java.util.Collections; import java.util.LinkedHashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -30,21 +32,50 @@ public final class MeteredEntitlementValue { @JsonProperty("enabled") private Boolean enabled; + @JsonProperty("grace_pct") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField gracePct = JsonField.missing(); + + @JsonProperty("group_by") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField groupBy = JsonField.missing(); + @JsonProperty("limit") @JsonInclude(JsonInclude.Include.NON_EMPTY) private JsonField limit = JsonField.missing(); + @JsonProperty("overage_behavior") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField overageBehavior = JsonField.missing(); + @JsonProperty("reset_period") private ResetPeriod resetPeriod; + @JsonProperty("thresholds") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField> thresholds = JsonField.missing(); + + @JsonProperty("type") + private String type = "METERED"; + + @JsonProperty("warning_threshold_pct") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField warningThresholdPct = JsonField.missing(); + private final Map additionalProperties = new LinkedHashMap<>(); private MeteredEntitlementValue() {} private MeteredEntitlementValue(Builder builder) { this.enabled = builder.enabled; + this.gracePct = builder.gracePct; + this.groupBy = builder.groupBy; this.limit = builder.limit; + this.overageBehavior = builder.overageBehavior; this.resetPeriod = builder.resetPeriod; + this.thresholds = builder.thresholds.map(Utils::copyList); + this.type = builder.type; + this.warningThresholdPct = builder.warningThresholdPct; this.additionalProperties.putAll(builder.additionalProperties); } @@ -65,8 +96,14 @@ public static Builder builder() { public Builder toBuilder() { Builder builder = new Builder(); builder.enabled = enabled; + builder.gracePct = gracePct; + builder.groupBy = groupBy; builder.limit = limit; + builder.overageBehavior = overageBehavior; builder.resetPeriod = resetPeriod; + builder.thresholds = thresholds.map(Utils::mutableList); + builder.type = type; + builder.warningThresholdPct = warningThresholdPct; builder.additionalProperties.putAll(additionalProperties); return builder; } @@ -80,6 +117,26 @@ public Optional enabled() { return Optional.ofNullable(enabled); } + /** + * BLOCK only: usage allowed beyond the limit before it is refused, in percent of + * the limit (1 to 1000). + * + * @return the value, empty when unset or null + */ + public Optional gracePct() { + return gracePct.asOptional(); + } + + /** + * Event property the limit applies to separately, one limit per value (e.g. user_id + * ). + * + * @return the value, empty when unset or null + */ + public Optional groupBy() { + return groupBy.asOptional(); + } + /** * Cap on usage. Null means unlimited. * @@ -89,6 +146,15 @@ public Optional limit() { return limit.asOptional(); } + /** + * The {@code overage_behavior} property. + * + * @return the value, empty when unset or null + */ + public Optional overageBehavior() { + return overageBehavior.asOptional(); + } + /** * The {@code reset_period} property. * @@ -98,6 +164,36 @@ public Optional resetPeriod() { return Optional.ofNullable(resetPeriod); } + /** + * Percents of the limit (1 to 100, at most 10) at which an alert is sent, once per period: + * entitlement.usage_threshold_reached, or entitlement.limit_reached + * at 100. Requires a limit and a window that is not sliding. + * + * @return the value, empty when unset or null + */ + public Optional> thresholds() { + return thresholds.asOptional(); + } + + /** + * The {@code type} property. + * + * @return the value, never null + */ + public String type() { + return Utils.required(type, "type"); + } + + /** + * Deprecated: use thresholds. A single alert threshold, read only when + * thresholds is omitted; returned as the lowest of thresholds. + * + * @return the value, empty when unset or null + */ + public Optional warningThresholdPct() { + return warningThresholdPct.asOptional(); + } + /** * Properties this version of the SDK does not know, kept as received and sent back. * @@ -127,14 +223,30 @@ public boolean equals(Object o) { } MeteredEntitlementValue that = (MeteredEntitlementValue) o; return Objects.equals(enabled, that.enabled) + && Objects.equals(gracePct, that.gracePct) + && Objects.equals(groupBy, that.groupBy) && Objects.equals(limit, that.limit) + && Objects.equals(overageBehavior, that.overageBehavior) && Objects.equals(resetPeriod, that.resetPeriod) + && Objects.equals(thresholds, that.thresholds) + && Objects.equals(type, that.type) + && Objects.equals(warningThresholdPct, that.warningThresholdPct) && Objects.equals(additionalProperties, that.additionalProperties); } @Override public int hashCode() { - return Objects.hash(enabled, limit, resetPeriod, additionalProperties); + return Objects.hash( + enabled, + gracePct, + groupBy, + limit, + overageBehavior, + resetPeriod, + thresholds, + type, + warningThresholdPct, + additionalProperties); } @Override @@ -142,10 +254,22 @@ public String toString() { return "MeteredEntitlementValue{" + "enabled=" + enabled + + ", gracePct=" + + gracePct + + ", groupBy=" + + groupBy + ", limit=" + limit + + ", overageBehavior=" + + overageBehavior + ", resetPeriod=" + resetPeriod + + ", thresholds=" + + thresholds + + ", type=" + + type + + ", warningThresholdPct=" + + warningThresholdPct + ", additionalProperties=" + additionalProperties + "}"; @@ -154,8 +278,14 @@ public String toString() { /** Builds {@link MeteredEntitlementValue}. */ public static final class Builder { private Boolean enabled; + private JsonField gracePct = JsonField.missing(); + private JsonField groupBy = JsonField.missing(); private JsonField limit = JsonField.missing(); + private JsonField overageBehavior = JsonField.missing(); private ResetPeriod resetPeriod; + private JsonField> thresholds = JsonField.missing(); + private String type = "METERED"; + private JsonField warningThresholdPct = JsonField.missing(); private final Map additionalProperties = new LinkedHashMap<>(); private Builder() {} @@ -171,6 +301,30 @@ public Builder enabled(Boolean enabled) { return this; } + /** + * BLOCK only: usage allowed beyond the limit before it is refused, in percent + * of the limit (1 to 1000). + * + * @param gracePct the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder gracePct(Integer gracePct) { + this.gracePct = JsonField.ofNullable(gracePct); + return this; + } + + /** + * Event property the limit applies to separately, one limit per value (e.g. user_id + * ). + * + * @param groupBy the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder groupBy(String groupBy) { + this.groupBy = JsonField.ofNullable(groupBy); + return this; + } + /** * Cap on usage. Null means unlimited. * @@ -182,6 +336,17 @@ public Builder limit(BigDecimal limit) { return this; } + /** + * The {@code overage_behavior} property. + * + * @param overageBehavior the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder overageBehavior(EntitlementOverageBehavior overageBehavior) { + this.overageBehavior = JsonField.ofNullable(overageBehavior); + return this; + } + /** * The {@code reset_period} property. * @@ -193,6 +358,58 @@ public Builder resetPeriod(ResetPeriod resetPeriod) { return this; } + /** + * Percents of the limit (1 to 100, at most 10) at which an alert is sent, once per period: + * entitlement.usage_threshold_reached, or entitlement.limit_reached + * at 100. Requires a limit and a window that is not sliding. + * + * @param thresholds the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder thresholds(List thresholds) { + this.thresholds = JsonField.ofNullable(Utils.mutableList(thresholds)); + return this; + } + + /** + * Adds an item to {@code thresholds}. + * + * @param item the item + * @return this builder + */ + public Builder addThresholdsItem(Integer item) { + List items = this.thresholds.orNull(); + if (items == null) { + items = new ArrayList<>(); + this.thresholds = JsonField.ofNullable(items); + } + items.add(item); + return this; + } + + /** + * The {@code type} property. + * + * @param type the value + * @return this builder + */ + public Builder type(String type) { + this.type = type; + return this; + } + + /** + * Deprecated: use thresholds. A single alert threshold, read only when + * thresholds is omitted; returned as the lowest of thresholds. + * + * @param warningThresholdPct the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder warningThresholdPct(Integer warningThresholdPct) { + this.warningThresholdPct = JsonField.ofNullable(warningThresholdPct); + return this; + } + /** * A property the SDK does not know, sent along. * @@ -234,6 +451,7 @@ public Builder removeAdditionalProperty(String name) { * @throws IllegalStateException when a required property is not set */ public MeteredEntitlementValue build() { + Utils.checkRequired(type, "type"); return new MeteredEntitlementValue(this); } } diff --git a/src/main/java/com/meteroid/models/MeteredFeatureType.java b/src/main/java/com/meteroid/models/MeteredFeatureType.java index dd00087..c603769 100644 --- a/src/main/java/com/meteroid/models/MeteredFeatureType.java +++ b/src/main/java/com/meteroid/models/MeteredFeatureType.java @@ -27,12 +27,16 @@ public final class MeteredFeatureType { @JsonProperty("metric_id") private String metricId; + @JsonProperty("type") + private String type = "METERED"; + private final Map additionalProperties = new LinkedHashMap<>(); private MeteredFeatureType() {} private MeteredFeatureType(Builder builder) { this.metricId = builder.metricId; + this.type = builder.type; this.additionalProperties.putAll(builder.additionalProperties); } @@ -53,6 +57,7 @@ public static Builder builder() { public Builder toBuilder() { Builder builder = new Builder(); builder.metricId = metricId; + builder.type = type; builder.additionalProperties.putAll(additionalProperties); return builder; } @@ -66,6 +71,15 @@ public String metricId() { return Utils.required(metricId, "metric_id"); } + /** + * The {@code type} property. + * + * @return the value, never null + */ + public String type() { + return Utils.required(type, "type"); + } + /** * Properties this version of the SDK does not know, kept as received and sent back. * @@ -95,12 +109,13 @@ public boolean equals(Object o) { } MeteredFeatureType that = (MeteredFeatureType) o; return Objects.equals(metricId, that.metricId) + && Objects.equals(type, that.type) && Objects.equals(additionalProperties, that.additionalProperties); } @Override public int hashCode() { - return Objects.hash(metricId, additionalProperties); + return Objects.hash(metricId, type, additionalProperties); } @Override @@ -108,6 +123,8 @@ public String toString() { return "MeteredFeatureType{" + "metricId=" + metricId + + ", type=" + + type + ", additionalProperties=" + additionalProperties + "}"; @@ -116,6 +133,7 @@ public String toString() { /** Builds {@link MeteredFeatureType}. */ public static final class Builder { private String metricId; + private String type = "METERED"; private final Map additionalProperties = new LinkedHashMap<>(); private Builder() {} @@ -131,6 +149,17 @@ public Builder metricId(String metricId) { return this; } + /** + * The {@code type} property. + * + * @param type the value + * @return this builder + */ + public Builder type(String type) { + this.type = type; + return this; + } + /** * A property the SDK does not know, sent along. * @@ -173,6 +202,7 @@ public Builder removeAdditionalProperty(String name) { */ public MeteredFeatureType build() { Utils.checkRequired(metricId, "metric_id"); + Utils.checkRequired(type, "type"); return new MeteredFeatureType(this); } } diff --git a/src/main/java/com/meteroid/models/MeteredResolvedEntitlementValue.java b/src/main/java/com/meteroid/models/MeteredResolvedEntitlementValue.java index 6e22014..0445996 100644 --- a/src/main/java/com/meteroid/models/MeteredResolvedEntitlementValue.java +++ b/src/main/java/com/meteroid/models/MeteredResolvedEntitlementValue.java @@ -13,8 +13,10 @@ import com.meteroid.internal.Utils; import java.math.BigDecimal; +import java.util.ArrayList; import java.util.Collections; import java.util.LinkedHashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -30,6 +32,14 @@ public final class MeteredResolvedEntitlementValue { @JsonProperty("enabled") private Boolean enabled; + @JsonProperty("grace_pct") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField gracePct = JsonField.missing(); + + @JsonProperty("group_by") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField groupBy = JsonField.missing(); + @JsonProperty("limit") @JsonInclude(JsonInclude.Include.NON_EMPTY) private JsonField limit = JsonField.missing(); @@ -37,18 +47,39 @@ public final class MeteredResolvedEntitlementValue { @JsonProperty("metric_id") private String metricId; + @JsonProperty("overage_behavior") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField overageBehavior = JsonField.missing(); + @JsonProperty("reset_period") private ResetPeriod resetPeriod; + @JsonProperty("thresholds") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField> thresholds = JsonField.missing(); + + @JsonProperty("type") + private String type = "METERED"; + + @JsonProperty("warning_threshold_pct") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField warningThresholdPct = JsonField.missing(); + private final Map additionalProperties = new LinkedHashMap<>(); private MeteredResolvedEntitlementValue() {} private MeteredResolvedEntitlementValue(Builder builder) { this.enabled = builder.enabled; + this.gracePct = builder.gracePct; + this.groupBy = builder.groupBy; this.limit = builder.limit; this.metricId = builder.metricId; + this.overageBehavior = builder.overageBehavior; this.resetPeriod = builder.resetPeriod; + this.thresholds = builder.thresholds.map(Utils::copyList); + this.type = builder.type; + this.warningThresholdPct = builder.warningThresholdPct; this.additionalProperties.putAll(builder.additionalProperties); } @@ -69,9 +100,15 @@ public static Builder builder() { public Builder toBuilder() { Builder builder = new Builder(); builder.enabled = enabled; + builder.gracePct = gracePct; + builder.groupBy = groupBy; builder.limit = limit; builder.metricId = metricId; + builder.overageBehavior = overageBehavior; builder.resetPeriod = resetPeriod; + builder.thresholds = thresholds.map(Utils::mutableList); + builder.type = type; + builder.warningThresholdPct = warningThresholdPct; builder.additionalProperties.putAll(additionalProperties); return builder; } @@ -85,6 +122,25 @@ public Boolean enabled() { return Utils.required(enabled, "enabled"); } + /** + * BLOCK only: usage allowed beyond the limit before it is refused, in percent of + * it. + * + * @return the value, empty when unset or null + */ + public Optional gracePct() { + return gracePct.asOptional(); + } + + /** + * Event property the limit applies to separately; usage is then the largest value's. + * + * @return the value, empty when unset or null + */ + public Optional groupBy() { + return groupBy.asOptional(); + } + /** * The {@code limit} property. * @@ -103,6 +159,15 @@ public String metricId() { return Utils.required(metricId, "metric_id"); } + /** + * The {@code overage_behavior} property. + * + * @return the value, empty when unset or null + */ + public Optional overageBehavior() { + return overageBehavior.asOptional(); + } + /** * The {@code reset_period} property. * @@ -112,6 +177,33 @@ public ResetPeriod resetPeriod() { return Utils.required(resetPeriod, "reset_period"); } + /** + * Percents of the limit at which an alert is sent, ascending. + * + * @return the value, empty when unset or null + */ + public Optional> thresholds() { + return thresholds.asOptional(); + } + + /** + * The {@code type} property. + * + * @return the value, never null + */ + public String type() { + return Utils.required(type, "type"); + } + + /** + * Deprecated: the lowest of thresholds. + * + * @return the value, empty when unset or null + */ + public Optional warningThresholdPct() { + return warningThresholdPct.asOptional(); + } + /** * Properties this version of the SDK does not know, kept as received and sent back. * @@ -141,15 +233,32 @@ public boolean equals(Object o) { } MeteredResolvedEntitlementValue that = (MeteredResolvedEntitlementValue) o; return Objects.equals(enabled, that.enabled) + && Objects.equals(gracePct, that.gracePct) + && Objects.equals(groupBy, that.groupBy) && Objects.equals(limit, that.limit) && Objects.equals(metricId, that.metricId) + && Objects.equals(overageBehavior, that.overageBehavior) && Objects.equals(resetPeriod, that.resetPeriod) + && Objects.equals(thresholds, that.thresholds) + && Objects.equals(type, that.type) + && Objects.equals(warningThresholdPct, that.warningThresholdPct) && Objects.equals(additionalProperties, that.additionalProperties); } @Override public int hashCode() { - return Objects.hash(enabled, limit, metricId, resetPeriod, additionalProperties); + return Objects.hash( + enabled, + gracePct, + groupBy, + limit, + metricId, + overageBehavior, + resetPeriod, + thresholds, + type, + warningThresholdPct, + additionalProperties); } @Override @@ -157,12 +266,24 @@ public String toString() { return "MeteredResolvedEntitlementValue{" + "enabled=" + enabled + + ", gracePct=" + + gracePct + + ", groupBy=" + + groupBy + ", limit=" + limit + ", metricId=" + metricId + + ", overageBehavior=" + + overageBehavior + ", resetPeriod=" + resetPeriod + + ", thresholds=" + + thresholds + + ", type=" + + type + + ", warningThresholdPct=" + + warningThresholdPct + ", additionalProperties=" + additionalProperties + "}"; @@ -171,9 +292,15 @@ public String toString() { /** Builds {@link MeteredResolvedEntitlementValue}. */ public static final class Builder { private Boolean enabled; + private JsonField gracePct = JsonField.missing(); + private JsonField groupBy = JsonField.missing(); private JsonField limit = JsonField.missing(); private String metricId; + private JsonField overageBehavior = JsonField.missing(); private ResetPeriod resetPeriod; + private JsonField> thresholds = JsonField.missing(); + private String type = "METERED"; + private JsonField warningThresholdPct = JsonField.missing(); private final Map additionalProperties = new LinkedHashMap<>(); private Builder() {} @@ -189,6 +316,29 @@ public Builder enabled(Boolean enabled) { return this; } + /** + * BLOCK only: usage allowed beyond the limit before it is refused, in percent + * of it. + * + * @param gracePct the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder gracePct(Integer gracePct) { + this.gracePct = JsonField.ofNullable(gracePct); + return this; + } + + /** + * Event property the limit applies to separately; usage is then the largest value's. + * + * @param groupBy the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder groupBy(String groupBy) { + this.groupBy = JsonField.ofNullable(groupBy); + return this; + } + /** * The {@code limit} property. * @@ -211,6 +361,17 @@ public Builder metricId(String metricId) { return this; } + /** + * The {@code overage_behavior} property. + * + * @param overageBehavior the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder overageBehavior(EntitlementOverageBehavior overageBehavior) { + this.overageBehavior = JsonField.ofNullable(overageBehavior); + return this; + } + /** * The {@code reset_period} property. * @@ -222,6 +383,55 @@ public Builder resetPeriod(ResetPeriod resetPeriod) { return this; } + /** + * Percents of the limit at which an alert is sent, ascending. + * + * @param thresholds the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder thresholds(List thresholds) { + this.thresholds = JsonField.ofNullable(Utils.mutableList(thresholds)); + return this; + } + + /** + * Adds an item to {@code thresholds}. + * + * @param item the item + * @return this builder + */ + public Builder addThresholdsItem(Integer item) { + List items = this.thresholds.orNull(); + if (items == null) { + items = new ArrayList<>(); + this.thresholds = JsonField.ofNullable(items); + } + items.add(item); + return this; + } + + /** + * The {@code type} property. + * + * @param type the value + * @return this builder + */ + public Builder type(String type) { + this.type = type; + return this; + } + + /** + * Deprecated: the lowest of thresholds. + * + * @param warningThresholdPct the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder warningThresholdPct(Integer warningThresholdPct) { + this.warningThresholdPct = JsonField.ofNullable(warningThresholdPct); + return this; + } + /** * A property the SDK does not know, sent along. * @@ -266,6 +476,7 @@ public MeteredResolvedEntitlementValue build() { Utils.checkRequired(enabled, "enabled"); Utils.checkRequired(metricId, "metric_id"); Utils.checkRequired(resetPeriod, "reset_period"); + Utils.checkRequired(type, "type"); return new MeteredResolvedEntitlementValue(this); } } diff --git a/src/main/java/com/meteroid/models/Metric.java b/src/main/java/com/meteroid/models/Metric.java index d54fcb6..37649a4 100644 --- a/src/main/java/com/meteroid/models/Metric.java +++ b/src/main/java/com/meteroid/models/Metric.java @@ -74,6 +74,14 @@ public final class Metric { @JsonInclude(JsonInclude.Include.NON_EMPTY) private JsonField unitConversion = JsonField.missing(); + @JsonProperty("unit_plural") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField unitPlural = JsonField.missing(); + + @JsonProperty("unit_singular") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField unitSingular = JsonField.missing(); + @JsonProperty("usage_group_key") @JsonInclude(JsonInclude.Include.NON_EMPTY) private JsonField usageGroupKey = JsonField.missing(); @@ -96,6 +104,8 @@ private Metric(Builder builder) { this.productId = builder.productId; this.segmentationMatrix = builder.segmentationMatrix; this.unitConversion = builder.unitConversion; + this.unitPlural = builder.unitPlural; + this.unitSingular = builder.unitSingular; this.usageGroupKey = builder.usageGroupKey; this.additionalProperties.putAll(builder.additionalProperties); } @@ -129,6 +139,8 @@ public Builder toBuilder() { builder.productId = productId; builder.segmentationMatrix = segmentationMatrix; builder.unitConversion = unitConversion; + builder.unitPlural = unitPlural; + builder.unitSingular = unitSingular; builder.usageGroupKey = usageGroupKey; builder.additionalProperties.putAll(additionalProperties); return builder; @@ -251,6 +263,25 @@ public Optional unitConversion() { return unitConversion.asOptional(); } + /** + * What several units of the metric are called, e.g. tokens. + * + * @return the value, empty when unset or null + */ + public Optional unitPlural() { + return unitPlural.asOptional(); + } + + /** + * What one unit of the metric is called, e.g. token. Set together with + * unit_plural. + * + * @return the value, empty when unset or null + */ + public Optional unitSingular() { + return unitSingular.asOptional(); + } + /** * The {@code usage_group_key} property. * @@ -301,6 +332,8 @@ public boolean equals(Object o) { && Objects.equals(productId, that.productId) && Objects.equals(segmentationMatrix, that.segmentationMatrix) && Objects.equals(unitConversion, that.unitConversion) + && Objects.equals(unitPlural, that.unitPlural) + && Objects.equals(unitSingular, that.unitSingular) && Objects.equals(usageGroupKey, that.usageGroupKey) && Objects.equals(additionalProperties, that.additionalProperties); } @@ -321,6 +354,8 @@ public int hashCode() { productId, segmentationMatrix, unitConversion, + unitPlural, + unitSingular, usageGroupKey, additionalProperties); } @@ -354,6 +389,10 @@ public String toString() { + segmentationMatrix + ", unitConversion=" + unitConversion + + ", unitPlural=" + + unitPlural + + ", unitSingular=" + + unitSingular + ", usageGroupKey=" + usageGroupKey + ", additionalProperties=" @@ -376,6 +415,8 @@ public static final class Builder { private JsonField productId = JsonField.missing(); private JsonField segmentationMatrix = JsonField.missing(); private JsonField unitConversion = JsonField.missing(); + private JsonField unitPlural = JsonField.missing(); + private JsonField unitSingular = JsonField.missing(); private JsonField usageGroupKey = JsonField.missing(); private final Map additionalProperties = new LinkedHashMap<>(); @@ -538,6 +579,29 @@ public Builder unitConversion(UnitConversion unitConversion) { return this; } + /** + * What several units of the metric are called, e.g. tokens. + * + * @param unitPlural the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder unitPlural(String unitPlural) { + this.unitPlural = JsonField.ofNullable(unitPlural); + return this; + } + + /** + * What one unit of the metric is called, e.g. token. Set together with + * unit_plural. + * + * @param unitSingular the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder unitSingular(String unitSingular) { + this.unitSingular = JsonField.ofNullable(unitSingular); + return this; + } + /** * The {@code usage_group_key} property. * diff --git a/src/main/java/com/meteroid/models/MetricEventData.java b/src/main/java/com/meteroid/models/MetricEventData.java index 2ff84a1..4ee614c 100644 --- a/src/main/java/com/meteroid/models/MetricEventData.java +++ b/src/main/java/com/meteroid/models/MetricEventData.java @@ -69,6 +69,14 @@ public final class MetricEventData { @JsonInclude(JsonInclude.Include.NON_EMPTY) private JsonField unitConversionRounding = JsonField.missing(); + @JsonProperty("unit_plural") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField unitPlural = JsonField.missing(); + + @JsonProperty("unit_singular") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField unitSingular = JsonField.missing(); + @JsonProperty("usage_group_key") @JsonInclude(JsonInclude.Include.NON_EMPTY) private JsonField usageGroupKey = JsonField.missing(); @@ -90,6 +98,8 @@ private MetricEventData(Builder builder) { this.segmentationMatrix = builder.segmentationMatrix; this.unitConversionFactor = builder.unitConversionFactor; this.unitConversionRounding = builder.unitConversionRounding; + this.unitPlural = builder.unitPlural; + this.unitSingular = builder.unitSingular; this.usageGroupKey = builder.usageGroupKey; this.additionalProperties.putAll(builder.additionalProperties); } @@ -122,6 +132,8 @@ public Builder toBuilder() { builder.segmentationMatrix = segmentationMatrix; builder.unitConversionFactor = unitConversionFactor; builder.unitConversionRounding = unitConversionRounding; + builder.unitPlural = unitPlural; + builder.unitSingular = unitSingular; builder.usageGroupKey = usageGroupKey; builder.additionalProperties.putAll(additionalProperties); return builder; @@ -235,6 +247,24 @@ public Optional unitConversionRounding() { return unitConversionRounding.asOptional(); } + /** + * What several units of the metric are called, e.g. tokens. + * + * @return the value, empty when unset or null + */ + public Optional unitPlural() { + return unitPlural.asOptional(); + } + + /** + * What one unit of the metric is called, e.g. token. + * + * @return the value, empty when unset or null + */ + public Optional unitSingular() { + return unitSingular.asOptional(); + } + /** * The {@code usage_group_key} property. * @@ -284,6 +314,8 @@ public boolean equals(Object o) { && Objects.equals(segmentationMatrix, that.segmentationMatrix) && Objects.equals(unitConversionFactor, that.unitConversionFactor) && Objects.equals(unitConversionRounding, that.unitConversionRounding) + && Objects.equals(unitPlural, that.unitPlural) + && Objects.equals(unitSingular, that.unitSingular) && Objects.equals(usageGroupKey, that.usageGroupKey) && Objects.equals(additionalProperties, that.additionalProperties); } @@ -303,6 +335,8 @@ public int hashCode() { segmentationMatrix, unitConversionFactor, unitConversionRounding, + unitPlural, + unitSingular, usageGroupKey, additionalProperties); } @@ -334,6 +368,10 @@ public String toString() { + unitConversionFactor + ", unitConversionRounding=" + unitConversionRounding + + ", unitPlural=" + + unitPlural + + ", unitSingular=" + + unitSingular + ", usageGroupKey=" + usageGroupKey + ", additionalProperties=" @@ -355,6 +393,8 @@ public static final class Builder { private JsonField segmentationMatrix = JsonField.missing(); private JsonField unitConversionFactor = JsonField.missing(); private JsonField unitConversionRounding = JsonField.missing(); + private JsonField unitPlural = JsonField.missing(); + private JsonField unitSingular = JsonField.missing(); private JsonField usageGroupKey = JsonField.missing(); private final Map additionalProperties = new LinkedHashMap<>(); @@ -492,6 +532,28 @@ public Builder unitConversionRounding(UnitConversionRoundingEnum unitConversionR return this; } + /** + * What several units of the metric are called, e.g. tokens. + * + * @param unitPlural the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder unitPlural(String unitPlural) { + this.unitPlural = JsonField.ofNullable(unitPlural); + return this; + } + + /** + * What one unit of the metric is called, e.g. token. + * + * @param unitSingular the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder unitSingular(String unitSingular) { + this.unitSingular = JsonField.ofNullable(unitSingular); + return this; + } + /** * The {@code usage_group_key} property. * diff --git a/src/main/java/com/meteroid/models/MetricSummary.java b/src/main/java/com/meteroid/models/MetricSummary.java index a34a90b..a990d67 100644 --- a/src/main/java/com/meteroid/models/MetricSummary.java +++ b/src/main/java/com/meteroid/models/MetricSummary.java @@ -54,6 +54,14 @@ public final class MetricSummary { @JsonProperty("name") private String name; + @JsonProperty("unit_plural") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField unitPlural = JsonField.missing(); + + @JsonProperty("unit_singular") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField unitSingular = JsonField.missing(); + private final Map additionalProperties = new LinkedHashMap<>(); private MetricSummary() {} @@ -67,6 +75,8 @@ private MetricSummary(Builder builder) { this.description = builder.description; this.id = builder.id; this.name = builder.name; + this.unitPlural = builder.unitPlural; + this.unitSingular = builder.unitSingular; this.additionalProperties.putAll(builder.additionalProperties); } @@ -94,6 +104,8 @@ public Builder toBuilder() { builder.description = description; builder.id = id; builder.name = name; + builder.unitPlural = unitPlural; + builder.unitSingular = unitSingular; builder.additionalProperties.putAll(additionalProperties); return builder; } @@ -170,6 +182,24 @@ public String name() { return Utils.required(name, "name"); } + /** + * What several units of the metric are called, e.g. tokens. + * + * @return the value, empty when unset or null + */ + public Optional unitPlural() { + return unitPlural.asOptional(); + } + + /** + * What one unit of the metric is called, e.g. token. + * + * @return the value, empty when unset or null + */ + public Optional unitSingular() { + return unitSingular.asOptional(); + } + /** * Properties this version of the SDK does not know, kept as received and sent back. * @@ -206,6 +236,8 @@ public boolean equals(Object o) { && Objects.equals(description, that.description) && Objects.equals(id, that.id) && Objects.equals(name, that.name) + && Objects.equals(unitPlural, that.unitPlural) + && Objects.equals(unitSingular, that.unitSingular) && Objects.equals(additionalProperties, that.additionalProperties); } @@ -220,6 +252,8 @@ public int hashCode() { description, id, name, + unitPlural, + unitSingular, additionalProperties); } @@ -242,6 +276,10 @@ public String toString() { + id + ", name=" + name + + ", unitPlural=" + + unitPlural + + ", unitSingular=" + + unitSingular + ", additionalProperties=" + additionalProperties + "}"; @@ -257,6 +295,8 @@ public static final class Builder { private JsonField description = JsonField.missing(); private String id; private String name; + private JsonField unitPlural = JsonField.missing(); + private JsonField unitSingular = JsonField.missing(); private final Map additionalProperties = new LinkedHashMap<>(); private Builder() {} @@ -349,6 +389,28 @@ public Builder name(String name) { return this; } + /** + * What several units of the metric are called, e.g. tokens. + * + * @param unitPlural the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder unitPlural(String unitPlural) { + this.unitPlural = JsonField.ofNullable(unitPlural); + return this; + } + + /** + * What one unit of the metric is called, e.g. token. + * + * @param unitSingular the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder unitSingular(String unitSingular) { + this.unitSingular = JsonField.ofNullable(unitSingular); + return this; + } + /** * A property the SDK does not know, sent along. * diff --git a/src/main/java/com/meteroid/models/MetricUsage.java b/src/main/java/com/meteroid/models/MetricUsage.java index 32db196..ba5effc 100644 --- a/src/main/java/com/meteroid/models/MetricUsage.java +++ b/src/main/java/com/meteroid/models/MetricUsage.java @@ -9,6 +9,7 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.JsonField; import com.meteroid.internal.Utils; import java.math.BigDecimal; @@ -18,6 +19,7 @@ import java.util.List; import java.util.Map; import java.util.Objects; +import java.util.Optional; /** Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. */ @JsonInclude(JsonInclude.Include.NON_NULL) @@ -27,6 +29,10 @@ isGetterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE) public final class MetricUsage { + @JsonProperty("costs") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField> costs = JsonField.missing(); + @JsonProperty("grouped_usage") private List groupedUsage; @@ -47,6 +53,7 @@ public final class MetricUsage { private MetricUsage() {} private MetricUsage(Builder builder) { + this.costs = builder.costs.map(Utils::copyList); this.groupedUsage = Utils.copyList(builder.groupedUsage); this.metricCode = builder.metricCode; this.metricId = builder.metricId; @@ -71,6 +78,7 @@ public static Builder builder() { */ public Builder toBuilder() { Builder builder = new Builder(); + builder.costs = costs.map(Utils::mutableList); builder.groupedUsage = Utils.mutableList(groupedUsage); builder.metricCode = metricCode; builder.metricId = metricId; @@ -80,6 +88,16 @@ public Builder toBuilder() { return builder; } + /** + * Beta: what the metric's usage adds so far to the subscription's next invoice, per currency or + * credit unit; empty while it bills nothing, as during a free trial or once cancelled. + * + * @return the value, empty when unset or null + */ + public Optional> costs() { + return costs.asOptional(); + } + /** * The {@code grouped_usage} property. * @@ -153,7 +171,8 @@ public boolean equals(Object o) { return false; } MetricUsage that = (MetricUsage) o; - return Objects.equals(groupedUsage, that.groupedUsage) + return Objects.equals(costs, that.costs) + && Objects.equals(groupedUsage, that.groupedUsage) && Objects.equals(metricCode, that.metricCode) && Objects.equals(metricId, that.metricId) && Objects.equals(metricName, that.metricName) @@ -164,13 +183,21 @@ public boolean equals(Object o) { @Override public int hashCode() { return Objects.hash( - groupedUsage, metricCode, metricId, metricName, totalValue, additionalProperties); + costs, + groupedUsage, + metricCode, + metricId, + metricName, + totalValue, + additionalProperties); } @Override public String toString() { return "MetricUsage{" - + "groupedUsage=" + + "costs=" + + costs + + ", groupedUsage=" + groupedUsage + ", metricCode=" + metricCode @@ -187,6 +214,7 @@ public String toString() { /** Builds {@link MetricUsage}. */ public static final class Builder { + private JsonField> costs = JsonField.missing(); private List groupedUsage; private String metricCode; private String metricId; @@ -196,6 +224,35 @@ public static final class Builder { private Builder() {} + /** + * Beta: what the metric's usage adds so far to the subscription's next invoice, per + * currency or credit unit; empty while it bills nothing, as during a free trial or once + * cancelled. + * + * @param costs the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder costs(List costs) { + this.costs = JsonField.ofNullable(Utils.mutableList(costs)); + return this; + } + + /** + * Adds an item to {@code costs}. + * + * @param item the item + * @return this builder + */ + public Builder addCostsItem(UsageCost item) { + List items = this.costs.orNull(); + if (items == null) { + items = new ArrayList<>(); + this.costs = JsonField.ofNullable(items); + } + items.add(item); + return this; + } + /** * The {@code grouped_usage} property. * diff --git a/src/main/java/com/meteroid/models/NeverResetPeriod.java b/src/main/java/com/meteroid/models/NeverResetPeriod.java index fae038c..3dae7a2 100644 --- a/src/main/java/com/meteroid/models/NeverResetPeriod.java +++ b/src/main/java/com/meteroid/models/NeverResetPeriod.java @@ -7,6 +7,7 @@ import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.JsonNode; import com.meteroid.internal.Utils; @@ -27,11 +28,15 @@ isGetterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE) public final class NeverResetPeriod { + @JsonProperty("type") + private String type = "NEVER"; + private final Map additionalProperties = new LinkedHashMap<>(); private NeverResetPeriod() {} private NeverResetPeriod(Builder builder) { + this.type = builder.type; this.additionalProperties.putAll(builder.additionalProperties); } @@ -51,10 +56,20 @@ public static Builder builder() { */ public Builder toBuilder() { Builder builder = new Builder(); + builder.type = type; builder.additionalProperties.putAll(additionalProperties); return builder; } + /** + * The {@code type} property. + * + * @return the value, never null + */ + public String type() { + return Utils.required(type, "type"); + } + /** * Properties this version of the SDK does not know, kept as received and sent back. * @@ -83,25 +98,43 @@ public boolean equals(Object o) { return false; } NeverResetPeriod that = (NeverResetPeriod) o; - return Objects.equals(additionalProperties, that.additionalProperties); + return Objects.equals(type, that.type) + && Objects.equals(additionalProperties, that.additionalProperties); } @Override public int hashCode() { - return Objects.hash(additionalProperties); + return Objects.hash(type, additionalProperties); } @Override public String toString() { - return "NeverResetPeriod{" + "additionalProperties=" + additionalProperties + "}"; + return "NeverResetPeriod{" + + "type=" + + type + + ", additionalProperties=" + + additionalProperties + + "}"; } /** Builds {@link NeverResetPeriod}. */ public static final class Builder { + private String type = "NEVER"; private final Map additionalProperties = new LinkedHashMap<>(); private Builder() {} + /** + * The {@code type} property. + * + * @param type the value + * @return this builder + */ + public Builder type(String type) { + this.type = type; + return this; + } + /** * A property the SDK does not know, sent along. * @@ -143,6 +176,7 @@ public Builder removeAdditionalProperty(String name) { * @throws IllegalStateException when a required property is not set */ public NeverResetPeriod build() { + Utils.checkRequired(type, "type"); return new NeverResetPeriod(this); } } diff --git a/src/main/java/com/meteroid/models/NewProductRef.java b/src/main/java/com/meteroid/models/NewProductRef.java index 9f06cd5..f410372 100644 --- a/src/main/java/com/meteroid/models/NewProductRef.java +++ b/src/main/java/com/meteroid/models/NewProductRef.java @@ -33,6 +33,9 @@ public final class NewProductRef { @JsonProperty("name") private String name; + @JsonProperty("type") + private String type = "NEW"; + private final Map additionalProperties = new LinkedHashMap<>(); private NewProductRef() {} @@ -41,6 +44,7 @@ private NewProductRef(Builder builder) { this.feeStructure = builder.feeStructure; this.feeType = builder.feeType; this.name = builder.name; + this.type = builder.type; this.additionalProperties.putAll(builder.additionalProperties); } @@ -63,6 +67,7 @@ public Builder toBuilder() { builder.feeStructure = feeStructure; builder.feeType = feeType; builder.name = name; + builder.type = type; builder.additionalProperties.putAll(additionalProperties); return builder; } @@ -94,6 +99,15 @@ public String name() { return Utils.required(name, "name"); } + /** + * The {@code type} property. + * + * @return the value, never null + */ + public String type() { + return Utils.required(type, "type"); + } + /** * Properties this version of the SDK does not know, kept as received and sent back. * @@ -125,12 +139,13 @@ public boolean equals(Object o) { return Objects.equals(feeStructure, that.feeStructure) && Objects.equals(feeType, that.feeType) && Objects.equals(name, that.name) + && Objects.equals(type, that.type) && Objects.equals(additionalProperties, that.additionalProperties); } @Override public int hashCode() { - return Objects.hash(feeStructure, feeType, name, additionalProperties); + return Objects.hash(feeStructure, feeType, name, type, additionalProperties); } @Override @@ -142,6 +157,8 @@ public String toString() { + feeType + ", name=" + name + + ", type=" + + type + ", additionalProperties=" + additionalProperties + "}"; @@ -152,6 +169,7 @@ public static final class Builder { private ProductFeeStructure feeStructure; private ProductFeeTypeEnum feeType; private String name; + private String type = "NEW"; private final Map additionalProperties = new LinkedHashMap<>(); private Builder() {} @@ -189,6 +207,17 @@ public Builder name(String name) { return this; } + /** + * The {@code type} property. + * + * @param type the value + * @return this builder + */ + public Builder type(String type) { + this.type = type; + return this; + } + /** * A property the SDK does not know, sent along. * @@ -233,6 +262,7 @@ public NewProductRef build() { Utils.checkRequired(feeStructure, "fee_structure"); Utils.checkRequired(feeType, "fee_type"); Utils.checkRequired(name, "name"); + Utils.checkRequired(type, "type"); return new NewProductRef(this); } } diff --git a/src/main/java/com/meteroid/models/NumberConfigValue.java b/src/main/java/com/meteroid/models/NumberConfigValue.java index 8e03194..4905c9e 100644 --- a/src/main/java/com/meteroid/models/NumberConfigValue.java +++ b/src/main/java/com/meteroid/models/NumberConfigValue.java @@ -29,6 +29,9 @@ isGetterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE) public final class NumberConfigValue { + @JsonProperty("kind") + private String kind = "NUMBER"; + @JsonProperty("value") private BigDecimal value; @@ -37,6 +40,7 @@ public final class NumberConfigValue { private NumberConfigValue() {} private NumberConfigValue(Builder builder) { + this.kind = builder.kind; this.value = builder.value; this.additionalProperties.putAll(builder.additionalProperties); } @@ -57,11 +61,21 @@ public static Builder builder() { */ public Builder toBuilder() { Builder builder = new Builder(); + builder.kind = kind; builder.value = value; builder.additionalProperties.putAll(additionalProperties); return builder; } + /** + * The {@code kind} property. + * + * @return the value, never null + */ + public String kind() { + return Utils.required(kind, "kind"); + } + /** * The {@code value} property. * @@ -99,19 +113,22 @@ public boolean equals(Object o) { return false; } NumberConfigValue that = (NumberConfigValue) o; - return Objects.equals(value, that.value) + return Objects.equals(kind, that.kind) + && Objects.equals(value, that.value) && Objects.equals(additionalProperties, that.additionalProperties); } @Override public int hashCode() { - return Objects.hash(value, additionalProperties); + return Objects.hash(kind, value, additionalProperties); } @Override public String toString() { return "NumberConfigValue{" - + "value=" + + "kind=" + + kind + + ", value=" + value + ", additionalProperties=" + additionalProperties @@ -120,11 +137,23 @@ public String toString() { /** Builds {@link NumberConfigValue}. */ public static final class Builder { + private String kind = "NUMBER"; private BigDecimal value; private final Map additionalProperties = new LinkedHashMap<>(); private Builder() {} + /** + * The {@code kind} property. + * + * @param kind the value + * @return this builder + */ + public Builder kind(String kind) { + this.kind = kind; + return this; + } + /** * The {@code value} property. * @@ -177,6 +206,7 @@ public Builder removeAdditionalProperty(String name) { * @throws IllegalStateException when a required property is not set */ public NumberConfigValue build() { + Utils.checkRequired(kind, "kind"); Utils.checkRequired(value, "value"); return new NumberConfigValue(this); } diff --git a/src/main/java/com/meteroid/models/OneTimeFee.java b/src/main/java/com/meteroid/models/OneTimeFee.java index 023d0f4..eb8c6cd 100644 --- a/src/main/java/com/meteroid/models/OneTimeFee.java +++ b/src/main/java/com/meteroid/models/OneTimeFee.java @@ -31,6 +31,9 @@ public final class OneTimeFee { @JsonProperty("rate") private BigDecimal rate; + @JsonProperty("type") + private String type = "ONE_TIME"; + private final Map additionalProperties = new LinkedHashMap<>(); private OneTimeFee() {} @@ -38,6 +41,7 @@ private OneTimeFee() {} private OneTimeFee(Builder builder) { this.quantity = builder.quantity; this.rate = builder.rate; + this.type = builder.type; this.additionalProperties.putAll(builder.additionalProperties); } @@ -59,6 +63,7 @@ public Builder toBuilder() { Builder builder = new Builder(); builder.quantity = quantity; builder.rate = rate; + builder.type = type; builder.additionalProperties.putAll(additionalProperties); return builder; } @@ -81,6 +86,15 @@ public BigDecimal rate() { return Utils.required(rate, "rate"); } + /** + * The {@code type} property. + * + * @return the value, never null + */ + public String type() { + return Utils.required(type, "type"); + } + /** * Properties this version of the SDK does not know, kept as received and sent back. * @@ -111,12 +125,13 @@ public boolean equals(Object o) { OneTimeFee that = (OneTimeFee) o; return Objects.equals(quantity, that.quantity) && Objects.equals(rate, that.rate) + && Objects.equals(type, that.type) && Objects.equals(additionalProperties, that.additionalProperties); } @Override public int hashCode() { - return Objects.hash(quantity, rate, additionalProperties); + return Objects.hash(quantity, rate, type, additionalProperties); } @Override @@ -126,6 +141,8 @@ public String toString() { + quantity + ", rate=" + rate + + ", type=" + + type + ", additionalProperties=" + additionalProperties + "}"; @@ -135,6 +152,7 @@ public String toString() { public static final class Builder { private Integer quantity; private BigDecimal rate; + private String type = "ONE_TIME"; private final Map additionalProperties = new LinkedHashMap<>(); private Builder() {} @@ -161,6 +179,17 @@ public Builder rate(BigDecimal rate) { return this; } + /** + * The {@code type} property. + * + * @param type the value + * @return this builder + */ + public Builder type(String type) { + this.type = type; + return this; + } + /** * A property the SDK does not know, sent along. * @@ -204,6 +233,7 @@ public Builder removeAdditionalProperty(String name) { public OneTimeFee build() { Utils.checkRequired(quantity, "quantity"); Utils.checkRequired(rate, "rate"); + Utils.checkRequired(type, "type"); return new OneTimeFee(this); } } diff --git a/src/main/java/com/meteroid/models/OneTimeFeeStructure.java b/src/main/java/com/meteroid/models/OneTimeFeeStructure.java index e4352df..97bf1b5 100644 --- a/src/main/java/com/meteroid/models/OneTimeFeeStructure.java +++ b/src/main/java/com/meteroid/models/OneTimeFeeStructure.java @@ -7,6 +7,7 @@ import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.JsonNode; import com.meteroid.internal.Utils; @@ -23,11 +24,15 @@ isGetterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE) public final class OneTimeFeeStructure { + @JsonProperty("type") + private String type = "ONE_TIME"; + private final Map additionalProperties = new LinkedHashMap<>(); private OneTimeFeeStructure() {} private OneTimeFeeStructure(Builder builder) { + this.type = builder.type; this.additionalProperties.putAll(builder.additionalProperties); } @@ -47,10 +52,20 @@ public static Builder builder() { */ public Builder toBuilder() { Builder builder = new Builder(); + builder.type = type; builder.additionalProperties.putAll(additionalProperties); return builder; } + /** + * The {@code type} property. + * + * @return the value, never null + */ + public String type() { + return Utils.required(type, "type"); + } + /** * Properties this version of the SDK does not know, kept as received and sent back. * @@ -79,25 +94,43 @@ public boolean equals(Object o) { return false; } OneTimeFeeStructure that = (OneTimeFeeStructure) o; - return Objects.equals(additionalProperties, that.additionalProperties); + return Objects.equals(type, that.type) + && Objects.equals(additionalProperties, that.additionalProperties); } @Override public int hashCode() { - return Objects.hash(additionalProperties); + return Objects.hash(type, additionalProperties); } @Override public String toString() { - return "OneTimeFeeStructure{" + "additionalProperties=" + additionalProperties + "}"; + return "OneTimeFeeStructure{" + + "type=" + + type + + ", additionalProperties=" + + additionalProperties + + "}"; } /** Builds {@link OneTimeFeeStructure}. */ public static final class Builder { + private String type = "ONE_TIME"; private final Map additionalProperties = new LinkedHashMap<>(); private Builder() {} + /** + * The {@code type} property. + * + * @param type the value + * @return this builder + */ + public Builder type(String type) { + this.type = type; + return this; + } + /** * A property the SDK does not know, sent along. * @@ -139,6 +172,7 @@ public Builder removeAdditionalProperty(String name) { * @throws IllegalStateException when a required property is not set */ public OneTimeFeeStructure build() { + Utils.checkRequired(type, "type"); return new OneTimeFeeStructure(this); } } diff --git a/src/main/java/com/meteroid/models/OneTimePlanFee.java b/src/main/java/com/meteroid/models/OneTimePlanFee.java index fc059bb..28b2bb3 100644 --- a/src/main/java/com/meteroid/models/OneTimePlanFee.java +++ b/src/main/java/com/meteroid/models/OneTimePlanFee.java @@ -32,6 +32,9 @@ public final class OneTimePlanFee { @JsonProperty("quantity") private Integer quantity; + @JsonProperty("type") + private String type = "ONE_TIME"; + @JsonProperty("unit_price") private BigDecimal unitPrice; @@ -41,6 +44,7 @@ private OneTimePlanFee() {} private OneTimePlanFee(Builder builder) { this.quantity = builder.quantity; + this.type = builder.type; this.unitPrice = builder.unitPrice; this.additionalProperties.putAll(builder.additionalProperties); } @@ -62,6 +66,7 @@ public static Builder builder() { public Builder toBuilder() { Builder builder = new Builder(); builder.quantity = quantity; + builder.type = type; builder.unitPrice = unitPrice; builder.additionalProperties.putAll(additionalProperties); return builder; @@ -76,6 +81,15 @@ public Integer quantity() { return Utils.required(quantity, "quantity"); } + /** + * The {@code type} property. + * + * @return the value, never null + */ + public String type() { + return Utils.required(type, "type"); + } + /** * The {@code unit_price} property. * @@ -114,13 +128,14 @@ public boolean equals(Object o) { } OneTimePlanFee that = (OneTimePlanFee) o; return Objects.equals(quantity, that.quantity) + && Objects.equals(type, that.type) && Objects.equals(unitPrice, that.unitPrice) && Objects.equals(additionalProperties, that.additionalProperties); } @Override public int hashCode() { - return Objects.hash(quantity, unitPrice, additionalProperties); + return Objects.hash(quantity, type, unitPrice, additionalProperties); } @Override @@ -128,6 +143,8 @@ public String toString() { return "OneTimePlanFee{" + "quantity=" + quantity + + ", type=" + + type + ", unitPrice=" + unitPrice + ", additionalProperties=" @@ -138,6 +155,7 @@ public String toString() { /** Builds {@link OneTimePlanFee}. */ public static final class Builder { private Integer quantity; + private String type = "ONE_TIME"; private BigDecimal unitPrice; private final Map additionalProperties = new LinkedHashMap<>(); @@ -154,6 +172,17 @@ public Builder quantity(Integer quantity) { return this; } + /** + * The {@code type} property. + * + * @param type the value + * @return this builder + */ + public Builder type(String type) { + this.type = type; + return this; + } + /** * The {@code unit_price} property. * @@ -207,6 +236,7 @@ public Builder removeAdditionalProperty(String name) { */ public OneTimePlanFee build() { Utils.checkRequired(quantity, "quantity"); + Utils.checkRequired(type, "type"); Utils.checkRequired(unitPrice, "unit_price"); return new OneTimePlanFee(this); } diff --git a/src/main/java/com/meteroid/models/OneTimePricing.java b/src/main/java/com/meteroid/models/OneTimePricing.java index dea48ba..8f45cd1 100644 --- a/src/main/java/com/meteroid/models/OneTimePricing.java +++ b/src/main/java/com/meteroid/models/OneTimePricing.java @@ -28,6 +28,9 @@ public final class OneTimePricing { @JsonProperty("quantity") private Integer quantity; + @JsonProperty("type") + private String type = "ONE_TIME"; + @JsonProperty("unit_price") private BigDecimal unitPrice; @@ -37,6 +40,7 @@ private OneTimePricing() {} private OneTimePricing(Builder builder) { this.quantity = builder.quantity; + this.type = builder.type; this.unitPrice = builder.unitPrice; this.additionalProperties.putAll(builder.additionalProperties); } @@ -58,6 +62,7 @@ public static Builder builder() { public Builder toBuilder() { Builder builder = new Builder(); builder.quantity = quantity; + builder.type = type; builder.unitPrice = unitPrice; builder.additionalProperties.putAll(additionalProperties); return builder; @@ -72,6 +77,15 @@ public Integer quantity() { return Utils.required(quantity, "quantity"); } + /** + * The {@code type} property. + * + * @return the value, never null + */ + public String type() { + return Utils.required(type, "type"); + } + /** * The {@code unit_price} property. * @@ -110,13 +124,14 @@ public boolean equals(Object o) { } OneTimePricing that = (OneTimePricing) o; return Objects.equals(quantity, that.quantity) + && Objects.equals(type, that.type) && Objects.equals(unitPrice, that.unitPrice) && Objects.equals(additionalProperties, that.additionalProperties); } @Override public int hashCode() { - return Objects.hash(quantity, unitPrice, additionalProperties); + return Objects.hash(quantity, type, unitPrice, additionalProperties); } @Override @@ -124,6 +139,8 @@ public String toString() { return "OneTimePricing{" + "quantity=" + quantity + + ", type=" + + type + ", unitPrice=" + unitPrice + ", additionalProperties=" @@ -134,6 +151,7 @@ public String toString() { /** Builds {@link OneTimePricing}. */ public static final class Builder { private Integer quantity; + private String type = "ONE_TIME"; private BigDecimal unitPrice; private final Map additionalProperties = new LinkedHashMap<>(); @@ -150,6 +168,17 @@ public Builder quantity(Integer quantity) { return this; } + /** + * The {@code type} property. + * + * @param type the value + * @return this builder + */ + public Builder type(String type) { + this.type = type; + return this; + } + /** * The {@code unit_price} property. * @@ -203,6 +232,7 @@ public Builder removeAdditionalProperty(String name) { */ public OneTimePricing build() { Utils.checkRequired(quantity, "quantity"); + Utils.checkRequired(type, "type"); Utils.checkRequired(unitPrice, "unit_price"); return new OneTimePricing(this); } diff --git a/src/main/java/com/meteroid/models/OnlinePaymentMethodConfig.java b/src/main/java/com/meteroid/models/OnlinePaymentMethodConfig.java index 072610b..a12519e 100644 --- a/src/main/java/com/meteroid/models/OnlinePaymentMethodConfig.java +++ b/src/main/java/com/meteroid/models/OnlinePaymentMethodConfig.java @@ -30,12 +30,16 @@ public final class OnlinePaymentMethodConfig { @JsonInclude(JsonInclude.Include.NON_EMPTY) private JsonField config = JsonField.missing(); + @JsonProperty("type") + private String type = "online"; + private final Map additionalProperties = new LinkedHashMap<>(); private OnlinePaymentMethodConfig() {} private OnlinePaymentMethodConfig(Builder builder) { this.config = builder.config; + this.type = builder.type; this.additionalProperties.putAll(builder.additionalProperties); } @@ -56,6 +60,7 @@ public static Builder builder() { public Builder toBuilder() { Builder builder = new Builder(); builder.config = config; + builder.type = type; builder.additionalProperties.putAll(additionalProperties); return builder; } @@ -69,6 +74,15 @@ public Optional config() { return config.asOptional(); } + /** + * The {@code type} property. + * + * @return the value, never null + */ + public String type() { + return Utils.required(type, "type"); + } + /** * Properties this version of the SDK does not know, kept as received and sent back. * @@ -98,12 +112,13 @@ public boolean equals(Object o) { } OnlinePaymentMethodConfig that = (OnlinePaymentMethodConfig) o; return Objects.equals(config, that.config) + && Objects.equals(type, that.type) && Objects.equals(additionalProperties, that.additionalProperties); } @Override public int hashCode() { - return Objects.hash(config, additionalProperties); + return Objects.hash(config, type, additionalProperties); } @Override @@ -111,6 +126,8 @@ public String toString() { return "OnlinePaymentMethodConfig{" + "config=" + config + + ", type=" + + type + ", additionalProperties=" + additionalProperties + "}"; @@ -119,6 +136,7 @@ public String toString() { /** Builds {@link OnlinePaymentMethodConfig}. */ public static final class Builder { private JsonField config = JsonField.missing(); + private String type = "online"; private final Map additionalProperties = new LinkedHashMap<>(); private Builder() {} @@ -134,6 +152,17 @@ public Builder config(OnlineMethodsConfig config) { return this; } + /** + * The {@code type} property. + * + * @param type the value + * @return this builder + */ + public Builder type(String type) { + this.type = type; + return this; + } + /** * A property the SDK does not know, sent along. * @@ -175,6 +204,7 @@ public Builder removeAdditionalProperty(String name) { * @throws IllegalStateException when a required property is not set */ public OnlinePaymentMethodConfig build() { + Utils.checkRequired(type, "type"); return new OnlinePaymentMethodConfig(this); } } diff --git a/src/main/java/com/meteroid/models/PackagePlanPricing.java b/src/main/java/com/meteroid/models/PackagePlanPricing.java index 25b4ec5..84e102b 100644 --- a/src/main/java/com/meteroid/models/PackagePlanPricing.java +++ b/src/main/java/com/meteroid/models/PackagePlanPricing.java @@ -31,6 +31,9 @@ public final class PackagePlanPricing { @JsonProperty("rate") private BigDecimal rate; + @JsonProperty("type") + private String type = "PACKAGE"; + private final Map additionalProperties = new LinkedHashMap<>(); private PackagePlanPricing() {} @@ -38,6 +41,7 @@ private PackagePlanPricing() {} private PackagePlanPricing(Builder builder) { this.blockSize = builder.blockSize; this.rate = builder.rate; + this.type = builder.type; this.additionalProperties.putAll(builder.additionalProperties); } @@ -59,6 +63,7 @@ public Builder toBuilder() { Builder builder = new Builder(); builder.blockSize = blockSize; builder.rate = rate; + builder.type = type; builder.additionalProperties.putAll(additionalProperties); return builder; } @@ -81,6 +86,15 @@ public BigDecimal rate() { return Utils.required(rate, "rate"); } + /** + * The {@code type} property. + * + * @return the value, never null + */ + public String type() { + return Utils.required(type, "type"); + } + /** * Properties this version of the SDK does not know, kept as received and sent back. * @@ -111,12 +125,13 @@ public boolean equals(Object o) { PackagePlanPricing that = (PackagePlanPricing) o; return Objects.equals(blockSize, that.blockSize) && Objects.equals(rate, that.rate) + && Objects.equals(type, that.type) && Objects.equals(additionalProperties, that.additionalProperties); } @Override public int hashCode() { - return Objects.hash(blockSize, rate, additionalProperties); + return Objects.hash(blockSize, rate, type, additionalProperties); } @Override @@ -126,6 +141,8 @@ public String toString() { + blockSize + ", rate=" + rate + + ", type=" + + type + ", additionalProperties=" + additionalProperties + "}"; @@ -135,6 +152,7 @@ public String toString() { public static final class Builder { private Long blockSize; private BigDecimal rate; + private String type = "PACKAGE"; private final Map additionalProperties = new LinkedHashMap<>(); private Builder() {} @@ -161,6 +179,17 @@ public Builder rate(BigDecimal rate) { return this; } + /** + * The {@code type} property. + * + * @param type the value + * @return this builder + */ + public Builder type(String type) { + this.type = type; + return this; + } + /** * A property the SDK does not know, sent along. * @@ -204,6 +233,7 @@ public Builder removeAdditionalProperty(String name) { public PackagePlanPricing build() { Utils.checkRequired(blockSize, "block_size"); Utils.checkRequired(rate, "rate"); + Utils.checkRequired(type, "type"); return new PackagePlanPricing(this); } } diff --git a/src/main/java/com/meteroid/models/PackagePricing.java b/src/main/java/com/meteroid/models/PackagePricing.java index 40917ac..748ced2 100644 --- a/src/main/java/com/meteroid/models/PackagePricing.java +++ b/src/main/java/com/meteroid/models/PackagePricing.java @@ -31,6 +31,9 @@ public final class PackagePricing { @JsonProperty("rate") private BigDecimal rate; + @JsonProperty("type") + private String type = "PACKAGE"; + private final Map additionalProperties = new LinkedHashMap<>(); private PackagePricing() {} @@ -38,6 +41,7 @@ private PackagePricing() {} private PackagePricing(Builder builder) { this.blockSize = builder.blockSize; this.rate = builder.rate; + this.type = builder.type; this.additionalProperties.putAll(builder.additionalProperties); } @@ -59,6 +63,7 @@ public Builder toBuilder() { Builder builder = new Builder(); builder.blockSize = blockSize; builder.rate = rate; + builder.type = type; builder.additionalProperties.putAll(additionalProperties); return builder; } @@ -81,6 +86,15 @@ public BigDecimal rate() { return Utils.required(rate, "rate"); } + /** + * The {@code type} property. + * + * @return the value, never null + */ + public String type() { + return Utils.required(type, "type"); + } + /** * Properties this version of the SDK does not know, kept as received and sent back. * @@ -111,12 +125,13 @@ public boolean equals(Object o) { PackagePricing that = (PackagePricing) o; return Objects.equals(blockSize, that.blockSize) && Objects.equals(rate, that.rate) + && Objects.equals(type, that.type) && Objects.equals(additionalProperties, that.additionalProperties); } @Override public int hashCode() { - return Objects.hash(blockSize, rate, additionalProperties); + return Objects.hash(blockSize, rate, type, additionalProperties); } @Override @@ -126,6 +141,8 @@ public String toString() { + blockSize + ", rate=" + rate + + ", type=" + + type + ", additionalProperties=" + additionalProperties + "}"; @@ -135,6 +152,7 @@ public String toString() { public static final class Builder { private Long blockSize; private BigDecimal rate; + private String type = "PACKAGE"; private final Map additionalProperties = new LinkedHashMap<>(); private Builder() {} @@ -161,6 +179,17 @@ public Builder rate(BigDecimal rate) { return this; } + /** + * The {@code type} property. + * + * @param type the value + * @return this builder + */ + public Builder type(String type) { + this.type = type; + return this; + } + /** * A property the SDK does not know, sent along. * @@ -204,6 +233,7 @@ public Builder removeAdditionalProperty(String name) { public PackagePricing build() { Utils.checkRequired(blockSize, "block_size"); Utils.checkRequired(rate, "rate"); + Utils.checkRequired(type, "type"); return new PackagePricing(this); } } diff --git a/src/main/java/com/meteroid/models/PatchBudgetRequest.java b/src/main/java/com/meteroid/models/PatchBudgetRequest.java new file mode 100644 index 0000000..3ae1d19 --- /dev/null +++ b/src/main/java/com/meteroid/models/PatchBudgetRequest.java @@ -0,0 +1,313 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.JsonField; +import com.meteroid.internal.Utils; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +/** + * The currency or credit unit, and the subscription, are fixed at creation. + * + *

Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonAutoDetect( + getterVisibility = Visibility.NONE, + isGetterVisibility = Visibility.NONE, + setterVisibility = Visibility.NONE) +public final class PatchBudgetRequest { + @JsonProperty("amount") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField amount = JsonField.missing(); + + @JsonProperty("behavior") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField behavior = JsonField.missing(); + + @JsonProperty("expected_version") + private Integer expectedVersion; + + @JsonProperty("thresholds") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField> thresholds = JsonField.missing(); + + private final Map additionalProperties = new LinkedHashMap<>(); + + private PatchBudgetRequest() {} + + private PatchBudgetRequest(Builder builder) { + this.amount = builder.amount; + this.behavior = builder.behavior; + this.expectedVersion = builder.expectedVersion; + this.thresholds = builder.thresholds.map(Utils::copyList); + this.additionalProperties.putAll(builder.additionalProperties); + } + + /** + * A builder of {@code PatchBudgetRequest}. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * A builder starting from this value. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.amount = amount; + builder.behavior = behavior; + builder.expectedVersion = expectedVersion; + builder.thresholds = thresholds.map(Utils::mutableList); + builder.additionalProperties.putAll(additionalProperties); + return builder; + } + + /** + * The {@code amount} property. + * + * @return the value, empty when unset or null + */ + public Optional amount() { + return amount.asOptional(); + } + + /** + * The {@code behavior} property. + * + * @return the value, empty when unset or null + */ + public Optional behavior() { + return behavior.asOptional(); + } + + /** + * The version you read; a newer stored version is refused with 409. + * + * @return the value, never null + */ + public Integer expectedVersion() { + return Utils.required(expectedVersion, "expected_version"); + } + + /** + * The {@code thresholds} property. + * + * @return the value, empty when unset or null + */ + public Optional> thresholds() { + return thresholds.asOptional(); + } + + /** + * Properties this version of the SDK does not know, kept as received and sent back. + * + * @return the properties by name, unmodifiable + */ + public Map additionalProperties() { + return Collections.unmodifiableMap(additionalProperties); + } + + @JsonAnyGetter + private Map anyProperties() { + return additionalProperties; + } + + @JsonAnySetter + private void putAnyProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + PatchBudgetRequest that = (PatchBudgetRequest) o; + return Objects.equals(amount, that.amount) + && Objects.equals(behavior, that.behavior) + && Objects.equals(expectedVersion, that.expectedVersion) + && Objects.equals(thresholds, that.thresholds) + && Objects.equals(additionalProperties, that.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(amount, behavior, expectedVersion, thresholds, additionalProperties); + } + + @Override + public String toString() { + return "PatchBudgetRequest{" + + "amount=" + + amount + + ", behavior=" + + behavior + + ", expectedVersion=" + + expectedVersion + + ", thresholds=" + + thresholds + + ", additionalProperties=" + + additionalProperties + + "}"; + } + + /** Builds {@link PatchBudgetRequest}. */ + public static final class Builder { + private JsonField amount = JsonField.missing(); + private JsonField behavior = JsonField.missing(); + private Integer expectedVersion; + private JsonField> thresholds = JsonField.missing(); + private final Map additionalProperties = new LinkedHashMap<>(); + + private Builder() {} + + /** + * The {@code amount} property. + * + * @param amount the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder amount(Long amount) { + this.amount = JsonField.ofNullable(amount); + return this; + } + + /** + * The {@code behavior} property. + * + * @param behavior the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder behavior(BudgetBehavior behavior) { + this.behavior = JsonField.ofNullable(behavior); + return this; + } + + /** + * The version you read; a newer stored version is refused with 409. + * + * @param expectedVersion the value + * @return this builder + */ + public Builder expectedVersion(Integer expectedVersion) { + this.expectedVersion = expectedVersion; + return this; + } + + /** + * The {@code thresholds} property. + * + * @param thresholds the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder thresholds(List thresholds) { + this.thresholds = JsonField.ofNullable(Utils.mutableList(thresholds)); + return this; + } + + /** + * Adds an item to {@code thresholds}. + * + * @param item the item + * @return this builder + */ + public Builder addThresholdsItem(Integer item) { + List items = this.thresholds.orNull(); + if (items == null) { + items = new ArrayList<>(); + this.thresholds = JsonField.ofNullable(items); + } + items.add(item); + return this; + } + + /** + * A property the SDK does not know, sent along. + * + * @param name the property name + * @param value the JSON value + * @return this builder + */ + public Builder putAdditionalProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + return this; + } + + /** + * Properties the SDK does not know, sent along. + * + * @param additionalProperties the properties by name + * @return this builder + */ + public Builder putAllAdditionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + + /** + * Leaves out a property the SDK does not know. + * + * @param name the property name + * @return this builder + */ + public Builder removeAdditionalProperty(String name) { + additionalProperties.remove(name); + return this; + } + + /** + * The {@code PatchBudgetRequest}. + * + * @return the immutable value + * @throws IllegalStateException when a required property is not set + */ + public PatchBudgetRequest build() { + Utils.checkRequired(expectedVersion, "expected_version"); + return new PatchBudgetRequest(this); + } + } + + /** + * Parse {@code json} as {@code PatchBudgetRequest}. + * + * @param json the JSON text + * @return the value + * @throws com.meteroid.exceptions.InvalidDataException if it is not valid JSON of this shape + */ + public static PatchBudgetRequest fromJson(String json) { + return Utils.parse(json, PatchBudgetRequest.class); + } + + /** + * This value as JSON. + * + * @return the JSON text + */ + public String toJson() { + return Utils.json(this); + } +} diff --git a/src/main/java/com/meteroid/models/PatchWalletRequest.java b/src/main/java/com/meteroid/models/PatchWalletRequest.java new file mode 100644 index 0000000..96121ee --- /dev/null +++ b/src/main/java/com/meteroid/models/PatchWalletRequest.java @@ -0,0 +1,328 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.JsonField; +import com.meteroid.internal.Utils; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +/** + * Partial update of a wallet's configuration: omit a field to leave it unchanged. + * + *

Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonAutoDetect( + getterVisibility = Visibility.NONE, + isGetterVisibility = Visibility.NONE, + setterVisibility = Visibility.NONE) +public final class PatchWalletRequest { + @JsonProperty("auto_top_up") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField autoTopUp = JsonField.missing(); + + @JsonProperty("low_balance_thresholds") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField> lowBalanceThresholds = JsonField.missing(); + + @JsonProperty("unit_price") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField unitPrice = JsonField.missing(); + + @JsonProperty("usage_at_zero") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField usageAtZero = JsonField.missing(); + + private final Map additionalProperties = new LinkedHashMap<>(); + + private PatchWalletRequest() {} + + private PatchWalletRequest(Builder builder) { + this.autoTopUp = builder.autoTopUp; + this.lowBalanceThresholds = builder.lowBalanceThresholds.map(Utils::copyList); + this.unitPrice = builder.unitPrice; + this.usageAtZero = builder.usageAtZero; + this.additionalProperties.putAll(builder.additionalProperties); + } + + /** + * A builder of {@code PatchWalletRequest}. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * A builder starting from this value. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.autoTopUp = autoTopUp; + builder.lowBalanceThresholds = lowBalanceThresholds.map(Utils::mutableList); + builder.unitPrice = unitPrice; + builder.usageAtZero = usageAtZero; + builder.additionalProperties.putAll(additionalProperties); + return builder; + } + + /** + * The {@code auto_top_up} property. + * + * @return the value, empty when unset or null + */ + public Optional autoTopUp() { + return autoTopUp.asOptional(); + } + + /** + * Ascending, distinct, at most 5, non-negative. Omit to leave unchanged; an empty list clears + * every threshold. + * + * @return the value, empty when unset or null + */ + public Optional> lowBalanceThresholds() { + return lowBalanceThresholds.asOptional(); + } + + /** + * Credit unit wallets: the price this customer agreed for one credit, in major units of the + * customer's currency, as a decimal string (positive, at most 12 decimal places). Purchases and + * automatic top-ups default to it instead of the list price. Omit to leave it unchanged; + * null returns the customer to the list price. A change applies to purchases quoted + * after it. An automatic top-up keeps running at the new price when it is at or below the price + * its terms were authorized at, and stops until they are confirmed again when it is above. + * + * @return the value, empty when unset or null + */ + public Optional unitPrice() { + return unitPrice.asOptional(); + } + + /** + * The {@code usage_at_zero} property. + * + * @return the value, empty when unset or null + */ + public Optional usageAtZero() { + return usageAtZero.asOptional(); + } + + /** + * Properties this version of the SDK does not know, kept as received and sent back. + * + * @return the properties by name, unmodifiable + */ + public Map additionalProperties() { + return Collections.unmodifiableMap(additionalProperties); + } + + @JsonAnyGetter + private Map anyProperties() { + return additionalProperties; + } + + @JsonAnySetter + private void putAnyProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + PatchWalletRequest that = (PatchWalletRequest) o; + return Objects.equals(autoTopUp, that.autoTopUp) + && Objects.equals(lowBalanceThresholds, that.lowBalanceThresholds) + && Objects.equals(unitPrice, that.unitPrice) + && Objects.equals(usageAtZero, that.usageAtZero) + && Objects.equals(additionalProperties, that.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash( + autoTopUp, lowBalanceThresholds, unitPrice, usageAtZero, additionalProperties); + } + + @Override + public String toString() { + return "PatchWalletRequest{" + + "autoTopUp=" + + autoTopUp + + ", lowBalanceThresholds=" + + lowBalanceThresholds + + ", unitPrice=" + + unitPrice + + ", usageAtZero=" + + usageAtZero + + ", additionalProperties=" + + additionalProperties + + "}"; + } + + /** Builds {@link PatchWalletRequest}. */ + public static final class Builder { + private JsonField autoTopUp = JsonField.missing(); + private JsonField> lowBalanceThresholds = JsonField.missing(); + private JsonField unitPrice = JsonField.missing(); + private JsonField usageAtZero = JsonField.missing(); + private final Map additionalProperties = new LinkedHashMap<>(); + + private Builder() {} + + /** + * The {@code auto_top_up} property. + * + * @param autoTopUp the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder autoTopUp(AutoTopUpWriteRequest autoTopUp) { + this.autoTopUp = JsonField.ofNullable(autoTopUp); + return this; + } + + /** + * Ascending, distinct, at most 5, non-negative. Omit to leave unchanged; an empty list + * clears every threshold. + * + * @param lowBalanceThresholds the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder lowBalanceThresholds(List lowBalanceThresholds) { + this.lowBalanceThresholds = + JsonField.ofNullable(Utils.mutableList(lowBalanceThresholds)); + return this; + } + + /** + * Adds an item to {@code low_balance_thresholds}. + * + * @param item the item + * @return this builder + */ + public Builder addLowBalanceThresholdsItem(Long item) { + List items = this.lowBalanceThresholds.orNull(); + if (items == null) { + items = new ArrayList<>(); + this.lowBalanceThresholds = JsonField.ofNullable(items); + } + items.add(item); + return this; + } + + /** + * Credit unit wallets: the price this customer agreed for one credit, in major units of the + * customer's currency, as a decimal string (positive, at most 12 decimal places). Purchases + * and automatic top-ups default to it instead of the list price. Omit to leave it + * unchanged; null returns the customer to the list price. A change applies to + * purchases quoted after it. An automatic top-up keeps running at the new price when it is + * at or below the price its terms were authorized at, and stops until they are confirmed + * again when it is above. + * + * @param unitPrice the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder unitPrice(String unitPrice) { + this.unitPrice = JsonField.ofNullable(unitPrice); + return this; + } + + /** + * The {@code usage_at_zero} property. + * + * @param usageAtZero the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder usageAtZero(UsageAtZero usageAtZero) { + this.usageAtZero = JsonField.ofNullable(usageAtZero); + return this; + } + + /** + * A property the SDK does not know, sent along. + * + * @param name the property name + * @param value the JSON value + * @return this builder + */ + public Builder putAdditionalProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + return this; + } + + /** + * Properties the SDK does not know, sent along. + * + * @param additionalProperties the properties by name + * @return this builder + */ + public Builder putAllAdditionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + + /** + * Leaves out a property the SDK does not know. + * + * @param name the property name + * @return this builder + */ + public Builder removeAdditionalProperty(String name) { + additionalProperties.remove(name); + return this; + } + + /** + * The {@code PatchWalletRequest}. + * + * @return the immutable value + * @throws IllegalStateException when a required property is not set + */ + public PatchWalletRequest build() { + return new PatchWalletRequest(this); + } + } + + /** + * Parse {@code json} as {@code PatchWalletRequest}. + * + * @param json the JSON text + * @return the value + * @throws com.meteroid.exceptions.InvalidDataException if it is not valid JSON of this shape + */ + public static PatchWalletRequest fromJson(String json) { + return Utils.parse(json, PatchWalletRequest.class); + } + + /** + * This value as JSON. + * + * @return the JSON text + */ + public String toJson() { + return Utils.json(this); + } +} diff --git a/src/main/java/com/meteroid/models/PerUnitPlanPricing.java b/src/main/java/com/meteroid/models/PerUnitPlanPricing.java index 5e42fe8..b9f4655 100644 --- a/src/main/java/com/meteroid/models/PerUnitPlanPricing.java +++ b/src/main/java/com/meteroid/models/PerUnitPlanPricing.java @@ -28,12 +28,16 @@ public final class PerUnitPlanPricing { @JsonProperty("rate") private BigDecimal rate; + @JsonProperty("type") + private String type = "PER_UNIT"; + private final Map additionalProperties = new LinkedHashMap<>(); private PerUnitPlanPricing() {} private PerUnitPlanPricing(Builder builder) { this.rate = builder.rate; + this.type = builder.type; this.additionalProperties.putAll(builder.additionalProperties); } @@ -54,6 +58,7 @@ public static Builder builder() { public Builder toBuilder() { Builder builder = new Builder(); builder.rate = rate; + builder.type = type; builder.additionalProperties.putAll(additionalProperties); return builder; } @@ -67,6 +72,15 @@ public BigDecimal rate() { return Utils.required(rate, "rate"); } + /** + * The {@code type} property. + * + * @return the value, never null + */ + public String type() { + return Utils.required(type, "type"); + } + /** * Properties this version of the SDK does not know, kept as received and sent back. * @@ -96,12 +110,13 @@ public boolean equals(Object o) { } PerUnitPlanPricing that = (PerUnitPlanPricing) o; return Objects.equals(rate, that.rate) + && Objects.equals(type, that.type) && Objects.equals(additionalProperties, that.additionalProperties); } @Override public int hashCode() { - return Objects.hash(rate, additionalProperties); + return Objects.hash(rate, type, additionalProperties); } @Override @@ -109,6 +124,8 @@ public String toString() { return "PerUnitPlanPricing{" + "rate=" + rate + + ", type=" + + type + ", additionalProperties=" + additionalProperties + "}"; @@ -117,6 +134,7 @@ public String toString() { /** Builds {@link PerUnitPlanPricing}. */ public static final class Builder { private BigDecimal rate; + private String type = "PER_UNIT"; private final Map additionalProperties = new LinkedHashMap<>(); private Builder() {} @@ -132,6 +150,17 @@ public Builder rate(BigDecimal rate) { return this; } + /** + * The {@code type} property. + * + * @param type the value + * @return this builder + */ + public Builder type(String type) { + this.type = type; + return this; + } + /** * A property the SDK does not know, sent along. * @@ -174,6 +203,7 @@ public Builder removeAdditionalProperty(String name) { */ public PerUnitPlanPricing build() { Utils.checkRequired(rate, "rate"); + Utils.checkRequired(type, "type"); return new PerUnitPlanPricing(this); } } diff --git a/src/main/java/com/meteroid/models/PerUnitPricing.java b/src/main/java/com/meteroid/models/PerUnitPricing.java index 309d35a..6666cae 100644 --- a/src/main/java/com/meteroid/models/PerUnitPricing.java +++ b/src/main/java/com/meteroid/models/PerUnitPricing.java @@ -28,12 +28,16 @@ public final class PerUnitPricing { @JsonProperty("rate") private BigDecimal rate; + @JsonProperty("type") + private String type = "PER_UNIT"; + private final Map additionalProperties = new LinkedHashMap<>(); private PerUnitPricing() {} private PerUnitPricing(Builder builder) { this.rate = builder.rate; + this.type = builder.type; this.additionalProperties.putAll(builder.additionalProperties); } @@ -54,6 +58,7 @@ public static Builder builder() { public Builder toBuilder() { Builder builder = new Builder(); builder.rate = rate; + builder.type = type; builder.additionalProperties.putAll(additionalProperties); return builder; } @@ -67,6 +72,15 @@ public BigDecimal rate() { return Utils.required(rate, "rate"); } + /** + * The {@code type} property. + * + * @return the value, never null + */ + public String type() { + return Utils.required(type, "type"); + } + /** * Properties this version of the SDK does not know, kept as received and sent back. * @@ -96,12 +110,13 @@ public boolean equals(Object o) { } PerUnitPricing that = (PerUnitPricing) o; return Objects.equals(rate, that.rate) + && Objects.equals(type, that.type) && Objects.equals(additionalProperties, that.additionalProperties); } @Override public int hashCode() { - return Objects.hash(rate, additionalProperties); + return Objects.hash(rate, type, additionalProperties); } @Override @@ -109,6 +124,8 @@ public String toString() { return "PerUnitPricing{" + "rate=" + rate + + ", type=" + + type + ", additionalProperties=" + additionalProperties + "}"; @@ -117,6 +134,7 @@ public String toString() { /** Builds {@link PerUnitPricing}. */ public static final class Builder { private BigDecimal rate; + private String type = "PER_UNIT"; private final Map additionalProperties = new LinkedHashMap<>(); private Builder() {} @@ -132,6 +150,17 @@ public Builder rate(BigDecimal rate) { return this; } + /** + * The {@code type} property. + * + * @param type the value + * @return this builder + */ + public Builder type(String type) { + this.type = type; + return this; + } + /** * A property the SDK does not know, sent along. * @@ -174,6 +203,7 @@ public Builder removeAdditionalProperty(String name) { */ public PerUnitPricing build() { Utils.checkRequired(rate, "rate"); + Utils.checkRequired(type, "type"); return new PerUnitPricing(this); } } diff --git a/src/main/java/com/meteroid/models/PercentageDiscount.java b/src/main/java/com/meteroid/models/PercentageDiscount.java index 84c9d9d..eb4ce88 100644 --- a/src/main/java/com/meteroid/models/PercentageDiscount.java +++ b/src/main/java/com/meteroid/models/PercentageDiscount.java @@ -27,12 +27,16 @@ public final class PercentageDiscount { @JsonProperty("percentage") private String percentage; + @JsonProperty("type") + private String type = "PERCENTAGE"; + private final Map additionalProperties = new LinkedHashMap<>(); private PercentageDiscount() {} private PercentageDiscount(Builder builder) { this.percentage = builder.percentage; + this.type = builder.type; this.additionalProperties.putAll(builder.additionalProperties); } @@ -53,6 +57,7 @@ public static Builder builder() { public Builder toBuilder() { Builder builder = new Builder(); builder.percentage = percentage; + builder.type = type; builder.additionalProperties.putAll(additionalProperties); return builder; } @@ -66,6 +71,15 @@ public String percentage() { return Utils.required(percentage, "percentage"); } + /** + * The {@code type} property. + * + * @return the value, never null + */ + public String type() { + return Utils.required(type, "type"); + } + /** * Properties this version of the SDK does not know, kept as received and sent back. * @@ -95,12 +109,13 @@ public boolean equals(Object o) { } PercentageDiscount that = (PercentageDiscount) o; return Objects.equals(percentage, that.percentage) + && Objects.equals(type, that.type) && Objects.equals(additionalProperties, that.additionalProperties); } @Override public int hashCode() { - return Objects.hash(percentage, additionalProperties); + return Objects.hash(percentage, type, additionalProperties); } @Override @@ -108,6 +123,8 @@ public String toString() { return "PercentageDiscount{" + "percentage=" + percentage + + ", type=" + + type + ", additionalProperties=" + additionalProperties + "}"; @@ -116,6 +133,7 @@ public String toString() { /** Builds {@link PercentageDiscount}. */ public static final class Builder { private String percentage; + private String type = "PERCENTAGE"; private final Map additionalProperties = new LinkedHashMap<>(); private Builder() {} @@ -131,6 +149,17 @@ public Builder percentage(String percentage) { return this; } + /** + * The {@code type} property. + * + * @param type the value + * @return this builder + */ + public Builder type(String type) { + this.type = type; + return this; + } + /** * A property the SDK does not know, sent along. * @@ -173,6 +202,7 @@ public Builder removeAdditionalProperty(String name) { */ public PercentageDiscount build() { Utils.checkRequired(percentage, "percentage"); + Utils.checkRequired(type, "type"); return new PercentageDiscount(this); } } diff --git a/src/main/java/com/meteroid/models/Plan.java b/src/main/java/com/meteroid/models/Plan.java index 7e1bb77..19888ad 100644 --- a/src/main/java/com/meteroid/models/Plan.java +++ b/src/main/java/com/meteroid/models/Plan.java @@ -39,6 +39,10 @@ public final class Plan { @JsonProperty("created_at") private OffsetDateTime createdAt; + @JsonProperty("credit_exhausted_rule") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField creditExhaustedRule = JsonField.missing(); + @JsonProperty("currency") private Currency currency; @@ -103,6 +107,7 @@ private Plan(Builder builder) { this.availableParameters = builder.availableParameters; this.billingCycles = builder.billingCycles; this.createdAt = builder.createdAt; + this.creditExhaustedRule = builder.creditExhaustedRule; this.currency = builder.currency; this.description = builder.description; this.entitlements = Utils.copyList(builder.entitlements); @@ -142,6 +147,7 @@ public Builder toBuilder() { builder.availableParameters = availableParameters; builder.billingCycles = billingCycles; builder.createdAt = createdAt; + builder.creditExhaustedRule = creditExhaustedRule; builder.currency = currency; builder.description = description; builder.entitlements = Utils.mutableList(entitlements); @@ -190,6 +196,15 @@ public OffsetDateTime createdAt() { return Utils.required(createdAt, "created_at"); } + /** + * The {@code credit_exhausted_rule} property. + * + * @return the value, empty when unset or null + */ + public Optional creditExhaustedRule() { + return creditExhaustedRule.asOptional(); + } + /** * The {@code currency} property. * @@ -377,6 +392,7 @@ public boolean equals(Object o) { return Objects.equals(availableParameters, that.availableParameters) && Objects.equals(billingCycles, that.billingCycles) && Objects.equals(createdAt, that.createdAt) + && Objects.equals(creditExhaustedRule, that.creditExhaustedRule) && Objects.equals(currency, that.currency) && Objects.equals(description, that.description) && Objects.equals(entitlements, that.entitlements) @@ -403,6 +419,7 @@ public int hashCode() { availableParameters, billingCycles, createdAt, + creditExhaustedRule, currency, description, entitlements, @@ -432,6 +449,8 @@ public String toString() { + billingCycles + ", createdAt=" + createdAt + + ", creditExhaustedRule=" + + creditExhaustedRule + ", currency=" + currency + ", description=" @@ -476,6 +495,7 @@ public static final class Builder { private AvailableParameters availableParameters; private JsonField billingCycles = JsonField.missing(); private OffsetDateTime createdAt; + private JsonField creditExhaustedRule = JsonField.missing(); private Currency currency; private JsonField description = JsonField.missing(); private List entitlements; @@ -530,6 +550,17 @@ public Builder createdAt(OffsetDateTime createdAt) { return this; } + /** + * The {@code credit_exhausted_rule} property. + * + * @param creditExhaustedRule the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder creditExhaustedRule(CreditExhaustedRule creditExhaustedRule) { + this.creditExhaustedRule = JsonField.ofNullable(creditExhaustedRule); + return this; + } + /** * The {@code currency} property. * diff --git a/src/main/java/com/meteroid/models/PlanFeeCreditUnit.java b/src/main/java/com/meteroid/models/PlanFeeCreditUnit.java new file mode 100644 index 0000000..ffaf87f --- /dev/null +++ b/src/main/java/com/meteroid/models/PlanFeeCreditUnit.java @@ -0,0 +1,236 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.Utils; + +import java.math.BigDecimal; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; + +/** + * The credit unit a plan's usage price is expressed in, with its value in the plan currency. + * + *

Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonAutoDetect( + getterVisibility = Visibility.NONE, + isGetterVisibility = Visibility.NONE, + setterVisibility = Visibility.NONE) +public final class PlanFeeCreditUnit { + @JsonProperty("credit_unit_id") + private String creditUnitId; + + @JsonProperty("rate") + private BigDecimal rate; + + private final Map additionalProperties = new LinkedHashMap<>(); + + private PlanFeeCreditUnit() {} + + private PlanFeeCreditUnit(Builder builder) { + this.creditUnitId = builder.creditUnitId; + this.rate = builder.rate; + this.additionalProperties.putAll(builder.additionalProperties); + } + + /** + * A builder of {@code PlanFeeCreditUnit}. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * A builder starting from this value. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.creditUnitId = creditUnitId; + builder.rate = rate; + builder.additionalProperties.putAll(additionalProperties); + return builder; + } + + /** + * An active credit unit of the tenant (GET /api/v1/credit-units). + * + * @return the value, never null + */ + public String creditUnitId() { + return Utils.required(creditUnitId, "credit_unit_id"); + } + + /** + * Plan-currency major units per credit (e.g. "0.01"), positive: the money billed for each + * credit the customer's balance in the unit does not cover, before tax. + * + * @return the value, never null + */ + public BigDecimal rate() { + return Utils.required(rate, "rate"); + } + + /** + * Properties this version of the SDK does not know, kept as received and sent back. + * + * @return the properties by name, unmodifiable + */ + public Map additionalProperties() { + return Collections.unmodifiableMap(additionalProperties); + } + + @JsonAnyGetter + private Map anyProperties() { + return additionalProperties; + } + + @JsonAnySetter + private void putAnyProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + PlanFeeCreditUnit that = (PlanFeeCreditUnit) o; + return Objects.equals(creditUnitId, that.creditUnitId) + && Objects.equals(rate, that.rate) + && Objects.equals(additionalProperties, that.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(creditUnitId, rate, additionalProperties); + } + + @Override + public String toString() { + return "PlanFeeCreditUnit{" + + "creditUnitId=" + + creditUnitId + + ", rate=" + + rate + + ", additionalProperties=" + + additionalProperties + + "}"; + } + + /** Builds {@link PlanFeeCreditUnit}. */ + public static final class Builder { + private String creditUnitId; + private BigDecimal rate; + private final Map additionalProperties = new LinkedHashMap<>(); + + private Builder() {} + + /** + * An active credit unit of the tenant (GET /api/v1/credit-units). + * + * @param creditUnitId the value + * @return this builder + */ + public Builder creditUnitId(String creditUnitId) { + this.creditUnitId = creditUnitId; + return this; + } + + /** + * Plan-currency major units per credit (e.g. "0.01"), positive: the money billed for each + * credit the customer's balance in the unit does not cover, before tax. + * + * @param rate the value + * @return this builder + */ + public Builder rate(BigDecimal rate) { + this.rate = rate; + return this; + } + + /** + * A property the SDK does not know, sent along. + * + * @param name the property name + * @param value the JSON value + * @return this builder + */ + public Builder putAdditionalProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + return this; + } + + /** + * Properties the SDK does not know, sent along. + * + * @param additionalProperties the properties by name + * @return this builder + */ + public Builder putAllAdditionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + + /** + * Leaves out a property the SDK does not know. + * + * @param name the property name + * @return this builder + */ + public Builder removeAdditionalProperty(String name) { + additionalProperties.remove(name); + return this; + } + + /** + * The {@code PlanFeeCreditUnit}. + * + * @return the immutable value + * @throws IllegalStateException when a required property is not set + */ + public PlanFeeCreditUnit build() { + Utils.checkRequired(creditUnitId, "credit_unit_id"); + Utils.checkRequired(rate, "rate"); + return new PlanFeeCreditUnit(this); + } + } + + /** + * Parse {@code json} as {@code PlanFeeCreditUnit}. + * + * @param json the JSON text + * @return the value + * @throws com.meteroid.exceptions.InvalidDataException if it is not valid JSON of this shape + */ + public static PlanFeeCreditUnit fromJson(String json) { + return Utils.parse(json, PlanFeeCreditUnit.class); + } + + /** + * This value as JSON. + * + * @return the JSON text + */ + public String toJson() { + return Utils.json(this); + } +} diff --git a/src/main/java/com/meteroid/models/PriceInput.java b/src/main/java/com/meteroid/models/PriceInput.java index 6c11755..3da5cdf 100644 --- a/src/main/java/com/meteroid/models/PriceInput.java +++ b/src/main/java/com/meteroid/models/PriceInput.java @@ -33,6 +33,9 @@ public final class PriceInput { @JsonProperty("pricing") private Pricing pricing; + @JsonProperty("type") + private String type = "NEW"; + private final Map additionalProperties = new LinkedHashMap<>(); private PriceInput() {} @@ -41,6 +44,7 @@ private PriceInput(Builder builder) { this.cadence = builder.cadence; this.currency = builder.currency; this.pricing = builder.pricing; + this.type = builder.type; this.additionalProperties.putAll(builder.additionalProperties); } @@ -63,6 +67,7 @@ public Builder toBuilder() { builder.cadence = cadence; builder.currency = currency; builder.pricing = pricing; + builder.type = type; builder.additionalProperties.putAll(additionalProperties); return builder; } @@ -94,6 +99,15 @@ public Pricing pricing() { return Utils.required(pricing, "pricing"); } + /** + * The {@code type} property. + * + * @return the value, never null + */ + public String type() { + return Utils.required(type, "type"); + } + /** * Properties this version of the SDK does not know, kept as received and sent back. * @@ -125,12 +139,13 @@ public boolean equals(Object o) { return Objects.equals(cadence, that.cadence) && Objects.equals(currency, that.currency) && Objects.equals(pricing, that.pricing) + && Objects.equals(type, that.type) && Objects.equals(additionalProperties, that.additionalProperties); } @Override public int hashCode() { - return Objects.hash(cadence, currency, pricing, additionalProperties); + return Objects.hash(cadence, currency, pricing, type, additionalProperties); } @Override @@ -142,6 +157,8 @@ public String toString() { + currency + ", pricing=" + pricing + + ", type=" + + type + ", additionalProperties=" + additionalProperties + "}"; @@ -152,6 +169,7 @@ public static final class Builder { private BillingPeriodEnum cadence; private String currency; private Pricing pricing; + private String type = "NEW"; private final Map additionalProperties = new LinkedHashMap<>(); private Builder() {} @@ -189,6 +207,17 @@ public Builder pricing(Pricing pricing) { return this; } + /** + * The {@code type} property. + * + * @param type the value + * @return this builder + */ + public Builder type(String type) { + this.type = type; + return this; + } + /** * A property the SDK does not know, sent along. * @@ -233,6 +262,7 @@ public PriceInput build() { Utils.checkRequired(cadence, "cadence"); Utils.checkRequired(currency, "currency"); Utils.checkRequired(pricing, "pricing"); + Utils.checkRequired(type, "type"); return new PriceInput(this); } } diff --git a/src/main/java/com/meteroid/models/ProductFeeStructure.java b/src/main/java/com/meteroid/models/ProductFeeStructure.java index 2671849..0cc1914 100644 --- a/src/main/java/com/meteroid/models/ProductFeeStructure.java +++ b/src/main/java/com/meteroid/models/ProductFeeStructure.java @@ -36,7 +36,8 @@ @JsonSubTypes.Type(value = ProductFeeStructure.Capacity.class, name = "CAPACITY"), @JsonSubTypes.Type(value = ProductFeeStructure.Usage.class, name = "USAGE"), @JsonSubTypes.Type(value = ProductFeeStructure.ExtraRecurring.class, name = "EXTRA_RECURRING"), - @JsonSubTypes.Type(value = ProductFeeStructure.OneTime.class, name = "ONE_TIME") + @JsonSubTypes.Type(value = ProductFeeStructure.OneTime.class, name = "ONE_TIME"), + @JsonSubTypes.Type(value = ProductFeeStructure.Credit.class, name = "CREDIT") }) @JsonInclude(JsonInclude.Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) @@ -188,6 +189,28 @@ public final OneTime asOneTime() { throw new IllegalStateException("not the ONE_TIME variant: " + type()); } + /** + * Whether this is the {@code CREDIT} variant. + * + * @return whether it is + */ + public final boolean isCredit() { + return this instanceof Credit; + } + + /** + * This value as the {@code CREDIT} variant. + * + * @return the variant + * @throws IllegalStateException if this is another variant + */ + public final Credit asCredit() { + if (this instanceof Credit) { + return (Credit) this; + } + throw new IllegalStateException("not the CREDIT variant: " + type()); + } + /** * Whether this is a variant this version of the SDK does not know. * @@ -273,6 +296,14 @@ public interface Visitor { */ R visitOneTime(OneTimeFeeStructure value); + /** + * Visits the {@code CREDIT} variant. + * + * @param value the variant + * @return the result + */ + R visitCredit(CreditFeeStructure value); + /** * Visits a variant this version of the SDK does not know. * @@ -732,6 +763,77 @@ public R accept(Visitor visitor) { } } + /** The {@code CREDIT} variant. */ + @JsonTypeName("CREDIT") + public static final class Credit extends ProductFeeStructure { + @JsonUnwrapped + @JsonIgnoreProperties(value = "type", allowSetters = true) + private CreditFeeStructure data; + + private Credit() {} + + /** + * The variant holding {@code data}. + * + * @param data the value of the variant + */ + public Credit(CreditFeeStructure data) { + this.data = Objects.requireNonNull(data, "data"); + } + + /** + * The variant holding {@code data}. + * + * @param data the value of the variant + * @return the variant + */ + public static Credit of(CreditFeeStructure data) { + return new Credit(data); + } + + @Override + @JsonProperty("type") + public String type() { + return "CREDIT"; + } + + /** + * The value of the variant. + * + * @return the value + */ + public CreditFeeStructure data() { + return data; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Credit that = (Credit) o; + return Objects.equals(data, that.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + return "Credit{" + "data=" + data + "}"; + } + + @Override + public R accept(Visitor visitor) { + return visitor.visitCredit(data); + } + } + /** A variant this version of the SDK does not know. */ public static final class Unrecognized extends ProductFeeStructure { @JsonProperty("type") diff --git a/src/main/java/com/meteroid/models/ProductFeeTypeEnum.java b/src/main/java/com/meteroid/models/ProductFeeTypeEnum.java index af6aae5..e31ab68 100644 --- a/src/main/java/com/meteroid/models/ProductFeeTypeEnum.java +++ b/src/main/java/com/meteroid/models/ProductFeeTypeEnum.java @@ -34,6 +34,9 @@ public final class ProductFeeTypeEnum implements ToQueryParam { public static final ProductFeeTypeEnum ONE_TIME = new ProductFeeTypeEnum("ONE_TIME", Value.ONE_TIME); + /** The value {@code "CREDIT"}. */ + public static final ProductFeeTypeEnum CREDIT = new ProductFeeTypeEnum("CREDIT", Value.CREDIT); + private static final Map constants = Map.ofEntries( Map.entry("RATE", RATE), @@ -41,7 +44,8 @@ public final class ProductFeeTypeEnum implements ToQueryParam { Map.entry("CAPACITY", CAPACITY), Map.entry("USAGE", USAGE), Map.entry("EXTRA_RECURRING", EXTRA_RECURRING), - Map.entry("ONE_TIME", ONE_TIME)); + Map.entry("ONE_TIME", ONE_TIME), + Map.entry("CREDIT", CREDIT)); private final String value; private final Value variant; @@ -140,7 +144,9 @@ public enum Known { /** The {@code EXTRA_RECURRING} constant. */ EXTRA_RECURRING, /** The {@code ONE_TIME} constant. */ - ONE_TIME + ONE_TIME, + /** The {@code CREDIT} constant. */ + CREDIT } /** The values this version of the SDK knows, and {@code _UNKNOWN} for the others. */ @@ -157,6 +163,8 @@ public enum Value { EXTRA_RECURRING, /** The {@code ONE_TIME} constant. */ ONE_TIME, + /** The {@code CREDIT} constant. */ + CREDIT, /** A value this version of the SDK does not know. */ _UNKNOWN } diff --git a/src/main/java/com/meteroid/models/ProductsScope.java b/src/main/java/com/meteroid/models/ProductsScope.java index ca0d71c..7b65986 100644 --- a/src/main/java/com/meteroid/models/ProductsScope.java +++ b/src/main/java/com/meteroid/models/ProductsScope.java @@ -34,12 +34,16 @@ public final class ProductsScope { @JsonProperty("product_ids") private List productIds; + @JsonProperty("type") + private String type = "products"; + private final Map additionalProperties = new LinkedHashMap<>(); private ProductsScope() {} private ProductsScope(Builder builder) { this.productIds = Utils.copyList(builder.productIds); + this.type = builder.type; this.additionalProperties.putAll(builder.additionalProperties); } @@ -60,6 +64,7 @@ public static Builder builder() { public Builder toBuilder() { Builder builder = new Builder(); builder.productIds = Utils.mutableList(productIds); + builder.type = type; builder.additionalProperties.putAll(additionalProperties); return builder; } @@ -73,6 +78,15 @@ public List productIds() { return Utils.required(productIds, "product_ids"); } + /** + * The {@code type} property. + * + * @return the value, never null + */ + public String type() { + return Utils.required(type, "type"); + } + /** * Properties this version of the SDK does not know, kept as received and sent back. * @@ -102,12 +116,13 @@ public boolean equals(Object o) { } ProductsScope that = (ProductsScope) o; return Objects.equals(productIds, that.productIds) + && Objects.equals(type, that.type) && Objects.equals(additionalProperties, that.additionalProperties); } @Override public int hashCode() { - return Objects.hash(productIds, additionalProperties); + return Objects.hash(productIds, type, additionalProperties); } @Override @@ -115,6 +130,8 @@ public String toString() { return "ProductsScope{" + "productIds=" + productIds + + ", type=" + + type + ", additionalProperties=" + additionalProperties + "}"; @@ -123,6 +140,7 @@ public String toString() { /** Builds {@link ProductsScope}. */ public static final class Builder { private List productIds; + private String type = "products"; private final Map additionalProperties = new LinkedHashMap<>(); private Builder() {} @@ -152,6 +170,17 @@ public Builder addProductIdsItem(String item) { return this; } + /** + * The {@code type} property. + * + * @param type the value + * @return this builder + */ + public Builder type(String type) { + this.type = type; + return this; + } + /** * A property the SDK does not know, sent along. * @@ -194,6 +223,7 @@ public Builder removeAdditionalProperty(String name) { */ public ProductsScope build() { Utils.checkRequired(productIds, "product_ids"); + Utils.checkRequired(type, "type"); return new ProductsScope(this); } } diff --git a/src/main/java/com/meteroid/models/RateFee.java b/src/main/java/com/meteroid/models/RateFee.java index 0e7e5ab..fccd020 100644 --- a/src/main/java/com/meteroid/models/RateFee.java +++ b/src/main/java/com/meteroid/models/RateFee.java @@ -28,12 +28,16 @@ public final class RateFee { @JsonProperty("rate") private BigDecimal rate; + @JsonProperty("type") + private String type = "RATE"; + private final Map additionalProperties = new LinkedHashMap<>(); private RateFee() {} private RateFee(Builder builder) { this.rate = builder.rate; + this.type = builder.type; this.additionalProperties.putAll(builder.additionalProperties); } @@ -54,6 +58,7 @@ public static Builder builder() { public Builder toBuilder() { Builder builder = new Builder(); builder.rate = rate; + builder.type = type; builder.additionalProperties.putAll(additionalProperties); return builder; } @@ -67,6 +72,15 @@ public BigDecimal rate() { return Utils.required(rate, "rate"); } + /** + * The {@code type} property. + * + * @return the value, never null + */ + public String type() { + return Utils.required(type, "type"); + } + /** * Properties this version of the SDK does not know, kept as received and sent back. * @@ -96,22 +110,31 @@ public boolean equals(Object o) { } RateFee that = (RateFee) o; return Objects.equals(rate, that.rate) + && Objects.equals(type, that.type) && Objects.equals(additionalProperties, that.additionalProperties); } @Override public int hashCode() { - return Objects.hash(rate, additionalProperties); + return Objects.hash(rate, type, additionalProperties); } @Override public String toString() { - return "RateFee{" + "rate=" + rate + ", additionalProperties=" + additionalProperties + "}"; + return "RateFee{" + + "rate=" + + rate + + ", type=" + + type + + ", additionalProperties=" + + additionalProperties + + "}"; } /** Builds {@link RateFee}. */ public static final class Builder { private BigDecimal rate; + private String type = "RATE"; private final Map additionalProperties = new LinkedHashMap<>(); private Builder() {} @@ -127,6 +150,17 @@ public Builder rate(BigDecimal rate) { return this; } + /** + * The {@code type} property. + * + * @param type the value + * @return this builder + */ + public Builder type(String type) { + this.type = type; + return this; + } + /** * A property the SDK does not know, sent along. * @@ -169,6 +203,7 @@ public Builder removeAdditionalProperty(String name) { */ public RateFee build() { Utils.checkRequired(rate, "rate"); + Utils.checkRequired(type, "type"); return new RateFee(this); } } diff --git a/src/main/java/com/meteroid/models/RateFeeStructure.java b/src/main/java/com/meteroid/models/RateFeeStructure.java index 8ed4d29..1207b50 100644 --- a/src/main/java/com/meteroid/models/RateFeeStructure.java +++ b/src/main/java/com/meteroid/models/RateFeeStructure.java @@ -7,6 +7,7 @@ import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.JsonNode; import com.meteroid.internal.Utils; @@ -23,11 +24,15 @@ isGetterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE) public final class RateFeeStructure { + @JsonProperty("type") + private String type = "RATE"; + private final Map additionalProperties = new LinkedHashMap<>(); private RateFeeStructure() {} private RateFeeStructure(Builder builder) { + this.type = builder.type; this.additionalProperties.putAll(builder.additionalProperties); } @@ -47,10 +52,20 @@ public static Builder builder() { */ public Builder toBuilder() { Builder builder = new Builder(); + builder.type = type; builder.additionalProperties.putAll(additionalProperties); return builder; } + /** + * The {@code type} property. + * + * @return the value, never null + */ + public String type() { + return Utils.required(type, "type"); + } + /** * Properties this version of the SDK does not know, kept as received and sent back. * @@ -79,25 +94,43 @@ public boolean equals(Object o) { return false; } RateFeeStructure that = (RateFeeStructure) o; - return Objects.equals(additionalProperties, that.additionalProperties); + return Objects.equals(type, that.type) + && Objects.equals(additionalProperties, that.additionalProperties); } @Override public int hashCode() { - return Objects.hash(additionalProperties); + return Objects.hash(type, additionalProperties); } @Override public String toString() { - return "RateFeeStructure{" + "additionalProperties=" + additionalProperties + "}"; + return "RateFeeStructure{" + + "type=" + + type + + ", additionalProperties=" + + additionalProperties + + "}"; } /** Builds {@link RateFeeStructure}. */ public static final class Builder { + private String type = "RATE"; private final Map additionalProperties = new LinkedHashMap<>(); private Builder() {} + /** + * The {@code type} property. + * + * @param type the value + * @return this builder + */ + public Builder type(String type) { + this.type = type; + return this; + } + /** * A property the SDK does not know, sent along. * @@ -139,6 +172,7 @@ public Builder removeAdditionalProperty(String name) { * @throws IllegalStateException when a required property is not set */ public RateFeeStructure build() { + Utils.checkRequired(type, "type"); return new RateFeeStructure(this); } } diff --git a/src/main/java/com/meteroid/models/RatePlanFee.java b/src/main/java/com/meteroid/models/RatePlanFee.java index 11ac974..2c30799 100644 --- a/src/main/java/com/meteroid/models/RatePlanFee.java +++ b/src/main/java/com/meteroid/models/RatePlanFee.java @@ -33,12 +33,16 @@ public final class RatePlanFee { @JsonProperty("rates") private List rates; + @JsonProperty("type") + private String type = "RATE"; + private final Map additionalProperties = new LinkedHashMap<>(); private RatePlanFee() {} private RatePlanFee(Builder builder) { this.rates = Utils.copyList(builder.rates); + this.type = builder.type; this.additionalProperties.putAll(builder.additionalProperties); } @@ -59,6 +63,7 @@ public static Builder builder() { public Builder toBuilder() { Builder builder = new Builder(); builder.rates = Utils.mutableList(rates); + builder.type = type; builder.additionalProperties.putAll(additionalProperties); return builder; } @@ -72,6 +77,15 @@ public List rates() { return Utils.required(rates, "rates"); } + /** + * The {@code type} property. + * + * @return the value, never null + */ + public String type() { + return Utils.required(type, "type"); + } + /** * Properties this version of the SDK does not know, kept as received and sent back. * @@ -101,12 +115,13 @@ public boolean equals(Object o) { } RatePlanFee that = (RatePlanFee) o; return Objects.equals(rates, that.rates) + && Objects.equals(type, that.type) && Objects.equals(additionalProperties, that.additionalProperties); } @Override public int hashCode() { - return Objects.hash(rates, additionalProperties); + return Objects.hash(rates, type, additionalProperties); } @Override @@ -114,6 +129,8 @@ public String toString() { return "RatePlanFee{" + "rates=" + rates + + ", type=" + + type + ", additionalProperties=" + additionalProperties + "}"; @@ -122,6 +139,7 @@ public String toString() { /** Builds {@link RatePlanFee}. */ public static final class Builder { private List rates; + private String type = "RATE"; private final Map additionalProperties = new LinkedHashMap<>(); private Builder() {} @@ -151,6 +169,17 @@ public Builder addRatesItem(TermRate item) { return this; } + /** + * The {@code type} property. + * + * @param type the value + * @return this builder + */ + public Builder type(String type) { + this.type = type; + return this; + } + /** * A property the SDK does not know, sent along. * @@ -193,6 +222,7 @@ public Builder removeAdditionalProperty(String name) { */ public RatePlanFee build() { Utils.checkRequired(rates, "rates"); + Utils.checkRequired(type, "type"); return new RatePlanFee(this); } } diff --git a/src/main/java/com/meteroid/models/RatePricing.java b/src/main/java/com/meteroid/models/RatePricing.java index a5411b9..be19850 100644 --- a/src/main/java/com/meteroid/models/RatePricing.java +++ b/src/main/java/com/meteroid/models/RatePricing.java @@ -28,12 +28,16 @@ public final class RatePricing { @JsonProperty("rate") private BigDecimal rate; + @JsonProperty("type") + private String type = "RATE"; + private final Map additionalProperties = new LinkedHashMap<>(); private RatePricing() {} private RatePricing(Builder builder) { this.rate = builder.rate; + this.type = builder.type; this.additionalProperties.putAll(builder.additionalProperties); } @@ -54,6 +58,7 @@ public static Builder builder() { public Builder toBuilder() { Builder builder = new Builder(); builder.rate = rate; + builder.type = type; builder.additionalProperties.putAll(additionalProperties); return builder; } @@ -67,6 +72,15 @@ public BigDecimal rate() { return Utils.required(rate, "rate"); } + /** + * The {@code type} property. + * + * @return the value, never null + */ + public String type() { + return Utils.required(type, "type"); + } + /** * Properties this version of the SDK does not know, kept as received and sent back. * @@ -96,12 +110,13 @@ public boolean equals(Object o) { } RatePricing that = (RatePricing) o; return Objects.equals(rate, that.rate) + && Objects.equals(type, that.type) && Objects.equals(additionalProperties, that.additionalProperties); } @Override public int hashCode() { - return Objects.hash(rate, additionalProperties); + return Objects.hash(rate, type, additionalProperties); } @Override @@ -109,6 +124,8 @@ public String toString() { return "RatePricing{" + "rate=" + rate + + ", type=" + + type + ", additionalProperties=" + additionalProperties + "}"; @@ -117,6 +134,7 @@ public String toString() { /** Builds {@link RatePricing}. */ public static final class Builder { private BigDecimal rate; + private String type = "RATE"; private final Map additionalProperties = new LinkedHashMap<>(); private Builder() {} @@ -132,6 +150,17 @@ public Builder rate(BigDecimal rate) { return this; } + /** + * The {@code type} property. + * + * @param type the value + * @return this builder + */ + public Builder type(String type) { + this.type = type; + return this; + } + /** * A property the SDK does not know, sent along. * @@ -174,6 +203,7 @@ public Builder removeAdditionalProperty(String name) { */ public RatePricing build() { Utils.checkRequired(rate, "rate"); + Utils.checkRequired(type, "type"); return new RatePricing(this); } } diff --git a/src/main/java/com/meteroid/models/RecurringFee.java b/src/main/java/com/meteroid/models/RecurringFee.java index 5445978..3ca99f5 100644 --- a/src/main/java/com/meteroid/models/RecurringFee.java +++ b/src/main/java/com/meteroid/models/RecurringFee.java @@ -34,6 +34,9 @@ public final class RecurringFee { @JsonProperty("rate") private BigDecimal rate; + @JsonProperty("type") + private String type = "RECURRING"; + private final Map additionalProperties = new LinkedHashMap<>(); private RecurringFee() {} @@ -42,6 +45,7 @@ private RecurringFee(Builder builder) { this.billingType = builder.billingType; this.quantity = builder.quantity; this.rate = builder.rate; + this.type = builder.type; this.additionalProperties.putAll(builder.additionalProperties); } @@ -64,6 +68,7 @@ public Builder toBuilder() { builder.billingType = billingType; builder.quantity = quantity; builder.rate = rate; + builder.type = type; builder.additionalProperties.putAll(additionalProperties); return builder; } @@ -95,6 +100,15 @@ public BigDecimal rate() { return Utils.required(rate, "rate"); } + /** + * The {@code type} property. + * + * @return the value, never null + */ + public String type() { + return Utils.required(type, "type"); + } + /** * Properties this version of the SDK does not know, kept as received and sent back. * @@ -126,12 +140,13 @@ public boolean equals(Object o) { return Objects.equals(billingType, that.billingType) && Objects.equals(quantity, that.quantity) && Objects.equals(rate, that.rate) + && Objects.equals(type, that.type) && Objects.equals(additionalProperties, that.additionalProperties); } @Override public int hashCode() { - return Objects.hash(billingType, quantity, rate, additionalProperties); + return Objects.hash(billingType, quantity, rate, type, additionalProperties); } @Override @@ -143,6 +158,8 @@ public String toString() { + quantity + ", rate=" + rate + + ", type=" + + type + ", additionalProperties=" + additionalProperties + "}"; @@ -153,6 +170,7 @@ public static final class Builder { private BillingTypeEnum billingType; private Integer quantity; private BigDecimal rate; + private String type = "RECURRING"; private final Map additionalProperties = new LinkedHashMap<>(); private Builder() {} @@ -190,6 +208,17 @@ public Builder rate(BigDecimal rate) { return this; } + /** + * The {@code type} property. + * + * @param type the value + * @return this builder + */ + public Builder type(String type) { + this.type = type; + return this; + } + /** * A property the SDK does not know, sent along. * @@ -234,6 +263,7 @@ public RecurringFee build() { Utils.checkRequired(billingType, "billing_type"); Utils.checkRequired(quantity, "quantity"); Utils.checkRequired(rate, "rate"); + Utils.checkRequired(type, "type"); return new RecurringFee(this); } } diff --git a/src/main/java/com/meteroid/models/RefundEventData.java b/src/main/java/com/meteroid/models/RefundEventData.java index a57d6d6..179e9bd 100644 --- a/src/main/java/com/meteroid/models/RefundEventData.java +++ b/src/main/java/com/meteroid/models/RefundEventData.java @@ -36,12 +36,18 @@ public final class RefundEventData { @JsonProperty("amount") private Long amount; + @JsonProperty("amount_disputed") + private Long amountDisputed; + @JsonProperty("amount_refunded") private Long amountRefunded; @JsonProperty("amount_reversed") private Long amountReversed; + @JsonProperty("amount_reversed_excess") + private Long amountReversedExcess; + @JsonProperty("credit_note_id") @JsonInclude(JsonInclude.Include.NON_EMPTY) private JsonField creditNoteId = JsonField.missing(); @@ -96,8 +102,10 @@ private RefundEventData() {} private RefundEventData(Builder builder) { this.amount = builder.amount; + this.amountDisputed = builder.amountDisputed; this.amountRefunded = builder.amountRefunded; this.amountReversed = builder.amountReversed; + this.amountReversedExcess = builder.amountReversedExcess; this.creditNoteId = builder.creditNoteId; this.currency = builder.currency; this.declineKind = builder.declineKind; @@ -131,8 +139,10 @@ public static Builder builder() { public Builder toBuilder() { Builder builder = new Builder(); builder.amount = amount; + builder.amountDisputed = amountDisputed; builder.amountRefunded = amountRefunded; builder.amountReversed = amountReversed; + builder.amountReversedExcess = amountReversedExcess; builder.creditNoteId = creditNoteId; builder.currency = currency; builder.declineKind = declineKind; @@ -159,6 +169,16 @@ public Long amount() { return Utils.required(amount, "amount"); } + /** + * The part of amount_reversed lost to disputes or chargebacks: the invoice stays + * paid. + * + * @return the value, empty when unset + */ + public Optional amountDisputed() { + return Optional.ofNullable(amountDisputed); + } + /** * The {@code amount_refunded} property. * @@ -177,6 +197,16 @@ public Long amountReversed() { return Utils.required(amountReversed, "amount_reversed"); } + /** + * What the provider withdrew above what the payment still held (refunded before); never applied + * to the invoice or credit. Contest it with the provider. + * + * @return the value, empty when unset + */ + public Optional amountReversedExcess() { + return Optional.ofNullable(amountReversedExcess); + } + /** * The {@code credit_note_id} property. * @@ -323,8 +353,10 @@ public boolean equals(Object o) { } RefundEventData that = (RefundEventData) o; return Objects.equals(amount, that.amount) + && Objects.equals(amountDisputed, that.amountDisputed) && Objects.equals(amountRefunded, that.amountRefunded) && Objects.equals(amountReversed, that.amountReversed) + && Objects.equals(amountReversedExcess, that.amountReversedExcess) && Objects.equals(creditNoteId, that.creditNoteId) && Objects.equals(currency, that.currency) && Objects.equals(declineKind, that.declineKind) @@ -345,8 +377,10 @@ public boolean equals(Object o) { public int hashCode() { return Objects.hash( amount, + amountDisputed, amountRefunded, amountReversed, + amountReversedExcess, creditNoteId, currency, declineKind, @@ -368,10 +402,14 @@ public String toString() { return "RefundEventData{" + "amount=" + amount + + ", amountDisputed=" + + amountDisputed + ", amountRefunded=" + amountRefunded + ", amountReversed=" + amountReversed + + ", amountReversedExcess=" + + amountReversedExcess + ", creditNoteId=" + creditNoteId + ", currency=" @@ -406,8 +444,10 @@ public String toString() { /** Builds {@link RefundEventData}. */ public static final class Builder { private Long amount; + private Long amountDisputed; private Long amountRefunded; private Long amountReversed; + private Long amountReversedExcess; private JsonField creditNoteId = JsonField.missing(); private String currency; private JsonField declineKind = JsonField.missing(); @@ -436,6 +476,18 @@ public Builder amount(Long amount) { return this; } + /** + * The part of amount_reversed lost to disputes or chargebacks: the invoice + * stays paid. + * + * @param amountDisputed the value + * @return this builder + */ + public Builder amountDisputed(Long amountDisputed) { + this.amountDisputed = amountDisputed; + return this; + } + /** * The {@code amount_refunded} property. * @@ -458,6 +510,18 @@ public Builder amountReversed(Long amountReversed) { return this; } + /** + * What the provider withdrew above what the payment still held (refunded before); never + * applied to the invoice or credit. Contest it with the provider. + * + * @param amountReversedExcess the value + * @return this builder + */ + public Builder amountReversedExcess(Long amountReversedExcess) { + this.amountReversedExcess = amountReversedExcess; + return this; + } + /** * The {@code credit_note_id} property. * diff --git a/src/main/java/com/meteroid/models/ReplacePlanRequest.java b/src/main/java/com/meteroid/models/ReplacePlanRequest.java index 7f02a1f..a603786 100644 --- a/src/main/java/com/meteroid/models/ReplacePlanRequest.java +++ b/src/main/java/com/meteroid/models/ReplacePlanRequest.java @@ -38,6 +38,10 @@ public final class ReplacePlanRequest { @JsonProperty("components") private List components; + @JsonProperty("credit_exhausted_rule") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField creditExhaustedRule = JsonField.missing(); + @JsonProperty("currency") private String currency; @@ -74,6 +78,7 @@ private ReplacePlanRequest(Builder builder) { this.addOns = Utils.copyList(builder.addOns); this.billing = builder.billing; this.components = Utils.copyList(builder.components); + this.creditExhaustedRule = builder.creditExhaustedRule; this.currency = builder.currency; this.description = builder.description; this.entitlements = Utils.copyList(builder.entitlements); @@ -104,6 +109,7 @@ public Builder toBuilder() { builder.addOns = Utils.mutableList(addOns); builder.billing = billing; builder.components = Utils.mutableList(components); + builder.creditExhaustedRule = creditExhaustedRule; builder.currency = currency; builder.description = description; builder.entitlements = Utils.mutableList(entitlements); @@ -143,6 +149,15 @@ public List components() { return Utils.required(components, "components"); } + /** + * The {@code credit_exhausted_rule} property. + * + * @return the value, empty when unset or null + */ + public Optional creditExhaustedRule() { + return creditExhaustedRule.asOptional(); + } + /** * The {@code currency} property. * @@ -251,6 +266,7 @@ public boolean equals(Object o) { return Objects.equals(addOns, that.addOns) && Objects.equals(billing, that.billing) && Objects.equals(components, that.components) + && Objects.equals(creditExhaustedRule, that.creditExhaustedRule) && Objects.equals(currency, that.currency) && Objects.equals(description, that.description) && Objects.equals(entitlements, that.entitlements) @@ -268,6 +284,7 @@ public int hashCode() { addOns, billing, components, + creditExhaustedRule, currency, description, entitlements, @@ -288,6 +305,8 @@ public String toString() { + billing + ", components=" + components + + ", creditExhaustedRule=" + + creditExhaustedRule + ", currency=" + currency + ", description=" @@ -314,6 +333,7 @@ public static final class Builder { private List addOns; private JsonField billing = JsonField.missing(); private List components; + private JsonField creditExhaustedRule = JsonField.missing(); private String currency; private JsonField description = JsonField.missing(); private List entitlements; @@ -387,6 +407,17 @@ public Builder addComponentsItem(PriceComponentInput item) { return this; } + /** + * The {@code credit_exhausted_rule} property. + * + * @param creditExhaustedRule the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder creditExhaustedRule(CreditExhaustedRule creditExhaustedRule) { + this.creditExhaustedRule = JsonField.ofNullable(creditExhaustedRule); + return this; + } + /** * The {@code currency} property. * diff --git a/src/main/java/com/meteroid/models/SlidingWindowResetPeriod.java b/src/main/java/com/meteroid/models/SlidingWindowResetPeriod.java index a1686e3..72e6dff 100644 --- a/src/main/java/com/meteroid/models/SlidingWindowResetPeriod.java +++ b/src/main/java/com/meteroid/models/SlidingWindowResetPeriod.java @@ -17,7 +17,9 @@ import java.util.Objects; /** - * Always ends at now — e.g. 30 days means the last 30 days, old usage drops off automatically. + * Always ends at now — e.g. 30 days means the last 30 days, old usage drops off automatically. A + * sliding window has no reset moment (reset_at is absent) and sends no threshold or + * limit-reached webhooks; it is enforced by the entitlement check. * *

Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. */ @@ -31,6 +33,9 @@ public final class SlidingWindowResetPeriod { @JsonProperty("interval") private Integer interval; + @JsonProperty("type") + private String type = "SLIDING_WINDOW"; + @JsonProperty("unit") private CalendarUnit unit; @@ -40,6 +45,7 @@ private SlidingWindowResetPeriod() {} private SlidingWindowResetPeriod(Builder builder) { this.interval = builder.interval; + this.type = builder.type; this.unit = builder.unit; this.additionalProperties.putAll(builder.additionalProperties); } @@ -61,6 +67,7 @@ public static Builder builder() { public Builder toBuilder() { Builder builder = new Builder(); builder.interval = interval; + builder.type = type; builder.unit = unit; builder.additionalProperties.putAll(additionalProperties); return builder; @@ -75,6 +82,15 @@ public Integer interval() { return Utils.required(interval, "interval"); } + /** + * The {@code type} property. + * + * @return the value, never null + */ + public String type() { + return Utils.required(type, "type"); + } + /** * The {@code unit} property. * @@ -113,13 +129,14 @@ public boolean equals(Object o) { } SlidingWindowResetPeriod that = (SlidingWindowResetPeriod) o; return Objects.equals(interval, that.interval) + && Objects.equals(type, that.type) && Objects.equals(unit, that.unit) && Objects.equals(additionalProperties, that.additionalProperties); } @Override public int hashCode() { - return Objects.hash(interval, unit, additionalProperties); + return Objects.hash(interval, type, unit, additionalProperties); } @Override @@ -127,6 +144,8 @@ public String toString() { return "SlidingWindowResetPeriod{" + "interval=" + interval + + ", type=" + + type + ", unit=" + unit + ", additionalProperties=" @@ -137,6 +156,7 @@ public String toString() { /** Builds {@link SlidingWindowResetPeriod}. */ public static final class Builder { private Integer interval; + private String type = "SLIDING_WINDOW"; private CalendarUnit unit; private final Map additionalProperties = new LinkedHashMap<>(); @@ -153,6 +173,17 @@ public Builder interval(Integer interval) { return this; } + /** + * The {@code type} property. + * + * @param type the value + * @return this builder + */ + public Builder type(String type) { + this.type = type; + return this; + } + /** * The {@code unit} property. * @@ -206,6 +237,7 @@ public Builder removeAdditionalProperty(String name) { */ public SlidingWindowResetPeriod build() { Utils.checkRequired(interval, "interval"); + Utils.checkRequired(type, "type"); Utils.checkRequired(unit, "unit"); return new SlidingWindowResetPeriod(this); } diff --git a/src/main/java/com/meteroid/models/SlotFee.java b/src/main/java/com/meteroid/models/SlotFee.java index dd89e73..cf37e80 100644 --- a/src/main/java/com/meteroid/models/SlotFee.java +++ b/src/main/java/com/meteroid/models/SlotFee.java @@ -38,6 +38,9 @@ public final class SlotFee { @JsonInclude(JsonInclude.Include.NON_EMPTY) private JsonField minSlots = JsonField.missing(); + @JsonProperty("type") + private String type = "SLOT"; + @JsonProperty("unit") private String unit; @@ -52,6 +55,7 @@ private SlotFee(Builder builder) { this.initialSlots = builder.initialSlots; this.maxSlots = builder.maxSlots; this.minSlots = builder.minSlots; + this.type = builder.type; this.unit = builder.unit; this.unitRate = builder.unitRate; this.additionalProperties.putAll(builder.additionalProperties); @@ -76,6 +80,7 @@ public Builder toBuilder() { builder.initialSlots = initialSlots; builder.maxSlots = maxSlots; builder.minSlots = minSlots; + builder.type = type; builder.unit = unit; builder.unitRate = unitRate; builder.additionalProperties.putAll(additionalProperties); @@ -109,6 +114,15 @@ public Optional minSlots() { return minSlots.asOptional(); } + /** + * The {@code type} property. + * + * @return the value, never null + */ + public String type() { + return Utils.required(type, "type"); + } + /** * The {@code unit} property. * @@ -158,6 +172,7 @@ public boolean equals(Object o) { return Objects.equals(initialSlots, that.initialSlots) && Objects.equals(maxSlots, that.maxSlots) && Objects.equals(minSlots, that.minSlots) + && Objects.equals(type, that.type) && Objects.equals(unit, that.unit) && Objects.equals(unitRate, that.unitRate) && Objects.equals(additionalProperties, that.additionalProperties); @@ -165,7 +180,8 @@ public boolean equals(Object o) { @Override public int hashCode() { - return Objects.hash(initialSlots, maxSlots, minSlots, unit, unitRate, additionalProperties); + return Objects.hash( + initialSlots, maxSlots, minSlots, type, unit, unitRate, additionalProperties); } @Override @@ -177,6 +193,8 @@ public String toString() { + maxSlots + ", minSlots=" + minSlots + + ", type=" + + type + ", unit=" + unit + ", unitRate=" @@ -191,6 +209,7 @@ public static final class Builder { private Integer initialSlots; private JsonField maxSlots = JsonField.missing(); private JsonField minSlots = JsonField.missing(); + private String type = "SLOT"; private String unit; private BigDecimal unitRate; private final Map additionalProperties = new LinkedHashMap<>(); @@ -230,6 +249,17 @@ public Builder minSlots(Integer minSlots) { return this; } + /** + * The {@code type} property. + * + * @param type the value + * @return this builder + */ + public Builder type(String type) { + this.type = type; + return this; + } + /** * The {@code unit} property. * @@ -294,6 +324,7 @@ public Builder removeAdditionalProperty(String name) { */ public SlotFee build() { Utils.checkRequired(initialSlots, "initial_slots"); + Utils.checkRequired(type, "type"); Utils.checkRequired(unit, "unit"); Utils.checkRequired(unitRate, "unit_rate"); return new SlotFee(this); diff --git a/src/main/java/com/meteroid/models/SlotFeeStructure.java b/src/main/java/com/meteroid/models/SlotFeeStructure.java index 815ab67..530194f 100644 --- a/src/main/java/com/meteroid/models/SlotFeeStructure.java +++ b/src/main/java/com/meteroid/models/SlotFeeStructure.java @@ -30,6 +30,9 @@ public final class SlotFeeStructure { @JsonProperty("slot_unit_name") private String slotUnitName; + @JsonProperty("type") + private String type = "SLOT"; + @JsonProperty("upgrade_policy") private SlotUpgradePolicyEnum upgradePolicy; @@ -40,6 +43,7 @@ private SlotFeeStructure() {} private SlotFeeStructure(Builder builder) { this.downgradePolicy = builder.downgradePolicy; this.slotUnitName = builder.slotUnitName; + this.type = builder.type; this.upgradePolicy = builder.upgradePolicy; this.additionalProperties.putAll(builder.additionalProperties); } @@ -62,6 +66,7 @@ public Builder toBuilder() { Builder builder = new Builder(); builder.downgradePolicy = downgradePolicy; builder.slotUnitName = slotUnitName; + builder.type = type; builder.upgradePolicy = upgradePolicy; builder.additionalProperties.putAll(additionalProperties); return builder; @@ -85,6 +90,15 @@ public String slotUnitName() { return Utils.required(slotUnitName, "slot_unit_name"); } + /** + * The {@code type} property. + * + * @return the value, never null + */ + public String type() { + return Utils.required(type, "type"); + } + /** * The {@code upgrade_policy} property. * @@ -124,13 +138,15 @@ public boolean equals(Object o) { SlotFeeStructure that = (SlotFeeStructure) o; return Objects.equals(downgradePolicy, that.downgradePolicy) && Objects.equals(slotUnitName, that.slotUnitName) + && Objects.equals(type, that.type) && Objects.equals(upgradePolicy, that.upgradePolicy) && Objects.equals(additionalProperties, that.additionalProperties); } @Override public int hashCode() { - return Objects.hash(downgradePolicy, slotUnitName, upgradePolicy, additionalProperties); + return Objects.hash( + downgradePolicy, slotUnitName, type, upgradePolicy, additionalProperties); } @Override @@ -140,6 +156,8 @@ public String toString() { + downgradePolicy + ", slotUnitName=" + slotUnitName + + ", type=" + + type + ", upgradePolicy=" + upgradePolicy + ", additionalProperties=" @@ -151,6 +169,7 @@ public String toString() { public static final class Builder { private SlotDowngradePolicyEnum downgradePolicy; private String slotUnitName; + private String type = "SLOT"; private SlotUpgradePolicyEnum upgradePolicy; private final Map additionalProperties = new LinkedHashMap<>(); @@ -178,6 +197,17 @@ public Builder slotUnitName(String slotUnitName) { return this; } + /** + * The {@code type} property. + * + * @param type the value + * @return this builder + */ + public Builder type(String type) { + this.type = type; + return this; + } + /** * The {@code upgrade_policy} property. * @@ -232,6 +262,7 @@ public Builder removeAdditionalProperty(String name) { public SlotFeeStructure build() { Utils.checkRequired(downgradePolicy, "downgrade_policy"); Utils.checkRequired(slotUnitName, "slot_unit_name"); + Utils.checkRequired(type, "type"); Utils.checkRequired(upgradePolicy, "upgrade_policy"); return new SlotFeeStructure(this); } diff --git a/src/main/java/com/meteroid/models/SlotPlanFee.java b/src/main/java/com/meteroid/models/SlotPlanFee.java index 144341c..c439bfb 100644 --- a/src/main/java/com/meteroid/models/SlotPlanFee.java +++ b/src/main/java/com/meteroid/models/SlotPlanFee.java @@ -46,6 +46,9 @@ public final class SlotPlanFee { @JsonProperty("slot_unit_name") private String slotUnitName; + @JsonProperty("type") + private String type = "SLOT"; + private final Map additionalProperties = new LinkedHashMap<>(); private SlotPlanFee() {} @@ -55,6 +58,7 @@ private SlotPlanFee(Builder builder) { this.quota = builder.quota; this.rates = Utils.copyList(builder.rates); this.slotUnitName = builder.slotUnitName; + this.type = builder.type; this.additionalProperties.putAll(builder.additionalProperties); } @@ -78,6 +82,7 @@ public Builder toBuilder() { builder.quota = quota; builder.rates = Utils.mutableList(rates); builder.slotUnitName = slotUnitName; + builder.type = type; builder.additionalProperties.putAll(additionalProperties); return builder; } @@ -118,6 +123,15 @@ public String slotUnitName() { return Utils.required(slotUnitName, "slot_unit_name"); } + /** + * The {@code type} property. + * + * @return the value, never null + */ + public String type() { + return Utils.required(type, "type"); + } + /** * Properties this version of the SDK does not know, kept as received and sent back. * @@ -150,12 +164,13 @@ public boolean equals(Object o) { && Objects.equals(quota, that.quota) && Objects.equals(rates, that.rates) && Objects.equals(slotUnitName, that.slotUnitName) + && Objects.equals(type, that.type) && Objects.equals(additionalProperties, that.additionalProperties); } @Override public int hashCode() { - return Objects.hash(minimumCount, quota, rates, slotUnitName, additionalProperties); + return Objects.hash(minimumCount, quota, rates, slotUnitName, type, additionalProperties); } @Override @@ -169,6 +184,8 @@ public String toString() { + rates + ", slotUnitName=" + slotUnitName + + ", type=" + + type + ", additionalProperties=" + additionalProperties + "}"; @@ -180,6 +197,7 @@ public static final class Builder { private JsonField quota = JsonField.missing(); private List rates; private String slotUnitName; + private String type = "SLOT"; private final Map additionalProperties = new LinkedHashMap<>(); private Builder() {} @@ -242,6 +260,17 @@ public Builder slotUnitName(String slotUnitName) { return this; } + /** + * The {@code type} property. + * + * @param type the value + * @return this builder + */ + public Builder type(String type) { + this.type = type; + return this; + } + /** * A property the SDK does not know, sent along. * @@ -285,6 +314,7 @@ public Builder removeAdditionalProperty(String name) { public SlotPlanFee build() { Utils.checkRequired(rates, "rates"); Utils.checkRequired(slotUnitName, "slot_unit_name"); + Utils.checkRequired(type, "type"); return new SlotPlanFee(this); } } diff --git a/src/main/java/com/meteroid/models/SlotPricing.java b/src/main/java/com/meteroid/models/SlotPricing.java index 18aea13..f8b4819 100644 --- a/src/main/java/com/meteroid/models/SlotPricing.java +++ b/src/main/java/com/meteroid/models/SlotPricing.java @@ -35,6 +35,9 @@ public final class SlotPricing { @JsonInclude(JsonInclude.Include.NON_EMPTY) private JsonField minSlots = JsonField.missing(); + @JsonProperty("type") + private String type = "SLOT"; + @JsonProperty("unit_rate") private BigDecimal unitRate; @@ -45,6 +48,7 @@ private SlotPricing() {} private SlotPricing(Builder builder) { this.maxSlots = builder.maxSlots; this.minSlots = builder.minSlots; + this.type = builder.type; this.unitRate = builder.unitRate; this.additionalProperties.putAll(builder.additionalProperties); } @@ -67,6 +71,7 @@ public Builder toBuilder() { Builder builder = new Builder(); builder.maxSlots = maxSlots; builder.minSlots = minSlots; + builder.type = type; builder.unitRate = unitRate; builder.additionalProperties.putAll(additionalProperties); return builder; @@ -90,6 +95,15 @@ public Optional minSlots() { return minSlots.asOptional(); } + /** + * The {@code type} property. + * + * @return the value, never null + */ + public String type() { + return Utils.required(type, "type"); + } + /** * The {@code unit_rate} property. * @@ -129,13 +143,14 @@ public boolean equals(Object o) { SlotPricing that = (SlotPricing) o; return Objects.equals(maxSlots, that.maxSlots) && Objects.equals(minSlots, that.minSlots) + && Objects.equals(type, that.type) && Objects.equals(unitRate, that.unitRate) && Objects.equals(additionalProperties, that.additionalProperties); } @Override public int hashCode() { - return Objects.hash(maxSlots, minSlots, unitRate, additionalProperties); + return Objects.hash(maxSlots, minSlots, type, unitRate, additionalProperties); } @Override @@ -145,6 +160,8 @@ public String toString() { + maxSlots + ", minSlots=" + minSlots + + ", type=" + + type + ", unitRate=" + unitRate + ", additionalProperties=" @@ -156,6 +173,7 @@ public String toString() { public static final class Builder { private JsonField maxSlots = JsonField.missing(); private JsonField minSlots = JsonField.missing(); + private String type = "SLOT"; private BigDecimal unitRate; private final Map additionalProperties = new LinkedHashMap<>(); @@ -183,6 +201,17 @@ public Builder minSlots(Integer minSlots) { return this; } + /** + * The {@code type} property. + * + * @param type the value + * @return this builder + */ + public Builder type(String type) { + this.type = type; + return this; + } + /** * The {@code unit_rate} property. * @@ -235,6 +264,7 @@ public Builder removeAdditionalProperty(String name) { * @throws IllegalStateException when a required property is not set */ public SlotPricing build() { + Utils.checkRequired(type, "type"); Utils.checkRequired(unitRate, "unit_rate"); return new SlotPricing(this); } diff --git a/src/main/java/com/meteroid/models/Subscription.java b/src/main/java/com/meteroid/models/Subscription.java index 72b5b05..8d90707 100644 --- a/src/main/java/com/meteroid/models/Subscription.java +++ b/src/main/java/com/meteroid/models/Subscription.java @@ -128,6 +128,14 @@ public final class Subscription { @JsonInclude(JsonInclude.Include.NON_EMPTY) private JsonField trialDuration = JsonField.missing(); + @JsonProperty("usage_filter") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField usageFilter = JsonField.missing(); + + @JsonProperty("usage_filter_effective_from") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField usageFilterEffectiveFrom = JsonField.missing(); + private final Map additionalProperties = new LinkedHashMap<>(); private Subscription() {} @@ -163,6 +171,8 @@ private Subscription(Builder builder) { this.status = builder.status; this.taxInclusive = builder.taxInclusive; this.trialDuration = builder.trialDuration; + this.usageFilter = builder.usageFilter; + this.usageFilterEffectiveFrom = builder.usageFilterEffectiveFrom; this.additionalProperties.putAll(builder.additionalProperties); } @@ -212,6 +222,8 @@ public Builder toBuilder() { builder.status = status; builder.taxInclusive = taxInclusive; builder.trialDuration = trialDuration; + builder.usageFilter = usageFilter; + builder.usageFilterEffectiveFrom = usageFilterEffectiveFrom; builder.additionalProperties.putAll(additionalProperties); return builder; } @@ -486,6 +498,25 @@ public Optional trialDuration() { return trialDuration.asOptional(); } + /** + * The {@code usage_filter} property. + * + * @return the value, empty when unset or null + */ + public Optional usageFilter() { + return usageFilter.asOptional(); + } + + /** + * When the current usage filter, or its removal, started to apply: the start of the usage + * neither this subscription nor the customer's others had invoiced when it was set. + * + * @return the value, empty when unset or null + */ + public Optional usageFilterEffectiveFrom() { + return usageFilterEffectiveFrom.asOptional(); + } + /** * Properties this version of the SDK does not know, kept as received and sent back. * @@ -544,6 +575,8 @@ public boolean equals(Object o) { && Objects.equals(status, that.status) && Objects.equals(taxInclusive, that.taxInclusive) && Objects.equals(trialDuration, that.trialDuration) + && Objects.equals(usageFilter, that.usageFilter) + && Objects.equals(usageFilterEffectiveFrom, that.usageFilterEffectiveFrom) && Objects.equals(additionalProperties, that.additionalProperties); } @@ -580,6 +613,8 @@ public int hashCode() { status, taxInclusive, trialDuration, + usageFilter, + usageFilterEffectiveFrom, additionalProperties); } @@ -646,6 +681,10 @@ public String toString() { + taxInclusive + ", trialDuration=" + trialDuration + + ", usageFilter=" + + usageFilter + + ", usageFilterEffectiveFrom=" + + usageFilterEffectiveFrom + ", additionalProperties=" + additionalProperties + "}"; @@ -683,6 +722,8 @@ public static final class Builder { private SubscriptionStatusEnum status; private Boolean taxInclusive; private JsonField trialDuration = JsonField.missing(); + private JsonField usageFilter = JsonField.missing(); + private JsonField usageFilterEffectiveFrom = JsonField.missing(); private final Map additionalProperties = new LinkedHashMap<>(); private Builder() {} @@ -1018,6 +1059,29 @@ public Builder trialDuration(Integer trialDuration) { return this; } + /** + * The {@code usage_filter} property. + * + * @param usageFilter the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder usageFilter(UsageFilter usageFilter) { + this.usageFilter = JsonField.ofNullable(usageFilter); + return this; + } + + /** + * When the current usage filter, or its removal, started to apply: the start of the usage + * neither this subscription nor the customer's others had invoiced when it was set. + * + * @param usageFilterEffectiveFrom the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder usageFilterEffectiveFrom(OffsetDateTime usageFilterEffectiveFrom) { + this.usageFilterEffectiveFrom = JsonField.ofNullable(usageFilterEffectiveFrom); + return this; + } + /** * A property the SDK does not know, sent along. * diff --git a/src/main/java/com/meteroid/models/SubscriptionAddOnParameterization.java b/src/main/java/com/meteroid/models/SubscriptionAddOnParameterization.java index f162a01..2bd0a60 100644 --- a/src/main/java/com/meteroid/models/SubscriptionAddOnParameterization.java +++ b/src/main/java/com/meteroid/models/SubscriptionAddOnParameterization.java @@ -38,6 +38,9 @@ public final class SubscriptionAddOnParameterization { @JsonInclude(JsonInclude.Include.NON_EMPTY) private JsonField initialSlotCount = JsonField.missing(); + @JsonProperty("type") + private String type = "PARAMETERIZATION"; + private final Map additionalProperties = new LinkedHashMap<>(); private SubscriptionAddOnParameterization() {} @@ -46,6 +49,7 @@ private SubscriptionAddOnParameterization(Builder builder) { this.billingPeriod = builder.billingPeriod; this.committedCapacity = builder.committedCapacity; this.initialSlotCount = builder.initialSlotCount; + this.type = builder.type; this.additionalProperties.putAll(builder.additionalProperties); } @@ -68,6 +72,7 @@ public Builder toBuilder() { builder.billingPeriod = billingPeriod; builder.committedCapacity = committedCapacity; builder.initialSlotCount = initialSlotCount; + builder.type = type; builder.additionalProperties.putAll(additionalProperties); return builder; } @@ -99,6 +104,15 @@ public Optional initialSlotCount() { return initialSlotCount.asOptional(); } + /** + * The {@code type} property. + * + * @return the value, never null + */ + public String type() { + return Utils.required(type, "type"); + } + /** * Properties this version of the SDK does not know, kept as received and sent back. * @@ -130,13 +144,14 @@ public boolean equals(Object o) { return Objects.equals(billingPeriod, that.billingPeriod) && Objects.equals(committedCapacity, that.committedCapacity) && Objects.equals(initialSlotCount, that.initialSlotCount) + && Objects.equals(type, that.type) && Objects.equals(additionalProperties, that.additionalProperties); } @Override public int hashCode() { return Objects.hash( - billingPeriod, committedCapacity, initialSlotCount, additionalProperties); + billingPeriod, committedCapacity, initialSlotCount, type, additionalProperties); } @Override @@ -148,6 +163,8 @@ public String toString() { + committedCapacity + ", initialSlotCount=" + initialSlotCount + + ", type=" + + type + ", additionalProperties=" + additionalProperties + "}"; @@ -158,6 +175,7 @@ public static final class Builder { private JsonField billingPeriod = JsonField.missing(); private JsonField committedCapacity = JsonField.missing(); private JsonField initialSlotCount = JsonField.missing(); + private String type = "PARAMETERIZATION"; private final Map additionalProperties = new LinkedHashMap<>(); private Builder() {} @@ -195,6 +213,17 @@ public Builder initialSlotCount(Integer initialSlotCount) { return this; } + /** + * The {@code type} property. + * + * @param type the value + * @return this builder + */ + public Builder type(String type) { + this.type = type; + return this; + } + /** * A property the SDK does not know, sent along. * @@ -236,6 +265,7 @@ public Builder removeAdditionalProperty(String name) { * @throws IllegalStateException when a required property is not set */ public SubscriptionAddOnParameterization build() { + Utils.checkRequired(type, "type"); return new SubscriptionAddOnParameterization(this); } } diff --git a/src/main/java/com/meteroid/models/SubscriptionAddOnPriceOverride.java b/src/main/java/com/meteroid/models/SubscriptionAddOnPriceOverride.java index 671845c..d150143 100644 --- a/src/main/java/com/meteroid/models/SubscriptionAddOnPriceOverride.java +++ b/src/main/java/com/meteroid/models/SubscriptionAddOnPriceOverride.java @@ -33,6 +33,9 @@ public final class SubscriptionAddOnPriceOverride { @JsonProperty("price_entry") private PriceEntry priceEntry; + @JsonProperty("type") + private String type = "PRICE_OVERRIDE"; + private final Map additionalProperties = new LinkedHashMap<>(); private SubscriptionAddOnPriceOverride() {} @@ -40,6 +43,7 @@ private SubscriptionAddOnPriceOverride() {} private SubscriptionAddOnPriceOverride(Builder builder) { this.name = builder.name; this.priceEntry = builder.priceEntry; + this.type = builder.type; this.additionalProperties.putAll(builder.additionalProperties); } @@ -61,6 +65,7 @@ public Builder toBuilder() { Builder builder = new Builder(); builder.name = name; builder.priceEntry = priceEntry; + builder.type = type; builder.additionalProperties.putAll(additionalProperties); return builder; } @@ -83,6 +88,15 @@ public PriceEntry priceEntry() { return Utils.required(priceEntry, "price_entry"); } + /** + * The {@code type} property. + * + * @return the value, never null + */ + public String type() { + return Utils.required(type, "type"); + } + /** * Properties this version of the SDK does not know, kept as received and sent back. * @@ -113,12 +127,13 @@ public boolean equals(Object o) { SubscriptionAddOnPriceOverride that = (SubscriptionAddOnPriceOverride) o; return Objects.equals(name, that.name) && Objects.equals(priceEntry, that.priceEntry) + && Objects.equals(type, that.type) && Objects.equals(additionalProperties, that.additionalProperties); } @Override public int hashCode() { - return Objects.hash(name, priceEntry, additionalProperties); + return Objects.hash(name, priceEntry, type, additionalProperties); } @Override @@ -128,6 +143,8 @@ public String toString() { + name + ", priceEntry=" + priceEntry + + ", type=" + + type + ", additionalProperties=" + additionalProperties + "}"; @@ -137,6 +154,7 @@ public String toString() { public static final class Builder { private JsonField name = JsonField.missing(); private PriceEntry priceEntry; + private String type = "PRICE_OVERRIDE"; private final Map additionalProperties = new LinkedHashMap<>(); private Builder() {} @@ -163,6 +181,17 @@ public Builder priceEntry(PriceEntry priceEntry) { return this; } + /** + * The {@code type} property. + * + * @param type the value + * @return this builder + */ + public Builder type(String type) { + this.type = type; + return this; + } + /** * A property the SDK does not know, sent along. * @@ -205,6 +234,7 @@ public Builder removeAdditionalProperty(String name) { */ public SubscriptionAddOnPriceOverride build() { Utils.checkRequired(priceEntry, "price_entry"); + Utils.checkRequired(type, "type"); return new SubscriptionAddOnPriceOverride(this); } } diff --git a/src/main/java/com/meteroid/models/SubscriptionCreateRequest.java b/src/main/java/com/meteroid/models/SubscriptionCreateRequest.java index 45fb9cc..0ca9461 100644 --- a/src/main/java/com/meteroid/models/SubscriptionCreateRequest.java +++ b/src/main/java/com/meteroid/models/SubscriptionCreateRequest.java @@ -88,6 +88,9 @@ public final class SubscriptionCreateRequest { @JsonProperty("trial_days") private Integer trialDays; + @JsonProperty("usage_filter") + private UsageFilter usageFilter; + @JsonProperty("version") private Integer version; @@ -115,6 +118,7 @@ private SubscriptionCreateRequest(Builder builder) { this.skipPastInvoices = builder.skipPastInvoices; this.startDate = builder.startDate; this.trialDays = builder.trialDays; + this.usageFilter = builder.usageFilter; this.version = builder.version; this.additionalProperties.putAll(builder.additionalProperties); } @@ -154,6 +158,7 @@ public Builder toBuilder() { builder.skipPastInvoices = skipPastInvoices; builder.startDate = startDate; builder.trialDays = trialDays; + builder.usageFilter = usageFilter; builder.version = version; builder.additionalProperties.putAll(additionalProperties); return builder; @@ -215,7 +220,10 @@ public Optional chargeAutomatically() { } /** - * The {@code coupon_codes} property. + * Codes of the coupons to apply. A code matches whatever the case of its ASCII letters; when + * several coupons differ from it only in that case, the one with exactly that code applies. A + * code that names no live coupon, or several differing only in case, refuses the request with + * 400 listing the codes (unknown codes used to be ignored silently). * * @return the value, empty when unset */ @@ -333,6 +341,16 @@ public Optional trialDays() { return Optional.ofNullable(trialDays); } + /** + * Bill only the customer's events whose property has this value. Omit to bill the events no + * usage filter of the customer's other subscriptions matches. + * + * @return the value, empty when unset + */ + public Optional usageFilter() { + return Optional.ofNullable(usageFilter); + } + /** * The {@code version} property. * @@ -389,6 +407,7 @@ public boolean equals(Object o) { && Objects.equals(skipPastInvoices, that.skipPastInvoices) && Objects.equals(startDate, that.startDate) && Objects.equals(trialDays, that.trialDays) + && Objects.equals(usageFilter, that.usageFilter) && Objects.equals(version, that.version) && Objects.equals(additionalProperties, that.additionalProperties); } @@ -415,6 +434,7 @@ public int hashCode() { skipPastInvoices, startDate, trialDays, + usageFilter, version, additionalProperties); } @@ -460,6 +480,8 @@ public String toString() { + startDate + ", trialDays=" + trialDays + + ", usageFilter=" + + usageFilter + ", version=" + version + ", additionalProperties=" @@ -488,6 +510,7 @@ public static final class Builder { private Boolean skipPastInvoices; private LocalDate startDate; private Integer trialDays; + private UsageFilter usageFilter; private Integer version; private final Map additionalProperties = new LinkedHashMap<>(); @@ -576,7 +599,10 @@ public Builder chargeAutomatically(Boolean chargeAutomatically) { } /** - * The {@code coupon_codes} property. + * Codes of the coupons to apply. A code matches whatever the case of its ASCII letters; + * when several coupons differ from it only in that case, the one with exactly that code + * applies. A code that names no live coupon, or several differing only in case, refuses the + * request with 400 listing the codes (unknown codes used to be ignored silently). * * @param couponCodes the value * @return this builder @@ -734,6 +760,18 @@ public Builder trialDays(Integer trialDays) { return this; } + /** + * Bill only the customer's events whose property has this value. Omit to bill the events no + * usage filter of the customer's other subscriptions matches. + * + * @param usageFilter the value + * @return this builder + */ + public Builder usageFilter(UsageFilter usageFilter) { + this.usageFilter = usageFilter; + return this; + } + /** * The {@code version} property. * diff --git a/src/main/java/com/meteroid/models/SubscriptionCredit.java b/src/main/java/com/meteroid/models/SubscriptionCredit.java new file mode 100644 index 0000000..674ac9d --- /dev/null +++ b/src/main/java/com/meteroid/models/SubscriptionCredit.java @@ -0,0 +1,233 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.Utils; + +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; + +/** + * Credit on account that only one subscription can use. + * + *

Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonAutoDetect( + getterVisibility = Visibility.NONE, + isGetterVisibility = Visibility.NONE, + setterVisibility = Visibility.NONE) +public final class SubscriptionCredit { + @JsonProperty("credit_on_account") + private Long creditOnAccount; + + @JsonProperty("subscription_id") + private String subscriptionId; + + private final Map additionalProperties = new LinkedHashMap<>(); + + private SubscriptionCredit() {} + + private SubscriptionCredit(Builder builder) { + this.creditOnAccount = builder.creditOnAccount; + this.subscriptionId = builder.subscriptionId; + this.additionalProperties.putAll(builder.additionalProperties); + } + + /** + * A builder of {@code SubscriptionCredit}. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * A builder starting from this value. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.creditOnAccount = creditOnAccount; + builder.subscriptionId = subscriptionId; + builder.additionalProperties.putAll(additionalProperties); + return builder; + } + + /** + * In minor units of the wallet. + * + * @return the value, never null + */ + public Long creditOnAccount() { + return Utils.required(creditOnAccount, "credit_on_account"); + } + + /** + * The {@code subscription_id} property. + * + * @return the value, never null + */ + public String subscriptionId() { + return Utils.required(subscriptionId, "subscription_id"); + } + + /** + * Properties this version of the SDK does not know, kept as received and sent back. + * + * @return the properties by name, unmodifiable + */ + public Map additionalProperties() { + return Collections.unmodifiableMap(additionalProperties); + } + + @JsonAnyGetter + private Map anyProperties() { + return additionalProperties; + } + + @JsonAnySetter + private void putAnyProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SubscriptionCredit that = (SubscriptionCredit) o; + return Objects.equals(creditOnAccount, that.creditOnAccount) + && Objects.equals(subscriptionId, that.subscriptionId) + && Objects.equals(additionalProperties, that.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(creditOnAccount, subscriptionId, additionalProperties); + } + + @Override + public String toString() { + return "SubscriptionCredit{" + + "creditOnAccount=" + + creditOnAccount + + ", subscriptionId=" + + subscriptionId + + ", additionalProperties=" + + additionalProperties + + "}"; + } + + /** Builds {@link SubscriptionCredit}. */ + public static final class Builder { + private Long creditOnAccount; + private String subscriptionId; + private final Map additionalProperties = new LinkedHashMap<>(); + + private Builder() {} + + /** + * In minor units of the wallet. + * + * @param creditOnAccount the value + * @return this builder + */ + public Builder creditOnAccount(Long creditOnAccount) { + this.creditOnAccount = creditOnAccount; + return this; + } + + /** + * The {@code subscription_id} property. + * + * @param subscriptionId the value + * @return this builder + */ + public Builder subscriptionId(String subscriptionId) { + this.subscriptionId = subscriptionId; + return this; + } + + /** + * A property the SDK does not know, sent along. + * + * @param name the property name + * @param value the JSON value + * @return this builder + */ + public Builder putAdditionalProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + return this; + } + + /** + * Properties the SDK does not know, sent along. + * + * @param additionalProperties the properties by name + * @return this builder + */ + public Builder putAllAdditionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + + /** + * Leaves out a property the SDK does not know. + * + * @param name the property name + * @return this builder + */ + public Builder removeAdditionalProperty(String name) { + additionalProperties.remove(name); + return this; + } + + /** + * The {@code SubscriptionCredit}. + * + * @return the immutable value + * @throws IllegalStateException when a required property is not set + */ + public SubscriptionCredit build() { + Utils.checkRequired(creditOnAccount, "credit_on_account"); + Utils.checkRequired(subscriptionId, "subscription_id"); + return new SubscriptionCredit(this); + } + } + + /** + * Parse {@code json} as {@code SubscriptionCredit}. + * + * @param json the JSON text + * @return the value + * @throws com.meteroid.exceptions.InvalidDataException if it is not valid JSON of this shape + */ + public static SubscriptionCredit fromJson(String json) { + return Utils.parse(json, SubscriptionCredit.class); + } + + /** + * This value as JSON. + * + * @return the JSON text + */ + public String toJson() { + return Utils.json(this); + } +} diff --git a/src/main/java/com/meteroid/models/SubscriptionDetails.java b/src/main/java/com/meteroid/models/SubscriptionDetails.java index 3ffffa2..e40a507 100644 --- a/src/main/java/com/meteroid/models/SubscriptionDetails.java +++ b/src/main/java/com/meteroid/models/SubscriptionDetails.java @@ -146,6 +146,14 @@ public final class SubscriptionDetails { @JsonInclude(JsonInclude.Include.NON_EMPTY) private JsonField trialDuration = JsonField.missing(); + @JsonProperty("usage_filter") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField usageFilter = JsonField.missing(); + + @JsonProperty("usage_filter_effective_from") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField usageFilterEffectiveFrom = JsonField.missing(); + private final Map additionalProperties = new LinkedHashMap<>(); private SubscriptionDetails() {} @@ -186,6 +194,8 @@ private SubscriptionDetails(Builder builder) { this.status = builder.status; this.taxInclusive = builder.taxInclusive; this.trialDuration = builder.trialDuration; + this.usageFilter = builder.usageFilter; + this.usageFilterEffectiveFrom = builder.usageFilterEffectiveFrom; this.additionalProperties.putAll(builder.additionalProperties); } @@ -240,6 +250,8 @@ public Builder toBuilder() { builder.status = status; builder.taxInclusive = taxInclusive; builder.trialDuration = trialDuration; + builder.usageFilter = usageFilter; + builder.usageFilterEffectiveFrom = usageFilterEffectiveFrom; builder.additionalProperties.putAll(additionalProperties); return builder; } @@ -559,6 +571,25 @@ public Optional trialDuration() { return trialDuration.asOptional(); } + /** + * The {@code usage_filter} property. + * + * @return the value, empty when unset or null + */ + public Optional usageFilter() { + return usageFilter.asOptional(); + } + + /** + * When the current usage filter, or its removal, started to apply: the start of the usage + * neither this subscription nor the customer's others had invoiced when it was set. + * + * @return the value, empty when unset or null + */ + public Optional usageFilterEffectiveFrom() { + return usageFilterEffectiveFrom.asOptional(); + } + /** * Properties this version of the SDK does not know, kept as received and sent back. * @@ -622,6 +653,8 @@ public boolean equals(Object o) { && Objects.equals(status, that.status) && Objects.equals(taxInclusive, that.taxInclusive) && Objects.equals(trialDuration, that.trialDuration) + && Objects.equals(usageFilter, that.usageFilter) + && Objects.equals(usageFilterEffectiveFrom, that.usageFilterEffectiveFrom) && Objects.equals(additionalProperties, that.additionalProperties); } @@ -663,6 +696,8 @@ public int hashCode() { status, taxInclusive, trialDuration, + usageFilter, + usageFilterEffectiveFrom, additionalProperties); } @@ -739,6 +774,10 @@ public String toString() { + taxInclusive + ", trialDuration=" + trialDuration + + ", usageFilter=" + + usageFilter + + ", usageFilterEffectiveFrom=" + + usageFilterEffectiveFrom + ", additionalProperties=" + additionalProperties + "}"; @@ -781,6 +820,8 @@ public static final class Builder { private SubscriptionStatusEnum status; private Boolean taxInclusive; private JsonField trialDuration = JsonField.missing(); + private JsonField usageFilter = JsonField.missing(); + private JsonField usageFilterEffectiveFrom = JsonField.missing(); private final Map additionalProperties = new LinkedHashMap<>(); private Builder() {} @@ -1226,6 +1267,29 @@ public Builder trialDuration(Integer trialDuration) { return this; } + /** + * The {@code usage_filter} property. + * + * @param usageFilter the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder usageFilter(UsageFilter usageFilter) { + this.usageFilter = JsonField.ofNullable(usageFilter); + return this; + } + + /** + * When the current usage filter, or its removal, started to apply: the start of the usage + * neither this subscription nor the customer's others had invoiced when it was set. + * + * @param usageFilterEffectiveFrom the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder usageFilterEffectiveFrom(OffsetDateTime usageFilterEffectiveFrom) { + this.usageFilterEffectiveFrom = JsonField.ofNullable(usageFilterEffectiveFrom); + return this; + } + /** * A property the SDK does not know, sent along. * diff --git a/src/main/java/com/meteroid/models/SubscriptionFee.java b/src/main/java/com/meteroid/models/SubscriptionFee.java index ef97743..cdb506c 100644 --- a/src/main/java/com/meteroid/models/SubscriptionFee.java +++ b/src/main/java/com/meteroid/models/SubscriptionFee.java @@ -36,7 +36,8 @@ @JsonSubTypes.Type(value = SubscriptionFee.Recurring.class, name = "RECURRING"), @JsonSubTypes.Type(value = SubscriptionFee.Capacity.class, name = "CAPACITY"), @JsonSubTypes.Type(value = SubscriptionFee.Slot.class, name = "SLOT"), - @JsonSubTypes.Type(value = SubscriptionFee.Usage.class, name = "USAGE") + @JsonSubTypes.Type(value = SubscriptionFee.Usage.class, name = "USAGE"), + @JsonSubTypes.Type(value = SubscriptionFee.Credit.class, name = "CREDIT") }) @JsonInclude(JsonInclude.Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) @@ -188,6 +189,28 @@ public final Usage asUsage() { throw new IllegalStateException("not the USAGE variant: " + type()); } + /** + * Whether this is the {@code CREDIT} variant. + * + * @return whether it is + */ + public final boolean isCredit() { + return this instanceof Credit; + } + + /** + * This value as the {@code CREDIT} variant. + * + * @return the variant + * @throws IllegalStateException if this is another variant + */ + public final Credit asCredit() { + if (this instanceof Credit) { + return (Credit) this; + } + throw new IllegalStateException("not the CREDIT variant: " + type()); + } + /** * Whether this is a variant this version of the SDK does not know. * @@ -273,6 +296,14 @@ public interface Visitor { */ R visitUsage(UsageFee value); + /** + * Visits the {@code CREDIT} variant. + * + * @param value the variant + * @return the result + */ + R visitCredit(CreditFee value); + /** * Visits a variant this version of the SDK does not know. * @@ -732,6 +763,77 @@ public R accept(Visitor visitor) { } } + /** The {@code CREDIT} variant. */ + @JsonTypeName("CREDIT") + public static final class Credit extends SubscriptionFee { + @JsonUnwrapped + @JsonIgnoreProperties(value = "type", allowSetters = true) + private CreditFee data; + + private Credit() {} + + /** + * The variant holding {@code data}. + * + * @param data the value of the variant + */ + public Credit(CreditFee data) { + this.data = Objects.requireNonNull(data, "data"); + } + + /** + * The variant holding {@code data}. + * + * @param data the value of the variant + * @return the variant + */ + public static Credit of(CreditFee data) { + return new Credit(data); + } + + @Override + @JsonProperty("type") + public String type() { + return "CREDIT"; + } + + /** + * The value of the variant. + * + * @return the value + */ + public CreditFee data() { + return data; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Credit that = (Credit) o; + return Objects.equals(data, that.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + return "Credit{" + "data=" + data + "}"; + } + + @Override + public R accept(Visitor visitor) { + return visitor.visitCredit(data); + } + } + /** A variant this version of the SDK does not know. */ public static final class Unrecognized extends SubscriptionFee { @JsonProperty("type") diff --git a/src/main/java/com/meteroid/models/SubscriptionUpdateRequest.java b/src/main/java/com/meteroid/models/SubscriptionUpdateRequest.java index cbcd420..e5e5fac 100644 --- a/src/main/java/com/meteroid/models/SubscriptionUpdateRequest.java +++ b/src/main/java/com/meteroid/models/SubscriptionUpdateRequest.java @@ -53,6 +53,10 @@ public final class SubscriptionUpdateRequest { @JsonInclude(JsonInclude.Include.NON_EMPTY) private JsonField purchaseOrder = JsonField.missing(); + @JsonProperty("usage_filter") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField usageFilter = JsonField.missing(); + private final Map additionalProperties = new LinkedHashMap<>(); private SubscriptionUpdateRequest() {} @@ -65,6 +69,7 @@ private SubscriptionUpdateRequest(Builder builder) { this.netTerms = builder.netTerms; this.paymentMethodsConfig = builder.paymentMethodsConfig; this.purchaseOrder = builder.purchaseOrder; + this.usageFilter = builder.usageFilter; this.additionalProperties.putAll(builder.additionalProperties); } @@ -91,6 +96,7 @@ public Builder toBuilder() { builder.netTerms = netTerms; builder.paymentMethodsConfig = paymentMethodsConfig; builder.purchaseOrder = purchaseOrder; + builder.usageFilter = usageFilter; builder.additionalProperties.putAll(additionalProperties); return builder; } @@ -160,6 +166,15 @@ public Optional purchaseOrder() { return purchaseOrder.asOptional(); } + /** + * The {@code usage_filter} property. + * + * @return the value, empty when unset or null + */ + public Optional usageFilter() { + return usageFilter.asOptional(); + } + /** * Properties this version of the SDK does not know, kept as received and sent back. * @@ -195,6 +210,7 @@ public boolean equals(Object o) { && Objects.equals(netTerms, that.netTerms) && Objects.equals(paymentMethodsConfig, that.paymentMethodsConfig) && Objects.equals(purchaseOrder, that.purchaseOrder) + && Objects.equals(usageFilter, that.usageFilter) && Objects.equals(additionalProperties, that.additionalProperties); } @@ -208,6 +224,7 @@ public int hashCode() { netTerms, paymentMethodsConfig, purchaseOrder, + usageFilter, additionalProperties); } @@ -228,6 +245,8 @@ public String toString() { + paymentMethodsConfig + ", purchaseOrder=" + purchaseOrder + + ", usageFilter=" + + usageFilter + ", additionalProperties=" + additionalProperties + "}"; @@ -242,6 +261,7 @@ public static final class Builder { private JsonField netTerms = JsonField.missing(); private JsonField paymentMethodsConfig = JsonField.missing(); private JsonField purchaseOrder = JsonField.missing(); + private JsonField usageFilter = JsonField.missing(); private final Map additionalProperties = new LinkedHashMap<>(); private Builder() {} @@ -325,6 +345,17 @@ public Builder purchaseOrder(String purchaseOrder) { return this; } + /** + * The {@code usage_filter} property. + * + * @param usageFilter the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder usageFilter(UsageFilter usageFilter) { + this.usageFilter = JsonField.ofNullable(usageFilter); + return this; + } + /** * A property the SDK does not know, sent along. * diff --git a/src/main/java/com/meteroid/models/TextConfigValue.java b/src/main/java/com/meteroid/models/TextConfigValue.java index 4ebf5b8..1f76f6e 100644 --- a/src/main/java/com/meteroid/models/TextConfigValue.java +++ b/src/main/java/com/meteroid/models/TextConfigValue.java @@ -28,6 +28,9 @@ isGetterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE) public final class TextConfigValue { + @JsonProperty("kind") + private String kind = "TEXT"; + @JsonProperty("value") private String value; @@ -36,6 +39,7 @@ public final class TextConfigValue { private TextConfigValue() {} private TextConfigValue(Builder builder) { + this.kind = builder.kind; this.value = builder.value; this.additionalProperties.putAll(builder.additionalProperties); } @@ -56,11 +60,21 @@ public static Builder builder() { */ public Builder toBuilder() { Builder builder = new Builder(); + builder.kind = kind; builder.value = value; builder.additionalProperties.putAll(additionalProperties); return builder; } + /** + * The {@code kind} property. + * + * @return the value, never null + */ + public String kind() { + return Utils.required(kind, "kind"); + } + /** * The {@code value} property. * @@ -98,19 +112,22 @@ public boolean equals(Object o) { return false; } TextConfigValue that = (TextConfigValue) o; - return Objects.equals(value, that.value) + return Objects.equals(kind, that.kind) + && Objects.equals(value, that.value) && Objects.equals(additionalProperties, that.additionalProperties); } @Override public int hashCode() { - return Objects.hash(value, additionalProperties); + return Objects.hash(kind, value, additionalProperties); } @Override public String toString() { return "TextConfigValue{" - + "value=" + + "kind=" + + kind + + ", value=" + value + ", additionalProperties=" + additionalProperties @@ -119,11 +136,23 @@ public String toString() { /** Builds {@link TextConfigValue}. */ public static final class Builder { + private String kind = "TEXT"; private String value; private final Map additionalProperties = new LinkedHashMap<>(); private Builder() {} + /** + * The {@code kind} property. + * + * @param kind the value + * @return this builder + */ + public Builder kind(String kind) { + this.kind = kind; + return this; + } + /** * The {@code value} property. * @@ -176,6 +205,7 @@ public Builder removeAdditionalProperty(String name) { * @throws IllegalStateException when a required property is not set */ public TextConfigValue build() { + Utils.checkRequired(kind, "kind"); Utils.checkRequired(value, "value"); return new TextConfigValue(this); } diff --git a/src/main/java/com/meteroid/models/TieredPlanPricing.java b/src/main/java/com/meteroid/models/TieredPlanPricing.java index dfddd69..ecc6ff5 100644 --- a/src/main/java/com/meteroid/models/TieredPlanPricing.java +++ b/src/main/java/com/meteroid/models/TieredPlanPricing.java @@ -35,6 +35,9 @@ public final class TieredPlanPricing { @JsonProperty("tiers") private List tiers; + @JsonProperty("type") + private String type = "TIERED"; + private final Map additionalProperties = new LinkedHashMap<>(); private TieredPlanPricing() {} @@ -42,6 +45,7 @@ private TieredPlanPricing() {} private TieredPlanPricing(Builder builder) { this.blockSize = builder.blockSize; this.tiers = Utils.copyList(builder.tiers); + this.type = builder.type; this.additionalProperties.putAll(builder.additionalProperties); } @@ -63,6 +67,7 @@ public Builder toBuilder() { Builder builder = new Builder(); builder.blockSize = blockSize; builder.tiers = Utils.mutableList(tiers); + builder.type = type; builder.additionalProperties.putAll(additionalProperties); return builder; } @@ -85,6 +90,15 @@ public List tiers() { return Utils.required(tiers, "tiers"); } + /** + * The {@code type} property. + * + * @return the value, never null + */ + public String type() { + return Utils.required(type, "type"); + } + /** * Properties this version of the SDK does not know, kept as received and sent back. * @@ -115,12 +129,13 @@ public boolean equals(Object o) { TieredPlanPricing that = (TieredPlanPricing) o; return Objects.equals(blockSize, that.blockSize) && Objects.equals(tiers, that.tiers) + && Objects.equals(type, that.type) && Objects.equals(additionalProperties, that.additionalProperties); } @Override public int hashCode() { - return Objects.hash(blockSize, tiers, additionalProperties); + return Objects.hash(blockSize, tiers, type, additionalProperties); } @Override @@ -130,6 +145,8 @@ public String toString() { + blockSize + ", tiers=" + tiers + + ", type=" + + type + ", additionalProperties=" + additionalProperties + "}"; @@ -139,6 +156,7 @@ public String toString() { public static final class Builder { private JsonField blockSize = JsonField.missing(); private List tiers; + private String type = "TIERED"; private final Map additionalProperties = new LinkedHashMap<>(); private Builder() {} @@ -179,6 +197,17 @@ public Builder addTiersItem(TierRow item) { return this; } + /** + * The {@code type} property. + * + * @param type the value + * @return this builder + */ + public Builder type(String type) { + this.type = type; + return this; + } + /** * A property the SDK does not know, sent along. * @@ -221,6 +250,7 @@ public Builder removeAdditionalProperty(String name) { */ public TieredPlanPricing build() { Utils.checkRequired(tiers, "tiers"); + Utils.checkRequired(type, "type"); return new TieredPlanPricing(this); } } diff --git a/src/main/java/com/meteroid/models/TieredPricing.java b/src/main/java/com/meteroid/models/TieredPricing.java index 3d02256..0468a6e 100644 --- a/src/main/java/com/meteroid/models/TieredPricing.java +++ b/src/main/java/com/meteroid/models/TieredPricing.java @@ -35,6 +35,9 @@ public final class TieredPricing { @JsonProperty("tiers") private List tiers; + @JsonProperty("type") + private String type = "TIERED"; + private final Map additionalProperties = new LinkedHashMap<>(); private TieredPricing() {} @@ -42,6 +45,7 @@ private TieredPricing() {} private TieredPricing(Builder builder) { this.blockSize = builder.blockSize; this.tiers = Utils.copyList(builder.tiers); + this.type = builder.type; this.additionalProperties.putAll(builder.additionalProperties); } @@ -63,6 +67,7 @@ public Builder toBuilder() { Builder builder = new Builder(); builder.blockSize = blockSize; builder.tiers = Utils.mutableList(tiers); + builder.type = type; builder.additionalProperties.putAll(additionalProperties); return builder; } @@ -85,6 +90,15 @@ public List tiers() { return Utils.required(tiers, "tiers"); } + /** + * The {@code type} property. + * + * @return the value, never null + */ + public String type() { + return Utils.required(type, "type"); + } + /** * Properties this version of the SDK does not know, kept as received and sent back. * @@ -115,12 +129,13 @@ public boolean equals(Object o) { TieredPricing that = (TieredPricing) o; return Objects.equals(blockSize, that.blockSize) && Objects.equals(tiers, that.tiers) + && Objects.equals(type, that.type) && Objects.equals(additionalProperties, that.additionalProperties); } @Override public int hashCode() { - return Objects.hash(blockSize, tiers, additionalProperties); + return Objects.hash(blockSize, tiers, type, additionalProperties); } @Override @@ -130,6 +145,8 @@ public String toString() { + blockSize + ", tiers=" + tiers + + ", type=" + + type + ", additionalProperties=" + additionalProperties + "}"; @@ -139,6 +156,7 @@ public String toString() { public static final class Builder { private JsonField blockSize = JsonField.missing(); private List tiers; + private String type = "TIERED"; private final Map additionalProperties = new LinkedHashMap<>(); private Builder() {} @@ -179,6 +197,17 @@ public Builder addTiersItem(TierRow item) { return this; } + /** + * The {@code type} property. + * + * @param type the value + * @return this builder + */ + public Builder type(String type) { + this.type = type; + return this; + } + /** * A property the SDK does not know, sent along. * @@ -221,6 +250,7 @@ public Builder removeAdditionalProperty(String name) { */ public TieredPricing build() { Utils.checkRequired(tiers, "tiers"); + Utils.checkRequired(type, "type"); return new TieredPricing(this); } } diff --git a/src/main/java/com/meteroid/models/TopUpCollection.java b/src/main/java/com/meteroid/models/TopUpCollection.java new file mode 100644 index 0000000..00bc29f --- /dev/null +++ b/src/main/java/com/meteroid/models/TopUpCollection.java @@ -0,0 +1,130 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import com.meteroid.internal.Utils.ToQueryParam; + +import java.util.Map; +import java.util.Objects; + +/** + * How a top-up is paid: CHARGE a saved payment method now, or SEND_INVOICE and grant the credit + * once the invoice is paid. + * + *

Values this version of the SDK does not know are kept, and sent back unchanged: {@link + * #value()} is an enum to switch on, {@code _UNKNOWN} for them, and {@link #known()} throws on + * them. + */ +public final class TopUpCollection implements ToQueryParam { + /** The value {@code "CHARGE"}. */ + public static final TopUpCollection CHARGE = new TopUpCollection("CHARGE", Value.CHARGE); + + /** The value {@code "SEND_INVOICE"}. */ + public static final TopUpCollection SEND_INVOICE = + new TopUpCollection("SEND_INVOICE", Value.SEND_INVOICE); + + private static final Map constants = + Map.ofEntries(Map.entry("CHARGE", CHARGE), Map.entry("SEND_INVOICE", SEND_INVOICE)); + + private final String value; + private final Value variant; + + private TopUpCollection(String value, Value variant) { + this.value = value; + this.variant = variant; + } + + /** + * The constant for {@code value}, or an unknown TopUpCollection holding it. + * + * @param value the value + * @return the constant + */ + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static TopUpCollection of(String value) { + TopUpCollection constant = constants.get(Objects.requireNonNull(value, "value")); + return constant != null ? constant : new TopUpCollection(value, Value._UNKNOWN); + } + + /** + * The value as sent. + * + * @return the value + */ + @JsonValue + public String asString() { + return value; + } + + /** + * Whether this version of the SDK knows the value. + * + * @return whether it is known + */ + public boolean isKnown() { + return variant != Value._UNKNOWN; + } + + /** + * The value as an enum to switch on, unknown values included. + * + * @return the enum, {@code _UNKNOWN} when unknown + */ + public Value value() { + return variant; + } + + /** + * The value as an enum of the known values only. + * + * @return the enum + * @throws com.meteroid.exceptions.InvalidDataException when this version of the SDK does not + * know the value + */ + public Known known() { + if (!isKnown()) { + throw new com.meteroid.exceptions.InvalidDataException( + "unknown TopUpCollection: " + value); + } + return Known.valueOf(variant.name()); + } + + @Override + public String toQueryParam() { + return String.valueOf(value); + } + + @Override + public boolean equals(Object o) { + return o instanceof TopUpCollection && Objects.equals(value, ((TopUpCollection) o).value); + } + + @Override + public int hashCode() { + return Objects.hashCode(value); + } + + @Override + public String toString() { + return String.valueOf(value); + } + + /** The values this version of the SDK knows. */ + public enum Known { + /** The {@code CHARGE} constant. */ + CHARGE, + /** The {@code SEND_INVOICE} constant. */ + SEND_INVOICE + } + + /** The values this version of the SDK knows, and {@code _UNKNOWN} for the others. */ + public enum Value { + /** The {@code CHARGE} constant. */ + CHARGE, + /** The {@code SEND_INVOICE} constant. */ + SEND_INVOICE, + /** A value this version of the SDK does not know. */ + _UNKNOWN + } +} diff --git a/src/main/java/com/meteroid/models/TopUpResponse.java b/src/main/java/com/meteroid/models/TopUpResponse.java new file mode 100644 index 0000000..0cf84b5 --- /dev/null +++ b/src/main/java/com/meteroid/models/TopUpResponse.java @@ -0,0 +1,430 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.JsonField; +import com.meteroid.internal.Utils; + +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +/** + * Where a top-up stands. Its credit is granted once it is paid; wallet.funded reports + * it. + * + *

Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonAutoDetect( + getterVisibility = Visibility.NONE, + isGetterVisibility = Visibility.NONE, + setterVisibility = Visibility.NONE) +public final class TopUpResponse { + @JsonProperty("amount") + private Long amount; + + @JsonProperty("charged_amount") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField chargedAmount = JsonField.missing(); + + @JsonProperty("checkout_url") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField checkoutUrl = JsonField.missing(); + + @JsonProperty("credit_unit") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField creditUnit = JsonField.missing(); + + @JsonProperty("currency") + private Currency currency; + + @JsonProperty("invoice_id") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField invoiceId = JsonField.missing(); + + @JsonProperty("payment_transaction_id") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField paymentTransactionId = JsonField.missing(); + + @JsonProperty("status") + private TopUpStatus status; + + private final Map additionalProperties = new LinkedHashMap<>(); + + private TopUpResponse() {} + + private TopUpResponse(Builder builder) { + this.amount = builder.amount; + this.chargedAmount = builder.chargedAmount; + this.checkoutUrl = builder.checkoutUrl; + this.creditUnit = builder.creditUnit; + this.currency = builder.currency; + this.invoiceId = builder.invoiceId; + this.paymentTransactionId = builder.paymentTransactionId; + this.status = builder.status; + this.additionalProperties.putAll(builder.additionalProperties); + } + + /** + * A builder of {@code TopUpResponse}. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * A builder starting from this value. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.amount = amount; + builder.chargedAmount = chargedAmount; + builder.checkoutUrl = checkoutUrl; + builder.creditUnit = creditUnit; + builder.currency = currency; + builder.invoiceId = invoiceId; + builder.paymentTransactionId = paymentTransactionId; + builder.status = status; + builder.additionalProperties.putAll(additionalProperties); + return builder; + } + + /** + * Credit bought, in minor units of currency, or of credit_unit when + * set. + * + * @return the value, never null + */ + public Long amount() { + return Utils.required(amount, "amount"); + } + + /** + * Charged to the payment method, tax included, in minor units of currency; absent + * until a charge is made. + * + * @return the value, empty when unset or null + */ + public Optional chargedAmount() { + return chargedAmount.asOptional(); + } + + /** + * Hosted page where the customer completes the payment; present while it awaits them. + * + * @return the value, empty when unset or null + */ + public Optional checkoutUrl() { + return checkoutUrl.asOptional(); + } + + /** + * Set when credits of this credit unit were bought: amount is in its minor units. + * + * @return the value, empty when unset or null + */ + public Optional creditUnit() { + return creditUnit.asOptional(); + } + + /** + * The money the top-up is charged in. + * + * @return the value, never null + */ + public Currency currency() { + return Utils.required(currency, "currency"); + } + + /** + * The invoice documenting the purchase. + * + * @return the value, empty when unset or null + */ + public Optional invoiceId() { + return invoiceId.asOptional(); + } + + /** + * The charge made on the payment method; absent until a charge is made. + * + * @return the value, empty when unset or null + */ + public Optional paymentTransactionId() { + return paymentTransactionId.asOptional(); + } + + /** + * SUCCEEDED once paid; otherwise what the payment is waiting for. + * + * @return the value, never null + */ + public TopUpStatus status() { + return Utils.required(status, "status"); + } + + /** + * Properties this version of the SDK does not know, kept as received and sent back. + * + * @return the properties by name, unmodifiable + */ + public Map additionalProperties() { + return Collections.unmodifiableMap(additionalProperties); + } + + @JsonAnyGetter + private Map anyProperties() { + return additionalProperties; + } + + @JsonAnySetter + private void putAnyProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + TopUpResponse that = (TopUpResponse) o; + return Objects.equals(amount, that.amount) + && Objects.equals(chargedAmount, that.chargedAmount) + && Objects.equals(checkoutUrl, that.checkoutUrl) + && Objects.equals(creditUnit, that.creditUnit) + && Objects.equals(currency, that.currency) + && Objects.equals(invoiceId, that.invoiceId) + && Objects.equals(paymentTransactionId, that.paymentTransactionId) + && Objects.equals(status, that.status) + && Objects.equals(additionalProperties, that.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash( + amount, + chargedAmount, + checkoutUrl, + creditUnit, + currency, + invoiceId, + paymentTransactionId, + status, + additionalProperties); + } + + @Override + public String toString() { + return "TopUpResponse{" + + "amount=" + + amount + + ", chargedAmount=" + + chargedAmount + + ", checkoutUrl=" + + checkoutUrl + + ", creditUnit=" + + creditUnit + + ", currency=" + + currency + + ", invoiceId=" + + invoiceId + + ", paymentTransactionId=" + + paymentTransactionId + + ", status=" + + status + + ", additionalProperties=" + + additionalProperties + + "}"; + } + + /** Builds {@link TopUpResponse}. */ + public static final class Builder { + private Long amount; + private JsonField chargedAmount = JsonField.missing(); + private JsonField checkoutUrl = JsonField.missing(); + private JsonField creditUnit = JsonField.missing(); + private Currency currency; + private JsonField invoiceId = JsonField.missing(); + private JsonField paymentTransactionId = JsonField.missing(); + private TopUpStatus status; + private final Map additionalProperties = new LinkedHashMap<>(); + + private Builder() {} + + /** + * Credit bought, in minor units of currency, or of credit_unit + * when set. + * + * @param amount the value + * @return this builder + */ + public Builder amount(Long amount) { + this.amount = amount; + return this; + } + + /** + * Charged to the payment method, tax included, in minor units of currency; + * absent until a charge is made. + * + * @param chargedAmount the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder chargedAmount(Long chargedAmount) { + this.chargedAmount = JsonField.ofNullable(chargedAmount); + return this; + } + + /** + * Hosted page where the customer completes the payment; present while it awaits them. + * + * @param checkoutUrl the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder checkoutUrl(String checkoutUrl) { + this.checkoutUrl = JsonField.ofNullable(checkoutUrl); + return this; + } + + /** + * Set when credits of this credit unit were bought: amount is in its minor + * units. + * + * @param creditUnit the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder creditUnit(String creditUnit) { + this.creditUnit = JsonField.ofNullable(creditUnit); + return this; + } + + /** + * The money the top-up is charged in. + * + * @param currency the value + * @return this builder + */ + public Builder currency(Currency currency) { + this.currency = currency; + return this; + } + + /** + * The invoice documenting the purchase. + * + * @param invoiceId the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder invoiceId(String invoiceId) { + this.invoiceId = JsonField.ofNullable(invoiceId); + return this; + } + + /** + * The charge made on the payment method; absent until a charge is made. + * + * @param paymentTransactionId the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder paymentTransactionId(String paymentTransactionId) { + this.paymentTransactionId = JsonField.ofNullable(paymentTransactionId); + return this; + } + + /** + * SUCCEEDED once paid; otherwise what the payment is waiting for. + * + * @param status the value + * @return this builder + */ + public Builder status(TopUpStatus status) { + this.status = status; + return this; + } + + /** + * A property the SDK does not know, sent along. + * + * @param name the property name + * @param value the JSON value + * @return this builder + */ + public Builder putAdditionalProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + return this; + } + + /** + * Properties the SDK does not know, sent along. + * + * @param additionalProperties the properties by name + * @return this builder + */ + public Builder putAllAdditionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + + /** + * Leaves out a property the SDK does not know. + * + * @param name the property name + * @return this builder + */ + public Builder removeAdditionalProperty(String name) { + additionalProperties.remove(name); + return this; + } + + /** + * The {@code TopUpResponse}. + * + * @return the immutable value + * @throws IllegalStateException when a required property is not set + */ + public TopUpResponse build() { + Utils.checkRequired(amount, "amount"); + Utils.checkRequired(currency, "currency"); + Utils.checkRequired(status, "status"); + return new TopUpResponse(this); + } + } + + /** + * Parse {@code json} as {@code TopUpResponse}. + * + * @param json the JSON text + * @return the value + * @throws com.meteroid.exceptions.InvalidDataException if it is not valid JSON of this shape + */ + public static TopUpResponse fromJson(String json) { + return Utils.parse(json, TopUpResponse.class); + } + + /** + * This value as JSON. + * + * @return the JSON text + */ + public String toJson() { + return Utils.json(this); + } +} diff --git a/src/main/java/com/meteroid/models/TopUpStatus.java b/src/main/java/com/meteroid/models/TopUpStatus.java new file mode 100644 index 0000000..fa2e3e0 --- /dev/null +++ b/src/main/java/com/meteroid/models/TopUpStatus.java @@ -0,0 +1,144 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import com.meteroid.internal.Utils.ToQueryParam; + +import java.util.Map; +import java.util.Objects; + +/** + * Values this version of the SDK does not know are kept, and sent back unchanged: {@link #value()} + * is an enum to switch on, {@code _UNKNOWN} for them, and {@link #known()} throws on them. + */ +public final class TopUpStatus implements ToQueryParam { + /** The value {@code "SUCCEEDED"}. */ + public static final TopUpStatus SUCCEEDED = new TopUpStatus("SUCCEEDED", Value.SUCCEEDED); + + /** The value {@code "PENDING"}. */ + public static final TopUpStatus PENDING = new TopUpStatus("PENDING", Value.PENDING); + + /** The value {@code "REQUIRES_CUSTOMER_ACTION"}. */ + public static final TopUpStatus REQUIRES_CUSTOMER_ACTION = + new TopUpStatus("REQUIRES_CUSTOMER_ACTION", Value.REQUIRES_CUSTOMER_ACTION); + + /** The value {@code "AWAITING_PAYMENT"}. */ + public static final TopUpStatus AWAITING_PAYMENT = + new TopUpStatus("AWAITING_PAYMENT", Value.AWAITING_PAYMENT); + + private static final Map constants = + Map.ofEntries( + Map.entry("SUCCEEDED", SUCCEEDED), + Map.entry("PENDING", PENDING), + Map.entry("REQUIRES_CUSTOMER_ACTION", REQUIRES_CUSTOMER_ACTION), + Map.entry("AWAITING_PAYMENT", AWAITING_PAYMENT)); + + private final String value; + private final Value variant; + + private TopUpStatus(String value, Value variant) { + this.value = value; + this.variant = variant; + } + + /** + * The constant for {@code value}, or an unknown TopUpStatus holding it. + * + * @param value the value + * @return the constant + */ + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static TopUpStatus of(String value) { + TopUpStatus constant = constants.get(Objects.requireNonNull(value, "value")); + return constant != null ? constant : new TopUpStatus(value, Value._UNKNOWN); + } + + /** + * The value as sent. + * + * @return the value + */ + @JsonValue + public String asString() { + return value; + } + + /** + * Whether this version of the SDK knows the value. + * + * @return whether it is known + */ + public boolean isKnown() { + return variant != Value._UNKNOWN; + } + + /** + * The value as an enum to switch on, unknown values included. + * + * @return the enum, {@code _UNKNOWN} when unknown + */ + public Value value() { + return variant; + } + + /** + * The value as an enum of the known values only. + * + * @return the enum + * @throws com.meteroid.exceptions.InvalidDataException when this version of the SDK does not + * know the value + */ + public Known known() { + if (!isKnown()) { + throw new com.meteroid.exceptions.InvalidDataException("unknown TopUpStatus: " + value); + } + return Known.valueOf(variant.name()); + } + + @Override + public String toQueryParam() { + return String.valueOf(value); + } + + @Override + public boolean equals(Object o) { + return o instanceof TopUpStatus && Objects.equals(value, ((TopUpStatus) o).value); + } + + @Override + public int hashCode() { + return Objects.hashCode(value); + } + + @Override + public String toString() { + return String.valueOf(value); + } + + /** The values this version of the SDK knows. */ + public enum Known { + /** The {@code SUCCEEDED} constant. */ + SUCCEEDED, + /** The {@code PENDING} constant. */ + PENDING, + /** The {@code REQUIRES_CUSTOMER_ACTION} constant. */ + REQUIRES_CUSTOMER_ACTION, + /** The {@code AWAITING_PAYMENT} constant. */ + AWAITING_PAYMENT + } + + /** The values this version of the SDK knows, and {@code _UNKNOWN} for the others. */ + public enum Value { + /** The {@code SUCCEEDED} constant. */ + SUCCEEDED, + /** The {@code PENDING} constant. */ + PENDING, + /** The {@code REQUIRES_CUSTOMER_ACTION} constant. */ + REQUIRES_CUSTOMER_ACTION, + /** The {@code AWAITING_PAYMENT} constant. */ + AWAITING_PAYMENT, + /** A value this version of the SDK does not know. */ + _UNKNOWN + } +} diff --git a/src/main/java/com/meteroid/models/Transaction.java b/src/main/java/com/meteroid/models/Transaction.java index b737daf..acbbe21 100644 --- a/src/main/java/com/meteroid/models/Transaction.java +++ b/src/main/java/com/meteroid/models/Transaction.java @@ -30,12 +30,18 @@ public final class Transaction { @JsonProperty("amount") private Long amount; + @JsonProperty("amount_disputed") + private Long amountDisputed; + @JsonProperty("amount_refunded") private Long amountRefunded; @JsonProperty("amount_reversed") private Long amountReversed; + @JsonProperty("amount_reversed_excess") + private Long amountReversedExcess; + @JsonProperty("credit_note_id") @JsonInclude(JsonInclude.Include.NON_EMPTY) private JsonField creditNoteId = JsonField.missing(); @@ -94,8 +100,10 @@ private Transaction() {} private Transaction(Builder builder) { this.amount = builder.amount; + this.amountDisputed = builder.amountDisputed; this.amountRefunded = builder.amountRefunded; this.amountReversed = builder.amountReversed; + this.amountReversedExcess = builder.amountReversedExcess; this.creditNoteId = builder.creditNoteId; this.currency = builder.currency; this.error = builder.error; @@ -130,8 +138,10 @@ public static Builder builder() { public Builder toBuilder() { Builder builder = new Builder(); builder.amount = amount; + builder.amountDisputed = amountDisputed; builder.amountRefunded = amountRefunded; builder.amountReversed = amountReversed; + builder.amountReversedExcess = amountReversedExcess; builder.creditNoteId = creditNoteId; builder.currency = currency; builder.error = error; @@ -159,6 +169,17 @@ public Long amount() { return Utils.required(amount, "amount"); } + /** + * On a PAYMENT: the part of amount_reversed lost to disputes or chargebacks. The + * invoice stays paid; only the rest of amount_reversed (a failed collection) + * reopens it. + * + * @return the value, empty when unset + */ + public Optional amountDisputed() { + return Optional.ofNullable(amountDisputed); + } + /** * On a PAYMENT: how much was voluntarily given back (the sum of its settled REFUND children). * The invoice stays paid — the Refund credit note is what reduces it. @@ -179,6 +200,16 @@ public Long amountReversed() { return Utils.required(amountReversed, "amount_reversed"); } + /** + * On a PAYMENT: what the provider withdrew above what the payment still held (refunded before). + * Never applied to the invoice or credit: contest it with the provider. + * + * @return the value, empty when unset + */ + public Optional amountReversedExcess() { + return Optional.ofNullable(amountReversedExcess); + } + /** * The {@code credit_note_id} property. * @@ -334,8 +365,10 @@ public boolean equals(Object o) { } Transaction that = (Transaction) o; return Objects.equals(amount, that.amount) + && Objects.equals(amountDisputed, that.amountDisputed) && Objects.equals(amountRefunded, that.amountRefunded) && Objects.equals(amountReversed, that.amountReversed) + && Objects.equals(amountReversedExcess, that.amountReversedExcess) && Objects.equals(creditNoteId, that.creditNoteId) && Objects.equals(currency, that.currency) && Objects.equals(error, that.error) @@ -357,8 +390,10 @@ public boolean equals(Object o) { public int hashCode() { return Objects.hash( amount, + amountDisputed, amountRefunded, amountReversed, + amountReversedExcess, creditNoteId, currency, error, @@ -381,10 +416,14 @@ public String toString() { return "Transaction{" + "amount=" + amount + + ", amountDisputed=" + + amountDisputed + ", amountRefunded=" + amountRefunded + ", amountReversed=" + amountReversed + + ", amountReversedExcess=" + + amountReversedExcess + ", creditNoteId=" + creditNoteId + ", currency=" @@ -421,8 +460,10 @@ public String toString() { /** Builds {@link Transaction}. */ public static final class Builder { private Long amount; + private Long amountDisputed; private Long amountRefunded; private Long amountReversed; + private Long amountReversedExcess; private JsonField creditNoteId = JsonField.missing(); private String currency; private JsonField error = JsonField.missing(); @@ -452,6 +493,19 @@ public Builder amount(Long amount) { return this; } + /** + * On a PAYMENT: the part of amount_reversed lost to disputes or chargebacks. + * The invoice stays paid; only the rest of amount_reversed (a failed + * collection) reopens it. + * + * @param amountDisputed the value + * @return this builder + */ + public Builder amountDisputed(Long amountDisputed) { + this.amountDisputed = amountDisputed; + return this; + } + /** * On a PAYMENT: how much was voluntarily given back (the sum of its settled REFUND * children). The invoice stays paid — the Refund credit note is what reduces it. @@ -476,6 +530,18 @@ public Builder amountReversed(Long amountReversed) { return this; } + /** + * On a PAYMENT: what the provider withdrew above what the payment still held (refunded + * before). Never applied to the invoice or credit: contest it with the provider. + * + * @param amountReversedExcess the value + * @return this builder + */ + public Builder amountReversedExcess(Long amountReversedExcess) { + this.amountReversedExcess = amountReversedExcess; + return this; + } + /** * The {@code credit_note_id} property. * diff --git a/src/main/java/com/meteroid/models/UnattributedMetricUsage.java b/src/main/java/com/meteroid/models/UnattributedMetricUsage.java new file mode 100644 index 0000000..4091b75 --- /dev/null +++ b/src/main/java/com/meteroid/models/UnattributedMetricUsage.java @@ -0,0 +1,357 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.Utils; + +import java.math.BigDecimal; +import java.time.OffsetDateTime; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; + +/** + * A metric's usage over [from, until) that no subscription bills: it matches none of + * the usage filters of the subscriptions pricing the metric, and none of them bills without one. + * + *

Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonAutoDetect( + getterVisibility = Visibility.NONE, + isGetterVisibility = Visibility.NONE, + setterVisibility = Visibility.NONE) +public final class UnattributedMetricUsage { + @JsonProperty("from") + private OffsetDateTime from; + + @JsonProperty("metric_code") + private String metricCode; + + @JsonProperty("metric_id") + private String metricId; + + @JsonProperty("metric_name") + private String metricName; + + @JsonProperty("total_value") + private BigDecimal totalValue; + + @JsonProperty("until") + private OffsetDateTime until; + + private final Map additionalProperties = new LinkedHashMap<>(); + + private UnattributedMetricUsage() {} + + private UnattributedMetricUsage(Builder builder) { + this.from = builder.from; + this.metricCode = builder.metricCode; + this.metricId = builder.metricId; + this.metricName = builder.metricName; + this.totalValue = builder.totalValue; + this.until = builder.until; + this.additionalProperties.putAll(builder.additionalProperties); + } + + /** + * A builder of {@code UnattributedMetricUsage}. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * A builder starting from this value. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.from = from; + builder.metricCode = metricCode; + builder.metricId = metricId; + builder.metricName = metricName; + builder.totalValue = totalValue; + builder.until = until; + builder.additionalProperties.putAll(additionalProperties); + return builder; + } + + /** + * The {@code from} property. + * + * @return the value, never null + */ + public OffsetDateTime from() { + return Utils.required(from, "from"); + } + + /** + * The {@code metric_code} property. + * + * @return the value, never null + */ + public String metricCode() { + return Utils.required(metricCode, "metric_code"); + } + + /** + * The {@code metric_id} property. + * + * @return the value, never null + */ + public String metricId() { + return Utils.required(metricId, "metric_id"); + } + + /** + * The {@code metric_name} property. + * + * @return the value, never null + */ + public String metricName() { + return Utils.required(metricName, "metric_name"); + } + + /** + * The {@code total_value} property. + * + * @return the value, never null + */ + public BigDecimal totalValue() { + return Utils.required(totalValue, "total_value"); + } + + /** + * The {@code until} property. + * + * @return the value, never null + */ + public OffsetDateTime until() { + return Utils.required(until, "until"); + } + + /** + * Properties this version of the SDK does not know, kept as received and sent back. + * + * @return the properties by name, unmodifiable + */ + public Map additionalProperties() { + return Collections.unmodifiableMap(additionalProperties); + } + + @JsonAnyGetter + private Map anyProperties() { + return additionalProperties; + } + + @JsonAnySetter + private void putAnyProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + UnattributedMetricUsage that = (UnattributedMetricUsage) o; + return Objects.equals(from, that.from) + && Objects.equals(metricCode, that.metricCode) + && Objects.equals(metricId, that.metricId) + && Objects.equals(metricName, that.metricName) + && Objects.equals(totalValue, that.totalValue) + && Objects.equals(until, that.until) + && Objects.equals(additionalProperties, that.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash( + from, metricCode, metricId, metricName, totalValue, until, additionalProperties); + } + + @Override + public String toString() { + return "UnattributedMetricUsage{" + + "from=" + + from + + ", metricCode=" + + metricCode + + ", metricId=" + + metricId + + ", metricName=" + + metricName + + ", totalValue=" + + totalValue + + ", until=" + + until + + ", additionalProperties=" + + additionalProperties + + "}"; + } + + /** Builds {@link UnattributedMetricUsage}. */ + public static final class Builder { + private OffsetDateTime from; + private String metricCode; + private String metricId; + private String metricName; + private BigDecimal totalValue; + private OffsetDateTime until; + private final Map additionalProperties = new LinkedHashMap<>(); + + private Builder() {} + + /** + * The {@code from} property. + * + * @param from the value + * @return this builder + */ + public Builder from(OffsetDateTime from) { + this.from = from; + return this; + } + + /** + * The {@code metric_code} property. + * + * @param metricCode the value + * @return this builder + */ + public Builder metricCode(String metricCode) { + this.metricCode = metricCode; + return this; + } + + /** + * The {@code metric_id} property. + * + * @param metricId the value + * @return this builder + */ + public Builder metricId(String metricId) { + this.metricId = metricId; + return this; + } + + /** + * The {@code metric_name} property. + * + * @param metricName the value + * @return this builder + */ + public Builder metricName(String metricName) { + this.metricName = metricName; + return this; + } + + /** + * The {@code total_value} property. + * + * @param totalValue the value + * @return this builder + */ + public Builder totalValue(BigDecimal totalValue) { + this.totalValue = totalValue; + return this; + } + + /** + * The {@code until} property. + * + * @param until the value + * @return this builder + */ + public Builder until(OffsetDateTime until) { + this.until = until; + return this; + } + + /** + * A property the SDK does not know, sent along. + * + * @param name the property name + * @param value the JSON value + * @return this builder + */ + public Builder putAdditionalProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + return this; + } + + /** + * Properties the SDK does not know, sent along. + * + * @param additionalProperties the properties by name + * @return this builder + */ + public Builder putAllAdditionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + + /** + * Leaves out a property the SDK does not know. + * + * @param name the property name + * @return this builder + */ + public Builder removeAdditionalProperty(String name) { + additionalProperties.remove(name); + return this; + } + + /** + * The {@code UnattributedMetricUsage}. + * + * @return the immutable value + * @throws IllegalStateException when a required property is not set + */ + public UnattributedMetricUsage build() { + Utils.checkRequired(from, "from"); + Utils.checkRequired(metricCode, "metric_code"); + Utils.checkRequired(metricId, "metric_id"); + Utils.checkRequired(metricName, "metric_name"); + Utils.checkRequired(totalValue, "total_value"); + Utils.checkRequired(until, "until"); + return new UnattributedMetricUsage(this); + } + } + + /** + * Parse {@code json} as {@code UnattributedMetricUsage}. + * + * @param json the JSON text + * @return the value + * @throws com.meteroid.exceptions.InvalidDataException if it is not valid JSON of this shape + */ + public static UnattributedMetricUsage fromJson(String json) { + return Utils.parse(json, UnattributedMetricUsage.class); + } + + /** + * This value as JSON. + * + * @return the JSON text + */ + public String toJson() { + return Utils.json(this); + } +} diff --git a/src/main/java/com/meteroid/models/UnattributedUsageResponse.java b/src/main/java/com/meteroid/models/UnattributedUsageResponse.java new file mode 100644 index 0000000..3fb1be0 --- /dev/null +++ b/src/main/java/com/meteroid/models/UnattributedUsageResponse.java @@ -0,0 +1,276 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.Utils; + +import java.time.LocalDate; +import java.util.ArrayList; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonAutoDetect( + getterVisibility = Visibility.NONE, + isGetterVisibility = Visibility.NONE, + setterVisibility = Visibility.NONE) +public final class UnattributedUsageResponse { + @JsonProperty("period_end") + private LocalDate periodEnd; + + @JsonProperty("period_start") + private LocalDate periodStart; + + @JsonProperty("usage") + private List usage; + + private final Map additionalProperties = new LinkedHashMap<>(); + + private UnattributedUsageResponse() {} + + private UnattributedUsageResponse(Builder builder) { + this.periodEnd = builder.periodEnd; + this.periodStart = builder.periodStart; + this.usage = Utils.copyList(builder.usage); + this.additionalProperties.putAll(builder.additionalProperties); + } + + /** + * A builder of {@code UnattributedUsageResponse}. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * A builder starting from this value. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.periodEnd = periodEnd; + builder.periodStart = periodStart; + builder.usage = Utils.mutableList(usage); + builder.additionalProperties.putAll(additionalProperties); + return builder; + } + + /** + * The {@code period_end} property. + * + * @return the value, never null + */ + public LocalDate periodEnd() { + return Utils.required(periodEnd, "period_end"); + } + + /** + * The {@code period_start} property. + * + * @return the value, never null + */ + public LocalDate periodStart() { + return Utils.required(periodStart, "period_start"); + } + + /** + * The {@code usage} property. + * + * @return the value, never null + */ + public List usage() { + return Utils.required(usage, "usage"); + } + + /** + * Properties this version of the SDK does not know, kept as received and sent back. + * + * @return the properties by name, unmodifiable + */ + public Map additionalProperties() { + return Collections.unmodifiableMap(additionalProperties); + } + + @JsonAnyGetter + private Map anyProperties() { + return additionalProperties; + } + + @JsonAnySetter + private void putAnyProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + UnattributedUsageResponse that = (UnattributedUsageResponse) o; + return Objects.equals(periodEnd, that.periodEnd) + && Objects.equals(periodStart, that.periodStart) + && Objects.equals(usage, that.usage) + && Objects.equals(additionalProperties, that.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(periodEnd, periodStart, usage, additionalProperties); + } + + @Override + public String toString() { + return "UnattributedUsageResponse{" + + "periodEnd=" + + periodEnd + + ", periodStart=" + + periodStart + + ", usage=" + + usage + + ", additionalProperties=" + + additionalProperties + + "}"; + } + + /** Builds {@link UnattributedUsageResponse}. */ + public static final class Builder { + private LocalDate periodEnd; + private LocalDate periodStart; + private List usage; + private final Map additionalProperties = new LinkedHashMap<>(); + + private Builder() {} + + /** + * The {@code period_end} property. + * + * @param periodEnd the value + * @return this builder + */ + public Builder periodEnd(LocalDate periodEnd) { + this.periodEnd = periodEnd; + return this; + } + + /** + * The {@code period_start} property. + * + * @param periodStart the value + * @return this builder + */ + public Builder periodStart(LocalDate periodStart) { + this.periodStart = periodStart; + return this; + } + + /** + * The {@code usage} property. + * + * @param usage the value + * @return this builder + */ + public Builder usage(List usage) { + this.usage = Utils.mutableList(usage); + return this; + } + + /** + * Adds an item to {@code usage}. + * + * @param item the item + * @return this builder + */ + public Builder addUsageItem(UnattributedMetricUsage item) { + if (this.usage == null) { + this.usage = new ArrayList<>(); + } + this.usage.add(item); + return this; + } + + /** + * A property the SDK does not know, sent along. + * + * @param name the property name + * @param value the JSON value + * @return this builder + */ + public Builder putAdditionalProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + return this; + } + + /** + * Properties the SDK does not know, sent along. + * + * @param additionalProperties the properties by name + * @return this builder + */ + public Builder putAllAdditionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + + /** + * Leaves out a property the SDK does not know. + * + * @param name the property name + * @return this builder + */ + public Builder removeAdditionalProperty(String name) { + additionalProperties.remove(name); + return this; + } + + /** + * The {@code UnattributedUsageResponse}. + * + * @return the immutable value + * @throws IllegalStateException when a required property is not set + */ + public UnattributedUsageResponse build() { + Utils.checkRequired(periodEnd, "period_end"); + Utils.checkRequired(periodStart, "period_start"); + Utils.checkRequired(usage, "usage"); + return new UnattributedUsageResponse(this); + } + } + + /** + * Parse {@code json} as {@code UnattributedUsageResponse}. + * + * @param json the JSON text + * @return the value + * @throws com.meteroid.exceptions.InvalidDataException if it is not valid JSON of this shape + */ + public static UnattributedUsageResponse fromJson(String json) { + return Utils.parse(json, UnattributedUsageResponse.class); + } + + /** + * This value as JSON. + * + * @return the JSON text + */ + public String toJson() { + return Utils.json(this); + } +} diff --git a/src/main/java/com/meteroid/models/UnitConversion.java b/src/main/java/com/meteroid/models/UnitConversion.java index 97020f2..651949f 100644 --- a/src/main/java/com/meteroid/models/UnitConversion.java +++ b/src/main/java/com/meteroid/models/UnitConversion.java @@ -16,7 +16,14 @@ import java.util.Map; import java.util.Objects; -/** Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. */ +/** + * Converts the aggregated usage into the unit prices are set in, e.g. tokens priced per 1M. The + * usage is divided by factor, then rounded. Rounding applies to each priced group's + * total for the billing period: each group of a segmented or grouped metric, and each matrix cell, + * is rounded on its own, never each event. + * + *

Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. + */ @JsonInclude(JsonInclude.Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) @JsonAutoDetect( @@ -63,7 +70,7 @@ public Builder toBuilder() { } /** - * The {@code factor} property. + * Raw units per priced unit, e.g. 1000000 to price per 1M. * * @return the value, never null */ @@ -139,7 +146,7 @@ public static final class Builder { private Builder() {} /** - * The {@code factor} property. + * Raw units per priced unit, e.g. 1000000 to price per 1M. * * @param factor the value * @return this builder diff --git a/src/main/java/com/meteroid/models/UpdateMetricRequest.java b/src/main/java/com/meteroid/models/UpdateMetricRequest.java index 46112e6..794cb5d 100644 --- a/src/main/java/com/meteroid/models/UpdateMetricRequest.java +++ b/src/main/java/com/meteroid/models/UpdateMetricRequest.java @@ -48,6 +48,14 @@ public final class UpdateMetricRequest { @JsonInclude(JsonInclude.Include.NON_EMPTY) private JsonField unitConversion = JsonField.missing(); + @JsonProperty("unit_plural") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField unitPlural = JsonField.missing(); + + @JsonProperty("unit_singular") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField unitSingular = JsonField.missing(); + private final Map additionalProperties = new LinkedHashMap<>(); private UpdateMetricRequest() {} @@ -58,6 +66,8 @@ private UpdateMetricRequest(Builder builder) { this.name = builder.name; this.segmentationMatrix = builder.segmentationMatrix; this.unitConversion = builder.unitConversion; + this.unitPlural = builder.unitPlural; + this.unitSingular = builder.unitSingular; this.additionalProperties.putAll(builder.additionalProperties); } @@ -82,6 +92,8 @@ public Builder toBuilder() { builder.name = name; builder.segmentationMatrix = segmentationMatrix; builder.unitConversion = unitConversion; + builder.unitPlural = unitPlural; + builder.unitSingular = unitSingular; builder.additionalProperties.putAll(additionalProperties); return builder; } @@ -131,6 +143,27 @@ public Optional unitConversion() { return unitConversion.asOptional(); } + /** + * What several units of the metric are called, e.g. tokens. See + * unit_singular. + * + * @return the value, empty when unset or null + */ + public Optional unitPlural() { + return unitPlural.asOptional(); + } + + /** + * What one unit of the metric is called, e.g. token. Send unit_singular + * and unit_plural together; omit both to leave the label unchanged, or + * send both as empty strings to remove it. Trimmed; at most 32 characters. + * + * @return the value, empty when unset or null + */ + public Optional unitSingular() { + return unitSingular.asOptional(); + } + /** * Properties this version of the SDK does not know, kept as received and sent back. * @@ -164,6 +197,8 @@ public boolean equals(Object o) { && Objects.equals(name, that.name) && Objects.equals(segmentationMatrix, that.segmentationMatrix) && Objects.equals(unitConversion, that.unitConversion) + && Objects.equals(unitPlural, that.unitPlural) + && Objects.equals(unitSingular, that.unitSingular) && Objects.equals(additionalProperties, that.additionalProperties); } @@ -175,6 +210,8 @@ public int hashCode() { name, segmentationMatrix, unitConversion, + unitPlural, + unitSingular, additionalProperties); } @@ -191,6 +228,10 @@ public String toString() { + segmentationMatrix + ", unitConversion=" + unitConversion + + ", unitPlural=" + + unitPlural + + ", unitSingular=" + + unitSingular + ", additionalProperties=" + additionalProperties + "}"; @@ -203,6 +244,8 @@ public static final class Builder { private JsonField name = JsonField.missing(); private JsonField segmentationMatrix = JsonField.missing(); private JsonField unitConversion = JsonField.missing(); + private JsonField unitPlural = JsonField.missing(); + private JsonField unitSingular = JsonField.missing(); private final Map additionalProperties = new LinkedHashMap<>(); private Builder() {} @@ -278,6 +321,31 @@ public Builder unitConversion(UnitConversion unitConversion) { return this; } + /** + * What several units of the metric are called, e.g. tokens. See + * unit_singular. + * + * @param unitPlural the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder unitPlural(String unitPlural) { + this.unitPlural = JsonField.ofNullable(unitPlural); + return this; + } + + /** + * What one unit of the metric is called, e.g. token. Send unit_singular + * and unit_plural together; omit both to leave the label unchanged, or + * send both as empty strings to remove it. Trimmed; at most 32 characters. + * + * @param unitSingular the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder unitSingular(String unitSingular) { + this.unitSingular = JsonField.ofNullable(unitSingular); + return this; + } + /** * A property the SDK does not know, sent along. * diff --git a/src/main/java/com/meteroid/models/UpdateWebhookEndpointRequest.java b/src/main/java/com/meteroid/models/UpdateWebhookEndpointRequest.java index 5eb4568..7ddd288 100644 --- a/src/main/java/com/meteroid/models/UpdateWebhookEndpointRequest.java +++ b/src/main/java/com/meteroid/models/UpdateWebhookEndpointRequest.java @@ -111,7 +111,8 @@ public Optional disabled() { } /** - * Replaces the subscription list. An empty array subscribes to every event type. + * Replaces the subscription list. An empty array subscribes to every event type except Beta + * ones, which are sent only to endpoints that list them. * * @return the value, empty when unset or null */ @@ -250,7 +251,8 @@ public Builder disabled(Boolean disabled) { } /** - * Replaces the subscription list. An empty array subscribes to every event type. + * Replaces the subscription list. An empty array subscribes to every event type except Beta + * ones, which are sent only to endpoints that list them. * * @param eventTypes the value, null to send an explicit {@code null} * @return this builder diff --git a/src/main/java/com/meteroid/models/UsageAtZero.java b/src/main/java/com/meteroid/models/UsageAtZero.java new file mode 100644 index 0000000..64cb577 --- /dev/null +++ b/src/main/java/com/meteroid/models/UsageAtZero.java @@ -0,0 +1,139 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import com.meteroid.internal.Utils.ToQueryParam; + +import java.util.Map; +import java.util.Objects; + +/** + * What a customer's usage does once the credit it can use runs out: what the subscription's plan + * says (FOLLOW_PLAN), or always or never refused for this customer. + * + *

Values this version of the SDK does not know are kept, and sent back unchanged: {@link + * #value()} is an enum to switch on, {@code _UNKNOWN} for them, and {@link #known()} throws on + * them. + */ +public final class UsageAtZero implements ToQueryParam { + /** The value {@code "FOLLOW_PLAN"}. */ + public static final UsageAtZero FOLLOW_PLAN = new UsageAtZero("FOLLOW_PLAN", Value.FOLLOW_PLAN); + + /** The value {@code "ALWAYS_PAUSE"}. */ + public static final UsageAtZero ALWAYS_PAUSE = + new UsageAtZero("ALWAYS_PAUSE", Value.ALWAYS_PAUSE); + + /** The value {@code "NEVER_PAUSE"}. */ + public static final UsageAtZero NEVER_PAUSE = new UsageAtZero("NEVER_PAUSE", Value.NEVER_PAUSE); + + private static final Map constants = + Map.ofEntries( + Map.entry("FOLLOW_PLAN", FOLLOW_PLAN), + Map.entry("ALWAYS_PAUSE", ALWAYS_PAUSE), + Map.entry("NEVER_PAUSE", NEVER_PAUSE)); + + private final String value; + private final Value variant; + + private UsageAtZero(String value, Value variant) { + this.value = value; + this.variant = variant; + } + + /** + * The constant for {@code value}, or an unknown UsageAtZero holding it. + * + * @param value the value + * @return the constant + */ + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static UsageAtZero of(String value) { + UsageAtZero constant = constants.get(Objects.requireNonNull(value, "value")); + return constant != null ? constant : new UsageAtZero(value, Value._UNKNOWN); + } + + /** + * The value as sent. + * + * @return the value + */ + @JsonValue + public String asString() { + return value; + } + + /** + * Whether this version of the SDK knows the value. + * + * @return whether it is known + */ + public boolean isKnown() { + return variant != Value._UNKNOWN; + } + + /** + * The value as an enum to switch on, unknown values included. + * + * @return the enum, {@code _UNKNOWN} when unknown + */ + public Value value() { + return variant; + } + + /** + * The value as an enum of the known values only. + * + * @return the enum + * @throws com.meteroid.exceptions.InvalidDataException when this version of the SDK does not + * know the value + */ + public Known known() { + if (!isKnown()) { + throw new com.meteroid.exceptions.InvalidDataException("unknown UsageAtZero: " + value); + } + return Known.valueOf(variant.name()); + } + + @Override + public String toQueryParam() { + return String.valueOf(value); + } + + @Override + public boolean equals(Object o) { + return o instanceof UsageAtZero && Objects.equals(value, ((UsageAtZero) o).value); + } + + @Override + public int hashCode() { + return Objects.hashCode(value); + } + + @Override + public String toString() { + return String.valueOf(value); + } + + /** The values this version of the SDK knows. */ + public enum Known { + /** The {@code FOLLOW_PLAN} constant. */ + FOLLOW_PLAN, + /** The {@code ALWAYS_PAUSE} constant. */ + ALWAYS_PAUSE, + /** The {@code NEVER_PAUSE} constant. */ + NEVER_PAUSE + } + + /** The values this version of the SDK knows, and {@code _UNKNOWN} for the others. */ + public enum Value { + /** The {@code FOLLOW_PLAN} constant. */ + FOLLOW_PLAN, + /** The {@code ALWAYS_PAUSE} constant. */ + ALWAYS_PAUSE, + /** The {@code NEVER_PAUSE} constant. */ + NEVER_PAUSE, + /** A value this version of the SDK does not know. */ + _UNKNOWN + } +} diff --git a/src/main/java/com/meteroid/models/UsageCost.java b/src/main/java/com/meteroid/models/UsageCost.java new file mode 100644 index 0000000..a15f573 --- /dev/null +++ b/src/main/java/com/meteroid/models/UsageCost.java @@ -0,0 +1,266 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.Utils; + +import java.math.BigDecimal; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; + +/** + * Usage priced as its invoice line prices it, before discounts and credits: tax-inclusive when the + * subscription's prices are. + * + *

Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonAutoDetect( + getterVisibility = Visibility.NONE, + isGetterVisibility = Visibility.NONE, + setterVisibility = Visibility.NONE) +public final class UsageCost { + @JsonProperty("amount") + private BigDecimal amount; + + @JsonProperty("currency") + private String currency; + + @JsonProperty("unit") + private UsageCostUnit unit; + + private final Map additionalProperties = new LinkedHashMap<>(); + + private UsageCost() {} + + private UsageCost(Builder builder) { + this.amount = builder.amount; + this.currency = builder.currency; + this.unit = builder.unit; + this.additionalProperties.putAll(builder.additionalProperties); + } + + /** + * A builder of {@code UsageCost}. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * A builder starting from this value. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.amount = amount; + builder.currency = currency; + builder.unit = unit; + builder.additionalProperties.putAll(additionalProperties); + return builder; + } + + /** + * The {@code amount} property. + * + * @return the value, never null + */ + public BigDecimal amount() { + return Utils.required(amount, "amount"); + } + + /** + * A currency code, or a credit unit code when unit is CREDIT_UNIT. + * + * @return the value, never null + */ + public String currency() { + return Utils.required(currency, "currency"); + } + + /** + * The {@code unit} property. + * + * @return the value, never null + */ + public UsageCostUnit unit() { + return Utils.required(unit, "unit"); + } + + /** + * Properties this version of the SDK does not know, kept as received and sent back. + * + * @return the properties by name, unmodifiable + */ + public Map additionalProperties() { + return Collections.unmodifiableMap(additionalProperties); + } + + @JsonAnyGetter + private Map anyProperties() { + return additionalProperties; + } + + @JsonAnySetter + private void putAnyProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + UsageCost that = (UsageCost) o; + return Objects.equals(amount, that.amount) + && Objects.equals(currency, that.currency) + && Objects.equals(unit, that.unit) + && Objects.equals(additionalProperties, that.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(amount, currency, unit, additionalProperties); + } + + @Override + public String toString() { + return "UsageCost{" + + "amount=" + + amount + + ", currency=" + + currency + + ", unit=" + + unit + + ", additionalProperties=" + + additionalProperties + + "}"; + } + + /** Builds {@link UsageCost}. */ + public static final class Builder { + private BigDecimal amount; + private String currency; + private UsageCostUnit unit; + private final Map additionalProperties = new LinkedHashMap<>(); + + private Builder() {} + + /** + * The {@code amount} property. + * + * @param amount the value + * @return this builder + */ + public Builder amount(BigDecimal amount) { + this.amount = amount; + return this; + } + + /** + * A currency code, or a credit unit code when unit is CREDIT_UNIT + * . + * + * @param currency the value + * @return this builder + */ + public Builder currency(String currency) { + this.currency = currency; + return this; + } + + /** + * The {@code unit} property. + * + * @param unit the value + * @return this builder + */ + public Builder unit(UsageCostUnit unit) { + this.unit = unit; + return this; + } + + /** + * A property the SDK does not know, sent along. + * + * @param name the property name + * @param value the JSON value + * @return this builder + */ + public Builder putAdditionalProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + return this; + } + + /** + * Properties the SDK does not know, sent along. + * + * @param additionalProperties the properties by name + * @return this builder + */ + public Builder putAllAdditionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + + /** + * Leaves out a property the SDK does not know. + * + * @param name the property name + * @return this builder + */ + public Builder removeAdditionalProperty(String name) { + additionalProperties.remove(name); + return this; + } + + /** + * The {@code UsageCost}. + * + * @return the immutable value + * @throws IllegalStateException when a required property is not set + */ + public UsageCost build() { + Utils.checkRequired(amount, "amount"); + Utils.checkRequired(currency, "currency"); + Utils.checkRequired(unit, "unit"); + return new UsageCost(this); + } + } + + /** + * Parse {@code json} as {@code UsageCost}. + * + * @param json the JSON text + * @return the value + * @throws com.meteroid.exceptions.InvalidDataException if it is not valid JSON of this shape + */ + public static UsageCost fromJson(String json) { + return Utils.parse(json, UsageCost.class); + } + + /** + * This value as JSON. + * + * @return the JSON text + */ + public String toJson() { + return Utils.json(this); + } +} diff --git a/src/main/java/com/meteroid/models/UsageCostListResponse.java b/src/main/java/com/meteroid/models/UsageCostListResponse.java new file mode 100644 index 0000000..c9f6ea8 --- /dev/null +++ b/src/main/java/com/meteroid/models/UsageCostListResponse.java @@ -0,0 +1,215 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.Utils; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonAutoDetect( + getterVisibility = Visibility.NONE, + isGetterVisibility = Visibility.NONE, + setterVisibility = Visibility.NONE) +public final class UsageCostListResponse { + @JsonProperty("data") + private List data; + + private final Map additionalProperties = new LinkedHashMap<>(); + + private UsageCostListResponse() {} + + private UsageCostListResponse(Builder builder) { + this.data = Utils.copyList(builder.data); + this.additionalProperties.putAll(builder.additionalProperties); + } + + /** + * A builder of {@code UsageCostListResponse}. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * A builder starting from this value. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.data = Utils.mutableList(data); + builder.additionalProperties.putAll(additionalProperties); + return builder; + } + + /** + * The {@code data} property. + * + * @return the value, never null + */ + public List data() { + return Utils.required(data, "data"); + } + + /** + * Properties this version of the SDK does not know, kept as received and sent back. + * + * @return the properties by name, unmodifiable + */ + public Map additionalProperties() { + return Collections.unmodifiableMap(additionalProperties); + } + + @JsonAnyGetter + private Map anyProperties() { + return additionalProperties; + } + + @JsonAnySetter + private void putAnyProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + UsageCostListResponse that = (UsageCostListResponse) o; + return Objects.equals(data, that.data) + && Objects.equals(additionalProperties, that.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(data, additionalProperties); + } + + @Override + public String toString() { + return "UsageCostListResponse{" + + "data=" + + data + + ", additionalProperties=" + + additionalProperties + + "}"; + } + + /** Builds {@link UsageCostListResponse}. */ + public static final class Builder { + private List data; + private final Map additionalProperties = new LinkedHashMap<>(); + + private Builder() {} + + /** + * The {@code data} property. + * + * @param data the value + * @return this builder + */ + public Builder data(List data) { + this.data = Utils.mutableList(data); + return this; + } + + /** + * Adds an item to {@code data}. + * + * @param item the item + * @return this builder + */ + public Builder addDataItem(UsageCostRow item) { + if (this.data == null) { + this.data = new ArrayList<>(); + } + this.data.add(item); + return this; + } + + /** + * A property the SDK does not know, sent along. + * + * @param name the property name + * @param value the JSON value + * @return this builder + */ + public Builder putAdditionalProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + return this; + } + + /** + * Properties the SDK does not know, sent along. + * + * @param additionalProperties the properties by name + * @return this builder + */ + public Builder putAllAdditionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + + /** + * Leaves out a property the SDK does not know. + * + * @param name the property name + * @return this builder + */ + public Builder removeAdditionalProperty(String name) { + additionalProperties.remove(name); + return this; + } + + /** + * The {@code UsageCostListResponse}. + * + * @return the immutable value + * @throws IllegalStateException when a required property is not set + */ + public UsageCostListResponse build() { + Utils.checkRequired(data, "data"); + return new UsageCostListResponse(this); + } + } + + /** + * Parse {@code json} as {@code UsageCostListResponse}. + * + * @param json the JSON text + * @return the value + * @throws com.meteroid.exceptions.InvalidDataException if it is not valid JSON of this shape + */ + public static UsageCostListResponse fromJson(String json) { + return Utils.parse(json, UsageCostListResponse.class); + } + + /** + * This value as JSON. + * + * @return the JSON text + */ + public String toJson() { + return Utils.json(this); + } +} diff --git a/src/main/java/com/meteroid/models/UsageCostRow.java b/src/main/java/com/meteroid/models/UsageCostRow.java new file mode 100644 index 0000000..aa19e30 --- /dev/null +++ b/src/main/java/com/meteroid/models/UsageCostRow.java @@ -0,0 +1,329 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.JsonField; +import com.meteroid.internal.Utils; + +import java.math.BigDecimal; +import java.time.OffsetDateTime; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +/** Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonAutoDetect( + getterVisibility = Visibility.NONE, + isGetterVisibility = Visibility.NONE, + setterVisibility = Visibility.NONE) +public final class UsageCostRow { + @JsonProperty("bucket_start") + private OffsetDateTime bucketStart; + + @JsonProperty("cost") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField cost = JsonField.missing(); + + @JsonProperty("exact") + private Boolean exact; + + @JsonProperty("group") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField group = JsonField.missing(); + + @JsonProperty("quantity") + private BigDecimal quantity; + + private final Map additionalProperties = new LinkedHashMap<>(); + + private UsageCostRow() {} + + private UsageCostRow(Builder builder) { + this.bucketStart = builder.bucketStart; + this.cost = builder.cost; + this.exact = builder.exact; + this.group = builder.group; + this.quantity = builder.quantity; + this.additionalProperties.putAll(builder.additionalProperties); + } + + /** + * A builder of {@code UsageCostRow}. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * A builder starting from this value. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.bucketStart = bucketStart; + builder.cost = cost; + builder.exact = exact; + builder.group = group; + builder.quantity = quantity; + builder.additionalProperties.putAll(additionalProperties); + return builder; + } + + /** + * The {@code bucket_start} property. + * + * @return the value, never null + */ + public OffsetDateTime bucketStart() { + return Utils.required(bucketStart, "bucket_start"); + } + + /** + * The {@code cost} property. + * + * @return the value, empty when unset or null + */ + public Optional cost() { + return cost.asOptional(); + } + + /** + * False when the price depends on the whole period's usage (tiered, volume, package, capacity): + * the cost is then what the bucket adds to the period's price so far. A period's rows still add + * up to its invoiced amount. + * + * @return the value, never null + */ + public Boolean exact() { + return Utils.required(exact, "exact"); + } + + /** + * The value of group_by for the row. Absent when the request is not grouped, or + * the usage has no value for the property. + * + * @return the value, empty when unset or null + */ + public Optional group() { + return group.asOptional(); + } + + /** + * The {@code quantity} property. + * + * @return the value, never null + */ + public BigDecimal quantity() { + return Utils.required(quantity, "quantity"); + } + + /** + * Properties this version of the SDK does not know, kept as received and sent back. + * + * @return the properties by name, unmodifiable + */ + public Map additionalProperties() { + return Collections.unmodifiableMap(additionalProperties); + } + + @JsonAnyGetter + private Map anyProperties() { + return additionalProperties; + } + + @JsonAnySetter + private void putAnyProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + UsageCostRow that = (UsageCostRow) o; + return Objects.equals(bucketStart, that.bucketStart) + && Objects.equals(cost, that.cost) + && Objects.equals(exact, that.exact) + && Objects.equals(group, that.group) + && Objects.equals(quantity, that.quantity) + && Objects.equals(additionalProperties, that.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(bucketStart, cost, exact, group, quantity, additionalProperties); + } + + @Override + public String toString() { + return "UsageCostRow{" + + "bucketStart=" + + bucketStart + + ", cost=" + + cost + + ", exact=" + + exact + + ", group=" + + group + + ", quantity=" + + quantity + + ", additionalProperties=" + + additionalProperties + + "}"; + } + + /** Builds {@link UsageCostRow}. */ + public static final class Builder { + private OffsetDateTime bucketStart; + private JsonField cost = JsonField.missing(); + private Boolean exact; + private JsonField group = JsonField.missing(); + private BigDecimal quantity; + private final Map additionalProperties = new LinkedHashMap<>(); + + private Builder() {} + + /** + * The {@code bucket_start} property. + * + * @param bucketStart the value + * @return this builder + */ + public Builder bucketStart(OffsetDateTime bucketStart) { + this.bucketStart = bucketStart; + return this; + } + + /** + * The {@code cost} property. + * + * @param cost the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder cost(UsageCost cost) { + this.cost = JsonField.ofNullable(cost); + return this; + } + + /** + * False when the price depends on the whole period's usage (tiered, volume, package, + * capacity): the cost is then what the bucket adds to the period's price so far. A period's + * rows still add up to its invoiced amount. + * + * @param exact the value + * @return this builder + */ + public Builder exact(Boolean exact) { + this.exact = exact; + return this; + } + + /** + * The value of group_by for the row. Absent when the request is not grouped, + * or the usage has no value for the property. + * + * @param group the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder group(String group) { + this.group = JsonField.ofNullable(group); + return this; + } + + /** + * The {@code quantity} property. + * + * @param quantity the value + * @return this builder + */ + public Builder quantity(BigDecimal quantity) { + this.quantity = quantity; + return this; + } + + /** + * A property the SDK does not know, sent along. + * + * @param name the property name + * @param value the JSON value + * @return this builder + */ + public Builder putAdditionalProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + return this; + } + + /** + * Properties the SDK does not know, sent along. + * + * @param additionalProperties the properties by name + * @return this builder + */ + public Builder putAllAdditionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + + /** + * Leaves out a property the SDK does not know. + * + * @param name the property name + * @return this builder + */ + public Builder removeAdditionalProperty(String name) { + additionalProperties.remove(name); + return this; + } + + /** + * The {@code UsageCostRow}. + * + * @return the immutable value + * @throws IllegalStateException when a required property is not set + */ + public UsageCostRow build() { + Utils.checkRequired(bucketStart, "bucket_start"); + Utils.checkRequired(exact, "exact"); + Utils.checkRequired(quantity, "quantity"); + return new UsageCostRow(this); + } + } + + /** + * Parse {@code json} as {@code UsageCostRow}. + * + * @param json the JSON text + * @return the value + * @throws com.meteroid.exceptions.InvalidDataException if it is not valid JSON of this shape + */ + public static UsageCostRow fromJson(String json) { + return Utils.parse(json, UsageCostRow.class); + } + + /** + * This value as JSON. + * + * @return the JSON text + */ + public String toJson() { + return Utils.json(this); + } +} diff --git a/src/main/java/com/meteroid/models/UsageCostUnit.java b/src/main/java/com/meteroid/models/UsageCostUnit.java new file mode 100644 index 0000000..6a3bcdd --- /dev/null +++ b/src/main/java/com/meteroid/models/UsageCostUnit.java @@ -0,0 +1,129 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import com.meteroid.internal.Utils.ToQueryParam; + +import java.util.Map; +import java.util.Objects; + +/** + * What a cost is counted in. + * + *

Values this version of the SDK does not know are kept, and sent back unchanged: {@link + * #value()} is an enum to switch on, {@code _UNKNOWN} for them, and {@link #known()} throws on + * them. + */ +public final class UsageCostUnit implements ToQueryParam { + /** The value {@code "CURRENCY"}. */ + public static final UsageCostUnit CURRENCY = new UsageCostUnit("CURRENCY", Value.CURRENCY); + + /** The value {@code "CREDIT_UNIT"}. */ + public static final UsageCostUnit CREDIT_UNIT = + new UsageCostUnit("CREDIT_UNIT", Value.CREDIT_UNIT); + + private static final Map constants = + Map.ofEntries(Map.entry("CURRENCY", CURRENCY), Map.entry("CREDIT_UNIT", CREDIT_UNIT)); + + private final String value; + private final Value variant; + + private UsageCostUnit(String value, Value variant) { + this.value = value; + this.variant = variant; + } + + /** + * The constant for {@code value}, or an unknown UsageCostUnit holding it. + * + * @param value the value + * @return the constant + */ + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static UsageCostUnit of(String value) { + UsageCostUnit constant = constants.get(Objects.requireNonNull(value, "value")); + return constant != null ? constant : new UsageCostUnit(value, Value._UNKNOWN); + } + + /** + * The value as sent. + * + * @return the value + */ + @JsonValue + public String asString() { + return value; + } + + /** + * Whether this version of the SDK knows the value. + * + * @return whether it is known + */ + public boolean isKnown() { + return variant != Value._UNKNOWN; + } + + /** + * The value as an enum to switch on, unknown values included. + * + * @return the enum, {@code _UNKNOWN} when unknown + */ + public Value value() { + return variant; + } + + /** + * The value as an enum of the known values only. + * + * @return the enum + * @throws com.meteroid.exceptions.InvalidDataException when this version of the SDK does not + * know the value + */ + public Known known() { + if (!isKnown()) { + throw new com.meteroid.exceptions.InvalidDataException( + "unknown UsageCostUnit: " + value); + } + return Known.valueOf(variant.name()); + } + + @Override + public String toQueryParam() { + return String.valueOf(value); + } + + @Override + public boolean equals(Object o) { + return o instanceof UsageCostUnit && Objects.equals(value, ((UsageCostUnit) o).value); + } + + @Override + public int hashCode() { + return Objects.hashCode(value); + } + + @Override + public String toString() { + return String.valueOf(value); + } + + /** The values this version of the SDK knows. */ + public enum Known { + /** The {@code CURRENCY} constant. */ + CURRENCY, + /** The {@code CREDIT_UNIT} constant. */ + CREDIT_UNIT + } + + /** The values this version of the SDK knows, and {@code _UNKNOWN} for the others. */ + public enum Value { + /** The {@code CURRENCY} constant. */ + CURRENCY, + /** The {@code CREDIT_UNIT} constant. */ + CREDIT_UNIT, + /** A value this version of the SDK does not know. */ + _UNKNOWN + } +} diff --git a/src/main/java/com/meteroid/models/UsageEvent.java b/src/main/java/com/meteroid/models/UsageEvent.java new file mode 100644 index 0000000..ff3ebc5 --- /dev/null +++ b/src/main/java/com/meteroid/models/UsageEvent.java @@ -0,0 +1,340 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.JsonField; +import com.meteroid.internal.Utils; + +import java.math.BigDecimal; +import java.time.OffsetDateTime; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +/** Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonAutoDetect( + getterVisibility = Visibility.NONE, + isGetterVisibility = Visibility.NONE, + setterVisibility = Visibility.NONE) +public final class UsageEvent { + @JsonProperty("cost") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField cost = JsonField.missing(); + + @JsonProperty("id") + private String id; + + @JsonProperty("properties") + private Map properties; + + @JsonProperty("quantity") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField quantity = JsonField.missing(); + + @JsonProperty("timestamp") + private OffsetDateTime timestamp; + + private final Map additionalProperties = new LinkedHashMap<>(); + + private UsageEvent() {} + + private UsageEvent(Builder builder) { + this.cost = builder.cost; + this.id = builder.id; + this.properties = Utils.copyMap(builder.properties); + this.quantity = builder.quantity; + this.timestamp = builder.timestamp; + this.additionalProperties.putAll(builder.additionalProperties); + } + + /** + * A builder of {@code UsageEvent}. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * A builder starting from this value. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.cost = cost; + builder.id = id; + builder.properties = Utils.mutableMap(properties); + builder.quantity = quantity; + builder.timestamp = timestamp; + builder.additionalProperties.putAll(additionalProperties); + return builder; + } + + /** + * The {@code cost} property. + * + * @return the value, empty when unset or null + */ + public Optional cost() { + return cost.asOptional(); + } + + /** + * The {@code id} property. + * + * @return the value, never null + */ + public String id() { + return Utils.required(id, "id"); + } + + /** + * The {@code properties} property. + * + * @return the value, never null + */ + public Map properties() { + return Utils.required(properties, "properties"); + } + + /** + * Billed units the event adds. Absent when the metric's aggregation cannot be split per event, + * or when the event does not count towards the metric. + * + * @return the value, empty when unset or null + */ + public Optional quantity() { + return quantity.asOptional(); + } + + /** + * The {@code timestamp} property. + * + * @return the value, never null + */ + public OffsetDateTime timestamp() { + return Utils.required(timestamp, "timestamp"); + } + + /** + * Properties this version of the SDK does not know, kept as received and sent back. + * + * @return the properties by name, unmodifiable + */ + public Map additionalProperties() { + return Collections.unmodifiableMap(additionalProperties); + } + + @JsonAnyGetter + private Map anyProperties() { + return additionalProperties; + } + + @JsonAnySetter + private void putAnyProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + UsageEvent that = (UsageEvent) o; + return Objects.equals(cost, that.cost) + && Objects.equals(id, that.id) + && Objects.equals(properties, that.properties) + && Objects.equals(quantity, that.quantity) + && Objects.equals(timestamp, that.timestamp) + && Objects.equals(additionalProperties, that.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(cost, id, properties, quantity, timestamp, additionalProperties); + } + + @Override + public String toString() { + return "UsageEvent{" + + "cost=" + + cost + + ", id=" + + id + + ", properties=" + + properties + + ", quantity=" + + quantity + + ", timestamp=" + + timestamp + + ", additionalProperties=" + + additionalProperties + + "}"; + } + + /** Builds {@link UsageEvent}. */ + public static final class Builder { + private JsonField cost = JsonField.missing(); + private String id; + private Map properties; + private JsonField quantity = JsonField.missing(); + private OffsetDateTime timestamp; + private final Map additionalProperties = new LinkedHashMap<>(); + + private Builder() {} + + /** + * The {@code cost} property. + * + * @param cost the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder cost(UsageCost cost) { + this.cost = JsonField.ofNullable(cost); + return this; + } + + /** + * The {@code id} property. + * + * @param id the value + * @return this builder + */ + public Builder id(String id) { + this.id = id; + return this; + } + + /** + * The {@code properties} property. + * + * @param properties the value + * @return this builder + */ + public Builder properties(Map properties) { + this.properties = Utils.mutableMap(properties); + return this; + } + + /** + * Puts an entry in {@code properties}. + * + * @param key the key + * @param item the item + * @return this builder + */ + public Builder putPropertiesItem(String key, String item) { + if (this.properties == null) { + this.properties = new LinkedHashMap<>(); + } + this.properties.put(key, item); + return this; + } + + /** + * Billed units the event adds. Absent when the metric's aggregation cannot be split per + * event, or when the event does not count towards the metric. + * + * @param quantity the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder quantity(BigDecimal quantity) { + this.quantity = JsonField.ofNullable(quantity); + return this; + } + + /** + * The {@code timestamp} property. + * + * @param timestamp the value + * @return this builder + */ + public Builder timestamp(OffsetDateTime timestamp) { + this.timestamp = timestamp; + return this; + } + + /** + * A property the SDK does not know, sent along. + * + * @param name the property name + * @param value the JSON value + * @return this builder + */ + public Builder putAdditionalProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + return this; + } + + /** + * Properties the SDK does not know, sent along. + * + * @param additionalProperties the properties by name + * @return this builder + */ + public Builder putAllAdditionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + + /** + * Leaves out a property the SDK does not know. + * + * @param name the property name + * @return this builder + */ + public Builder removeAdditionalProperty(String name) { + additionalProperties.remove(name); + return this; + } + + /** + * The {@code UsageEvent}. + * + * @return the immutable value + * @throws IllegalStateException when a required property is not set + */ + public UsageEvent build() { + Utils.checkRequired(id, "id"); + Utils.checkRequired(properties, "properties"); + Utils.checkRequired(timestamp, "timestamp"); + return new UsageEvent(this); + } + } + + /** + * Parse {@code json} as {@code UsageEvent}. + * + * @param json the JSON text + * @return the value + * @throws com.meteroid.exceptions.InvalidDataException if it is not valid JSON of this shape + */ + public static UsageEvent fromJson(String json) { + return Utils.parse(json, UsageEvent.class); + } + + /** + * This value as JSON. + * + * @return the JSON text + */ + public String toJson() { + return Utils.json(this); + } +} diff --git a/src/main/java/com/meteroid/models/UsageEventListResponse.java b/src/main/java/com/meteroid/models/UsageEventListResponse.java new file mode 100644 index 0000000..5c04cd1 --- /dev/null +++ b/src/main/java/com/meteroid/models/UsageEventListResponse.java @@ -0,0 +1,247 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.JsonField; +import com.meteroid.internal.Utils; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +/** Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonAutoDetect( + getterVisibility = Visibility.NONE, + isGetterVisibility = Visibility.NONE, + setterVisibility = Visibility.NONE) +public final class UsageEventListResponse { + @JsonProperty("data") + private List data; + + @JsonProperty("next_cursor") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField nextCursor = JsonField.missing(); + + private final Map additionalProperties = new LinkedHashMap<>(); + + private UsageEventListResponse() {} + + private UsageEventListResponse(Builder builder) { + this.data = Utils.copyList(builder.data); + this.nextCursor = builder.nextCursor; + this.additionalProperties.putAll(builder.additionalProperties); + } + + /** + * A builder of {@code UsageEventListResponse}. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * A builder starting from this value. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.data = Utils.mutableList(data); + builder.nextCursor = nextCursor; + builder.additionalProperties.putAll(additionalProperties); + return builder; + } + + /** + * The {@code data} property. + * + * @return the value, never null + */ + public List data() { + return Utils.required(data, "data"); + } + + /** + * Absent on the last page. + * + * @return the value, empty when unset or null + */ + public Optional nextCursor() { + return nextCursor.asOptional(); + } + + /** + * Properties this version of the SDK does not know, kept as received and sent back. + * + * @return the properties by name, unmodifiable + */ + public Map additionalProperties() { + return Collections.unmodifiableMap(additionalProperties); + } + + @JsonAnyGetter + private Map anyProperties() { + return additionalProperties; + } + + @JsonAnySetter + private void putAnyProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + UsageEventListResponse that = (UsageEventListResponse) o; + return Objects.equals(data, that.data) + && Objects.equals(nextCursor, that.nextCursor) + && Objects.equals(additionalProperties, that.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(data, nextCursor, additionalProperties); + } + + @Override + public String toString() { + return "UsageEventListResponse{" + + "data=" + + data + + ", nextCursor=" + + nextCursor + + ", additionalProperties=" + + additionalProperties + + "}"; + } + + /** Builds {@link UsageEventListResponse}. */ + public static final class Builder { + private List data; + private JsonField nextCursor = JsonField.missing(); + private final Map additionalProperties = new LinkedHashMap<>(); + + private Builder() {} + + /** + * The {@code data} property. + * + * @param data the value + * @return this builder + */ + public Builder data(List data) { + this.data = Utils.mutableList(data); + return this; + } + + /** + * Adds an item to {@code data}. + * + * @param item the item + * @return this builder + */ + public Builder addDataItem(UsageEvent item) { + if (this.data == null) { + this.data = new ArrayList<>(); + } + this.data.add(item); + return this; + } + + /** + * Absent on the last page. + * + * @param nextCursor the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder nextCursor(String nextCursor) { + this.nextCursor = JsonField.ofNullable(nextCursor); + return this; + } + + /** + * A property the SDK does not know, sent along. + * + * @param name the property name + * @param value the JSON value + * @return this builder + */ + public Builder putAdditionalProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + return this; + } + + /** + * Properties the SDK does not know, sent along. + * + * @param additionalProperties the properties by name + * @return this builder + */ + public Builder putAllAdditionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + + /** + * Leaves out a property the SDK does not know. + * + * @param name the property name + * @return this builder + */ + public Builder removeAdditionalProperty(String name) { + additionalProperties.remove(name); + return this; + } + + /** + * The {@code UsageEventListResponse}. + * + * @return the immutable value + * @throws IllegalStateException when a required property is not set + */ + public UsageEventListResponse build() { + Utils.checkRequired(data, "data"); + return new UsageEventListResponse(this); + } + } + + /** + * Parse {@code json} as {@code UsageEventListResponse}. + * + * @param json the JSON text + * @return the value + * @throws com.meteroid.exceptions.InvalidDataException if it is not valid JSON of this shape + */ + public static UsageEventListResponse fromJson(String json) { + return Utils.parse(json, UsageEventListResponse.class); + } + + /** + * This value as JSON. + * + * @return the JSON text + */ + public String toJson() { + return Utils.json(this); + } +} diff --git a/src/main/java/com/meteroid/models/UsageFee.java b/src/main/java/com/meteroid/models/UsageFee.java index 9f35d2d..d31f407 100644 --- a/src/main/java/com/meteroid/models/UsageFee.java +++ b/src/main/java/com/meteroid/models/UsageFee.java @@ -9,12 +9,14 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.JsonField; import com.meteroid.internal.Utils; import java.util.Collections; import java.util.LinkedHashMap; import java.util.Map; import java.util.Objects; +import java.util.Optional; /** Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. */ @JsonInclude(JsonInclude.Include.NON_NULL) @@ -24,19 +26,28 @@ isGetterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE) public final class UsageFee { + @JsonProperty("credit_unit") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField creditUnit = JsonField.missing(); + @JsonProperty("metric_id") private String metricId; @JsonProperty("model") private UsagePricingModel model; + @JsonProperty("type") + private String type = "USAGE"; + private final Map additionalProperties = new LinkedHashMap<>(); private UsageFee() {} private UsageFee(Builder builder) { + this.creditUnit = builder.creditUnit; this.metricId = builder.metricId; this.model = builder.model; + this.type = builder.type; this.additionalProperties.putAll(builder.additionalProperties); } @@ -56,12 +67,23 @@ public static Builder builder() { */ public Builder toBuilder() { Builder builder = new Builder(); + builder.creditUnit = creditUnit; builder.metricId = metricId; builder.model = model; + builder.type = type; builder.additionalProperties.putAll(additionalProperties); return builder; } + /** + * The {@code credit_unit} property. + * + * @return the value, empty when unset or null + */ + public Optional creditUnit() { + return creditUnit.asOptional(); + } + /** * The {@code metric_id} property. * @@ -80,6 +102,15 @@ public UsagePricingModel model() { return Utils.required(model, "model"); } + /** + * The {@code type} property. + * + * @return the value, never null + */ + public String type() { + return Utils.required(type, "type"); + } + /** * Properties this version of the SDK does not know, kept as received and sent back. * @@ -108,23 +139,29 @@ public boolean equals(Object o) { return false; } UsageFee that = (UsageFee) o; - return Objects.equals(metricId, that.metricId) + return Objects.equals(creditUnit, that.creditUnit) + && Objects.equals(metricId, that.metricId) && Objects.equals(model, that.model) + && Objects.equals(type, that.type) && Objects.equals(additionalProperties, that.additionalProperties); } @Override public int hashCode() { - return Objects.hash(metricId, model, additionalProperties); + return Objects.hash(creditUnit, metricId, model, type, additionalProperties); } @Override public String toString() { return "UsageFee{" - + "metricId=" + + "creditUnit=" + + creditUnit + + ", metricId=" + metricId + ", model=" + model + + ", type=" + + type + ", additionalProperties=" + additionalProperties + "}"; @@ -132,12 +169,25 @@ public String toString() { /** Builds {@link UsageFee}. */ public static final class Builder { + private JsonField creditUnit = JsonField.missing(); private String metricId; private UsagePricingModel model; + private String type = "USAGE"; private final Map additionalProperties = new LinkedHashMap<>(); private Builder() {} + /** + * The {@code credit_unit} property. + * + * @param creditUnit the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder creditUnit(FeeCreditUnit creditUnit) { + this.creditUnit = JsonField.ofNullable(creditUnit); + return this; + } + /** * The {@code metric_id} property. * @@ -160,6 +210,17 @@ public Builder model(UsagePricingModel model) { return this; } + /** + * The {@code type} property. + * + * @param type the value + * @return this builder + */ + public Builder type(String type) { + this.type = type; + return this; + } + /** * A property the SDK does not know, sent along. * @@ -203,6 +264,7 @@ public Builder removeAdditionalProperty(String name) { public UsageFee build() { Utils.checkRequired(metricId, "metric_id"); Utils.checkRequired(model, "model"); + Utils.checkRequired(type, "type"); return new UsageFee(this); } } diff --git a/src/main/java/com/meteroid/models/UsageFeeStructure.java b/src/main/java/com/meteroid/models/UsageFeeStructure.java index 9dfde03..1dcb517 100644 --- a/src/main/java/com/meteroid/models/UsageFeeStructure.java +++ b/src/main/java/com/meteroid/models/UsageFeeStructure.java @@ -30,6 +30,9 @@ public final class UsageFeeStructure { @JsonProperty("model") private UsageModelEnum model; + @JsonProperty("type") + private String type = "USAGE"; + private final Map additionalProperties = new LinkedHashMap<>(); private UsageFeeStructure() {} @@ -37,6 +40,7 @@ private UsageFeeStructure() {} private UsageFeeStructure(Builder builder) { this.metricId = builder.metricId; this.model = builder.model; + this.type = builder.type; this.additionalProperties.putAll(builder.additionalProperties); } @@ -58,6 +62,7 @@ public Builder toBuilder() { Builder builder = new Builder(); builder.metricId = metricId; builder.model = model; + builder.type = type; builder.additionalProperties.putAll(additionalProperties); return builder; } @@ -80,6 +85,15 @@ public UsageModelEnum model() { return Utils.required(model, "model"); } + /** + * The {@code type} property. + * + * @return the value, never null + */ + public String type() { + return Utils.required(type, "type"); + } + /** * Properties this version of the SDK does not know, kept as received and sent back. * @@ -110,12 +124,13 @@ public boolean equals(Object o) { UsageFeeStructure that = (UsageFeeStructure) o; return Objects.equals(metricId, that.metricId) && Objects.equals(model, that.model) + && Objects.equals(type, that.type) && Objects.equals(additionalProperties, that.additionalProperties); } @Override public int hashCode() { - return Objects.hash(metricId, model, additionalProperties); + return Objects.hash(metricId, model, type, additionalProperties); } @Override @@ -125,6 +140,8 @@ public String toString() { + metricId + ", model=" + model + + ", type=" + + type + ", additionalProperties=" + additionalProperties + "}"; @@ -134,6 +151,7 @@ public String toString() { public static final class Builder { private String metricId; private UsageModelEnum model; + private String type = "USAGE"; private final Map additionalProperties = new LinkedHashMap<>(); private Builder() {} @@ -160,6 +178,17 @@ public Builder model(UsageModelEnum model) { return this; } + /** + * The {@code type} property. + * + * @param type the value + * @return this builder + */ + public Builder type(String type) { + this.type = type; + return this; + } + /** * A property the SDK does not know, sent along. * @@ -203,6 +232,7 @@ public Builder removeAdditionalProperty(String name) { public UsageFeeStructure build() { Utils.checkRequired(metricId, "metric_id"); Utils.checkRequired(model, "model"); + Utils.checkRequired(type, "type"); return new UsageFeeStructure(this); } } diff --git a/src/main/java/com/meteroid/models/UsageFilter.java b/src/main/java/com/meteroid/models/UsageFilter.java new file mode 100644 index 0000000..5915fb2 --- /dev/null +++ b/src/main/java/com/meteroid/models/UsageFilter.java @@ -0,0 +1,239 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.Utils; + +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; + +/** + * Restricts the customer's usage events a subscription bills to those whose property + * equals value (for example api_key = key-A). Among the + * customer's subscriptions pricing the same metric, one with a usage filter bills the events + * matching it (an event two filters match goes to the older subscription); one without bills the + * events matching no other subscription's filter. Two subscriptions without a usage filter both + * bill every such event. Events matching no filter while every subscription pricing their metric + * has one are billed by none and reported as unattributed usage. + * + *

Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonAutoDetect( + getterVisibility = Visibility.NONE, + isGetterVisibility = Visibility.NONE, + setterVisibility = Visibility.NONE) +public final class UsageFilter { + @JsonProperty("property") + private String property; + + @JsonProperty("value") + private String value; + + private final Map additionalProperties = new LinkedHashMap<>(); + + private UsageFilter() {} + + private UsageFilter(Builder builder) { + this.property = builder.property; + this.value = builder.value; + this.additionalProperties.putAll(builder.additionalProperties); + } + + /** + * A builder of {@code UsageFilter}. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * A builder starting from this value. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.property = property; + builder.value = value; + builder.additionalProperties.putAll(additionalProperties); + return builder; + } + + /** + * Event property name, e.g. api_key. + * + * @return the value, never null + */ + public String property() { + return Utils.required(property, "property"); + } + + /** + * Value the property must have. + * + * @return the value, never null + */ + public String value() { + return Utils.required(value, "value"); + } + + /** + * Properties this version of the SDK does not know, kept as received and sent back. + * + * @return the properties by name, unmodifiable + */ + public Map additionalProperties() { + return Collections.unmodifiableMap(additionalProperties); + } + + @JsonAnyGetter + private Map anyProperties() { + return additionalProperties; + } + + @JsonAnySetter + private void putAnyProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + UsageFilter that = (UsageFilter) o; + return Objects.equals(property, that.property) + && Objects.equals(value, that.value) + && Objects.equals(additionalProperties, that.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(property, value, additionalProperties); + } + + @Override + public String toString() { + return "UsageFilter{" + + "property=" + + property + + ", value=" + + value + + ", additionalProperties=" + + additionalProperties + + "}"; + } + + /** Builds {@link UsageFilter}. */ + public static final class Builder { + private String property; + private String value; + private final Map additionalProperties = new LinkedHashMap<>(); + + private Builder() {} + + /** + * Event property name, e.g. api_key. + * + * @param property the value + * @return this builder + */ + public Builder property(String property) { + this.property = property; + return this; + } + + /** + * Value the property must have. + * + * @param value the value + * @return this builder + */ + public Builder value(String value) { + this.value = value; + return this; + } + + /** + * A property the SDK does not know, sent along. + * + * @param name the property name + * @param value the JSON value + * @return this builder + */ + public Builder putAdditionalProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + return this; + } + + /** + * Properties the SDK does not know, sent along. + * + * @param additionalProperties the properties by name + * @return this builder + */ + public Builder putAllAdditionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + + /** + * Leaves out a property the SDK does not know. + * + * @param name the property name + * @return this builder + */ + public Builder removeAdditionalProperty(String name) { + additionalProperties.remove(name); + return this; + } + + /** + * The {@code UsageFilter}. + * + * @return the immutable value + * @throws IllegalStateException when a required property is not set + */ + public UsageFilter build() { + Utils.checkRequired(property, "property"); + Utils.checkRequired(value, "value"); + return new UsageFilter(this); + } + } + + /** + * Parse {@code json} as {@code UsageFilter}. + * + * @param json the JSON text + * @return the value + * @throws com.meteroid.exceptions.InvalidDataException if it is not valid JSON of this shape + */ + public static UsageFilter fromJson(String json) { + return Utils.parse(json, UsageFilter.class); + } + + /** + * This value as JSON. + * + * @return the JSON text + */ + public String toJson() { + return Utils.json(this); + } +} diff --git a/src/main/java/com/meteroid/models/UsagePlanFee.java b/src/main/java/com/meteroid/models/UsagePlanFee.java index 6151011..379b31a 100644 --- a/src/main/java/com/meteroid/models/UsagePlanFee.java +++ b/src/main/java/com/meteroid/models/UsagePlanFee.java @@ -9,12 +9,14 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.JsonField; import com.meteroid.internal.Utils; import java.util.Collections; import java.util.LinkedHashMap; import java.util.Map; import java.util.Objects; +import java.util.Optional; /** * Usage-based fee @@ -31,20 +33,29 @@ public final class UsagePlanFee { @JsonProperty("cadence") private BillingPeriodEnum cadence; + @JsonProperty("credit_unit") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField creditUnit = JsonField.missing(); + @JsonProperty("metric_id") private String metricId; @JsonProperty("pricing") private PlanUsagePricingModel pricing; + @JsonProperty("type") + private String type = "USAGE"; + private final Map additionalProperties = new LinkedHashMap<>(); private UsagePlanFee() {} private UsagePlanFee(Builder builder) { this.cadence = builder.cadence; + this.creditUnit = builder.creditUnit; this.metricId = builder.metricId; this.pricing = builder.pricing; + this.type = builder.type; this.additionalProperties.putAll(builder.additionalProperties); } @@ -65,8 +76,10 @@ public static Builder builder() { public Builder toBuilder() { Builder builder = new Builder(); builder.cadence = cadence; + builder.creditUnit = creditUnit; builder.metricId = metricId; builder.pricing = pricing; + builder.type = type; builder.additionalProperties.putAll(additionalProperties); return builder; } @@ -80,6 +93,15 @@ public BillingPeriodEnum cadence() { return Utils.required(cadence, "cadence"); } + /** + * The {@code credit_unit} property. + * + * @return the value, empty when unset or null + */ + public Optional creditUnit() { + return creditUnit.asOptional(); + } + /** * The {@code metric_id} property. * @@ -98,6 +120,15 @@ public PlanUsagePricingModel pricing() { return Utils.required(pricing, "pricing"); } + /** + * The {@code type} property. + * + * @return the value, never null + */ + public String type() { + return Utils.required(type, "type"); + } + /** * Properties this version of the SDK does not know, kept as received and sent back. * @@ -127,14 +158,16 @@ public boolean equals(Object o) { } UsagePlanFee that = (UsagePlanFee) o; return Objects.equals(cadence, that.cadence) + && Objects.equals(creditUnit, that.creditUnit) && Objects.equals(metricId, that.metricId) && Objects.equals(pricing, that.pricing) + && Objects.equals(type, that.type) && Objects.equals(additionalProperties, that.additionalProperties); } @Override public int hashCode() { - return Objects.hash(cadence, metricId, pricing, additionalProperties); + return Objects.hash(cadence, creditUnit, metricId, pricing, type, additionalProperties); } @Override @@ -142,10 +175,14 @@ public String toString() { return "UsagePlanFee{" + "cadence=" + cadence + + ", creditUnit=" + + creditUnit + ", metricId=" + metricId + ", pricing=" + pricing + + ", type=" + + type + ", additionalProperties=" + additionalProperties + "}"; @@ -154,8 +191,10 @@ public String toString() { /** Builds {@link UsagePlanFee}. */ public static final class Builder { private BillingPeriodEnum cadence; + private JsonField creditUnit = JsonField.missing(); private String metricId; private PlanUsagePricingModel pricing; + private String type = "USAGE"; private final Map additionalProperties = new LinkedHashMap<>(); private Builder() {} @@ -171,6 +210,17 @@ public Builder cadence(BillingPeriodEnum cadence) { return this; } + /** + * The {@code credit_unit} property. + * + * @param creditUnit the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder creditUnit(PlanFeeCreditUnit creditUnit) { + this.creditUnit = JsonField.ofNullable(creditUnit); + return this; + } + /** * The {@code metric_id} property. * @@ -193,6 +243,17 @@ public Builder pricing(PlanUsagePricingModel pricing) { return this; } + /** + * The {@code type} property. + * + * @param type the value + * @return this builder + */ + public Builder type(String type) { + this.type = type; + return this; + } + /** * A property the SDK does not know, sent along. * @@ -237,6 +298,7 @@ public UsagePlanFee build() { Utils.checkRequired(cadence, "cadence"); Utils.checkRequired(metricId, "metric_id"); Utils.checkRequired(pricing, "pricing"); + Utils.checkRequired(type, "type"); return new UsagePlanFee(this); } } diff --git a/src/main/java/com/meteroid/models/UsagePricing.java b/src/main/java/com/meteroid/models/UsagePricing.java index 653c519..f92ea74 100644 --- a/src/main/java/com/meteroid/models/UsagePricing.java +++ b/src/main/java/com/meteroid/models/UsagePricing.java @@ -27,12 +27,16 @@ public final class UsagePricing { @JsonProperty("model") private UsagePricingModel model; + @JsonProperty("type") + private String type = "USAGE"; + private final Map additionalProperties = new LinkedHashMap<>(); private UsagePricing() {} private UsagePricing(Builder builder) { this.model = builder.model; + this.type = builder.type; this.additionalProperties.putAll(builder.additionalProperties); } @@ -53,6 +57,7 @@ public static Builder builder() { public Builder toBuilder() { Builder builder = new Builder(); builder.model = model; + builder.type = type; builder.additionalProperties.putAll(additionalProperties); return builder; } @@ -66,6 +71,15 @@ public UsagePricingModel model() { return Utils.required(model, "model"); } + /** + * The {@code type} property. + * + * @return the value, never null + */ + public String type() { + return Utils.required(type, "type"); + } + /** * Properties this version of the SDK does not know, kept as received and sent back. * @@ -95,12 +109,13 @@ public boolean equals(Object o) { } UsagePricing that = (UsagePricing) o; return Objects.equals(model, that.model) + && Objects.equals(type, that.type) && Objects.equals(additionalProperties, that.additionalProperties); } @Override public int hashCode() { - return Objects.hash(model, additionalProperties); + return Objects.hash(model, type, additionalProperties); } @Override @@ -108,6 +123,8 @@ public String toString() { return "UsagePricing{" + "model=" + model + + ", type=" + + type + ", additionalProperties=" + additionalProperties + "}"; @@ -116,6 +133,7 @@ public String toString() { /** Builds {@link UsagePricing}. */ public static final class Builder { private UsagePricingModel model; + private String type = "USAGE"; private final Map additionalProperties = new LinkedHashMap<>(); private Builder() {} @@ -131,6 +149,17 @@ public Builder model(UsagePricingModel model) { return this; } + /** + * The {@code type} property. + * + * @param type the value + * @return this builder + */ + public Builder type(String type) { + this.type = type; + return this; + } + /** * A property the SDK does not know, sent along. * @@ -173,6 +202,7 @@ public Builder removeAdditionalProperty(String name) { */ public UsagePricing build() { Utils.checkRequired(model, "model"); + Utils.checkRequired(type, "type"); return new UsagePricing(this); } } diff --git a/src/main/java/com/meteroid/models/UsageResponse.java b/src/main/java/com/meteroid/models/UsageResponse.java index 9daf67d..b0ac15f 100644 --- a/src/main/java/com/meteroid/models/UsageResponse.java +++ b/src/main/java/com/meteroid/models/UsageResponse.java @@ -9,15 +9,18 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.JsonField; import com.meteroid.internal.Utils; import java.time.LocalDate; +import java.time.OffsetDateTime; import java.util.ArrayList; import java.util.Collections; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Objects; +import java.util.Optional; /** Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. */ @JsonInclude(JsonInclude.Include.NON_NULL) @@ -27,12 +30,20 @@ isGetterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE) public final class UsageResponse { + @JsonProperty("computed_at") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField computedAt = JsonField.missing(); + @JsonProperty("period_end") private LocalDate periodEnd; @JsonProperty("period_start") private LocalDate periodStart; + @JsonProperty("totals") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField> totals = JsonField.missing(); + @JsonProperty("usage") private List usage; @@ -41,8 +52,10 @@ public final class UsageResponse { private UsageResponse() {} private UsageResponse(Builder builder) { + this.computedAt = builder.computedAt; this.periodEnd = builder.periodEnd; this.periodStart = builder.periodStart; + this.totals = builder.totals.map(Utils::copyList); this.usage = Utils.copyList(builder.usage); this.additionalProperties.putAll(builder.additionalProperties); } @@ -63,13 +76,26 @@ public static Builder builder() { */ public Builder toBuilder() { Builder builder = new Builder(); + builder.computedAt = computedAt; builder.periodEnd = periodEnd; builder.periodStart = periodStart; + builder.totals = totals.map(Utils::mutableList); builder.usage = Utils.mutableList(usage); builder.additionalProperties.putAll(additionalProperties); return builder; } + /** + * Beta: when totals and the metrics' costs were computed. These are + * present only when a subscription's current billing period is read (no start_date + * nor end_date) and its usage could be priced. + * + * @return the value, empty when unset or null + */ + public Optional computedAt() { + return computedAt.asOptional(); + } + /** * The {@code period_end} property. * @@ -88,6 +114,15 @@ public LocalDate periodStart() { return Utils.required(periodStart, "period_start"); } + /** + * Beta: the sum of the metrics' costs, per currency or credit unit. + * + * @return the value, empty when unset or null + */ + public Optional> totals() { + return totals.asOptional(); + } + /** * The {@code usage} property. * @@ -125,24 +160,31 @@ public boolean equals(Object o) { return false; } UsageResponse that = (UsageResponse) o; - return Objects.equals(periodEnd, that.periodEnd) + return Objects.equals(computedAt, that.computedAt) + && Objects.equals(periodEnd, that.periodEnd) && Objects.equals(periodStart, that.periodStart) + && Objects.equals(totals, that.totals) && Objects.equals(usage, that.usage) && Objects.equals(additionalProperties, that.additionalProperties); } @Override public int hashCode() { - return Objects.hash(periodEnd, periodStart, usage, additionalProperties); + return Objects.hash( + computedAt, periodEnd, periodStart, totals, usage, additionalProperties); } @Override public String toString() { return "UsageResponse{" - + "periodEnd=" + + "computedAt=" + + computedAt + + ", periodEnd=" + periodEnd + ", periodStart=" + periodStart + + ", totals=" + + totals + ", usage=" + usage + ", additionalProperties=" @@ -152,13 +194,28 @@ public String toString() { /** Builds {@link UsageResponse}. */ public static final class Builder { + private JsonField computedAt = JsonField.missing(); private LocalDate periodEnd; private LocalDate periodStart; + private JsonField> totals = JsonField.missing(); private List usage; private final Map additionalProperties = new LinkedHashMap<>(); private Builder() {} + /** + * Beta: when totals and the metrics' costs were computed. These + * are present only when a subscription's current billing period is read (no + * start_date nor end_date) and its usage could be priced. + * + * @param computedAt the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder computedAt(OffsetDateTime computedAt) { + this.computedAt = JsonField.ofNullable(computedAt); + return this; + } + /** * The {@code period_end} property. * @@ -181,6 +238,33 @@ public Builder periodStart(LocalDate periodStart) { return this; } + /** + * Beta: the sum of the metrics' costs, per currency or credit unit. + * + * @param totals the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder totals(List totals) { + this.totals = JsonField.ofNullable(Utils.mutableList(totals)); + return this; + } + + /** + * Adds an item to {@code totals}. + * + * @param item the item + * @return this builder + */ + public Builder addTotalsItem(UsageCost item) { + List items = this.totals.orNull(); + if (items == null) { + items = new ArrayList<>(); + this.totals = JsonField.ofNullable(items); + } + items.add(item); + return this; + } + /** * The {@code usage} property. * diff --git a/src/main/java/com/meteroid/models/VolumePlanPricing.java b/src/main/java/com/meteroid/models/VolumePlanPricing.java index a5a6a1d..92dedac 100644 --- a/src/main/java/com/meteroid/models/VolumePlanPricing.java +++ b/src/main/java/com/meteroid/models/VolumePlanPricing.java @@ -35,6 +35,9 @@ public final class VolumePlanPricing { @JsonProperty("tiers") private List tiers; + @JsonProperty("type") + private String type = "VOLUME"; + private final Map additionalProperties = new LinkedHashMap<>(); private VolumePlanPricing() {} @@ -42,6 +45,7 @@ private VolumePlanPricing() {} private VolumePlanPricing(Builder builder) { this.blockSize = builder.blockSize; this.tiers = Utils.copyList(builder.tiers); + this.type = builder.type; this.additionalProperties.putAll(builder.additionalProperties); } @@ -63,6 +67,7 @@ public Builder toBuilder() { Builder builder = new Builder(); builder.blockSize = blockSize; builder.tiers = Utils.mutableList(tiers); + builder.type = type; builder.additionalProperties.putAll(additionalProperties); return builder; } @@ -85,6 +90,15 @@ public List tiers() { return Utils.required(tiers, "tiers"); } + /** + * The {@code type} property. + * + * @return the value, never null + */ + public String type() { + return Utils.required(type, "type"); + } + /** * Properties this version of the SDK does not know, kept as received and sent back. * @@ -115,12 +129,13 @@ public boolean equals(Object o) { VolumePlanPricing that = (VolumePlanPricing) o; return Objects.equals(blockSize, that.blockSize) && Objects.equals(tiers, that.tiers) + && Objects.equals(type, that.type) && Objects.equals(additionalProperties, that.additionalProperties); } @Override public int hashCode() { - return Objects.hash(blockSize, tiers, additionalProperties); + return Objects.hash(blockSize, tiers, type, additionalProperties); } @Override @@ -130,6 +145,8 @@ public String toString() { + blockSize + ", tiers=" + tiers + + ", type=" + + type + ", additionalProperties=" + additionalProperties + "}"; @@ -139,6 +156,7 @@ public String toString() { public static final class Builder { private JsonField blockSize = JsonField.missing(); private List tiers; + private String type = "VOLUME"; private final Map additionalProperties = new LinkedHashMap<>(); private Builder() {} @@ -179,6 +197,17 @@ public Builder addTiersItem(TierRow item) { return this; } + /** + * The {@code type} property. + * + * @param type the value + * @return this builder + */ + public Builder type(String type) { + this.type = type; + return this; + } + /** * A property the SDK does not know, sent along. * @@ -221,6 +250,7 @@ public Builder removeAdditionalProperty(String name) { */ public VolumePlanPricing build() { Utils.checkRequired(tiers, "tiers"); + Utils.checkRequired(type, "type"); return new VolumePlanPricing(this); } } diff --git a/src/main/java/com/meteroid/models/VolumePricing.java b/src/main/java/com/meteroid/models/VolumePricing.java index 898ff96..fe1f66a 100644 --- a/src/main/java/com/meteroid/models/VolumePricing.java +++ b/src/main/java/com/meteroid/models/VolumePricing.java @@ -35,6 +35,9 @@ public final class VolumePricing { @JsonProperty("tiers") private List tiers; + @JsonProperty("type") + private String type = "VOLUME"; + private final Map additionalProperties = new LinkedHashMap<>(); private VolumePricing() {} @@ -42,6 +45,7 @@ private VolumePricing() {} private VolumePricing(Builder builder) { this.blockSize = builder.blockSize; this.tiers = Utils.copyList(builder.tiers); + this.type = builder.type; this.additionalProperties.putAll(builder.additionalProperties); } @@ -63,6 +67,7 @@ public Builder toBuilder() { Builder builder = new Builder(); builder.blockSize = blockSize; builder.tiers = Utils.mutableList(tiers); + builder.type = type; builder.additionalProperties.putAll(additionalProperties); return builder; } @@ -85,6 +90,15 @@ public List tiers() { return Utils.required(tiers, "tiers"); } + /** + * The {@code type} property. + * + * @return the value, never null + */ + public String type() { + return Utils.required(type, "type"); + } + /** * Properties this version of the SDK does not know, kept as received and sent back. * @@ -115,12 +129,13 @@ public boolean equals(Object o) { VolumePricing that = (VolumePricing) o; return Objects.equals(blockSize, that.blockSize) && Objects.equals(tiers, that.tiers) + && Objects.equals(type, that.type) && Objects.equals(additionalProperties, that.additionalProperties); } @Override public int hashCode() { - return Objects.hash(blockSize, tiers, additionalProperties); + return Objects.hash(blockSize, tiers, type, additionalProperties); } @Override @@ -130,6 +145,8 @@ public String toString() { + blockSize + ", tiers=" + tiers + + ", type=" + + type + ", additionalProperties=" + additionalProperties + "}"; @@ -139,6 +156,7 @@ public String toString() { public static final class Builder { private JsonField blockSize = JsonField.missing(); private List tiers; + private String type = "VOLUME"; private final Map additionalProperties = new LinkedHashMap<>(); private Builder() {} @@ -179,6 +197,17 @@ public Builder addTiersItem(TierRow item) { return this; } + /** + * The {@code type} property. + * + * @param type the value + * @return this builder + */ + public Builder type(String type) { + this.type = type; + return this; + } + /** * A property the SDK does not know, sent along. * @@ -221,6 +250,7 @@ public Builder removeAdditionalProperty(String name) { */ public VolumePricing build() { Utils.checkRequired(tiers, "tiers"); + Utils.checkRequired(type, "type"); return new VolumePricing(this); } } diff --git a/src/main/java/com/meteroid/models/Wallet.java b/src/main/java/com/meteroid/models/Wallet.java new file mode 100644 index 0000000..1dec88e --- /dev/null +++ b/src/main/java/com/meteroid/models/Wallet.java @@ -0,0 +1,796 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.JsonField; +import com.meteroid.internal.Utils; + +import java.time.OffsetDateTime; +import java.util.ArrayList; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +/** + * A customer's credit in one currency or credit unit. Amounts are minor units of it. Read with + * subscription_id, every amount counts only the credit that subscription can use. + * + *

Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonAutoDetect( + getterVisibility = Visibility.NONE, + isGetterVisibility = Visibility.NONE, + setterVisibility = Visibility.NONE) +public final class Wallet { + @JsonProperty("as_of") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField asOf = JsonField.missing(); + + @JsonProperty("auto_top_up") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField autoTopUp = JsonField.missing(); + + @JsonProperty("balance") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField balance = JsonField.missing(); + + @JsonProperty("credit_on_account") + private Long creditOnAccount; + + @JsonProperty("credit_on_account_usage_only") + private Long creditOnAccountUsageOnly; + + @JsonProperty("credit_unit") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField creditUnit = JsonField.missing(); + + @JsonProperty("credit_unit_precision") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField creditUnitPrecision = JsonField.missing(); + + @JsonProperty("currency") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField currency = JsonField.missing(); + + @JsonProperty("low_balance_thresholds") + private List lowBalanceThresholds; + + @JsonProperty("pauses_at_zero") + private Boolean pausesAtZero; + + @JsonProperty("shared_balance") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField sharedBalance = JsonField.missing(); + + @JsonProperty("subscription_credit") + private List subscriptionCredit; + + @JsonProperty("unbilled_usage") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField unbilledUsage = JsonField.missing(); + + @JsonProperty("unit_price") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField unitPrice = JsonField.missing(); + + @JsonProperty("unit_price_currency") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField unitPriceCurrency = JsonField.missing(); + + @JsonProperty("upcoming_credit") + private Long upcomingCredit; + + @JsonProperty("usage_at_zero") + private UsageAtZero usageAtZero; + + private final Map additionalProperties = new LinkedHashMap<>(); + + private Wallet() {} + + private Wallet(Builder builder) { + this.asOf = builder.asOf; + this.autoTopUp = builder.autoTopUp; + this.balance = builder.balance; + this.creditOnAccount = builder.creditOnAccount; + this.creditOnAccountUsageOnly = builder.creditOnAccountUsageOnly; + this.creditUnit = builder.creditUnit; + this.creditUnitPrecision = builder.creditUnitPrecision; + this.currency = builder.currency; + this.lowBalanceThresholds = Utils.copyList(builder.lowBalanceThresholds); + this.pausesAtZero = builder.pausesAtZero; + this.sharedBalance = builder.sharedBalance; + this.subscriptionCredit = Utils.copyList(builder.subscriptionCredit); + this.unbilledUsage = builder.unbilledUsage; + this.unitPrice = builder.unitPrice; + this.unitPriceCurrency = builder.unitPriceCurrency; + this.upcomingCredit = builder.upcomingCredit; + this.usageAtZero = builder.usageAtZero; + this.additionalProperties.putAll(builder.additionalProperties); + } + + /** + * A builder of {@code Wallet}. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * A builder starting from this value. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.asOf = asOf; + builder.autoTopUp = autoTopUp; + builder.balance = balance; + builder.creditOnAccount = creditOnAccount; + builder.creditOnAccountUsageOnly = creditOnAccountUsageOnly; + builder.creditUnit = creditUnit; + builder.creditUnitPrecision = creditUnitPrecision; + builder.currency = currency; + builder.lowBalanceThresholds = Utils.mutableList(lowBalanceThresholds); + builder.pausesAtZero = pausesAtZero; + builder.sharedBalance = sharedBalance; + builder.subscriptionCredit = Utils.mutableList(subscriptionCredit); + builder.unbilledUsage = unbilledUsage; + builder.unitPrice = unitPrice; + builder.unitPriceCurrency = unitPriceCurrency; + builder.upcomingCredit = upcomingCredit; + builder.usageAtZero = usageAtZero; + builder.additionalProperties.putAll(additionalProperties); + return builder; + } + + /** + * When balance and unbilled_usage were computed. They follow usage + * within a few seconds while the balance is near zero or a threshold, and within a minute + * otherwise. + * + * @return the value, empty when unset or null + */ + public Optional asOf() { + return asOf.asOptional(); + } + + /** + * The {@code auto_top_up} property. + * + * @return the value, empty when unset or null + */ + public Optional autoTopUp() { + return autoTopUp.asOptional(); + } + + /** + * What the customer has left: credit_on_account minus the part of + * unbilled_usage that credit will pay. Never negative: usage beyond the credit stays in + * unbilled_usage, to be invoiced. Low-balance alerts use it; automatic top-ups + * watch only its part that pays any charge (credit that belongs to no subscription and is not + * limited to usage or products). Absent, with unbilled_usage and as_of + * , until the customer's usage has been priced once. With subscription_id: + * the credit that subscription can spend once every subscription's unbilled usage is paid, + * minus its own unbilled usage no credit pays (negative then), as GET /wallets/check + * reads it. Credit restricted to products it is not charged for is left out. Credit + * that belongs to no subscription counts in the balance of every subscription that can use it + * (see shared_balance): never add subscriptions' balances up. + * + * @return the value, empty when unset or null + */ + public Optional balance() { + return balance.asOptional(); + } + + /** + * The ledger total: credit granted and effective, not yet applied to an invoice or expired, + * whatever it applies to. Usage not invoiced yet is not deducted (see balance). + * + * @return the value, never null + */ + public Long creditOnAccount() { + return Utils.required(creditOnAccount, "credit_on_account"); + } + + /** + * The part of credit_on_account that pays only usage charges. + * + * @return the value, never null + */ + public Long creditOnAccountUsageOnly() { + return Utils.required(creditOnAccountUsageOnly, "credit_on_account_usage_only"); + } + + /** + * The credit unit (its code) the wallet holds; absent for a currency. + * + * @return the value, empty when unset or null + */ + public Optional creditUnit() { + return creditUnit.asOptional(); + } + + /** + * Decimal places of credit_unit: amounts are integers of 10^-precision credit. + * + * @return the value, empty when unset or null + */ + public Optional creditUnitPrecision() { + return creditUnitPrecision.asOptional(); + } + + /** + * The {@code currency} property. + * + * @return the value, empty when unset or null + */ + public Optional currency() { + return currency.asOptional(); + } + + /** + * Ascending, distinct, at most 5. wallet.balance_low fires once when balance + * falls below one; a drop below several at once fires once, for the lowest. All credit + * counts, including credit that belongs to a subscription or is limited to usage or products, + * which wallet.depleted leaves out: a wallet can be depleted without an alert + * firing. + * + * @return the value, never null + */ + public List lowBalanceThresholds() { + return Utils.required(lowBalanceThresholds, "low_balance_thresholds"); + } + + /** + * Usage stops as soon as the credit is used up, for at least one active subscription: by + * usage_at_zero, or by the plan of a subscription charging usage in this wallet. + * + * @return the value, never null + */ + public Boolean pausesAtZero() { + return Utils.required(pausesAtZero, "pauses_at_zero"); + } + + /** + * With subscription_id only: the part of balance that belongs to no + * subscription, which the customer's other subscriptions can spend too. + * + * @return the value, empty when unset or null + */ + public Optional sharedBalance() { + return sharedBalance.asOptional(); + } + + /** + * The part of credit_on_account that belongs to a subscription, which only that + * subscription's charges can use, per subscription. The rest pays any subscription. + * + * @return the value, never null + */ + public List subscriptionCredit() { + return Utils.required(subscriptionCredit, "subscription_credit"); + } + + /** + * Usage recorded and priced but not invoiced yet, tax included, in minor units: what the next + * invoices will charge for it, paid from credit as far as the credit goes. With + * subscription_id, that subscription's usage only; other subscriptions' usage paid from + * shared credit still lowers balance. + * + * @return the value, empty when unset or null + */ + public Optional unbilledUsage() { + return unbilledUsage.asOptional(); + } + + /** + * Credit unit wallets: the price this customer agreed for one credit, in major units of + * unit_price_currency, as a decimal string (e.g. "0.0008"). Purchases and automatic + * top-ups in that currency charge it instead of the list price, unless a purchase sets its own + * unit_price. Absent: the list price applies. + * + * @return the value, empty when unset or null + */ + public Optional unitPrice() { + return unitPrice.asOptional(); + } + + /** + * The {@code unit_price_currency} property. + * + * @return the value, empty when unset or null + */ + public Optional unitPriceCurrency() { + return unitPriceCurrency.asOptional(); + } + + /** + * Credit granted that takes effect later. + * + * @return the value, never null + */ + public Long upcomingCredit() { + return Utils.required(upcomingCredit, "upcoming_credit"); + } + + /** + * What this customer's usage does once the credit a subscription can use for it is used up (its + * own credit, credit that belongs to no subscription, and credit limited to the product: the + * balance of GET /wallets/check). FOLLOW_PLAN applies + * the "when credit runs out" rule of each subscription's plan. + * + * @return the value, never null + */ + public UsageAtZero usageAtZero() { + return Utils.required(usageAtZero, "usage_at_zero"); + } + + /** + * Properties this version of the SDK does not know, kept as received and sent back. + * + * @return the properties by name, unmodifiable + */ + public Map additionalProperties() { + return Collections.unmodifiableMap(additionalProperties); + } + + @JsonAnyGetter + private Map anyProperties() { + return additionalProperties; + } + + @JsonAnySetter + private void putAnyProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Wallet that = (Wallet) o; + return Objects.equals(asOf, that.asOf) + && Objects.equals(autoTopUp, that.autoTopUp) + && Objects.equals(balance, that.balance) + && Objects.equals(creditOnAccount, that.creditOnAccount) + && Objects.equals(creditOnAccountUsageOnly, that.creditOnAccountUsageOnly) + && Objects.equals(creditUnit, that.creditUnit) + && Objects.equals(creditUnitPrecision, that.creditUnitPrecision) + && Objects.equals(currency, that.currency) + && Objects.equals(lowBalanceThresholds, that.lowBalanceThresholds) + && Objects.equals(pausesAtZero, that.pausesAtZero) + && Objects.equals(sharedBalance, that.sharedBalance) + && Objects.equals(subscriptionCredit, that.subscriptionCredit) + && Objects.equals(unbilledUsage, that.unbilledUsage) + && Objects.equals(unitPrice, that.unitPrice) + && Objects.equals(unitPriceCurrency, that.unitPriceCurrency) + && Objects.equals(upcomingCredit, that.upcomingCredit) + && Objects.equals(usageAtZero, that.usageAtZero) + && Objects.equals(additionalProperties, that.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash( + asOf, + autoTopUp, + balance, + creditOnAccount, + creditOnAccountUsageOnly, + creditUnit, + creditUnitPrecision, + currency, + lowBalanceThresholds, + pausesAtZero, + sharedBalance, + subscriptionCredit, + unbilledUsage, + unitPrice, + unitPriceCurrency, + upcomingCredit, + usageAtZero, + additionalProperties); + } + + @Override + public String toString() { + return "Wallet{" + + "asOf=" + + asOf + + ", autoTopUp=" + + autoTopUp + + ", balance=" + + balance + + ", creditOnAccount=" + + creditOnAccount + + ", creditOnAccountUsageOnly=" + + creditOnAccountUsageOnly + + ", creditUnit=" + + creditUnit + + ", creditUnitPrecision=" + + creditUnitPrecision + + ", currency=" + + currency + + ", lowBalanceThresholds=" + + lowBalanceThresholds + + ", pausesAtZero=" + + pausesAtZero + + ", sharedBalance=" + + sharedBalance + + ", subscriptionCredit=" + + subscriptionCredit + + ", unbilledUsage=" + + unbilledUsage + + ", unitPrice=" + + unitPrice + + ", unitPriceCurrency=" + + unitPriceCurrency + + ", upcomingCredit=" + + upcomingCredit + + ", usageAtZero=" + + usageAtZero + + ", additionalProperties=" + + additionalProperties + + "}"; + } + + /** Builds {@link Wallet}. */ + public static final class Builder { + private JsonField asOf = JsonField.missing(); + private JsonField autoTopUp = JsonField.missing(); + private JsonField balance = JsonField.missing(); + private Long creditOnAccount; + private Long creditOnAccountUsageOnly; + private JsonField creditUnit = JsonField.missing(); + private JsonField creditUnitPrecision = JsonField.missing(); + private JsonField currency = JsonField.missing(); + private List lowBalanceThresholds; + private Boolean pausesAtZero; + private JsonField sharedBalance = JsonField.missing(); + private List subscriptionCredit; + private JsonField unbilledUsage = JsonField.missing(); + private JsonField unitPrice = JsonField.missing(); + private JsonField unitPriceCurrency = JsonField.missing(); + private Long upcomingCredit; + private UsageAtZero usageAtZero; + private final Map additionalProperties = new LinkedHashMap<>(); + + private Builder() {} + + /** + * When balance and unbilled_usage were computed. They follow + * usage within a few seconds while the balance is near zero or a threshold, and within a + * minute otherwise. + * + * @param asOf the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder asOf(OffsetDateTime asOf) { + this.asOf = JsonField.ofNullable(asOf); + return this; + } + + /** + * The {@code auto_top_up} property. + * + * @param autoTopUp the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder autoTopUp(AutoTopUp autoTopUp) { + this.autoTopUp = JsonField.ofNullable(autoTopUp); + return this; + } + + /** + * What the customer has left: credit_on_account minus the part of + * unbilled_usage that credit will pay. Never negative: usage beyond the credit stays + * in unbilled_usage, to be invoiced. Low-balance alerts use it; automatic + * top-ups watch only its part that pays any charge (credit that belongs to no subscription + * and is not limited to usage or products). Absent, with unbilled_usage and + * as_of, until the customer's usage has been priced once. With + * subscription_id: the credit that subscription can spend once every subscription's + * unbilled usage is paid, minus its own unbilled usage no credit pays (negative then), as + * GET /wallets/check reads it. Credit restricted to products it is not charged + * for is left out. Credit that belongs to no subscription counts in the balance of every + * subscription that can use it (see shared_balance): never add subscriptions' + * balances up. + * + * @param balance the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder balance(Long balance) { + this.balance = JsonField.ofNullable(balance); + return this; + } + + /** + * The ledger total: credit granted and effective, not yet applied to an invoice or expired, + * whatever it applies to. Usage not invoiced yet is not deducted (see balance + * ). + * + * @param creditOnAccount the value + * @return this builder + */ + public Builder creditOnAccount(Long creditOnAccount) { + this.creditOnAccount = creditOnAccount; + return this; + } + + /** + * The part of credit_on_account that pays only usage charges. + * + * @param creditOnAccountUsageOnly the value + * @return this builder + */ + public Builder creditOnAccountUsageOnly(Long creditOnAccountUsageOnly) { + this.creditOnAccountUsageOnly = creditOnAccountUsageOnly; + return this; + } + + /** + * The credit unit (its code) the wallet holds; absent for a currency. + * + * @param creditUnit the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder creditUnit(String creditUnit) { + this.creditUnit = JsonField.ofNullable(creditUnit); + return this; + } + + /** + * Decimal places of credit_unit: amounts are integers of 10^-precision credit. + * + * @param creditUnitPrecision the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder creditUnitPrecision(Integer creditUnitPrecision) { + this.creditUnitPrecision = JsonField.ofNullable(creditUnitPrecision); + return this; + } + + /** + * The {@code currency} property. + * + * @param currency the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder currency(Currency currency) { + this.currency = JsonField.ofNullable(currency); + return this; + } + + /** + * Ascending, distinct, at most 5. wallet.balance_low fires once when + * balance falls below one; a drop below several at once fires once, for the lowest. + * All credit counts, including credit that belongs to a subscription or is limited to usage + * or products, which wallet.depleted leaves out: a wallet can be depleted + * without an alert firing. + * + * @param lowBalanceThresholds the value + * @return this builder + */ + public Builder lowBalanceThresholds(List lowBalanceThresholds) { + this.lowBalanceThresholds = Utils.mutableList(lowBalanceThresholds); + return this; + } + + /** + * Adds an item to {@code low_balance_thresholds}. + * + * @param item the item + * @return this builder + */ + public Builder addLowBalanceThresholdsItem(Long item) { + if (this.lowBalanceThresholds == null) { + this.lowBalanceThresholds = new ArrayList<>(); + } + this.lowBalanceThresholds.add(item); + return this; + } + + /** + * Usage stops as soon as the credit is used up, for at least one active subscription: by + * usage_at_zero, or by the plan of a subscription charging usage in this + * wallet. + * + * @param pausesAtZero the value + * @return this builder + */ + public Builder pausesAtZero(Boolean pausesAtZero) { + this.pausesAtZero = pausesAtZero; + return this; + } + + /** + * With subscription_id only: the part of balance that belongs to + * no subscription, which the customer's other subscriptions can spend too. + * + * @param sharedBalance the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder sharedBalance(Long sharedBalance) { + this.sharedBalance = JsonField.ofNullable(sharedBalance); + return this; + } + + /** + * The part of credit_on_account that belongs to a subscription, which only + * that subscription's charges can use, per subscription. The rest pays any subscription. + * + * @param subscriptionCredit the value + * @return this builder + */ + public Builder subscriptionCredit(List subscriptionCredit) { + this.subscriptionCredit = Utils.mutableList(subscriptionCredit); + return this; + } + + /** + * Adds an item to {@code subscription_credit}. + * + * @param item the item + * @return this builder + */ + public Builder addSubscriptionCreditItem(SubscriptionCredit item) { + if (this.subscriptionCredit == null) { + this.subscriptionCredit = new ArrayList<>(); + } + this.subscriptionCredit.add(item); + return this; + } + + /** + * Usage recorded and priced but not invoiced yet, tax included, in minor units: what the + * next invoices will charge for it, paid from credit as far as the credit goes. With + * subscription_id, that subscription's usage only; other subscriptions' usage paid + * from shared credit still lowers balance. + * + * @param unbilledUsage the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder unbilledUsage(Long unbilledUsage) { + this.unbilledUsage = JsonField.ofNullable(unbilledUsage); + return this; + } + + /** + * Credit unit wallets: the price this customer agreed for one credit, in major units of + * unit_price_currency, as a decimal string (e.g. "0.0008"). Purchases and + * automatic top-ups in that currency charge it instead of the list price, unless a purchase + * sets its own unit_price. Absent: the list price applies. + * + * @param unitPrice the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder unitPrice(String unitPrice) { + this.unitPrice = JsonField.ofNullable(unitPrice); + return this; + } + + /** + * The {@code unit_price_currency} property. + * + * @param unitPriceCurrency the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder unitPriceCurrency(Currency unitPriceCurrency) { + this.unitPriceCurrency = JsonField.ofNullable(unitPriceCurrency); + return this; + } + + /** + * Credit granted that takes effect later. + * + * @param upcomingCredit the value + * @return this builder + */ + public Builder upcomingCredit(Long upcomingCredit) { + this.upcomingCredit = upcomingCredit; + return this; + } + + /** + * What this customer's usage does once the credit a subscription can use for it is used up + * (its own credit, credit that belongs to no subscription, and credit limited to the + * product: the balance of GET /wallets/check). FOLLOW_PLAN + * applies the "when credit runs out" rule of each subscription's plan. + * + * @param usageAtZero the value + * @return this builder + */ + public Builder usageAtZero(UsageAtZero usageAtZero) { + this.usageAtZero = usageAtZero; + return this; + } + + /** + * A property the SDK does not know, sent along. + * + * @param name the property name + * @param value the JSON value + * @return this builder + */ + public Builder putAdditionalProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + return this; + } + + /** + * Properties the SDK does not know, sent along. + * + * @param additionalProperties the properties by name + * @return this builder + */ + public Builder putAllAdditionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + + /** + * Leaves out a property the SDK does not know. + * + * @param name the property name + * @return this builder + */ + public Builder removeAdditionalProperty(String name) { + additionalProperties.remove(name); + return this; + } + + /** + * The {@code Wallet}. + * + * @return the immutable value + * @throws IllegalStateException when a required property is not set + */ + public Wallet build() { + Utils.checkRequired(creditOnAccount, "credit_on_account"); + Utils.checkRequired(creditOnAccountUsageOnly, "credit_on_account_usage_only"); + Utils.checkRequired(lowBalanceThresholds, "low_balance_thresholds"); + Utils.checkRequired(pausesAtZero, "pauses_at_zero"); + Utils.checkRequired(subscriptionCredit, "subscription_credit"); + Utils.checkRequired(upcomingCredit, "upcoming_credit"); + Utils.checkRequired(usageAtZero, "usage_at_zero"); + return new Wallet(this); + } + } + + /** + * Parse {@code json} as {@code Wallet}. + * + * @param json the JSON text + * @return the value + * @throws com.meteroid.exceptions.InvalidDataException if it is not valid JSON of this shape + */ + public static Wallet fromJson(String json) { + return Utils.parse(json, Wallet.class); + } + + /** + * This value as JSON. + * + * @return the JSON text + */ + public String toJson() { + return Utils.json(this); + } +} diff --git a/src/main/java/com/meteroid/models/WalletBalanceLowEvent.java b/src/main/java/com/meteroid/models/WalletBalanceLowEvent.java new file mode 100644 index 0000000..312b371 --- /dev/null +++ b/src/main/java/com/meteroid/models/WalletBalanceLowEvent.java @@ -0,0 +1,284 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.Unions; +import com.meteroid.internal.Utils; + +import java.time.OffsetDateTime; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; + +/** Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonAutoDetect( + getterVisibility = Visibility.NONE, + isGetterVisibility = Visibility.NONE, + setterVisibility = Visibility.NONE) +public final class WalletBalanceLowEvent { + @JsonProperty("id") + private String id; + + @JsonProperty("timestamp") + private OffsetDateTime timestamp; + + @JsonProperty("type") + private EventType type; + + private final Map additionalProperties = new LinkedHashMap<>(); + + private WalletBalanceLowEvent() {} + + private WalletBalanceLowEvent(Builder builder) { + this.id = builder.id; + this.timestamp = builder.timestamp; + this.type = builder.type; + this.additionalProperties.putAll(builder.additionalProperties); + } + + /** + * A builder of {@code WalletBalanceLowEvent}. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * A builder starting from this value. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.id = id; + builder.timestamp = timestamp; + builder.type = type; + builder.additionalProperties.putAll(additionalProperties); + return builder; + } + + /** + * The properties of {@link WalletBalanceLowEventData}, which this schema extends. + * + * @return the properties of this part + */ + public WalletBalanceLowEventData walletBalanceLowEventData() { + return Unions.convert(additionalProperties, WalletBalanceLowEventData.class); + } + + /** + * The {@code id} property. + * + * @return the value, never null + */ + public String id() { + return Utils.required(id, "id"); + } + + /** + * The {@code timestamp} property. + * + * @return the value, never null + */ + public OffsetDateTime timestamp() { + return Utils.required(timestamp, "timestamp"); + } + + /** + * The {@code type} property. + * + * @return the value, never null + */ + public EventType type() { + return Utils.required(type, "type"); + } + + /** + * Properties this version of the SDK does not know, kept as received and sent back. + * + * @return the properties by name, unmodifiable + */ + public Map additionalProperties() { + Map unknown = new LinkedHashMap<>(additionalProperties); + unknown.keySet().retainAll(walletBalanceLowEventData().additionalProperties().keySet()); + return Collections.unmodifiableMap(unknown); + } + + @JsonAnyGetter + private Map anyProperties() { + return additionalProperties; + } + + @JsonAnySetter + private void putAnyProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + WalletBalanceLowEvent that = (WalletBalanceLowEvent) o; + return Objects.equals(id, that.id) + && Objects.equals(timestamp, that.timestamp) + && Objects.equals(type, that.type) + && Objects.equals(additionalProperties, that.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(id, timestamp, type, additionalProperties); + } + + @Override + public String toString() { + return "WalletBalanceLowEvent{" + + "id=" + + id + + ", timestamp=" + + timestamp + + ", type=" + + type + + ", additionalProperties=" + + additionalProperties + + "}"; + } + + /** Builds {@link WalletBalanceLowEvent}. */ + public static final class Builder { + private String id; + private OffsetDateTime timestamp; + private EventType type; + private final Map additionalProperties = new LinkedHashMap<>(); + + private Builder() {} + + /** + * Sets the properties of {@link WalletBalanceLowEventData}, which this schema extends. + * + * @param walletBalanceLowEventData the properties + * @return this builder + */ + public Builder walletBalanceLowEventData( + WalletBalanceLowEventData walletBalanceLowEventData) { + additionalProperties.putAll(Utils.properties(walletBalanceLowEventData)); + return this; + } + + /** + * The {@code id} property. + * + * @param id the value + * @return this builder + */ + public Builder id(String id) { + this.id = id; + return this; + } + + /** + * The {@code timestamp} property. + * + * @param timestamp the value + * @return this builder + */ + public Builder timestamp(OffsetDateTime timestamp) { + this.timestamp = timestamp; + return this; + } + + /** + * The {@code type} property. + * + * @param type the value + * @return this builder + */ + public Builder type(EventType type) { + this.type = type; + return this; + } + + /** + * A property the SDK does not know, sent along. + * + * @param name the property name + * @param value the JSON value + * @return this builder + */ + public Builder putAdditionalProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + return this; + } + + /** + * Properties the SDK does not know, sent along. + * + * @param additionalProperties the properties by name + * @return this builder + */ + public Builder putAllAdditionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + + /** + * Leaves out a property the SDK does not know. + * + * @param name the property name + * @return this builder + */ + public Builder removeAdditionalProperty(String name) { + additionalProperties.remove(name); + return this; + } + + /** + * The {@code WalletBalanceLowEvent}. + * + * @return the immutable value + * @throws IllegalStateException when a required property is not set + */ + public WalletBalanceLowEvent build() { + Utils.checkRequired(id, "id"); + Utils.checkRequired(timestamp, "timestamp"); + Utils.checkRequired(type, "type"); + return new WalletBalanceLowEvent(this); + } + } + + /** + * Parse {@code json} as {@code WalletBalanceLowEvent}. + * + * @param json the JSON text + * @return the value + * @throws com.meteroid.exceptions.InvalidDataException if it is not valid JSON of this shape + */ + public static WalletBalanceLowEvent fromJson(String json) { + return Utils.parse(json, WalletBalanceLowEvent.class); + } + + /** + * This value as JSON. + * + * @return the JSON text + */ + public String toJson() { + return Utils.json(this); + } +} diff --git a/src/main/java/com/meteroid/models/WalletBalanceLowEventData.java b/src/main/java/com/meteroid/models/WalletBalanceLowEventData.java new file mode 100644 index 0000000..59e19dd --- /dev/null +++ b/src/main/java/com/meteroid/models/WalletBalanceLowEventData.java @@ -0,0 +1,407 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.JsonField; +import com.meteroid.internal.Utils; + +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +/** + * A wallet's balance fell below one of its low-balance thresholds. + * + *

Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonAutoDetect( + getterVisibility = Visibility.NONE, + isGetterVisibility = Visibility.NONE, + setterVisibility = Visibility.NONE) +public final class WalletBalanceLowEventData { + @JsonProperty("balance") + private Long balance; + + @JsonProperty("credit_unit") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField creditUnit = JsonField.missing(); + + @JsonProperty("credit_unit_precision") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField creditUnitPrecision = JsonField.missing(); + + @JsonProperty("currency") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField currency = JsonField.missing(); + + @JsonProperty("customer_id") + private String customerId; + + @JsonProperty("shared_balance") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField sharedBalance = JsonField.missing(); + + @JsonProperty("threshold") + private Long threshold; + + private final Map additionalProperties = new LinkedHashMap<>(); + + private WalletBalanceLowEventData() {} + + private WalletBalanceLowEventData(Builder builder) { + this.balance = builder.balance; + this.creditUnit = builder.creditUnit; + this.creditUnitPrecision = builder.creditUnitPrecision; + this.currency = builder.currency; + this.customerId = builder.customerId; + this.sharedBalance = builder.sharedBalance; + this.threshold = builder.threshold; + this.additionalProperties.putAll(builder.additionalProperties); + } + + /** + * A builder of {@code WalletBalanceLowEventData}. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * A builder starting from this value. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.balance = balance; + builder.creditUnit = creditUnit; + builder.creditUnitPrecision = creditUnitPrecision; + builder.currency = currency; + builder.customerId = customerId; + builder.sharedBalance = sharedBalance; + builder.threshold = threshold; + builder.additionalProperties.putAll(additionalProperties); + return builder; + } + + /** + * The balance when it fell below threshold, in minor units: the wallet's + * balance, all its credit on account net of the unbilled usage it pays, including credit + * that belongs to a subscription or is limited to usage or products. Sent once per crossing, + * for the lowest threshold crossed; it re-arms once the balance is back at the threshold. + * Because that credit counts here and not in wallet.depleted, a wallet can be + * depleted without this event firing. + * + * @return the value, never null + */ + public Long balance() { + return Utils.required(balance, "balance"); + } + + /** + * The credit unit (its code) the amounts are in; absent for a currency. + * + * @return the value, empty when unset or null + */ + public Optional creditUnit() { + return creditUnit.asOptional(); + } + + /** + * Decimal places of credit_unit: amounts are integers of 10^-precision credit. + * + * @return the value, empty when unset or null + */ + public Optional creditUnitPrecision() { + return creditUnitPrecision.asOptional(); + } + + /** + * Absent when the amounts are in a credit unit. + * + * @return the value, empty when unset or null + */ + public Optional currency() { + return currency.asOptional(); + } + + /** + * The {@code customer_id} property. + * + * @return the value, never null + */ + public String customerId() { + return Utils.required(customerId, "customer_id"); + } + + /** + * The part of balance that pays any charge of any subscription: what automatic + * top-ups refill and wallet.depleted watches. Absent on events recorded before it + * was reported. + * + * @return the value, empty when unset or null + */ + public Optional sharedBalance() { + return sharedBalance.asOptional(); + } + + /** + * The low-balance threshold crossed, in the same minor units. + * + * @return the value, never null + */ + public Long threshold() { + return Utils.required(threshold, "threshold"); + } + + /** + * Properties this version of the SDK does not know, kept as received and sent back. + * + * @return the properties by name, unmodifiable + */ + public Map additionalProperties() { + return Collections.unmodifiableMap(additionalProperties); + } + + @JsonAnyGetter + private Map anyProperties() { + return additionalProperties; + } + + @JsonAnySetter + private void putAnyProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + WalletBalanceLowEventData that = (WalletBalanceLowEventData) o; + return Objects.equals(balance, that.balance) + && Objects.equals(creditUnit, that.creditUnit) + && Objects.equals(creditUnitPrecision, that.creditUnitPrecision) + && Objects.equals(currency, that.currency) + && Objects.equals(customerId, that.customerId) + && Objects.equals(sharedBalance, that.sharedBalance) + && Objects.equals(threshold, that.threshold) + && Objects.equals(additionalProperties, that.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash( + balance, + creditUnit, + creditUnitPrecision, + currency, + customerId, + sharedBalance, + threshold, + additionalProperties); + } + + @Override + public String toString() { + return "WalletBalanceLowEventData{" + + "balance=" + + balance + + ", creditUnit=" + + creditUnit + + ", creditUnitPrecision=" + + creditUnitPrecision + + ", currency=" + + currency + + ", customerId=" + + customerId + + ", sharedBalance=" + + sharedBalance + + ", threshold=" + + threshold + + ", additionalProperties=" + + additionalProperties + + "}"; + } + + /** Builds {@link WalletBalanceLowEventData}. */ + public static final class Builder { + private Long balance; + private JsonField creditUnit = JsonField.missing(); + private JsonField creditUnitPrecision = JsonField.missing(); + private JsonField currency = JsonField.missing(); + private String customerId; + private JsonField sharedBalance = JsonField.missing(); + private Long threshold; + private final Map additionalProperties = new LinkedHashMap<>(); + + private Builder() {} + + /** + * The balance when it fell below threshold, in minor units: the wallet's + * balance, all its credit on account net of the unbilled usage it pays, + * including credit that belongs to a subscription or is limited to usage or products. Sent + * once per crossing, for the lowest threshold crossed; it re-arms once the balance is back + * at the threshold. Because that credit counts here and not in wallet.depleted + * , a wallet can be depleted without this event firing. + * + * @param balance the value + * @return this builder + */ + public Builder balance(Long balance) { + this.balance = balance; + return this; + } + + /** + * The credit unit (its code) the amounts are in; absent for a currency. + * + * @param creditUnit the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder creditUnit(String creditUnit) { + this.creditUnit = JsonField.ofNullable(creditUnit); + return this; + } + + /** + * Decimal places of credit_unit: amounts are integers of 10^-precision credit. + * + * @param creditUnitPrecision the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder creditUnitPrecision(Integer creditUnitPrecision) { + this.creditUnitPrecision = JsonField.ofNullable(creditUnitPrecision); + return this; + } + + /** + * Absent when the amounts are in a credit unit. + * + * @param currency the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder currency(String currency) { + this.currency = JsonField.ofNullable(currency); + return this; + } + + /** + * The {@code customer_id} property. + * + * @param customerId the value + * @return this builder + */ + public Builder customerId(String customerId) { + this.customerId = customerId; + return this; + } + + /** + * The part of balance that pays any charge of any subscription: what automatic + * top-ups refill and wallet.depleted watches. Absent on events recorded before + * it was reported. + * + * @param sharedBalance the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder sharedBalance(Long sharedBalance) { + this.sharedBalance = JsonField.ofNullable(sharedBalance); + return this; + } + + /** + * The low-balance threshold crossed, in the same minor units. + * + * @param threshold the value + * @return this builder + */ + public Builder threshold(Long threshold) { + this.threshold = threshold; + return this; + } + + /** + * A property the SDK does not know, sent along. + * + * @param name the property name + * @param value the JSON value + * @return this builder + */ + public Builder putAdditionalProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + return this; + } + + /** + * Properties the SDK does not know, sent along. + * + * @param additionalProperties the properties by name + * @return this builder + */ + public Builder putAllAdditionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + + /** + * Leaves out a property the SDK does not know. + * + * @param name the property name + * @return this builder + */ + public Builder removeAdditionalProperty(String name) { + additionalProperties.remove(name); + return this; + } + + /** + * The {@code WalletBalanceLowEventData}. + * + * @return the immutable value + * @throws IllegalStateException when a required property is not set + */ + public WalletBalanceLowEventData build() { + Utils.checkRequired(balance, "balance"); + Utils.checkRequired(customerId, "customer_id"); + Utils.checkRequired(threshold, "threshold"); + return new WalletBalanceLowEventData(this); + } + } + + /** + * Parse {@code json} as {@code WalletBalanceLowEventData}. + * + * @param json the JSON text + * @return the value + * @throws com.meteroid.exceptions.InvalidDataException if it is not valid JSON of this shape + */ + public static WalletBalanceLowEventData fromJson(String json) { + return Utils.parse(json, WalletBalanceLowEventData.class); + } + + /** + * This value as JSON. + * + * @return the JSON text + */ + public String toJson() { + return Utils.json(this); + } +} diff --git a/src/main/java/com/meteroid/models/WalletCheck.java b/src/main/java/com/meteroid/models/WalletCheck.java new file mode 100644 index 0000000..1af8efd --- /dev/null +++ b/src/main/java/com/meteroid/models/WalletCheck.java @@ -0,0 +1,558 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.JsonField; +import com.meteroid.internal.Utils; + +import java.time.OffsetDateTime; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +/** + * Whether a customer may keep consuming what their prepaid credit pays for. + * + *

Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonAutoDetect( + getterVisibility = Visibility.NONE, + isGetterVisibility = Visibility.NONE, + setterVisibility = Visibility.NONE) +public final class WalletCheck { + @JsonProperty("as_of") + private OffsetDateTime asOf; + + @JsonProperty("balance") + private Long balance; + + @JsonProperty("credit_unit") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField creditUnit = JsonField.missing(); + + @JsonProperty("credit_unit_precision") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField creditUnitPrecision = JsonField.missing(); + + @JsonProperty("currency") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField currency = JsonField.missing(); + + @JsonProperty("exact") + private Boolean exact; + + @JsonProperty("exhausted") + private Boolean exhausted; + + @JsonProperty("has_access") + private Boolean hasAccess; + + @JsonProperty("lag_ms") + private Long lagMs; + + @JsonProperty("pauses_at_zero") + private Boolean pausesAtZero; + + @JsonProperty("shared_balance") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField sharedBalance = JsonField.missing(); + + private final Map additionalProperties = new LinkedHashMap<>(); + + private WalletCheck() {} + + private WalletCheck(Builder builder) { + this.asOf = builder.asOf; + this.balance = builder.balance; + this.creditUnit = builder.creditUnit; + this.creditUnitPrecision = builder.creditUnitPrecision; + this.currency = builder.currency; + this.exact = builder.exact; + this.exhausted = builder.exhausted; + this.hasAccess = builder.hasAccess; + this.lagMs = builder.lagMs; + this.pausesAtZero = builder.pausesAtZero; + this.sharedBalance = builder.sharedBalance; + this.additionalProperties.putAll(builder.additionalProperties); + } + + /** + * A builder of {@code WalletCheck}. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * A builder starting from this value. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.asOf = asOf; + builder.balance = balance; + builder.creditUnit = creditUnit; + builder.creditUnitPrecision = creditUnitPrecision; + builder.currency = currency; + builder.exact = exact; + builder.exhausted = exhausted; + builder.hasAccess = hasAccess; + builder.lagMs = lagMs; + builder.pausesAtZero = pausesAtZero; + builder.sharedBalance = sharedBalance; + builder.additionalProperties.putAll(additionalProperties); + return builder; + } + + /** + * When balance was computed. + * + * @return the value, never null + */ + public OffsetDateTime asOf() { + return Utils.required(asOf, "as_of"); + } + + /** + * The balance: credit on account net of the usage not invoiced yet that it will pay, in minor + * units of currency or credit_unit; never negative for the customer + * as a whole, as balance of GET /wallets. With product_id + * , only the credit that can pay for that product, net of its usage no credit covers. + * With subscription_id, only the credit that subscription can spend (credit + * restricted to products it is not charged for left out), net of its usage no credit covers; + * credit that belongs to no subscription counts in every subscription's balance (see + * shared_balance). + * + * @return the value, never null + */ + public Long balance() { + return Utils.required(balance, "balance"); + } + + /** + * The credit unit (its code) checked; absent for a currency. + * + * @return the value, empty when unset or null + */ + public Optional creditUnit() { + return creditUnit.asOptional(); + } + + /** + * Decimal places of credit_unit: balance is in integers of + * 10^-precision credit. + * + * @return the value, empty when unset or null + */ + public Optional creditUnitPrecision() { + return creditUnitPrecision.asOptional(); + } + + /** + * The {@code currency} property. + * + * @return the value, empty when unset or null + */ + public Optional currency() { + return currency.asOptional(); + } + + /** + * Always false: balance may lag usage by a few seconds (see as_of), + * and the answer is cached for one second. + * + * @return the value, never null + */ + public Boolean exact() { + return Utils.required(exact, "exact"); + } + + /** + * True once balance is at or below zero, or, with subscription_id, + * once no credit is left for some of its usage. Independent of has_access: a + * wallet that allows overage still reports this, so the caller can warn without refusing. + * + * @return the value, never null + */ + public Boolean exhausted() { + return Utils.required(exhausted, "exhausted"); + } + + /** + * False only once balance is at or below zero and blocks_when_exhausted + * is true. Customers without a wallet in currency do not prepay, and + * always have access. With subscription_id: false when blocks_when_exhausted + * is true and no credit that subscription can spend is left for some of its usage (of + * product_id when given), as the access gate refuses it; a subscription charged no + * usage in the wallet keeps access. + * + * @return the value, never null + */ + public Boolean hasAccess() { + return Utils.required(hasAccess, "has_access"); + } + + /** + * Age of balance, in milliseconds. + * + * @return the value, never null + */ + public Long lagMs() { + return Utils.required(lagMs, "lag_ms"); + } + + /** + * Whether usage is refused as soon as the credit is used up: the wallet's usage_at_zero + * , else the plan of the subscription checked (of any active subscription without one). + * A plan that invoices usage up to a cap refuses it past the cap only, as has_access + * reports. + * + * @return the value, never null + */ + public Boolean pausesAtZero() { + return Utils.required(pausesAtZero, "pauses_at_zero"); + } + + /** + * With subscription_id only: the part of balance that belongs to no + * subscription, which the customer's other subscriptions can spend too. + * + * @return the value, empty when unset or null + */ + public Optional sharedBalance() { + return sharedBalance.asOptional(); + } + + /** + * Properties this version of the SDK does not know, kept as received and sent back. + * + * @return the properties by name, unmodifiable + */ + public Map additionalProperties() { + return Collections.unmodifiableMap(additionalProperties); + } + + @JsonAnyGetter + private Map anyProperties() { + return additionalProperties; + } + + @JsonAnySetter + private void putAnyProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + WalletCheck that = (WalletCheck) o; + return Objects.equals(asOf, that.asOf) + && Objects.equals(balance, that.balance) + && Objects.equals(creditUnit, that.creditUnit) + && Objects.equals(creditUnitPrecision, that.creditUnitPrecision) + && Objects.equals(currency, that.currency) + && Objects.equals(exact, that.exact) + && Objects.equals(exhausted, that.exhausted) + && Objects.equals(hasAccess, that.hasAccess) + && Objects.equals(lagMs, that.lagMs) + && Objects.equals(pausesAtZero, that.pausesAtZero) + && Objects.equals(sharedBalance, that.sharedBalance) + && Objects.equals(additionalProperties, that.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash( + asOf, + balance, + creditUnit, + creditUnitPrecision, + currency, + exact, + exhausted, + hasAccess, + lagMs, + pausesAtZero, + sharedBalance, + additionalProperties); + } + + @Override + public String toString() { + return "WalletCheck{" + + "asOf=" + + asOf + + ", balance=" + + balance + + ", creditUnit=" + + creditUnit + + ", creditUnitPrecision=" + + creditUnitPrecision + + ", currency=" + + currency + + ", exact=" + + exact + + ", exhausted=" + + exhausted + + ", hasAccess=" + + hasAccess + + ", lagMs=" + + lagMs + + ", pausesAtZero=" + + pausesAtZero + + ", sharedBalance=" + + sharedBalance + + ", additionalProperties=" + + additionalProperties + + "}"; + } + + /** Builds {@link WalletCheck}. */ + public static final class Builder { + private OffsetDateTime asOf; + private Long balance; + private JsonField creditUnit = JsonField.missing(); + private JsonField creditUnitPrecision = JsonField.missing(); + private JsonField currency = JsonField.missing(); + private Boolean exact; + private Boolean exhausted; + private Boolean hasAccess; + private Long lagMs; + private Boolean pausesAtZero; + private JsonField sharedBalance = JsonField.missing(); + private final Map additionalProperties = new LinkedHashMap<>(); + + private Builder() {} + + /** + * When balance was computed. + * + * @param asOf the value + * @return this builder + */ + public Builder asOf(OffsetDateTime asOf) { + this.asOf = asOf; + return this; + } + + /** + * The balance: credit on account net of the usage not invoiced yet that it will pay, in + * minor units of currency or credit_unit; never negative for the + * customer as a whole, as balance of GET /wallets. With + * product_id, only the credit that can pay for that product, net of its usage no + * credit covers. With subscription_id, only the credit that subscription can + * spend (credit restricted to products it is not charged for left out), net of its usage no + * credit covers; credit that belongs to no subscription counts in every subscription's + * balance (see shared_balance). + * + * @param balance the value + * @return this builder + */ + public Builder balance(Long balance) { + this.balance = balance; + return this; + } + + /** + * The credit unit (its code) checked; absent for a currency. + * + * @param creditUnit the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder creditUnit(String creditUnit) { + this.creditUnit = JsonField.ofNullable(creditUnit); + return this; + } + + /** + * Decimal places of credit_unit: balance is in integers of + * 10^-precision credit. + * + * @param creditUnitPrecision the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder creditUnitPrecision(Integer creditUnitPrecision) { + this.creditUnitPrecision = JsonField.ofNullable(creditUnitPrecision); + return this; + } + + /** + * The {@code currency} property. + * + * @param currency the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder currency(Currency currency) { + this.currency = JsonField.ofNullable(currency); + return this; + } + + /** + * Always false: balance may lag usage by a few seconds (see as_of + * ), and the answer is cached for one second. + * + * @param exact the value + * @return this builder + */ + public Builder exact(Boolean exact) { + this.exact = exact; + return this; + } + + /** + * True once balance is at or below zero, or, with subscription_id + * , once no credit is left for some of its usage. Independent of has_access: a + * wallet that allows overage still reports this, so the caller can warn without refusing. + * + * @param exhausted the value + * @return this builder + */ + public Builder exhausted(Boolean exhausted) { + this.exhausted = exhausted; + return this; + } + + /** + * False only once balance is at or below zero and blocks_when_exhausted + * is true. Customers without a wallet in currency do not prepay, and + * always have access. With subscription_id: false when + * blocks_when_exhausted is true and no credit that subscription can spend is left + * for some of its usage (of product_id when given), as the access gate refuses + * it; a subscription charged no usage in the wallet keeps access. + * + * @param hasAccess the value + * @return this builder + */ + public Builder hasAccess(Boolean hasAccess) { + this.hasAccess = hasAccess; + return this; + } + + /** + * Age of balance, in milliseconds. + * + * @param lagMs the value + * @return this builder + */ + public Builder lagMs(Long lagMs) { + this.lagMs = lagMs; + return this; + } + + /** + * Whether usage is refused as soon as the credit is used up: the wallet's + * usage_at_zero, else the plan of the subscription checked (of any active + * subscription without one). A plan that invoices usage up to a cap refuses it past the cap + * only, as has_access reports. + * + * @param pausesAtZero the value + * @return this builder + */ + public Builder pausesAtZero(Boolean pausesAtZero) { + this.pausesAtZero = pausesAtZero; + return this; + } + + /** + * With subscription_id only: the part of balance that belongs to + * no subscription, which the customer's other subscriptions can spend too. + * + * @param sharedBalance the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder sharedBalance(Long sharedBalance) { + this.sharedBalance = JsonField.ofNullable(sharedBalance); + return this; + } + + /** + * A property the SDK does not know, sent along. + * + * @param name the property name + * @param value the JSON value + * @return this builder + */ + public Builder putAdditionalProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + return this; + } + + /** + * Properties the SDK does not know, sent along. + * + * @param additionalProperties the properties by name + * @return this builder + */ + public Builder putAllAdditionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + + /** + * Leaves out a property the SDK does not know. + * + * @param name the property name + * @return this builder + */ + public Builder removeAdditionalProperty(String name) { + additionalProperties.remove(name); + return this; + } + + /** + * The {@code WalletCheck}. + * + * @return the immutable value + * @throws IllegalStateException when a required property is not set + */ + public WalletCheck build() { + Utils.checkRequired(asOf, "as_of"); + Utils.checkRequired(balance, "balance"); + Utils.checkRequired(exact, "exact"); + Utils.checkRequired(exhausted, "exhausted"); + Utils.checkRequired(hasAccess, "has_access"); + Utils.checkRequired(lagMs, "lag_ms"); + Utils.checkRequired(pausesAtZero, "pauses_at_zero"); + return new WalletCheck(this); + } + } + + /** + * Parse {@code json} as {@code WalletCheck}. + * + * @param json the JSON text + * @return the value + * @throws com.meteroid.exceptions.InvalidDataException if it is not valid JSON of this shape + */ + public static WalletCheck fromJson(String json) { + return Utils.parse(json, WalletCheck.class); + } + + /** + * This value as JSON. + * + * @return the JSON text + */ + public String toJson() { + return Utils.json(this); + } +} diff --git a/src/main/java/com/meteroid/models/WalletCreditRecoveredEvent.java b/src/main/java/com/meteroid/models/WalletCreditRecoveredEvent.java new file mode 100644 index 0000000..b431c98 --- /dev/null +++ b/src/main/java/com/meteroid/models/WalletCreditRecoveredEvent.java @@ -0,0 +1,285 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.Unions; +import com.meteroid.internal.Utils; + +import java.time.OffsetDateTime; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; + +/** Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonAutoDetect( + getterVisibility = Visibility.NONE, + isGetterVisibility = Visibility.NONE, + setterVisibility = Visibility.NONE) +public final class WalletCreditRecoveredEvent { + @JsonProperty("id") + private String id; + + @JsonProperty("timestamp") + private OffsetDateTime timestamp; + + @JsonProperty("type") + private EventType type; + + private final Map additionalProperties = new LinkedHashMap<>(); + + private WalletCreditRecoveredEvent() {} + + private WalletCreditRecoveredEvent(Builder builder) { + this.id = builder.id; + this.timestamp = builder.timestamp; + this.type = builder.type; + this.additionalProperties.putAll(builder.additionalProperties); + } + + /** + * A builder of {@code WalletCreditRecoveredEvent}. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * A builder starting from this value. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.id = id; + builder.timestamp = timestamp; + builder.type = type; + builder.additionalProperties.putAll(additionalProperties); + return builder; + } + + /** + * The properties of {@link WalletCreditRecoveredEventData}, which this schema extends. + * + * @return the properties of this part + */ + public WalletCreditRecoveredEventData walletCreditRecoveredEventData() { + return Unions.convert(additionalProperties, WalletCreditRecoveredEventData.class); + } + + /** + * The {@code id} property. + * + * @return the value, never null + */ + public String id() { + return Utils.required(id, "id"); + } + + /** + * The {@code timestamp} property. + * + * @return the value, never null + */ + public OffsetDateTime timestamp() { + return Utils.required(timestamp, "timestamp"); + } + + /** + * The {@code type} property. + * + * @return the value, never null + */ + public EventType type() { + return Utils.required(type, "type"); + } + + /** + * Properties this version of the SDK does not know, kept as received and sent back. + * + * @return the properties by name, unmodifiable + */ + public Map additionalProperties() { + Map unknown = new LinkedHashMap<>(additionalProperties); + unknown.keySet() + .retainAll(walletCreditRecoveredEventData().additionalProperties().keySet()); + return Collections.unmodifiableMap(unknown); + } + + @JsonAnyGetter + private Map anyProperties() { + return additionalProperties; + } + + @JsonAnySetter + private void putAnyProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + WalletCreditRecoveredEvent that = (WalletCreditRecoveredEvent) o; + return Objects.equals(id, that.id) + && Objects.equals(timestamp, that.timestamp) + && Objects.equals(type, that.type) + && Objects.equals(additionalProperties, that.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(id, timestamp, type, additionalProperties); + } + + @Override + public String toString() { + return "WalletCreditRecoveredEvent{" + + "id=" + + id + + ", timestamp=" + + timestamp + + ", type=" + + type + + ", additionalProperties=" + + additionalProperties + + "}"; + } + + /** Builds {@link WalletCreditRecoveredEvent}. */ + public static final class Builder { + private String id; + private OffsetDateTime timestamp; + private EventType type; + private final Map additionalProperties = new LinkedHashMap<>(); + + private Builder() {} + + /** + * Sets the properties of {@link WalletCreditRecoveredEventData}, which this schema extends. + * + * @param walletCreditRecoveredEventData the properties + * @return this builder + */ + public Builder walletCreditRecoveredEventData( + WalletCreditRecoveredEventData walletCreditRecoveredEventData) { + additionalProperties.putAll(Utils.properties(walletCreditRecoveredEventData)); + return this; + } + + /** + * The {@code id} property. + * + * @param id the value + * @return this builder + */ + public Builder id(String id) { + this.id = id; + return this; + } + + /** + * The {@code timestamp} property. + * + * @param timestamp the value + * @return this builder + */ + public Builder timestamp(OffsetDateTime timestamp) { + this.timestamp = timestamp; + return this; + } + + /** + * The {@code type} property. + * + * @param type the value + * @return this builder + */ + public Builder type(EventType type) { + this.type = type; + return this; + } + + /** + * A property the SDK does not know, sent along. + * + * @param name the property name + * @param value the JSON value + * @return this builder + */ + public Builder putAdditionalProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + return this; + } + + /** + * Properties the SDK does not know, sent along. + * + * @param additionalProperties the properties by name + * @return this builder + */ + public Builder putAllAdditionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + + /** + * Leaves out a property the SDK does not know. + * + * @param name the property name + * @return this builder + */ + public Builder removeAdditionalProperty(String name) { + additionalProperties.remove(name); + return this; + } + + /** + * The {@code WalletCreditRecoveredEvent}. + * + * @return the immutable value + * @throws IllegalStateException when a required property is not set + */ + public WalletCreditRecoveredEvent build() { + Utils.checkRequired(id, "id"); + Utils.checkRequired(timestamp, "timestamp"); + Utils.checkRequired(type, "type"); + return new WalletCreditRecoveredEvent(this); + } + } + + /** + * Parse {@code json} as {@code WalletCreditRecoveredEvent}. + * + * @param json the JSON text + * @return the value + * @throws com.meteroid.exceptions.InvalidDataException if it is not valid JSON of this shape + */ + public static WalletCreditRecoveredEvent fromJson(String json) { + return Utils.parse(json, WalletCreditRecoveredEvent.class); + } + + /** + * This value as JSON. + * + * @return the JSON text + */ + public String toJson() { + return Utils.json(this); + } +} diff --git a/src/main/java/com/meteroid/models/WalletCreditRecoveredEventData.java b/src/main/java/com/meteroid/models/WalletCreditRecoveredEventData.java new file mode 100644 index 0000000..4a3960e --- /dev/null +++ b/src/main/java/com/meteroid/models/WalletCreditRecoveredEventData.java @@ -0,0 +1,492 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.JsonField; +import com.meteroid.internal.Utils; + +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +/** + * Spent credit reported by wallet.credit_unrecovered is backed again. + * + *

Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonAutoDetect( + getterVisibility = Visibility.NONE, + isGetterVisibility = Visibility.NONE, + setterVisibility = Visibility.NONE) +public final class WalletCreditRecoveredEventData { + @JsonProperty("cause") + private String cause; + + @JsonProperty("credit_note_id") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField creditNoteId = JsonField.missing(); + + @JsonProperty("credit_recovered") + private Long creditRecovered; + + @JsonProperty("credit_unit") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField creditUnit = JsonField.missing(); + + @JsonProperty("credit_unit_precision") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField creditUnitPrecision = JsonField.missing(); + + @JsonProperty("credit_unrecovered_total") + private Long creditUnrecoveredTotal; + + @JsonProperty("currency") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField currency = JsonField.missing(); + + @JsonProperty("customer_id") + private String customerId; + + @JsonProperty("invoice_id") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField invoiceId = JsonField.missing(); + + @JsonProperty("payment_id") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField paymentId = JsonField.missing(); + + private final Map additionalProperties = new LinkedHashMap<>(); + + private WalletCreditRecoveredEventData() {} + + private WalletCreditRecoveredEventData(Builder builder) { + this.cause = builder.cause; + this.creditNoteId = builder.creditNoteId; + this.creditRecovered = builder.creditRecovered; + this.creditUnit = builder.creditUnit; + this.creditUnitPrecision = builder.creditUnitPrecision; + this.creditUnrecoveredTotal = builder.creditUnrecoveredTotal; + this.currency = builder.currency; + this.customerId = builder.customerId; + this.invoiceId = builder.invoiceId; + this.paymentId = builder.paymentId; + this.additionalProperties.putAll(builder.additionalProperties); + } + + /** + * A builder of {@code WalletCreditRecoveredEventData}. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * A builder starting from this value. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.cause = cause; + builder.creditNoteId = creditNoteId; + builder.creditRecovered = creditRecovered; + builder.creditUnit = creditUnit; + builder.creditUnitPrecision = creditUnitPrecision; + builder.creditUnrecoveredTotal = creditUnrecoveredTotal; + builder.currency = currency; + builder.customerId = customerId; + builder.invoiceId = invoiceId; + builder.paymentId = paymentId; + builder.additionalProperties.putAll(additionalProperties); + return builder; + } + + /** + * Cause of the loss this recovers: PAYMENT_DISPUTED, PAYMENT_REVERSED + * , PAYMENT_REFUNDED or CREDIT_NOTE_REFUNDED. + * + * @return the value, never null + */ + public String cause() { + return Utils.required(cause, "cause"); + } + + /** + * The {@code credit_note_id} property. + * + * @return the value, empty when unset or null + */ + public Optional creditNoteId() { + return creditNoteId.asOptional(); + } + + /** + * Spent credit an earlier wallet.credit_unrecovered reported that is backed again, + * in minor units: the money came back, or the credit was returned and taken back. + * + * @return the value, never null + */ + public Long creditRecovered() { + return Utils.required(creditRecovered, "credit_recovered"); + } + + /** + * The credit unit (its code) the amounts are in; absent for a currency. + * + * @return the value, empty when unset or null + */ + public Optional creditUnit() { + return creditUnit.asOptional(); + } + + /** + * Decimal places of credit_unit: amounts are integers of 10^-precision credit. + * + * @return the value, empty when unset or null + */ + public Optional creditUnitPrecision() { + return creditUnitPrecision.asOptional(); + } + + /** + * The loss of this money flow (an invoice's payments, a credit note, or a payment) once this + * event applies. + * + * @return the value, never null + */ + public Long creditUnrecoveredTotal() { + return Utils.required(creditUnrecoveredTotal, "credit_unrecovered_total"); + } + + /** + * Absent when the amounts are in a credit unit. + * + * @return the value, empty when unset or null + */ + public Optional currency() { + return currency.asOptional(); + } + + /** + * The {@code customer_id} property. + * + * @return the value, never null + */ + public String customerId() { + return Utils.required(customerId, "customer_id"); + } + + /** + * The {@code invoice_id} property. + * + * @return the value, empty when unset or null + */ + public Optional invoiceId() { + return invoiceId.asOptional(); + } + + /** + * The {@code payment_id} property. + * + * @return the value, empty when unset or null + */ + public Optional paymentId() { + return paymentId.asOptional(); + } + + /** + * Properties this version of the SDK does not know, kept as received and sent back. + * + * @return the properties by name, unmodifiable + */ + public Map additionalProperties() { + return Collections.unmodifiableMap(additionalProperties); + } + + @JsonAnyGetter + private Map anyProperties() { + return additionalProperties; + } + + @JsonAnySetter + private void putAnyProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + WalletCreditRecoveredEventData that = (WalletCreditRecoveredEventData) o; + return Objects.equals(cause, that.cause) + && Objects.equals(creditNoteId, that.creditNoteId) + && Objects.equals(creditRecovered, that.creditRecovered) + && Objects.equals(creditUnit, that.creditUnit) + && Objects.equals(creditUnitPrecision, that.creditUnitPrecision) + && Objects.equals(creditUnrecoveredTotal, that.creditUnrecoveredTotal) + && Objects.equals(currency, that.currency) + && Objects.equals(customerId, that.customerId) + && Objects.equals(invoiceId, that.invoiceId) + && Objects.equals(paymentId, that.paymentId) + && Objects.equals(additionalProperties, that.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash( + cause, + creditNoteId, + creditRecovered, + creditUnit, + creditUnitPrecision, + creditUnrecoveredTotal, + currency, + customerId, + invoiceId, + paymentId, + additionalProperties); + } + + @Override + public String toString() { + return "WalletCreditRecoveredEventData{" + + "cause=" + + cause + + ", creditNoteId=" + + creditNoteId + + ", creditRecovered=" + + creditRecovered + + ", creditUnit=" + + creditUnit + + ", creditUnitPrecision=" + + creditUnitPrecision + + ", creditUnrecoveredTotal=" + + creditUnrecoveredTotal + + ", currency=" + + currency + + ", customerId=" + + customerId + + ", invoiceId=" + + invoiceId + + ", paymentId=" + + paymentId + + ", additionalProperties=" + + additionalProperties + + "}"; + } + + /** Builds {@link WalletCreditRecoveredEventData}. */ + public static final class Builder { + private String cause; + private JsonField creditNoteId = JsonField.missing(); + private Long creditRecovered; + private JsonField creditUnit = JsonField.missing(); + private JsonField creditUnitPrecision = JsonField.missing(); + private Long creditUnrecoveredTotal; + private JsonField currency = JsonField.missing(); + private String customerId; + private JsonField invoiceId = JsonField.missing(); + private JsonField paymentId = JsonField.missing(); + private final Map additionalProperties = new LinkedHashMap<>(); + + private Builder() {} + + /** + * Cause of the loss this recovers: PAYMENT_DISPUTED, PAYMENT_REVERSED + * , PAYMENT_REFUNDED or CREDIT_NOTE_REFUNDED. + * + * @param cause the value + * @return this builder + */ + public Builder cause(String cause) { + this.cause = cause; + return this; + } + + /** + * The {@code credit_note_id} property. + * + * @param creditNoteId the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder creditNoteId(String creditNoteId) { + this.creditNoteId = JsonField.ofNullable(creditNoteId); + return this; + } + + /** + * Spent credit an earlier wallet.credit_unrecovered reported that is backed + * again, in minor units: the money came back, or the credit was returned and taken back. + * + * @param creditRecovered the value + * @return this builder + */ + public Builder creditRecovered(Long creditRecovered) { + this.creditRecovered = creditRecovered; + return this; + } + + /** + * The credit unit (its code) the amounts are in; absent for a currency. + * + * @param creditUnit the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder creditUnit(String creditUnit) { + this.creditUnit = JsonField.ofNullable(creditUnit); + return this; + } + + /** + * Decimal places of credit_unit: amounts are integers of 10^-precision credit. + * + * @param creditUnitPrecision the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder creditUnitPrecision(Integer creditUnitPrecision) { + this.creditUnitPrecision = JsonField.ofNullable(creditUnitPrecision); + return this; + } + + /** + * The loss of this money flow (an invoice's payments, a credit note, or a payment) once + * this event applies. + * + * @param creditUnrecoveredTotal the value + * @return this builder + */ + public Builder creditUnrecoveredTotal(Long creditUnrecoveredTotal) { + this.creditUnrecoveredTotal = creditUnrecoveredTotal; + return this; + } + + /** + * Absent when the amounts are in a credit unit. + * + * @param currency the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder currency(String currency) { + this.currency = JsonField.ofNullable(currency); + return this; + } + + /** + * The {@code customer_id} property. + * + * @param customerId the value + * @return this builder + */ + public Builder customerId(String customerId) { + this.customerId = customerId; + return this; + } + + /** + * The {@code invoice_id} property. + * + * @param invoiceId the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder invoiceId(String invoiceId) { + this.invoiceId = JsonField.ofNullable(invoiceId); + return this; + } + + /** + * The {@code payment_id} property. + * + * @param paymentId the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder paymentId(String paymentId) { + this.paymentId = JsonField.ofNullable(paymentId); + return this; + } + + /** + * A property the SDK does not know, sent along. + * + * @param name the property name + * @param value the JSON value + * @return this builder + */ + public Builder putAdditionalProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + return this; + } + + /** + * Properties the SDK does not know, sent along. + * + * @param additionalProperties the properties by name + * @return this builder + */ + public Builder putAllAdditionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + + /** + * Leaves out a property the SDK does not know. + * + * @param name the property name + * @return this builder + */ + public Builder removeAdditionalProperty(String name) { + additionalProperties.remove(name); + return this; + } + + /** + * The {@code WalletCreditRecoveredEventData}. + * + * @return the immutable value + * @throws IllegalStateException when a required property is not set + */ + public WalletCreditRecoveredEventData build() { + Utils.checkRequired(cause, "cause"); + Utils.checkRequired(creditRecovered, "credit_recovered"); + Utils.checkRequired(creditUnrecoveredTotal, "credit_unrecovered_total"); + Utils.checkRequired(customerId, "customer_id"); + return new WalletCreditRecoveredEventData(this); + } + } + + /** + * Parse {@code json} as {@code WalletCreditRecoveredEventData}. + * + * @param json the JSON text + * @return the value + * @throws com.meteroid.exceptions.InvalidDataException if it is not valid JSON of this shape + */ + public static WalletCreditRecoveredEventData fromJson(String json) { + return Utils.parse(json, WalletCreditRecoveredEventData.class); + } + + /** + * This value as JSON. + * + * @return the JSON text + */ + public String toJson() { + return Utils.json(this); + } +} diff --git a/src/main/java/com/meteroid/models/WalletCreditUnrecoveredEvent.java b/src/main/java/com/meteroid/models/WalletCreditUnrecoveredEvent.java new file mode 100644 index 0000000..6f76328 --- /dev/null +++ b/src/main/java/com/meteroid/models/WalletCreditUnrecoveredEvent.java @@ -0,0 +1,286 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.Unions; +import com.meteroid.internal.Utils; + +import java.time.OffsetDateTime; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; + +/** Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonAutoDetect( + getterVisibility = Visibility.NONE, + isGetterVisibility = Visibility.NONE, + setterVisibility = Visibility.NONE) +public final class WalletCreditUnrecoveredEvent { + @JsonProperty("id") + private String id; + + @JsonProperty("timestamp") + private OffsetDateTime timestamp; + + @JsonProperty("type") + private EventType type; + + private final Map additionalProperties = new LinkedHashMap<>(); + + private WalletCreditUnrecoveredEvent() {} + + private WalletCreditUnrecoveredEvent(Builder builder) { + this.id = builder.id; + this.timestamp = builder.timestamp; + this.type = builder.type; + this.additionalProperties.putAll(builder.additionalProperties); + } + + /** + * A builder of {@code WalletCreditUnrecoveredEvent}. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * A builder starting from this value. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.id = id; + builder.timestamp = timestamp; + builder.type = type; + builder.additionalProperties.putAll(additionalProperties); + return builder; + } + + /** + * The properties of {@link WalletCreditUnrecoveredEventData}, which this schema extends. + * + * @return the properties of this part + */ + public WalletCreditUnrecoveredEventData walletCreditUnrecoveredEventData() { + return Unions.convert(additionalProperties, WalletCreditUnrecoveredEventData.class); + } + + /** + * The {@code id} property. + * + * @return the value, never null + */ + public String id() { + return Utils.required(id, "id"); + } + + /** + * The {@code timestamp} property. + * + * @return the value, never null + */ + public OffsetDateTime timestamp() { + return Utils.required(timestamp, "timestamp"); + } + + /** + * The {@code type} property. + * + * @return the value, never null + */ + public EventType type() { + return Utils.required(type, "type"); + } + + /** + * Properties this version of the SDK does not know, kept as received and sent back. + * + * @return the properties by name, unmodifiable + */ + public Map additionalProperties() { + Map unknown = new LinkedHashMap<>(additionalProperties); + unknown.keySet() + .retainAll(walletCreditUnrecoveredEventData().additionalProperties().keySet()); + return Collections.unmodifiableMap(unknown); + } + + @JsonAnyGetter + private Map anyProperties() { + return additionalProperties; + } + + @JsonAnySetter + private void putAnyProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + WalletCreditUnrecoveredEvent that = (WalletCreditUnrecoveredEvent) o; + return Objects.equals(id, that.id) + && Objects.equals(timestamp, that.timestamp) + && Objects.equals(type, that.type) + && Objects.equals(additionalProperties, that.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(id, timestamp, type, additionalProperties); + } + + @Override + public String toString() { + return "WalletCreditUnrecoveredEvent{" + + "id=" + + id + + ", timestamp=" + + timestamp + + ", type=" + + type + + ", additionalProperties=" + + additionalProperties + + "}"; + } + + /** Builds {@link WalletCreditUnrecoveredEvent}. */ + public static final class Builder { + private String id; + private OffsetDateTime timestamp; + private EventType type; + private final Map additionalProperties = new LinkedHashMap<>(); + + private Builder() {} + + /** + * Sets the properties of {@link WalletCreditUnrecoveredEventData}, which this schema + * extends. + * + * @param walletCreditUnrecoveredEventData the properties + * @return this builder + */ + public Builder walletCreditUnrecoveredEventData( + WalletCreditUnrecoveredEventData walletCreditUnrecoveredEventData) { + additionalProperties.putAll(Utils.properties(walletCreditUnrecoveredEventData)); + return this; + } + + /** + * The {@code id} property. + * + * @param id the value + * @return this builder + */ + public Builder id(String id) { + this.id = id; + return this; + } + + /** + * The {@code timestamp} property. + * + * @param timestamp the value + * @return this builder + */ + public Builder timestamp(OffsetDateTime timestamp) { + this.timestamp = timestamp; + return this; + } + + /** + * The {@code type} property. + * + * @param type the value + * @return this builder + */ + public Builder type(EventType type) { + this.type = type; + return this; + } + + /** + * A property the SDK does not know, sent along. + * + * @param name the property name + * @param value the JSON value + * @return this builder + */ + public Builder putAdditionalProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + return this; + } + + /** + * Properties the SDK does not know, sent along. + * + * @param additionalProperties the properties by name + * @return this builder + */ + public Builder putAllAdditionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + + /** + * Leaves out a property the SDK does not know. + * + * @param name the property name + * @return this builder + */ + public Builder removeAdditionalProperty(String name) { + additionalProperties.remove(name); + return this; + } + + /** + * The {@code WalletCreditUnrecoveredEvent}. + * + * @return the immutable value + * @throws IllegalStateException when a required property is not set + */ + public WalletCreditUnrecoveredEvent build() { + Utils.checkRequired(id, "id"); + Utils.checkRequired(timestamp, "timestamp"); + Utils.checkRequired(type, "type"); + return new WalletCreditUnrecoveredEvent(this); + } + } + + /** + * Parse {@code json} as {@code WalletCreditUnrecoveredEvent}. + * + * @param json the JSON text + * @return the value + * @throws com.meteroid.exceptions.InvalidDataException if it is not valid JSON of this shape + */ + public static WalletCreditUnrecoveredEvent fromJson(String json) { + return Utils.parse(json, WalletCreditUnrecoveredEvent.class); + } + + /** + * This value as JSON. + * + * @return the JSON text + */ + public String toJson() { + return Utils.json(this); + } +} diff --git a/src/main/java/com/meteroid/models/WalletCreditUnrecoveredEventData.java b/src/main/java/com/meteroid/models/WalletCreditUnrecoveredEventData.java new file mode 100644 index 0000000..af47526 --- /dev/null +++ b/src/main/java/com/meteroid/models/WalletCreditUnrecoveredEventData.java @@ -0,0 +1,529 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.JsonField; +import com.meteroid.internal.Utils; + +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +/** + * Purchased credit was already spent when its money came back. + * + *

Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonAutoDetect( + getterVisibility = Visibility.NONE, + isGetterVisibility = Visibility.NONE, + setterVisibility = Visibility.NONE) +public final class WalletCreditUnrecoveredEventData { + @JsonProperty("cause") + private String cause; + + @JsonProperty("credit_note_id") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField creditNoteId = JsonField.missing(); + + @JsonProperty("credit_taken_back") + private Long creditTakenBack; + + @JsonProperty("credit_unit") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField creditUnit = JsonField.missing(); + + @JsonProperty("credit_unit_precision") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField creditUnitPrecision = JsonField.missing(); + + @JsonProperty("credit_unrecovered") + private Long creditUnrecovered; + + @JsonProperty("credit_unrecovered_total") + private Long creditUnrecoveredTotal; + + @JsonProperty("currency") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField currency = JsonField.missing(); + + @JsonProperty("customer_id") + private String customerId; + + @JsonProperty("invoice_id") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField invoiceId = JsonField.missing(); + + @JsonProperty("payment_id") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField paymentId = JsonField.missing(); + + private final Map additionalProperties = new LinkedHashMap<>(); + + private WalletCreditUnrecoveredEventData() {} + + private WalletCreditUnrecoveredEventData(Builder builder) { + this.cause = builder.cause; + this.creditNoteId = builder.creditNoteId; + this.creditTakenBack = builder.creditTakenBack; + this.creditUnit = builder.creditUnit; + this.creditUnitPrecision = builder.creditUnitPrecision; + this.creditUnrecovered = builder.creditUnrecovered; + this.creditUnrecoveredTotal = builder.creditUnrecoveredTotal; + this.currency = builder.currency; + this.customerId = builder.customerId; + this.invoiceId = builder.invoiceId; + this.paymentId = builder.paymentId; + this.additionalProperties.putAll(builder.additionalProperties); + } + + /** + * A builder of {@code WalletCreditUnrecoveredEventData}. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * A builder starting from this value. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.cause = cause; + builder.creditNoteId = creditNoteId; + builder.creditTakenBack = creditTakenBack; + builder.creditUnit = creditUnit; + builder.creditUnitPrecision = creditUnitPrecision; + builder.creditUnrecovered = creditUnrecovered; + builder.creditUnrecoveredTotal = creditUnrecoveredTotal; + builder.currency = currency; + builder.customerId = customerId; + builder.invoiceId = invoiceId; + builder.paymentId = paymentId; + builder.additionalProperties.putAll(additionalProperties); + return builder; + } + + /** + * PAYMENT_DISPUTED (lost to a dispute or chargeback), PAYMENT_REVERSED + * (a failed collection clawed back), PAYMENT_REFUNDED (a payment refunded + * without a credit note, at the provider or as an overpayment, after the credit it backed was + * spent) or CREDIT_NOTE_REFUNDED. + * + * @return the value, never null + */ + public String cause() { + return Utils.required(cause, "cause"); + } + + /** + * The {@code credit_note_id} property. + * + * @return the value, empty when unset or null + */ + public Optional creditNoteId() { + return creditNoteId.asOptional(); + } + + /** + * Unspent credit taken back from the wallet at the same time, in minor units. + * + * @return the value, never null + */ + public Long creditTakenBack() { + return Utils.required(creditTakenBack, "credit_taken_back"); + } + + /** + * The credit unit (its code) the amounts are in; absent for a currency. + * + * @return the value, empty when unset or null + */ + public Optional creditUnit() { + return creditUnit.asOptional(); + } + + /** + * Decimal places of credit_unit: amounts are integers of 10^-precision credit. + * + * @return the value, empty when unset or null + */ + public Optional creditUnitPrecision() { + return creditUnitPrecision.asOptional(); + } + + /** + * Spent credit this event adds to the loss, in minor units. A failed collection reopens its + * invoice, which collects it again; a dispute's loss stays unless the dispute is won. + * wallet.credit_recovered reports what comes back. + * + * @return the value, never null + */ + public Long creditUnrecovered() { + return Utils.required(creditUnrecovered, "credit_unrecovered"); + } + + /** + * The loss of this money flow (an invoice's payments, a credit note, or a payment) once this + * event applies. + * + * @return the value, never null + */ + public Long creditUnrecoveredTotal() { + return Utils.required(creditUnrecoveredTotal, "credit_unrecovered_total"); + } + + /** + * Absent when the amounts are in a credit unit. + * + * @return the value, empty when unset or null + */ + public Optional currency() { + return currency.asOptional(); + } + + /** + * The {@code customer_id} property. + * + * @return the value, never null + */ + public String customerId() { + return Utils.required(customerId, "customer_id"); + } + + /** + * The {@code invoice_id} property. + * + * @return the value, empty when unset or null + */ + public Optional invoiceId() { + return invoiceId.asOptional(); + } + + /** + * The {@code payment_id} property. + * + * @return the value, empty when unset or null + */ + public Optional paymentId() { + return paymentId.asOptional(); + } + + /** + * Properties this version of the SDK does not know, kept as received and sent back. + * + * @return the properties by name, unmodifiable + */ + public Map additionalProperties() { + return Collections.unmodifiableMap(additionalProperties); + } + + @JsonAnyGetter + private Map anyProperties() { + return additionalProperties; + } + + @JsonAnySetter + private void putAnyProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + WalletCreditUnrecoveredEventData that = (WalletCreditUnrecoveredEventData) o; + return Objects.equals(cause, that.cause) + && Objects.equals(creditNoteId, that.creditNoteId) + && Objects.equals(creditTakenBack, that.creditTakenBack) + && Objects.equals(creditUnit, that.creditUnit) + && Objects.equals(creditUnitPrecision, that.creditUnitPrecision) + && Objects.equals(creditUnrecovered, that.creditUnrecovered) + && Objects.equals(creditUnrecoveredTotal, that.creditUnrecoveredTotal) + && Objects.equals(currency, that.currency) + && Objects.equals(customerId, that.customerId) + && Objects.equals(invoiceId, that.invoiceId) + && Objects.equals(paymentId, that.paymentId) + && Objects.equals(additionalProperties, that.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash( + cause, + creditNoteId, + creditTakenBack, + creditUnit, + creditUnitPrecision, + creditUnrecovered, + creditUnrecoveredTotal, + currency, + customerId, + invoiceId, + paymentId, + additionalProperties); + } + + @Override + public String toString() { + return "WalletCreditUnrecoveredEventData{" + + "cause=" + + cause + + ", creditNoteId=" + + creditNoteId + + ", creditTakenBack=" + + creditTakenBack + + ", creditUnit=" + + creditUnit + + ", creditUnitPrecision=" + + creditUnitPrecision + + ", creditUnrecovered=" + + creditUnrecovered + + ", creditUnrecoveredTotal=" + + creditUnrecoveredTotal + + ", currency=" + + currency + + ", customerId=" + + customerId + + ", invoiceId=" + + invoiceId + + ", paymentId=" + + paymentId + + ", additionalProperties=" + + additionalProperties + + "}"; + } + + /** Builds {@link WalletCreditUnrecoveredEventData}. */ + public static final class Builder { + private String cause; + private JsonField creditNoteId = JsonField.missing(); + private Long creditTakenBack; + private JsonField creditUnit = JsonField.missing(); + private JsonField creditUnitPrecision = JsonField.missing(); + private Long creditUnrecovered; + private Long creditUnrecoveredTotal; + private JsonField currency = JsonField.missing(); + private String customerId; + private JsonField invoiceId = JsonField.missing(); + private JsonField paymentId = JsonField.missing(); + private final Map additionalProperties = new LinkedHashMap<>(); + + private Builder() {} + + /** + * PAYMENT_DISPUTED (lost to a dispute or chargeback), PAYMENT_REVERSED + * (a failed collection clawed back), PAYMENT_REFUNDED (a payment + * refunded without a credit note, at the provider or as an overpayment, after the credit it + * backed was spent) or CREDIT_NOTE_REFUNDED. + * + * @param cause the value + * @return this builder + */ + public Builder cause(String cause) { + this.cause = cause; + return this; + } + + /** + * The {@code credit_note_id} property. + * + * @param creditNoteId the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder creditNoteId(String creditNoteId) { + this.creditNoteId = JsonField.ofNullable(creditNoteId); + return this; + } + + /** + * Unspent credit taken back from the wallet at the same time, in minor units. + * + * @param creditTakenBack the value + * @return this builder + */ + public Builder creditTakenBack(Long creditTakenBack) { + this.creditTakenBack = creditTakenBack; + return this; + } + + /** + * The credit unit (its code) the amounts are in; absent for a currency. + * + * @param creditUnit the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder creditUnit(String creditUnit) { + this.creditUnit = JsonField.ofNullable(creditUnit); + return this; + } + + /** + * Decimal places of credit_unit: amounts are integers of 10^-precision credit. + * + * @param creditUnitPrecision the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder creditUnitPrecision(Integer creditUnitPrecision) { + this.creditUnitPrecision = JsonField.ofNullable(creditUnitPrecision); + return this; + } + + /** + * Spent credit this event adds to the loss, in minor units. A failed collection reopens its + * invoice, which collects it again; a dispute's loss stays unless the dispute is won. + * wallet.credit_recovered reports what comes back. + * + * @param creditUnrecovered the value + * @return this builder + */ + public Builder creditUnrecovered(Long creditUnrecovered) { + this.creditUnrecovered = creditUnrecovered; + return this; + } + + /** + * The loss of this money flow (an invoice's payments, a credit note, or a payment) once + * this event applies. + * + * @param creditUnrecoveredTotal the value + * @return this builder + */ + public Builder creditUnrecoveredTotal(Long creditUnrecoveredTotal) { + this.creditUnrecoveredTotal = creditUnrecoveredTotal; + return this; + } + + /** + * Absent when the amounts are in a credit unit. + * + * @param currency the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder currency(String currency) { + this.currency = JsonField.ofNullable(currency); + return this; + } + + /** + * The {@code customer_id} property. + * + * @param customerId the value + * @return this builder + */ + public Builder customerId(String customerId) { + this.customerId = customerId; + return this; + } + + /** + * The {@code invoice_id} property. + * + * @param invoiceId the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder invoiceId(String invoiceId) { + this.invoiceId = JsonField.ofNullable(invoiceId); + return this; + } + + /** + * The {@code payment_id} property. + * + * @param paymentId the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder paymentId(String paymentId) { + this.paymentId = JsonField.ofNullable(paymentId); + return this; + } + + /** + * A property the SDK does not know, sent along. + * + * @param name the property name + * @param value the JSON value + * @return this builder + */ + public Builder putAdditionalProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + return this; + } + + /** + * Properties the SDK does not know, sent along. + * + * @param additionalProperties the properties by name + * @return this builder + */ + public Builder putAllAdditionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + + /** + * Leaves out a property the SDK does not know. + * + * @param name the property name + * @return this builder + */ + public Builder removeAdditionalProperty(String name) { + additionalProperties.remove(name); + return this; + } + + /** + * The {@code WalletCreditUnrecoveredEventData}. + * + * @return the immutable value + * @throws IllegalStateException when a required property is not set + */ + public WalletCreditUnrecoveredEventData build() { + Utils.checkRequired(cause, "cause"); + Utils.checkRequired(creditTakenBack, "credit_taken_back"); + Utils.checkRequired(creditUnrecovered, "credit_unrecovered"); + Utils.checkRequired(creditUnrecoveredTotal, "credit_unrecovered_total"); + Utils.checkRequired(customerId, "customer_id"); + return new WalletCreditUnrecoveredEventData(this); + } + } + + /** + * Parse {@code json} as {@code WalletCreditUnrecoveredEventData}. + * + * @param json the JSON text + * @return the value + * @throws com.meteroid.exceptions.InvalidDataException if it is not valid JSON of this shape + */ + public static WalletCreditUnrecoveredEventData fromJson(String json) { + return Utils.parse(json, WalletCreditUnrecoveredEventData.class); + } + + /** + * This value as JSON. + * + * @return the JSON text + */ + public String toJson() { + return Utils.json(this); + } +} diff --git a/src/main/java/com/meteroid/models/WalletDebitedEvent.java b/src/main/java/com/meteroid/models/WalletDebitedEvent.java new file mode 100644 index 0000000..4d05046 --- /dev/null +++ b/src/main/java/com/meteroid/models/WalletDebitedEvent.java @@ -0,0 +1,283 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.Unions; +import com.meteroid.internal.Utils; + +import java.time.OffsetDateTime; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; + +/** Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonAutoDetect( + getterVisibility = Visibility.NONE, + isGetterVisibility = Visibility.NONE, + setterVisibility = Visibility.NONE) +public final class WalletDebitedEvent { + @JsonProperty("id") + private String id; + + @JsonProperty("timestamp") + private OffsetDateTime timestamp; + + @JsonProperty("type") + private EventType type; + + private final Map additionalProperties = new LinkedHashMap<>(); + + private WalletDebitedEvent() {} + + private WalletDebitedEvent(Builder builder) { + this.id = builder.id; + this.timestamp = builder.timestamp; + this.type = builder.type; + this.additionalProperties.putAll(builder.additionalProperties); + } + + /** + * A builder of {@code WalletDebitedEvent}. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * A builder starting from this value. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.id = id; + builder.timestamp = timestamp; + builder.type = type; + builder.additionalProperties.putAll(additionalProperties); + return builder; + } + + /** + * The properties of {@link WalletDebitedEventData}, which this schema extends. + * + * @return the properties of this part + */ + public WalletDebitedEventData walletDebitedEventData() { + return Unions.convert(additionalProperties, WalletDebitedEventData.class); + } + + /** + * The {@code id} property. + * + * @return the value, never null + */ + public String id() { + return Utils.required(id, "id"); + } + + /** + * The {@code timestamp} property. + * + * @return the value, never null + */ + public OffsetDateTime timestamp() { + return Utils.required(timestamp, "timestamp"); + } + + /** + * The {@code type} property. + * + * @return the value, never null + */ + public EventType type() { + return Utils.required(type, "type"); + } + + /** + * Properties this version of the SDK does not know, kept as received and sent back. + * + * @return the properties by name, unmodifiable + */ + public Map additionalProperties() { + Map unknown = new LinkedHashMap<>(additionalProperties); + unknown.keySet().retainAll(walletDebitedEventData().additionalProperties().keySet()); + return Collections.unmodifiableMap(unknown); + } + + @JsonAnyGetter + private Map anyProperties() { + return additionalProperties; + } + + @JsonAnySetter + private void putAnyProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + WalletDebitedEvent that = (WalletDebitedEvent) o; + return Objects.equals(id, that.id) + && Objects.equals(timestamp, that.timestamp) + && Objects.equals(type, that.type) + && Objects.equals(additionalProperties, that.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(id, timestamp, type, additionalProperties); + } + + @Override + public String toString() { + return "WalletDebitedEvent{" + + "id=" + + id + + ", timestamp=" + + timestamp + + ", type=" + + type + + ", additionalProperties=" + + additionalProperties + + "}"; + } + + /** Builds {@link WalletDebitedEvent}. */ + public static final class Builder { + private String id; + private OffsetDateTime timestamp; + private EventType type; + private final Map additionalProperties = new LinkedHashMap<>(); + + private Builder() {} + + /** + * Sets the properties of {@link WalletDebitedEventData}, which this schema extends. + * + * @param walletDebitedEventData the properties + * @return this builder + */ + public Builder walletDebitedEventData(WalletDebitedEventData walletDebitedEventData) { + additionalProperties.putAll(Utils.properties(walletDebitedEventData)); + return this; + } + + /** + * The {@code id} property. + * + * @param id the value + * @return this builder + */ + public Builder id(String id) { + this.id = id; + return this; + } + + /** + * The {@code timestamp} property. + * + * @param timestamp the value + * @return this builder + */ + public Builder timestamp(OffsetDateTime timestamp) { + this.timestamp = timestamp; + return this; + } + + /** + * The {@code type} property. + * + * @param type the value + * @return this builder + */ + public Builder type(EventType type) { + this.type = type; + return this; + } + + /** + * A property the SDK does not know, sent along. + * + * @param name the property name + * @param value the JSON value + * @return this builder + */ + public Builder putAdditionalProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + return this; + } + + /** + * Properties the SDK does not know, sent along. + * + * @param additionalProperties the properties by name + * @return this builder + */ + public Builder putAllAdditionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + + /** + * Leaves out a property the SDK does not know. + * + * @param name the property name + * @return this builder + */ + public Builder removeAdditionalProperty(String name) { + additionalProperties.remove(name); + return this; + } + + /** + * The {@code WalletDebitedEvent}. + * + * @return the immutable value + * @throws IllegalStateException when a required property is not set + */ + public WalletDebitedEvent build() { + Utils.checkRequired(id, "id"); + Utils.checkRequired(timestamp, "timestamp"); + Utils.checkRequired(type, "type"); + return new WalletDebitedEvent(this); + } + } + + /** + * Parse {@code json} as {@code WalletDebitedEvent}. + * + * @param json the JSON text + * @return the value + * @throws com.meteroid.exceptions.InvalidDataException if it is not valid JSON of this shape + */ + public static WalletDebitedEvent fromJson(String json) { + return Utils.parse(json, WalletDebitedEvent.class); + } + + /** + * This value as JSON. + * + * @return the JSON text + */ + public String toJson() { + return Utils.json(this); + } +} diff --git a/src/main/java/com/meteroid/models/WalletDebitedEventData.java b/src/main/java/com/meteroid/models/WalletDebitedEventData.java new file mode 100644 index 0000000..2d38336 --- /dev/null +++ b/src/main/java/com/meteroid/models/WalletDebitedEventData.java @@ -0,0 +1,628 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.JsonField; +import com.meteroid.internal.Utils; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +/** + * Credit left a customer's wallet. + * + *

Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonAutoDetect( + getterVisibility = Visibility.NONE, + isGetterVisibility = Visibility.NONE, + setterVisibility = Visibility.NONE) +public final class WalletDebitedEventData { + @JsonProperty("actor") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField actor = JsonField.missing(); + + @JsonProperty("amount") + private Long amount; + + @JsonProperty("applicable_product_ids") + private List applicableProductIds; + + @JsonProperty("applies_to") + private CreditAppliesTo appliesTo; + + @JsonProperty("credit_grant_id") + private String creditGrantId; + + @JsonProperty("credit_note_id") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField creditNoteId = JsonField.missing(); + + @JsonProperty("credit_unit") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField creditUnit = JsonField.missing(); + + @JsonProperty("credit_unit_precision") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField creditUnitPrecision = JsonField.missing(); + + @JsonProperty("currency") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField currency = JsonField.missing(); + + @JsonProperty("customer_id") + private String customerId; + + @JsonProperty("invoice_id") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField invoiceId = JsonField.missing(); + + @JsonProperty("ledger_entry_id") + private String ledgerEntryId; + + @JsonProperty("reason") + private String reason; + + @JsonProperty("subscription_id") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField subscriptionId = JsonField.missing(); + + private final Map additionalProperties = new LinkedHashMap<>(); + + private WalletDebitedEventData() {} + + private WalletDebitedEventData(Builder builder) { + this.actor = builder.actor; + this.amount = builder.amount; + this.applicableProductIds = Utils.copyList(builder.applicableProductIds); + this.appliesTo = builder.appliesTo; + this.creditGrantId = builder.creditGrantId; + this.creditNoteId = builder.creditNoteId; + this.creditUnit = builder.creditUnit; + this.creditUnitPrecision = builder.creditUnitPrecision; + this.currency = builder.currency; + this.customerId = builder.customerId; + this.invoiceId = builder.invoiceId; + this.ledgerEntryId = builder.ledgerEntryId; + this.reason = builder.reason; + this.subscriptionId = builder.subscriptionId; + this.additionalProperties.putAll(builder.additionalProperties); + } + + /** + * A builder of {@code WalletDebitedEventData}. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * A builder starting from this value. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.actor = actor; + builder.amount = amount; + builder.applicableProductIds = Utils.mutableList(applicableProductIds); + builder.appliesTo = appliesTo; + builder.creditGrantId = creditGrantId; + builder.creditNoteId = creditNoteId; + builder.creditUnit = creditUnit; + builder.creditUnitPrecision = creditUnitPrecision; + builder.currency = currency; + builder.customerId = customerId; + builder.invoiceId = invoiceId; + builder.ledgerEntryId = ledgerEntryId; + builder.reason = reason; + builder.subscriptionId = subscriptionId; + builder.additionalProperties.putAll(additionalProperties); + return builder; + } + + /** + * The {@code actor} property. + * + * @return the value, empty when unset or null + */ + public Optional actor() { + return actor.asOptional(); + } + + /** + * In minor units of currency or credit_unit. + * + * @return the value, never null + */ + public Long amount() { + return Utils.required(amount, "amount"); + } + + /** + * The products whose charges the grant pays; empty when it pays every product. + * + * @return the value, never null + */ + public List applicableProductIds() { + return Utils.required(applicableProductIds, "applicable_product_ids"); + } + + /** + * What the grant pays: ALL any charge, USAGE only usage charges. + * + * @return the value, never null + */ + public CreditAppliesTo appliesTo() { + return Utils.required(appliesTo, "applies_to"); + } + + /** + * The grant the credit left. + * + * @return the value, never null + */ + public String creditGrantId() { + return Utils.required(creditGrantId, "credit_grant_id"); + } + + /** + * The {@code credit_note_id} property. + * + * @return the value, empty when unset or null + */ + public Optional creditNoteId() { + return creditNoteId.asOptional(); + } + + /** + * The credit unit (its code) the amounts are in; absent for a currency. + * + * @return the value, empty when unset or null + */ + public Optional creditUnit() { + return creditUnit.asOptional(); + } + + /** + * Decimal places of credit_unit: amounts are integers of 10^-precision credit. + * + * @return the value, empty when unset or null + */ + public Optional creditUnitPrecision() { + return creditUnitPrecision.asOptional(); + } + + /** + * Absent when the amounts are in a credit unit. + * + * @return the value, empty when unset or null + */ + public Optional currency() { + return currency.asOptional(); + } + + /** + * The {@code customer_id} property. + * + * @return the value, never null + */ + public String customerId() { + return Utils.required(customerId, "customer_id"); + } + + /** + * The {@code invoice_id} property. + * + * @return the value, empty when unset or null + */ + public Optional invoiceId() { + return invoiceId.asOptional(); + } + + /** + * The credit ledger entry recording the movement. + * + * @return the value, never null + */ + public String ledgerEntryId() { + return Utils.required(ledgerEntryId, "ledger_entry_id"); + } + + /** + * Why the credit moved, as shown on the ledger. + * + * @return the value, never null + */ + public String reason() { + return Utils.required(reason, "reason"); + } + + /** + * The subscription the grant belongs to: it pays only that subscription's charges. Null when it + * pays any of the customer's subscriptions. + * + * @return the value, empty when unset or null + */ + public Optional subscriptionId() { + return subscriptionId.asOptional(); + } + + /** + * Properties this version of the SDK does not know, kept as received and sent back. + * + * @return the properties by name, unmodifiable + */ + public Map additionalProperties() { + return Collections.unmodifiableMap(additionalProperties); + } + + @JsonAnyGetter + private Map anyProperties() { + return additionalProperties; + } + + @JsonAnySetter + private void putAnyProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + WalletDebitedEventData that = (WalletDebitedEventData) o; + return Objects.equals(actor, that.actor) + && Objects.equals(amount, that.amount) + && Objects.equals(applicableProductIds, that.applicableProductIds) + && Objects.equals(appliesTo, that.appliesTo) + && Objects.equals(creditGrantId, that.creditGrantId) + && Objects.equals(creditNoteId, that.creditNoteId) + && Objects.equals(creditUnit, that.creditUnit) + && Objects.equals(creditUnitPrecision, that.creditUnitPrecision) + && Objects.equals(currency, that.currency) + && Objects.equals(customerId, that.customerId) + && Objects.equals(invoiceId, that.invoiceId) + && Objects.equals(ledgerEntryId, that.ledgerEntryId) + && Objects.equals(reason, that.reason) + && Objects.equals(subscriptionId, that.subscriptionId) + && Objects.equals(additionalProperties, that.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash( + actor, + amount, + applicableProductIds, + appliesTo, + creditGrantId, + creditNoteId, + creditUnit, + creditUnitPrecision, + currency, + customerId, + invoiceId, + ledgerEntryId, + reason, + subscriptionId, + additionalProperties); + } + + @Override + public String toString() { + return "WalletDebitedEventData{" + + "actor=" + + actor + + ", amount=" + + amount + + ", applicableProductIds=" + + applicableProductIds + + ", appliesTo=" + + appliesTo + + ", creditGrantId=" + + creditGrantId + + ", creditNoteId=" + + creditNoteId + + ", creditUnit=" + + creditUnit + + ", creditUnitPrecision=" + + creditUnitPrecision + + ", currency=" + + currency + + ", customerId=" + + customerId + + ", invoiceId=" + + invoiceId + + ", ledgerEntryId=" + + ledgerEntryId + + ", reason=" + + reason + + ", subscriptionId=" + + subscriptionId + + ", additionalProperties=" + + additionalProperties + + "}"; + } + + /** Builds {@link WalletDebitedEventData}. */ + public static final class Builder { + private JsonField actor = JsonField.missing(); + private Long amount; + private List applicableProductIds; + private CreditAppliesTo appliesTo; + private String creditGrantId; + private JsonField creditNoteId = JsonField.missing(); + private JsonField creditUnit = JsonField.missing(); + private JsonField creditUnitPrecision = JsonField.missing(); + private JsonField currency = JsonField.missing(); + private String customerId; + private JsonField invoiceId = JsonField.missing(); + private String ledgerEntryId; + private String reason; + private JsonField subscriptionId = JsonField.missing(); + private final Map additionalProperties = new LinkedHashMap<>(); + + private Builder() {} + + /** + * The {@code actor} property. + * + * @param actor the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder actor(Actor actor) { + this.actor = JsonField.ofNullable(actor); + return this; + } + + /** + * In minor units of currency or credit_unit. + * + * @param amount the value + * @return this builder + */ + public Builder amount(Long amount) { + this.amount = amount; + return this; + } + + /** + * The products whose charges the grant pays; empty when it pays every product. + * + * @param applicableProductIds the value + * @return this builder + */ + public Builder applicableProductIds(List applicableProductIds) { + this.applicableProductIds = Utils.mutableList(applicableProductIds); + return this; + } + + /** + * Adds an item to {@code applicable_product_ids}. + * + * @param item the item + * @return this builder + */ + public Builder addApplicableProductIdsItem(String item) { + if (this.applicableProductIds == null) { + this.applicableProductIds = new ArrayList<>(); + } + this.applicableProductIds.add(item); + return this; + } + + /** + * What the grant pays: ALL any charge, USAGE only usage charges. + * + * @param appliesTo the value + * @return this builder + */ + public Builder appliesTo(CreditAppliesTo appliesTo) { + this.appliesTo = appliesTo; + return this; + } + + /** + * The grant the credit left. + * + * @param creditGrantId the value + * @return this builder + */ + public Builder creditGrantId(String creditGrantId) { + this.creditGrantId = creditGrantId; + return this; + } + + /** + * The {@code credit_note_id} property. + * + * @param creditNoteId the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder creditNoteId(String creditNoteId) { + this.creditNoteId = JsonField.ofNullable(creditNoteId); + return this; + } + + /** + * The credit unit (its code) the amounts are in; absent for a currency. + * + * @param creditUnit the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder creditUnit(String creditUnit) { + this.creditUnit = JsonField.ofNullable(creditUnit); + return this; + } + + /** + * Decimal places of credit_unit: amounts are integers of 10^-precision credit. + * + * @param creditUnitPrecision the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder creditUnitPrecision(Integer creditUnitPrecision) { + this.creditUnitPrecision = JsonField.ofNullable(creditUnitPrecision); + return this; + } + + /** + * Absent when the amounts are in a credit unit. + * + * @param currency the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder currency(String currency) { + this.currency = JsonField.ofNullable(currency); + return this; + } + + /** + * The {@code customer_id} property. + * + * @param customerId the value + * @return this builder + */ + public Builder customerId(String customerId) { + this.customerId = customerId; + return this; + } + + /** + * The {@code invoice_id} property. + * + * @param invoiceId the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder invoiceId(String invoiceId) { + this.invoiceId = JsonField.ofNullable(invoiceId); + return this; + } + + /** + * The credit ledger entry recording the movement. + * + * @param ledgerEntryId the value + * @return this builder + */ + public Builder ledgerEntryId(String ledgerEntryId) { + this.ledgerEntryId = ledgerEntryId; + return this; + } + + /** + * Why the credit moved, as shown on the ledger. + * + * @param reason the value + * @return this builder + */ + public Builder reason(String reason) { + this.reason = reason; + return this; + } + + /** + * The subscription the grant belongs to: it pays only that subscription's charges. Null + * when it pays any of the customer's subscriptions. + * + * @param subscriptionId the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder subscriptionId(String subscriptionId) { + this.subscriptionId = JsonField.ofNullable(subscriptionId); + return this; + } + + /** + * A property the SDK does not know, sent along. + * + * @param name the property name + * @param value the JSON value + * @return this builder + */ + public Builder putAdditionalProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + return this; + } + + /** + * Properties the SDK does not know, sent along. + * + * @param additionalProperties the properties by name + * @return this builder + */ + public Builder putAllAdditionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + + /** + * Leaves out a property the SDK does not know. + * + * @param name the property name + * @return this builder + */ + public Builder removeAdditionalProperty(String name) { + additionalProperties.remove(name); + return this; + } + + /** + * The {@code WalletDebitedEventData}. + * + * @return the immutable value + * @throws IllegalStateException when a required property is not set + */ + public WalletDebitedEventData build() { + Utils.checkRequired(amount, "amount"); + Utils.checkRequired(applicableProductIds, "applicable_product_ids"); + Utils.checkRequired(appliesTo, "applies_to"); + Utils.checkRequired(creditGrantId, "credit_grant_id"); + Utils.checkRequired(customerId, "customer_id"); + Utils.checkRequired(ledgerEntryId, "ledger_entry_id"); + Utils.checkRequired(reason, "reason"); + return new WalletDebitedEventData(this); + } + } + + /** + * Parse {@code json} as {@code WalletDebitedEventData}. + * + * @param json the JSON text + * @return the value + * @throws com.meteroid.exceptions.InvalidDataException if it is not valid JSON of this shape + */ + public static WalletDebitedEventData fromJson(String json) { + return Utils.parse(json, WalletDebitedEventData.class); + } + + /** + * This value as JSON. + * + * @return the JSON text + */ + public String toJson() { + return Utils.json(this); + } +} diff --git a/src/main/java/com/meteroid/models/WalletDepletedEvent.java b/src/main/java/com/meteroid/models/WalletDepletedEvent.java new file mode 100644 index 0000000..6f24c2d --- /dev/null +++ b/src/main/java/com/meteroid/models/WalletDepletedEvent.java @@ -0,0 +1,283 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.Unions; +import com.meteroid.internal.Utils; + +import java.time.OffsetDateTime; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; + +/** Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonAutoDetect( + getterVisibility = Visibility.NONE, + isGetterVisibility = Visibility.NONE, + setterVisibility = Visibility.NONE) +public final class WalletDepletedEvent { + @JsonProperty("id") + private String id; + + @JsonProperty("timestamp") + private OffsetDateTime timestamp; + + @JsonProperty("type") + private EventType type; + + private final Map additionalProperties = new LinkedHashMap<>(); + + private WalletDepletedEvent() {} + + private WalletDepletedEvent(Builder builder) { + this.id = builder.id; + this.timestamp = builder.timestamp; + this.type = builder.type; + this.additionalProperties.putAll(builder.additionalProperties); + } + + /** + * A builder of {@code WalletDepletedEvent}. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * A builder starting from this value. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.id = id; + builder.timestamp = timestamp; + builder.type = type; + builder.additionalProperties.putAll(additionalProperties); + return builder; + } + + /** + * The properties of {@link WalletDepletedEventData}, which this schema extends. + * + * @return the properties of this part + */ + public WalletDepletedEventData walletDepletedEventData() { + return Unions.convert(additionalProperties, WalletDepletedEventData.class); + } + + /** + * The {@code id} property. + * + * @return the value, never null + */ + public String id() { + return Utils.required(id, "id"); + } + + /** + * The {@code timestamp} property. + * + * @return the value, never null + */ + public OffsetDateTime timestamp() { + return Utils.required(timestamp, "timestamp"); + } + + /** + * The {@code type} property. + * + * @return the value, never null + */ + public EventType type() { + return Utils.required(type, "type"); + } + + /** + * Properties this version of the SDK does not know, kept as received and sent back. + * + * @return the properties by name, unmodifiable + */ + public Map additionalProperties() { + Map unknown = new LinkedHashMap<>(additionalProperties); + unknown.keySet().retainAll(walletDepletedEventData().additionalProperties().keySet()); + return Collections.unmodifiableMap(unknown); + } + + @JsonAnyGetter + private Map anyProperties() { + return additionalProperties; + } + + @JsonAnySetter + private void putAnyProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + WalletDepletedEvent that = (WalletDepletedEvent) o; + return Objects.equals(id, that.id) + && Objects.equals(timestamp, that.timestamp) + && Objects.equals(type, that.type) + && Objects.equals(additionalProperties, that.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(id, timestamp, type, additionalProperties); + } + + @Override + public String toString() { + return "WalletDepletedEvent{" + + "id=" + + id + + ", timestamp=" + + timestamp + + ", type=" + + type + + ", additionalProperties=" + + additionalProperties + + "}"; + } + + /** Builds {@link WalletDepletedEvent}. */ + public static final class Builder { + private String id; + private OffsetDateTime timestamp; + private EventType type; + private final Map additionalProperties = new LinkedHashMap<>(); + + private Builder() {} + + /** + * Sets the properties of {@link WalletDepletedEventData}, which this schema extends. + * + * @param walletDepletedEventData the properties + * @return this builder + */ + public Builder walletDepletedEventData(WalletDepletedEventData walletDepletedEventData) { + additionalProperties.putAll(Utils.properties(walletDepletedEventData)); + return this; + } + + /** + * The {@code id} property. + * + * @param id the value + * @return this builder + */ + public Builder id(String id) { + this.id = id; + return this; + } + + /** + * The {@code timestamp} property. + * + * @param timestamp the value + * @return this builder + */ + public Builder timestamp(OffsetDateTime timestamp) { + this.timestamp = timestamp; + return this; + } + + /** + * The {@code type} property. + * + * @param type the value + * @return this builder + */ + public Builder type(EventType type) { + this.type = type; + return this; + } + + /** + * A property the SDK does not know, sent along. + * + * @param name the property name + * @param value the JSON value + * @return this builder + */ + public Builder putAdditionalProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + return this; + } + + /** + * Properties the SDK does not know, sent along. + * + * @param additionalProperties the properties by name + * @return this builder + */ + public Builder putAllAdditionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + + /** + * Leaves out a property the SDK does not know. + * + * @param name the property name + * @return this builder + */ + public Builder removeAdditionalProperty(String name) { + additionalProperties.remove(name); + return this; + } + + /** + * The {@code WalletDepletedEvent}. + * + * @return the immutable value + * @throws IllegalStateException when a required property is not set + */ + public WalletDepletedEvent build() { + Utils.checkRequired(id, "id"); + Utils.checkRequired(timestamp, "timestamp"); + Utils.checkRequired(type, "type"); + return new WalletDepletedEvent(this); + } + } + + /** + * Parse {@code json} as {@code WalletDepletedEvent}. + * + * @param json the JSON text + * @return the value + * @throws com.meteroid.exceptions.InvalidDataException if it is not valid JSON of this shape + */ + public static WalletDepletedEvent fromJson(String json) { + return Utils.parse(json, WalletDepletedEvent.class); + } + + /** + * This value as JSON. + * + * @return the JSON text + */ + public String toJson() { + return Utils.json(this); + } +} diff --git a/src/main/java/com/meteroid/models/WalletDepletedEventData.java b/src/main/java/com/meteroid/models/WalletDepletedEventData.java new file mode 100644 index 0000000..661c5a8 --- /dev/null +++ b/src/main/java/com/meteroid/models/WalletDepletedEventData.java @@ -0,0 +1,297 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.JsonField; +import com.meteroid.internal.Utils; + +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +/** + * A wallet's balance (credit that pays any charge of any of the customer's subscriptions, net of + * unbilled usage) reached zero; credit included with a subscription may remain. + * + *

Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonAutoDetect( + getterVisibility = Visibility.NONE, + isGetterVisibility = Visibility.NONE, + setterVisibility = Visibility.NONE) +public final class WalletDepletedEventData { + @JsonProperty("credit_unit") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField creditUnit = JsonField.missing(); + + @JsonProperty("credit_unit_precision") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField creditUnitPrecision = JsonField.missing(); + + @JsonProperty("currency") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField currency = JsonField.missing(); + + @JsonProperty("customer_id") + private String customerId; + + private final Map additionalProperties = new LinkedHashMap<>(); + + private WalletDepletedEventData() {} + + private WalletDepletedEventData(Builder builder) { + this.creditUnit = builder.creditUnit; + this.creditUnitPrecision = builder.creditUnitPrecision; + this.currency = builder.currency; + this.customerId = builder.customerId; + this.additionalProperties.putAll(builder.additionalProperties); + } + + /** + * A builder of {@code WalletDepletedEventData}. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * A builder starting from this value. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.creditUnit = creditUnit; + builder.creditUnitPrecision = creditUnitPrecision; + builder.currency = currency; + builder.customerId = customerId; + builder.additionalProperties.putAll(additionalProperties); + return builder; + } + + /** + * The credit unit (its code) the amounts are in; absent for a currency. + * + * @return the value, empty when unset or null + */ + public Optional creditUnit() { + return creditUnit.asOptional(); + } + + /** + * Decimal places of credit_unit: amounts are integers of 10^-precision credit. + * + * @return the value, empty when unset or null + */ + public Optional creditUnitPrecision() { + return creditUnitPrecision.asOptional(); + } + + /** + * Absent when the amounts are in a credit unit. + * + * @return the value, empty when unset or null + */ + public Optional currency() { + return currency.asOptional(); + } + + /** + * The {@code customer_id} property. + * + * @return the value, never null + */ + public String customerId() { + return Utils.required(customerId, "customer_id"); + } + + /** + * Properties this version of the SDK does not know, kept as received and sent back. + * + * @return the properties by name, unmodifiable + */ + public Map additionalProperties() { + return Collections.unmodifiableMap(additionalProperties); + } + + @JsonAnyGetter + private Map anyProperties() { + return additionalProperties; + } + + @JsonAnySetter + private void putAnyProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + WalletDepletedEventData that = (WalletDepletedEventData) o; + return Objects.equals(creditUnit, that.creditUnit) + && Objects.equals(creditUnitPrecision, that.creditUnitPrecision) + && Objects.equals(currency, that.currency) + && Objects.equals(customerId, that.customerId) + && Objects.equals(additionalProperties, that.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash( + creditUnit, creditUnitPrecision, currency, customerId, additionalProperties); + } + + @Override + public String toString() { + return "WalletDepletedEventData{" + + "creditUnit=" + + creditUnit + + ", creditUnitPrecision=" + + creditUnitPrecision + + ", currency=" + + currency + + ", customerId=" + + customerId + + ", additionalProperties=" + + additionalProperties + + "}"; + } + + /** Builds {@link WalletDepletedEventData}. */ + public static final class Builder { + private JsonField creditUnit = JsonField.missing(); + private JsonField creditUnitPrecision = JsonField.missing(); + private JsonField currency = JsonField.missing(); + private String customerId; + private final Map additionalProperties = new LinkedHashMap<>(); + + private Builder() {} + + /** + * The credit unit (its code) the amounts are in; absent for a currency. + * + * @param creditUnit the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder creditUnit(String creditUnit) { + this.creditUnit = JsonField.ofNullable(creditUnit); + return this; + } + + /** + * Decimal places of credit_unit: amounts are integers of 10^-precision credit. + * + * @param creditUnitPrecision the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder creditUnitPrecision(Integer creditUnitPrecision) { + this.creditUnitPrecision = JsonField.ofNullable(creditUnitPrecision); + return this; + } + + /** + * Absent when the amounts are in a credit unit. + * + * @param currency the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder currency(String currency) { + this.currency = JsonField.ofNullable(currency); + return this; + } + + /** + * The {@code customer_id} property. + * + * @param customerId the value + * @return this builder + */ + public Builder customerId(String customerId) { + this.customerId = customerId; + return this; + } + + /** + * A property the SDK does not know, sent along. + * + * @param name the property name + * @param value the JSON value + * @return this builder + */ + public Builder putAdditionalProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + return this; + } + + /** + * Properties the SDK does not know, sent along. + * + * @param additionalProperties the properties by name + * @return this builder + */ + public Builder putAllAdditionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + + /** + * Leaves out a property the SDK does not know. + * + * @param name the property name + * @return this builder + */ + public Builder removeAdditionalProperty(String name) { + additionalProperties.remove(name); + return this; + } + + /** + * The {@code WalletDepletedEventData}. + * + * @return the immutable value + * @throws IllegalStateException when a required property is not set + */ + public WalletDepletedEventData build() { + Utils.checkRequired(customerId, "customer_id"); + return new WalletDepletedEventData(this); + } + } + + /** + * Parse {@code json} as {@code WalletDepletedEventData}. + * + * @param json the JSON text + * @return the value + * @throws com.meteroid.exceptions.InvalidDataException if it is not valid JSON of this shape + */ + public static WalletDepletedEventData fromJson(String json) { + return Utils.parse(json, WalletDepletedEventData.class); + } + + /** + * This value as JSON. + * + * @return the JSON text + */ + public String toJson() { + return Utils.json(this); + } +} diff --git a/src/main/java/com/meteroid/models/WalletFundedEvent.java b/src/main/java/com/meteroid/models/WalletFundedEvent.java new file mode 100644 index 0000000..b4f0992 --- /dev/null +++ b/src/main/java/com/meteroid/models/WalletFundedEvent.java @@ -0,0 +1,283 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.Unions; +import com.meteroid.internal.Utils; + +import java.time.OffsetDateTime; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; + +/** Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonAutoDetect( + getterVisibility = Visibility.NONE, + isGetterVisibility = Visibility.NONE, + setterVisibility = Visibility.NONE) +public final class WalletFundedEvent { + @JsonProperty("id") + private String id; + + @JsonProperty("timestamp") + private OffsetDateTime timestamp; + + @JsonProperty("type") + private EventType type; + + private final Map additionalProperties = new LinkedHashMap<>(); + + private WalletFundedEvent() {} + + private WalletFundedEvent(Builder builder) { + this.id = builder.id; + this.timestamp = builder.timestamp; + this.type = builder.type; + this.additionalProperties.putAll(builder.additionalProperties); + } + + /** + * A builder of {@code WalletFundedEvent}. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * A builder starting from this value. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.id = id; + builder.timestamp = timestamp; + builder.type = type; + builder.additionalProperties.putAll(additionalProperties); + return builder; + } + + /** + * The properties of {@link WalletFundedEventData}, which this schema extends. + * + * @return the properties of this part + */ + public WalletFundedEventData walletFundedEventData() { + return Unions.convert(additionalProperties, WalletFundedEventData.class); + } + + /** + * The {@code id} property. + * + * @return the value, never null + */ + public String id() { + return Utils.required(id, "id"); + } + + /** + * The {@code timestamp} property. + * + * @return the value, never null + */ + public OffsetDateTime timestamp() { + return Utils.required(timestamp, "timestamp"); + } + + /** + * The {@code type} property. + * + * @return the value, never null + */ + public EventType type() { + return Utils.required(type, "type"); + } + + /** + * Properties this version of the SDK does not know, kept as received and sent back. + * + * @return the properties by name, unmodifiable + */ + public Map additionalProperties() { + Map unknown = new LinkedHashMap<>(additionalProperties); + unknown.keySet().retainAll(walletFundedEventData().additionalProperties().keySet()); + return Collections.unmodifiableMap(unknown); + } + + @JsonAnyGetter + private Map anyProperties() { + return additionalProperties; + } + + @JsonAnySetter + private void putAnyProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + WalletFundedEvent that = (WalletFundedEvent) o; + return Objects.equals(id, that.id) + && Objects.equals(timestamp, that.timestamp) + && Objects.equals(type, that.type) + && Objects.equals(additionalProperties, that.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(id, timestamp, type, additionalProperties); + } + + @Override + public String toString() { + return "WalletFundedEvent{" + + "id=" + + id + + ", timestamp=" + + timestamp + + ", type=" + + type + + ", additionalProperties=" + + additionalProperties + + "}"; + } + + /** Builds {@link WalletFundedEvent}. */ + public static final class Builder { + private String id; + private OffsetDateTime timestamp; + private EventType type; + private final Map additionalProperties = new LinkedHashMap<>(); + + private Builder() {} + + /** + * Sets the properties of {@link WalletFundedEventData}, which this schema extends. + * + * @param walletFundedEventData the properties + * @return this builder + */ + public Builder walletFundedEventData(WalletFundedEventData walletFundedEventData) { + additionalProperties.putAll(Utils.properties(walletFundedEventData)); + return this; + } + + /** + * The {@code id} property. + * + * @param id the value + * @return this builder + */ + public Builder id(String id) { + this.id = id; + return this; + } + + /** + * The {@code timestamp} property. + * + * @param timestamp the value + * @return this builder + */ + public Builder timestamp(OffsetDateTime timestamp) { + this.timestamp = timestamp; + return this; + } + + /** + * The {@code type} property. + * + * @param type the value + * @return this builder + */ + public Builder type(EventType type) { + this.type = type; + return this; + } + + /** + * A property the SDK does not know, sent along. + * + * @param name the property name + * @param value the JSON value + * @return this builder + */ + public Builder putAdditionalProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + return this; + } + + /** + * Properties the SDK does not know, sent along. + * + * @param additionalProperties the properties by name + * @return this builder + */ + public Builder putAllAdditionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + + /** + * Leaves out a property the SDK does not know. + * + * @param name the property name + * @return this builder + */ + public Builder removeAdditionalProperty(String name) { + additionalProperties.remove(name); + return this; + } + + /** + * The {@code WalletFundedEvent}. + * + * @return the immutable value + * @throws IllegalStateException when a required property is not set + */ + public WalletFundedEvent build() { + Utils.checkRequired(id, "id"); + Utils.checkRequired(timestamp, "timestamp"); + Utils.checkRequired(type, "type"); + return new WalletFundedEvent(this); + } + } + + /** + * Parse {@code json} as {@code WalletFundedEvent}. + * + * @param json the JSON text + * @return the value + * @throws com.meteroid.exceptions.InvalidDataException if it is not valid JSON of this shape + */ + public static WalletFundedEvent fromJson(String json) { + return Utils.parse(json, WalletFundedEvent.class); + } + + /** + * This value as JSON. + * + * @return the JSON text + */ + public String toJson() { + return Utils.json(this); + } +} diff --git a/src/main/java/com/meteroid/models/WalletFundedEventData.java b/src/main/java/com/meteroid/models/WalletFundedEventData.java new file mode 100644 index 0000000..c512675 --- /dev/null +++ b/src/main/java/com/meteroid/models/WalletFundedEventData.java @@ -0,0 +1,628 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.JsonField; +import com.meteroid.internal.Utils; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +/** + * Credit entered a customer's wallet. + * + *

Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonAutoDetect( + getterVisibility = Visibility.NONE, + isGetterVisibility = Visibility.NONE, + setterVisibility = Visibility.NONE) +public final class WalletFundedEventData { + @JsonProperty("amount") + private Long amount; + + @JsonProperty("applicable_product_ids") + private List applicableProductIds; + + @JsonProperty("applies_to") + private CreditAppliesTo appliesTo; + + @JsonProperty("credit_grant_id") + private String creditGrantId; + + @JsonProperty("credit_note_id") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField creditNoteId = JsonField.missing(); + + @JsonProperty("credit_unit") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField creditUnit = JsonField.missing(); + + @JsonProperty("credit_unit_precision") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField creditUnitPrecision = JsonField.missing(); + + @JsonProperty("currency") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField currency = JsonField.missing(); + + @JsonProperty("customer_id") + private String customerId; + + @JsonProperty("grant_type") + private CreditGrantType grantType; + + @JsonProperty("invoice_id") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField invoiceId = JsonField.missing(); + + @JsonProperty("ledger_entry_id") + private String ledgerEntryId; + + @JsonProperty("source") + private CreditGrantSource source; + + @JsonProperty("subscription_id") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField subscriptionId = JsonField.missing(); + + private final Map additionalProperties = new LinkedHashMap<>(); + + private WalletFundedEventData() {} + + private WalletFundedEventData(Builder builder) { + this.amount = builder.amount; + this.applicableProductIds = Utils.copyList(builder.applicableProductIds); + this.appliesTo = builder.appliesTo; + this.creditGrantId = builder.creditGrantId; + this.creditNoteId = builder.creditNoteId; + this.creditUnit = builder.creditUnit; + this.creditUnitPrecision = builder.creditUnitPrecision; + this.currency = builder.currency; + this.customerId = builder.customerId; + this.grantType = builder.grantType; + this.invoiceId = builder.invoiceId; + this.ledgerEntryId = builder.ledgerEntryId; + this.source = builder.source; + this.subscriptionId = builder.subscriptionId; + this.additionalProperties.putAll(builder.additionalProperties); + } + + /** + * A builder of {@code WalletFundedEventData}. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * A builder starting from this value. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.amount = amount; + builder.applicableProductIds = Utils.mutableList(applicableProductIds); + builder.appliesTo = appliesTo; + builder.creditGrantId = creditGrantId; + builder.creditNoteId = creditNoteId; + builder.creditUnit = creditUnit; + builder.creditUnitPrecision = creditUnitPrecision; + builder.currency = currency; + builder.customerId = customerId; + builder.grantType = grantType; + builder.invoiceId = invoiceId; + builder.ledgerEntryId = ledgerEntryId; + builder.source = source; + builder.subscriptionId = subscriptionId; + builder.additionalProperties.putAll(additionalProperties); + return builder; + } + + /** + * In minor units of currency or credit_unit. + * + * @return the value, never null + */ + public Long amount() { + return Utils.required(amount, "amount"); + } + + /** + * The products whose charges the grant pays; empty when it pays every product. + * + * @return the value, never null + */ + public List applicableProductIds() { + return Utils.required(applicableProductIds, "applicable_product_ids"); + } + + /** + * What the grant pays: ALL any charge, USAGE only usage charges. + * + * @return the value, never null + */ + public CreditAppliesTo appliesTo() { + return Utils.required(appliesTo, "applies_to"); + } + + /** + * The grant the credit entered. + * + * @return the value, never null + */ + public String creditGrantId() { + return Utils.required(creditGrantId, "credit_grant_id"); + } + + /** + * The {@code credit_note_id} property. + * + * @return the value, empty when unset or null + */ + public Optional creditNoteId() { + return creditNoteId.asOptional(); + } + + /** + * The credit unit (its code) the amounts are in; absent for a currency. + * + * @return the value, empty when unset or null + */ + public Optional creditUnit() { + return creditUnit.asOptional(); + } + + /** + * Decimal places of credit_unit: amounts are integers of 10^-precision credit. + * + * @return the value, empty when unset or null + */ + public Optional creditUnitPrecision() { + return creditUnitPrecision.asOptional(); + } + + /** + * Absent when the amounts are in a credit unit. + * + * @return the value, empty when unset or null + */ + public Optional currency() { + return currency.asOptional(); + } + + /** + * The {@code customer_id} property. + * + * @return the value, never null + */ + public String customerId() { + return Utils.required(customerId, "customer_id"); + } + + /** + * PAID or PROMOTIONAL: whether the credit applies after or before tax. + * + * @return the value, never null + */ + public CreditGrantType grantType() { + return Utils.required(grantType, "grant_type"); + } + + /** + * The {@code invoice_id} property. + * + * @return the value, empty when unset or null + */ + public Optional invoiceId() { + return invoiceId.asOptional(); + } + + /** + * The credit ledger entry recording the movement. + * + * @return the value, never null + */ + public String ledgerEntryId() { + return Utils.required(ledgerEntryId, "ledger_entry_id"); + } + + /** + * Where the credit came from. + * + * @return the value, never null + */ + public CreditGrantSource source() { + return Utils.required(source, "source"); + } + + /** + * The subscription the grant belongs to: it pays only that subscription's charges. Null when it + * pays any of the customer's subscriptions. + * + * @return the value, empty when unset or null + */ + public Optional subscriptionId() { + return subscriptionId.asOptional(); + } + + /** + * Properties this version of the SDK does not know, kept as received and sent back. + * + * @return the properties by name, unmodifiable + */ + public Map additionalProperties() { + return Collections.unmodifiableMap(additionalProperties); + } + + @JsonAnyGetter + private Map anyProperties() { + return additionalProperties; + } + + @JsonAnySetter + private void putAnyProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + WalletFundedEventData that = (WalletFundedEventData) o; + return Objects.equals(amount, that.amount) + && Objects.equals(applicableProductIds, that.applicableProductIds) + && Objects.equals(appliesTo, that.appliesTo) + && Objects.equals(creditGrantId, that.creditGrantId) + && Objects.equals(creditNoteId, that.creditNoteId) + && Objects.equals(creditUnit, that.creditUnit) + && Objects.equals(creditUnitPrecision, that.creditUnitPrecision) + && Objects.equals(currency, that.currency) + && Objects.equals(customerId, that.customerId) + && Objects.equals(grantType, that.grantType) + && Objects.equals(invoiceId, that.invoiceId) + && Objects.equals(ledgerEntryId, that.ledgerEntryId) + && Objects.equals(source, that.source) + && Objects.equals(subscriptionId, that.subscriptionId) + && Objects.equals(additionalProperties, that.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash( + amount, + applicableProductIds, + appliesTo, + creditGrantId, + creditNoteId, + creditUnit, + creditUnitPrecision, + currency, + customerId, + grantType, + invoiceId, + ledgerEntryId, + source, + subscriptionId, + additionalProperties); + } + + @Override + public String toString() { + return "WalletFundedEventData{" + + "amount=" + + amount + + ", applicableProductIds=" + + applicableProductIds + + ", appliesTo=" + + appliesTo + + ", creditGrantId=" + + creditGrantId + + ", creditNoteId=" + + creditNoteId + + ", creditUnit=" + + creditUnit + + ", creditUnitPrecision=" + + creditUnitPrecision + + ", currency=" + + currency + + ", customerId=" + + customerId + + ", grantType=" + + grantType + + ", invoiceId=" + + invoiceId + + ", ledgerEntryId=" + + ledgerEntryId + + ", source=" + + source + + ", subscriptionId=" + + subscriptionId + + ", additionalProperties=" + + additionalProperties + + "}"; + } + + /** Builds {@link WalletFundedEventData}. */ + public static final class Builder { + private Long amount; + private List applicableProductIds; + private CreditAppliesTo appliesTo; + private String creditGrantId; + private JsonField creditNoteId = JsonField.missing(); + private JsonField creditUnit = JsonField.missing(); + private JsonField creditUnitPrecision = JsonField.missing(); + private JsonField currency = JsonField.missing(); + private String customerId; + private CreditGrantType grantType; + private JsonField invoiceId = JsonField.missing(); + private String ledgerEntryId; + private CreditGrantSource source; + private JsonField subscriptionId = JsonField.missing(); + private final Map additionalProperties = new LinkedHashMap<>(); + + private Builder() {} + + /** + * In minor units of currency or credit_unit. + * + * @param amount the value + * @return this builder + */ + public Builder amount(Long amount) { + this.amount = amount; + return this; + } + + /** + * The products whose charges the grant pays; empty when it pays every product. + * + * @param applicableProductIds the value + * @return this builder + */ + public Builder applicableProductIds(List applicableProductIds) { + this.applicableProductIds = Utils.mutableList(applicableProductIds); + return this; + } + + /** + * Adds an item to {@code applicable_product_ids}. + * + * @param item the item + * @return this builder + */ + public Builder addApplicableProductIdsItem(String item) { + if (this.applicableProductIds == null) { + this.applicableProductIds = new ArrayList<>(); + } + this.applicableProductIds.add(item); + return this; + } + + /** + * What the grant pays: ALL any charge, USAGE only usage charges. + * + * @param appliesTo the value + * @return this builder + */ + public Builder appliesTo(CreditAppliesTo appliesTo) { + this.appliesTo = appliesTo; + return this; + } + + /** + * The grant the credit entered. + * + * @param creditGrantId the value + * @return this builder + */ + public Builder creditGrantId(String creditGrantId) { + this.creditGrantId = creditGrantId; + return this; + } + + /** + * The {@code credit_note_id} property. + * + * @param creditNoteId the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder creditNoteId(String creditNoteId) { + this.creditNoteId = JsonField.ofNullable(creditNoteId); + return this; + } + + /** + * The credit unit (its code) the amounts are in; absent for a currency. + * + * @param creditUnit the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder creditUnit(String creditUnit) { + this.creditUnit = JsonField.ofNullable(creditUnit); + return this; + } + + /** + * Decimal places of credit_unit: amounts are integers of 10^-precision credit. + * + * @param creditUnitPrecision the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder creditUnitPrecision(Integer creditUnitPrecision) { + this.creditUnitPrecision = JsonField.ofNullable(creditUnitPrecision); + return this; + } + + /** + * Absent when the amounts are in a credit unit. + * + * @param currency the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder currency(String currency) { + this.currency = JsonField.ofNullable(currency); + return this; + } + + /** + * The {@code customer_id} property. + * + * @param customerId the value + * @return this builder + */ + public Builder customerId(String customerId) { + this.customerId = customerId; + return this; + } + + /** + * PAID or PROMOTIONAL: whether the credit applies after or before tax. + * + * @param grantType the value + * @return this builder + */ + public Builder grantType(CreditGrantType grantType) { + this.grantType = grantType; + return this; + } + + /** + * The {@code invoice_id} property. + * + * @param invoiceId the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder invoiceId(String invoiceId) { + this.invoiceId = JsonField.ofNullable(invoiceId); + return this; + } + + /** + * The credit ledger entry recording the movement. + * + * @param ledgerEntryId the value + * @return this builder + */ + public Builder ledgerEntryId(String ledgerEntryId) { + this.ledgerEntryId = ledgerEntryId; + return this; + } + + /** + * Where the credit came from. + * + * @param source the value + * @return this builder + */ + public Builder source(CreditGrantSource source) { + this.source = source; + return this; + } + + /** + * The subscription the grant belongs to: it pays only that subscription's charges. Null + * when it pays any of the customer's subscriptions. + * + * @param subscriptionId the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder subscriptionId(String subscriptionId) { + this.subscriptionId = JsonField.ofNullable(subscriptionId); + return this; + } + + /** + * A property the SDK does not know, sent along. + * + * @param name the property name + * @param value the JSON value + * @return this builder + */ + public Builder putAdditionalProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + return this; + } + + /** + * Properties the SDK does not know, sent along. + * + * @param additionalProperties the properties by name + * @return this builder + */ + public Builder putAllAdditionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + + /** + * Leaves out a property the SDK does not know. + * + * @param name the property name + * @return this builder + */ + public Builder removeAdditionalProperty(String name) { + additionalProperties.remove(name); + return this; + } + + /** + * The {@code WalletFundedEventData}. + * + * @return the immutable value + * @throws IllegalStateException when a required property is not set + */ + public WalletFundedEventData build() { + Utils.checkRequired(amount, "amount"); + Utils.checkRequired(applicableProductIds, "applicable_product_ids"); + Utils.checkRequired(appliesTo, "applies_to"); + Utils.checkRequired(creditGrantId, "credit_grant_id"); + Utils.checkRequired(customerId, "customer_id"); + Utils.checkRequired(grantType, "grant_type"); + Utils.checkRequired(ledgerEntryId, "ledger_entry_id"); + Utils.checkRequired(source, "source"); + return new WalletFundedEventData(this); + } + } + + /** + * Parse {@code json} as {@code WalletFundedEventData}. + * + * @param json the JSON text + * @return the value + * @throws com.meteroid.exceptions.InvalidDataException if it is not valid JSON of this shape + */ + public static WalletFundedEventData fromJson(String json) { + return Utils.parse(json, WalletFundedEventData.class); + } + + /** + * This value as JSON. + * + * @return the JSON text + */ + public String toJson() { + return Utils.json(this); + } +} diff --git a/src/main/java/com/meteroid/models/WalletListResponse.java b/src/main/java/com/meteroid/models/WalletListResponse.java new file mode 100644 index 0000000..a070ceb --- /dev/null +++ b/src/main/java/com/meteroid/models/WalletListResponse.java @@ -0,0 +1,219 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.Utils; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * A customer's wallets, the customer's own currency first. + * + *

Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonAutoDetect( + getterVisibility = Visibility.NONE, + isGetterVisibility = Visibility.NONE, + setterVisibility = Visibility.NONE) +public final class WalletListResponse { + @JsonProperty("data") + private List data; + + private final Map additionalProperties = new LinkedHashMap<>(); + + private WalletListResponse() {} + + private WalletListResponse(Builder builder) { + this.data = Utils.copyList(builder.data); + this.additionalProperties.putAll(builder.additionalProperties); + } + + /** + * A builder of {@code WalletListResponse}. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * A builder starting from this value. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.data = Utils.mutableList(data); + builder.additionalProperties.putAll(additionalProperties); + return builder; + } + + /** + * The {@code data} property. + * + * @return the value, never null + */ + public List data() { + return Utils.required(data, "data"); + } + + /** + * Properties this version of the SDK does not know, kept as received and sent back. + * + * @return the properties by name, unmodifiable + */ + public Map additionalProperties() { + return Collections.unmodifiableMap(additionalProperties); + } + + @JsonAnyGetter + private Map anyProperties() { + return additionalProperties; + } + + @JsonAnySetter + private void putAnyProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + WalletListResponse that = (WalletListResponse) o; + return Objects.equals(data, that.data) + && Objects.equals(additionalProperties, that.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(data, additionalProperties); + } + + @Override + public String toString() { + return "WalletListResponse{" + + "data=" + + data + + ", additionalProperties=" + + additionalProperties + + "}"; + } + + /** Builds {@link WalletListResponse}. */ + public static final class Builder { + private List data; + private final Map additionalProperties = new LinkedHashMap<>(); + + private Builder() {} + + /** + * The {@code data} property. + * + * @param data the value + * @return this builder + */ + public Builder data(List data) { + this.data = Utils.mutableList(data); + return this; + } + + /** + * Adds an item to {@code data}. + * + * @param item the item + * @return this builder + */ + public Builder addDataItem(Wallet item) { + if (this.data == null) { + this.data = new ArrayList<>(); + } + this.data.add(item); + return this; + } + + /** + * A property the SDK does not know, sent along. + * + * @param name the property name + * @param value the JSON value + * @return this builder + */ + public Builder putAdditionalProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + return this; + } + + /** + * Properties the SDK does not know, sent along. + * + * @param additionalProperties the properties by name + * @return this builder + */ + public Builder putAllAdditionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + + /** + * Leaves out a property the SDK does not know. + * + * @param name the property name + * @return this builder + */ + public Builder removeAdditionalProperty(String name) { + additionalProperties.remove(name); + return this; + } + + /** + * The {@code WalletListResponse}. + * + * @return the immutable value + * @throws IllegalStateException when a required property is not set + */ + public WalletListResponse build() { + Utils.checkRequired(data, "data"); + return new WalletListResponse(this); + } + } + + /** + * Parse {@code json} as {@code WalletListResponse}. + * + * @param json the JSON text + * @return the value + * @throws com.meteroid.exceptions.InvalidDataException if it is not valid JSON of this shape + */ + public static WalletListResponse fromJson(String json) { + return Utils.parse(json, WalletListResponse.class); + } + + /** + * This value as JSON. + * + * @return the JSON text + */ + public String toJson() { + return Utils.json(this); + } +} diff --git a/src/main/java/com/meteroid/models/WalletRecoveredEvent.java b/src/main/java/com/meteroid/models/WalletRecoveredEvent.java new file mode 100644 index 0000000..564ba13 --- /dev/null +++ b/src/main/java/com/meteroid/models/WalletRecoveredEvent.java @@ -0,0 +1,283 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.Unions; +import com.meteroid.internal.Utils; + +import java.time.OffsetDateTime; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; + +/** Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonAutoDetect( + getterVisibility = Visibility.NONE, + isGetterVisibility = Visibility.NONE, + setterVisibility = Visibility.NONE) +public final class WalletRecoveredEvent { + @JsonProperty("id") + private String id; + + @JsonProperty("timestamp") + private OffsetDateTime timestamp; + + @JsonProperty("type") + private EventType type; + + private final Map additionalProperties = new LinkedHashMap<>(); + + private WalletRecoveredEvent() {} + + private WalletRecoveredEvent(Builder builder) { + this.id = builder.id; + this.timestamp = builder.timestamp; + this.type = builder.type; + this.additionalProperties.putAll(builder.additionalProperties); + } + + /** + * A builder of {@code WalletRecoveredEvent}. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * A builder starting from this value. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.id = id; + builder.timestamp = timestamp; + builder.type = type; + builder.additionalProperties.putAll(additionalProperties); + return builder; + } + + /** + * The properties of {@link WalletRecoveredEventData}, which this schema extends. + * + * @return the properties of this part + */ + public WalletRecoveredEventData walletRecoveredEventData() { + return Unions.convert(additionalProperties, WalletRecoveredEventData.class); + } + + /** + * The {@code id} property. + * + * @return the value, never null + */ + public String id() { + return Utils.required(id, "id"); + } + + /** + * The {@code timestamp} property. + * + * @return the value, never null + */ + public OffsetDateTime timestamp() { + return Utils.required(timestamp, "timestamp"); + } + + /** + * The {@code type} property. + * + * @return the value, never null + */ + public EventType type() { + return Utils.required(type, "type"); + } + + /** + * Properties this version of the SDK does not know, kept as received and sent back. + * + * @return the properties by name, unmodifiable + */ + public Map additionalProperties() { + Map unknown = new LinkedHashMap<>(additionalProperties); + unknown.keySet().retainAll(walletRecoveredEventData().additionalProperties().keySet()); + return Collections.unmodifiableMap(unknown); + } + + @JsonAnyGetter + private Map anyProperties() { + return additionalProperties; + } + + @JsonAnySetter + private void putAnyProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + WalletRecoveredEvent that = (WalletRecoveredEvent) o; + return Objects.equals(id, that.id) + && Objects.equals(timestamp, that.timestamp) + && Objects.equals(type, that.type) + && Objects.equals(additionalProperties, that.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(id, timestamp, type, additionalProperties); + } + + @Override + public String toString() { + return "WalletRecoveredEvent{" + + "id=" + + id + + ", timestamp=" + + timestamp + + ", type=" + + type + + ", additionalProperties=" + + additionalProperties + + "}"; + } + + /** Builds {@link WalletRecoveredEvent}. */ + public static final class Builder { + private String id; + private OffsetDateTime timestamp; + private EventType type; + private final Map additionalProperties = new LinkedHashMap<>(); + + private Builder() {} + + /** + * Sets the properties of {@link WalletRecoveredEventData}, which this schema extends. + * + * @param walletRecoveredEventData the properties + * @return this builder + */ + public Builder walletRecoveredEventData(WalletRecoveredEventData walletRecoveredEventData) { + additionalProperties.putAll(Utils.properties(walletRecoveredEventData)); + return this; + } + + /** + * The {@code id} property. + * + * @param id the value + * @return this builder + */ + public Builder id(String id) { + this.id = id; + return this; + } + + /** + * The {@code timestamp} property. + * + * @param timestamp the value + * @return this builder + */ + public Builder timestamp(OffsetDateTime timestamp) { + this.timestamp = timestamp; + return this; + } + + /** + * The {@code type} property. + * + * @param type the value + * @return this builder + */ + public Builder type(EventType type) { + this.type = type; + return this; + } + + /** + * A property the SDK does not know, sent along. + * + * @param name the property name + * @param value the JSON value + * @return this builder + */ + public Builder putAdditionalProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + return this; + } + + /** + * Properties the SDK does not know, sent along. + * + * @param additionalProperties the properties by name + * @return this builder + */ + public Builder putAllAdditionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + + /** + * Leaves out a property the SDK does not know. + * + * @param name the property name + * @return this builder + */ + public Builder removeAdditionalProperty(String name) { + additionalProperties.remove(name); + return this; + } + + /** + * The {@code WalletRecoveredEvent}. + * + * @return the immutable value + * @throws IllegalStateException when a required property is not set + */ + public WalletRecoveredEvent build() { + Utils.checkRequired(id, "id"); + Utils.checkRequired(timestamp, "timestamp"); + Utils.checkRequired(type, "type"); + return new WalletRecoveredEvent(this); + } + } + + /** + * Parse {@code json} as {@code WalletRecoveredEvent}. + * + * @param json the JSON text + * @return the value + * @throws com.meteroid.exceptions.InvalidDataException if it is not valid JSON of this shape + */ + public static WalletRecoveredEvent fromJson(String json) { + return Utils.parse(json, WalletRecoveredEvent.class); + } + + /** + * This value as JSON. + * + * @return the JSON text + */ + public String toJson() { + return Utils.json(this); + } +} diff --git a/src/main/java/com/meteroid/models/WalletRecoveredEventData.java b/src/main/java/com/meteroid/models/WalletRecoveredEventData.java new file mode 100644 index 0000000..503f7fe --- /dev/null +++ b/src/main/java/com/meteroid/models/WalletRecoveredEventData.java @@ -0,0 +1,334 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.JsonField; +import com.meteroid.internal.Utils; + +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +/** + * A wallet's balance (credit that pays any charge of any of the customer's subscriptions, net of + * unbilled usage) came back above zero. + * + *

Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonAutoDetect( + getterVisibility = Visibility.NONE, + isGetterVisibility = Visibility.NONE, + setterVisibility = Visibility.NONE) +public final class WalletRecoveredEventData { + @JsonProperty("balance") + private Long balance; + + @JsonProperty("credit_unit") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField creditUnit = JsonField.missing(); + + @JsonProperty("credit_unit_precision") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField creditUnitPrecision = JsonField.missing(); + + @JsonProperty("currency") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField currency = JsonField.missing(); + + @JsonProperty("customer_id") + private String customerId; + + private final Map additionalProperties = new LinkedHashMap<>(); + + private WalletRecoveredEventData() {} + + private WalletRecoveredEventData(Builder builder) { + this.balance = builder.balance; + this.creditUnit = builder.creditUnit; + this.creditUnitPrecision = builder.creditUnitPrecision; + this.currency = builder.currency; + this.customerId = builder.customerId; + this.additionalProperties.putAll(builder.additionalProperties); + } + + /** + * A builder of {@code WalletRecoveredEventData}. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * A builder starting from this value. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.balance = balance; + builder.creditUnit = creditUnit; + builder.creditUnitPrecision = creditUnitPrecision; + builder.currency = currency; + builder.customerId = customerId; + builder.additionalProperties.putAll(additionalProperties); + return builder; + } + + /** + * The balance (credit on account that pays any charge of any of the customer's subscriptions, + * net of unbilled usage) now that it is back above zero, in minor units. + * + * @return the value, never null + */ + public Long balance() { + return Utils.required(balance, "balance"); + } + + /** + * The credit unit (its code) the amounts are in; absent for a currency. + * + * @return the value, empty when unset or null + */ + public Optional creditUnit() { + return creditUnit.asOptional(); + } + + /** + * Decimal places of credit_unit: amounts are integers of 10^-precision credit. + * + * @return the value, empty when unset or null + */ + public Optional creditUnitPrecision() { + return creditUnitPrecision.asOptional(); + } + + /** + * Absent when the amounts are in a credit unit. + * + * @return the value, empty when unset or null + */ + public Optional currency() { + return currency.asOptional(); + } + + /** + * The {@code customer_id} property. + * + * @return the value, never null + */ + public String customerId() { + return Utils.required(customerId, "customer_id"); + } + + /** + * Properties this version of the SDK does not know, kept as received and sent back. + * + * @return the properties by name, unmodifiable + */ + public Map additionalProperties() { + return Collections.unmodifiableMap(additionalProperties); + } + + @JsonAnyGetter + private Map anyProperties() { + return additionalProperties; + } + + @JsonAnySetter + private void putAnyProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + WalletRecoveredEventData that = (WalletRecoveredEventData) o; + return Objects.equals(balance, that.balance) + && Objects.equals(creditUnit, that.creditUnit) + && Objects.equals(creditUnitPrecision, that.creditUnitPrecision) + && Objects.equals(currency, that.currency) + && Objects.equals(customerId, that.customerId) + && Objects.equals(additionalProperties, that.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash( + balance, + creditUnit, + creditUnitPrecision, + currency, + customerId, + additionalProperties); + } + + @Override + public String toString() { + return "WalletRecoveredEventData{" + + "balance=" + + balance + + ", creditUnit=" + + creditUnit + + ", creditUnitPrecision=" + + creditUnitPrecision + + ", currency=" + + currency + + ", customerId=" + + customerId + + ", additionalProperties=" + + additionalProperties + + "}"; + } + + /** Builds {@link WalletRecoveredEventData}. */ + public static final class Builder { + private Long balance; + private JsonField creditUnit = JsonField.missing(); + private JsonField creditUnitPrecision = JsonField.missing(); + private JsonField currency = JsonField.missing(); + private String customerId; + private final Map additionalProperties = new LinkedHashMap<>(); + + private Builder() {} + + /** + * The balance (credit on account that pays any charge of any of the customer's + * subscriptions, net of unbilled usage) now that it is back above zero, in minor units. + * + * @param balance the value + * @return this builder + */ + public Builder balance(Long balance) { + this.balance = balance; + return this; + } + + /** + * The credit unit (its code) the amounts are in; absent for a currency. + * + * @param creditUnit the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder creditUnit(String creditUnit) { + this.creditUnit = JsonField.ofNullable(creditUnit); + return this; + } + + /** + * Decimal places of credit_unit: amounts are integers of 10^-precision credit. + * + * @param creditUnitPrecision the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder creditUnitPrecision(Integer creditUnitPrecision) { + this.creditUnitPrecision = JsonField.ofNullable(creditUnitPrecision); + return this; + } + + /** + * Absent when the amounts are in a credit unit. + * + * @param currency the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder currency(String currency) { + this.currency = JsonField.ofNullable(currency); + return this; + } + + /** + * The {@code customer_id} property. + * + * @param customerId the value + * @return this builder + */ + public Builder customerId(String customerId) { + this.customerId = customerId; + return this; + } + + /** + * A property the SDK does not know, sent along. + * + * @param name the property name + * @param value the JSON value + * @return this builder + */ + public Builder putAdditionalProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + return this; + } + + /** + * Properties the SDK does not know, sent along. + * + * @param additionalProperties the properties by name + * @return this builder + */ + public Builder putAllAdditionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + + /** + * Leaves out a property the SDK does not know. + * + * @param name the property name + * @return this builder + */ + public Builder removeAdditionalProperty(String name) { + additionalProperties.remove(name); + return this; + } + + /** + * The {@code WalletRecoveredEventData}. + * + * @return the immutable value + * @throws IllegalStateException when a required property is not set + */ + public WalletRecoveredEventData build() { + Utils.checkRequired(balance, "balance"); + Utils.checkRequired(customerId, "customer_id"); + return new WalletRecoveredEventData(this); + } + } + + /** + * Parse {@code json} as {@code WalletRecoveredEventData}. + * + * @param json the JSON text + * @return the value + * @throws com.meteroid.exceptions.InvalidDataException if it is not valid JSON of this shape + */ + public static WalletRecoveredEventData fromJson(String json) { + return Utils.parse(json, WalletRecoveredEventData.class); + } + + /** + * This value as JSON. + * + * @return the JSON text + */ + public String toJson() { + return Utils.json(this); + } +} diff --git a/src/main/java/com/meteroid/models/WebhookEndpoint.java b/src/main/java/com/meteroid/models/WebhookEndpoint.java index fea34c2..3ec8182 100644 --- a/src/main/java/com/meteroid/models/WebhookEndpoint.java +++ b/src/main/java/com/meteroid/models/WebhookEndpoint.java @@ -194,7 +194,8 @@ public Optional disabledReason() { } /** - * Subscribed event types. Empty means every event type. + * Subscribed event types. Empty means every event type except Beta ones, which are sent only to + * endpoints that list them. * * @return the value, never null */ @@ -481,7 +482,8 @@ public Builder disabledReason(WebhookEndpointDisabledReason disabledReason) { } /** - * Subscribed event types. Empty means every event type. + * Subscribed event types. Empty means every event type except Beta ones, which are sent + * only to endpoints that list them. * * @param eventTypes the value * @return this builder diff --git a/src/test/java/com/meteroid/api/BudgetsTest.java b/src/test/java/com/meteroid/api/BudgetsTest.java new file mode 100644 index 0000000..cf08da3 --- /dev/null +++ b/src/test/java/com/meteroid/api/BudgetsTest.java @@ -0,0 +1,22 @@ +// this file is @generated +package com.meteroid.api; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.junit.jupiter.api.Test; + +import java.util.List; + +class BudgetsTest { + + @Test + void list() throws Exception { + PerseidMock mock = + new PerseidMock( + 200, + "application/json", + "{\"data\":[{\"amount\":-9007199254740993,\"behavior\":\"SOFT\",\"created_at\":\"2023-12-31T23:59:59.999-05:30\",\"created_by\":\"TENANT\",\"exact\":false,\"id\":\"sample\",\"thresholds\":[-123456789],\"updated_at\":\"2024-03-15T10:30:45.123+02:00\",\"version\":123456789}],\"pagination_meta\":{\"page\":-123456789,\"per_page\":-123456789,\"total_items\":-9007199254740993,\"total_pages\":123456789}}"); + mock.client.budgets().list("id_or_alias"); + assertEquals(List.of("GET /api/v1/customers/id_or_alias/budgets"), mock.requests); + } +} diff --git a/src/test/java/com/meteroid/api/ChecksTest.java b/src/test/java/com/meteroid/api/ChecksTest.java new file mode 100644 index 0000000..3305cd5 --- /dev/null +++ b/src/test/java/com/meteroid/api/ChecksTest.java @@ -0,0 +1,24 @@ +// this file is @generated +package com.meteroid.api; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.junit.jupiter.api.Test; + +import java.util.List; + +class ChecksTest { + + @Test + void checkEntitlement() throws Exception { + PerseidMock mock = + new PerseidMock( + 200, + "application/json", + "{\"as_of\":\"2023-12-31T23:59:59.999-05:30\",\"exact\":true,\"feature\":{\"code\":\"sample\",\"id\":\"feature_id_19\"},\"has_access\":true,\"in_overage\":false,\"lag_ms\":9007199254740993,\"limits\":[{\"behavior\":\"HARD\",\"has_access\":false,\"limit\":\"-0.000123\",\"remaining\":\"12345.6789\",\"usage_limit_id\":\"usage_limit_id_23\",\"used\":\"12345.6789\"}],\"near_limit\":false,\"reason\":\"INSUFFICIENT_BALANCE\"}"); + mock.client.checks().checkEntitlement("id_or_alias", "feature_id_or_code"); + assertEquals( + List.of("GET /api/v1/customers/id_or_alias/entitlements/feature_id_or_code/check"), + mock.requests); + } +} diff --git a/src/test/java/com/meteroid/api/ConnectTest.java b/src/test/java/com/meteroid/api/ConnectTest.java index 7ec40de..f186967 100644 --- a/src/test/java/com/meteroid/api/ConnectTest.java +++ b/src/test/java/com/meteroid/api/ConnectTest.java @@ -26,13 +26,13 @@ void createConnectedAccount() throws Exception { new PerseidMock( 200, "application/json", - "{\"connection_type\":\"express\",\"created_at\":\"2024-03-15T10:30:45.123+02:00\",\"id\":\"connected_account_id_47\",\"onboarding_mode\":\"express\",\"platform_organization_id\":\"organization_id_83\",\"status\":\"active\"}"); + "{\"connection_type\":\"standard\",\"created_at\":\"2024-03-15T10:30:45.123+02:00\",\"id\":\"connected_account_id_67\",\"onboarding_mode\":\"full\",\"platform_organization_id\":\"organization_id_23\",\"status\":\"active\",\"onboarding_link\":{\"expires_at\":\"2023-12-31T23:59:59.999-05:30\",\"url\":\"sample\"}}"); mock.client .connect() .createConnectedAccount( PerseidMock.decode( com.meteroid.models.CreateConnectedAccountRequest.class, - "{\"connected_organization_id\":\"00000000-0000-0000-0000-000000000000\"}")); + "{\"email\":\"alice@example.com\",\"organization_name\":\"sample\"}")); assertEquals(List.of("POST /api/v1/connected-accounts"), mock.requests); } diff --git a/src/test/java/com/meteroid/api/CreditNotesTest.java b/src/test/java/com/meteroid/api/CreditNotesTest.java index f585766..b72b3ba 100644 --- a/src/test/java/com/meteroid/api/CreditNotesTest.java +++ b/src/test/java/com/meteroid/api/CreditNotesTest.java @@ -15,7 +15,7 @@ void list() throws Exception { new PerseidMock( 200, "application/json", - "{\"data\":[{\"created_at\":\"2023-12-31T23:59:59.999-05:30\",\"credit_note_number\":\"sample\",\"credit_type\":\"DEBT_CANCELLATION\",\"credited_amount_cents\":9007199254740993,\"currency\":\"TMT\",\"custom_properties\":{\"key\":\"value\",\"count\":3,\"ratio\":0.5,\"flags\":[true,false],\"nested\":{\"ok\":true}},\"customer_id\":\"customer_id_78\",\"id\":\"credit_note_id_47\",\"invoice_id\":\"invoice_id_67\",\"invoice_number\":\"sample\",\"line_items\":[{\"amount_total\":-9007199254740993,\"end_date\":\"2024-02-29\",\"name\":\"sample\",\"start_date\":\"2024-02-29\",\"sub_line_items\":[{\"id\":\"sample\",\"name\":\"sample\",\"quantity\":\"12345.6789\",\"total\":9007199254740993,\"unit_price\":\"12345.6789\"}],\"tax_rate\":\"12345.6789\"}],\"refunded_amount_cents\":9007199254740993,\"status\":\"DRAFT\",\"subtotal\":-9007199254740993,\"tax_amount\":9007199254740993,\"tax_breakdown\":[{\"name\":\"sample\",\"tax_amount\":-9007199254740993,\"tax_rate\":\"-0.000123\",\"taxable_amount\":-9007199254740993}],\"total\":-9007199254740993}],\"pagination_meta\":{\"page\":-123456789,\"per_page\":-123456789,\"total_items\":-9007199254740993,\"total_pages\":123456789}}"); + "{\"data\":[{\"created_at\":\"2023-12-31T23:59:59.999-05:30\",\"credit_note_number\":\"sample\",\"credit_type\":\"DEBT_CANCELLATION\",\"credited_amount_cents\":9007199254740993,\"currency\":\"TMT\",\"custom_properties\":{\"key\":\"value\",\"count\":3,\"ratio\":0.5,\"flags\":[true,false],\"nested\":{\"ok\":true}},\"customer_id\":\"customer_id_78\",\"id\":\"credit_note_id_47\",\"invoice_id\":\"invoice_id_67\",\"invoice_number\":\"sample\",\"line_items\":[{\"amount_total\":-9007199254740993,\"end_date\":\"2024-02-29\",\"name\":\"sample\",\"start_date\":\"1999-12-31\",\"sub_line_items\":[{\"id\":\"sample\",\"name\":\"sample\",\"quantity\":\"-0.000123\",\"total\":9007199254740993,\"unit_price\":\"12345.6789\"}],\"tax_rate\":\"-0.000123\"}],\"refunded_amount_cents\":9007199254740993,\"status\":\"DRAFT\",\"subtotal\":-9007199254740993,\"tax_amount\":9007199254740993,\"tax_breakdown\":[{\"name\":\"sample\",\"tax_amount\":-9007199254740993,\"tax_rate\":\"-0.000123\",\"taxable_amount\":-9007199254740993}],\"total\":-9007199254740993}],\"pagination_meta\":{\"page\":-123456789,\"per_page\":-123456789,\"total_items\":-9007199254740993,\"total_pages\":123456789}}"); mock.client.creditNotes().list(); assertEquals(List.of("GET /api/v1/credit-notes"), mock.requests); } @@ -26,7 +26,7 @@ void retrieve() throws Exception { new PerseidMock( 200, "application/json", - "{\"created_at\":\"2023-12-31T23:59:59.999-05:30\",\"credit_note_number\":\"sample\",\"credit_type\":\"REFUND\",\"credited_amount_cents\":9007199254740993,\"currency\":\"MMK\",\"custom_properties\":{\"key\":\"value\",\"count\":3,\"ratio\":0.5,\"flags\":[true,false],\"nested\":{\"ok\":true}},\"customer_id\":\"customer_id_13\",\"id\":\"credit_note_id_99\",\"invoice_id\":\"invoice_id_90\",\"invoice_number\":\"sample\",\"line_items\":[{\"amount_total\":-9007199254740993,\"end_date\":\"2024-02-29\",\"name\":\"sample\",\"start_date\":\"1999-12-31\",\"sub_line_items\":[{\"id\":\"sample\",\"name\":\"sample\",\"quantity\":\"12345.6789\",\"total\":9007199254740993,\"unit_price\":\"-0.000123\"}],\"tax_rate\":\"12345.6789\"}],\"refunded_amount_cents\":-9007199254740993,\"status\":\"DRAFT\",\"subtotal\":9007199254740993,\"tax_amount\":9007199254740993,\"tax_breakdown\":[{\"name\":\"sample\",\"tax_amount\":9007199254740993,\"tax_rate\":\"12345.6789\",\"taxable_amount\":9007199254740993}],\"total\":-9007199254740993}"); + "{\"created_at\":\"2023-12-31T23:59:59.999-05:30\",\"credit_note_number\":\"sample\",\"credit_type\":\"REFUND\",\"credited_amount_cents\":9007199254740993,\"currency\":\"MMK\",\"custom_properties\":{\"key\":\"value\",\"count\":3,\"ratio\":0.5,\"flags\":[true,false],\"nested\":{\"ok\":true}},\"customer_id\":\"customer_id_13\",\"id\":\"credit_note_id_99\",\"invoice_id\":\"invoice_id_90\",\"invoice_number\":\"sample\",\"line_items\":[{\"amount_total\":-9007199254740993,\"end_date\":\"2024-02-29\",\"name\":\"sample\",\"start_date\":\"1999-12-31\",\"sub_line_items\":[{\"id\":\"sample\",\"name\":\"sample\",\"quantity\":\"-0.000123\",\"total\":9007199254740993,\"unit_price\":\"12345.6789\"}],\"tax_rate\":\"12345.6789\"}],\"refunded_amount_cents\":-9007199254740993,\"status\":\"DRAFT\",\"subtotal\":9007199254740993,\"tax_amount\":9007199254740993,\"tax_breakdown\":[{\"name\":\"sample\",\"tax_amount\":9007199254740993,\"tax_rate\":\"12345.6789\",\"taxable_amount\":9007199254740993}],\"total\":-9007199254740993}"); mock.client.creditNotes().retrieve("credit_note_id"); assertEquals(List.of("GET /api/v1/credit-notes/credit_note_id"), mock.requests); } @@ -37,7 +37,7 @@ void updateCustomProperties() throws Exception { new PerseidMock( 200, "application/json", - "{\"created_at\":\"2023-12-31T23:59:59.999-05:30\",\"credit_note_number\":\"sample\",\"credit_type\":\"REFUND\",\"credited_amount_cents\":9007199254740993,\"currency\":\"MMK\",\"custom_properties\":{\"key\":\"value\",\"count\":3,\"ratio\":0.5,\"flags\":[true,false],\"nested\":{\"ok\":true}},\"customer_id\":\"customer_id_13\",\"id\":\"credit_note_id_99\",\"invoice_id\":\"invoice_id_90\",\"invoice_number\":\"sample\",\"line_items\":[{\"amount_total\":-9007199254740993,\"end_date\":\"2024-02-29\",\"name\":\"sample\",\"start_date\":\"1999-12-31\",\"sub_line_items\":[{\"id\":\"sample\",\"name\":\"sample\",\"quantity\":\"12345.6789\",\"total\":9007199254740993,\"unit_price\":\"-0.000123\"}],\"tax_rate\":\"12345.6789\"}],\"refunded_amount_cents\":-9007199254740993,\"status\":\"DRAFT\",\"subtotal\":9007199254740993,\"tax_amount\":9007199254740993,\"tax_breakdown\":[{\"name\":\"sample\",\"tax_amount\":9007199254740993,\"tax_rate\":\"12345.6789\",\"taxable_amount\":9007199254740993}],\"total\":-9007199254740993}"); + "{\"created_at\":\"2023-12-31T23:59:59.999-05:30\",\"credit_note_number\":\"sample\",\"credit_type\":\"REFUND\",\"credited_amount_cents\":9007199254740993,\"currency\":\"MMK\",\"custom_properties\":{\"key\":\"value\",\"count\":3,\"ratio\":0.5,\"flags\":[true,false],\"nested\":{\"ok\":true}},\"customer_id\":\"customer_id_13\",\"id\":\"credit_note_id_99\",\"invoice_id\":\"invoice_id_90\",\"invoice_number\":\"sample\",\"line_items\":[{\"amount_total\":-9007199254740993,\"end_date\":\"2024-02-29\",\"name\":\"sample\",\"start_date\":\"1999-12-31\",\"sub_line_items\":[{\"id\":\"sample\",\"name\":\"sample\",\"quantity\":\"-0.000123\",\"total\":9007199254740993,\"unit_price\":\"12345.6789\"}],\"tax_rate\":\"12345.6789\"}],\"refunded_amount_cents\":-9007199254740993,\"status\":\"DRAFT\",\"subtotal\":9007199254740993,\"tax_amount\":9007199254740993,\"tax_breakdown\":[{\"name\":\"sample\",\"tax_amount\":9007199254740993,\"tax_rate\":\"12345.6789\",\"taxable_amount\":9007199254740993}],\"total\":-9007199254740993}"); mock.client .creditNotes() .updateCustomProperties( diff --git a/src/test/java/com/meteroid/api/CreditUnitsPricesTest.java b/src/test/java/com/meteroid/api/CreditUnitsPricesTest.java new file mode 100644 index 0000000..1685725 --- /dev/null +++ b/src/test/java/com/meteroid/api/CreditUnitsPricesTest.java @@ -0,0 +1,52 @@ +// this file is @generated +package com.meteroid.api; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.junit.jupiter.api.Test; + +import java.util.List; + +class CreditUnitsPricesTest { + + @Test + void list() throws Exception { + PerseidMock mock = + new PerseidMock( + 200, + "application/json", + "{\"data\":[{\"created_at\":\"2023-12-31T23:59:59.999-05:30\",\"currency\":\"sample\",\"id\":\"sample\",\"unit_price\":\"sample\"}]}"); + mock.client.creditUnits().prices().list("id"); + assertEquals(List.of("GET /api/v1/credit-units/id/prices"), mock.requests); + } + + @Test + void update() throws Exception { + PerseidMock mock = + new PerseidMock( + 200, + "application/json", + "{\"created_at\":\"2024-03-15T10:30:45.123+02:00\",\"currency\":\"sample\",\"id\":\"sample\",\"unit_price\":\"sample\"}"); + mock.client + .creditUnits() + .prices() + .update( + "id", + "currency", + PerseidMock.decode( + com.meteroid.models.CreditUnitPriceSetRequest.class, + "{\"unit_price\":\"sample\"}")); + assertEquals(List.of("PUT /api/v1/credit-units/id/prices/currency"), mock.requests); + } + + @Test + void archive() throws Exception { + PerseidMock mock = + new PerseidMock( + 200, + "application/json", + "{\"created_at\":\"2024-03-15T10:30:45.123+02:00\",\"currency\":\"sample\",\"id\":\"sample\",\"unit_price\":\"sample\"}"); + mock.client.creditUnits().prices().archive("id", "currency"); + assertEquals(List.of("DELETE /api/v1/credit-units/id/prices/currency"), mock.requests); + } +} diff --git a/src/test/java/com/meteroid/api/CreditUnitsTest.java b/src/test/java/com/meteroid/api/CreditUnitsTest.java new file mode 100644 index 0000000..fc63e82 --- /dev/null +++ b/src/test/java/com/meteroid/api/CreditUnitsTest.java @@ -0,0 +1,65 @@ +// this file is @generated +package com.meteroid.api; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.junit.jupiter.api.Test; + +import java.util.List; + +class CreditUnitsTest { + + @Test + void list() throws Exception { + PerseidMock mock = + new PerseidMock( + 200, + "application/json", + "{\"data\":[{\"archived\":false,\"code\":\"sample\",\"id\":\"sample\",\"name\":\"sample\",\"plural_name\":\"sample\",\"precision\":123456789,\"prices\":[{\"created_at\":\"2023-12-31T23:59:59.999-05:30\",\"currency\":\"sample\",\"id\":\"sample\",\"unit_price\":\"sample\"}]}]}"); + mock.client.creditUnits().list(); + assertEquals(List.of("GET /api/v1/credit-units"), mock.requests); + } + + @Test + void create() throws Exception { + PerseidMock mock = + new PerseidMock( + 200, + "application/json", + "{\"archived\":false,\"code\":\"sample\",\"id\":\"sample\",\"name\":\"sample\",\"plural_name\":\"sample\",\"precision\":2147483647,\"prices\":[{\"created_at\":\"2024-03-15T10:30:45.123+02:00\",\"currency\":\"sample\",\"id\":\"sample\",\"unit_price\":\"sample\"}]}"); + mock.client + .creditUnits() + .create( + PerseidMock.decode( + com.meteroid.models.CreditUnitCreateRequest.class, + "{\"code\":\"sample\",\"name\":\"sample\",\"plural_name\":\"sample\",\"precision\":123456789}")); + assertEquals(List.of("POST /api/v1/credit-units"), mock.requests); + } + + @Test + void retrieve() throws Exception { + PerseidMock mock = + new PerseidMock( + 200, + "application/json", + "{\"archived\":false,\"code\":\"sample\",\"id\":\"sample\",\"name\":\"sample\",\"plural_name\":\"sample\",\"precision\":2147483647,\"prices\":[{\"created_at\":\"2024-03-15T10:30:45.123+02:00\",\"currency\":\"sample\",\"id\":\"sample\",\"unit_price\":\"sample\"}]}"); + mock.client.creditUnits().retrieve("id"); + assertEquals(List.of("GET /api/v1/credit-units/id"), mock.requests); + } + + @Test + void update() throws Exception { + PerseidMock mock = + new PerseidMock( + 200, + "application/json", + "{\"archived\":false,\"code\":\"sample\",\"id\":\"sample\",\"name\":\"sample\",\"plural_name\":\"sample\",\"precision\":2147483647,\"prices\":[{\"created_at\":\"2024-03-15T10:30:45.123+02:00\",\"currency\":\"sample\",\"id\":\"sample\",\"unit_price\":\"sample\"}]}"); + mock.client + .creditUnits() + .update( + "id", + PerseidMock.decode( + com.meteroid.models.CreditUnitUpdateRequest.class, "{}")); + assertEquals(List.of("PATCH /api/v1/credit-units/id"), mock.requests); + } +} diff --git a/src/test/java/com/meteroid/api/CreditsGrantsTest.java b/src/test/java/com/meteroid/api/CreditsGrantsTest.java new file mode 100644 index 0000000..ec08c95 --- /dev/null +++ b/src/test/java/com/meteroid/api/CreditsGrantsTest.java @@ -0,0 +1,22 @@ +// this file is @generated +package com.meteroid.api; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.junit.jupiter.api.Test; + +import java.util.List; + +class CreditsGrantsTest { + + @Test + void list() throws Exception { + PerseidMock mock = + new PerseidMock( + 200, + "application/json", + "{\"data\":[{\"amount\":-9007199254740993,\"applicable_product_ids\":[\"product_id_39\"],\"applies_to\":\"ALL\",\"created_at\":\"2024-03-15T10:30:45.123+02:00\",\"effective_at\":\"2023-12-31T23:59:59.999-05:30\",\"id\":\"sample\",\"kind\":\"ACCOUNT_BALANCE\",\"kind_label\":\"sample\",\"priority\":123456789,\"reason\":\"sample\",\"remaining\":-9007199254740993,\"source\":\"OVERPAYMENT\",\"status\":\"ACTIVE\",\"type\":\"PAID\"}],\"pagination_meta\":{\"page\":-123456789,\"per_page\":-123456789,\"total_items\":-9007199254740993,\"total_pages\":123456789}}"); + mock.client.credits().grants().list("id_or_alias"); + assertEquals(List.of("GET /api/v1/customers/id_or_alias/credit-grants"), mock.requests); + } +} diff --git a/src/test/java/com/meteroid/api/CreditsTest.java b/src/test/java/com/meteroid/api/CreditsTest.java new file mode 100644 index 0000000..03cc08b --- /dev/null +++ b/src/test/java/com/meteroid/api/CreditsTest.java @@ -0,0 +1,22 @@ +// this file is @generated +package com.meteroid.api; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.junit.jupiter.api.Test; + +import java.util.List; + +class CreditsTest { + + @Test + void listCustomerCreditLedger() throws Exception { + PerseidMock mock = + new PerseidMock( + 200, + "application/json", + "{\"data\":[{\"amount\":-9007199254740993,\"applies_to\":\"USAGE\",\"balance_after\":9007199254740993,\"credit_grant_id\":\"sample\",\"effective_at\":\"2023-12-31T23:59:59.999-05:30\",\"id\":\"sample\",\"reason\":\"sample\",\"recorded_at\":\"2023-12-31T23:59:59.999-05:30\",\"sequence\":9007199254740993,\"type\":\"CREDIT\"}],\"pagination_meta\":{\"page\":-123456789,\"per_page\":-123456789,\"total_items\":-9007199254740993,\"total_pages\":123456789}}"); + mock.client.credits().listCustomerCreditLedger("id_or_alias"); + assertEquals(List.of("GET /api/v1/customers/id_or_alias/credit-ledger"), mock.requests); + } +} diff --git a/src/test/java/com/meteroid/api/CreditsWalletsTest.java b/src/test/java/com/meteroid/api/CreditsWalletsTest.java new file mode 100644 index 0000000..5d0b8d8 --- /dev/null +++ b/src/test/java/com/meteroid/api/CreditsWalletsTest.java @@ -0,0 +1,33 @@ +// this file is @generated +package com.meteroid.api; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.junit.jupiter.api.Test; + +import java.util.List; + +class CreditsWalletsTest { + + @Test + void list() throws Exception { + PerseidMock mock = + new PerseidMock( + 200, + "application/json", + "{\"data\":[{\"credit_on_account\":9007199254740993,\"credit_on_account_usage_only\":-9007199254740993,\"low_balance_thresholds\":[-9007199254740993],\"pauses_at_zero\":false,\"subscription_credit\":[{\"credit_on_account\":-9007199254740993,\"subscription_id\":\"sample\"}],\"upcoming_credit\":9007199254740993,\"usage_at_zero\":\"FOLLOW_PLAN\"}]}"); + mock.client.credits().wallets().list("id_or_alias"); + assertEquals(List.of("GET /api/v1/customers/id_or_alias/wallets"), mock.requests); + } + + @Test + void check() throws Exception { + PerseidMock mock = + new PerseidMock( + 200, + "application/json", + "{\"as_of\":\"2023-12-31T23:59:59.999-05:30\",\"balance\":9007199254740993,\"exact\":true,\"exhausted\":false,\"has_access\":true,\"lag_ms\":-9007199254740993,\"pauses_at_zero\":true}"); + mock.client.credits().wallets().check("id_or_alias"); + assertEquals(List.of("GET /api/v1/customers/id_or_alias/wallets/check"), mock.requests); + } +} diff --git a/src/test/java/com/meteroid/api/InvoicesTest.java b/src/test/java/com/meteroid/api/InvoicesTest.java index 47a8a77..b0aabbf 100644 --- a/src/test/java/com/meteroid/api/InvoicesTest.java +++ b/src/test/java/com/meteroid/api/InvoicesTest.java @@ -15,7 +15,7 @@ void list() throws Exception { new PerseidMock( 200, "application/json", - "{\"data\":[{\"amount_due\":-9007199254740993,\"applied_credits\":-9007199254740993,\"coupons\":[{\"coupon_id\":\"sample\",\"name\":\"sample\",\"total\":-9007199254740993}],\"created_at\":\"2024-03-15T10:30:45.123+02:00\",\"currency\":\"CNY\",\"custom_properties\":{\"key\":\"value\",\"count\":3,\"ratio\":0.5,\"flags\":[true,false],\"nested\":{\"ok\":true}},\"customer_details\":{\"id\":\"customer_id_39\",\"name\":\"sample\",\"snapshot_at\":\"2023-12-31T23:59:59.999-05:30\"},\"customer_id\":\"customer_id_67\",\"id\":\"invoice_id_67\",\"invoice_date\":\"1999-12-31\",\"invoice_number\":\"sample\",\"invoice_type\":\"RECURRING\",\"line_items\":[{\"amount_total\":9007199254740993,\"end_date\":\"2024-02-29\",\"name\":\"sample\",\"start_date\":\"2024-02-29\",\"sub_line_items\":[{\"id\":\"sample\",\"name\":\"sample\",\"quantity\":\"-0.000123\",\"total\":9007199254740993,\"unit_price\":\"12345.6789\"}],\"tax_rate\":\"12345.6789\"}],\"net_terms\":-2147483648,\"payment_status\":\"PARTIALLY_PAID\",\"status\":\"FINALIZED\",\"subtotal\":-9007199254740993,\"subtotal_recurring\":9007199254740993,\"tax_amount\":9007199254740993,\"tax_breakdown\":[{\"name\":\"sample\",\"tax_amount\":-9007199254740993,\"tax_rate\":\"12345.6789\",\"taxable_amount\":9007199254740993}],\"tax_inclusive\":false,\"total\":-9007199254740993,\"transactions\":[{\"amount\":9007199254740993,\"amount_refunded\":9007199254740993,\"amount_reversed\":-9007199254740993,\"currency\":\"sample\",\"id\":\"payment_transaction_id_94\",\"payment_type\":\"PAYMENT\",\"status\":\"READY\"}]}],\"pagination_meta\":{\"page\":-123456789,\"per_page\":-123456789,\"total_items\":-9007199254740993,\"total_pages\":123456789}}"); + "{\"data\":[{\"amount_due\":-9007199254740993,\"applied_credits\":-9007199254740993,\"coupons\":[{\"coupon_id\":\"sample\",\"name\":\"sample\",\"total\":-9007199254740993}],\"created_at\":\"2024-03-15T10:30:45.123+02:00\",\"currency\":\"CNY\",\"custom_properties\":{\"key\":\"value\",\"count\":3,\"ratio\":0.5,\"flags\":[true,false],\"nested\":{\"ok\":true}},\"customer_details\":{\"id\":\"customer_id_39\",\"name\":\"sample\",\"snapshot_at\":\"2023-12-31T23:59:59.999-05:30\"},\"customer_id\":\"customer_id_67\",\"id\":\"invoice_id_67\",\"invoice_date\":\"1999-12-31\",\"invoice_number\":\"sample\",\"invoice_type\":\"RECURRING\",\"line_items\":[{\"amount_total\":9007199254740993,\"end_date\":\"2024-02-29\",\"name\":\"sample\",\"start_date\":\"2024-02-29\",\"sub_line_items\":[{\"id\":\"sample\",\"name\":\"sample\",\"quantity\":\"12345.6789\",\"total\":9007199254740993,\"unit_price\":\"12345.6789\"}],\"tax_rate\":\"-0.000123\"}],\"net_terms\":-2147483648,\"payment_status\":\"ERRORED\",\"settled_by_credit_notes\":false,\"status\":\"FINALIZED\",\"subtotal\":9007199254740993,\"subtotal_recurring\":-9007199254740993,\"tax_amount\":-9007199254740993,\"tax_breakdown\":[{\"name\":\"sample\",\"tax_amount\":9007199254740993,\"tax_rate\":\"12345.6789\",\"taxable_amount\":9007199254740993}],\"tax_inclusive\":true,\"total\":-9007199254740993,\"transactions\":[{\"amount\":9007199254740993,\"amount_refunded\":9007199254740993,\"amount_reversed\":9007199254740993,\"currency\":\"sample\",\"id\":\"payment_transaction_id_30\",\"payment_type\":\"REFUND\",\"status\":\"READY\"}]}],\"pagination_meta\":{\"page\":-123456789,\"per_page\":-123456789,\"total_items\":-9007199254740993,\"total_pages\":123456789}}"); mock.client.invoices().list(); assertEquals(List.of("GET /api/v1/invoices"), mock.requests); } @@ -26,7 +26,7 @@ void retrieve() throws Exception { new PerseidMock( 200, "application/json", - "{\"amount_due\":-9007199254740993,\"applied_credits\":9007199254740993,\"coupons\":[{\"coupon_id\":\"sample\",\"name\":\"sample\",\"total\":-9007199254740993}],\"created_at\":\"2024-03-15T10:30:45.123+02:00\",\"currency\":\"NAD\",\"custom_properties\":{\"key\":\"value\",\"count\":3,\"ratio\":0.5,\"flags\":[true,false],\"nested\":{\"ok\":true}},\"customer_details\":{\"id\":\"customer_id_62\",\"name\":\"sample\",\"snapshot_at\":\"2024-03-15T10:30:45.123+02:00\"},\"customer_id\":\"customer_id_90\",\"id\":\"invoice_id_31\",\"invoice_date\":\"1999-12-31\",\"invoice_number\":\"sample\",\"invoice_type\":\"ONE_OFF\",\"line_items\":[{\"amount_total\":9007199254740993,\"end_date\":\"1999-12-31\",\"name\":\"sample\",\"start_date\":\"2024-02-29\",\"sub_line_items\":[{\"id\":\"sample\",\"name\":\"sample\",\"quantity\":\"12345.6789\",\"total\":-9007199254740993,\"unit_price\":\"12345.6789\"}],\"tax_rate\":\"-0.000123\"}],\"net_terms\":-2147483648,\"payment_status\":\"UNPAID\",\"status\":\"DRAFT\",\"subtotal\":9007199254740993,\"subtotal_recurring\":9007199254740993,\"tax_amount\":-9007199254740993,\"tax_breakdown\":[{\"name\":\"sample\",\"tax_amount\":9007199254740993,\"tax_rate\":\"-0.000123\",\"taxable_amount\":9007199254740993}],\"tax_inclusive\":true,\"total\":-9007199254740993,\"transactions\":[{\"amount\":-9007199254740993,\"amount_refunded\":9007199254740993,\"amount_reversed\":-9007199254740993,\"currency\":\"sample\",\"id\":\"payment_transaction_id_7\",\"payment_type\":\"PAYMENT\",\"status\":\"CANCELLED\"}]}"); + "{\"amount_due\":-9007199254740993,\"applied_credits\":9007199254740993,\"coupons\":[{\"coupon_id\":\"sample\",\"name\":\"sample\",\"total\":-9007199254740993}],\"created_at\":\"2024-03-15T10:30:45.123+02:00\",\"currency\":\"NAD\",\"custom_properties\":{\"key\":\"value\",\"count\":3,\"ratio\":0.5,\"flags\":[true,false],\"nested\":{\"ok\":true}},\"customer_details\":{\"id\":\"customer_id_62\",\"name\":\"sample\",\"snapshot_at\":\"2024-03-15T10:30:45.123+02:00\"},\"customer_id\":\"customer_id_90\",\"id\":\"invoice_id_31\",\"invoice_date\":\"1999-12-31\",\"invoice_number\":\"sample\",\"invoice_type\":\"ONE_OFF\",\"line_items\":[{\"amount_total\":9007199254740993,\"end_date\":\"1999-12-31\",\"name\":\"sample\",\"start_date\":\"1999-12-31\",\"sub_line_items\":[{\"id\":\"sample\",\"name\":\"sample\",\"quantity\":\"12345.6789\",\"total\":9007199254740993,\"unit_price\":\"12345.6789\"}],\"tax_rate\":\"12345.6789\"}],\"net_terms\":-2147483648,\"payment_status\":\"PARTIALLY_PAID\",\"settled_by_credit_notes\":true,\"status\":\"VOID\",\"subtotal\":-9007199254740993,\"subtotal_recurring\":9007199254740993,\"tax_amount\":-9007199254740993,\"tax_breakdown\":[{\"name\":\"sample\",\"tax_amount\":9007199254740993,\"tax_rate\":\"-0.000123\",\"taxable_amount\":-9007199254740993}],\"tax_inclusive\":false,\"total\":-9007199254740993,\"transactions\":[{\"amount\":-9007199254740993,\"amount_refunded\":9007199254740993,\"amount_reversed\":9007199254740993,\"currency\":\"sample\",\"id\":\"payment_transaction_id_88\",\"payment_type\":\"REFUND\",\"status\":\"PENDING\"}]}"); mock.client.invoices().retrieve("invoice_id"); assertEquals(List.of("GET /api/v1/invoices/invoice_id"), mock.requests); } @@ -37,7 +37,7 @@ void updateCustomProperties() throws Exception { new PerseidMock( 200, "application/json", - "{\"amount_due\":-9007199254740993,\"applied_credits\":9007199254740993,\"coupons\":[{\"coupon_id\":\"sample\",\"name\":\"sample\",\"total\":-9007199254740993}],\"created_at\":\"2024-03-15T10:30:45.123+02:00\",\"currency\":\"NAD\",\"custom_properties\":{\"key\":\"value\",\"count\":3,\"ratio\":0.5,\"flags\":[true,false],\"nested\":{\"ok\":true}},\"customer_details\":{\"id\":\"customer_id_62\",\"name\":\"sample\",\"snapshot_at\":\"2024-03-15T10:30:45.123+02:00\"},\"customer_id\":\"customer_id_90\",\"id\":\"invoice_id_31\",\"invoice_date\":\"1999-12-31\",\"invoice_number\":\"sample\",\"invoice_type\":\"ONE_OFF\",\"line_items\":[{\"amount_total\":9007199254740993,\"end_date\":\"1999-12-31\",\"name\":\"sample\",\"start_date\":\"2024-02-29\",\"sub_line_items\":[{\"id\":\"sample\",\"name\":\"sample\",\"quantity\":\"12345.6789\",\"total\":-9007199254740993,\"unit_price\":\"12345.6789\"}],\"tax_rate\":\"-0.000123\"}],\"net_terms\":-2147483648,\"payment_status\":\"UNPAID\",\"status\":\"DRAFT\",\"subtotal\":9007199254740993,\"subtotal_recurring\":9007199254740993,\"tax_amount\":-9007199254740993,\"tax_breakdown\":[{\"name\":\"sample\",\"tax_amount\":9007199254740993,\"tax_rate\":\"-0.000123\",\"taxable_amount\":9007199254740993}],\"tax_inclusive\":true,\"total\":-9007199254740993,\"transactions\":[{\"amount\":-9007199254740993,\"amount_refunded\":9007199254740993,\"amount_reversed\":-9007199254740993,\"currency\":\"sample\",\"id\":\"payment_transaction_id_7\",\"payment_type\":\"PAYMENT\",\"status\":\"CANCELLED\"}]}"); + "{\"amount_due\":-9007199254740993,\"applied_credits\":9007199254740993,\"coupons\":[{\"coupon_id\":\"sample\",\"name\":\"sample\",\"total\":-9007199254740993}],\"created_at\":\"2024-03-15T10:30:45.123+02:00\",\"currency\":\"NAD\",\"custom_properties\":{\"key\":\"value\",\"count\":3,\"ratio\":0.5,\"flags\":[true,false],\"nested\":{\"ok\":true}},\"customer_details\":{\"id\":\"customer_id_62\",\"name\":\"sample\",\"snapshot_at\":\"2024-03-15T10:30:45.123+02:00\"},\"customer_id\":\"customer_id_90\",\"id\":\"invoice_id_31\",\"invoice_date\":\"1999-12-31\",\"invoice_number\":\"sample\",\"invoice_type\":\"ONE_OFF\",\"line_items\":[{\"amount_total\":9007199254740993,\"end_date\":\"1999-12-31\",\"name\":\"sample\",\"start_date\":\"1999-12-31\",\"sub_line_items\":[{\"id\":\"sample\",\"name\":\"sample\",\"quantity\":\"12345.6789\",\"total\":9007199254740993,\"unit_price\":\"12345.6789\"}],\"tax_rate\":\"12345.6789\"}],\"net_terms\":-2147483648,\"payment_status\":\"PARTIALLY_PAID\",\"settled_by_credit_notes\":true,\"status\":\"VOID\",\"subtotal\":-9007199254740993,\"subtotal_recurring\":9007199254740993,\"tax_amount\":-9007199254740993,\"tax_breakdown\":[{\"name\":\"sample\",\"tax_amount\":9007199254740993,\"tax_rate\":\"-0.000123\",\"taxable_amount\":-9007199254740993}],\"tax_inclusive\":false,\"total\":-9007199254740993,\"transactions\":[{\"amount\":-9007199254740993,\"amount_refunded\":9007199254740993,\"amount_reversed\":9007199254740993,\"currency\":\"sample\",\"id\":\"payment_transaction_id_88\",\"payment_type\":\"REFUND\",\"status\":\"PENDING\"}]}"); mock.client .invoices() .updateCustomProperties( @@ -61,7 +61,7 @@ void refresh() throws Exception { new PerseidMock( 200, "application/json", - "{\"amount_due\":-9007199254740993,\"applied_credits\":9007199254740993,\"coupons\":[{\"coupon_id\":\"sample\",\"name\":\"sample\",\"total\":-9007199254740993}],\"created_at\":\"2024-03-15T10:30:45.123+02:00\",\"currency\":\"NAD\",\"custom_properties\":{\"key\":\"value\",\"count\":3,\"ratio\":0.5,\"flags\":[true,false],\"nested\":{\"ok\":true}},\"customer_details\":{\"id\":\"customer_id_62\",\"name\":\"sample\",\"snapshot_at\":\"2024-03-15T10:30:45.123+02:00\"},\"customer_id\":\"customer_id_90\",\"id\":\"invoice_id_31\",\"invoice_date\":\"1999-12-31\",\"invoice_number\":\"sample\",\"invoice_type\":\"ONE_OFF\",\"line_items\":[{\"amount_total\":9007199254740993,\"end_date\":\"1999-12-31\",\"name\":\"sample\",\"start_date\":\"2024-02-29\",\"sub_line_items\":[{\"id\":\"sample\",\"name\":\"sample\",\"quantity\":\"12345.6789\",\"total\":-9007199254740993,\"unit_price\":\"12345.6789\"}],\"tax_rate\":\"-0.000123\"}],\"net_terms\":-2147483648,\"payment_status\":\"UNPAID\",\"status\":\"DRAFT\",\"subtotal\":9007199254740993,\"subtotal_recurring\":9007199254740993,\"tax_amount\":-9007199254740993,\"tax_breakdown\":[{\"name\":\"sample\",\"tax_amount\":9007199254740993,\"tax_rate\":\"-0.000123\",\"taxable_amount\":9007199254740993}],\"tax_inclusive\":true,\"total\":-9007199254740993,\"transactions\":[{\"amount\":-9007199254740993,\"amount_refunded\":9007199254740993,\"amount_reversed\":-9007199254740993,\"currency\":\"sample\",\"id\":\"payment_transaction_id_7\",\"payment_type\":\"PAYMENT\",\"status\":\"CANCELLED\"}]}"); + "{\"amount_due\":-9007199254740993,\"applied_credits\":9007199254740993,\"coupons\":[{\"coupon_id\":\"sample\",\"name\":\"sample\",\"total\":-9007199254740993}],\"created_at\":\"2024-03-15T10:30:45.123+02:00\",\"currency\":\"NAD\",\"custom_properties\":{\"key\":\"value\",\"count\":3,\"ratio\":0.5,\"flags\":[true,false],\"nested\":{\"ok\":true}},\"customer_details\":{\"id\":\"customer_id_62\",\"name\":\"sample\",\"snapshot_at\":\"2024-03-15T10:30:45.123+02:00\"},\"customer_id\":\"customer_id_90\",\"id\":\"invoice_id_31\",\"invoice_date\":\"1999-12-31\",\"invoice_number\":\"sample\",\"invoice_type\":\"ONE_OFF\",\"line_items\":[{\"amount_total\":9007199254740993,\"end_date\":\"1999-12-31\",\"name\":\"sample\",\"start_date\":\"1999-12-31\",\"sub_line_items\":[{\"id\":\"sample\",\"name\":\"sample\",\"quantity\":\"12345.6789\",\"total\":9007199254740993,\"unit_price\":\"12345.6789\"}],\"tax_rate\":\"12345.6789\"}],\"net_terms\":-2147483648,\"payment_status\":\"PARTIALLY_PAID\",\"settled_by_credit_notes\":true,\"status\":\"VOID\",\"subtotal\":-9007199254740993,\"subtotal_recurring\":9007199254740993,\"tax_amount\":-9007199254740993,\"tax_breakdown\":[{\"name\":\"sample\",\"tax_amount\":9007199254740993,\"tax_rate\":\"-0.000123\",\"taxable_amount\":-9007199254740993}],\"tax_inclusive\":false,\"total\":-9007199254740993,\"transactions\":[{\"amount\":-9007199254740993,\"amount_refunded\":9007199254740993,\"amount_reversed\":9007199254740993,\"currency\":\"sample\",\"id\":\"payment_transaction_id_88\",\"payment_type\":\"REFUND\",\"status\":\"PENDING\"}]}"); mock.client.invoices().refresh("invoice_id"); assertEquals(List.of("POST /api/v1/invoices/invoice_id/refresh"), mock.requests); } diff --git a/src/test/java/com/meteroid/api/PlansTest.java b/src/test/java/com/meteroid/api/PlansTest.java index f011c0c..3e234c8 100644 --- a/src/test/java/com/meteroid/api/PlansTest.java +++ b/src/test/java/com/meteroid/api/PlansTest.java @@ -45,7 +45,7 @@ void list() throws Exception { new PerseidMock( 200, "application/json", - "{\"data\":[{\"available_parameters\":{},\"created_at\":\"2024-03-15T10:30:45.123+02:00\",\"currency\":\"WST\",\"id\":\"plan_id_78\",\"name\":\"sample\",\"net_terms\":-2147483648,\"plan_type\":\"FREE\",\"price_components\":[{\"id\":\"price_component_id_82\",\"name\":\"sample\"}],\"product_family\":{\"id\":\"product_family_id_59\",\"name\":\"sample\"},\"status\":\"INACTIVE\",\"tax_inclusive\":true,\"version\":-2147483648,\"version_id\":\"plan_version_id_92\"}],\"pagination_meta\":{\"page\":-123456789,\"per_page\":-123456789,\"total_items\":-9007199254740993,\"total_pages\":123456789}}"); + "{\"data\":[{\"available_parameters\":{},\"created_at\":\"2024-03-15T10:30:45.123+02:00\",\"currency\":\"TMT\",\"id\":\"plan_id_25\",\"name\":\"sample\",\"net_terms\":-2147483648,\"plan_type\":\"CUSTOM\",\"price_components\":[{\"id\":\"price_component_id_8\",\"name\":\"sample\"}],\"product_family\":{\"id\":\"product_family_id_2\",\"name\":\"sample\"},\"status\":\"DRAFT\",\"tax_inclusive\":false,\"version\":123456789,\"version_id\":\"plan_version_id_3\"}],\"pagination_meta\":{\"page\":-123456789,\"per_page\":-123456789,\"total_items\":-9007199254740993,\"total_pages\":123456789}}"); mock.client.plans().list(); assertEquals(List.of("GET /api/v1/plans"), mock.requests); } @@ -56,13 +56,13 @@ void create() throws Exception { new PerseidMock( 200, "application/json", - "{\"available_parameters\":{},\"created_at\":\"2023-12-31T23:59:59.999-05:30\",\"currency\":\"COP\",\"id\":\"plan_id_13\",\"name\":\"sample\",\"net_terms\":2147483647,\"plan_type\":\"FREE\",\"price_components\":[{\"id\":\"price_component_id_38\",\"name\":\"sample\"}],\"product_family\":{\"id\":\"product_family_id_66\",\"name\":\"sample\"},\"status\":\"ARCHIVED\",\"tax_inclusive\":false,\"version\":123456789,\"version_id\":\"plan_version_id_84\"}"); + "{\"available_parameters\":{},\"created_at\":\"2023-12-31T23:59:59.999-05:30\",\"currency\":\"MMK\",\"id\":\"plan_id_40\",\"name\":\"sample\",\"net_terms\":-123456789,\"plan_type\":\"STANDARD\",\"price_components\":[{\"id\":\"price_component_id_88\",\"name\":\"sample\"}],\"product_family\":{\"id\":\"product_family_id_15\",\"name\":\"sample\"},\"status\":\"ACTIVE\",\"tax_inclusive\":true,\"version\":123456789,\"version_id\":\"plan_version_id_79\"}"); mock.client .plans() .create( PerseidMock.decode( com.meteroid.models.CreatePlanRequest.class, - "{\"components\":[{\"fee\":{\"type\":\"RATE\",\"rates\":[{\"price\":\"-0.000123\",\"term\":\"ANNUAL\"}]},\"name\":\"sample\"}],\"currency\":\"sample\",\"name\":\"sample\",\"plan_type\":\"CUSTOM\",\"product_family_id\":\"product_family_id_99\",\"status\":\"ACTIVE\"}")); + "{\"components\":[{\"fee\":{\"type\":\"RATE\",\"rates\":[{\"price\":\"-0.000123\",\"term\":\"ANNUAL\"}]},\"name\":\"sample\"}],\"currency\":\"sample\",\"name\":\"sample\",\"plan_type\":\"CUSTOM\",\"product_family_id\":\"product_family_id_90\",\"status\":\"INACTIVE\"}")); assertEquals(List.of("POST /api/v1/plans"), mock.requests); } @@ -72,7 +72,7 @@ void retrieve() throws Exception { new PerseidMock( 200, "application/json", - "{\"available_parameters\":{},\"created_at\":\"2023-12-31T23:59:59.999-05:30\",\"currency\":\"COP\",\"id\":\"plan_id_13\",\"name\":\"sample\",\"net_terms\":2147483647,\"plan_type\":\"FREE\",\"price_components\":[{\"id\":\"price_component_id_38\",\"name\":\"sample\"}],\"product_family\":{\"id\":\"product_family_id_66\",\"name\":\"sample\"},\"status\":\"ARCHIVED\",\"tax_inclusive\":false,\"version\":123456789,\"version_id\":\"plan_version_id_84\"}"); + "{\"available_parameters\":{},\"created_at\":\"2023-12-31T23:59:59.999-05:30\",\"currency\":\"MMK\",\"id\":\"plan_id_40\",\"name\":\"sample\",\"net_terms\":-123456789,\"plan_type\":\"STANDARD\",\"price_components\":[{\"id\":\"price_component_id_88\",\"name\":\"sample\"}],\"product_family\":{\"id\":\"product_family_id_15\",\"name\":\"sample\"},\"status\":\"ACTIVE\",\"tax_inclusive\":true,\"version\":123456789,\"version_id\":\"plan_version_id_79\"}"); mock.client.plans().retrieve("plan_id"); assertEquals(List.of("GET /api/v1/plans/plan_id"), mock.requests); } @@ -83,7 +83,7 @@ void replace() throws Exception { new PerseidMock( 200, "application/json", - "{\"available_parameters\":{},\"created_at\":\"2023-12-31T23:59:59.999-05:30\",\"currency\":\"COP\",\"id\":\"plan_id_13\",\"name\":\"sample\",\"net_terms\":2147483647,\"plan_type\":\"FREE\",\"price_components\":[{\"id\":\"price_component_id_38\",\"name\":\"sample\"}],\"product_family\":{\"id\":\"product_family_id_66\",\"name\":\"sample\"},\"status\":\"ARCHIVED\",\"tax_inclusive\":false,\"version\":123456789,\"version_id\":\"plan_version_id_84\"}"); + "{\"available_parameters\":{},\"created_at\":\"2023-12-31T23:59:59.999-05:30\",\"currency\":\"MMK\",\"id\":\"plan_id_40\",\"name\":\"sample\",\"net_terms\":-123456789,\"plan_type\":\"STANDARD\",\"price_components\":[{\"id\":\"price_component_id_88\",\"name\":\"sample\"}],\"product_family\":{\"id\":\"product_family_id_15\",\"name\":\"sample\"},\"status\":\"ACTIVE\",\"tax_inclusive\":true,\"version\":123456789,\"version_id\":\"plan_version_id_79\"}"); mock.client .plans() .replace( @@ -100,7 +100,7 @@ void update() throws Exception { new PerseidMock( 200, "application/json", - "{\"available_parameters\":{},\"created_at\":\"2023-12-31T23:59:59.999-05:30\",\"currency\":\"COP\",\"id\":\"plan_id_13\",\"name\":\"sample\",\"net_terms\":2147483647,\"plan_type\":\"FREE\",\"price_components\":[{\"id\":\"price_component_id_38\",\"name\":\"sample\"}],\"product_family\":{\"id\":\"product_family_id_66\",\"name\":\"sample\"},\"status\":\"ARCHIVED\",\"tax_inclusive\":false,\"version\":123456789,\"version_id\":\"plan_version_id_84\"}"); + "{\"available_parameters\":{},\"created_at\":\"2023-12-31T23:59:59.999-05:30\",\"currency\":\"MMK\",\"id\":\"plan_id_40\",\"name\":\"sample\",\"net_terms\":-123456789,\"plan_type\":\"STANDARD\",\"price_components\":[{\"id\":\"price_component_id_88\",\"name\":\"sample\"}],\"product_family\":{\"id\":\"product_family_id_15\",\"name\":\"sample\"},\"status\":\"ACTIVE\",\"tax_inclusive\":true,\"version\":123456789,\"version_id\":\"plan_version_id_79\"}"); mock.client .plans() .update( @@ -122,7 +122,7 @@ void publish() throws Exception { new PerseidMock( 200, "application/json", - "{\"available_parameters\":{},\"created_at\":\"2023-12-31T23:59:59.999-05:30\",\"currency\":\"COP\",\"id\":\"plan_id_13\",\"name\":\"sample\",\"net_terms\":2147483647,\"plan_type\":\"FREE\",\"price_components\":[{\"id\":\"price_component_id_38\",\"name\":\"sample\"}],\"product_family\":{\"id\":\"product_family_id_66\",\"name\":\"sample\"},\"status\":\"ARCHIVED\",\"tax_inclusive\":false,\"version\":123456789,\"version_id\":\"plan_version_id_84\"}"); + "{\"available_parameters\":{},\"created_at\":\"2023-12-31T23:59:59.999-05:30\",\"currency\":\"MMK\",\"id\":\"plan_id_40\",\"name\":\"sample\",\"net_terms\":-123456789,\"plan_type\":\"STANDARD\",\"price_components\":[{\"id\":\"price_component_id_88\",\"name\":\"sample\"}],\"product_family\":{\"id\":\"product_family_id_15\",\"name\":\"sample\"},\"status\":\"ACTIVE\",\"tax_inclusive\":true,\"version\":123456789,\"version_id\":\"plan_version_id_79\"}"); mock.client.plans().publish("plan_id"); assertEquals(List.of("POST /api/v1/plans/plan_id/publish"), mock.requests); } diff --git a/src/test/java/com/meteroid/api/ProductsTest.java b/src/test/java/com/meteroid/api/ProductsTest.java index 39f1df2..3c9f1f4 100644 --- a/src/test/java/com/meteroid/api/ProductsTest.java +++ b/src/test/java/com/meteroid/api/ProductsTest.java @@ -15,7 +15,7 @@ void list() throws Exception { new PerseidMock( 200, "application/json", - "{\"data\":[{\"catalog\":false,\"created_at\":\"2024-03-15T10:30:45.123+02:00\",\"fee_structure\":{\"type\":\"RATE\"},\"fee_type\":\"CAPACITY\",\"id\":\"product_id_78\",\"name\":\"sample\",\"product_family_id\":\"product_family_id_47\"}],\"pagination_meta\":{\"page\":-123456789,\"per_page\":-123456789,\"total_items\":-9007199254740993,\"total_pages\":123456789}}"); + "{\"data\":[{\"catalog\":false,\"created_at\":\"2024-03-15T10:30:45.123+02:00\",\"fee_structure\":{\"type\":\"RATE\"},\"fee_type\":\"USAGE\",\"id\":\"product_id_78\",\"name\":\"sample\",\"product_family_id\":\"product_family_id_47\"}],\"pagination_meta\":{\"page\":-123456789,\"per_page\":-123456789,\"total_items\":-9007199254740993,\"total_pages\":123456789}}"); mock.client.products().list(); assertEquals(List.of("GET /api/v1/products"), mock.requests); } @@ -26,7 +26,7 @@ void create() throws Exception { new PerseidMock( 200, "application/json", - "{\"catalog\":true,\"created_at\":\"2023-12-31T23:59:59.999-05:30\",\"fee_structure\":{\"type\":\"RATE\"},\"fee_type\":\"RATE\",\"id\":\"product_id_13\",\"name\":\"sample\",\"product_family_id\":\"product_family_id_99\"}"); + "{\"catalog\":true,\"created_at\":\"2023-12-31T23:59:59.999-05:30\",\"fee_structure\":{\"type\":\"RATE\"},\"fee_type\":\"CAPACITY\",\"id\":\"product_id_13\",\"name\":\"sample\",\"product_family_id\":\"product_family_id_99\"}"); mock.client .products() .create( @@ -42,7 +42,7 @@ void retrieve() throws Exception { new PerseidMock( 200, "application/json", - "{\"catalog\":true,\"created_at\":\"2023-12-31T23:59:59.999-05:30\",\"fee_structure\":{\"type\":\"RATE\"},\"fee_type\":\"RATE\",\"id\":\"product_id_13\",\"name\":\"sample\",\"product_family_id\":\"product_family_id_99\"}"); + "{\"catalog\":true,\"created_at\":\"2023-12-31T23:59:59.999-05:30\",\"fee_structure\":{\"type\":\"RATE\"},\"fee_type\":\"CAPACITY\",\"id\":\"product_id_13\",\"name\":\"sample\",\"product_family_id\":\"product_family_id_99\"}"); mock.client.products().retrieve("product_id"); assertEquals(List.of("GET /api/v1/products/product_id"), mock.requests); } @@ -53,7 +53,7 @@ void update() throws Exception { new PerseidMock( 200, "application/json", - "{\"catalog\":true,\"created_at\":\"2023-12-31T23:59:59.999-05:30\",\"fee_structure\":{\"type\":\"RATE\"},\"fee_type\":\"RATE\",\"id\":\"product_id_13\",\"name\":\"sample\",\"product_family_id\":\"product_family_id_99\"}"); + "{\"catalog\":true,\"created_at\":\"2023-12-31T23:59:59.999-05:30\",\"fee_structure\":{\"type\":\"RATE\"},\"fee_type\":\"CAPACITY\",\"id\":\"product_id_13\",\"name\":\"sample\",\"product_family_id\":\"product_family_id_99\"}"); mock.client .products() .update( diff --git a/src/test/java/com/meteroid/api/UsageCustomerTest.java b/src/test/java/com/meteroid/api/UsageCustomerTest.java new file mode 100644 index 0000000..dbbfc24 --- /dev/null +++ b/src/test/java/com/meteroid/api/UsageCustomerTest.java @@ -0,0 +1,22 @@ +// this file is @generated +package com.meteroid.api; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.junit.jupiter.api.Test; + +import java.util.List; + +class UsageCustomerTest { + + @Test + void retrieveUnattributed() throws Exception { + PerseidMock mock = + new PerseidMock( + 200, + "application/json", + "{\"period_end\":\"1999-12-31\",\"period_start\":\"2024-02-29\",\"usage\":[{\"from\":\"2024-03-15T10:30:45.123+02:00\",\"metric_code\":\"sample\",\"metric_id\":\"billable_metric_id_44\",\"metric_name\":\"sample\",\"total_value\":\"12345.6789\",\"until\":\"2023-12-31T23:59:59.999-05:30\"}]}"); + mock.client.usage().customer().retrieveUnattributed("customer_id"); + assertEquals(List.of("GET /api/v1/usage/customer/customer_id/unattributed"), mock.requests); + } +} diff --git a/src/test/java/com/meteroid/api/UsageTest.java b/src/test/java/com/meteroid/api/UsageTest.java index 3cdc8a1..b4e4add 100644 --- a/src/test/java/com/meteroid/api/UsageTest.java +++ b/src/test/java/com/meteroid/api/UsageTest.java @@ -15,7 +15,7 @@ void retrieveSubscription() throws Exception { new PerseidMock( 200, "application/json", - "{\"period_end\":\"1999-12-31\",\"period_start\":\"2024-02-29\",\"usage\":[{\"grouped_usage\":[{\"dimensions\":{\"alpha\":\"sample\"},\"value\":\"12345.6789\"}],\"metric_code\":\"sample\",\"metric_id\":\"billable_metric_id_44\",\"metric_name\":\"sample\",\"total_value\":\"12345.6789\"}]}"); + "{\"period_end\":\"2024-02-29\",\"period_start\":\"1999-12-31\",\"usage\":[{\"grouped_usage\":[{\"dimensions\":{\"alpha\":\"sample\"},\"value\":\"-0.000123\"}],\"metric_code\":\"sample\",\"metric_id\":\"billable_metric_id_52\",\"metric_name\":\"sample\",\"total_value\":\"12345.6789\"}]}"); mock.client.usage().retrieveSubscription("subscription_id"); assertEquals(List.of("GET /api/v1/usage/subscription/subscription_id"), mock.requests); }