From ff55d6c78cf21a051aa37dcc3c1d8cf88d26ce24 Mon Sep 17 00:00:00 2001 From: maxio-sdk Date: Tue, 9 Sep 2025 14:56:54 +0000 Subject: [PATCH 1/4] Automated commit message --- README.md | 133 +++++++-------- doc/auth/basic-authentication.md | 18 ++- doc/client.md | 27 ++-- doc/controllers/component-price-points.md | 6 +- doc/controllers/components.md | 4 +- doc/controllers/customers.md | 39 ++++- doc/controllers/payment-profiles.md | 10 +- doc/controllers/subscription-components.md | 16 +- doc/controllers/subscriptions.md | 18 +-- doc/controllers/webhooks.md | 41 ++--- doc/http-client-configuration-builder.md | 1 + doc/http-client-configuration.md | 1 + doc/http-proxy-configuration-builder.md | 36 +++++ doc/http-proxy-configuration.md | 16 ++ ...eate-usage-subscription-id-or-reference.md | 14 ++ ...ages-input-subscription-id-or-reference.md | 14 ++ pom.xml | 8 +- .../AdvancedBillingClient.java | 2 +- .../ComponentPricePointsController.java | 2 +- .../controllers/ComponentsController.java | 6 +- .../controllers/CustomersController.java | 3 +- .../PaymentProfilesController.java | 10 +- .../SubscriptionComponentsController.java | 22 ++- .../controllers/SubscriptionsController.java | 18 +-- .../controllers/WebhooksController.java | 50 +++--- .../http/client/HttpClientConfiguration.java | 53 +++++- .../http/client/HttpProxyConfiguration.java | 135 ++++++++++++++++ .../ReadonlyHttpClientConfiguration.java | 5 + .../ReadonlyHttpProxyConfiguration.java | 37 +++++ .../models/ListUsagesInput.java | 76 +++++---- .../CreateUsageSubscriptionIdOrReference.java | 151 ++++++++++++++++++ ...tUsagesInputSubscriptionIdOrReference.java | 151 ++++++++++++++++++ 32 files changed, 886 insertions(+), 237 deletions(-) create mode 100644 doc/http-proxy-configuration-builder.md create mode 100644 doc/http-proxy-configuration.md create mode 100644 doc/models/containers/create-usage-subscription-id-or-reference.md create mode 100644 doc/models/containers/list-usages-input-subscription-id-or-reference.md create mode 100644 src/main/java/com/maxio/advancedbilling/http/client/HttpProxyConfiguration.java create mode 100644 src/main/java/com/maxio/advancedbilling/http/client/ReadonlyHttpProxyConfiguration.java create mode 100644 src/main/java/com/maxio/advancedbilling/models/containers/CreateUsageSubscriptionIdOrReference.java create mode 100644 src/main/java/com/maxio/advancedbilling/models/containers/ListUsagesInputSubscriptionIdOrReference.java diff --git a/README.md b/README.md index e0e863ff..c0b114da 100644 --- a/README.md +++ b/README.md @@ -32,16 +32,16 @@ Install the SDK by adding the following dependency in your project's pom.xml fil com.maxio advanced-billing-sdk - 7.0.0 + 7.0.1 ``` You can also view the package at: -https://central.sonatype.com/artifact/com.maxio/advanced-billing-sdk/7.0.0 +https://central.sonatype.com/artifact/com.maxio/advanced-billing-sdk/7.0.1 ## Initialize the API Client -**_Note:_** Documentation for the client can be found [here.](https://www.github.com/maxio-com/ab-java-sdk/tree/7.0.0/doc/client.md) +**_Note:_** Documentation for the client can be found [here.](https://www.github.com/maxio-com/ab-java-sdk/tree/7.0.1/doc/client.md) The following parameters are configurable for the API Client: @@ -49,8 +49,8 @@ The following parameters are configurable for the API Client: | --- | --- | --- | | site | `String` | The subdomain for your Advanced Billing site.
*Default*: `"subdomain"` | | environment | `Environment` | The API environment.
**Default: `Environment.US`** | -| httpClientConfig | [`Consumer`](https://www.github.com/maxio-com/ab-java-sdk/tree/7.0.0/doc/http-client-configuration-builder.md) | Set up Http Client Configuration instance. | -| basicAuthCredentials | [`BasicAuthCredentials`](https://www.github.com/maxio-com/ab-java-sdk/tree/7.0.0/doc/auth/basic-authentication.md) | The Credentials Setter for Basic Authentication | +| httpClientConfig | [`Consumer`](https://www.github.com/maxio-com/ab-java-sdk/tree/7.0.1/doc/http-client-configuration-builder.md) | Set up Http Client Configuration instance. | +| basicAuthCredentials | [`BasicAuthCredentials`](https://www.github.com/maxio-com/ab-java-sdk/tree/7.0.1/doc/auth/basic-authentication.md) | The Credentials Setter for Basic Authentication | The API client can be initialized as follows: @@ -61,17 +61,22 @@ import com.maxio.advancedbilling.authentication.BasicAuthModel; import com.maxio.advancedbilling.exceptions.ApiException; import java.io.IOException; -AdvancedBillingClient client = new AdvancedBillingClient.Builder() - .httpClientConfig(configBuilder -> configBuilder - .timeout(0)) - .basicAuthCredentials(new BasicAuthModel.Builder( - "BasicAuthUserName", - "BasicAuthPassword" - ) - .build()) - .environment(Environment.US) - .site("subdomain") - .build(); +public class Program { + public static void main(String[] args) { + AdvancedBillingClient client = new AdvancedBillingClient.Builder() + .httpClientConfig(configBuilder -> configBuilder + .timeout(0)) + .basicAuthCredentials(new BasicAuthModel.Builder( + "BasicAuthUserName", + "BasicAuthPassword" + ) + .build()) + .environment(Environment.US) + .site("subdomain") + .build(); + + } +} ``` ## Environments @@ -89,65 +94,67 @@ The SDK can be configured to use a different environment for making API calls. A This API uses the following authentication schemes. -* [`BasicAuth (Basic Authentication)`](https://www.github.com/maxio-com/ab-java-sdk/tree/7.0.0/doc/auth/basic-authentication.md) +* [`BasicAuth (Basic Authentication)`](https://www.github.com/maxio-com/ab-java-sdk/tree/7.0.1/doc/auth/basic-authentication.md) ## List of APIs -* [API Exports](https://www.github.com/maxio-com/ab-java-sdk/tree/7.0.0/doc/controllers/api-exports.md) -* [Advance Invoice](https://www.github.com/maxio-com/ab-java-sdk/tree/7.0.0/doc/controllers/advance-invoice.md) -* [Billing Portal](https://www.github.com/maxio-com/ab-java-sdk/tree/7.0.0/doc/controllers/billing-portal.md) -* [Component Price Points](https://www.github.com/maxio-com/ab-java-sdk/tree/7.0.0/doc/controllers/component-price-points.md) -* [Custom Fields](https://www.github.com/maxio-com/ab-java-sdk/tree/7.0.0/doc/controllers/custom-fields.md) -* [Events-Based Billing Segments](https://www.github.com/maxio-com/ab-java-sdk/tree/7.0.0/doc/controllers/events-based-billing-segments.md) -* [Payment Profiles](https://www.github.com/maxio-com/ab-java-sdk/tree/7.0.0/doc/controllers/payment-profiles.md) -* [Product Families](https://www.github.com/maxio-com/ab-java-sdk/tree/7.0.0/doc/controllers/product-families.md) -* [Product Price Points](https://www.github.com/maxio-com/ab-java-sdk/tree/7.0.0/doc/controllers/product-price-points.md) -* [Proforma Invoices](https://www.github.com/maxio-com/ab-java-sdk/tree/7.0.0/doc/controllers/proforma-invoices.md) -* [Reason Codes](https://www.github.com/maxio-com/ab-java-sdk/tree/7.0.0/doc/controllers/reason-codes.md) -* [Referral Codes](https://www.github.com/maxio-com/ab-java-sdk/tree/7.0.0/doc/controllers/referral-codes.md) -* [Sales Commissions](https://www.github.com/maxio-com/ab-java-sdk/tree/7.0.0/doc/controllers/sales-commissions.md) -* [Subscription Components](https://www.github.com/maxio-com/ab-java-sdk/tree/7.0.0/doc/controllers/subscription-components.md) -* [Subscription Groups](https://www.github.com/maxio-com/ab-java-sdk/tree/7.0.0/doc/controllers/subscription-groups.md) -* [Subscription Group Invoice Account](https://www.github.com/maxio-com/ab-java-sdk/tree/7.0.0/doc/controllers/subscription-group-invoice-account.md) -* [Subscription Group Status](https://www.github.com/maxio-com/ab-java-sdk/tree/7.0.0/doc/controllers/subscription-group-status.md) -* [Subscription Invoice Account](https://www.github.com/maxio-com/ab-java-sdk/tree/7.0.0/doc/controllers/subscription-invoice-account.md) -* [Subscription Notes](https://www.github.com/maxio-com/ab-java-sdk/tree/7.0.0/doc/controllers/subscription-notes.md) -* [Subscription Products](https://www.github.com/maxio-com/ab-java-sdk/tree/7.0.0/doc/controllers/subscription-products.md) -* [Subscription Status](https://www.github.com/maxio-com/ab-java-sdk/tree/7.0.0/doc/controllers/subscription-status.md) -* [Coupons](https://www.github.com/maxio-com/ab-java-sdk/tree/7.0.0/doc/controllers/coupons.md) -* [Components](https://www.github.com/maxio-com/ab-java-sdk/tree/7.0.0/doc/controllers/components.md) -* [Customers](https://www.github.com/maxio-com/ab-java-sdk/tree/7.0.0/doc/controllers/customers.md) -* [Events](https://www.github.com/maxio-com/ab-java-sdk/tree/7.0.0/doc/controllers/events.md) -* [Insights](https://www.github.com/maxio-com/ab-java-sdk/tree/7.0.0/doc/controllers/insights.md) -* [Invoices](https://www.github.com/maxio-com/ab-java-sdk/tree/7.0.0/doc/controllers/invoices.md) -* [Offers](https://www.github.com/maxio-com/ab-java-sdk/tree/7.0.0/doc/controllers/offers.md) -* [Products](https://www.github.com/maxio-com/ab-java-sdk/tree/7.0.0/doc/controllers/products.md) -* [Sites](https://www.github.com/maxio-com/ab-java-sdk/tree/7.0.0/doc/controllers/sites.md) -* [Subscriptions](https://www.github.com/maxio-com/ab-java-sdk/tree/7.0.0/doc/controllers/subscriptions.md) -* [Webhooks](https://www.github.com/maxio-com/ab-java-sdk/tree/7.0.0/doc/controllers/webhooks.md) +* [API Exports](https://www.github.com/maxio-com/ab-java-sdk/tree/7.0.1/doc/controllers/api-exports.md) +* [Advance Invoice](https://www.github.com/maxio-com/ab-java-sdk/tree/7.0.1/doc/controllers/advance-invoice.md) +* [Billing Portal](https://www.github.com/maxio-com/ab-java-sdk/tree/7.0.1/doc/controllers/billing-portal.md) +* [Component Price Points](https://www.github.com/maxio-com/ab-java-sdk/tree/7.0.1/doc/controllers/component-price-points.md) +* [Custom Fields](https://www.github.com/maxio-com/ab-java-sdk/tree/7.0.1/doc/controllers/custom-fields.md) +* [Events-Based Billing Segments](https://www.github.com/maxio-com/ab-java-sdk/tree/7.0.1/doc/controllers/events-based-billing-segments.md) +* [Payment Profiles](https://www.github.com/maxio-com/ab-java-sdk/tree/7.0.1/doc/controllers/payment-profiles.md) +* [Product Families](https://www.github.com/maxio-com/ab-java-sdk/tree/7.0.1/doc/controllers/product-families.md) +* [Product Price Points](https://www.github.com/maxio-com/ab-java-sdk/tree/7.0.1/doc/controllers/product-price-points.md) +* [Proforma Invoices](https://www.github.com/maxio-com/ab-java-sdk/tree/7.0.1/doc/controllers/proforma-invoices.md) +* [Reason Codes](https://www.github.com/maxio-com/ab-java-sdk/tree/7.0.1/doc/controllers/reason-codes.md) +* [Referral Codes](https://www.github.com/maxio-com/ab-java-sdk/tree/7.0.1/doc/controllers/referral-codes.md) +* [Sales Commissions](https://www.github.com/maxio-com/ab-java-sdk/tree/7.0.1/doc/controllers/sales-commissions.md) +* [Subscription Components](https://www.github.com/maxio-com/ab-java-sdk/tree/7.0.1/doc/controllers/subscription-components.md) +* [Subscription Groups](https://www.github.com/maxio-com/ab-java-sdk/tree/7.0.1/doc/controllers/subscription-groups.md) +* [Subscription Group Invoice Account](https://www.github.com/maxio-com/ab-java-sdk/tree/7.0.1/doc/controllers/subscription-group-invoice-account.md) +* [Subscription Group Status](https://www.github.com/maxio-com/ab-java-sdk/tree/7.0.1/doc/controllers/subscription-group-status.md) +* [Subscription Invoice Account](https://www.github.com/maxio-com/ab-java-sdk/tree/7.0.1/doc/controllers/subscription-invoice-account.md) +* [Subscription Notes](https://www.github.com/maxio-com/ab-java-sdk/tree/7.0.1/doc/controllers/subscription-notes.md) +* [Subscription Products](https://www.github.com/maxio-com/ab-java-sdk/tree/7.0.1/doc/controllers/subscription-products.md) +* [Subscription Status](https://www.github.com/maxio-com/ab-java-sdk/tree/7.0.1/doc/controllers/subscription-status.md) +* [Coupons](https://www.github.com/maxio-com/ab-java-sdk/tree/7.0.1/doc/controllers/coupons.md) +* [Components](https://www.github.com/maxio-com/ab-java-sdk/tree/7.0.1/doc/controllers/components.md) +* [Customers](https://www.github.com/maxio-com/ab-java-sdk/tree/7.0.1/doc/controllers/customers.md) +* [Events](https://www.github.com/maxio-com/ab-java-sdk/tree/7.0.1/doc/controllers/events.md) +* [Insights](https://www.github.com/maxio-com/ab-java-sdk/tree/7.0.1/doc/controllers/insights.md) +* [Invoices](https://www.github.com/maxio-com/ab-java-sdk/tree/7.0.1/doc/controllers/invoices.md) +* [Offers](https://www.github.com/maxio-com/ab-java-sdk/tree/7.0.1/doc/controllers/offers.md) +* [Products](https://www.github.com/maxio-com/ab-java-sdk/tree/7.0.1/doc/controllers/products.md) +* [Sites](https://www.github.com/maxio-com/ab-java-sdk/tree/7.0.1/doc/controllers/sites.md) +* [Subscriptions](https://www.github.com/maxio-com/ab-java-sdk/tree/7.0.1/doc/controllers/subscriptions.md) +* [Webhooks](https://www.github.com/maxio-com/ab-java-sdk/tree/7.0.1/doc/controllers/webhooks.md) ## SDK Infrastructure ### Configuration -* [Configuration Interface](https://www.github.com/maxio-com/ab-java-sdk/tree/7.0.0/doc/configuration-interface.md) -* [HttpClientConfiguration](https://www.github.com/maxio-com/ab-java-sdk/tree/7.0.0/doc/http-client-configuration.md) -* [HttpClientConfiguration.Builder](https://www.github.com/maxio-com/ab-java-sdk/tree/7.0.0/doc/http-client-configuration-builder.md) +* [Configuration Interface](https://www.github.com/maxio-com/ab-java-sdk/tree/7.0.1/doc/configuration-interface.md) +* [HttpClientConfiguration](https://www.github.com/maxio-com/ab-java-sdk/tree/7.0.1/doc/http-client-configuration.md) +* [HttpClientConfiguration.Builder](https://www.github.com/maxio-com/ab-java-sdk/tree/7.0.1/doc/http-client-configuration-builder.md) +* [HttpProxyConfiguration](https://www.github.com/maxio-com/ab-java-sdk/tree/7.0.1/doc/http-proxy-configuration.md) +* [HttpProxyConfiguration.Builder](https://www.github.com/maxio-com/ab-java-sdk/tree/7.0.1/doc/http-proxy-configuration-builder.md) ### HTTP -* [Headers](https://www.github.com/maxio-com/ab-java-sdk/tree/7.0.0/doc/headers.md) -* [HttpCallback Interface](https://www.github.com/maxio-com/ab-java-sdk/tree/7.0.0/doc/http-callback-interface.md) -* [HttpContext](https://www.github.com/maxio-com/ab-java-sdk/tree/7.0.0/doc/http-context.md) -* [HttpBodyRequest](https://www.github.com/maxio-com/ab-java-sdk/tree/7.0.0/doc/http-body-request.md) -* [HttpRequest](https://www.github.com/maxio-com/ab-java-sdk/tree/7.0.0/doc/http-request.md) -* [HttpResponse](https://www.github.com/maxio-com/ab-java-sdk/tree/7.0.0/doc/http-response.md) -* [HttpStringResponse](https://www.github.com/maxio-com/ab-java-sdk/tree/7.0.0/doc/http-string-response.md) +* [Headers](https://www.github.com/maxio-com/ab-java-sdk/tree/7.0.1/doc/headers.md) +* [HttpCallback Interface](https://www.github.com/maxio-com/ab-java-sdk/tree/7.0.1/doc/http-callback-interface.md) +* [HttpContext](https://www.github.com/maxio-com/ab-java-sdk/tree/7.0.1/doc/http-context.md) +* [HttpBodyRequest](https://www.github.com/maxio-com/ab-java-sdk/tree/7.0.1/doc/http-body-request.md) +* [HttpRequest](https://www.github.com/maxio-com/ab-java-sdk/tree/7.0.1/doc/http-request.md) +* [HttpResponse](https://www.github.com/maxio-com/ab-java-sdk/tree/7.0.1/doc/http-response.md) +* [HttpStringResponse](https://www.github.com/maxio-com/ab-java-sdk/tree/7.0.1/doc/http-string-response.md) ### Utilities -* [ApiException](https://www.github.com/maxio-com/ab-java-sdk/tree/7.0.0/doc/api-exception.md) -* [ApiHelper](https://www.github.com/maxio-com/ab-java-sdk/tree/7.0.0/doc/api-helper.md) -* [FileWrapper](https://www.github.com/maxio-com/ab-java-sdk/tree/7.0.0/doc/file-wrapper.md) -* [DateTimeHelper](https://www.github.com/maxio-com/ab-java-sdk/tree/7.0.0/doc/date-time-helper.md) +* [ApiException](https://www.github.com/maxio-com/ab-java-sdk/tree/7.0.1/doc/api-exception.md) +* [ApiHelper](https://www.github.com/maxio-com/ab-java-sdk/tree/7.0.1/doc/api-helper.md) +* [FileWrapper](https://www.github.com/maxio-com/ab-java-sdk/tree/7.0.1/doc/file-wrapper.md) +* [DateTimeHelper](https://www.github.com/maxio-com/ab-java-sdk/tree/7.0.1/doc/date-time-helper.md) diff --git a/doc/auth/basic-authentication.md b/doc/auth/basic-authentication.md index bb18ddbd..6cd61cb6 100644 --- a/doc/auth/basic-authentication.md +++ b/doc/auth/basic-authentication.md @@ -26,13 +26,17 @@ You must provide credentials in the client as shown in the following code snippe import com.maxio.advancedbilling.AdvancedBillingClient; import com.maxio.advancedbilling.authentication.BasicAuthModel; -AdvancedBillingClient client = new AdvancedBillingClient.Builder() - .basicAuthCredentials(new BasicAuthModel.Builder( - "BasicAuthUserName", - "BasicAuthPassword" - ) - .build()) - .build(); +public class Program { + public static void main(String[] args) { + AdvancedBillingClient client = new AdvancedBillingClient.Builder() + .basicAuthCredentials(new BasicAuthModel.Builder( + "BasicAuthUserName", + "BasicAuthPassword" + ) + .build()) + .build(); + } +} ``` diff --git a/doc/client.md b/doc/client.md index 95473ddb..2ec9673f 100644 --- a/doc/client.md +++ b/doc/client.md @@ -19,17 +19,22 @@ import com.maxio.advancedbilling.authentication.BasicAuthModel; import com.maxio.advancedbilling.exceptions.ApiException; import java.io.IOException; -AdvancedBillingClient client = new AdvancedBillingClient.Builder() - .httpClientConfig(configBuilder -> configBuilder - .timeout(0)) - .basicAuthCredentials(new BasicAuthModel.Builder( - "BasicAuthUserName", - "BasicAuthPassword" - ) - .build()) - .environment(Environment.US) - .site("subdomain") - .build(); +public class Program { + public static void main(String[] args) { + AdvancedBillingClient client = new AdvancedBillingClient.Builder() + .httpClientConfig(configBuilder -> configBuilder + .timeout(0)) + .basicAuthCredentials(new BasicAuthModel.Builder( + "BasicAuthUserName", + "BasicAuthPassword" + ) + .build()) + .environment(Environment.US) + .site("subdomain") + .build(); + + } +} ``` ## Maxio Advanced BillingClient Class diff --git a/doc/controllers/component-price-points.md b/doc/controllers/component-price-points.md index 85e056ae..d3696eb7 100644 --- a/doc/controllers/component-price-points.md +++ b/doc/controllers/component-price-points.md @@ -100,7 +100,7 @@ try { # Create Component Price Point -This endpoint can be used to create a new price point for an existing component. +Creates a price point for an existing component. ```java ComponentPricePointResponse createComponentPricePoint( @@ -149,7 +149,9 @@ CreateComponentPricePointRequest body = new CreateComponentPricePointRequest.Bui "4.00" ) ) - .endingQuantity(null) + .endingQuantity(PriceEndingQuantity.fromString( + "200" + )) .build() ) ) diff --git a/doc/controllers/components.md b/doc/controllers/components.md index 111082de..87cdf14c 100644 --- a/doc/controllers/components.md +++ b/doc/controllers/components.md @@ -707,9 +707,9 @@ try { # Read Component -This request will return information regarding a component from a specific product family. +Returns information regarding a component from a specific product family. -You may read the component by either the component's id or handle. When using the handle, it must be prefixed with `handle:`. +You can read the component by either the component's id or handle. When using the handle, it must be prefixed with `handle:`. ```java ComponentResponse readComponent( diff --git a/doc/controllers/customers.md b/doc/controllers/customers.md index 2b7c4ae5..4e216d75 100644 --- a/doc/controllers/customers.md +++ b/doc/controllers/customers.md @@ -284,7 +284,7 @@ try { # Read Customer -This method allows to retrieve the Customer properties by Advanced Billing-generated Customer ID. +Retrieves the Customer properties by Advanced Billing-generated Customer ID. ```java CustomerResponse readCustomer( @@ -316,6 +316,43 @@ try { } ``` +## Example Response *(as JSON)* + +```json +{ + "customer": { + "first_name": "Jane", + "last_name": "Doe", + "email": "jane@example.com", + "cc_emails": "joe@example.com", + "organization": "ABC, Inc.", + "reference": "1234567890", + "id": 88833369, + "created_at": "2025-05-08T11:39:18-04:00", + "updated_at": "2025-05-08T11:39:18-04:00", + "address": "123 Main Street", + "address_2": "Unit 10", + "city": "Anytown", + "state": "MA", + "state_name": "Massachusetts", + "zip": "02120", + "country": "US", + "country_name": "United States", + "phone": "555-555-1212", + "verified": false, + "portal_customer_created_at": null, + "portal_invite_last_sent_at": null, + "portal_invite_last_accepted_at": null, + "tax_exempt": false, + "vat_number": null, + "parent_id": null, + "locale": "es-MX", + "salesforce_id": null, + "default_auto_renewal_profile_id": null + } +} +``` + # Update Customer diff --git a/doc/controllers/payment-profiles.md b/doc/controllers/payment-profiles.md index e9a860fe..cc948917 100644 --- a/doc/controllers/payment-profiles.md +++ b/doc/controllers/payment-profiles.md @@ -96,9 +96,9 @@ For more information on GoCardless, please view the following resources: + [Full documentation on GoCardless](https://maxio.zendesk.com/hc/en-us/articles/24176159136909-GoCardless) -+ [Using Chargify.js with GoCardless - minimal example](https://developers.chargify.com/docs/developer-docs/ZG9jOjE0NjAzNDIy-examples#minimal-example-with-direct-debit-gocardless-gateway) ++ [Using Chargify.js with GoCardless - minimal example](https://docs.maxio.com/hc/en-us/articles/38206331271693-Examples#h_01K0PJ15QQZKCER8CFK40MR6XJ) -+ [Using Chargify.js with GoCardless - full example](https://developers.chargify.com/docs/developer-docs/ZG9jOjE0NjAzNDIy-examples#full-example-with-direct-debit-gocardless-gateway) ++ [Using Chargify.js with GoCardless - full example](https://docs.maxio.com/hc/en-us/articles/38206331271693-Examples#h_01K0PJ15QR09JVHWW0MCA7HVJV) ### GoCardless with Local Bank Details @@ -170,9 +170,9 @@ For more information on Stripe SEPA Direct Debit, please view the following reso + [Full documentation on Stripe SEPA Direct Debit](https://maxio.zendesk.com/hc/en-us/articles/24176170430093-Stripe-SEPA-and-BECS-Direct-Debit) -+ [Using Chargify.js with Stripe Direct Debit - minimal example](https://developers.chargify.com/docs/developer-docs/ZG9jOjE0NjAzNDIy-examples#minimal-example-with-sepa-or-becs-direct-debit-stripe-gateway) ++ [Using Chargify.js with Stripe Direct Debit - minimal example](https://docs.maxio.com/hc/en-us/articles/38206331271693-Examples#h_01K0PJ15QQFKKN8Z7B7DZ9AJS5) -+ [Using Chargify.js with Stripe Direct Debit - full example](https://developers.chargify.com/docs/developer-docs/ZG9jOjE0NjAzNDIy-examples#full-example-with-sepa-direct-debit-stripe-gateway) ++ [Using Chargify.js with Stripe Direct Debit - full example](https://docs.maxio.com/hc/en-us/articles/38206331271693-Examples#h_01K0PJ15QRECQQ4ECS3ZA55GY7) ### Stripe SEPA Direct Debit Payment Profiles @@ -1073,7 +1073,7 @@ One Time Tokens aka Advanced Billing Tokens house the credit card or ACH (Author You can use One Time Tokens while creating a subscription or payment profile instead of passing all bank account or credit card data directly to a given API endpoint. -To obtain a One Time Token you have to use [Chargify.js](https://developers.chargify.com/docs/developer-docs/ZG9jOjE0NjAzNDI0-overview). +To obtain a One Time Token you have to use [Chargify.js](https://docs.maxio.com/hc/en-us/articles/38163190843789-Chargify-js-Overview#chargify-js-overview-0-0). ```java GetOneTimeTokenRequest readOneTimeToken( diff --git a/doc/controllers/subscription-components.md b/doc/controllers/subscription-components.md index 35411a14..721fc2fe 100644 --- a/doc/controllers/subscription-components.md +++ b/doc/controllers/subscription-components.md @@ -1125,7 +1125,7 @@ A. No. Usage should be reported as one API call per component on a single subscr ```java UsageResponse createUsage( - final int subscriptionId, + final CreateUsageSubscriptionIdOrReference subscriptionIdOrReference, final CreateUsageComponentId componentId, final CreateUsageRequest body) ``` @@ -1134,7 +1134,7 @@ UsageResponse createUsage( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `subscriptionId` | `int` | Template, Required | The Chargify id of the subscription | +| `subscriptionIdOrReference` | [`CreateUsageSubscriptionIdOrReference`](../../doc/models/containers/create-usage-subscription-id-or-reference.md) | Template, Required | This is a container for one-of cases. | | `componentId` | [`CreateUsageComponentId`](../../doc/models/containers/create-usage-component-id.md) | Template, Required | This is a container for one-of cases. | | `body` | [`CreateUsageRequest`](../../doc/models/create-usage-request.md) | Body, Optional | - | @@ -1145,7 +1145,9 @@ UsageResponse createUsage( ## Example Usage ```java -int subscriptionId = 222; +CreateUsageSubscriptionIdOrReference subscriptionIdOrReference = CreateUsageSubscriptionIdOrReference.fromNumber( + 234 +); CreateUsageComponentId componentId = CreateUsageComponentId.fromNumber( 144 ); @@ -1159,7 +1161,7 @@ CreateUsageRequest body = new CreateUsageRequest.Builder( .build(); try { - UsageResponse result = subscriptionComponentsController.createUsage(subscriptionId, componentId, body); + UsageResponse result = subscriptionComponentsController.createUsage(subscriptionIdOrReference, componentId, body); System.out.println(result); } catch (ApiException e) { e.printStackTrace(); @@ -1219,7 +1221,7 @@ List listUsages( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `subscriptionId` | `int` | Template, Required | The Chargify id of the subscription | +| `subscriptionIdOrReference` | [`ListUsagesInputSubscriptionIdOrReference`](../../doc/models/containers/list-usages-input-subscription-id-or-reference.md) | Template, Required | This is a container for one-of cases. | | `componentId` | [`ListUsagesInputComponentId`](../../doc/models/containers/list-usages-input-component-id.md) | Template, Required | This is a container for one-of cases. | | `sinceId` | `Long` | Query, Optional | Returns usages with an id greater than or equal to the one specified | | `maxId` | `Long` | Query, Optional | Returns usages with an id less than or equal to the one specified | @@ -1236,7 +1238,9 @@ List listUsages( ```java ListUsagesInput listUsagesInput = new ListUsagesInput.Builder( - 222, + ListUsagesInputSubscriptionIdOrReference.fromNumber( + 234 + ), ListUsagesInputComponentId.fromNumber( 144 ) diff --git a/doc/controllers/subscriptions.md b/doc/controllers/subscriptions.md index 278b9386..98e33868 100644 --- a/doc/controllers/subscriptions.md +++ b/doc/controllers/subscriptions.md @@ -117,7 +117,7 @@ Custom prices and price points can exist in harmony on a subscription. ## Subscription with Chargify.js token -The `chargify_token` can be obtained using [Chargify.js](https://developers.chargify.com/docs/developer-docs/ZG9jOjE0NjAzNDI0-overview). The token represents payment profile attributes that were provided by the customer in their browser and stored at the payment gateway. +The `chargify_token` can be obtained using [Chargify.js](https://docs.maxio.com/hc/en-us/articles/38163190843789-Chargify-js-Overview#chargify-js-overview-0-0). The token represents payment profile attributes that were provided by the customer in their browser and stored at the payment gateway. The `payment_type` attribute may either be `credit_card` or `bank_account`, depending on the type of payment method being added. If a bank account is being passed, the payment attributes should be changed to `bank_account_attributes`. @@ -248,9 +248,9 @@ For more information on GoCardless, please view the following two resources: + [Full documentation on GoCardless](https://maxio.zendesk.com/hc/en-us/articles/24176159136909-GoCardless) -+ [Using Chargify.js with GoCardless - minimal example](https://developers.chargify.com/docs/developer-docs/ZG9jOjE0NjAzNDIy-examples#minimal-example-with-direct-debit-gocardless-gateway) ++ [Using Chargify.js with GoCardless - minimal example](https://docs.maxio.com/hc/en-us/articles/38206331271693-Examples#h_01K0PJ15QQZKCER8CFK40MR6XJ) -+ [Using Chargify.js with GoCardless - full example](https://developers.chargify.com/docs/developer-docs/ZG9jOjE0NjAzNDIy-examples#full-example-with-direct-debit-gocardless-gateway) ++ [Using Chargify.js with GoCardless - full example](https://docs.maxio.com/hc/en-us/articles/38206331271693-Examples#h_01K0PJ15QR09JVHWW0MCA7HVJV) ```json { @@ -310,9 +310,9 @@ For more information on Stripe Direct Debit, please view the following two resou + [Full documentation on Stripe Direct Debit](https://maxio.zendesk.com/hc/en-us/articles/24176170430093-Stripe-SEPA-and-BECS-Direct-Debit) -+ [Using Chargify.js with Stripe SEPA or BECS Direct Debit - minimal example](https://developers.chargify.com/docs/developer-docs/ZG9jOjE0NjAzNDIy-examples#minimal-example-with-sepa-or-becs-direct-debit-stripe-gateway) ++ [Using Chargify.js with Stripe SEPA or BECS Direct Debit - minimal example](https://docs.maxio.com/hc/en-us/articles/38206331271693-Examples#h_01K0PJ15QQFKKN8Z7B7DZ9AJS5) -+ [Using Chargify.js with Stripe SEPA Direct Debit - full example](https://developers.chargify.com/docs/developer-docs/ZG9jOjE0NjAzNDIy-examples#full-example-with-sepa-direct-debit-stripe-gateway) ++ [Using Chargify.js with Stripe SEPA Direct Debit - full example](https://docs.maxio.com/hc/en-us/articles/38206331271693-Examples#h_01K0PJ15QR09JVHWW0MCA7HVJV) ```json { @@ -340,9 +340,9 @@ For more information on Stripe Direct Debit, please view the following two resou + [Full documentation on Stripe Direct Debit](https://maxio.zendesk.com/hc/en-us/articles/24176170430093-Stripe-SEPA-and-BECS-Direct-Debit) -+ [Using Chargify.js with Stripe SEPA, BECS or BACS Direct Debit - minimal example](page:development-tools/chargify-js/examples#minimal-example-with-sepa-becs-or-bacs-direct-debit-stripe-gateway) ++ [Using Chargify.js with Stripe SEPA, BECS or BACS Direct Debit - minimal example](https://docs.maxio.com/hc/en-us/articles/38206331271693-Examples#h_01K0PJ15QQFKKN8Z7B7DZ9AJS5) -+ [Using Chargify.js with Stripe BECS Direct Debit - full example](page:development-tools/chargify-js/examples#full-example-with-becs-direct-debit-stripe-gateway) ++ [Using Chargify.js with Stripe BECS Direct Debit - full example](https://docs.maxio.com/hc/en-us/articles/38206331271693-Examples#h_01K0PJ15QRX4B1TYZKZD8ZND6D) ```json { @@ -371,9 +371,9 @@ For more information on Stripe Direct Debit, please view the following two resou + [Full documentation on Stripe Direct Debit](https://maxio.zendesk.com/hc/en-us/articles/24176170430093-Stripe-SEPA-and-BECS-Direct-Debit) -+ [Using Chargify.js with Stripe SEPA, BECS or BACS Direct Debit - minimal example](page:development-tools/chargify-js/examples#minimal-example-with-sepa-becs-or-bacs-direct-debit-stripe-gateway) ++ [Using Chargify.js with Stripe SEPA, BECS or BACS Direct Debit - minimal example](https://docs.maxio.com/hc/en-us/articles/38206331271693-Examples#h_01K0PJ15QQFKKN8Z7B7DZ9AJS5) -+ [Using Chargify.js with Stripe BACS Direct Debit - full example](page:development-tools/chargify-js/examples#full-example-with-bacs-direct-debit-stripe-gateway) ++ [Using Chargify.js with Stripe BACS Direct Debit - full example](https://docs.maxio.com/hc/en-us/articles/38206331271693-Examples#h_01K0PJ15QR7PA1DJ3XE9MD05FM) ```json { diff --git a/doc/controllers/webhooks.md b/doc/controllers/webhooks.md index 30aa1bf8..00e87421 100644 --- a/doc/controllers/webhooks.md +++ b/doc/controllers/webhooks.md @@ -20,20 +20,7 @@ WebhooksController webhooksController = client.getWebhooksController(); # List Webhooks -## Webhooks Intro - -The Webhooks API allows you to view a list of all webhooks and to selectively resend individual or groups of webhooks. Webhooks will be sent on endpoints specified by you. Endpoints can be added via API or Web UI. There is also an option to enable / disable webhooks via API request. - -We recommend that you review Advanced Billing's webhook documentation located in our help site. The following resources will help guide you on how to use webhooks in Advanced Billing, in addition to these webhook endpoints: - -+ [Adding/editing new webhooks](https://maxio.zendesk.com/hc/en-us/articles/24286723085197-Webhooks#configure-webhook-url) -+ [Webhooks introduction and delivery information](https://maxio.zendesk.com/hc/en-us/articles/24266143173901-Webhooks-Overview) -+ [Main webhook reference](https://maxio.zendesk.com/hc/en-us/articles/24266136649869-Webhooks-Reference) -+ [Available webhooks and payloads](https://maxio.zendesk.com/hc/en-us/articles/24266136649869-Webhooks-Reference#events) - -## List Webhooks for a Site - -This method allows you to fetch data about webhooks. You can pass query parameters if you want to filter webhooks. +Allows you to view a list of webhooks. You can pass query parameters if you want to filter webhooks. See the [Webhooks](page:introduction/webhooks/webhooks) documentation for more information. ```java List listWebhooks( @@ -116,7 +103,7 @@ try { # Enable Webhooks -This method allows you to enable webhooks via API for your site +Allows you to enable webhooks for your site ```java EnableWebhooksResponse enableWebhooks( @@ -162,9 +149,7 @@ try { # Replay Webhooks -Posting to the replay endpoint does not immediately resend the webhooks. They are added to a queue and will be sent as soon as possible, depending on available system resources. - -You may submit an array of up to 1000 webhook IDs to replay in the request. +Replays webhooks. Posting to this endpoint does not immediately resend the webhooks. They are added to a queue and sent as soon as possible, depending on available system resources. You can submit an array of up to 1000 webhook IDs in the replay request. ```java ReplayWebhooksResponse replayWebhooks( @@ -213,10 +198,8 @@ try { # Create Endpoint -The Chargify API allows you to create an endpoint and assign a list of webhooks subscriptions (events) to it. - -You can check available events here. -[Event keys](https://maxio.zendesk.com/hc/en-us/articles/24266136649869-Webhooks-Reference#events) +Creates an endpoint and assigns a list of webhooks subscriptions (events) to it. +See the [Webhooks Reference](page:introduction/webhooks/webhooks-reference#events) page for available events. ```java EndpointResponse createEndpoint( @@ -284,7 +267,7 @@ try { # List Endpoints -This method returns created endpoints for site. +Returns created endpoints for a site. ```java List listEndpoints() @@ -338,15 +321,11 @@ try { # Update Endpoint -You can update an Endpoint via the API with a PUT request to the resource endpoint. - -You can change the `url` of your endpoint which consumes webhooks or list of `webhook_subscriptions`. -Check available [Event keys](https://maxio.zendesk.com/hc/en-us/articles/24266136649869-Webhooks-Reference#events). +Updates an Endpoint. You can change the `url` of your endpoint or the list of `webhook_subscriptions` to which you are subscribed. See the [Webhooks Reference](page:introduction/webhooks/webhooks-reference#events) page for available events. -Always send a complete list of events which you want subscribe/watch. -Sending an PUT request for existing endpoint with empty list of `webhook_subscriptions` will end with unsubscribe from all events. +Always send a complete list of events to which you want to subscribe. Sending a PUT request for an existing endpoint with an empty list of `webhook_subscriptions` will unsubscribe all events. -If you want unsubscribe from specific event, just send a list of `webhook_subscriptions` without the specific event key. +If you want unsubscribe from a specific event, send a list of `webhook_subscriptions` without the specific event key. ```java EndpointResponse updateEndpoint( @@ -371,7 +350,7 @@ EndpointResponse updateEndpoint( int endpointId = 42; CreateOrUpdateEndpointRequest body = new CreateOrUpdateEndpointRequest.Builder( new CreateOrUpdateEndpoint.Builder( - "https://yout.site/webhooks/1/json.", + "https://your.site/webhooks/1/json.", Arrays.asList( WebhookSubscription.PAYMENT_FAILURE, WebhookSubscription.PAYMENT_SUCCESS, diff --git a/doc/http-client-configuration-builder.md b/doc/http-client-configuration-builder.md index 27777c38..e631b75d 100644 --- a/doc/http-client-configuration-builder.md +++ b/doc/http-client-configuration-builder.md @@ -23,5 +23,6 @@ Class to build instances of [HttpClientConfiguration](../doc/http-client-configu | `shouldRetryOnTimeout(boolean shouldRetryOnTimeout)` | Sets whether to retry on request timeout. | `HttpClientConfiguration.Builder` | | `httpClientInstance(okhttp3.OkHttpClient httpClientInstance)` | Sets the okhttpclient instance used to make the http calls. | `HttpClientConfiguration.Builder` | | `httpClientInstance(okhttp3.OkHttpClient httpClientInstance, boolean overrideHttpClientConfigurations)` | Sets the okhttpclient instance used to make the http calls and an option to Allow the SDK to override HTTP client instance's settings used for features like retries, timeouts etc. | `HttpClientConfiguration.Builder` | +| proxyConfig([HttpProxyConfiguration.Builder](../doc/http-proxy-configuration-builder.md) proxyBuilder) | Sets the proxy configuration for the underlying HTTP client. | `HttpClientConfiguration.Builder` | | `build()` | Builds a new HttpClientConfiguration object using the set fields. | [`HttpClientConfiguration`](../doc/http-client-configuration.md) | diff --git a/doc/http-client-configuration.md b/doc/http-client-configuration.md index eabd480e..4189cd7d 100644 --- a/doc/http-client-configuration.md +++ b/doc/http-client-configuration.md @@ -17,6 +17,7 @@ Class for holding http client configuration. | `shouldRetryOnTimeout()` | Whether to retry on request timeout. | `boolean` | | `getHttpClientInstance()` | The OkHttpClient instance used to make the HTTP calls. | `okhttp3.OkHttpClient` | | `shouldOverrideHttpClientConfigurations()` | Allow the SDK to override HTTP client instance's settings used for features like retries, timeouts etc. | `boolean` | +| `getProxyConfig()` | The proxy configuration settings used by the HTTP client. | [`HttpProxyConfiguration`](../doc/http-proxy-configuration.md) | | `toString()` | Converts this HttpClientConfiguration into string format. | `String` | | `newBuilder()` | Builds a new {@link HttpClientConfiguration.Builder} object. Creates the instance with the current state. | [`HttpClientConfiguration.Builder`](../doc/http-client-configuration-builder.md) | diff --git a/doc/http-proxy-configuration-builder.md b/doc/http-proxy-configuration-builder.md new file mode 100644 index 00000000..3d5f6e30 --- /dev/null +++ b/doc/http-proxy-configuration-builder.md @@ -0,0 +1,36 @@ + +# HttpProxyConfiguration.Builder + +Class to build instances of [HttpProxyConfiguration](../doc/http-proxy-configuration.md). + +## Constructors + +| Name | Description | +| --- | --- | +| `Builder()` | Default Constructor to initiate builder with default properties. | + +## Methods + +| Name | Description | Return Type | +| --- | --- | --- | +| `Builder(String address, int port)` | Constructs HttpProxyConfiguration.Builder with proxy address and port. | `HttpProxyConfiguration.Builder` | +| `auth(String username, String password)` | Sets the username and password for proxy auth. | `HttpProxyConfiguration.Builder` | +| `build()` | Builds a new HttpProxyConfiguration object using the set fields. | [`HttpProxyConfiguration`](../doc/http-proxy-configuration.md) | + +### Client Initialization with Proxy Configuration + +To configure the SDK to use a proxy server, initialize the proxy configuration during client setup as shown in the Usage Example. + +## Usage Example + +```java +import com.maxio.advancedbilling.AdvancedBillingClient; +import com.maxio.advancedbilling.http.client.HttpProxyConfiguration; + +AdvancedBillingClient client = new AdvancedBillingClient.Builder() + .httpClientConfig(configBuilder -> configBuilder + .proxyConfig(new HttpProxyConfiguration.Builder("http://localhost", + 8080).auth("username", "password"))) + .build(); +``` + diff --git a/doc/http-proxy-configuration.md b/doc/http-proxy-configuration.md new file mode 100644 index 00000000..a04f59a7 --- /dev/null +++ b/doc/http-proxy-configuration.md @@ -0,0 +1,16 @@ + +# HttpProxyConfiguration + +Class for holding http proxy configuration. + +## Methods + +| Name | Description | Return Type | +| --- | --- | --- | +| `getAddress()` | The proxy server address. | `String` | +| `getPort()` | The proxy server port. | `String` | +| `getUsername()` | The username used for proxy authentication. | `String` | +| `getPassword()` | The password used for proxy authentication. | `String` | +| `toString()` | Converts this HttpProxyConfiguration into string format. | `String` | +| `newBuilder()` | Builds a new HttpProxyConfiguration.Builder object. Creates the instance with the current state. | [`HttpProxyConfiguration.Builder`](../doc/http-proxy-configuration-builder.md) | + diff --git a/doc/models/containers/create-usage-subscription-id-or-reference.md b/doc/models/containers/create-usage-subscription-id-or-reference.md new file mode 100644 index 00000000..f5d95f14 --- /dev/null +++ b/doc/models/containers/create-usage-subscription-id-or-reference.md @@ -0,0 +1,14 @@ + +# Create Usage Subscription Id or Reference + +## Class Name + +`CreateUsageSubscriptionIdOrReference` + +## Cases + +| Type | Factory Method | +| --- | --- | +| `int` | CreateUsageSubscriptionIdOrReference.fromNumber(int number) | +| `String` | CreateUsageSubscriptionIdOrReference.fromString(String string) | + diff --git a/doc/models/containers/list-usages-input-subscription-id-or-reference.md b/doc/models/containers/list-usages-input-subscription-id-or-reference.md new file mode 100644 index 00000000..45379586 --- /dev/null +++ b/doc/models/containers/list-usages-input-subscription-id-or-reference.md @@ -0,0 +1,14 @@ + +# List Usages Input Subscription Id or Reference + +## Class Name + +`ListUsagesInputSubscriptionIdOrReference` + +## Cases + +| Type | Factory Method | +| --- | --- | +| `int` | ListUsagesInputSubscriptionIdOrReference.fromNumber(int number) | +| `String` | ListUsagesInputSubscriptionIdOrReference.fromString(String string) | + diff --git a/pom.xml b/pom.xml index c2640442..6aceff1d 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ 4.0.0 com.maxio advanced-billing-sdk - 7.0.0 + 7.0.1 jar Advanced Billing SDK Ultimate billing and pricing flexibility for B2B SaaS. @@ -43,17 +43,17 @@ Maxio integrates directly into your product, so you can seamlessly manage your p io.apimatic core-interfaces - [0.3.1, 0.4) + [0.3.3, 0.4) io.apimatic core - [0.6.12, 0.7) + [0.6.13, 0.7) io.apimatic okhttp-client-adapter - [0.3.1, 0.4) + [0.3.5, 0.4) diff --git a/src/main/java/com/maxio/advancedbilling/AdvancedBillingClient.java b/src/main/java/com/maxio/advancedbilling/AdvancedBillingClient.java index 50a2ea08..bd5393e7 100644 --- a/src/main/java/com/maxio/advancedbilling/AdvancedBillingClient.java +++ b/src/main/java/com/maxio/advancedbilling/AdvancedBillingClient.java @@ -99,7 +99,7 @@ public final class AdvancedBillingClient implements Configuration { private static final CompatibilityFactory compatibilityFactory = new CompatibilityFactoryImpl(); - private static String userAgent = "AB SDK Java:7.0.0 on OS {os-info}"; + private static String userAgent = "AB SDK Java:7.0.1 on OS {os-info}"; /** * Current API environment. diff --git a/src/main/java/com/maxio/advancedbilling/controllers/ComponentPricePointsController.java b/src/main/java/com/maxio/advancedbilling/controllers/ComponentPricePointsController.java index 60591044..e1c54496 100644 --- a/src/main/java/com/maxio/advancedbilling/controllers/ComponentPricePointsController.java +++ b/src/main/java/com/maxio/advancedbilling/controllers/ComponentPricePointsController.java @@ -100,7 +100,7 @@ private ApiCall preparePromoteComponentPricePoi } /** - * This endpoint can be used to create a new price point for an existing component. + * Creates a price point for an existing component. * @param componentId Required parameter: The Advanced Billing id of the component * @param body Optional parameter: * @return Returns the ComponentPricePointResponse response from the API call diff --git a/src/main/java/com/maxio/advancedbilling/controllers/ComponentsController.java b/src/main/java/com/maxio/advancedbilling/controllers/ComponentsController.java index 4a019a2a..17799b35 100644 --- a/src/main/java/com/maxio/advancedbilling/controllers/ComponentsController.java +++ b/src/main/java/com/maxio/advancedbilling/controllers/ComponentsController.java @@ -378,9 +378,9 @@ private ApiCall prepareFindComponentRequest( } /** - * This request will return information regarding a component from a specific product family. - * You may read the component by either the component's id or handle. When using the handle, it - * must be prefixed with `handle:`. + * Returns information regarding a component from a specific product family. You can read the + * component by either the component's id or handle. When using the handle, it must be prefixed + * with `handle:`. * @param productFamilyId Required parameter: The Advanced Billing id of the product family to * which the component belongs * @param componentId Required parameter: Either the Advanced Billing id of the component or diff --git a/src/main/java/com/maxio/advancedbilling/controllers/CustomersController.java b/src/main/java/com/maxio/advancedbilling/controllers/CustomersController.java index 63d0fa6c..c05b33b5 100644 --- a/src/main/java/com/maxio/advancedbilling/controllers/CustomersController.java +++ b/src/main/java/com/maxio/advancedbilling/controllers/CustomersController.java @@ -160,8 +160,7 @@ private ApiCall, ApiException> prepareListCustomersReques } /** - * This method allows to retrieve the Customer properties by Advanced Billing-generated Customer - * ID. + * Retrieves the Customer properties by Advanced Billing-generated Customer ID. * @param id Required parameter: The Advanced Billing id of the customer * @return Returns the CustomerResponse response from the API call * @throws ApiException Represents error response from the server. diff --git a/src/main/java/com/maxio/advancedbilling/controllers/PaymentProfilesController.java b/src/main/java/com/maxio/advancedbilling/controllers/PaymentProfilesController.java index 58324178..615c826b 100644 --- a/src/main/java/com/maxio/advancedbilling/controllers/PaymentProfilesController.java +++ b/src/main/java/com/maxio/advancedbilling/controllers/PaymentProfilesController.java @@ -84,9 +84,9 @@ public PaymentProfilesController(GlobalConfiguration globalConfig) { * following resources: + [Full documentation on * GoCardless](https://maxio.zendesk.com/hc/en-us/articles/24176159136909-GoCardless) + [Using * Chargify.js with GoCardless - minimal - * example](https://developers.chargify.com/docs/developer-docs/ZG9jOjE0NjAzNDIy-examples#minimal-example-with-direct-debit-gocardless-gateway) + * example](https://docs.maxio.com/hc/en-us/articles/38206331271693-Examples#h_01K0PJ15QQZKCER8CFK40MR6XJ) * + [Using Chargify.js with GoCardless - full - * example](https://developers.chargify.com/docs/developer-docs/ZG9jOjE0NjAzNDIy-examples#full-example-with-direct-debit-gocardless-gateway) + * example](https://docs.maxio.com/hc/en-us/articles/38206331271693-Examples#h_01K0PJ15QR09JVHWW0MCA7HVJV) * ### GoCardless with Local Bank Details Following examples create customer, bank account and * mandate in GoCardless: ```json { "payment_profile": { "customer_id": "Valid-Customer-ID", * "bank_name": "Royal Bank of France", "bank_account_number": "0000000", "bank_routing_number": @@ -112,9 +112,9 @@ public PaymentProfilesController(GlobalConfiguration globalConfig) { * resources: + [Full documentation on Stripe SEPA Direct * Debit](https://maxio.zendesk.com/hc/en-us/articles/24176170430093-Stripe-SEPA-and-BECS-Direct-Debit) * + [Using Chargify.js with Stripe Direct Debit - minimal - * example](https://developers.chargify.com/docs/developer-docs/ZG9jOjE0NjAzNDIy-examples#minimal-example-with-sepa-or-becs-direct-debit-stripe-gateway) + * example](https://docs.maxio.com/hc/en-us/articles/38206331271693-Examples#h_01K0PJ15QQFKKN8Z7B7DZ9AJS5) * + [Using Chargify.js with Stripe Direct Debit - full - * example](https://developers.chargify.com/docs/developer-docs/ZG9jOjE0NjAzNDIy-examples#full-example-with-sepa-direct-debit-stripe-gateway) + * example](https://docs.maxio.com/hc/en-us/articles/38206331271693-Examples#h_01K0PJ15QRECQQ4ECS3ZA55GY7) * ### Stripe SEPA Direct Debit Payment Profiles The following example creates a customer, bank * account and mandate in Stripe: ```json { "payment_profile": { "customer_id": "24907598", * "bank_name": "Deutsche bank", "bank_iban": "DE89370400440532013000", "payment_type": @@ -673,7 +673,7 @@ private ApiCall prepareChangeSubscriptionG * Stripe only) data for a customer. You can use One Time Tokens while creating a subscription * or payment profile instead of passing all bank account or credit card data directly to a * given API endpoint. To obtain a One Time Token you have to use - * [Chargify.js](https://developers.chargify.com/docs/developer-docs/ZG9jOjE0NjAzNDI0-overview). + * [Chargify.js](https://docs.maxio.com/hc/en-us/articles/38163190843789-Chargify-js-Overview#chargify-js-overview-0-0). * @param chargifyToken Required parameter: Advanced Billing Token * @return Returns the GetOneTimeTokenRequest response from the API call * @throws ApiException Represents error response from the server. diff --git a/src/main/java/com/maxio/advancedbilling/controllers/SubscriptionComponentsController.java b/src/main/java/com/maxio/advancedbilling/controllers/SubscriptionComponentsController.java index 053d403e..d9d4ab27 100644 --- a/src/main/java/com/maxio/advancedbilling/controllers/SubscriptionComponentsController.java +++ b/src/main/java/com/maxio/advancedbilling/controllers/SubscriptionComponentsController.java @@ -35,6 +35,7 @@ import com.maxio.advancedbilling.models.UpdateAllocationExpirationDate; import com.maxio.advancedbilling.models.UsageResponse; import com.maxio.advancedbilling.models.containers.CreateUsageComponentId; +import com.maxio.advancedbilling.models.containers.CreateUsageSubscriptionIdOrReference; import io.apimatic.core.ApiCall; import io.apimatic.core.ErrorCase; import io.apimatic.core.GlobalConfiguration; @@ -692,7 +693,12 @@ private ApiCall prepareDeletePrepaidUsageAllocationRequest( * time? A. No. Usage should be reported as one API call per component on a single subscription. * For example, to record that a subscriber has sent both an SMS Message and an Email, send an * API call for each. - * @param subscriptionId Required parameter: The Chargify id of the subscription + * @param subscriptionIdOrReference Required parameter: Either the Advanced Billing + * subscription ID (integer) or the subscription reference (string). Important: In cases + * where a numeric string value matches both an existing subscription ID and an existing + * subscription reference, the system will prioritize the subscription ID lookup. For + * example, if both subscription ID 123 and subscription reference "123" exist, passing + * "123" will return the subscription with ID 123. * @param componentId Required parameter: Either the Advanced Billing id for the component or * the component's handle prefixed by `handle:` * @param body Optional parameter: @@ -701,27 +707,27 @@ private ApiCall prepareDeletePrepaidUsageAllocationRequest( * @throws IOException Signals that an I/O exception of some sort has occurred. */ public UsageResponse createUsage( - final int subscriptionId, + final CreateUsageSubscriptionIdOrReference subscriptionIdOrReference, final CreateUsageComponentId componentId, final CreateUsageRequest body) throws ApiException, IOException { - return prepareCreateUsageRequest(subscriptionId, componentId, body).execute(); + return prepareCreateUsageRequest(subscriptionIdOrReference, componentId, body).execute(); } /** * Builds the ApiCall object for createUsage. */ private ApiCall prepareCreateUsageRequest( - final int subscriptionId, + final CreateUsageSubscriptionIdOrReference subscriptionIdOrReference, final CreateUsageComponentId componentId, final CreateUsageRequest body) { return new ApiCall.Builder() .globalConfig(getGlobalConfiguration()) .requestBuilder(requestBuilder -> requestBuilder .server(Server.PRODUCTION.value()) - .path("/subscriptions/{subscription_id}/components/{component_id}/usages.json") + .path("/subscriptions/{subscription_id_or_reference}/components/{component_id}/usages.json") .bodyParam(param -> param.value(body).isRequired(false)) .bodySerializer(() -> ApiHelper.serialize(body)) - .templateParam(param -> param.key("subscription_id").value(subscriptionId).isRequired(false) + .templateParam(param -> param.key("subscription_id_or_reference").value(subscriptionIdOrReference) .shouldEncode(true)) .templateParam(param -> param.key("component_id").value(componentId) .shouldEncode(true)) @@ -772,7 +778,7 @@ private ApiCall, ApiException> prepareListUsagesRequest( .globalConfig(getGlobalConfiguration()) .requestBuilder(requestBuilder -> requestBuilder .server(Server.PRODUCTION.value()) - .path("/subscriptions/{subscription_id}/components/{component_id}/usages.json") + .path("/subscriptions/{subscription_id_or_reference}/components/{component_id}/usages.json") .queryParam(param -> param.key("since_id") .value(input.getSinceId()).isRequired(false)) .queryParam(param -> param.key("max_id") @@ -785,7 +791,7 @@ private ApiCall, ApiException> prepareListUsagesRequest( .value(input.getPage()).isRequired(false)) .queryParam(param -> param.key("per_page") .value(input.getPerPage()).isRequired(false)) - .templateParam(param -> param.key("subscription_id").value(input.getSubscriptionId()).isRequired(false) + .templateParam(param -> param.key("subscription_id_or_reference").value(input.getSubscriptionIdOrReference()) .shouldEncode(true)) .templateParam(param -> param.key("component_id").value(input.getComponentId()) .shouldEncode(true)) diff --git a/src/main/java/com/maxio/advancedbilling/controllers/SubscriptionsController.java b/src/main/java/com/maxio/advancedbilling/controllers/SubscriptionsController.java index 3e8958c6..43704145 100644 --- a/src/main/java/com/maxio/advancedbilling/controllers/SubscriptionsController.java +++ b/src/main/java/com/maxio/advancedbilling/controllers/SubscriptionsController.java @@ -133,7 +133,7 @@ public SubscriptionsController(GlobalConfiguration globalConfig) { * `custom_price` object within the component object. Custom prices and price points can exist * in harmony on a subscription. # Passing Payment Information ## Subscription with Chargify.js * token The `chargify_token` can be obtained using - * [Chargify.js](https://developers.chargify.com/docs/developer-docs/ZG9jOjE0NjAzNDI0-overview). + * [Chargify.js](https://docs.maxio.com/hc/en-us/articles/38163190843789-Chargify-js-Overview#chargify-js-overview-0-0). * The token represents payment profile attributes that were provided by the customer in their * browser and stored at the payment gateway. The `payment_type` attribute may either be * `credit_card` or `bank_account`, depending on the type of payment method being added. If a @@ -174,9 +174,9 @@ public SubscriptionsController(GlobalConfiguration globalConfig) { * + [Full documentation on * GoCardless](https://maxio.zendesk.com/hc/en-us/articles/24176159136909-GoCardless) + [Using * Chargify.js with GoCardless - minimal - * example](https://developers.chargify.com/docs/developer-docs/ZG9jOjE0NjAzNDIy-examples#minimal-example-with-direct-debit-gocardless-gateway) + * example](https://docs.maxio.com/hc/en-us/articles/38206331271693-Examples#h_01K0PJ15QQZKCER8CFK40MR6XJ) * + [Using Chargify.js with GoCardless - full - * example](https://developers.chargify.com/docs/developer-docs/ZG9jOjE0NjAzNDIy-examples#full-example-with-direct-debit-gocardless-gateway) + * example](https://docs.maxio.com/hc/en-us/articles/38206331271693-Examples#h_01K0PJ15QR09JVHWW0MCA7HVJV) * ```json { "subscription": { "product_handle": "gold-product", "customer_attributes": { * "first_name": "Jane", "last_name": "Doe", "email": "jd{@literal @}chargify.test" }, * "bank_account_attributes": { "bank_name": "Royal Bank of France", "bank_account_number": @@ -195,9 +195,9 @@ public SubscriptionsController(GlobalConfiguration globalConfig) { * + [Full documentation on Stripe Direct * Debit](https://maxio.zendesk.com/hc/en-us/articles/24176170430093-Stripe-SEPA-and-BECS-Direct-Debit) * + [Using Chargify.js with Stripe SEPA or BECS Direct Debit - minimal - * example](https://developers.chargify.com/docs/developer-docs/ZG9jOjE0NjAzNDIy-examples#minimal-example-with-sepa-or-becs-direct-debit-stripe-gateway) + * example](https://docs.maxio.com/hc/en-us/articles/38206331271693-Examples#h_01K0PJ15QQFKKN8Z7B7DZ9AJS5) * + [Using Chargify.js with Stripe SEPA Direct Debit - full - * example](https://developers.chargify.com/docs/developer-docs/ZG9jOjE0NjAzNDIy-examples#full-example-with-sepa-direct-debit-stripe-gateway) + * example](https://docs.maxio.com/hc/en-us/articles/38206331271693-Examples#h_01K0PJ15QR09JVHWW0MCA7HVJV) * ```json { "subscription": { "product_handle": "gold-product", "customer_attributes": { * "first_name": "Jane", "last_name": "Doe", "email": "jd{@literal @}chargify.test" }, * "bank_account_attributes": { "bank_name": "Test Bank", "bank_iban": "DE89370400440532013000", @@ -207,9 +207,9 @@ public SubscriptionsController(GlobalConfiguration globalConfig) { * [Full documentation on Stripe Direct * Debit](https://maxio.zendesk.com/hc/en-us/articles/24176170430093-Stripe-SEPA-and-BECS-Direct-Debit) * + [Using Chargify.js with Stripe SEPA, BECS or BACS Direct Debit - minimal - * example](page:development-tools/chargify-js/examples#minimal-example-with-sepa-becs-or-bacs-direct-debit-stripe-gateway) + * example](https://docs.maxio.com/hc/en-us/articles/38206331271693-Examples#h_01K0PJ15QQFKKN8Z7B7DZ9AJS5) * + [Using Chargify.js with Stripe BECS Direct Debit - full - * example](page:development-tools/chargify-js/examples#full-example-with-becs-direct-debit-stripe-gateway) + * example](https://docs.maxio.com/hc/en-us/articles/38206331271693-Examples#h_01K0PJ15QRX4B1TYZKZD8ZND6D) * ```json { "subscription": { "product_handle": "gold-product", "customer_attributes": { * "first_name": "Jane", "last_name": "Doe", "email": "jd{@literal @}chargify.test" }, * "bank_account_attributes": { "bank_name": "Test Bank", "bank_branch_code": "000000", @@ -219,9 +219,9 @@ public SubscriptionsController(GlobalConfiguration globalConfig) { * Debit]($e/Payment%20Profiles/createPaymentProfile) + [Full documentation on Stripe Direct * Debit](https://maxio.zendesk.com/hc/en-us/articles/24176170430093-Stripe-SEPA-and-BECS-Direct-Debit) * + [Using Chargify.js with Stripe SEPA, BECS or BACS Direct Debit - minimal - * example](page:development-tools/chargify-js/examples#minimal-example-with-sepa-becs-or-bacs-direct-debit-stripe-gateway) + * example](https://docs.maxio.com/hc/en-us/articles/38206331271693-Examples#h_01K0PJ15QQFKKN8Z7B7DZ9AJS5) * + [Using Chargify.js with Stripe BACS Direct Debit - full - * example](page:development-tools/chargify-js/examples#full-example-with-bacs-direct-debit-stripe-gateway) + * example](https://docs.maxio.com/hc/en-us/articles/38206331271693-Examples#h_01K0PJ15QR7PA1DJ3XE9MD05FM) * ```json { "subscription": { "product_handle": "gold-product", "customer_attributes": { * "first_name": "Jane", "last_name": "Doe", "email": "jd{@literal @}chargify.test" }, * "bank_account_attributes": { "bank_name": "Test Bank", "bank_branch_code": "108800", diff --git a/src/main/java/com/maxio/advancedbilling/controllers/WebhooksController.java b/src/main/java/com/maxio/advancedbilling/controllers/WebhooksController.java index 3d58eed5..b976c46c 100644 --- a/src/main/java/com/maxio/advancedbilling/controllers/WebhooksController.java +++ b/src/main/java/com/maxio/advancedbilling/controllers/WebhooksController.java @@ -41,22 +41,9 @@ public WebhooksController(GlobalConfiguration globalConfig) { } /** - * ## Webhooks Intro The Webhooks API allows you to view a list of all webhooks and to - * selectively resend individual or groups of webhooks. Webhooks will be sent on endpoints - * specified by you. Endpoints can be added via API or Web UI. There is also an option to enable - * / disable webhooks via API request. We recommend that you review Advanced Billing's webhook - * documentation located in our help site. The following resources will help guide you on how to - * use webhooks in Advanced Billing, in addition to these webhook endpoints: + [Adding/editing - * new - * webhooks](https://maxio.zendesk.com/hc/en-us/articles/24286723085197-Webhooks#configure-webhook-url) - * + [Webhooks introduction and delivery - * information](https://maxio.zendesk.com/hc/en-us/articles/24266143173901-Webhooks-Overview) + - * [Main webhook - * reference](https://maxio.zendesk.com/hc/en-us/articles/24266136649869-Webhooks-Reference) + - * [Available webhooks and - * payloads](https://maxio.zendesk.com/hc/en-us/articles/24266136649869-Webhooks-Reference#events) - * ## List Webhooks for a Site This method allows you to fetch data about webhooks. You can pass - * query parameters if you want to filter webhooks. + * Allows you to view a list of webhooks. You can pass query parameters if you want to filter + * webhooks. See the [Webhooks](page:introduction/webhooks/webhooks) documentation for more + * information. * @param input ListWebhooksInput object containing request parameters * @return Returns the List of WebhookResponse response from the API call * @throws ApiException Represents error response from the server. @@ -106,7 +93,7 @@ private ApiCall, ApiException> prepareListWebhooksRequest( } /** - * This method allows you to enable webhooks via API for your site. + * Allows you to enable webhooks for your site. * @param body Optional parameter: * @return Returns the EnableWebhooksResponse response from the API call * @throws ApiException Represents error response from the server. @@ -145,9 +132,9 @@ private ApiCall prepareEnableWebhooksReque } /** - * Posting to the replay endpoint does not immediately resend the webhooks. They are added to a - * queue and will be sent as soon as possible, depending on available system resources. You may - * submit an array of up to 1000 webhook IDs to replay in the request. + * Replays webhooks. Posting to this endpoint does not immediately resend the webhooks. They are + * added to a queue and sent as soon as possible, depending on available system resources. You + * can submit an array of up to 1000 webhook IDs in the replay request. * @param body Optional parameter: * @return Returns the ReplayWebhooksResponse response from the API call * @throws ApiException Represents error response from the server. @@ -186,9 +173,9 @@ private ApiCall prepareReplayWebhooksReque } /** - * The Chargify API allows you to create an endpoint and assign a list of webhooks subscriptions - * (events) to it. You can check available events here. [Event - * keys](https://maxio.zendesk.com/hc/en-us/articles/24266136649869-Webhooks-Reference#events). + * Creates an endpoint and assigns a list of webhooks subscriptions (events) to it. See the + * [Webhooks Reference](page:introduction/webhooks/webhooks-reference#events) page for available + * events. * @param body Optional parameter: * @return Returns the EndpointResponse response from the API call * @throws ApiException Represents error response from the server. @@ -230,7 +217,7 @@ private ApiCall prepareCreateEndpointRequest( } /** - * This method returns created endpoints for site. + * Returns created endpoints for a site. * @return Returns the List of Endpoint response from the API call * @throws ApiException Represents error response from the server. * @throws IOException Signals that an I/O exception of some sort has occurred. @@ -263,14 +250,13 @@ private ApiCall, ApiException> prepareListEndpointsRequest() { } /** - * You can update an Endpoint via the API with a PUT request to the resource endpoint. You can - * change the `url` of your endpoint which consumes webhooks or list of `webhook_subscriptions`. - * Check available [Event - * keys](https://maxio.zendesk.com/hc/en-us/articles/24266136649869-Webhooks-Reference#events). - * Always send a complete list of events which you want subscribe/watch. Sending an PUT request - * for existing endpoint with empty list of `webhook_subscriptions` will end with unsubscribe - * from all events. If you want unsubscribe from specific event, just send a list of - * `webhook_subscriptions` without the specific event key. + * Updates an Endpoint. You can change the `url` of your endpoint or the list of + * `webhook_subscriptions` to which you are subscribed. See the [Webhooks + * Reference](page:introduction/webhooks/webhooks-reference#events) page for available events. + * Always send a complete list of events to which you want to subscribe. Sending a PUT request + * for an existing endpoint with an empty list of `webhook_subscriptions` will unsubscribe all + * events. If you want unsubscribe from a specific event, send a list of `webhook_subscriptions` + * without the specific event key. * @param endpointId Required parameter: The Advanced Billing id for the endpoint that should * be updated * @param body Optional parameter: diff --git a/src/main/java/com/maxio/advancedbilling/http/client/HttpClientConfiguration.java b/src/main/java/com/maxio/advancedbilling/http/client/HttpClientConfiguration.java index 76506104..be56d7fc 100644 --- a/src/main/java/com/maxio/advancedbilling/http/client/HttpClientConfiguration.java +++ b/src/main/java/com/maxio/advancedbilling/http/client/HttpClientConfiguration.java @@ -12,6 +12,7 @@ import io.apimatic.coreinterfaces.http.HttpMethodType; import io.apimatic.coreinterfaces.http.Method; import java.util.Set; +import java.util.function.Supplier; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -21,11 +22,19 @@ public class HttpClientConfiguration implements ReadonlyHttpClientConfiguration { private final ClientConfiguration configuration; + private final ReadonlyHttpProxyConfiguration proxyConfiguration; /** * Default Constructor. */ - private HttpClientConfiguration(CoreHttpClientConfiguration.Builder configurationBuilder) { + private HttpClientConfiguration(CoreHttpClientConfiguration.Builder configurationBuilder, + HttpProxyConfiguration.Builder proxyConfiguration){ + this.proxyConfiguration = proxyConfiguration != null ? proxyConfiguration.build() : null; + + if (proxyConfiguration != null) { + configurationBuilder.proxyConfiguration(proxyConfiguration.build().getConfiguration()); + } + this.configuration = configurationBuilder.build(); } @@ -115,6 +124,15 @@ public boolean shouldOverrideHttpClientConfigurations() { return configuration.shouldOverrideHttpClientConfigurations(); } + + /** + * Retrieves the proxy configuration settings used by the HTTP client. + * @return the {@link ReadonlyHttpProxyConfiguration} containing the configured proxy settings + */ + public ReadonlyHttpProxyConfiguration getProxyConfig() { + return this.proxyConfiguration; + } + /** * Returns the ClientConfiguration instance. * @return ClientConfiguration @@ -136,7 +154,7 @@ public String toString() { + ", maximumRetryWaitTime=" + getMaximumRetryWaitTime() + ", shouldRetryOnTimeout=" + shouldRetryOnTimeout() + ", httpClientInstance=" + getHttpClientInstance() + ", overrideHttpClientConfigurations=" + shouldOverrideHttpClientConfigurations() - + "]"; + + ", proxyConfig=" + getProxyConfig() + "]"; } /** @@ -155,7 +173,11 @@ public Builder newBuilder() { .httpMethodsToRetry(getHttpMethodsToRetry()) .maximumRetryWaitTime(getMaximumRetryWaitTime()) .shouldRetryOnTimeout(shouldRetryOnTimeout()) - .httpClientInstance(getHttpClientInstance(), shouldOverrideHttpClientConfigurations()); + .httpClientInstance(getHttpClientInstance(), shouldOverrideHttpClientConfigurations()) + .proxyConfig(() -> { + HttpProxyConfiguration proxyConfig = (HttpProxyConfiguration) getProxyConfig(); + return proxyConfig != null ? proxyConfig.newBuilder() : null; + }); } /** @@ -166,6 +188,8 @@ public static class Builder { private final CoreHttpClientConfiguration.Builder configurationBuilder = new CoreHttpClientConfiguration.Builder(); + private HttpProxyConfiguration.Builder proxyConfigurationBuilder = null; + /** * Default Constructor to initiate builder with default properties. */ @@ -285,12 +309,33 @@ public Builder httpClientInstance(okhttp3.OkHttpClient httpClientInstance, return this; } + /** + * Sets the proxy configuration for the underlying HTTP client. + * @param proxyBuilder The builder instance used to configure the proxy settings + * @return Builder + */ + public Builder proxyConfig(HttpProxyConfiguration.Builder proxyBuilder) { + proxyConfigurationBuilder = proxyBuilder; + return this; + } + + /** + * Private setter for the Builder of ProxyConfiguration, takes in an operation to be + * performed on the builder instance of proxy configuration. + * @param proxySupplier Supplier for the builder of ProxyConfiguration. + * @return Builder + */ + private Builder proxyConfig(Supplier proxySupplier) { + proxyConfigurationBuilder = proxySupplier.get(); + return this; + } + /** * Builds a new HttpClientConfiguration object using the set fields. * @return {@link HttpClientConfiguration} */ public HttpClientConfiguration build() { - return new HttpClientConfiguration(configurationBuilder); + return new HttpClientConfiguration(configurationBuilder, proxyConfigurationBuilder); } } } \ No newline at end of file diff --git a/src/main/java/com/maxio/advancedbilling/http/client/HttpProxyConfiguration.java b/src/main/java/com/maxio/advancedbilling/http/client/HttpProxyConfiguration.java new file mode 100644 index 00000000..b2c05a48 --- /dev/null +++ b/src/main/java/com/maxio/advancedbilling/http/client/HttpProxyConfiguration.java @@ -0,0 +1,135 @@ +/* + * AdvancedBilling + * + * This file was automatically generated for Maxio by APIMATIC v3.0 ( https://www.apimatic.io ). + */ + +package com.maxio.advancedbilling.http.client; + +import io.apimatic.core.configurations.http.client.CoreProxyConfiguration; +import io.apimatic.coreinterfaces.http.proxy.ProxyConfiguration; + +/** +* Represents the HTTP proxy configuration used by the SDK. +*/ +public class HttpProxyConfiguration implements ReadonlyHttpProxyConfiguration { + + private final CoreProxyConfiguration configuration; + + /** + * Creates a new {@code HttpProxyConfiguration} instance with the given core proxy + * configuration. + * @param configuration the underlying {@link CoreProxyConfiguration} to wrap. + */ + private HttpProxyConfiguration(final CoreProxyConfiguration configuration) { + this.configuration = configuration; + } + + /** + * Gets the proxy server address. + * @return the proxy address as a string. + */ + public String getAddress() { + return configuration.getAddress(); + } + + /** + * Gets the proxy server port. + * @return the proxy port number. + */ + public int getPort() { + return configuration.getPort(); + } + + /** + * Gets the username used for proxy authentication. + * @return the proxy username, or {@code null} if authentication is not required. + */ + public String getUsername() { + return configuration.getUsername(); + } + + /** + * Gets the password used for proxy authentication. + * @return the proxy password, or {@code null} if authentication is not required. + */ + public String getPassword() { + return configuration.getPassword(); + } + + /** + * Retrieves the underlying proxy configuration. + * @return the {@link ProxyConfiguration} instance containing all proxy settings. + */ + public ProxyConfiguration getConfiguration() { + return configuration; + } + + /** + * Creates a new builder initialized with the current configuration's values. + * @return a new {@link CoreProxyConfiguration.Builder} instance + */ + public HttpProxyConfiguration.Builder newBuilder() { + return new Builder(this.getAddress(), this.getPort()) + .auth(this.getUsername(), this.getPassword()); + } + + /** + * Returns a string representation of this proxy configuration. + * @return string representation of this object + */ + @Override + public String toString() { + return "HttpProxyConfiguration [" + + "address=" + this.getAddress() + + ", port=" + this.getPort() + + ", username=" + this.getUsername() + + ", password=" + this.getPassword() + + "]"; + } + + /** + * Builder class for constructing {@link CoreProxyConfiguration} instances. + */ + public static class Builder { + + private final String address; + private final int port; + private String username; + private String password; + + /** + * Creates a new {@code Builder} instance with the specified proxy server address and port. + * @param address the proxy server address. + * @param port the proxy server port. + */ + public Builder(String address, int port) { + this.address = address; + this.port = port; + } + + /** + * Sets the username and password for proxy auth. + * @param username the username to set for proxy auth. + * @param password the password to set for proxy auth. + * @return the builder instance + */ + public Builder auth(String username, String password) { + this.username = username; + this.password = password; + return this; + } + + /** + * Builds a new {@link HttpProxyConfiguration} instance using the set fields. + * @return the built {@link HttpProxyConfiguration} + */ + public HttpProxyConfiguration build() { + return new HttpProxyConfiguration( + new CoreProxyConfiguration.Builder(address, port) + .username(username) + .password(password) + .build()); + } + } +} \ No newline at end of file diff --git a/src/main/java/com/maxio/advancedbilling/http/client/ReadonlyHttpClientConfiguration.java b/src/main/java/com/maxio/advancedbilling/http/client/ReadonlyHttpClientConfiguration.java index d9f4cc10..4ee81982 100644 --- a/src/main/java/com/maxio/advancedbilling/http/client/ReadonlyHttpClientConfiguration.java +++ b/src/main/java/com/maxio/advancedbilling/http/client/ReadonlyHttpClientConfiguration.java @@ -75,4 +75,9 @@ public interface ReadonlyHttpClientConfiguration { */ boolean shouldOverrideHttpClientConfigurations(); + /** + * Retrieves the proxy configuration settings used by the HTTP client. + * @return configuration + */ + ReadonlyHttpProxyConfiguration getProxyConfig(); } \ No newline at end of file diff --git a/src/main/java/com/maxio/advancedbilling/http/client/ReadonlyHttpProxyConfiguration.java b/src/main/java/com/maxio/advancedbilling/http/client/ReadonlyHttpProxyConfiguration.java new file mode 100644 index 00000000..a23f3e1f --- /dev/null +++ b/src/main/java/com/maxio/advancedbilling/http/client/ReadonlyHttpProxyConfiguration.java @@ -0,0 +1,37 @@ +/* + * AdvancedBilling + * + * This file was automatically generated for Maxio by APIMATIC v3.0 ( https://www.apimatic.io ). + */ + +package com.maxio.advancedbilling.http.client; + +public interface ReadonlyHttpProxyConfiguration { + /** + * Returns the address (hostname or IP) of the proxy server. + * + * @return the proxy server address as a {@link String} + */ + String getAddress(); + + /** + * Returns the port number on which the proxy server is listening. + * + * @return the proxy server port + */ + int getPort(); + + /** + * Returns the username used for proxy authentication. + * + * @return the proxy authentication username as a {@link String} + */ + String getUsername(); + + /** + * Returns the password associated with the proxy authentication username. + * + * @return the proxy authentication password as a {@link String} + */ + String getPassword(); +} \ No newline at end of file diff --git a/src/main/java/com/maxio/advancedbilling/models/ListUsagesInput.java b/src/main/java/com/maxio/advancedbilling/models/ListUsagesInput.java index 68a89cc9..e44a8bc2 100644 --- a/src/main/java/com/maxio/advancedbilling/models/ListUsagesInput.java +++ b/src/main/java/com/maxio/advancedbilling/models/ListUsagesInput.java @@ -13,13 +13,14 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.maxio.advancedbilling.DateTimeHelper; import com.maxio.advancedbilling.models.containers.ListUsagesInputComponentId; +import com.maxio.advancedbilling.models.containers.ListUsagesInputSubscriptionIdOrReference; import java.time.LocalDate; /** * This is a model class for ListUsagesInput type. */ public class ListUsagesInput { - private int subscriptionId; + private ListUsagesInputSubscriptionIdOrReference subscriptionIdOrReference; private ListUsagesInputComponentId componentId; private Long sinceId; private Long maxId; @@ -38,7 +39,8 @@ public ListUsagesInput() { /** * Initialization constructor. - * @param subscriptionId int value for subscriptionId. + * @param subscriptionIdOrReference ListUsagesInputSubscriptionIdOrReference value for + * subscriptionIdOrReference. * @param componentId ListUsagesInputComponentId value for componentId. * @param sinceId Long value for sinceId. * @param maxId Long value for maxId. @@ -48,7 +50,7 @@ public ListUsagesInput() { * @param perPage Integer value for perPage. */ public ListUsagesInput( - int subscriptionId, + ListUsagesInputSubscriptionIdOrReference subscriptionIdOrReference, ListUsagesInputComponentId componentId, Long sinceId, Long maxId, @@ -56,7 +58,7 @@ public ListUsagesInput( LocalDate untilDate, Integer page, Integer perPage) { - this.subscriptionId = subscriptionId; + this.subscriptionIdOrReference = subscriptionIdOrReference; this.componentId = componentId; this.sinceId = sinceId; this.maxId = maxId; @@ -67,23 +69,31 @@ public ListUsagesInput( } /** - * Getter for SubscriptionId. - * The Chargify id of the subscription - * @return Returns the int + * Getter for SubscriptionIdOrReference. + * Either the Advanced Billing subscription ID (integer) or the subscription reference (string). + * Important: In cases where a numeric string value matches both an existing subscription ID and + * an existing subscription reference, the system will prioritize the subscription ID lookup. + * For example, if both subscription ID 123 and subscription reference "123" exist, passing + * "123" will return the subscription with ID 123. + * @return Returns the ListUsagesInputSubscriptionIdOrReference */ - @JsonGetter("subscription_id") - public int getSubscriptionId() { - return subscriptionId; + @JsonGetter("subscription_id_or_reference") + public ListUsagesInputSubscriptionIdOrReference getSubscriptionIdOrReference() { + return subscriptionIdOrReference; } /** - * Setter for SubscriptionId. - * The Chargify id of the subscription - * @param subscriptionId Value for int + * Setter for SubscriptionIdOrReference. + * Either the Advanced Billing subscription ID (integer) or the subscription reference (string). + * Important: In cases where a numeric string value matches both an existing subscription ID and + * an existing subscription reference, the system will prioritize the subscription ID lookup. + * For example, if both subscription ID 123 and subscription reference "123" exist, passing + * "123" will return the subscription with ID 123. + * @param subscriptionIdOrReference Value for ListUsagesInputSubscriptionIdOrReference */ - @JsonSetter("subscription_id") - public void setSubscriptionId(int subscriptionId) { - this.subscriptionId = subscriptionId; + @JsonSetter("subscription_id_or_reference") + public void setSubscriptionIdOrReference(ListUsagesInputSubscriptionIdOrReference subscriptionIdOrReference) { + this.subscriptionIdOrReference = subscriptionIdOrReference; } /** @@ -260,10 +270,10 @@ public void setPerPage(Integer perPage) { */ @Override public String toString() { - return "ListUsagesInput [" + "subscriptionId=" + subscriptionId + ", componentId=" - + componentId + ", sinceId=" + sinceId + ", maxId=" + maxId + ", sinceDate=" - + sinceDate + ", untilDate=" + untilDate + ", page=" + page + ", perPage=" + perPage - + "]"; + return "ListUsagesInput [" + "subscriptionIdOrReference=" + subscriptionIdOrReference + + ", componentId=" + componentId + ", sinceId=" + sinceId + ", maxId=" + maxId + + ", sinceDate=" + sinceDate + ", untilDate=" + untilDate + ", page=" + page + + ", perPage=" + perPage + "]"; } /** @@ -272,7 +282,7 @@ public String toString() { * @return a new {@link ListUsagesInput.Builder} object */ public Builder toBuilder() { - Builder builder = new Builder(subscriptionId, componentId) + Builder builder = new Builder(subscriptionIdOrReference, componentId) .sinceId(getSinceId()) .maxId(getMaxId()) .sinceDate(getSinceDate()) @@ -286,7 +296,7 @@ public Builder toBuilder() { * Class to build instances of {@link ListUsagesInput}. */ public static class Builder { - private int subscriptionId; + private ListUsagesInputSubscriptionIdOrReference subscriptionIdOrReference; private ListUsagesInputComponentId componentId; private Long sinceId; private Long maxId; @@ -303,21 +313,25 @@ public Builder() { /** * Initialization constructor. - * @param subscriptionId int value for subscriptionId. + * @param subscriptionIdOrReference ListUsagesInputSubscriptionIdOrReference value for + * subscriptionIdOrReference. * @param componentId ListUsagesInputComponentId value for componentId. */ - public Builder(int subscriptionId, ListUsagesInputComponentId componentId) { - this.subscriptionId = subscriptionId; + public Builder(ListUsagesInputSubscriptionIdOrReference subscriptionIdOrReference, + ListUsagesInputComponentId componentId) { + this.subscriptionIdOrReference = subscriptionIdOrReference; this.componentId = componentId; } /** - * Setter for subscriptionId. - * @param subscriptionId int value for subscriptionId. + * Setter for subscriptionIdOrReference. + * @param subscriptionIdOrReference ListUsagesInputSubscriptionIdOrReference value for + * subscriptionIdOrReference. * @return Builder */ - public Builder subscriptionId(int subscriptionId) { - this.subscriptionId = subscriptionId; + public Builder subscriptionIdOrReference( + ListUsagesInputSubscriptionIdOrReference subscriptionIdOrReference) { + this.subscriptionIdOrReference = subscriptionIdOrReference; return this; } @@ -396,8 +410,8 @@ public Builder perPage(Integer perPage) { * @return {@link ListUsagesInput} */ public ListUsagesInput build() { - return new ListUsagesInput(subscriptionId, componentId, sinceId, maxId, sinceDate, - untilDate, page, perPage); + return new ListUsagesInput(subscriptionIdOrReference, componentId, sinceId, maxId, + sinceDate, untilDate, page, perPage); } } } diff --git a/src/main/java/com/maxio/advancedbilling/models/containers/CreateUsageSubscriptionIdOrReference.java b/src/main/java/com/maxio/advancedbilling/models/containers/CreateUsageSubscriptionIdOrReference.java new file mode 100644 index 00000000..f7fe16dc --- /dev/null +++ b/src/main/java/com/maxio/advancedbilling/models/containers/CreateUsageSubscriptionIdOrReference.java @@ -0,0 +1,151 @@ +/* + * AdvancedBilling + * + * This file was automatically generated for Maxio by APIMATIC v3.0 ( https://www.apimatic.io ). + */ + +package com.maxio.advancedbilling.models.containers; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.ObjectCodec; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonDeserializer; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.maxio.advancedbilling.ApiHelper; +import io.apimatic.core.annotations.TypeCombinator.TypeCombinatorCase; +import io.apimatic.core.annotations.TypeCombinator.TypeCombinatorStringCase; +import java.io.IOException; +import java.util.Arrays; + +/** + * This is a container class for one-of types. + */ +@JsonDeserialize(using = CreateUsageSubscriptionIdOrReference.CreateUsageSubscriptionIdOrReferenceDeserializer.class) +public abstract class CreateUsageSubscriptionIdOrReference { + + /** + * This is Number case. + * @param number int value for number. + * @return The NumberCase object. + */ + public static CreateUsageSubscriptionIdOrReference fromNumber(int number) { + return new NumberCase(number); + } + + /** + * This is String case. + * @param string String value for string. + * @return The StringCase object. + */ + public static CreateUsageSubscriptionIdOrReference fromString(String string) { + return string == null ? null : new StringCase(string); + } + + /** + * Method to match from the provided one-of cases. + * @param The type to return after applying callback. + * @param cases The one-of type cases callback. + * @return The one-of matched case. + */ + public abstract R match(Cases cases); + + /** + * This is interface for one-of cases. + * @param The type to return after applying callback. + */ + public interface Cases { + R number(int number); + + R string(String string); + } + + /** + * This is a implementation class for NumberCase. + */ + @JsonDeserialize(using = JsonDeserializer.None.class) + @TypeCombinatorCase(type = "int") + private static class NumberCase extends CreateUsageSubscriptionIdOrReference { + + @JsonValue + private int number; + + NumberCase(int number) { + this.number = number; + } + + @Override + public R match(Cases cases) { + return cases.number(this.number); + } + + @JsonCreator + private NumberCase(JsonNode jsonNode) throws IOException { + if (jsonNode.isInt()) { + this.number = ApiHelper.deserialize(jsonNode, Integer.class); + } else { + throw new IllegalArgumentException(); + } + } + + @Override + public String toString() { + return String.valueOf(number); + } + } + + /** + * This is a implementation class for StringCase. + */ + @JsonDeserialize(using = JsonDeserializer.None.class) + @TypeCombinatorStringCase + @TypeCombinatorCase(type = "String") + private static class StringCase extends CreateUsageSubscriptionIdOrReference { + + @JsonValue + private String string; + + StringCase(String string) { + this.string = string; + } + + @Override + public R match(Cases cases) { + return cases.string(this.string); + } + + @JsonCreator + private StringCase(JsonNode jsonNode) throws IOException { + if (jsonNode.isTextual()) { + this.string = ApiHelper.deserialize(jsonNode, String.class); + } else { + throw new IllegalArgumentException(); + } + } + + @Override + public String toString() { + return string.toString(); + } + } + + /** + * This is a custom deserializer class for CreateUsageSubscriptionIdOrReference. + */ + protected static class CreateUsageSubscriptionIdOrReferenceDeserializer + extends JsonDeserializer { + + @Override + public CreateUsageSubscriptionIdOrReference deserialize(JsonParser jp, DeserializationContext ctxt) + throws IOException, JsonProcessingException { + ObjectCodec oc = jp.getCodec(); + JsonNode node = oc.readTree(jp); + return ApiHelper.deserialize(node, Arrays.asList(NumberCase.class, + StringCase.class), true); + } + } + +} diff --git a/src/main/java/com/maxio/advancedbilling/models/containers/ListUsagesInputSubscriptionIdOrReference.java b/src/main/java/com/maxio/advancedbilling/models/containers/ListUsagesInputSubscriptionIdOrReference.java new file mode 100644 index 00000000..7a268046 --- /dev/null +++ b/src/main/java/com/maxio/advancedbilling/models/containers/ListUsagesInputSubscriptionIdOrReference.java @@ -0,0 +1,151 @@ +/* + * AdvancedBilling + * + * This file was automatically generated for Maxio by APIMATIC v3.0 ( https://www.apimatic.io ). + */ + +package com.maxio.advancedbilling.models.containers; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.ObjectCodec; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonDeserializer; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.maxio.advancedbilling.ApiHelper; +import io.apimatic.core.annotations.TypeCombinator.TypeCombinatorCase; +import io.apimatic.core.annotations.TypeCombinator.TypeCombinatorStringCase; +import java.io.IOException; +import java.util.Arrays; + +/** + * This is a container class for one-of types. + */ +@JsonDeserialize(using = ListUsagesInputSubscriptionIdOrReference.ListUsagesInputSubscriptionIdOrReferenceDeserializer.class) +public abstract class ListUsagesInputSubscriptionIdOrReference { + + /** + * This is Number case. + * @param number int value for number. + * @return The NumberCase object. + */ + public static ListUsagesInputSubscriptionIdOrReference fromNumber(int number) { + return new NumberCase(number); + } + + /** + * This is String case. + * @param string String value for string. + * @return The StringCase object. + */ + public static ListUsagesInputSubscriptionIdOrReference fromString(String string) { + return string == null ? null : new StringCase(string); + } + + /** + * Method to match from the provided one-of cases. + * @param The type to return after applying callback. + * @param cases The one-of type cases callback. + * @return The one-of matched case. + */ + public abstract R match(Cases cases); + + /** + * This is interface for one-of cases. + * @param The type to return after applying callback. + */ + public interface Cases { + R number(int number); + + R string(String string); + } + + /** + * This is a implementation class for NumberCase. + */ + @JsonDeserialize(using = JsonDeserializer.None.class) + @TypeCombinatorCase(type = "int") + private static class NumberCase extends ListUsagesInputSubscriptionIdOrReference { + + @JsonValue + private int number; + + NumberCase(int number) { + this.number = number; + } + + @Override + public R match(Cases cases) { + return cases.number(this.number); + } + + @JsonCreator + private NumberCase(JsonNode jsonNode) throws IOException { + if (jsonNode.isInt()) { + this.number = ApiHelper.deserialize(jsonNode, Integer.class); + } else { + throw new IllegalArgumentException(); + } + } + + @Override + public String toString() { + return String.valueOf(number); + } + } + + /** + * This is a implementation class for StringCase. + */ + @JsonDeserialize(using = JsonDeserializer.None.class) + @TypeCombinatorStringCase + @TypeCombinatorCase(type = "String") + private static class StringCase extends ListUsagesInputSubscriptionIdOrReference { + + @JsonValue + private String string; + + StringCase(String string) { + this.string = string; + } + + @Override + public R match(Cases cases) { + return cases.string(this.string); + } + + @JsonCreator + private StringCase(JsonNode jsonNode) throws IOException { + if (jsonNode.isTextual()) { + this.string = ApiHelper.deserialize(jsonNode, String.class); + } else { + throw new IllegalArgumentException(); + } + } + + @Override + public String toString() { + return string.toString(); + } + } + + /** + * This is a custom deserializer class for ListUsagesInputSubscriptionIdOrReference. + */ + protected static class ListUsagesInputSubscriptionIdOrReferenceDeserializer + extends JsonDeserializer { + + @Override + public ListUsagesInputSubscriptionIdOrReference deserialize(JsonParser jp, DeserializationContext ctxt) + throws IOException, JsonProcessingException { + ObjectCodec oc = jp.getCodec(); + JsonNode node = oc.readTree(jp); + return ApiHelper.deserialize(node, Arrays.asList(NumberCase.class, + StringCase.class), true); + } + } + +} From c2ac7b3a698a36ad047ae0cf442c5e03539cdc3f Mon Sep 17 00:00:00 2001 From: Lukasz Bandzarewicz Date: Wed, 10 Sep 2025 16:43:26 +0200 Subject: [PATCH 2/4] Refactor usage creation to utilize CreateUsageSubscriptionIdOrReference --- .../EventsControllerListEventsTest.java | 3 ++- ...rListSubscriptionProformaInvoicesTest.java | 3 ++- .../ProformaInvoicesTestBase.java | 9 ++----- ...onComponentsControllerCreateUsageTest.java | 16 +++++++----- ...ionComponentsControllerListUsagesTest.java | 25 ++++++++++++------- ...iptionGroupStatusControllerCancelTest.java | 9 ++++--- 6 files changed, 37 insertions(+), 28 deletions(-) diff --git a/tests/src/test/java/com/maxio/advancedbilling/controllers/events/EventsControllerListEventsTest.java b/tests/src/test/java/com/maxio/advancedbilling/controllers/events/EventsControllerListEventsTest.java index db015cdb..18fd4936 100644 --- a/tests/src/test/java/com/maxio/advancedbilling/controllers/events/EventsControllerListEventsTest.java +++ b/tests/src/test/java/com/maxio/advancedbilling/controllers/events/EventsControllerListEventsTest.java @@ -28,6 +28,7 @@ import com.maxio.advancedbilling.models.UpdateSubscription; import com.maxio.advancedbilling.models.UpdateSubscriptionRequest; import com.maxio.advancedbilling.models.containers.CreateUsageComponentId; +import com.maxio.advancedbilling.models.containers.CreateUsageSubscriptionIdOrReference; import com.maxio.advancedbilling.utils.TestSetup; import com.maxio.advancedbilling.utils.matchers.EventSpecificDataGetter; import org.junit.jupiter.api.BeforeAll; @@ -84,7 +85,7 @@ void setup() throws IOException, ApiException, InterruptedException { subscription = testSetup.createSubscription(customer, product); // metered_usage client.getSubscriptionComponentsController().createUsage( - subscription.getId(), + CreateUsageSubscriptionIdOrReference.fromNumber(subscription.getId()), CreateUsageComponentId.fromNumber(component.getId()), new CreateUsageRequest( new CreateUsage.Builder() diff --git a/tests/src/test/java/com/maxio/advancedbilling/controllers/proformainvoices/ProformaInvoicesControllerListSubscriptionProformaInvoicesTest.java b/tests/src/test/java/com/maxio/advancedbilling/controllers/proformainvoices/ProformaInvoicesControllerListSubscriptionProformaInvoicesTest.java index ec495e0d..8bda9a0e 100644 --- a/tests/src/test/java/com/maxio/advancedbilling/controllers/proformainvoices/ProformaInvoicesControllerListSubscriptionProformaInvoicesTest.java +++ b/tests/src/test/java/com/maxio/advancedbilling/controllers/proformainvoices/ProformaInvoicesControllerListSubscriptionProformaInvoicesTest.java @@ -37,6 +37,7 @@ import com.maxio.advancedbilling.models.VoidInvoiceRequest; import com.maxio.advancedbilling.models.containers.CreateMetafieldsRequestMetafields; import com.maxio.advancedbilling.models.containers.CreateUsageComponentId; +import com.maxio.advancedbilling.models.containers.CreateUsageSubscriptionIdOrReference; import com.maxio.advancedbilling.models.containers.IssueServiceCreditAmount; import com.maxio.advancedbilling.utils.TestSetup; import com.maxio.advancedbilling.utils.TestTeardown; @@ -116,7 +117,7 @@ ResourceType.SUBSCRIPTIONS, new CreateMetafieldsRequest( ) ) .build()); - CLIENT.getSubscriptionComponentsController().createUsage(subscription.getId(), + CLIENT.getSubscriptionComponentsController().createUsage(CreateUsageSubscriptionIdOrReference.fromNumber(subscription.getId()), CreateUsageComponentId.fromNumber(meteredComponent.getId()), new CreateUsageRequest(new CreateUsage.Builder() .quantity(20.0) diff --git a/tests/src/test/java/com/maxio/advancedbilling/controllers/proformainvoices/ProformaInvoicesTestBase.java b/tests/src/test/java/com/maxio/advancedbilling/controllers/proformainvoices/ProformaInvoicesTestBase.java index b0e257dd..1875a589 100644 --- a/tests/src/test/java/com/maxio/advancedbilling/controllers/proformainvoices/ProformaInvoicesTestBase.java +++ b/tests/src/test/java/com/maxio/advancedbilling/controllers/proformainvoices/ProformaInvoicesTestBase.java @@ -29,12 +29,7 @@ import com.maxio.advancedbilling.models.ProformaInvoiceRole; import com.maxio.advancedbilling.models.SignupProformaPreview; import com.maxio.advancedbilling.models.Subscription; -import com.maxio.advancedbilling.models.containers.CreateSubscriptionComponentAllocatedQuantity; -import com.maxio.advancedbilling.models.containers.CreateSubscriptionComponentComponentId; -import com.maxio.advancedbilling.models.containers.CreateUsageComponentId; -import com.maxio.advancedbilling.models.containers.IssueServiceCreditAmount; -import com.maxio.advancedbilling.models.containers.PaymentProfileAttributesExpirationMonth; -import com.maxio.advancedbilling.models.containers.PaymentProfileAttributesExpirationYear; +import com.maxio.advancedbilling.models.containers.*; import com.maxio.advancedbilling.utils.TestSetup; import java.io.IOException; @@ -134,7 +129,7 @@ protected Subscription setupSubscription(Customer customer, Component quantityBa ) ) .build()); - CLIENT.getSubscriptionComponentsController().createUsage(subscription.getId(), + CLIENT.getSubscriptionComponentsController().createUsage(CreateUsageSubscriptionIdOrReference.fromNumber(subscription.getId()), CreateUsageComponentId.fromNumber(meteredComponent.getId()), new CreateUsageRequest(new CreateUsage.Builder() .quantity(20.0) diff --git a/tests/src/test/java/com/maxio/advancedbilling/controllers/subscriptioncomponents/SubscriptionComponentsControllerCreateUsageTest.java b/tests/src/test/java/com/maxio/advancedbilling/controllers/subscriptioncomponents/SubscriptionComponentsControllerCreateUsageTest.java index 4f6a83fa..c1c49663 100644 --- a/tests/src/test/java/com/maxio/advancedbilling/controllers/subscriptioncomponents/SubscriptionComponentsControllerCreateUsageTest.java +++ b/tests/src/test/java/com/maxio/advancedbilling/controllers/subscriptioncomponents/SubscriptionComponentsControllerCreateUsageTest.java @@ -12,6 +12,7 @@ import com.maxio.advancedbilling.models.Subscription; import com.maxio.advancedbilling.models.Usage; import com.maxio.advancedbilling.models.containers.CreateUsageComponentId; +import com.maxio.advancedbilling.models.containers.CreateUsageSubscriptionIdOrReference; import com.maxio.advancedbilling.utils.TestSetup; import com.maxio.advancedbilling.utils.TestTeardown; import org.junit.jupiter.api.AfterAll; @@ -56,7 +57,7 @@ static void teardown() throws IOException, ApiException { @Test void shouldCreateMeteredComponentUsage() throws IOException, ApiException { // given - Usage usage = SUBSCRIPTION_COMPONENTS_CONTROLLER.createUsage(subscription.getId(), + Usage usage = SUBSCRIPTION_COMPONENTS_CONTROLLER.createUsage(CreateUsageSubscriptionIdOrReference.fromNumber(subscription.getId()), CreateUsageComponentId.fromNumber(meteredComponent.getId()), new CreateUsageRequest( new CreateUsage.Builder() @@ -72,7 +73,7 @@ void shouldCreateMeteredComponentUsage() throws IOException, ApiException { @Test void shouldCreatePrepaidComponentUsage() throws IOException, ApiException { // given - Usage usage = SUBSCRIPTION_COMPONENTS_CONTROLLER.createUsage(subscription.getId(), + Usage usage = SUBSCRIPTION_COMPONENTS_CONTROLLER.createUsage(CreateUsageSubscriptionIdOrReference.fromNumber(subscription.getId()), CreateUsageComponentId.fromNumber(prepaidComponent.getId()), new CreateUsageRequest( new CreateUsage.Builder() @@ -96,7 +97,8 @@ void shouldNotCreateUsageForArchivedQuantityBasedComponent() throws IOException, // when - then assertThatErrorListResponse(() -> SUBSCRIPTION_COMPONENTS_CONTROLLER.createUsage( - subscription.getId(), CreateUsageComponentId.fromNumber(quantityBasedComponent.getId()), + CreateUsageSubscriptionIdOrReference.fromNumber(subscription.getId()), + CreateUsageComponentId.fromNumber(quantityBasedComponent.getId()), new CreateUsageRequest( new CreateUsage.Builder().quantity(2.0).build() )) @@ -110,13 +112,15 @@ void shouldNotCreateUsageForArchivedQuantityBasedComponent() throws IOException, @Test void shouldNotCreateUsageWhenSubscriptionDoesNotExist() { - assertNotFound(() -> SUBSCRIPTION_COMPONENTS_CONTROLLER.createUsage(123, + assertNotFound(() -> SUBSCRIPTION_COMPONENTS_CONTROLLER.createUsage( + CreateUsageSubscriptionIdOrReference.fromNumber(123), CreateUsageComponentId.fromNumber(meteredComponent.getId()), null)); } @Test void shouldNotCreateUsageWhenComponentDoesNotExist() { - assertNotFound(() -> SUBSCRIPTION_COMPONENTS_CONTROLLER.createUsage(subscription.getId(), + assertNotFound(() -> SUBSCRIPTION_COMPONENTS_CONTROLLER.createUsage( + CreateUsageSubscriptionIdOrReference.fromNumber(subscription.getId()), CreateUsageComponentId.fromNumber(123), null)); } @@ -124,7 +128,7 @@ void shouldNotCreateUsageWhenComponentDoesNotExist() { void shouldNotCreateUsageWhenProvidingInvalidCredentials() { // when - then assertUnauthorized(() -> TestClientProvider.createInvalidCredentialsClient().getSubscriptionComponentsController() - .createUsage(subscription.getId(), CreateUsageComponentId.fromNumber(meteredComponent.getId()), null)); + .createUsage(CreateUsageSubscriptionIdOrReference.fromNumber(subscription.getId()), CreateUsageComponentId.fromNumber(meteredComponent.getId()), null)); } } diff --git a/tests/src/test/java/com/maxio/advancedbilling/controllers/subscriptioncomponents/SubscriptionComponentsControllerListUsagesTest.java b/tests/src/test/java/com/maxio/advancedbilling/controllers/subscriptioncomponents/SubscriptionComponentsControllerListUsagesTest.java index 833f205a..c6b50434 100644 --- a/tests/src/test/java/com/maxio/advancedbilling/controllers/subscriptioncomponents/SubscriptionComponentsControllerListUsagesTest.java +++ b/tests/src/test/java/com/maxio/advancedbilling/controllers/subscriptioncomponents/SubscriptionComponentsControllerListUsagesTest.java @@ -14,7 +14,9 @@ import com.maxio.advancedbilling.models.Usage; import com.maxio.advancedbilling.models.UsageResponse; import com.maxio.advancedbilling.models.containers.CreateUsageComponentId; +import com.maxio.advancedbilling.models.containers.CreateUsageSubscriptionIdOrReference; import com.maxio.advancedbilling.models.containers.ListUsagesInputComponentId; +import com.maxio.advancedbilling.models.containers.ListUsagesInputSubscriptionIdOrReference; import com.maxio.advancedbilling.utils.TestSetup; import com.maxio.advancedbilling.utils.TestTeardown; import org.junit.jupiter.api.AfterAll; @@ -52,7 +54,7 @@ static void setup() throws IOException, ApiException { customer = TEST_SETUP.createCustomer(); subscription = TEST_SETUP.createSubscription(customer, product); - usage1 = SUBSCRIPTION_COMPONENTS_CONTROLLER.createUsage(subscription.getId(), + usage1 = SUBSCRIPTION_COMPONENTS_CONTROLLER.createUsage(CreateUsageSubscriptionIdOrReference.fromNumber(subscription.getId()), CreateUsageComponentId.fromNumber(meteredComponent.getId()), new CreateUsageRequest( new CreateUsage.Builder() @@ -60,7 +62,7 @@ static void setup() throws IOException, ApiException { .memo("created usage") .build() )).getUsage(); - usage2 = SUBSCRIPTION_COMPONENTS_CONTROLLER.createUsage(subscription.getId(), + usage2 = SUBSCRIPTION_COMPONENTS_CONTROLLER.createUsage(CreateUsageSubscriptionIdOrReference.fromNumber(subscription.getId()), CreateUsageComponentId.fromNumber(meteredComponent.getId()), new CreateUsageRequest( new CreateUsage.Builder() @@ -68,7 +70,7 @@ static void setup() throws IOException, ApiException { .memo("created usage 2") .build() )).getUsage(); - usage3 = SUBSCRIPTION_COMPONENTS_CONTROLLER.createUsage(subscription.getId(), + usage3 = SUBSCRIPTION_COMPONENTS_CONTROLLER.createUsage(CreateUsageSubscriptionIdOrReference.fromNumber(subscription.getId()), CreateUsageComponentId.fromNumber(meteredComponent.getId()), new CreateUsageRequest( new CreateUsage.Builder() @@ -87,7 +89,7 @@ static void teardown() throws IOException, ApiException { void shouldListUsages() throws IOException, ApiException { // when List usages = SUBSCRIPTION_COMPONENTS_CONTROLLER.listUsages(new ListUsagesInput.Builder() - .subscriptionId(subscription.getId()) + .subscriptionIdOrReference(ListUsagesInputSubscriptionIdOrReference.fromNumber(subscription.getId())) .componentId(ListUsagesInputComponentId.fromNumber(meteredComponent.getId())) .build() ); @@ -103,7 +105,7 @@ void shouldListUsages() throws IOException, ApiException { void shouldReturnEmptyListWhenListingUsagesUsingTimeframeWithoutUsages() throws IOException, ApiException { // when List usages = SUBSCRIPTION_COMPONENTS_CONTROLLER.listUsages(new ListUsagesInput.Builder() - .subscriptionId(subscription.getId()) + .subscriptionIdOrReference(ListUsagesInputSubscriptionIdOrReference.fromNumber(subscription.getId())) .componentId(ListUsagesInputComponentId.fromNumber(meteredComponent.getId())) .sinceDate(LocalDate.parse("2022-10-25")) .untilDate(LocalDate.parse("2022-11-23")) @@ -118,7 +120,7 @@ void shouldReturnEmptyListWhenListingUsagesUsingTimeframeWithoutUsages() throws void shouldReturnUsagesBetweenIds() throws IOException, ApiException { // when List usages = SUBSCRIPTION_COMPONENTS_CONTROLLER.listUsages(new ListUsagesInput.Builder() - .subscriptionId(subscription.getId()) + .subscriptionIdOrReference(ListUsagesInputSubscriptionIdOrReference.fromNumber(subscription.getId())) .componentId(ListUsagesInputComponentId.fromNumber(meteredComponent.getId())) .sinceId(usage1.getId()) .maxId(usage2.getId()) @@ -134,7 +136,7 @@ void shouldReturnUsagesBetweenIds() throws IOException, ApiException { @Test void shouldNotListUsagesWhenSubscriptionDoesNotExist() { assertNotFound(() -> SUBSCRIPTION_COMPONENTS_CONTROLLER.listUsages(new ListUsagesInput.Builder() - .subscriptionId(123) + .subscriptionIdOrReference(ListUsagesInputSubscriptionIdOrReference.fromNumber(123)) .componentId(ListUsagesInputComponentId.fromNumber(meteredComponent.getId())) .build())); } @@ -142,7 +144,7 @@ void shouldNotListUsagesWhenSubscriptionDoesNotExist() { @Test void shouldNotListUsagesWhenComponentDoesNotExist() { assertNotFound(() -> SUBSCRIPTION_COMPONENTS_CONTROLLER.listUsages(new ListUsagesInput.Builder() - .subscriptionId(subscription.getId()) + .subscriptionIdOrReference(ListUsagesInputSubscriptionIdOrReference.fromNumber(subscription.getId())) .componentId(ListUsagesInputComponentId.fromNumber(123)) .build())); } @@ -151,7 +153,12 @@ void shouldNotListUsagesWhenComponentDoesNotExist() { void shouldNotCreateUsageWhenProvidingInvalidCredentials() { // when - then assertUnauthorized(() -> TestClientProvider.createInvalidCredentialsClient().getSubscriptionComponentsController() - .createUsage(subscription.getId(), CreateUsageComponentId.fromNumber(meteredComponent.getId()), null)); + .createUsage( + CreateUsageSubscriptionIdOrReference.fromNumber(subscription.getId()), + CreateUsageComponentId.fromNumber(meteredComponent.getId()), + null + ) + ); } } diff --git a/tests/src/test/java/com/maxio/advancedbilling/controllers/subscriptiongroupstatus/SubscriptionGroupStatusControllerCancelTest.java b/tests/src/test/java/com/maxio/advancedbilling/controllers/subscriptiongroupstatus/SubscriptionGroupStatusControllerCancelTest.java index 8e27eacc..c3bd1c80 100644 --- a/tests/src/test/java/com/maxio/advancedbilling/controllers/subscriptiongroupstatus/SubscriptionGroupStatusControllerCancelTest.java +++ b/tests/src/test/java/com/maxio/advancedbilling/controllers/subscriptiongroupstatus/SubscriptionGroupStatusControllerCancelTest.java @@ -11,6 +11,7 @@ import com.maxio.advancedbilling.models.Subscription; import com.maxio.advancedbilling.models.SubscriptionState; import com.maxio.advancedbilling.models.containers.CreateUsageComponentId; +import com.maxio.advancedbilling.models.containers.CreateUsageSubscriptionIdOrReference; import org.junit.jupiter.api.Test; import java.io.IOException; @@ -39,8 +40,8 @@ void shouldCancelGroupWithoutCharge() throws IOException, ApiException { .build() ); - subscriptionComponentsController.createUsage(group.getPrimarySubscription().getId(), componentId, usageRequest); - subscriptionComponentsController.createUsage(group.getMember(0).getId(), componentId, usageRequest); + subscriptionComponentsController.createUsage(CreateUsageSubscriptionIdOrReference.fromNumber(group.getPrimarySubscription().getId()), componentId, usageRequest); + subscriptionComponentsController.createUsage(CreateUsageSubscriptionIdOrReference.fromNumber(group.getMember(0).getId()), componentId, usageRequest); // when subscriptionGroupStatusController.cancelSubscriptionsInGroup(group.getSubscriptionGroup().getUid(), @@ -80,8 +81,8 @@ void shouldCancelGroupWithCharge() throws IOException, ApiException { .build() ); - subscriptionComponentsController.createUsage(group.getPrimarySubscription().getId(), componentId, usageRequest); - subscriptionComponentsController.createUsage(group.getMember(0).getId(), componentId, usageRequest); + subscriptionComponentsController.createUsage(CreateUsageSubscriptionIdOrReference.fromNumber(group.getPrimarySubscription().getId()), componentId, usageRequest); + subscriptionComponentsController.createUsage(CreateUsageSubscriptionIdOrReference.fromNumber(group.getMember(0).getId()), componentId, usageRequest); // when subscriptionGroupStatusController.cancelSubscriptionsInGroup(group.getSubscriptionGroup().getUid(), From c46685893fe7afa548c075f85a38f6a2d361cd19 Mon Sep 17 00:00:00 2001 From: Lukasz Bandzarewicz Date: Wed, 10 Sep 2025 17:10:49 +0200 Subject: [PATCH 3/4] Update invoice balance assertion to ignore additional properties --- .../controllers/invoices/InvoicesControllerIssueTest.java | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/src/test/java/com/maxio/advancedbilling/controllers/invoices/InvoicesControllerIssueTest.java b/tests/src/test/java/com/maxio/advancedbilling/controllers/invoices/InvoicesControllerIssueTest.java index 81f94200..83abec1e 100644 --- a/tests/src/test/java/com/maxio/advancedbilling/controllers/invoices/InvoicesControllerIssueTest.java +++ b/tests/src/test/java/com/maxio/advancedbilling/controllers/invoices/InvoicesControllerIssueTest.java @@ -248,6 +248,7 @@ void shouldIssuePendingInvoice() throws IOException, ApiException { assertThat(previousBalanceData.getInvoices()) .hasSize(1) .usingRecursiveFieldByFieldElementComparator() + .ignoringFields("additionalProperties") .containsExactly(new InvoiceBalanceItem.Builder() .uid(openInvoice.getUid()) .number(openInvoice.getNumber()) From 5432b048988f2e9e50982a765cb177a3a2cd08e1 Mon Sep 17 00:00:00 2001 From: Lukasz Bandzarewicz Date: Wed, 10 Sep 2025 17:23:19 +0200 Subject: [PATCH 4/4] Update invoice balance assertion to ignore additional properties more succinctly --- .../controllers/invoices/InvoicesControllerIssueTest.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/src/test/java/com/maxio/advancedbilling/controllers/invoices/InvoicesControllerIssueTest.java b/tests/src/test/java/com/maxio/advancedbilling/controllers/invoices/InvoicesControllerIssueTest.java index 83abec1e..d631b7b4 100644 --- a/tests/src/test/java/com/maxio/advancedbilling/controllers/invoices/InvoicesControllerIssueTest.java +++ b/tests/src/test/java/com/maxio/advancedbilling/controllers/invoices/InvoicesControllerIssueTest.java @@ -247,8 +247,7 @@ void shouldIssuePendingInvoice() throws IOException, ApiException { assertThat(previousBalanceData.getCapturedAt()).isNotNull(); assertThat(previousBalanceData.getInvoices()) .hasSize(1) - .usingRecursiveFieldByFieldElementComparator() - .ignoringFields("additionalProperties") + .usingRecursiveFieldByFieldElementComparatorIgnoringFields("additionalProperties") .containsExactly(new InvoiceBalanceItem.Builder() .uid(openInvoice.getUid()) .number(openInvoice.getNumber())