From fe60c17a0e6f05539ea00c97309f209f0fe1139e Mon Sep 17 00:00:00 2001
From: "github-actions[bot]"
<41898282+github-actions[bot]@users.noreply.github.com>
Date: Wed, 7 Oct 2026 15:22:19 +0000
Subject: [PATCH] feat(api)!: update SDKs to meteroid 0.1.0
---
api.md | 36 ++--
src/main/java/com/meteroid/AsyncPage.java | 71 ++++++--
.../java/com/meteroid/AsyncPaginator.java | 63 -------
src/main/java/com/meteroid/Meteroid.java | 17 +-
src/main/java/com/meteroid/Page.java | 96 ++++++++--
src/main/java/com/meteroid/Paginator.java | 98 -----------
src/main/java/com/meteroid/api/AddOns.java | 76 ++++++--
.../java/com/meteroid/api/AddOnsAsync.java | 60 +++++--
.../com/meteroid/api/AddOnsListAsyncPage.java | 66 +++++++
.../java/com/meteroid/api/AddOnsListPage.java | 66 +++++++
src/main/java/com/meteroid/api/BatchJobs.java | 166 ++++++++++++++----
.../java/com/meteroid/api/BatchJobsAsync.java | 132 ++++++++++----
.../meteroid/api/BatchJobsListAsyncPage.java | 67 +++++++
.../api/BatchJobsListFailuresAsyncPage.java | 70 ++++++++
.../api/BatchJobsListFailuresPage.java | 68 +++++++
.../com/meteroid/api/BatchJobsListPage.java | 68 +++++++
src/main/java/com/meteroid/api/Coupons.java | 76 ++++++--
.../java/com/meteroid/api/CouponsAsync.java | 60 +++++--
.../meteroid/api/CouponsListAsyncPage.java | 66 +++++++
.../com/meteroid/api/CouponsListPage.java | 66 +++++++
.../java/com/meteroid/api/CreditNotes.java | 77 ++++++--
.../com/meteroid/api/CreditNotesAsync.java | 60 +++++--
.../api/CreditNotesListAsyncPage.java | 67 +++++++
.../com/meteroid/api/CreditNotesListPage.java | 68 +++++++
.../com/meteroid/api/CustomProperties.java | 99 ++++++++---
.../meteroid/api/CustomPropertiesAsync.java | 84 ++++++---
...istCustomPropertyDefinitionsAsyncPage.java | 74 ++++++++
...tiesListCustomPropertyDefinitionsPage.java | 74 ++++++++
src/main/java/com/meteroid/api/Customers.java | 77 ++++++--
.../java/com/meteroid/api/CustomersAsync.java | 60 +++++--
.../meteroid/api/CustomersListAsyncPage.java | 66 +++++++
.../com/meteroid/api/CustomersListPage.java | 66 +++++++
src/main/java/com/meteroid/api/Features.java | 75 ++++++--
.../java/com/meteroid/api/FeaturesAsync.java | 60 +++++--
.../meteroid/api/FeaturesListAsyncPage.java | 66 +++++++
.../com/meteroid/api/FeaturesListPage.java | 66 +++++++
src/main/java/com/meteroid/api/Invoices.java | 75 ++++++--
.../java/com/meteroid/api/InvoicesAsync.java | 60 +++++--
.../meteroid/api/InvoicesListAsyncPage.java | 66 +++++++
.../com/meteroid/api/InvoicesListPage.java | 66 +++++++
src/main/java/com/meteroid/api/Metrics.java | 78 ++++++--
.../java/com/meteroid/api/MetricsAsync.java | 61 +++++--
.../meteroid/api/MetricsListAsyncPage.java | 66 +++++++
.../com/meteroid/api/MetricsListPage.java | 66 +++++++
src/main/java/com/meteroid/api/Plans.java | 162 +++++++++++++----
.../java/com/meteroid/api/PlansAsync.java | 130 ++++++++++----
.../com/meteroid/api/PlansListAsyncPage.java | 66 +++++++
.../java/com/meteroid/api/PlansListPage.java | 65 +++++++
.../api/PlansListVersionsAsyncPage.java | 67 +++++++
.../meteroid/api/PlansListVersionsPage.java | 68 +++++++
.../com/meteroid/api/ProductFamilies.java | 78 ++++++--
.../meteroid/api/ProductFamiliesAsync.java | 61 +++++--
.../api/ProductFamiliesListAsyncPage.java | 67 +++++++
.../meteroid/api/ProductFamiliesListPage.java | 68 +++++++
src/main/java/com/meteroid/api/Products.java | 76 ++++++--
.../java/com/meteroid/api/ProductsAsync.java | 60 +++++--
.../meteroid/api/ProductsListAsyncPage.java | 66 +++++++
.../com/meteroid/api/ProductsListPage.java | 66 +++++++
.../java/com/meteroid/api/Subscriptions.java | 76 ++++++--
.../com/meteroid/api/SubscriptionsAsync.java | 60 +++++--
.../api/SubscriptionsListAsyncPage.java | 67 +++++++
.../meteroid/api/SubscriptionsListPage.java | 68 +++++++
.../meteroid/internal/MeteroidHttpClient.java | 33 +++-
63 files changed, 3792 insertions(+), 777 deletions(-)
delete mode 100644 src/main/java/com/meteroid/AsyncPaginator.java
delete mode 100644 src/main/java/com/meteroid/Paginator.java
create mode 100644 src/main/java/com/meteroid/api/AddOnsListAsyncPage.java
create mode 100644 src/main/java/com/meteroid/api/AddOnsListPage.java
create mode 100644 src/main/java/com/meteroid/api/BatchJobsListAsyncPage.java
create mode 100644 src/main/java/com/meteroid/api/BatchJobsListFailuresAsyncPage.java
create mode 100644 src/main/java/com/meteroid/api/BatchJobsListFailuresPage.java
create mode 100644 src/main/java/com/meteroid/api/BatchJobsListPage.java
create mode 100644 src/main/java/com/meteroid/api/CouponsListAsyncPage.java
create mode 100644 src/main/java/com/meteroid/api/CouponsListPage.java
create mode 100644 src/main/java/com/meteroid/api/CreditNotesListAsyncPage.java
create mode 100644 src/main/java/com/meteroid/api/CreditNotesListPage.java
create mode 100644 src/main/java/com/meteroid/api/CustomPropertiesListCustomPropertyDefinitionsAsyncPage.java
create mode 100644 src/main/java/com/meteroid/api/CustomPropertiesListCustomPropertyDefinitionsPage.java
create mode 100644 src/main/java/com/meteroid/api/CustomersListAsyncPage.java
create mode 100644 src/main/java/com/meteroid/api/CustomersListPage.java
create mode 100644 src/main/java/com/meteroid/api/FeaturesListAsyncPage.java
create mode 100644 src/main/java/com/meteroid/api/FeaturesListPage.java
create mode 100644 src/main/java/com/meteroid/api/InvoicesListAsyncPage.java
create mode 100644 src/main/java/com/meteroid/api/InvoicesListPage.java
create mode 100644 src/main/java/com/meteroid/api/MetricsListAsyncPage.java
create mode 100644 src/main/java/com/meteroid/api/MetricsListPage.java
create mode 100644 src/main/java/com/meteroid/api/PlansListAsyncPage.java
create mode 100644 src/main/java/com/meteroid/api/PlansListPage.java
create mode 100644 src/main/java/com/meteroid/api/PlansListVersionsAsyncPage.java
create mode 100644 src/main/java/com/meteroid/api/PlansListVersionsPage.java
create mode 100644 src/main/java/com/meteroid/api/ProductFamiliesListAsyncPage.java
create mode 100644 src/main/java/com/meteroid/api/ProductFamiliesListPage.java
create mode 100644 src/main/java/com/meteroid/api/ProductsListAsyncPage.java
create mode 100644 src/main/java/com/meteroid/api/ProductsListPage.java
create mode 100644 src/main/java/com/meteroid/api/SubscriptionsListAsyncPage.java
create mode 100644 src/main/java/com/meteroid/api/SubscriptionsListPage.java
diff --git a/api.md b/api.md
index eaf01d0..b25af4a 100644
--- a/api.md
+++ b/api.md
@@ -8,6 +8,12 @@ idempotency key of that call. `client.async()` has the same methods returning
`CompletableFuture`s, and `client.withRawResponse()` returning `ApiResponse`s. Models are in
[`com.meteroid.models`](src/main/java/com/meteroid/models).
+A paginated list returns a page: the getters of its response body (`page.data()`), its items
+(`page.items()`), `hasNextPage()` and `nextPage()`. Iterating it, or its `stream()`, yields every
+item from that page on, and `pages()` every page, fetching the next ones on demand. `body()` is
+the response body as received. The async client's pages have `nextPage()`, `forEach(...)`,
+`forEachPage(...)` and `toList()`, returning `CompletableFuture`s.
+
[Add ons](#add-ons) · [Batch jobs](#batch-jobs) · [Checkout sessions](#checkout-sessions) · [Connect](#connect) · [Coupons](#coupons) · [Credit notes](#credit-notes) · [Custom properties](#custom-properties) · [Customers](#customers) · [Entitlements](#entitlements) · [Events](#events) · [Features](#features) · [Invoices](#invoices) · [Metrics](#metrics) · [Oauth](#oauth) · [Oauth apps](#oauth-apps) · [Plans](#plans) · [Product families](#product-families) · [Products](#products) · [Subscriptions](#subscriptions) · [Usage](#usage)
## Add ons
@@ -16,7 +22,7 @@ idempotency key of that call. `client.async()` has the same methods returning
| Method | Request | Returns |
| --- | --- | --- |
-| `AddOnListResponse client.addOns().list([AddOnsListOptions options])` | `GET /api/v1/addons` | [`AddOnListResponse`](src/main/java/com/meteroid/models/AddOnListResponse.java) |
+| `AddOnsListPage client.addOns().list([AddOnsListOptions options])` | `GET /api/v1/addons` | [page](src/main/java/com/meteroid/api/AddOnsListPage.java) of [`AddOn`](src/main/java/com/meteroid/models/AddOn.java), with the properties of [`AddOnListResponse`](src/main/java/com/meteroid/models/AddOnListResponse.java) |
| `AddOn client.addOns().create(CreateAddOnRequest createAddOnRequest)` | `POST /api/v1/addons` | [`AddOn`](src/main/java/com/meteroid/models/AddOn.java) |
| `AddOn client.addOns().retrieve(String addonId)` | `GET /api/v1/addons/{addon_id}` | [`AddOn`](src/main/java/com/meteroid/models/AddOn.java) |
| `AddOn client.addOns().update(String addonId, UpdateAddOnRequest updateAddOnRequest)` | `PATCH /api/v1/addons/{addon_id}` | [`AddOn`](src/main/java/com/meteroid/models/AddOn.java) |
@@ -31,9 +37,9 @@ idempotency key of that call. `client.async()` has the same methods returning
| Method | Request | Returns |
| --- | --- | --- |
-| `BatchJobListResponse client.batchJobs().list([BatchJobsListOptions options])` | `GET /api/v1/batch-jobs` | [`BatchJobListResponse`](src/main/java/com/meteroid/models/BatchJobListResponse.java) |
+| `BatchJobsListPage client.batchJobs().list([BatchJobsListOptions options])` | `GET /api/v1/batch-jobs` | [page](src/main/java/com/meteroid/api/BatchJobsListPage.java) of [`BatchJobResponse`](src/main/java/com/meteroid/models/BatchJobResponse.java), with the properties of [`BatchJobListResponse`](src/main/java/com/meteroid/models/BatchJobListResponse.java) |
| `BatchJobDetailResponse client.batchJobs().retrieve(String batchJobId)` | `GET /api/v1/batch-jobs/{batch_job_id}` | [`BatchJobDetailResponse`](src/main/java/com/meteroid/models/BatchJobDetailResponse.java) |
-| `BatchJobFailuresResponse client.batchJobs().listFailures(String batchJobId, [BatchJobsListFailuresOptions options])` | `GET /api/v1/batch-jobs/{batch_job_id}/failures` | [`BatchJobFailuresResponse`](src/main/java/com/meteroid/models/BatchJobFailuresResponse.java) |
+| `BatchJobsListFailuresPage client.batchJobs().listFailures(String batchJobId, [BatchJobsListFailuresOptions options])` | `GET /api/v1/batch-jobs/{batch_job_id}/failures` | [page](src/main/java/com/meteroid/api/BatchJobsListFailuresPage.java) of [`BatchJobItemFailureResponse`](src/main/java/com/meteroid/models/BatchJobItemFailureResponse.java), with the properties of [`BatchJobFailuresResponse`](src/main/java/com/meteroid/models/BatchJobFailuresResponse.java) |
## Checkout sessions
@@ -64,7 +70,7 @@ idempotency key of that call. `client.async()` has the same methods returning
| Method | Request | Returns |
| --- | --- | --- |
-| `CouponListResponse client.coupons().list([CouponsListOptions options])` | `GET /api/v1/coupons` | [`CouponListResponse`](src/main/java/com/meteroid/models/CouponListResponse.java) |
+| `CouponsListPage client.coupons().list([CouponsListOptions options])` | `GET /api/v1/coupons` | [page](src/main/java/com/meteroid/api/CouponsListPage.java) of [`Coupon`](src/main/java/com/meteroid/models/Coupon.java), with the properties of [`CouponListResponse`](src/main/java/com/meteroid/models/CouponListResponse.java) |
| `Coupon client.coupons().create(CreateCouponRequest createCouponRequest)` | `POST /api/v1/coupons` | [`Coupon`](src/main/java/com/meteroid/models/Coupon.java) |
| `Coupon client.coupons().retrieve(String couponId)` | `GET /api/v1/coupons/{coupon_id}` | [`Coupon`](src/main/java/com/meteroid/models/Coupon.java) |
| `Coupon client.coupons().update(String couponId, UpdateCouponRequest updateCouponRequest)` | `PATCH /api/v1/coupons/{coupon_id}` | [`Coupon`](src/main/java/com/meteroid/models/Coupon.java) |
@@ -79,7 +85,7 @@ idempotency key of that call. `client.async()` has the same methods returning
| Method | Request | Returns |
| --- | --- | --- |
-| `CreditNoteListResponse client.creditNotes().list([CreditNotesListOptions options])` | `GET /api/v1/credit-notes` | [`CreditNoteListResponse`](src/main/java/com/meteroid/models/CreditNoteListResponse.java) |
+| `CreditNotesListPage client.creditNotes().list([CreditNotesListOptions options])` | `GET /api/v1/credit-notes` | [page](src/main/java/com/meteroid/api/CreditNotesListPage.java) of [`CreditNote`](src/main/java/com/meteroid/models/CreditNote.java), with the properties of [`CreditNoteListResponse`](src/main/java/com/meteroid/models/CreditNoteListResponse.java) |
| `CreditNote client.creditNotes().retrieve(String creditNoteId)` | `GET /api/v1/credit-notes/{credit_note_id}` | [`CreditNote`](src/main/java/com/meteroid/models/CreditNote.java) |
| `CreditNote client.creditNotes().updateCustomProperties(String creditNoteId, CreditNoteCustomPropertiesRequest creditNoteCustomPropertiesRequest)` | `PATCH /api/v1/credit-notes/{credit_note_id}/custom-properties` | [`CreditNote`](src/main/java/com/meteroid/models/CreditNote.java) |
| `byte[] client.creditNotes().download(String creditNoteId)` | `GET /api/v1/credit-notes/{credit_note_id}/download` | bytes |
@@ -91,7 +97,7 @@ idempotency key of that call. `client.async()` has the same methods returning
| Method | Request | Returns |
| --- | --- | --- |
-| `CustomPropertyDefinitionListResponse client.customProperties().listCustomPropertyDefinitions([CustomPropertiesListCustomPropertyDefinitionsOptions options])` | `GET /api/v1/custom-property-definitions` | [`CustomPropertyDefinitionListResponse`](src/main/java/com/meteroid/models/CustomPropertyDefinitionListResponse.java) |
+| `CustomPropertiesListCustomPropertyDefinitionsPage client.customProperties().listCustomPropertyDefinitions([CustomPropertiesListCustomPropertyDefinitionsOptions options])` | `GET /api/v1/custom-property-definitions` | [page](src/main/java/com/meteroid/api/CustomPropertiesListCustomPropertyDefinitionsPage.java) of [`CustomPropertyDefinition`](src/main/java/com/meteroid/models/CustomPropertyDefinition.java), with the properties of [`CustomPropertyDefinitionListResponse`](src/main/java/com/meteroid/models/CustomPropertyDefinitionListResponse.java) |
| `CustomPropertyDefinition client.customProperties().createCustomPropertyDefinition(CustomPropertyDefinitionCreateRequest customPropertyDefinitionCreateRequest)` | `POST /api/v1/custom-property-definitions` | [`CustomPropertyDefinition`](src/main/java/com/meteroid/models/CustomPropertyDefinition.java) |
| `CustomPropertyDefinition client.customProperties().retrieveCustomPropertyDefinition(String id)` | `GET /api/v1/custom-property-definitions/{id}` | [`CustomPropertyDefinition`](src/main/java/com/meteroid/models/CustomPropertyDefinition.java) |
| `CustomPropertyDefinition client.customProperties().updateCustomPropertyDefinition(String id, CustomPropertyDefinitionUpdateRequest customPropertyDefinitionUpdateRequest)` | `PUT /api/v1/custom-property-definitions/{id}` | [`CustomPropertyDefinition`](src/main/java/com/meteroid/models/CustomPropertyDefinition.java) |
@@ -103,7 +109,7 @@ idempotency key of that call. `client.async()` has the same methods returning
| Method | Request | Returns |
| --- | --- | --- |
-| `CustomerListResponse client.customers().list([CustomersListOptions options])` | `GET /api/v1/customers` | [`CustomerListResponse`](src/main/java/com/meteroid/models/CustomerListResponse.java) |
+| `CustomersListPage client.customers().list([CustomersListOptions options])` | `GET /api/v1/customers` | [page](src/main/java/com/meteroid/api/CustomersListPage.java) of [`Customer`](src/main/java/com/meteroid/models/Customer.java), with the properties of [`CustomerListResponse`](src/main/java/com/meteroid/models/CustomerListResponse.java) |
| `Customer client.customers().create(CustomerCreateRequest customerCreateRequest)` | `POST /api/v1/customers` | [`Customer`](src/main/java/com/meteroid/models/Customer.java) |
| `Customer client.customers().retrieve(String idOrAlias)` | `GET /api/v1/customers/{id_or_alias}` | [`Customer`](src/main/java/com/meteroid/models/Customer.java) |
| `Customer client.customers().replace(String idOrAlias, CustomerUpdateRequest customerUpdateRequest)` | `PUT /api/v1/customers/{id_or_alias}` | [`Customer`](src/main/java/com/meteroid/models/Customer.java) |
@@ -137,7 +143,7 @@ idempotency key of that call. `client.async()` has the same methods returning
| Method | Request | Returns |
| --- | --- | --- |
-| `FeatureListResponse client.features().list([FeaturesListOptions options])` | `GET /api/v1/features` | [`FeatureListResponse`](src/main/java/com/meteroid/models/FeatureListResponse.java) |
+| `FeaturesListPage client.features().list([FeaturesListOptions options])` | `GET /api/v1/features` | [page](src/main/java/com/meteroid/api/FeaturesListPage.java) of [`Feature`](src/main/java/com/meteroid/models/Feature.java), with the properties of [`FeatureListResponse`](src/main/java/com/meteroid/models/FeatureListResponse.java) |
| `Feature client.features().create(CreateFeatureRequest createFeatureRequest)` | `POST /api/v1/features` | [`Feature`](src/main/java/com/meteroid/models/Feature.java) |
| `Feature client.features().retrieve(String idOrCode)` | `GET /api/v1/features/{id_or_code}` | [`Feature`](src/main/java/com/meteroid/models/Feature.java) |
| `Feature client.features().update(String idOrCode, UpdateFeatureRequest updateFeatureRequest)` | `PATCH /api/v1/features/{id_or_code}` | [`Feature`](src/main/java/com/meteroid/models/Feature.java) |
@@ -150,7 +156,7 @@ idempotency key of that call. `client.async()` has the same methods returning
| Method | Request | Returns |
| --- | --- | --- |
-| `InvoiceListResponse client.invoices().list([InvoicesListOptions options])` | `GET /api/v1/invoices` | [`InvoiceListResponse`](src/main/java/com/meteroid/models/InvoiceListResponse.java) |
+| `InvoicesListPage client.invoices().list([InvoicesListOptions options])` | `GET /api/v1/invoices` | [page](src/main/java/com/meteroid/api/InvoicesListPage.java) of [`Invoice`](src/main/java/com/meteroid/models/Invoice.java), with the properties of [`InvoiceListResponse`](src/main/java/com/meteroid/models/InvoiceListResponse.java) |
| `Invoice client.invoices().retrieve(String invoiceId)` | `GET /api/v1/invoices/{invoice_id}` | [`Invoice`](src/main/java/com/meteroid/models/Invoice.java) |
| `Invoice client.invoices().updateCustomProperties(String invoiceId, InvoiceCustomPropertiesRequest invoiceCustomPropertiesRequest)` | `PATCH /api/v1/invoices/{invoice_id}/custom-properties` | [`Invoice`](src/main/java/com/meteroid/models/Invoice.java) |
| `byte[] client.invoices().download(String invoiceId)` | `GET /api/v1/invoices/{invoice_id}/download` | bytes |
@@ -163,7 +169,7 @@ idempotency key of that call. `client.async()` has the same methods returning
| Method | Request | Returns |
| --- | --- | --- |
-| `MetricListResponse client.metrics().list([MetricsListOptions options])` | `GET /api/v1/metrics` | [`MetricListResponse`](src/main/java/com/meteroid/models/MetricListResponse.java) |
+| `MetricsListPage client.metrics().list([MetricsListOptions options])` | `GET /api/v1/metrics` | [page](src/main/java/com/meteroid/api/MetricsListPage.java) of [`MetricSummary`](src/main/java/com/meteroid/models/MetricSummary.java), with the properties of [`MetricListResponse`](src/main/java/com/meteroid/models/MetricListResponse.java) |
| `Metric client.metrics().create(CreateMetricRequest createMetricRequest)` | `POST /api/v1/metrics` | [`Metric`](src/main/java/com/meteroid/models/Metric.java) |
| `Metric client.metrics().retrieve(String metricId)` | `GET /api/v1/metrics/{metric_id}` | [`Metric`](src/main/java/com/meteroid/models/Metric.java) |
| `Metric client.metrics().update(String metricId, UpdateMetricRequest updateMetricRequest)` | `PATCH /api/v1/metrics/{metric_id}` | [`Metric`](src/main/java/com/meteroid/models/Metric.java) |
@@ -200,7 +206,7 @@ idempotency key of that call. `client.async()` has the same methods returning
| --- | --- | --- |
| `ResolvedEntitlementListResponse client.plans().listPlanVersionEntitlements(String planVersionId)` | `GET /api/v1/plan-versions/{plan_version_id}/entitlements` | [`ResolvedEntitlementListResponse`](src/main/java/com/meteroid/models/ResolvedEntitlementListResponse.java) |
| `EntitlementListResponse client.plans().createPlanVersionEntitlement(String planVersionId, CreateEntitlementsRequest createEntitlementsRequest)` | `POST /api/v1/plan-versions/{plan_version_id}/entitlements` | [`EntitlementListResponse`](src/main/java/com/meteroid/models/EntitlementListResponse.java) |
-| `PlanListResponse client.plans().list([PlansListOptions options])` | `GET /api/v1/plans` | [`PlanListResponse`](src/main/java/com/meteroid/models/PlanListResponse.java) |
+| `PlansListPage client.plans().list([PlansListOptions options])` | `GET /api/v1/plans` | [page](src/main/java/com/meteroid/api/PlansListPage.java) of [`Plan`](src/main/java/com/meteroid/models/Plan.java), with the properties of [`PlanListResponse`](src/main/java/com/meteroid/models/PlanListResponse.java) |
| `Plan client.plans().create(CreatePlanRequest createPlanRequest)` | `POST /api/v1/plans` | [`Plan`](src/main/java/com/meteroid/models/Plan.java) |
| `MinimumCommitment client.plans().updateVersionMinimum(String planVersionId, MinimumCommitment minimumCommitment)` | `PUT /api/v1/plans/versions/{plan_version_id}/minimum` | [`MinimumCommitment`](src/main/java/com/meteroid/models/MinimumCommitment.java) |
| `void client.plans().deleteVersionMinimum(String planVersionId)` | `DELETE /api/v1/plans/versions/{plan_version_id}/minimum` | nothing |
@@ -210,7 +216,7 @@ idempotency key of that call. `client.async()` has the same methods returning
| `void client.plans().archive(String planId)` | `POST /api/v1/plans/{plan_id}/archive` | nothing |
| `Plan client.plans().publish(String planId)` | `POST /api/v1/plans/{plan_id}/publish` | [`Plan`](src/main/java/com/meteroid/models/Plan.java) |
| `void client.plans().unarchive(String planId)` | `POST /api/v1/plans/{plan_id}/unarchive` | nothing |
-| `PlanVersionListResponse client.plans().listVersions(String planId, [PlansListVersionsOptions options])` | `GET /api/v1/plans/{plan_id}/versions` | [`PlanVersionListResponse`](src/main/java/com/meteroid/models/PlanVersionListResponse.java) |
+| `PlansListVersionsPage client.plans().listVersions(String planId, [PlansListVersionsOptions options])` | `GET /api/v1/plans/{plan_id}/versions` | [page](src/main/java/com/meteroid/api/PlansListVersionsPage.java) of [`PlanVersionSummary`](src/main/java/com/meteroid/models/PlanVersionSummary.java), with the properties of [`PlanVersionListResponse`](src/main/java/com/meteroid/models/PlanVersionListResponse.java) |
## Product families
@@ -218,7 +224,7 @@ idempotency key of that call. `client.async()` has the same methods returning
| Method | Request | Returns |
| --- | --- | --- |
-| `ProductFamilyListResponse client.productFamilies().list([ProductFamiliesListOptions options])` | `GET /api/v1/product_families` | [`ProductFamilyListResponse`](src/main/java/com/meteroid/models/ProductFamilyListResponse.java) |
+| `ProductFamiliesListPage client.productFamilies().list([ProductFamiliesListOptions options])` | `GET /api/v1/product_families` | [page](src/main/java/com/meteroid/api/ProductFamiliesListPage.java) of [`ProductFamily`](src/main/java/com/meteroid/models/ProductFamily.java), with the properties of [`ProductFamilyListResponse`](src/main/java/com/meteroid/models/ProductFamilyListResponse.java) |
| `ProductFamily client.productFamilies().create(ProductFamilyCreateRequest productFamilyCreateRequest)` | `POST /api/v1/product_families` | [`ProductFamily`](src/main/java/com/meteroid/models/ProductFamily.java) |
| `ProductFamily client.productFamilies().retrieve(String idOrAlias)` | `GET /api/v1/product_families/{id_or_alias}` | [`ProductFamily`](src/main/java/com/meteroid/models/ProductFamily.java) |
@@ -228,7 +234,7 @@ idempotency key of that call. `client.async()` has the same methods returning
| Method | Request | Returns |
| --- | --- | --- |
-| `ProductListResponse client.products().list([ProductsListOptions options])` | `GET /api/v1/products` | [`ProductListResponse`](src/main/java/com/meteroid/models/ProductListResponse.java) |
+| `ProductsListPage client.products().list([ProductsListOptions options])` | `GET /api/v1/products` | [page](src/main/java/com/meteroid/api/ProductsListPage.java) of [`Product`](src/main/java/com/meteroid/models/Product.java), with the properties of [`ProductListResponse`](src/main/java/com/meteroid/models/ProductListResponse.java) |
| `Product client.products().create(CreateProductRequest createProductRequest)` | `POST /api/v1/products` | [`Product`](src/main/java/com/meteroid/models/Product.java) |
| `Product client.products().retrieve(String productId)` | `GET /api/v1/products/{product_id}` | [`Product`](src/main/java/com/meteroid/models/Product.java) |
| `Product client.products().update(String productId, UpdateProductRequest updateProductRequest)` | `PATCH /api/v1/products/{product_id}` | [`Product`](src/main/java/com/meteroid/models/Product.java) |
@@ -243,7 +249,7 @@ idempotency key of that call. `client.async()` has the same methods returning
| Method | Request | Returns |
| --- | --- | --- |
-| `SubscriptionListResponse client.subscriptions().list([SubscriptionsListOptions options])` | `GET /api/v1/subscriptions` | [`SubscriptionListResponse`](src/main/java/com/meteroid/models/SubscriptionListResponse.java) |
+| `SubscriptionsListPage client.subscriptions().list([SubscriptionsListOptions options])` | `GET /api/v1/subscriptions` | [page](src/main/java/com/meteroid/api/SubscriptionsListPage.java) of [`Subscription`](src/main/java/com/meteroid/models/Subscription.java), with the properties of [`SubscriptionListResponse`](src/main/java/com/meteroid/models/SubscriptionListResponse.java) |
| `SubscriptionDetails client.subscriptions().create(SubscriptionCreateRequest subscriptionCreateRequest)` | `POST /api/v1/subscriptions` | [`SubscriptionDetails`](src/main/java/com/meteroid/models/SubscriptionDetails.java) |
| `SubscriptionDetails client.subscriptions().retrieve(String subscriptionId)` | `GET /api/v1/subscriptions/{subscription_id}` | [`SubscriptionDetails`](src/main/java/com/meteroid/models/SubscriptionDetails.java) |
| `SubscriptionUpdateResponse client.subscriptions().update(String subscriptionId, SubscriptionUpdateRequest subscriptionUpdateRequest)` | `PATCH /api/v1/subscriptions/{subscription_id}` | [`SubscriptionUpdateResponse`](src/main/java/com/meteroid/models/SubscriptionUpdateResponse.java) |
diff --git a/src/main/java/com/meteroid/AsyncPage.java b/src/main/java/com/meteroid/AsyncPage.java
index 3ee4dfe..9707e06 100644
--- a/src/main/java/com/meteroid/AsyncPage.java
+++ b/src/main/java/com/meteroid/AsyncPage.java
@@ -6,34 +6,30 @@
import java.util.List;
import java.util.NoSuchElementException;
import java.util.concurrent.CompletableFuture;
+import java.util.function.Consumer;
import java.util.function.Supplier;
/**
* One page of a paginated list operation of the async client: its items, and the way to the next
- * page.
+ * page. Each list operation returns its own subclass, which also has the getters of the response
+ * body.
*
+ * @param
the type of the pages
* @param the type of the items
*/
-public final class AsyncPage {
+public abstract class AsyncPage, T> {
private final List items;
- private final Supplier>> next;
-
- private AsyncPage(List items, Supplier>> next) {
- this.items = Collections.unmodifiableList(new ArrayList<>(items));
- this.next = next;
- }
+ private final Supplier> next;
/**
* A page, built by the SDK.
*
- * @param the type of the items
* @param items the items of the page
* @param next fetches the next page, or null on the last page
- * @return the page
*/
- public static AsyncPage of(
- List items, Supplier>> next) {
- return new AsyncPage<>(items, next);
+ protected AsyncPage(List items, Supplier> next) {
+ this.items = Collections.unmodifiableList(new ArrayList<>(items));
+ this.next = next;
}
/**
@@ -41,7 +37,7 @@ public static AsyncPage of(
*
* @return the items, unmodifiable
*/
- public List items() {
+ public final List items() {
return items;
}
@@ -50,7 +46,7 @@ public List items() {
*
* @return false on the last page
*/
- public boolean hasNextPage() {
+ public final boolean hasNextPage() {
return next != null;
}
@@ -59,7 +55,7 @@ public boolean hasNextPage() {
*
* @return the next page, failed with {@link NoSuchElementException} on the last page
*/
- public CompletableFuture> nextPage() {
+ public final CompletableFuture nextPage() {
if (next == null) {
return CompletableFuture.failedFuture(
new NoSuchElementException("this is the last page"));
@@ -67,8 +63,45 @@ public CompletableFuture> nextPage() {
return next.get();
}
- @Override
- public String toString() {
- return "AsyncPage{items=" + items + ", hasNextPage=" + hasNextPage() + "}";
+ /**
+ * Calls {@code action} with this page and each one after it, fetching the next page once the
+ * action returns.
+ *
+ * @param action called with each page, in order
+ * @return completes after the last page, or with the first error
+ */
+ public final CompletableFuture forEachPage(Consumer super P> action) {
+ P page = self();
+ action.accept(page);
+ if (!page.hasNextPage()) {
+ return CompletableFuture.completedFuture(null);
+ }
+ return page.nextPage().thenCompose(next -> next.forEachPage(action));
+ }
+
+ /**
+ * Calls {@code action} with every item from this page on, fetching the next page once the items
+ * of one are done.
+ *
+ * @param action called with each item, in order
+ * @return completes after the last item, or with the first error
+ */
+ public final CompletableFuture forEach(Consumer super T> action) {
+ return forEachPage(page -> page.items().forEach(action));
+ }
+
+ /**
+ * Collects every item from this page on.
+ *
+ * @return the items of this page and the ones after it
+ */
+ public final CompletableFuture> toList() {
+ List all = new ArrayList<>();
+ return forEach(all::add).thenApply(done -> all);
+ }
+
+ @SuppressWarnings("unchecked")
+ private P self() {
+ return (P) this;
}
}
diff --git a/src/main/java/com/meteroid/AsyncPaginator.java b/src/main/java/com/meteroid/AsyncPaginator.java
deleted file mode 100644
index 3f21e71..0000000
--- a/src/main/java/com/meteroid/AsyncPaginator.java
+++ /dev/null
@@ -1,63 +0,0 @@
-// this file is @generated by Perseid; edit the shared runtime template.
-package com.meteroid;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.CompletableFuture;
-import java.util.function.Consumer;
-import java.util.function.Supplier;
-
-/**
- * Every item of a paginated list operation of the async client, fetched page by page.
- *
- * @param the type of the items
- */
-public final class AsyncPaginator {
- private final Supplier>> first;
-
- /**
- * A paginator, built by the SDK.
- *
- * @param first fetches the first page
- */
- public AsyncPaginator(Supplier>> first) {
- this.first = first;
- }
-
- /**
- * Fetches the first page.
- *
- * @return the first page
- */
- public CompletableFuture> firstPage() {
- return first.get();
- }
-
- /**
- * Calls {@code action} with every item, fetching the next page once the items of one are done.
- *
- * @param action called with each item, in order
- * @return completes after the last item, or with the first error
- */
- public CompletableFuture forEach(Consumer super T> action) {
- return firstPage().thenCompose(page -> forEach(page, action));
- }
-
- /**
- * Collects every item.
- *
- * @return the items of every page
- */
- public CompletableFuture> toList() {
- List items = new ArrayList<>();
- return forEach(items::add).thenApply(done -> items);
- }
-
- private CompletableFuture forEach(AsyncPage page, Consumer super T> action) {
- page.items().forEach(action);
- if (!page.hasNextPage()) {
- return CompletableFuture.completedFuture(null);
- }
- return page.nextPage().thenCompose(next -> forEach(next, action));
- }
-}
diff --git a/src/main/java/com/meteroid/Meteroid.java b/src/main/java/com/meteroid/Meteroid.java
index 8fa8d3c..2f06564 100644
--- a/src/main/java/com/meteroid/Meteroid.java
+++ b/src/main/java/com/meteroid/Meteroid.java
@@ -42,13 +42,15 @@
* }
*
* Without an API key, the client reads {@value MeteroidOptions#API_KEY_ENV}, and {@value
- * MeteroidOptions#BASE_URL_ENV} overrides the base URL, which the API has no default for: one of
- * them is required.
+ * MeteroidOptions#BASE_URL_ENV} overrides the base URL, {@link #DEFAULT_BASE_URL} otherwise.
*/
public final class Meteroid implements AutoCloseable {
private static final Map SECURITY_SCHEMES =
Map.ofEntries(Map.entry("bearer_auth", new MeteroidAuth.Scheme("bearer", null, null)));
+ /** The base URL of the API when neither the options nor the environment set one. */
+ public static final String DEFAULT_BASE_URL = "https://api.meteroid.com";
+
private final MeteroidOptions options;
private final MeteroidHttpClient httpClient;
private final WithRawResponse withRawResponse;
@@ -107,17 +109,12 @@ public Meteroid(String apiKey, MeteroidOptions options) {
* A client with custom options.
*
* @param options the options; the environment supplies the API key and base URL they leave out
- * @throws IllegalStateException when neither the options nor the environment set a base URL
*/
public Meteroid(MeteroidOptions options) {
this.options = options;
- String baseUrl = options.baseUrl().orElseGet(() -> env(MeteroidOptions.BASE_URL_ENV, null));
- if (baseUrl == null) {
- throw new IllegalStateException(
- "no base URL: set MeteroidOptions.builder().baseUrl(...) or the "
- + MeteroidOptions.BASE_URL_ENV
- + " environment variable");
- }
+ String baseUrl =
+ options.baseUrl()
+ .orElseGet(() -> env(MeteroidOptions.BASE_URL_ENV, DEFAULT_BASE_URL));
HttpUrl parsedUrl = HttpUrl.parse(baseUrl);
if (parsedUrl == null) {
throw new IllegalArgumentException("Invalid base URL: " + baseUrl);
diff --git a/src/main/java/com/meteroid/Page.java b/src/main/java/com/meteroid/Page.java
index dab46c9..9c4a505 100644
--- a/src/main/java/com/meteroid/Page.java
+++ b/src/main/java/com/meteroid/Page.java
@@ -3,34 +3,36 @@
import java.util.ArrayList;
import java.util.Collections;
+import java.util.Iterator;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.function.Supplier;
+import java.util.stream.Stream;
+import java.util.stream.StreamSupport;
/**
- * One page of a paginated list operation: its items, and the way to the next page.
+ * One page of a paginated list operation: its items, and the way to the next page. Each list
+ * operation returns its own subclass, which also has the getters of the response body.
*
+ * Iterating a page yields every item from this page on, fetching the next pages as the iteration
+ * goes; each iteration fetches them again.
+ *
+ * @param
the type of the pages
* @param the type of the items
*/
-public final class Page {
+public abstract class Page, T> implements Iterable {
private final List items;
- private final Supplier> next;
-
- private Page(List items, Supplier> next) {
- this.items = Collections.unmodifiableList(new ArrayList<>(items));
- this.next = next;
- }
+ private final Supplier next;
/**
* A page, built by the SDK.
*
- * @param the type of the items
* @param items the items of the page
* @param next fetches the next page, or null on the last page
- * @return the page
*/
- public static Page of(List items, Supplier> next) {
- return new Page<>(items, next);
+ protected Page(List items, Supplier next) {
+ this.items = Collections.unmodifiableList(new ArrayList<>(items));
+ this.next = next;
}
/**
@@ -38,7 +40,7 @@ public static Page of(List items, Supplier> next) {
*
* @return the items, unmodifiable
*/
- public List items() {
+ public final List items() {
return items;
}
@@ -47,7 +49,7 @@ public List items() {
*
* @return false on the last page
*/
- public boolean hasNextPage() {
+ public final boolean hasNextPage() {
return next != null;
}
@@ -57,15 +59,75 @@ public boolean hasNextPage() {
* @return the next page
* @throws NoSuchElementException on the last page
*/
- public Page nextPage() {
+ public final P nextPage() {
if (next == null) {
throw new NoSuchElementException("this is the last page");
}
return next.get();
}
+ /**
+ * This page and the ones after it, fetched as the iteration goes.
+ *
+ * @return the pages, from this one
+ */
+ public final Iterable pages() {
+ return () ->
+ new Iterator<>() {
+ private P current;
+
+ @Override
+ public boolean hasNext() {
+ return current == null || current.hasNextPage();
+ }
+
+ @Override
+ public P next() {
+ if (!hasNext()) {
+ throw new NoSuchElementException();
+ }
+ current = current == null ? self() : current.nextPage();
+ return current;
+ }
+ };
+ }
+
+ /**
+ * The items of this page and the ones after it, as a sequential stream fetching pages on
+ * demand.
+ *
+ * @return every item from this page on
+ */
+ public final Stream stream() {
+ return StreamSupport.stream(spliterator(), false);
+ }
+
@Override
- public String toString() {
- return "Page{items=" + items + ", hasNextPage=" + hasNextPage() + "}";
+ public final Iterator iterator() {
+ Iterator pages = pages().iterator();
+ return new Iterator<>() {
+ private Iterator items = Collections.emptyIterator();
+
+ @Override
+ public boolean hasNext() {
+ while (!items.hasNext() && pages.hasNext()) {
+ items = pages.next().items().iterator();
+ }
+ return items.hasNext();
+ }
+
+ @Override
+ public T next() {
+ if (!hasNext()) {
+ throw new NoSuchElementException();
+ }
+ return items.next();
+ }
+ };
+ }
+
+ @SuppressWarnings("unchecked")
+ private P self() {
+ return (P) this;
}
}
diff --git a/src/main/java/com/meteroid/Paginator.java b/src/main/java/com/meteroid/Paginator.java
deleted file mode 100644
index 7a88500..0000000
--- a/src/main/java/com/meteroid/Paginator.java
+++ /dev/null
@@ -1,98 +0,0 @@
-// this file is @generated by Perseid; edit the shared runtime template.
-package com.meteroid;
-
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-import java.util.function.Supplier;
-import java.util.stream.Stream;
-import java.util.stream.StreamSupport;
-
-/**
- * Every item of a paginated list operation, fetched page by page as the iteration goes. Each
- * iteration starts over from the first page; {@link #pages()} goes page by page instead.
- *
- * @param the type of the items
- */
-public final class Paginator implements Iterable {
- private final Supplier> first;
-
- /**
- * A paginator, built by the SDK.
- *
- * @param first fetches the first page
- */
- public Paginator(Supplier> first) {
- this.first = first;
- }
-
- /**
- * Fetches the first page.
- *
- * @return the first page
- */
- public Page firstPage() {
- return first.get();
- }
-
- /**
- * The pages, fetched as the iteration goes.
- *
- * @return the pages, from the first one
- */
- public Iterable> pages() {
- return () ->
- new Iterator<>() {
- private Page current;
- private boolean started;
-
- @Override
- public boolean hasNext() {
- return !started || current.hasNextPage();
- }
-
- @Override
- public Page next() {
- if (!hasNext()) {
- throw new NoSuchElementException();
- }
- current = started ? current.nextPage() : firstPage();
- started = true;
- return current;
- }
- };
- }
-
- /**
- * The items, as a sequential stream fetching pages on demand.
- *
- * @return the items of every page
- */
- public Stream stream() {
- return StreamSupport.stream(spliterator(), false);
- }
-
- @Override
- public Iterator iterator() {
- Iterator> pages = pages().iterator();
- return new Iterator<>() {
- private Iterator items = Collections.emptyIterator();
-
- @Override
- public boolean hasNext() {
- while (!items.hasNext() && pages.hasNext()) {
- items = pages.next().items().iterator();
- }
- return items.hasNext();
- }
-
- @Override
- public T next() {
- if (!hasNext()) {
- throw new NoSuchElementException();
- }
- return items.next();
- }
- };
- }
-}
diff --git a/src/main/java/com/meteroid/api/AddOns.java b/src/main/java/com/meteroid/api/AddOns.java
index fba154e..b2712e1 100644
--- a/src/main/java/com/meteroid/api/AddOns.java
+++ b/src/main/java/com/meteroid/api/AddOns.java
@@ -15,6 +15,7 @@
import okhttp3.HttpUrl;
+import java.util.List;
import java.util.Objects;
/**
@@ -47,9 +48,9 @@ public WithRawResponse withRawResponse() {
/**
* List add-ons
*
- * @return the response body
+ * @return the page: the response body, its items and the way to the next pages
*/
- public AddOnListResponse list() {
+ public AddOnsListPage list() {
return list(AddOnsListOptions.none(), RequestOptions.none());
}
@@ -57,9 +58,9 @@ public AddOnListResponse list() {
* List add-ons
*
* @param options the optional parameters
- * @return the response body
+ * @return the page: the response body, its items and the way to the next pages
*/
- public AddOnListResponse list(final AddOnsListOptions options) {
+ public AddOnsListPage list(final AddOnsListOptions options) {
return list(options, RequestOptions.none());
}
@@ -67,9 +68,9 @@ public AddOnListResponse list(final AddOnsListOptions options) {
* List add-ons
*
* @param requestOptions headers, timeout and retries of this call
- * @return the response body
+ * @return the page: the response body, its items and the way to the next pages
*/
- public AddOnListResponse list(final RequestOptions requestOptions) {
+ public AddOnsListPage list(final RequestOptions requestOptions) {
return list(AddOnsListOptions.none(), requestOptions);
}
@@ -78,11 +79,11 @@ public AddOnListResponse list(final RequestOptions requestOptions) {
*
* @param options the optional parameters
* @param requestOptions headers, timeout and retries of this call
- * @return the response body
+ * @return the page: the response body, its items and the way to the next pages
*/
- public AddOnListResponse list(
+ public AddOnsListPage list(
final AddOnsListOptions options, final RequestOptions requestOptions) {
- return exchangeList(options, requestOptions).send();
+ return pageOfList(exchangeList(options, requestOptions).send(), options, requestOptions);
}
MeteroidHttpClient.Exchange exchangeList(
@@ -119,6 +120,40 @@ MeteroidHttpClient.Exchange exchangeList(
.returning(AddOnListResponse.class);
}
+ private AddOnsListPage pageOfList(
+ AddOnListResponse response,
+ final AddOnsListOptions options,
+ final RequestOptions requestOptions) {
+ List items = itemsOfList(response);
+ Integer next = nextOfList(response, items, options.page().orElse(0));
+ return new AddOnsListPage(
+ response,
+ items,
+ next == null
+ ? null
+ : () -> list(options.toBuilder().page(next).build(), requestOptions));
+ }
+
+ static List itemsOfList(AddOnListResponse response) {
+ return Utils.optional(response.data()).orElse(List.of());
+ }
+
+ /** The parameter of the page after {@code response}, null after the last one. */
+ static Integer nextOfList(AddOnListResponse response, List items, Integer current) {
+ if (items.isEmpty()) {
+ return null;
+ }
+ long pages =
+ Utils.optional(response.paginationMeta())
+ .flatMap(v2 -> Utils.optional(v2.totalPages()))
+ .map(Number::longValue)
+ .orElse(Long.MAX_VALUE);
+ if (current - 0 + 1 >= pages) {
+ return null;
+ }
+ return current + 1;
+ }
+
/**
* Create an add-on
*
@@ -393,9 +428,9 @@ private WithRawResponse() {}
/**
* List add-ons
*
- * @return the status, headers and body
+ * @return the status, headers and page
*/
- public ApiResponse list() {
+ public ApiResponse list() {
return list(AddOnsListOptions.none(), RequestOptions.none());
}
@@ -403,9 +438,9 @@ public ApiResponse list() {
* List add-ons
*
* @param options the optional parameters
- * @return the status, headers and body
+ * @return the status, headers and page
*/
- public ApiResponse list(final AddOnsListOptions options) {
+ public ApiResponse list(final AddOnsListOptions options) {
return list(options, RequestOptions.none());
}
@@ -413,9 +448,9 @@ public ApiResponse list(final AddOnsListOptions options) {
* List add-ons
*
* @param requestOptions headers, timeout and retries of this call
- * @return the status, headers and body
+ * @return the status, headers and page
*/
- public ApiResponse list(final RequestOptions requestOptions) {
+ public ApiResponse list(final RequestOptions requestOptions) {
return list(AddOnsListOptions.none(), requestOptions);
}
@@ -424,11 +459,16 @@ public ApiResponse list(final RequestOptions requestOptions)
*
* @param options the optional parameters
* @param requestOptions headers, timeout and retries of this call
- * @return the status, headers and body
+ * @return the status, headers and page
*/
- public ApiResponse list(
+ public ApiResponse list(
final AddOnsListOptions options, final RequestOptions requestOptions) {
- return AddOns.this.exchangeList(options, requestOptions).sendRaw();
+ ApiResponse response =
+ exchangeList(options, requestOptions).sendRaw();
+ return new ApiResponse<>(
+ response.statusCode(),
+ response.headers(),
+ pageOfList(response.body(), options, requestOptions));
}
/**
diff --git a/src/main/java/com/meteroid/api/AddOnsAsync.java b/src/main/java/com/meteroid/api/AddOnsAsync.java
index a01df16..a963298 100644
--- a/src/main/java/com/meteroid/api/AddOnsAsync.java
+++ b/src/main/java/com/meteroid/api/AddOnsAsync.java
@@ -11,6 +11,7 @@
import com.meteroid.models.ResolvedEntitlementListResponse;
import com.meteroid.models.UpdateAddOnRequest;
+import java.util.List;
import java.util.concurrent.CompletableFuture;
/**
@@ -43,9 +44,9 @@ public WithRawResponse withRawResponse() {
/**
* List add-ons
*
- * @return the response body, once received
+ * @return the page, once received
*/
- public CompletableFuture list() {
+ public CompletableFuture list() {
return list(AddOnsListOptions.none(), RequestOptions.none());
}
@@ -53,9 +54,9 @@ public CompletableFuture list() {
* List add-ons
*
* @param options the optional parameters
- * @return the response body, once received
+ * @return the page, once received
*/
- public CompletableFuture list(final AddOnsListOptions options) {
+ public CompletableFuture list(final AddOnsListOptions options) {
return list(options, RequestOptions.none());
}
@@ -63,9 +64,9 @@ public CompletableFuture list(final AddOnsListOptions options
* List add-ons
*
* @param requestOptions headers, timeout and retries of this call
- * @return the response body, once received
+ * @return the page, once received
*/
- public CompletableFuture list(final RequestOptions requestOptions) {
+ public CompletableFuture list(final RequestOptions requestOptions) {
return list(AddOnsListOptions.none(), requestOptions);
}
@@ -74,11 +75,27 @@ public CompletableFuture list(final RequestOptions requestOpt
*
* @param options the optional parameters
* @param requestOptions headers, timeout and retries of this call
- * @return the response body, once received
+ * @return the page, once received
*/
- public CompletableFuture list(
+ public CompletableFuture list(
final AddOnsListOptions options, final RequestOptions requestOptions) {
- return sync.exchangeList(options, requestOptions).sendAsync();
+ return sync.exchangeList(options, requestOptions)
+ .sendAsync()
+ .thenApply(response -> pageOfList(response, options, requestOptions));
+ }
+
+ private AddOnsListAsyncPage pageOfList(
+ AddOnListResponse response,
+ final AddOnsListOptions options,
+ final RequestOptions requestOptions) {
+ List items = AddOns.itemsOfList(response);
+ Integer next = AddOns.nextOfList(response, items, options.page().orElse(0));
+ return new AddOnsListAsyncPage(
+ response,
+ items,
+ next == null
+ ? null
+ : () -> list(options.toBuilder().page(next).build(), requestOptions));
}
/**
@@ -258,9 +275,9 @@ private WithRawResponse() {}
/**
* List add-ons
*
- * @return the status, headers and body, once received
+ * @return the status, headers and page, once received
*/
- public CompletableFuture> list() {
+ public CompletableFuture> list() {
return list(AddOnsListOptions.none(), RequestOptions.none());
}
@@ -268,9 +285,9 @@ public CompletableFuture> list() {
* List add-ons
*
* @param options the optional parameters
- * @return the status, headers and body, once received
+ * @return the status, headers and page, once received
*/
- public CompletableFuture> list(
+ public CompletableFuture> list(
final AddOnsListOptions options) {
return list(options, RequestOptions.none());
}
@@ -279,9 +296,9 @@ public CompletableFuture> list(
* List add-ons
*
* @param requestOptions headers, timeout and retries of this call
- * @return the status, headers and body, once received
+ * @return the status, headers and page, once received
*/
- public CompletableFuture> list(
+ public CompletableFuture> list(
final RequestOptions requestOptions) {
return list(AddOnsListOptions.none(), requestOptions);
}
@@ -291,11 +308,18 @@ public CompletableFuture> list(
*
* @param options the optional parameters
* @param requestOptions headers, timeout and retries of this call
- * @return the status, headers and body, once received
+ * @return the status, headers and page, once received
*/
- public CompletableFuture> list(
+ public CompletableFuture> list(
final AddOnsListOptions options, final RequestOptions requestOptions) {
- return sync.exchangeList(options, requestOptions).sendRawAsync();
+ return sync.exchangeList(options, requestOptions)
+ .sendRawAsync()
+ .thenApply(
+ response ->
+ new ApiResponse<>(
+ response.statusCode(),
+ response.headers(),
+ pageOfList(response.body(), options, requestOptions)));
}
/**
diff --git a/src/main/java/com/meteroid/api/AddOnsListAsyncPage.java b/src/main/java/com/meteroid/api/AddOnsListAsyncPage.java
new file mode 100644
index 0000000..9b32fd5
--- /dev/null
+++ b/src/main/java/com/meteroid/api/AddOnsListAsyncPage.java
@@ -0,0 +1,66 @@
+// this file is @generated
+package com.meteroid.api;
+
+import com.meteroid.AsyncPage;
+import com.meteroid.models.AddOn;
+import com.meteroid.models.AddOnListResponse;
+import com.meteroid.models.PaginationResponse;
+
+import java.util.List;
+import java.util.concurrent.CompletableFuture;
+import java.util.function.Supplier;
+
+/**
+ * A page of {@link AddOnsAsync#list}: the {@link AddOn} items of one response, and the properties
+ * of its body, {@link AddOnListResponse}.
+ */
+public final class AddOnsListAsyncPage extends AsyncPage {
+ private final AddOnListResponse body;
+
+ /**
+ * A page, built by the SDK.
+ *
+ * @param body the response body
+ * @param items the items of the page
+ * @param next fetches the next page, or null on the last page
+ */
+ public AddOnsListAsyncPage(
+ AddOnListResponse body,
+ List items,
+ Supplier> next) {
+ super(items, next);
+ this.body = body;
+ }
+
+ /**
+ * The response body, as received.
+ *
+ * @return the body
+ */
+ public AddOnListResponse body() {
+ return body;
+ }
+
+ /**
+ * The {@code data} property.
+ *
+ * @return the value, never null
+ */
+ public List data() {
+ return body.data();
+ }
+
+ /**
+ * The {@code pagination_meta} property.
+ *
+ * @return the value, never null
+ */
+ public PaginationResponse paginationMeta() {
+ return body.paginationMeta();
+ }
+
+ @Override
+ public String toString() {
+ return "AddOnsListAsyncPage{body=" + body + ", hasNextPage=" + hasNextPage() + "}";
+ }
+}
diff --git a/src/main/java/com/meteroid/api/AddOnsListPage.java b/src/main/java/com/meteroid/api/AddOnsListPage.java
new file mode 100644
index 0000000..5e9d873
--- /dev/null
+++ b/src/main/java/com/meteroid/api/AddOnsListPage.java
@@ -0,0 +1,66 @@
+// this file is @generated
+package com.meteroid.api;
+
+import com.meteroid.Page;
+import com.meteroid.models.AddOn;
+import com.meteroid.models.AddOnListResponse;
+import com.meteroid.models.PaginationResponse;
+
+import java.util.List;
+import java.util.function.Supplier;
+
+/**
+ * A page of {@link AddOns#list}: the {@link AddOn} items of one response, and the properties of its
+ * body, {@link AddOnListResponse}.
+ *
+ * Iterating it yields every item from this page on, fetching the next pages as the iteration
+ * goes.
+ */
+public final class AddOnsListPage extends Page {
+ private final AddOnListResponse body;
+
+ /**
+ * A page, built by the SDK.
+ *
+ * @param body the response body
+ * @param items the items of the page
+ * @param next fetches the next page, or null on the last page
+ */
+ public AddOnsListPage(
+ AddOnListResponse body, List items, Supplier next) {
+ super(items, next);
+ this.body = body;
+ }
+
+ /**
+ * The response body, as received.
+ *
+ * @return the body
+ */
+ public AddOnListResponse body() {
+ return body;
+ }
+
+ /**
+ * The {@code data} property.
+ *
+ * @return the value, never null
+ */
+ public List data() {
+ return body.data();
+ }
+
+ /**
+ * The {@code pagination_meta} property.
+ *
+ * @return the value, never null
+ */
+ public PaginationResponse paginationMeta() {
+ return body.paginationMeta();
+ }
+
+ @Override
+ public String toString() {
+ return "AddOnsListPage{body=" + body + ", hasNextPage=" + hasNextPage() + "}";
+ }
+}
diff --git a/src/main/java/com/meteroid/api/BatchJobs.java b/src/main/java/com/meteroid/api/BatchJobs.java
index 83cac64..b9c8853 100644
--- a/src/main/java/com/meteroid/api/BatchJobs.java
+++ b/src/main/java/com/meteroid/api/BatchJobs.java
@@ -7,7 +7,9 @@
import com.meteroid.internal.Utils;
import com.meteroid.models.BatchJobDetailResponse;
import com.meteroid.models.BatchJobFailuresResponse;
+import com.meteroid.models.BatchJobItemFailureResponse;
import com.meteroid.models.BatchJobListResponse;
+import com.meteroid.models.BatchJobResponse;
import com.meteroid.models.BatchJobStatus;
import com.meteroid.models.BatchJobType;
@@ -46,9 +48,9 @@ public WithRawResponse withRawResponse() {
/**
* List batch jobs with optional filtering by type and status.
*
- * @return the response body
+ * @return the page: the response body, its items and the way to the next pages
*/
- public BatchJobListResponse list() {
+ public BatchJobsListPage list() {
return list(BatchJobsListOptions.none(), RequestOptions.none());
}
@@ -56,9 +58,9 @@ public BatchJobListResponse list() {
* List batch jobs with optional filtering by type and status.
*
* @param options the optional parameters
- * @return the response body
+ * @return the page: the response body, its items and the way to the next pages
*/
- public BatchJobListResponse list(final BatchJobsListOptions options) {
+ public BatchJobsListPage list(final BatchJobsListOptions options) {
return list(options, RequestOptions.none());
}
@@ -66,9 +68,9 @@ public BatchJobListResponse list(final BatchJobsListOptions options) {
* List batch jobs with optional filtering by type and status.
*
* @param requestOptions headers, timeout and retries of this call
- * @return the response body
+ * @return the page: the response body, its items and the way to the next pages
*/
- public BatchJobListResponse list(final RequestOptions requestOptions) {
+ public BatchJobsListPage list(final RequestOptions requestOptions) {
return list(BatchJobsListOptions.none(), requestOptions);
}
@@ -77,11 +79,11 @@ public BatchJobListResponse list(final RequestOptions requestOptions) {
*
* @param options the optional parameters
* @param requestOptions headers, timeout and retries of this call
- * @return the response body
+ * @return the page: the response body, its items and the way to the next pages
*/
- public BatchJobListResponse list(
+ public BatchJobsListPage list(
final BatchJobsListOptions options, final RequestOptions requestOptions) {
- return exchangeList(options, requestOptions).send();
+ return pageOfList(exchangeList(options, requestOptions).send(), options, requestOptions);
}
MeteroidHttpClient.Exchange exchangeList(
@@ -110,6 +112,41 @@ MeteroidHttpClient.Exchange exchangeList(
.returning(BatchJobListResponse.class);
}
+ private BatchJobsListPage pageOfList(
+ BatchJobListResponse response,
+ final BatchJobsListOptions options,
+ final RequestOptions requestOptions) {
+ List items = itemsOfList(response);
+ Integer next = nextOfList(response, items, options.page().orElse(0));
+ return new BatchJobsListPage(
+ response,
+ items,
+ next == null
+ ? null
+ : () -> list(options.toBuilder().page(next).build(), requestOptions));
+ }
+
+ static List itemsOfList(BatchJobListResponse response) {
+ return Utils.optional(response.data()).orElse(List.of());
+ }
+
+ /** The parameter of the page after {@code response}, null after the last one. */
+ static Integer nextOfList(
+ BatchJobListResponse response, List items, Integer current) {
+ if (items.isEmpty()) {
+ return null;
+ }
+ long pages =
+ Utils.optional(response.paginationMeta())
+ .flatMap(v2 -> Utils.optional(v2.totalPages()))
+ .map(Number::longValue)
+ .orElse(Long.MAX_VALUE);
+ if (current - 0 + 1 >= pages) {
+ return null;
+ }
+ return current + 1;
+ }
+
/**
* Get batch job detail
*
@@ -156,9 +193,9 @@ MeteroidHttpClient.Exchange exchangeRetrieve(
* Retrieve paginated failures for a batch job.
*
* @param batchJobId the {@code batch_job_id} path parameter
- * @return the response body
+ * @return the page: the response body, its items and the way to the next pages
*/
- public BatchJobFailuresResponse listFailures(final String batchJobId) {
+ public BatchJobsListFailuresPage listFailures(final String batchJobId) {
return listFailures(batchJobId, BatchJobsListFailuresOptions.none(), RequestOptions.none());
}
@@ -169,9 +206,9 @@ public BatchJobFailuresResponse listFailures(final String batchJobId) {
*
* @param batchJobId the {@code batch_job_id} path parameter
* @param options the optional parameters
- * @return the response body
+ * @return the page: the response body, its items and the way to the next pages
*/
- public BatchJobFailuresResponse listFailures(
+ public BatchJobsListFailuresPage listFailures(
final String batchJobId, final BatchJobsListFailuresOptions options) {
return listFailures(batchJobId, options, RequestOptions.none());
}
@@ -183,9 +220,9 @@ public BatchJobFailuresResponse listFailures(
*
* @param batchJobId the {@code batch_job_id} path parameter
* @param requestOptions headers, timeout and retries of this call
- * @return the response body
+ * @return the page: the response body, its items and the way to the next pages
*/
- public BatchJobFailuresResponse listFailures(
+ public BatchJobsListFailuresPage listFailures(
final String batchJobId, final RequestOptions requestOptions) {
return listFailures(batchJobId, BatchJobsListFailuresOptions.none(), requestOptions);
}
@@ -198,13 +235,17 @@ public BatchJobFailuresResponse listFailures(
* @param batchJobId the {@code batch_job_id} path parameter
* @param options the optional parameters
* @param requestOptions headers, timeout and retries of this call
- * @return the response body
+ * @return the page: the response body, its items and the way to the next pages
*/
- public BatchJobFailuresResponse listFailures(
+ public BatchJobsListFailuresPage listFailures(
final String batchJobId,
final BatchJobsListFailuresOptions options,
final RequestOptions requestOptions) {
- return exchangeListFailures(batchJobId, options, requestOptions).send();
+ return pageOfListFailures(
+ exchangeListFailures(batchJobId, options, requestOptions).send(),
+ batchJobId,
+ options,
+ requestOptions);
}
MeteroidHttpClient.Exchange exchangeListFailures(
@@ -236,6 +277,47 @@ MeteroidHttpClient.Exchange exchangeListFailures(
.returning(BatchJobFailuresResponse.class);
}
+ private BatchJobsListFailuresPage pageOfListFailures(
+ BatchJobFailuresResponse response,
+ final String batchJobId,
+ final BatchJobsListFailuresOptions options,
+ final RequestOptions requestOptions) {
+ List items = itemsOfListFailures(response);
+ Integer next = nextOfListFailures(response, items, options.offset().orElse(0));
+ return new BatchJobsListFailuresPage(
+ response,
+ items,
+ next == null
+ ? null
+ : () ->
+ listFailures(
+ batchJobId,
+ options.toBuilder().offset(next).build(),
+ requestOptions));
+ }
+
+ static List itemsOfListFailures(
+ BatchJobFailuresResponse response) {
+ return Utils.optional(response.data()).orElse(List.of());
+ }
+
+ /** The parameter of the page after {@code response}, null after the last one. */
+ static Integer nextOfListFailures(
+ BatchJobFailuresResponse response,
+ List items,
+ Integer current) {
+ if (items.isEmpty()) {
+ return null;
+ }
+ Integer next = current + items.size();
+ long total =
+ Utils.optional(response.totalCount()).map(Number::longValue).orElse(Long.MAX_VALUE);
+ if (next >= total) {
+ return null;
+ }
+ return next;
+ }
+
/** The operations, returning the status and headers along with the body. */
public final class WithRawResponse {
private WithRawResponse() {}
@@ -243,9 +325,9 @@ private WithRawResponse() {}
/**
* List batch jobs with optional filtering by type and status.
*
- * @return the status, headers and body
+ * @return the status, headers and page
*/
- public ApiResponse list() {
+ public ApiResponse list() {
return list(BatchJobsListOptions.none(), RequestOptions.none());
}
@@ -253,9 +335,9 @@ public ApiResponse list() {
* List batch jobs with optional filtering by type and status.
*
* @param options the optional parameters
- * @return the status, headers and body
+ * @return the status, headers and page
*/
- public ApiResponse list(final BatchJobsListOptions options) {
+ public ApiResponse list(final BatchJobsListOptions options) {
return list(options, RequestOptions.none());
}
@@ -263,9 +345,9 @@ public ApiResponse list(final BatchJobsListOptions options
* List batch jobs with optional filtering by type and status.
*
* @param requestOptions headers, timeout and retries of this call
- * @return the status, headers and body
+ * @return the status, headers and page
*/
- public ApiResponse list(final RequestOptions requestOptions) {
+ public ApiResponse list(final RequestOptions requestOptions) {
return list(BatchJobsListOptions.none(), requestOptions);
}
@@ -274,11 +356,16 @@ public ApiResponse list(final RequestOptions requestOption
*
* @param options the optional parameters
* @param requestOptions headers, timeout and retries of this call
- * @return the status, headers and body
+ * @return the status, headers and page
*/
- public ApiResponse list(
+ public ApiResponse list(
final BatchJobsListOptions options, final RequestOptions requestOptions) {
- return BatchJobs.this.exchangeList(options, requestOptions).sendRaw();
+ ApiResponse response =
+ exchangeList(options, requestOptions).sendRaw();
+ return new ApiResponse<>(
+ response.statusCode(),
+ response.headers(),
+ pageOfList(response.body(), options, requestOptions));
}
/**
@@ -313,9 +400,9 @@ public ApiResponse retrieve(
* Retrieve paginated failures for a batch job.
*
* @param batchJobId the {@code batch_job_id} path parameter
- * @return the status, headers and body
+ * @return the status, headers and page
*/
- public ApiResponse listFailures(final String batchJobId) {
+ public ApiResponse listFailures(final String batchJobId) {
return listFailures(
batchJobId, BatchJobsListFailuresOptions.none(), RequestOptions.none());
}
@@ -327,9 +414,9 @@ public ApiResponse listFailures(final String batchJobI
*
* @param batchJobId the {@code batch_job_id} path parameter
* @param options the optional parameters
- * @return the status, headers and body
+ * @return the status, headers and page
*/
- public ApiResponse listFailures(
+ public ApiResponse listFailures(
final String batchJobId, final BatchJobsListFailuresOptions options) {
return listFailures(batchJobId, options, RequestOptions.none());
}
@@ -341,9 +428,9 @@ public ApiResponse listFailures(
*
* @param batchJobId the {@code batch_job_id} path parameter
* @param requestOptions headers, timeout and retries of this call
- * @return the status, headers and body
+ * @return the status, headers and page
*/
- public ApiResponse listFailures(
+ public ApiResponse listFailures(
final String batchJobId, final RequestOptions requestOptions) {
return listFailures(batchJobId, BatchJobsListFailuresOptions.none(), requestOptions);
}
@@ -356,15 +443,18 @@ public ApiResponse listFailures(
* @param batchJobId the {@code batch_job_id} path parameter
* @param options the optional parameters
* @param requestOptions headers, timeout and retries of this call
- * @return the status, headers and body
+ * @return the status, headers and page
*/
- public ApiResponse listFailures(
+ public ApiResponse listFailures(
final String batchJobId,
final BatchJobsListFailuresOptions options,
final RequestOptions requestOptions) {
- return BatchJobs.this
- .exchangeListFailures(batchJobId, options, requestOptions)
- .sendRaw();
+ ApiResponse response =
+ exchangeListFailures(batchJobId, options, requestOptions).sendRaw();
+ return new ApiResponse<>(
+ response.statusCode(),
+ response.headers(),
+ pageOfListFailures(response.body(), batchJobId, options, requestOptions));
}
}
}
diff --git a/src/main/java/com/meteroid/api/BatchJobsAsync.java b/src/main/java/com/meteroid/api/BatchJobsAsync.java
index 831708b..bdda26b 100644
--- a/src/main/java/com/meteroid/api/BatchJobsAsync.java
+++ b/src/main/java/com/meteroid/api/BatchJobsAsync.java
@@ -5,8 +5,11 @@
import com.meteroid.RequestOptions;
import com.meteroid.models.BatchJobDetailResponse;
import com.meteroid.models.BatchJobFailuresResponse;
+import com.meteroid.models.BatchJobItemFailureResponse;
import com.meteroid.models.BatchJobListResponse;
+import com.meteroid.models.BatchJobResponse;
+import java.util.List;
import java.util.concurrent.CompletableFuture;
/**
@@ -39,9 +42,9 @@ public WithRawResponse withRawResponse() {
/**
* List batch jobs with optional filtering by type and status.
*
- * @return the response body, once received
+ * @return the page, once received
*/
- public CompletableFuture list() {
+ public CompletableFuture list() {
return list(BatchJobsListOptions.none(), RequestOptions.none());
}
@@ -49,9 +52,9 @@ public CompletableFuture list() {
* List batch jobs with optional filtering by type and status.
*
* @param options the optional parameters
- * @return the response body, once received
+ * @return the page, once received
*/
- public CompletableFuture list(final BatchJobsListOptions options) {
+ public CompletableFuture list(final BatchJobsListOptions options) {
return list(options, RequestOptions.none());
}
@@ -59,9 +62,9 @@ public CompletableFuture list(final BatchJobsListOptions o
* List batch jobs with optional filtering by type and status.
*
* @param requestOptions headers, timeout and retries of this call
- * @return the response body, once received
+ * @return the page, once received
*/
- public CompletableFuture list(final RequestOptions requestOptions) {
+ public CompletableFuture list(final RequestOptions requestOptions) {
return list(BatchJobsListOptions.none(), requestOptions);
}
@@ -70,11 +73,27 @@ public CompletableFuture list(final RequestOptions request
*
* @param options the optional parameters
* @param requestOptions headers, timeout and retries of this call
- * @return the response body, once received
+ * @return the page, once received
*/
- public CompletableFuture list(
+ public CompletableFuture list(
final BatchJobsListOptions options, final RequestOptions requestOptions) {
- return sync.exchangeList(options, requestOptions).sendAsync();
+ return sync.exchangeList(options, requestOptions)
+ .sendAsync()
+ .thenApply(response -> pageOfList(response, options, requestOptions));
+ }
+
+ private BatchJobsListAsyncPage pageOfList(
+ BatchJobListResponse response,
+ final BatchJobsListOptions options,
+ final RequestOptions requestOptions) {
+ List items = BatchJobs.itemsOfList(response);
+ Integer next = BatchJobs.nextOfList(response, items, options.page().orElse(0));
+ return new BatchJobsListAsyncPage(
+ response,
+ items,
+ next == null
+ ? null
+ : () -> list(options.toBuilder().page(next).build(), requestOptions));
}
/**
@@ -109,9 +128,9 @@ public CompletableFuture retrieve(
* Retrieve paginated failures for a batch job.
*
* @param batchJobId the {@code batch_job_id} path parameter
- * @return the response body, once received
+ * @return the page, once received
*/
- public CompletableFuture listFailures(final String batchJobId) {
+ public CompletableFuture listFailures(final String batchJobId) {
return listFailures(batchJobId, BatchJobsListFailuresOptions.none(), RequestOptions.none());
}
@@ -122,9 +141,9 @@ public CompletableFuture listFailures(final String bat
*
* @param batchJobId the {@code batch_job_id} path parameter
* @param options the optional parameters
- * @return the response body, once received
+ * @return the page, once received
*/
- public CompletableFuture listFailures(
+ public CompletableFuture listFailures(
final String batchJobId, final BatchJobsListFailuresOptions options) {
return listFailures(batchJobId, options, RequestOptions.none());
}
@@ -136,9 +155,9 @@ public CompletableFuture listFailures(
*
* @param batchJobId the {@code batch_job_id} path parameter
* @param requestOptions headers, timeout and retries of this call
- * @return the response body, once received
+ * @return the page, once received
*/
- public CompletableFuture listFailures(
+ public CompletableFuture listFailures(
final String batchJobId, final RequestOptions requestOptions) {
return listFailures(batchJobId, BatchJobsListFailuresOptions.none(), requestOptions);
}
@@ -151,13 +170,36 @@ public CompletableFuture listFailures(
* @param batchJobId the {@code batch_job_id} path parameter
* @param options the optional parameters
* @param requestOptions headers, timeout and retries of this call
- * @return the response body, once received
+ * @return the page, once received
*/
- public CompletableFuture listFailures(
+ public CompletableFuture listFailures(
+ final String batchJobId,
+ final BatchJobsListFailuresOptions options,
+ final RequestOptions requestOptions) {
+ return sync.exchangeListFailures(batchJobId, options, requestOptions)
+ .sendAsync()
+ .thenApply(
+ response ->
+ pageOfListFailures(response, batchJobId, options, requestOptions));
+ }
+
+ private BatchJobsListFailuresAsyncPage pageOfListFailures(
+ BatchJobFailuresResponse response,
final String batchJobId,
final BatchJobsListFailuresOptions options,
final RequestOptions requestOptions) {
- return sync.exchangeListFailures(batchJobId, options, requestOptions).sendAsync();
+ List items = BatchJobs.itemsOfListFailures(response);
+ Integer next = BatchJobs.nextOfListFailures(response, items, options.offset().orElse(0));
+ return new BatchJobsListFailuresAsyncPage(
+ response,
+ items,
+ next == null
+ ? null
+ : () ->
+ listFailures(
+ batchJobId,
+ options.toBuilder().offset(next).build(),
+ requestOptions));
}
/** The operations, returning the status and headers along with the body. */
@@ -167,9 +209,9 @@ private WithRawResponse() {}
/**
* List batch jobs with optional filtering by type and status.
*
- * @return the status, headers and body, once received
+ * @return the status, headers and page, once received
*/
- public CompletableFuture> list() {
+ public CompletableFuture> list() {
return list(BatchJobsListOptions.none(), RequestOptions.none());
}
@@ -177,9 +219,9 @@ public CompletableFuture> list() {
* List batch jobs with optional filtering by type and status.
*
* @param options the optional parameters
- * @return the status, headers and body, once received
+ * @return the status, headers and page, once received
*/
- public CompletableFuture> list(
+ public CompletableFuture> list(
final BatchJobsListOptions options) {
return list(options, RequestOptions.none());
}
@@ -188,9 +230,9 @@ public CompletableFuture> list(
* List batch jobs with optional filtering by type and status.
*
* @param requestOptions headers, timeout and retries of this call
- * @return the status, headers and body, once received
+ * @return the status, headers and page, once received
*/
- public CompletableFuture> list(
+ public CompletableFuture> list(
final RequestOptions requestOptions) {
return list(BatchJobsListOptions.none(), requestOptions);
}
@@ -200,11 +242,18 @@ public CompletableFuture> list(
*
* @param options the optional parameters
* @param requestOptions headers, timeout and retries of this call
- * @return the status, headers and body, once received
+ * @return the status, headers and page, once received
*/
- public CompletableFuture> list(
+ public CompletableFuture> list(
final BatchJobsListOptions options, final RequestOptions requestOptions) {
- return sync.exchangeList(options, requestOptions).sendRawAsync();
+ return sync.exchangeList(options, requestOptions)
+ .sendRawAsync()
+ .thenApply(
+ response ->
+ new ApiResponse<>(
+ response.statusCode(),
+ response.headers(),
+ pageOfList(response.body(), options, requestOptions)));
}
/**
@@ -240,9 +289,9 @@ public CompletableFuture> retrieve(
* Retrieve paginated failures for a batch job.
*
* @param batchJobId the {@code batch_job_id} path parameter
- * @return the status, headers and body, once received
+ * @return the status, headers and page, once received
*/
- public CompletableFuture> listFailures(
+ public CompletableFuture> listFailures(
final String batchJobId) {
return listFailures(
batchJobId, BatchJobsListFailuresOptions.none(), RequestOptions.none());
@@ -255,9 +304,9 @@ public CompletableFuture> listFailures(
*
* @param batchJobId the {@code batch_job_id} path parameter
* @param options the optional parameters
- * @return the status, headers and body, once received
+ * @return the status, headers and page, once received
*/
- public CompletableFuture> listFailures(
+ public CompletableFuture> listFailures(
final String batchJobId, final BatchJobsListFailuresOptions options) {
return listFailures(batchJobId, options, RequestOptions.none());
}
@@ -269,9 +318,9 @@ public CompletableFuture> listFailures(
*
* @param batchJobId the {@code batch_job_id} path parameter
* @param requestOptions headers, timeout and retries of this call
- * @return the status, headers and body, once received
+ * @return the status, headers and page, once received
*/
- public CompletableFuture> listFailures(
+ public CompletableFuture> listFailures(
final String batchJobId, final RequestOptions requestOptions) {
return listFailures(batchJobId, BatchJobsListFailuresOptions.none(), requestOptions);
}
@@ -284,13 +333,24 @@ public CompletableFuture> listFailures(
* @param batchJobId the {@code batch_job_id} path parameter
* @param options the optional parameters
* @param requestOptions headers, timeout and retries of this call
- * @return the status, headers and body, once received
+ * @return the status, headers and page, once received
*/
- public CompletableFuture> listFailures(
+ public CompletableFuture> listFailures(
final String batchJobId,
final BatchJobsListFailuresOptions options,
final RequestOptions requestOptions) {
- return sync.exchangeListFailures(batchJobId, options, requestOptions).sendRawAsync();
+ return sync.exchangeListFailures(batchJobId, options, requestOptions)
+ .sendRawAsync()
+ .thenApply(
+ response ->
+ new ApiResponse<>(
+ response.statusCode(),
+ response.headers(),
+ pageOfListFailures(
+ response.body(),
+ batchJobId,
+ options,
+ requestOptions)));
}
}
}
diff --git a/src/main/java/com/meteroid/api/BatchJobsListAsyncPage.java b/src/main/java/com/meteroid/api/BatchJobsListAsyncPage.java
new file mode 100644
index 0000000..0f6cab9
--- /dev/null
+++ b/src/main/java/com/meteroid/api/BatchJobsListAsyncPage.java
@@ -0,0 +1,67 @@
+// this file is @generated
+package com.meteroid.api;
+
+import com.meteroid.AsyncPage;
+import com.meteroid.models.BatchJobListResponse;
+import com.meteroid.models.BatchJobResponse;
+import com.meteroid.models.PaginationResponse;
+
+import java.util.List;
+import java.util.concurrent.CompletableFuture;
+import java.util.function.Supplier;
+
+/**
+ * A page of {@link BatchJobsAsync#list}: the {@link BatchJobResponse} items of one response, and
+ * the properties of its body, {@link BatchJobListResponse}.
+ */
+public final class BatchJobsListAsyncPage
+ extends AsyncPage {
+ private final BatchJobListResponse body;
+
+ /**
+ * A page, built by the SDK.
+ *
+ * @param body the response body
+ * @param items the items of the page
+ * @param next fetches the next page, or null on the last page
+ */
+ public BatchJobsListAsyncPage(
+ BatchJobListResponse body,
+ List items,
+ Supplier> next) {
+ super(items, next);
+ this.body = body;
+ }
+
+ /**
+ * The response body, as received.
+ *
+ * @return the body
+ */
+ public BatchJobListResponse body() {
+ return body;
+ }
+
+ /**
+ * The {@code data} property.
+ *
+ * @return the value, never null
+ */
+ public List data() {
+ return body.data();
+ }
+
+ /**
+ * The {@code pagination_meta} property.
+ *
+ * @return the value, never null
+ */
+ public PaginationResponse paginationMeta() {
+ return body.paginationMeta();
+ }
+
+ @Override
+ public String toString() {
+ return "BatchJobsListAsyncPage{body=" + body + ", hasNextPage=" + hasNextPage() + "}";
+ }
+}
diff --git a/src/main/java/com/meteroid/api/BatchJobsListFailuresAsyncPage.java b/src/main/java/com/meteroid/api/BatchJobsListFailuresAsyncPage.java
new file mode 100644
index 0000000..35d5fae
--- /dev/null
+++ b/src/main/java/com/meteroid/api/BatchJobsListFailuresAsyncPage.java
@@ -0,0 +1,70 @@
+// this file is @generated
+package com.meteroid.api;
+
+import com.meteroid.AsyncPage;
+import com.meteroid.models.BatchJobFailuresResponse;
+import com.meteroid.models.BatchJobItemFailureResponse;
+
+import java.util.List;
+import java.util.concurrent.CompletableFuture;
+import java.util.function.Supplier;
+
+/**
+ * A page of {@link BatchJobsAsync#listFailures}: the {@link BatchJobItemFailureResponse} items of
+ * one response, and the properties of its body, {@link BatchJobFailuresResponse}.
+ */
+public final class BatchJobsListFailuresAsyncPage
+ extends AsyncPage {
+ private final BatchJobFailuresResponse body;
+
+ /**
+ * A page, built by the SDK.
+ *
+ * @param body the response body
+ * @param items the items of the page
+ * @param next fetches the next page, or null on the last page
+ */
+ public BatchJobsListFailuresAsyncPage(
+ BatchJobFailuresResponse body,
+ List items,
+ Supplier> next) {
+ super(items, next);
+ this.body = body;
+ }
+
+ /**
+ * The response body, as received.
+ *
+ * @return the body
+ */
+ public BatchJobFailuresResponse body() {
+ return body;
+ }
+
+ /**
+ * The {@code data} property.
+ *
+ * @return the value, never null
+ */
+ public List data() {
+ return body.data();
+ }
+
+ /**
+ * The {@code total_count} property.
+ *
+ * @return the value, never null
+ */
+ public Long totalCount() {
+ return body.totalCount();
+ }
+
+ @Override
+ public String toString() {
+ return "BatchJobsListFailuresAsyncPage{body="
+ + body
+ + ", hasNextPage="
+ + hasNextPage()
+ + "}";
+ }
+}
diff --git a/src/main/java/com/meteroid/api/BatchJobsListFailuresPage.java b/src/main/java/com/meteroid/api/BatchJobsListFailuresPage.java
new file mode 100644
index 0000000..d553d84
--- /dev/null
+++ b/src/main/java/com/meteroid/api/BatchJobsListFailuresPage.java
@@ -0,0 +1,68 @@
+// this file is @generated
+package com.meteroid.api;
+
+import com.meteroid.Page;
+import com.meteroid.models.BatchJobFailuresResponse;
+import com.meteroid.models.BatchJobItemFailureResponse;
+
+import java.util.List;
+import java.util.function.Supplier;
+
+/**
+ * A page of {@link BatchJobs#listFailures}: the {@link BatchJobItemFailureResponse} items of one
+ * response, and the properties of its body, {@link BatchJobFailuresResponse}.
+ *
+ * Iterating it yields every item from this page on, fetching the next pages as the iteration
+ * goes.
+ */
+public final class BatchJobsListFailuresPage
+ extends Page {
+ private final BatchJobFailuresResponse body;
+
+ /**
+ * A page, built by the SDK.
+ *
+ * @param body the response body
+ * @param items the items of the page
+ * @param next fetches the next page, or null on the last page
+ */
+ public BatchJobsListFailuresPage(
+ BatchJobFailuresResponse body,
+ List items,
+ Supplier next) {
+ super(items, next);
+ this.body = body;
+ }
+
+ /**
+ * The response body, as received.
+ *
+ * @return the body
+ */
+ public BatchJobFailuresResponse body() {
+ return body;
+ }
+
+ /**
+ * The {@code data} property.
+ *
+ * @return the value, never null
+ */
+ public List data() {
+ return body.data();
+ }
+
+ /**
+ * The {@code total_count} property.
+ *
+ * @return the value, never null
+ */
+ public Long totalCount() {
+ return body.totalCount();
+ }
+
+ @Override
+ public String toString() {
+ return "BatchJobsListFailuresPage{body=" + body + ", hasNextPage=" + hasNextPage() + "}";
+ }
+}
diff --git a/src/main/java/com/meteroid/api/BatchJobsListPage.java b/src/main/java/com/meteroid/api/BatchJobsListPage.java
new file mode 100644
index 0000000..edad055
--- /dev/null
+++ b/src/main/java/com/meteroid/api/BatchJobsListPage.java
@@ -0,0 +1,68 @@
+// this file is @generated
+package com.meteroid.api;
+
+import com.meteroid.Page;
+import com.meteroid.models.BatchJobListResponse;
+import com.meteroid.models.BatchJobResponse;
+import com.meteroid.models.PaginationResponse;
+
+import java.util.List;
+import java.util.function.Supplier;
+
+/**
+ * A page of {@link BatchJobs#list}: the {@link BatchJobResponse} items of one response, and the
+ * properties of its body, {@link BatchJobListResponse}.
+ *
+ * Iterating it yields every item from this page on, fetching the next pages as the iteration
+ * goes.
+ */
+public final class BatchJobsListPage extends Page {
+ private final BatchJobListResponse body;
+
+ /**
+ * A page, built by the SDK.
+ *
+ * @param body the response body
+ * @param items the items of the page
+ * @param next fetches the next page, or null on the last page
+ */
+ public BatchJobsListPage(
+ BatchJobListResponse body,
+ List items,
+ Supplier next) {
+ super(items, next);
+ this.body = body;
+ }
+
+ /**
+ * The response body, as received.
+ *
+ * @return the body
+ */
+ public BatchJobListResponse body() {
+ return body;
+ }
+
+ /**
+ * The {@code data} property.
+ *
+ * @return the value, never null
+ */
+ public List data() {
+ return body.data();
+ }
+
+ /**
+ * The {@code pagination_meta} property.
+ *
+ * @return the value, never null
+ */
+ public PaginationResponse paginationMeta() {
+ return body.paginationMeta();
+ }
+
+ @Override
+ public String toString() {
+ return "BatchJobsListPage{body=" + body + ", hasNextPage=" + hasNextPage() + "}";
+ }
+}
diff --git a/src/main/java/com/meteroid/api/Coupons.java b/src/main/java/com/meteroid/api/Coupons.java
index 23e9741..73440ec 100644
--- a/src/main/java/com/meteroid/api/Coupons.java
+++ b/src/main/java/com/meteroid/api/Coupons.java
@@ -13,6 +13,7 @@
import okhttp3.HttpUrl;
+import java.util.List;
import java.util.Objects;
/**
@@ -45,9 +46,9 @@ public WithRawResponse withRawResponse() {
/**
* List coupons
*
- * @return the response body
+ * @return the page: the response body, its items and the way to the next pages
*/
- public CouponListResponse list() {
+ public CouponsListPage list() {
return list(CouponsListOptions.none(), RequestOptions.none());
}
@@ -55,9 +56,9 @@ public CouponListResponse list() {
* List coupons
*
* @param options the optional parameters
- * @return the response body
+ * @return the page: the response body, its items and the way to the next pages
*/
- public CouponListResponse list(final CouponsListOptions options) {
+ public CouponsListPage list(final CouponsListOptions options) {
return list(options, RequestOptions.none());
}
@@ -65,9 +66,9 @@ public CouponListResponse list(final CouponsListOptions options) {
* List coupons
*
* @param requestOptions headers, timeout and retries of this call
- * @return the response body
+ * @return the page: the response body, its items and the way to the next pages
*/
- public CouponListResponse list(final RequestOptions requestOptions) {
+ public CouponsListPage list(final RequestOptions requestOptions) {
return list(CouponsListOptions.none(), requestOptions);
}
@@ -76,11 +77,11 @@ public CouponListResponse list(final RequestOptions requestOptions) {
*
* @param options the optional parameters
* @param requestOptions headers, timeout and retries of this call
- * @return the response body
+ * @return the page: the response body, its items and the way to the next pages
*/
- public CouponListResponse list(
+ public CouponsListPage list(
final CouponsListOptions options, final RequestOptions requestOptions) {
- return exchangeList(options, requestOptions).send();
+ return pageOfList(exchangeList(options, requestOptions).send(), options, requestOptions);
}
MeteroidHttpClient.Exchange exchangeList(
@@ -113,6 +114,40 @@ MeteroidHttpClient.Exchange exchangeList(
.returning(CouponListResponse.class);
}
+ private CouponsListPage pageOfList(
+ CouponListResponse response,
+ final CouponsListOptions options,
+ final RequestOptions requestOptions) {
+ List items = itemsOfList(response);
+ Integer next = nextOfList(response, items, options.page().orElse(0));
+ return new CouponsListPage(
+ response,
+ items,
+ next == null
+ ? null
+ : () -> list(options.toBuilder().page(next).build(), requestOptions));
+ }
+
+ static List itemsOfList(CouponListResponse response) {
+ return Utils.optional(response.data()).orElse(List.of());
+ }
+
+ /** The parameter of the page after {@code response}, null after the last one. */
+ static Integer nextOfList(CouponListResponse response, List items, Integer current) {
+ if (items.isEmpty()) {
+ return null;
+ }
+ long pages =
+ Utils.optional(response.paginationMeta())
+ .flatMap(v2 -> Utils.optional(v2.totalPages()))
+ .map(Number::longValue)
+ .orElse(Long.MAX_VALUE);
+ if (current - 0 + 1 >= pages) {
+ return null;
+ }
+ return current + 1;
+ }
+
/**
* Create a coupon
*
@@ -368,9 +403,9 @@ private WithRawResponse() {}
/**
* List coupons
*
- * @return the status, headers and body
+ * @return the status, headers and page
*/
- public ApiResponse list() {
+ public ApiResponse list() {
return list(CouponsListOptions.none(), RequestOptions.none());
}
@@ -378,9 +413,9 @@ public ApiResponse list() {
* List coupons
*
* @param options the optional parameters
- * @return the status, headers and body
+ * @return the status, headers and page
*/
- public ApiResponse list(final CouponsListOptions options) {
+ public ApiResponse list(final CouponsListOptions options) {
return list(options, RequestOptions.none());
}
@@ -388,9 +423,9 @@ public ApiResponse list(final CouponsListOptions options) {
* List coupons
*
* @param requestOptions headers, timeout and retries of this call
- * @return the status, headers and body
+ * @return the status, headers and page
*/
- public ApiResponse list(final RequestOptions requestOptions) {
+ public ApiResponse list(final RequestOptions requestOptions) {
return list(CouponsListOptions.none(), requestOptions);
}
@@ -399,11 +434,16 @@ public ApiResponse list(final RequestOptions requestOptions)
*
* @param options the optional parameters
* @param requestOptions headers, timeout and retries of this call
- * @return the status, headers and body
+ * @return the status, headers and page
*/
- public ApiResponse list(
+ public ApiResponse