From bd2c783a81d53eaf40ec553f90c7925e0290688f Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 8 Oct 2026 15:53:22 +0000 Subject: [PATCH] feat(api)!: update SDKs to meteroid 0.1.0 --- api.md | 37 +- src/main/java/com/meteroid/api/AddOns.java | 167 ++------- .../java/com/meteroid/api/AddOnsAsync.java | 136 ++----- .../com/meteroid/api/AddOnsEntitlements.java | 189 ++++++++++ .../meteroid/api/AddOnsEntitlementsAsync.java | 151 ++++++++ src/main/java/com/meteroid/api/Plans.java | 330 ++-------------- .../java/com/meteroid/api/PlansAsync.java | 259 ++----------- .../java/com/meteroid/api/PlansVersions.java | 351 ++++++++++++++++++ .../com/meteroid/api/PlansVersionsAsync.java | 275 ++++++++++++++ ...e.java => PlansVersionsListAsyncPage.java} | 12 +- ...ons.java => PlansVersionsListOptions.java} | 18 +- ...nsPage.java => PlansVersionsListPage.java} | 10 +- src/main/java/com/meteroid/api/Products.java | 193 ++-------- .../java/com/meteroid/api/ProductsAsync.java | 160 ++------ .../meteroid/api/ProductsEntitlements.java | 213 +++++++++++ .../api/ProductsEntitlementsAsync.java | 176 +++++++++ .../meteroid/api/AddOnsEntitlementsTest.java | 40 ++ .../java/com/meteroid/api/AddOnsTest.java | 28 -- src/test/java/com/meteroid/api/PlansTest.java | 36 -- .../com/meteroid/api/PlansVersionsTest.java | 48 +++ .../api/ProductsEntitlementsTest.java | 40 ++ .../java/com/meteroid/api/ProductsTest.java | 28 -- 22 files changed, 1664 insertions(+), 1233 deletions(-) create mode 100644 src/main/java/com/meteroid/api/AddOnsEntitlements.java create mode 100644 src/main/java/com/meteroid/api/AddOnsEntitlementsAsync.java create mode 100644 src/main/java/com/meteroid/api/PlansVersions.java create mode 100644 src/main/java/com/meteroid/api/PlansVersionsAsync.java rename src/main/java/com/meteroid/api/{PlansListVersionsAsyncPage.java => PlansVersionsListAsyncPage.java} (81%) rename src/main/java/com/meteroid/api/{PlansListVersionsOptions.java => PlansVersionsListOptions.java} (82%) rename src/main/java/com/meteroid/api/{PlansListVersionsPage.java => PlansVersionsListPage.java} (82%) create mode 100644 src/main/java/com/meteroid/api/ProductsEntitlements.java create mode 100644 src/main/java/com/meteroid/api/ProductsEntitlementsAsync.java create mode 100644 src/test/java/com/meteroid/api/AddOnsEntitlementsTest.java create mode 100644 src/test/java/com/meteroid/api/PlansVersionsTest.java create mode 100644 src/test/java/com/meteroid/api/ProductsEntitlementsTest.java diff --git a/api.md b/api.md index b25af4a..c7649db 100644 --- a/api.md +++ b/api.md @@ -14,7 +14,7 @@ item from that page on, and `pages()` every page, fetching the next ones on dema the response body as received. The async client's pages have `nextPage()`, `forEach(...)`, `forEachPage(...)` and `toList()`, returning `CompletableFuture`s. -[Add ons](#add-ons) · [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](#add-ons) · [Add ons entitlements](#add-ons-entitlements) · [Batch jobs](#batch-jobs) · [Checkout sessions](#checkout-sessions) · [Connect](#connect) · [Coupons](#coupons) · [Credit notes](#credit-notes) · [Custom properties](#custom-properties) · [Customers](#customers) · [Entitlements](#entitlements) · [Events](#events) · [Features](#features) · [Invoices](#invoices) · [Metrics](#metrics) · [Oauth](#oauth) · [Oauth apps](#oauth-apps) · [Plans](#plans) · [Plans versions](#plans-versions) · [Product families](#product-families) · [Products](#products) · [Products entitlements](#products-entitlements) · [Subscriptions](#subscriptions) · [Usage](#usage) ## Add ons @@ -27,10 +27,17 @@ the response body as received. The async client's pages have `nextPage()`, `forE | `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) | | `void client.addOns().archive(String addonId)` | `POST /api/v1/addons/{addon_id}/archive` | nothing | -| `ResolvedEntitlementListResponse client.addOns().listEntitlements(String addonId)` | `GET /api/v1/addons/{addon_id}/entitlements` | [`ResolvedEntitlementListResponse`](src/main/java/com/meteroid/models/ResolvedEntitlementListResponse.java) | -| `EntitlementListResponse client.addOns().createEntitlement(String addonId, CreateEntitlementsRequest createEntitlementsRequest)` | `POST /api/v1/addons/{addon_id}/entitlements` | [`EntitlementListResponse`](src/main/java/com/meteroid/models/EntitlementListResponse.java) | | `void client.addOns().unarchive(String addonId)` | `POST /api/v1/addons/{addon_id}/unarchive` | nothing | +### Add ons entitlements + +[`client.addOns().entitlements()`](src/main/java/com/meteroid/api/AddOnsEntitlements.java) + +| Method | Request | Returns | +| --- | --- | --- | +| `ResolvedEntitlementListResponse client.addOns().entitlements().list(String addonId)` | `GET /api/v1/addons/{addon_id}/entitlements` | [`ResolvedEntitlementListResponse`](src/main/java/com/meteroid/models/ResolvedEntitlementListResponse.java) | +| `EntitlementListResponse client.addOns().entitlements().create(String addonId, CreateEntitlementsRequest createEntitlementsRequest)` | `POST /api/v1/addons/{addon_id}/entitlements` | [`EntitlementListResponse`](src/main/java/com/meteroid/models/EntitlementListResponse.java) | + ## Batch jobs [`client.batchJobs()`](src/main/java/com/meteroid/api/BatchJobs.java) @@ -208,15 +215,22 @@ the response body as received. The async client's pages have `nextPage()`, `forE | `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) | | `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 | | `Plan client.plans().retrieve(String planId, [PlansRetrieveOptions options])` | `GET /api/v1/plans/{plan_id}` | [`Plan`](src/main/java/com/meteroid/models/Plan.java) | | `Plan client.plans().replace(String planId, ReplacePlanRequest replacePlanRequest)` | `PUT /api/v1/plans/{plan_id}` | [`Plan`](src/main/java/com/meteroid/models/Plan.java) | | `Plan client.plans().update(String planId, PatchPlanRequest patchPlanRequest)` | `PATCH /api/v1/plans/{plan_id}` | [`Plan`](src/main/java/com/meteroid/models/Plan.java) | | `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 | -| `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) | + +### Plans versions + +[`client.plans().versions()`](src/main/java/com/meteroid/api/PlansVersions.java) + +| Method | Request | Returns | +| --- | --- | --- | +| `MinimumCommitment client.plans().versions().updateMinimum(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().versions().deleteMinimum(String planVersionId)` | `DELETE /api/v1/plans/versions/{plan_version_id}/minimum` | nothing | +| `PlansVersionsListPage client.plans().versions().list(String planId, [PlansVersionsListOptions options])` | `GET /api/v1/plans/{plan_id}/versions` | [page](src/main/java/com/meteroid/api/PlansVersionsListPage.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 @@ -239,10 +253,17 @@ the response body as received. The async client's pages have `nextPage()`, `forE | `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) | | `void client.products().archive(String productId)` | `POST /api/v1/products/{product_id}/archive` | nothing | -| `ResolvedEntitlementListResponse client.products().listEntitlements(String productId)` | `GET /api/v1/products/{product_id}/entitlements` | [`ResolvedEntitlementListResponse`](src/main/java/com/meteroid/models/ResolvedEntitlementListResponse.java) | -| `EntitlementListResponse client.products().createEntitlement(String productId, CreateEntitlementsRequest createEntitlementsRequest)` | `POST /api/v1/products/{product_id}/entitlements` | [`EntitlementListResponse`](src/main/java/com/meteroid/models/EntitlementListResponse.java) | | `void client.products().unarchive(String productId)` | `POST /api/v1/products/{product_id}/unarchive` | nothing | +### Products entitlements + +[`client.products().entitlements()`](src/main/java/com/meteroid/api/ProductsEntitlements.java) + +| Method | Request | Returns | +| --- | --- | --- | +| `ResolvedEntitlementListResponse client.products().entitlements().list(String productId)` | `GET /api/v1/products/{product_id}/entitlements` | [`ResolvedEntitlementListResponse`](src/main/java/com/meteroid/models/ResolvedEntitlementListResponse.java) | +| `EntitlementListResponse client.products().entitlements().create(String productId, CreateEntitlementsRequest createEntitlementsRequest)` | `POST /api/v1/products/{product_id}/entitlements` | [`EntitlementListResponse`](src/main/java/com/meteroid/models/EntitlementListResponse.java) | + ## Subscriptions [`client.subscriptions()`](src/main/java/com/meteroid/api/Subscriptions.java) diff --git a/src/main/java/com/meteroid/api/AddOns.java b/src/main/java/com/meteroid/api/AddOns.java index b2712e1..a015b6f 100644 --- a/src/main/java/com/meteroid/api/AddOns.java +++ b/src/main/java/com/meteroid/api/AddOns.java @@ -8,9 +8,6 @@ import com.meteroid.models.AddOn; import com.meteroid.models.AddOnListResponse; import com.meteroid.models.CreateAddOnRequest; -import com.meteroid.models.CreateEntitlementsRequest; -import com.meteroid.models.EntitlementListResponse; -import com.meteroid.models.ResolvedEntitlementListResponse; import com.meteroid.models.UpdateAddOnRequest; import okhttp3.HttpUrl; @@ -26,6 +23,8 @@ public final class AddOns { private final MeteroidHttpClient client; private final WithRawResponse withRawResponse; + private final AddOnsEntitlements entitlements; + /** * The operations, sending through {@code client}. * @@ -34,6 +33,8 @@ public final class AddOns { public AddOns(MeteroidHttpClient client) { this.client = client; this.withRawResponse = new WithRawResponse(); + + this.entitlements = new AddOnsEntitlements(client); } /** @@ -45,6 +46,15 @@ public WithRawResponse withRawResponse() { return withRawResponse; } + /** + * The {@code entitlements} operations. + * + * @return the operations + */ + public AddOnsEntitlements entitlements() { + return entitlements; + } + /** * List add-ons * @@ -300,93 +310,6 @@ MeteroidHttpClient.Exchange exchangeArchive( .returningNothing(); } - /** - * List add-on entitlements - * - * @param addonId the {@code addon_id} path parameter - * @return the response body - */ - public ResolvedEntitlementListResponse listEntitlements(final String addonId) { - return listEntitlements(addonId, RequestOptions.none()); - } - - /** - * List add-on entitlements - * - * @param addonId the {@code addon_id} path parameter - * @param requestOptions headers, timeout and retries of this call - * @return the response body - */ - public ResolvedEntitlementListResponse listEntitlements( - final String addonId, final RequestOptions requestOptions) { - return exchangeListEntitlements(addonId, requestOptions).send(); - } - - MeteroidHttpClient.Exchange exchangeListEntitlements( - final String addonId, final RequestOptions requestOptions) { - Objects.requireNonNull(addonId, "addon_id"); - HttpUrl url = - client.newUrlBuilder() - .addPathSegments("api/v1/addons") - .addPathSegment(Utils.pathSegment("addon_id", addonId)) - .addPathSegments("entitlements") - .build(); - return client.call("GET", url) - .errors(com.meteroid.models.RestErrorResponse.class, "401", "404", "429") - .options(requestOptions) - .returning(ResolvedEntitlementListResponse.class); - } - - /** - * Create add-on entitlements - * - *

Entitlements already present on this add-on are skipped. - * - * @param addonId the {@code addon_id} path parameter - * @param createEntitlementsRequest the request body - * @return the response body - */ - public EntitlementListResponse createEntitlement( - final String addonId, final CreateEntitlementsRequest createEntitlementsRequest) { - return createEntitlement(addonId, createEntitlementsRequest, RequestOptions.none()); - } - - /** - * Create add-on entitlements - * - *

Entitlements already present on this add-on are skipped. - * - * @param addonId the {@code addon_id} path parameter - * @param createEntitlementsRequest the request body - * @param requestOptions headers, timeout and retries of this call - * @return the response body - */ - public EntitlementListResponse createEntitlement( - final String addonId, - final CreateEntitlementsRequest createEntitlementsRequest, - final RequestOptions requestOptions) { - return exchangeCreateEntitlement(addonId, createEntitlementsRequest, requestOptions).send(); - } - - MeteroidHttpClient.Exchange exchangeCreateEntitlement( - final String addonId, - final CreateEntitlementsRequest createEntitlementsRequest, - final RequestOptions requestOptions) { - Objects.requireNonNull(addonId, "addon_id"); - Objects.requireNonNull(createEntitlementsRequest, "body"); - HttpUrl url = - client.newUrlBuilder() - .addPathSegments("api/v1/addons") - .addPathSegment(Utils.pathSegment("addon_id", addonId)) - .addPathSegments("entitlements") - .build(); - return client.call("POST", url) - .json(createEntitlementsRequest) - .errors(com.meteroid.models.RestErrorResponse.class, "400", "401", "404", "429") - .options(requestOptions) - .returning(EntitlementListResponse.class); - } - /** * Unarchive an add-on * @@ -425,6 +348,15 @@ MeteroidHttpClient.Exchange exchangeUnarchive( public final class WithRawResponse { private WithRawResponse() {} + /** + * The {@code entitlements} operations. + * + * @return the operations + */ + public AddOnsEntitlements.WithRawResponse entitlements() { + return AddOns.this.entitlements.withRawResponse(); + } + /** * List add-ons * @@ -566,61 +498,6 @@ public ApiResponse archive( return AddOns.this.exchangeArchive(addonId, requestOptions).sendRaw(); } - /** - * List add-on entitlements - * - * @param addonId the {@code addon_id} path parameter - * @return the status, headers and body - */ - public ApiResponse listEntitlements(final String addonId) { - return listEntitlements(addonId, RequestOptions.none()); - } - - /** - * List add-on entitlements - * - * @param addonId the {@code addon_id} path parameter - * @param requestOptions headers, timeout and retries of this call - * @return the status, headers and body - */ - public ApiResponse listEntitlements( - final String addonId, final RequestOptions requestOptions) { - return AddOns.this.exchangeListEntitlements(addonId, requestOptions).sendRaw(); - } - - /** - * Create add-on entitlements - * - *

Entitlements already present on this add-on are skipped. - * - * @param addonId the {@code addon_id} path parameter - * @param createEntitlementsRequest the request body - * @return the status, headers and body - */ - public ApiResponse createEntitlement( - final String addonId, final CreateEntitlementsRequest createEntitlementsRequest) { - return createEntitlement(addonId, createEntitlementsRequest, RequestOptions.none()); - } - - /** - * Create add-on entitlements - * - *

Entitlements already present on this add-on are skipped. - * - * @param addonId the {@code addon_id} path parameter - * @param createEntitlementsRequest the request body - * @param requestOptions headers, timeout and retries of this call - * @return the status, headers and body - */ - public ApiResponse createEntitlement( - final String addonId, - final CreateEntitlementsRequest createEntitlementsRequest, - final RequestOptions requestOptions) { - return AddOns.this - .exchangeCreateEntitlement(addonId, createEntitlementsRequest, requestOptions) - .sendRaw(); - } - /** * Unarchive an add-on * diff --git a/src/main/java/com/meteroid/api/AddOnsAsync.java b/src/main/java/com/meteroid/api/AddOnsAsync.java index a963298..607d84c 100644 --- a/src/main/java/com/meteroid/api/AddOnsAsync.java +++ b/src/main/java/com/meteroid/api/AddOnsAsync.java @@ -6,9 +6,6 @@ import com.meteroid.models.AddOn; import com.meteroid.models.AddOnListResponse; import com.meteroid.models.CreateAddOnRequest; -import com.meteroid.models.CreateEntitlementsRequest; -import com.meteroid.models.EntitlementListResponse; -import com.meteroid.models.ResolvedEntitlementListResponse; import com.meteroid.models.UpdateAddOnRequest; import java.util.List; @@ -22,6 +19,8 @@ public final class AddOnsAsync { private final AddOns sync; private final WithRawResponse withRawResponse; + private final AddOnsEntitlementsAsync entitlements; + /** * The operations, sending through {@code sync}. * @@ -30,6 +29,8 @@ public final class AddOnsAsync { public AddOnsAsync(AddOns sync) { this.sync = sync; this.withRawResponse = new WithRawResponse(); + + this.entitlements = new AddOnsEntitlementsAsync(sync.entitlements()); } /** @@ -41,6 +42,15 @@ public WithRawResponse withRawResponse() { return withRawResponse; } + /** + * The {@code entitlements} operations. + * + * @return the operations + */ + public AddOnsEntitlementsAsync entitlements() { + return entitlements; + } + /** * List add-ons * @@ -191,61 +201,6 @@ public CompletableFuture archive( return sync.exchangeArchive(addonId, requestOptions).sendAsync(); } - /** - * List add-on entitlements - * - * @param addonId the {@code addon_id} path parameter - * @return the response body, once received - */ - public CompletableFuture listEntitlements( - final String addonId) { - return listEntitlements(addonId, RequestOptions.none()); - } - - /** - * List add-on entitlements - * - * @param addonId the {@code addon_id} path parameter - * @param requestOptions headers, timeout and retries of this call - * @return the response body, once received - */ - public CompletableFuture listEntitlements( - final String addonId, final RequestOptions requestOptions) { - return sync.exchangeListEntitlements(addonId, requestOptions).sendAsync(); - } - - /** - * Create add-on entitlements - * - *

Entitlements already present on this add-on are skipped. - * - * @param addonId the {@code addon_id} path parameter - * @param createEntitlementsRequest the request body - * @return the response body, once received - */ - public CompletableFuture createEntitlement( - final String addonId, final CreateEntitlementsRequest createEntitlementsRequest) { - return createEntitlement(addonId, createEntitlementsRequest, RequestOptions.none()); - } - - /** - * Create add-on entitlements - * - *

Entitlements already present on this add-on are skipped. - * - * @param addonId the {@code addon_id} path parameter - * @param createEntitlementsRequest the request body - * @param requestOptions headers, timeout and retries of this call - * @return the response body, once received - */ - public CompletableFuture createEntitlement( - final String addonId, - final CreateEntitlementsRequest createEntitlementsRequest, - final RequestOptions requestOptions) { - return sync.exchangeCreateEntitlement(addonId, createEntitlementsRequest, requestOptions) - .sendAsync(); - } - /** * Unarchive an add-on * @@ -272,6 +227,15 @@ public CompletableFuture unarchive( public final class WithRawResponse { private WithRawResponse() {} + /** + * The {@code entitlements} operations. + * + * @return the operations + */ + public AddOnsEntitlementsAsync.WithRawResponse entitlements() { + return AddOnsAsync.this.entitlements.withRawResponse(); + } + /** * List add-ons * @@ -416,62 +380,6 @@ public CompletableFuture> archive( return sync.exchangeArchive(addonId, requestOptions).sendRawAsync(); } - /** - * List add-on entitlements - * - * @param addonId the {@code addon_id} path parameter - * @return the status, headers and body, once received - */ - public CompletableFuture> listEntitlements( - final String addonId) { - return listEntitlements(addonId, RequestOptions.none()); - } - - /** - * List add-on entitlements - * - * @param addonId the {@code addon_id} path parameter - * @param requestOptions headers, timeout and retries of this call - * @return the status, headers and body, once received - */ - public CompletableFuture> listEntitlements( - final String addonId, final RequestOptions requestOptions) { - return sync.exchangeListEntitlements(addonId, requestOptions).sendRawAsync(); - } - - /** - * Create add-on entitlements - * - *

Entitlements already present on this add-on are skipped. - * - * @param addonId the {@code addon_id} path parameter - * @param createEntitlementsRequest the request body - * @return the status, headers and body, once received - */ - public CompletableFuture> createEntitlement( - final String addonId, final CreateEntitlementsRequest createEntitlementsRequest) { - return createEntitlement(addonId, createEntitlementsRequest, RequestOptions.none()); - } - - /** - * Create add-on entitlements - * - *

Entitlements already present on this add-on are skipped. - * - * @param addonId the {@code addon_id} path parameter - * @param createEntitlementsRequest the request body - * @param requestOptions headers, timeout and retries of this call - * @return the status, headers and body, once received - */ - public CompletableFuture> createEntitlement( - final String addonId, - final CreateEntitlementsRequest createEntitlementsRequest, - final RequestOptions requestOptions) { - return sync.exchangeCreateEntitlement( - addonId, createEntitlementsRequest, requestOptions) - .sendRawAsync(); - } - /** * Unarchive an add-on * diff --git a/src/main/java/com/meteroid/api/AddOnsEntitlements.java b/src/main/java/com/meteroid/api/AddOnsEntitlements.java new file mode 100644 index 0000000..d442eff --- /dev/null +++ b/src/main/java/com/meteroid/api/AddOnsEntitlements.java @@ -0,0 +1,189 @@ +// this file is @generated +package com.meteroid.api; + +import com.meteroid.ApiResponse; +import com.meteroid.RequestOptions; +import com.meteroid.internal.MeteroidHttpClient; +import com.meteroid.internal.Utils; +import com.meteroid.models.CreateEntitlementsRequest; +import com.meteroid.models.EntitlementListResponse; +import com.meteroid.models.ResolvedEntitlementListResponse; + +import okhttp3.HttpUrl; + +import java.util.Objects; + +/** + * The {@code add_ons.entitlements} operations, blocking. {@link #withRawResponse()} has the same + * methods returning the status and headers along with the body. + */ +public final class AddOnsEntitlements { + private final MeteroidHttpClient client; + private final WithRawResponse withRawResponse; + + /** + * The operations, sending through {@code client}. + * + * @param client the HTTP client of the SDK + */ + public AddOnsEntitlements(MeteroidHttpClient client) { + this.client = client; + this.withRawResponse = new WithRawResponse(); + } + + /** + * The same operations, returning the status and headers along with the body. + * + * @return the operations + */ + public WithRawResponse withRawResponse() { + return withRawResponse; + } + + /** + * List add-on entitlements + * + * @param addonId the {@code addon_id} path parameter + * @return the response body + */ + public ResolvedEntitlementListResponse list(final String addonId) { + return list(addonId, RequestOptions.none()); + } + + /** + * List add-on entitlements + * + * @param addonId the {@code addon_id} path parameter + * @param requestOptions headers, timeout and retries of this call + * @return the response body + */ + public ResolvedEntitlementListResponse list( + final String addonId, final RequestOptions requestOptions) { + return exchangeList(addonId, requestOptions).send(); + } + + MeteroidHttpClient.Exchange exchangeList( + final String addonId, final RequestOptions requestOptions) { + Objects.requireNonNull(addonId, "addon_id"); + HttpUrl url = + client.newUrlBuilder() + .addPathSegments("api/v1/addons") + .addPathSegment(Utils.pathSegment("addon_id", addonId)) + .addPathSegments("entitlements") + .build(); + return client.call("GET", url) + .errors(com.meteroid.models.RestErrorResponse.class, "401", "404", "429") + .options(requestOptions) + .returning(ResolvedEntitlementListResponse.class); + } + + /** + * Create add-on entitlements + * + *

Entitlements already present on this add-on are skipped. + * + * @param addonId the {@code addon_id} path parameter + * @param createEntitlementsRequest the request body + * @return the response body + */ + public EntitlementListResponse create( + final String addonId, final CreateEntitlementsRequest createEntitlementsRequest) { + return create(addonId, createEntitlementsRequest, RequestOptions.none()); + } + + /** + * Create add-on entitlements + * + *

Entitlements already present on this add-on are skipped. + * + * @param addonId the {@code addon_id} path parameter + * @param createEntitlementsRequest the request body + * @param requestOptions headers, timeout and retries of this call + * @return the response body + */ + public EntitlementListResponse create( + final String addonId, + final CreateEntitlementsRequest createEntitlementsRequest, + final RequestOptions requestOptions) { + return exchangeCreate(addonId, createEntitlementsRequest, requestOptions).send(); + } + + MeteroidHttpClient.Exchange exchangeCreate( + final String addonId, + final CreateEntitlementsRequest createEntitlementsRequest, + final RequestOptions requestOptions) { + Objects.requireNonNull(addonId, "addon_id"); + Objects.requireNonNull(createEntitlementsRequest, "body"); + HttpUrl url = + client.newUrlBuilder() + .addPathSegments("api/v1/addons") + .addPathSegment(Utils.pathSegment("addon_id", addonId)) + .addPathSegments("entitlements") + .build(); + return client.call("POST", url) + .json(createEntitlementsRequest) + .errors(com.meteroid.models.RestErrorResponse.class, "400", "401", "404", "429") + .options(requestOptions) + .returning(EntitlementListResponse.class); + } + + /** The operations, returning the status and headers along with the body. */ + public final class WithRawResponse { + private WithRawResponse() {} + + /** + * List add-on entitlements + * + * @param addonId the {@code addon_id} path parameter + * @return the status, headers and body + */ + public ApiResponse list(final String addonId) { + return list(addonId, RequestOptions.none()); + } + + /** + * List add-on entitlements + * + * @param addonId the {@code addon_id} path parameter + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body + */ + public ApiResponse list( + final String addonId, final RequestOptions requestOptions) { + return AddOnsEntitlements.this.exchangeList(addonId, requestOptions).sendRaw(); + } + + /** + * Create add-on entitlements + * + *

Entitlements already present on this add-on are skipped. + * + * @param addonId the {@code addon_id} path parameter + * @param createEntitlementsRequest the request body + * @return the status, headers and body + */ + public ApiResponse create( + final String addonId, final CreateEntitlementsRequest createEntitlementsRequest) { + return create(addonId, createEntitlementsRequest, RequestOptions.none()); + } + + /** + * Create add-on entitlements + * + *

Entitlements already present on this add-on are skipped. + * + * @param addonId the {@code addon_id} path parameter + * @param createEntitlementsRequest the request body + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body + */ + public ApiResponse create( + final String addonId, + final CreateEntitlementsRequest createEntitlementsRequest, + final RequestOptions requestOptions) { + return AddOnsEntitlements.this + .exchangeCreate(addonId, createEntitlementsRequest, requestOptions) + .sendRaw(); + } + } +} diff --git a/src/main/java/com/meteroid/api/AddOnsEntitlementsAsync.java b/src/main/java/com/meteroid/api/AddOnsEntitlementsAsync.java new file mode 100644 index 0000000..a336740 --- /dev/null +++ b/src/main/java/com/meteroid/api/AddOnsEntitlementsAsync.java @@ -0,0 +1,151 @@ +// this file is @generated +package com.meteroid.api; + +import com.meteroid.ApiResponse; +import com.meteroid.RequestOptions; +import com.meteroid.models.CreateEntitlementsRequest; +import com.meteroid.models.EntitlementListResponse; +import com.meteroid.models.ResolvedEntitlementListResponse; + +import java.util.concurrent.CompletableFuture; + +/** + * The {@code add_ons.entitlements} operations, without blocking: each method returns a {@link + * CompletableFuture}. Obtained from {@code client.async()}. + */ +public final class AddOnsEntitlementsAsync { + private final AddOnsEntitlements sync; + private final WithRawResponse withRawResponse; + + /** + * The operations, sending through {@code sync}. + * + * @param sync the blocking operations + */ + public AddOnsEntitlementsAsync(AddOnsEntitlements sync) { + this.sync = sync; + this.withRawResponse = new WithRawResponse(); + } + + /** + * The same operations, returning the status and headers along with the body. + * + * @return the operations + */ + public WithRawResponse withRawResponse() { + return withRawResponse; + } + + /** + * List add-on entitlements + * + * @param addonId the {@code addon_id} path parameter + * @return the response body, once received + */ + public CompletableFuture list(final String addonId) { + return list(addonId, RequestOptions.none()); + } + + /** + * List add-on entitlements + * + * @param addonId the {@code addon_id} path parameter + * @param requestOptions headers, timeout and retries of this call + * @return the response body, once received + */ + public CompletableFuture list( + final String addonId, final RequestOptions requestOptions) { + return sync.exchangeList(addonId, requestOptions).sendAsync(); + } + + /** + * Create add-on entitlements + * + *

Entitlements already present on this add-on are skipped. + * + * @param addonId the {@code addon_id} path parameter + * @param createEntitlementsRequest the request body + * @return the response body, once received + */ + public CompletableFuture create( + final String addonId, final CreateEntitlementsRequest createEntitlementsRequest) { + return create(addonId, createEntitlementsRequest, RequestOptions.none()); + } + + /** + * Create add-on entitlements + * + *

Entitlements already present on this add-on are skipped. + * + * @param addonId the {@code addon_id} path parameter + * @param createEntitlementsRequest the request body + * @param requestOptions headers, timeout and retries of this call + * @return the response body, once received + */ + public CompletableFuture create( + final String addonId, + final CreateEntitlementsRequest createEntitlementsRequest, + final RequestOptions requestOptions) { + return sync.exchangeCreate(addonId, createEntitlementsRequest, requestOptions).sendAsync(); + } + + /** The operations, returning the status and headers along with the body. */ + public final class WithRawResponse { + private WithRawResponse() {} + + /** + * List add-on entitlements + * + * @param addonId the {@code addon_id} path parameter + * @return the status, headers and body, once received + */ + public CompletableFuture> list( + final String addonId) { + return list(addonId, RequestOptions.none()); + } + + /** + * List add-on entitlements + * + * @param addonId the {@code addon_id} path parameter + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body, once received + */ + public CompletableFuture> list( + final String addonId, final RequestOptions requestOptions) { + return sync.exchangeList(addonId, requestOptions).sendRawAsync(); + } + + /** + * Create add-on entitlements + * + *

Entitlements already present on this add-on are skipped. + * + * @param addonId the {@code addon_id} path parameter + * @param createEntitlementsRequest the request body + * @return the status, headers and body, once received + */ + public CompletableFuture> create( + final String addonId, final CreateEntitlementsRequest createEntitlementsRequest) { + return create(addonId, createEntitlementsRequest, RequestOptions.none()); + } + + /** + * Create add-on entitlements + * + *

Entitlements already present on this add-on are skipped. + * + * @param addonId the {@code addon_id} path parameter + * @param createEntitlementsRequest the request body + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body, once received + */ + public CompletableFuture> create( + final String addonId, + final CreateEntitlementsRequest createEntitlementsRequest, + final RequestOptions requestOptions) { + return sync.exchangeCreate(addonId, createEntitlementsRequest, requestOptions) + .sendRawAsync(); + } + } +} diff --git a/src/main/java/com/meteroid/api/Plans.java b/src/main/java/com/meteroid/api/Plans.java index 572dfed..e8f80e7 100644 --- a/src/main/java/com/meteroid/api/Plans.java +++ b/src/main/java/com/meteroid/api/Plans.java @@ -8,14 +8,11 @@ import com.meteroid.models.CreateEntitlementsRequest; import com.meteroid.models.CreatePlanRequest; import com.meteroid.models.EntitlementListResponse; -import com.meteroid.models.MinimumCommitment; import com.meteroid.models.PatchPlanRequest; import com.meteroid.models.Plan; import com.meteroid.models.PlanListResponse; import com.meteroid.models.PlanStatusEnum; import com.meteroid.models.PlanTypeEnum; -import com.meteroid.models.PlanVersionListResponse; -import com.meteroid.models.PlanVersionSummary; import com.meteroid.models.ReplacePlanRequest; import com.meteroid.models.ResolvedEntitlementListResponse; @@ -32,6 +29,8 @@ public final class Plans { private final MeteroidHttpClient client; private final WithRawResponse withRawResponse; + private final PlansVersions versions; + /** * The operations, sending through {@code client}. * @@ -40,6 +39,8 @@ public final class Plans { public Plans(MeteroidHttpClient client) { this.client = client; this.withRawResponse = new WithRawResponse(); + + this.versions = new PlansVersions(client); } /** @@ -51,6 +52,15 @@ public WithRawResponse withRawResponse() { return withRawResponse; } + /** + * The {@code versions} operations. + * + * @return the operations + */ + public PlansVersions versions() { + return versions; + } + /** * List plan version entitlements * @@ -293,88 +303,6 @@ MeteroidHttpClient.Exchange exchangeCreate( .returning(Plan.class); } - /** - * Set or replace the plan-level minimum commitment for a draft plan version. - * - * @param planVersionId the {@code plan_version_id} path parameter - * @param minimumCommitment the request body - * @return the response body - */ - public MinimumCommitment updateVersionMinimum( - final String planVersionId, final MinimumCommitment minimumCommitment) { - return updateVersionMinimum(planVersionId, minimumCommitment, RequestOptions.none()); - } - - /** - * Set or replace the plan-level minimum commitment for a draft plan version. - * - * @param planVersionId the {@code plan_version_id} path parameter - * @param minimumCommitment the request body - * @param requestOptions headers, timeout and retries of this call - * @return the response body - */ - public MinimumCommitment updateVersionMinimum( - final String planVersionId, - final MinimumCommitment minimumCommitment, - final RequestOptions requestOptions) { - return exchangeUpdateVersionMinimum(planVersionId, minimumCommitment, requestOptions) - .send(); - } - - MeteroidHttpClient.Exchange exchangeUpdateVersionMinimum( - final String planVersionId, - final MinimumCommitment minimumCommitment, - final RequestOptions requestOptions) { - Objects.requireNonNull(planVersionId, "plan_version_id"); - Objects.requireNonNull(minimumCommitment, "body"); - HttpUrl url = - client.newUrlBuilder() - .addPathSegments("api/v1/plans/versions") - .addPathSegment(Utils.pathSegment("plan_version_id", planVersionId)) - .addPathSegments("minimum") - .build(); - return client.call("PUT", url) - .json(minimumCommitment) - .errors(com.meteroid.models.RestErrorResponse.class, "400", "401", "404", "429") - .options(requestOptions) - .returning(MinimumCommitment.class); - } - - /** - * Remove the plan-level minimum commitment for a draft plan version. - * - * @param planVersionId the {@code plan_version_id} path parameter - */ - public void deleteVersionMinimum(final String planVersionId) { - deleteVersionMinimum(planVersionId, RequestOptions.none()); - } - - /** - * Remove the plan-level minimum commitment for a draft plan version. - * - * @param planVersionId the {@code plan_version_id} path parameter - * @param requestOptions headers, timeout and retries of this call - */ - public void deleteVersionMinimum( - final String planVersionId, final RequestOptions requestOptions) { - exchangeDeleteVersionMinimum(planVersionId, requestOptions).send(); - } - - MeteroidHttpClient.Exchange exchangeDeleteVersionMinimum( - final String planVersionId, final RequestOptions requestOptions) { - Objects.requireNonNull(planVersionId, "plan_version_id"); - HttpUrl url = - client.newUrlBuilder() - .addPathSegments("api/v1/plans/versions") - .addPathSegment(Utils.pathSegment("plan_version_id", planVersionId)) - .addPathSegments("minimum") - .build(); - return client.call("DELETE", url) - .errors(com.meteroid.models.RestErrorResponse.class, "401", "404", "429") - .options(requestOptions) - .returningNothing(); - } - /** * Get plan details * @@ -664,128 +592,19 @@ MeteroidHttpClient.Exchange exchangeUnarchive( .returningNothing(); } - /** - * List plan versions - * - * @param planId the {@code plan_id} path parameter - * @return the page: the response body, its items and the way to the next pages - */ - public PlansListVersionsPage listVersions(final String planId) { - return listVersions(planId, PlansListVersionsOptions.none(), RequestOptions.none()); - } - - /** - * List plan versions - * - * @param planId the {@code plan_id} path parameter - * @param options the optional parameters - * @return the page: the response body, its items and the way to the next pages - */ - public PlansListVersionsPage listVersions( - final String planId, final PlansListVersionsOptions options) { - return listVersions(planId, options, RequestOptions.none()); - } - - /** - * List plan versions - * - * @param planId the {@code plan_id} path parameter - * @param requestOptions headers, timeout and retries of this call - * @return the page: the response body, its items and the way to the next pages - */ - public PlansListVersionsPage listVersions( - final String planId, final RequestOptions requestOptions) { - return listVersions(planId, PlansListVersionsOptions.none(), requestOptions); - } - - /** - * List plan versions - * - * @param planId the {@code plan_id} path parameter - * @param options the optional parameters - * @param requestOptions headers, timeout and retries of this call - * @return the page: the response body, its items and the way to the next pages - */ - public PlansListVersionsPage listVersions( - final String planId, - final PlansListVersionsOptions options, - final RequestOptions requestOptions) { - return pageOfListVersions( - exchangeListVersions(planId, options, requestOptions).send(), - planId, - options, - requestOptions); - } - - MeteroidHttpClient.Exchange exchangeListVersions( - final String planId, - final PlansListVersionsOptions options, - final RequestOptions requestOptions) { - Objects.requireNonNull(planId, "plan_id"); - Objects.requireNonNull(options, "options"); - HttpUrl.Builder url = - client.newUrlBuilder() - .addPathSegments("api/v1/plans") - .addPathSegment(Utils.pathSegment("plan_id", planId)) - .addPathSegments("versions"); - Integer value1 = options.page().orElse(null); - if (value1 != null) { - url.addQueryParameter("page", Utils.serializeQueryParam(value1)); - } - Integer value2 = options.perPage().orElse(null); - if (value2 != null) { - url.addQueryParameter("per_page", Utils.serializeQueryParam(value2)); - } - return client.call("GET", url.build()) - .errors(com.meteroid.models.RestErrorResponse.class, "401", "404", "429") - .options(requestOptions) - .returning(PlanVersionListResponse.class); - } - - private PlansListVersionsPage pageOfListVersions( - PlanVersionListResponse response, - final String planId, - final PlansListVersionsOptions options, - final RequestOptions requestOptions) { - List items = itemsOfListVersions(response); - Integer next = nextOfListVersions(response, items, options.page().orElse(0)); - return new PlansListVersionsPage( - response, - items, - next == null - ? null - : () -> - listVersions( - planId, - options.toBuilder().page(next).build(), - requestOptions)); - } - - static List itemsOfListVersions(PlanVersionListResponse response) { - return Utils.optional(response.data()).orElse(List.of()); - } - - /** The parameter of the page after {@code response}, null after the last one. */ - static Integer nextOfListVersions( - PlanVersionListResponse 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; - } - /** The operations, returning the status and headers along with the body. */ public final class WithRawResponse { private WithRawResponse() {} + /** + * The {@code versions} operations. + * + * @return the operations + */ + public PlansVersions.WithRawResponse versions() { + return Plans.this.versions.withRawResponse(); + } + /** * List plan version entitlements * @@ -921,57 +740,6 @@ public ApiResponse create( return Plans.this.exchangeCreate(createPlanRequest, requestOptions).sendRaw(); } - /** - * Set or replace the plan-level minimum commitment for a draft plan version. - * - * @param planVersionId the {@code plan_version_id} path parameter - * @param minimumCommitment the request body - * @return the status, headers and body - */ - public ApiResponse updateVersionMinimum( - final String planVersionId, final MinimumCommitment minimumCommitment) { - return updateVersionMinimum(planVersionId, minimumCommitment, RequestOptions.none()); - } - - /** - * Set or replace the plan-level minimum commitment for a draft plan version. - * - * @param planVersionId the {@code plan_version_id} path parameter - * @param minimumCommitment the request body - * @param requestOptions headers, timeout and retries of this call - * @return the status, headers and body - */ - public ApiResponse updateVersionMinimum( - final String planVersionId, - final MinimumCommitment minimumCommitment, - final RequestOptions requestOptions) { - return Plans.this - .exchangeUpdateVersionMinimum(planVersionId, minimumCommitment, requestOptions) - .sendRaw(); - } - - /** - * Remove the plan-level minimum commitment for a draft plan version. - * - * @param planVersionId the {@code plan_version_id} path parameter - * @return the status, headers and body - */ - public ApiResponse deleteVersionMinimum(final String planVersionId) { - return deleteVersionMinimum(planVersionId, RequestOptions.none()); - } - - /** - * Remove the plan-level minimum commitment for a draft plan version. - * - * @param planVersionId the {@code plan_version_id} path parameter - * @param requestOptions headers, timeout and retries of this call - * @return the status, headers and body - */ - public ApiResponse deleteVersionMinimum( - final String planVersionId, final RequestOptions requestOptions) { - return Plans.this.exchangeDeleteVersionMinimum(planVersionId, requestOptions).sendRaw(); - } - /** * Get plan details * @@ -1167,59 +935,5 @@ public ApiResponse unarchive( final String planId, final RequestOptions requestOptions) { return Plans.this.exchangeUnarchive(planId, requestOptions).sendRaw(); } - - /** - * List plan versions - * - * @param planId the {@code plan_id} path parameter - * @return the status, headers and page - */ - public ApiResponse listVersions(final String planId) { - return listVersions(planId, PlansListVersionsOptions.none(), RequestOptions.none()); - } - - /** - * List plan versions - * - * @param planId the {@code plan_id} path parameter - * @param options the optional parameters - * @return the status, headers and page - */ - public ApiResponse listVersions( - final String planId, final PlansListVersionsOptions options) { - return listVersions(planId, options, RequestOptions.none()); - } - - /** - * List plan versions - * - * @param planId the {@code plan_id} path parameter - * @param requestOptions headers, timeout and retries of this call - * @return the status, headers and page - */ - public ApiResponse listVersions( - final String planId, final RequestOptions requestOptions) { - return listVersions(planId, PlansListVersionsOptions.none(), requestOptions); - } - - /** - * List plan versions - * - * @param planId the {@code plan_id} path parameter - * @param options the optional parameters - * @param requestOptions headers, timeout and retries of this call - * @return the status, headers and page - */ - public ApiResponse listVersions( - final String planId, - final PlansListVersionsOptions options, - final RequestOptions requestOptions) { - ApiResponse response = - exchangeListVersions(planId, options, requestOptions).sendRaw(); - return new ApiResponse<>( - response.statusCode(), - response.headers(), - pageOfListVersions(response.body(), planId, options, requestOptions)); - } } } diff --git a/src/main/java/com/meteroid/api/PlansAsync.java b/src/main/java/com/meteroid/api/PlansAsync.java index bacf7f6..f3b0baf 100644 --- a/src/main/java/com/meteroid/api/PlansAsync.java +++ b/src/main/java/com/meteroid/api/PlansAsync.java @@ -6,12 +6,9 @@ import com.meteroid.models.CreateEntitlementsRequest; import com.meteroid.models.CreatePlanRequest; import com.meteroid.models.EntitlementListResponse; -import com.meteroid.models.MinimumCommitment; import com.meteroid.models.PatchPlanRequest; import com.meteroid.models.Plan; import com.meteroid.models.PlanListResponse; -import com.meteroid.models.PlanVersionListResponse; -import com.meteroid.models.PlanVersionSummary; import com.meteroid.models.ReplacePlanRequest; import com.meteroid.models.ResolvedEntitlementListResponse; @@ -26,6 +23,8 @@ public final class PlansAsync { private final Plans sync; private final WithRawResponse withRawResponse; + private final PlansVersionsAsync versions; + /** * The operations, sending through {@code sync}. * @@ -34,6 +33,8 @@ public final class PlansAsync { public PlansAsync(Plans sync) { this.sync = sync; this.withRawResponse = new WithRawResponse(); + + this.versions = new PlansVersionsAsync(sync.versions()); } /** @@ -45,6 +46,15 @@ public WithRawResponse withRawResponse() { return withRawResponse; } + /** + * The {@code versions} operations. + * + * @return the operations + */ + public PlansVersionsAsync versions() { + return versions; + } + /** * List plan version entitlements * @@ -187,56 +197,6 @@ public CompletableFuture create( return sync.exchangeCreate(createPlanRequest, requestOptions).sendAsync(); } - /** - * Set or replace the plan-level minimum commitment for a draft plan version. - * - * @param planVersionId the {@code plan_version_id} path parameter - * @param minimumCommitment the request body - * @return the response body, once received - */ - public CompletableFuture updateVersionMinimum( - final String planVersionId, final MinimumCommitment minimumCommitment) { - return updateVersionMinimum(planVersionId, minimumCommitment, RequestOptions.none()); - } - - /** - * Set or replace the plan-level minimum commitment for a draft plan version. - * - * @param planVersionId the {@code plan_version_id} path parameter - * @param minimumCommitment the request body - * @param requestOptions headers, timeout and retries of this call - * @return the response body, once received - */ - public CompletableFuture updateVersionMinimum( - final String planVersionId, - final MinimumCommitment minimumCommitment, - final RequestOptions requestOptions) { - return sync.exchangeUpdateVersionMinimum(planVersionId, minimumCommitment, requestOptions) - .sendAsync(); - } - - /** - * Remove the plan-level minimum commitment for a draft plan version. - * - * @param planVersionId the {@code plan_version_id} path parameter - * @return the response body, once received - */ - public CompletableFuture deleteVersionMinimum(final String planVersionId) { - return deleteVersionMinimum(planVersionId, RequestOptions.none()); - } - - /** - * Remove the plan-level minimum commitment for a draft plan version. - * - * @param planVersionId the {@code plan_version_id} path parameter - * @param requestOptions headers, timeout and retries of this call - * @return the response body, once received - */ - public CompletableFuture deleteVersionMinimum( - final String planVersionId, final RequestOptions requestOptions) { - return sync.exchangeDeleteVersionMinimum(planVersionId, requestOptions).sendAsync(); - } - /** * Get plan details * @@ -436,81 +396,19 @@ public CompletableFuture unarchive( return sync.exchangeUnarchive(planId, requestOptions).sendAsync(); } - /** - * List plan versions - * - * @param planId the {@code plan_id} path parameter - * @return the page, once received - */ - public CompletableFuture listVersions(final String planId) { - return listVersions(planId, PlansListVersionsOptions.none(), RequestOptions.none()); - } - - /** - * List plan versions - * - * @param planId the {@code plan_id} path parameter - * @param options the optional parameters - * @return the page, once received - */ - public CompletableFuture listVersions( - final String planId, final PlansListVersionsOptions options) { - return listVersions(planId, options, RequestOptions.none()); - } - - /** - * List plan versions - * - * @param planId the {@code plan_id} path parameter - * @param requestOptions headers, timeout and retries of this call - * @return the page, once received - */ - public CompletableFuture listVersions( - final String planId, final RequestOptions requestOptions) { - return listVersions(planId, PlansListVersionsOptions.none(), requestOptions); - } - - /** - * List plan versions - * - * @param planId the {@code plan_id} path parameter - * @param options the optional parameters - * @param requestOptions headers, timeout and retries of this call - * @return the page, once received - */ - public CompletableFuture listVersions( - final String planId, - final PlansListVersionsOptions options, - final RequestOptions requestOptions) { - return sync.exchangeListVersions(planId, options, requestOptions) - .sendAsync() - .thenApply( - response -> pageOfListVersions(response, planId, options, requestOptions)); - } - - private PlansListVersionsAsyncPage pageOfListVersions( - PlanVersionListResponse response, - final String planId, - final PlansListVersionsOptions options, - final RequestOptions requestOptions) { - List items = Plans.itemsOfListVersions(response); - Integer next = Plans.nextOfListVersions(response, items, options.page().orElse(0)); - return new PlansListVersionsAsyncPage( - response, - items, - next == null - ? null - : () -> - listVersions( - planId, - options.toBuilder().page(next).build(), - requestOptions)); - } - /** The operations, returning the status and headers along with the body. */ public final class WithRawResponse { private WithRawResponse() {} + /** + * The {@code versions} operations. + * + * @return the operations + */ + public PlansVersionsAsync.WithRawResponse versions() { + return PlansAsync.this.versions.withRawResponse(); + } + /** * List plan version entitlements * @@ -650,58 +548,6 @@ public CompletableFuture> create( return sync.exchangeCreate(createPlanRequest, requestOptions).sendRawAsync(); } - /** - * Set or replace the plan-level minimum commitment for a draft plan version. - * - * @param planVersionId the {@code plan_version_id} path parameter - * @param minimumCommitment the request body - * @return the status, headers and body, once received - */ - public CompletableFuture> updateVersionMinimum( - final String planVersionId, final MinimumCommitment minimumCommitment) { - return updateVersionMinimum(planVersionId, minimumCommitment, RequestOptions.none()); - } - - /** - * Set or replace the plan-level minimum commitment for a draft plan version. - * - * @param planVersionId the {@code plan_version_id} path parameter - * @param minimumCommitment the request body - * @param requestOptions headers, timeout and retries of this call - * @return the status, headers and body, once received - */ - public CompletableFuture> updateVersionMinimum( - final String planVersionId, - final MinimumCommitment minimumCommitment, - final RequestOptions requestOptions) { - return sync.exchangeUpdateVersionMinimum( - planVersionId, minimumCommitment, requestOptions) - .sendRawAsync(); - } - - /** - * Remove the plan-level minimum commitment for a draft plan version. - * - * @param planVersionId the {@code plan_version_id} path parameter - * @return the status, headers and body, once received - */ - public CompletableFuture> deleteVersionMinimum( - final String planVersionId) { - return deleteVersionMinimum(planVersionId, RequestOptions.none()); - } - - /** - * Remove the plan-level minimum commitment for a draft plan version. - * - * @param planVersionId the {@code plan_version_id} path parameter - * @param requestOptions headers, timeout and retries of this call - * @return the status, headers and body, once received - */ - public CompletableFuture> deleteVersionMinimum( - final String planVersionId, final RequestOptions requestOptions) { - return sync.exchangeDeleteVersionMinimum(planVersionId, requestOptions).sendRawAsync(); - } - /** * Get plan details * @@ -900,66 +746,5 @@ public CompletableFuture> unarchive( final String planId, final RequestOptions requestOptions) { return sync.exchangeUnarchive(planId, requestOptions).sendRawAsync(); } - - /** - * List plan versions - * - * @param planId the {@code plan_id} path parameter - * @return the status, headers and page, once received - */ - public CompletableFuture> listVersions( - final String planId) { - return listVersions(planId, PlansListVersionsOptions.none(), RequestOptions.none()); - } - - /** - * List plan versions - * - * @param planId the {@code plan_id} path parameter - * @param options the optional parameters - * @return the status, headers and page, once received - */ - public CompletableFuture> listVersions( - final String planId, final PlansListVersionsOptions options) { - return listVersions(planId, options, RequestOptions.none()); - } - - /** - * List plan versions - * - * @param planId the {@code plan_id} path parameter - * @param requestOptions headers, timeout and retries of this call - * @return the status, headers and page, once received - */ - public CompletableFuture> listVersions( - final String planId, final RequestOptions requestOptions) { - return listVersions(planId, PlansListVersionsOptions.none(), requestOptions); - } - - /** - * List plan versions - * - * @param planId the {@code plan_id} path parameter - * @param options the optional parameters - * @param requestOptions headers, timeout and retries of this call - * @return the status, headers and page, once received - */ - public CompletableFuture> listVersions( - final String planId, - final PlansListVersionsOptions options, - final RequestOptions requestOptions) { - return sync.exchangeListVersions(planId, options, requestOptions) - .sendRawAsync() - .thenApply( - response -> - new ApiResponse<>( - response.statusCode(), - response.headers(), - pageOfListVersions( - response.body(), - planId, - options, - requestOptions))); - } } } diff --git a/src/main/java/com/meteroid/api/PlansVersions.java b/src/main/java/com/meteroid/api/PlansVersions.java new file mode 100644 index 0000000..fceaca0 --- /dev/null +++ b/src/main/java/com/meteroid/api/PlansVersions.java @@ -0,0 +1,351 @@ +// this file is @generated +package com.meteroid.api; + +import com.meteroid.ApiResponse; +import com.meteroid.RequestOptions; +import com.meteroid.internal.MeteroidHttpClient; +import com.meteroid.internal.Utils; +import com.meteroid.models.MinimumCommitment; +import com.meteroid.models.PlanVersionListResponse; +import com.meteroid.models.PlanVersionSummary; + +import okhttp3.HttpUrl; + +import java.util.List; +import java.util.Objects; + +/** + * The {@code plans.versions} operations, blocking. {@link #withRawResponse()} has the same methods + * returning the status and headers along with the body. + */ +public final class PlansVersions { + private final MeteroidHttpClient client; + private final WithRawResponse withRawResponse; + + /** + * The operations, sending through {@code client}. + * + * @param client the HTTP client of the SDK + */ + public PlansVersions(MeteroidHttpClient client) { + this.client = client; + this.withRawResponse = new WithRawResponse(); + } + + /** + * The same operations, returning the status and headers along with the body. + * + * @return the operations + */ + public WithRawResponse withRawResponse() { + return withRawResponse; + } + + /** + * Set or replace the plan-level minimum commitment for a draft plan version. + * + * @param planVersionId the {@code plan_version_id} path parameter + * @param minimumCommitment the request body + * @return the response body + */ + public MinimumCommitment updateMinimum( + final String planVersionId, final MinimumCommitment minimumCommitment) { + return updateMinimum(planVersionId, minimumCommitment, RequestOptions.none()); + } + + /** + * Set or replace the plan-level minimum commitment for a draft plan version. + * + * @param planVersionId the {@code plan_version_id} path parameter + * @param minimumCommitment the request body + * @param requestOptions headers, timeout and retries of this call + * @return the response body + */ + public MinimumCommitment updateMinimum( + final String planVersionId, + final MinimumCommitment minimumCommitment, + final RequestOptions requestOptions) { + return exchangeUpdateMinimum(planVersionId, minimumCommitment, requestOptions).send(); + } + + MeteroidHttpClient.Exchange exchangeUpdateMinimum( + final String planVersionId, + final MinimumCommitment minimumCommitment, + final RequestOptions requestOptions) { + Objects.requireNonNull(planVersionId, "plan_version_id"); + Objects.requireNonNull(minimumCommitment, "body"); + HttpUrl url = + client.newUrlBuilder() + .addPathSegments("api/v1/plans/versions") + .addPathSegment(Utils.pathSegment("plan_version_id", planVersionId)) + .addPathSegments("minimum") + .build(); + return client.call("PUT", url) + .json(minimumCommitment) + .errors(com.meteroid.models.RestErrorResponse.class, "400", "401", "404", "429") + .options(requestOptions) + .returning(MinimumCommitment.class); + } + + /** + * Remove the plan-level minimum commitment for a draft plan version. + * + * @param planVersionId the {@code plan_version_id} path parameter + */ + public void deleteMinimum(final String planVersionId) { + deleteMinimum(planVersionId, RequestOptions.none()); + } + + /** + * Remove the plan-level minimum commitment for a draft plan version. + * + * @param planVersionId the {@code plan_version_id} path parameter + * @param requestOptions headers, timeout and retries of this call + */ + public void deleteMinimum(final String planVersionId, final RequestOptions requestOptions) { + exchangeDeleteMinimum(planVersionId, requestOptions).send(); + } + + MeteroidHttpClient.Exchange exchangeDeleteMinimum( + final String planVersionId, final RequestOptions requestOptions) { + Objects.requireNonNull(planVersionId, "plan_version_id"); + HttpUrl url = + client.newUrlBuilder() + .addPathSegments("api/v1/plans/versions") + .addPathSegment(Utils.pathSegment("plan_version_id", planVersionId)) + .addPathSegments("minimum") + .build(); + return client.call("DELETE", url) + .errors(com.meteroid.models.RestErrorResponse.class, "401", "404", "429") + .options(requestOptions) + .returningNothing(); + } + + /** + * List plan versions + * + * @param planId the {@code plan_id} path parameter + * @return the page: the response body, its items and the way to the next pages + */ + public PlansVersionsListPage list(final String planId) { + return list(planId, PlansVersionsListOptions.none(), RequestOptions.none()); + } + + /** + * List plan versions + * + * @param planId the {@code plan_id} path parameter + * @param options the optional parameters + * @return the page: the response body, its items and the way to the next pages + */ + public PlansVersionsListPage list(final String planId, final PlansVersionsListOptions options) { + return list(planId, options, RequestOptions.none()); + } + + /** + * List plan versions + * + * @param planId the {@code plan_id} path parameter + * @param requestOptions headers, timeout and retries of this call + * @return the page: the response body, its items and the way to the next pages + */ + public PlansVersionsListPage list(final String planId, final RequestOptions requestOptions) { + return list(planId, PlansVersionsListOptions.none(), requestOptions); + } + + /** + * List plan versions + * + * @param planId the {@code plan_id} path parameter + * @param options the optional parameters + * @param requestOptions headers, timeout and retries of this call + * @return the page: the response body, its items and the way to the next pages + */ + public PlansVersionsListPage list( + final String planId, + final PlansVersionsListOptions options, + final RequestOptions requestOptions) { + return pageOfList( + exchangeList(planId, options, requestOptions).send(), + planId, + options, + requestOptions); + } + + MeteroidHttpClient.Exchange exchangeList( + final String planId, + final PlansVersionsListOptions options, + final RequestOptions requestOptions) { + Objects.requireNonNull(planId, "plan_id"); + Objects.requireNonNull(options, "options"); + HttpUrl.Builder url = + client.newUrlBuilder() + .addPathSegments("api/v1/plans") + .addPathSegment(Utils.pathSegment("plan_id", planId)) + .addPathSegments("versions"); + Integer value1 = options.page().orElse(null); + if (value1 != null) { + url.addQueryParameter("page", Utils.serializeQueryParam(value1)); + } + Integer value2 = options.perPage().orElse(null); + if (value2 != null) { + url.addQueryParameter("per_page", Utils.serializeQueryParam(value2)); + } + return client.call("GET", url.build()) + .errors(com.meteroid.models.RestErrorResponse.class, "401", "404", "429") + .options(requestOptions) + .returning(PlanVersionListResponse.class); + } + + private PlansVersionsListPage pageOfList( + PlanVersionListResponse response, + final String planId, + final PlansVersionsListOptions options, + final RequestOptions requestOptions) { + List items = itemsOfList(response); + Integer next = nextOfList(response, items, options.page().orElse(0)); + return new PlansVersionsListPage( + response, + items, + next == null + ? null + : () -> + list( + planId, + options.toBuilder().page(next).build(), + requestOptions)); + } + + static List itemsOfList(PlanVersionListResponse 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( + PlanVersionListResponse 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; + } + + /** The operations, returning the status and headers along with the body. */ + public final class WithRawResponse { + private WithRawResponse() {} + + /** + * Set or replace the plan-level minimum commitment for a draft plan version. + * + * @param planVersionId the {@code plan_version_id} path parameter + * @param minimumCommitment the request body + * @return the status, headers and body + */ + public ApiResponse updateMinimum( + final String planVersionId, final MinimumCommitment minimumCommitment) { + return updateMinimum(planVersionId, minimumCommitment, RequestOptions.none()); + } + + /** + * Set or replace the plan-level minimum commitment for a draft plan version. + * + * @param planVersionId the {@code plan_version_id} path parameter + * @param minimumCommitment the request body + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body + */ + public ApiResponse updateMinimum( + final String planVersionId, + final MinimumCommitment minimumCommitment, + final RequestOptions requestOptions) { + return PlansVersions.this + .exchangeUpdateMinimum(planVersionId, minimumCommitment, requestOptions) + .sendRaw(); + } + + /** + * Remove the plan-level minimum commitment for a draft plan version. + * + * @param planVersionId the {@code plan_version_id} path parameter + * @return the status, headers and body + */ + public ApiResponse deleteMinimum(final String planVersionId) { + return deleteMinimum(planVersionId, RequestOptions.none()); + } + + /** + * Remove the plan-level minimum commitment for a draft plan version. + * + * @param planVersionId the {@code plan_version_id} path parameter + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body + */ + public ApiResponse deleteMinimum( + final String planVersionId, final RequestOptions requestOptions) { + return PlansVersions.this + .exchangeDeleteMinimum(planVersionId, requestOptions) + .sendRaw(); + } + + /** + * List plan versions + * + * @param planId the {@code plan_id} path parameter + * @return the status, headers and page + */ + public ApiResponse list(final String planId) { + return list(planId, PlansVersionsListOptions.none(), RequestOptions.none()); + } + + /** + * List plan versions + * + * @param planId the {@code plan_id} path parameter + * @param options the optional parameters + * @return the status, headers and page + */ + public ApiResponse list( + final String planId, final PlansVersionsListOptions options) { + return list(planId, options, RequestOptions.none()); + } + + /** + * List plan versions + * + * @param planId the {@code plan_id} path parameter + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and page + */ + public ApiResponse list( + final String planId, final RequestOptions requestOptions) { + return list(planId, PlansVersionsListOptions.none(), requestOptions); + } + + /** + * List plan versions + * + * @param planId the {@code plan_id} path parameter + * @param options the optional parameters + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and page + */ + public ApiResponse list( + final String planId, + final PlansVersionsListOptions options, + final RequestOptions requestOptions) { + ApiResponse response = + exchangeList(planId, options, requestOptions).sendRaw(); + return new ApiResponse<>( + response.statusCode(), + response.headers(), + pageOfList(response.body(), planId, options, requestOptions)); + } + } +} diff --git a/src/main/java/com/meteroid/api/PlansVersionsAsync.java b/src/main/java/com/meteroid/api/PlansVersionsAsync.java new file mode 100644 index 0000000..08bbd59 --- /dev/null +++ b/src/main/java/com/meteroid/api/PlansVersionsAsync.java @@ -0,0 +1,275 @@ +// this file is @generated +package com.meteroid.api; + +import com.meteroid.ApiResponse; +import com.meteroid.RequestOptions; +import com.meteroid.models.MinimumCommitment; +import com.meteroid.models.PlanVersionListResponse; +import com.meteroid.models.PlanVersionSummary; + +import java.util.List; +import java.util.concurrent.CompletableFuture; + +/** + * The {@code plans.versions} operations, without blocking: each method returns a {@link + * CompletableFuture}. Obtained from {@code client.async()}. + */ +public final class PlansVersionsAsync { + private final PlansVersions sync; + private final WithRawResponse withRawResponse; + + /** + * The operations, sending through {@code sync}. + * + * @param sync the blocking operations + */ + public PlansVersionsAsync(PlansVersions sync) { + this.sync = sync; + this.withRawResponse = new WithRawResponse(); + } + + /** + * The same operations, returning the status and headers along with the body. + * + * @return the operations + */ + public WithRawResponse withRawResponse() { + return withRawResponse; + } + + /** + * Set or replace the plan-level minimum commitment for a draft plan version. + * + * @param planVersionId the {@code plan_version_id} path parameter + * @param minimumCommitment the request body + * @return the response body, once received + */ + public CompletableFuture updateMinimum( + final String planVersionId, final MinimumCommitment minimumCommitment) { + return updateMinimum(planVersionId, minimumCommitment, RequestOptions.none()); + } + + /** + * Set or replace the plan-level minimum commitment for a draft plan version. + * + * @param planVersionId the {@code plan_version_id} path parameter + * @param minimumCommitment the request body + * @param requestOptions headers, timeout and retries of this call + * @return the response body, once received + */ + public CompletableFuture updateMinimum( + final String planVersionId, + final MinimumCommitment minimumCommitment, + final RequestOptions requestOptions) { + return sync.exchangeUpdateMinimum(planVersionId, minimumCommitment, requestOptions) + .sendAsync(); + } + + /** + * Remove the plan-level minimum commitment for a draft plan version. + * + * @param planVersionId the {@code plan_version_id} path parameter + * @return the response body, once received + */ + public CompletableFuture deleteMinimum(final String planVersionId) { + return deleteMinimum(planVersionId, RequestOptions.none()); + } + + /** + * Remove the plan-level minimum commitment for a draft plan version. + * + * @param planVersionId the {@code plan_version_id} path parameter + * @param requestOptions headers, timeout and retries of this call + * @return the response body, once received + */ + public CompletableFuture deleteMinimum( + final String planVersionId, final RequestOptions requestOptions) { + return sync.exchangeDeleteMinimum(planVersionId, requestOptions).sendAsync(); + } + + /** + * List plan versions + * + * @param planId the {@code plan_id} path parameter + * @return the page, once received + */ + public CompletableFuture list(final String planId) { + return list(planId, PlansVersionsListOptions.none(), RequestOptions.none()); + } + + /** + * List plan versions + * + * @param planId the {@code plan_id} path parameter + * @param options the optional parameters + * @return the page, once received + */ + public CompletableFuture list( + final String planId, final PlansVersionsListOptions options) { + return list(planId, options, RequestOptions.none()); + } + + /** + * List plan versions + * + * @param planId the {@code plan_id} path parameter + * @param requestOptions headers, timeout and retries of this call + * @return the page, once received + */ + public CompletableFuture list( + final String planId, final RequestOptions requestOptions) { + return list(planId, PlansVersionsListOptions.none(), requestOptions); + } + + /** + * List plan versions + * + * @param planId the {@code plan_id} path parameter + * @param options the optional parameters + * @param requestOptions headers, timeout and retries of this call + * @return the page, once received + */ + public CompletableFuture list( + final String planId, + final PlansVersionsListOptions options, + final RequestOptions requestOptions) { + return sync.exchangeList(planId, options, requestOptions) + .sendAsync() + .thenApply(response -> pageOfList(response, planId, options, requestOptions)); + } + + private PlansVersionsListAsyncPage pageOfList( + PlanVersionListResponse response, + final String planId, + final PlansVersionsListOptions options, + final RequestOptions requestOptions) { + List items = PlansVersions.itemsOfList(response); + Integer next = PlansVersions.nextOfList(response, items, options.page().orElse(0)); + return new PlansVersionsListAsyncPage( + response, + items, + next == null + ? null + : () -> + list( + planId, + options.toBuilder().page(next).build(), + requestOptions)); + } + + /** The operations, returning the status and headers along with the body. */ + public final class WithRawResponse { + private WithRawResponse() {} + + /** + * Set or replace the plan-level minimum commitment for a draft plan version. + * + * @param planVersionId the {@code plan_version_id} path parameter + * @param minimumCommitment the request body + * @return the status, headers and body, once received + */ + public CompletableFuture> updateMinimum( + final String planVersionId, final MinimumCommitment minimumCommitment) { + return updateMinimum(planVersionId, minimumCommitment, RequestOptions.none()); + } + + /** + * Set or replace the plan-level minimum commitment for a draft plan version. + * + * @param planVersionId the {@code plan_version_id} path parameter + * @param minimumCommitment the request body + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body, once received + */ + public CompletableFuture> updateMinimum( + final String planVersionId, + final MinimumCommitment minimumCommitment, + final RequestOptions requestOptions) { + return sync.exchangeUpdateMinimum(planVersionId, minimumCommitment, requestOptions) + .sendRawAsync(); + } + + /** + * Remove the plan-level minimum commitment for a draft plan version. + * + * @param planVersionId the {@code plan_version_id} path parameter + * @return the status, headers and body, once received + */ + public CompletableFuture> deleteMinimum(final String planVersionId) { + return deleteMinimum(planVersionId, RequestOptions.none()); + } + + /** + * Remove the plan-level minimum commitment for a draft plan version. + * + * @param planVersionId the {@code plan_version_id} path parameter + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body, once received + */ + public CompletableFuture> deleteMinimum( + final String planVersionId, final RequestOptions requestOptions) { + return sync.exchangeDeleteMinimum(planVersionId, requestOptions).sendRawAsync(); + } + + /** + * List plan versions + * + * @param planId the {@code plan_id} path parameter + * @return the status, headers and page, once received + */ + public CompletableFuture> list( + final String planId) { + return list(planId, PlansVersionsListOptions.none(), RequestOptions.none()); + } + + /** + * List plan versions + * + * @param planId the {@code plan_id} path parameter + * @param options the optional parameters + * @return the status, headers and page, once received + */ + public CompletableFuture> list( + final String planId, final PlansVersionsListOptions options) { + return list(planId, options, RequestOptions.none()); + } + + /** + * List plan versions + * + * @param planId the {@code plan_id} path parameter + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and page, once received + */ + public CompletableFuture> list( + final String planId, final RequestOptions requestOptions) { + return list(planId, PlansVersionsListOptions.none(), requestOptions); + } + + /** + * List plan versions + * + * @param planId the {@code plan_id} path parameter + * @param options the optional parameters + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and page, once received + */ + public CompletableFuture> list( + final String planId, + final PlansVersionsListOptions options, + final RequestOptions requestOptions) { + return sync.exchangeList(planId, options, requestOptions) + .sendRawAsync() + .thenApply( + response -> + new ApiResponse<>( + response.statusCode(), + response.headers(), + pageOfList( + response.body(), + planId, + options, + requestOptions))); + } + } +} diff --git a/src/main/java/com/meteroid/api/PlansListVersionsAsyncPage.java b/src/main/java/com/meteroid/api/PlansVersionsListAsyncPage.java similarity index 81% rename from src/main/java/com/meteroid/api/PlansListVersionsAsyncPage.java rename to src/main/java/com/meteroid/api/PlansVersionsListAsyncPage.java index 3265cb2..2742bcc 100644 --- a/src/main/java/com/meteroid/api/PlansListVersionsAsyncPage.java +++ b/src/main/java/com/meteroid/api/PlansVersionsListAsyncPage.java @@ -11,11 +11,11 @@ import java.util.function.Supplier; /** - * A page of {@link PlansAsync#listVersions}: the {@link PlanVersionSummary} items of one response, + * A page of {@link PlansVersionsAsync#list}: the {@link PlanVersionSummary} items of one response, * and the properties of its body, {@link PlanVersionListResponse}. */ -public final class PlansListVersionsAsyncPage - extends AsyncPage { +public final class PlansVersionsListAsyncPage + extends AsyncPage { private final PlanVersionListResponse body; /** @@ -25,10 +25,10 @@ public final class PlansListVersionsAsyncPage * @param items the items of the page * @param next fetches the next page, or null on the last page */ - public PlansListVersionsAsyncPage( + public PlansVersionsListAsyncPage( PlanVersionListResponse body, List items, - Supplier> next) { + Supplier> next) { super(items, next); this.body = body; } @@ -62,6 +62,6 @@ public PaginationResponse paginationMeta() { @Override public String toString() { - return "PlansListVersionsAsyncPage{body=" + body + ", hasNextPage=" + hasNextPage() + "}"; + return "PlansVersionsListAsyncPage{body=" + body + ", hasNextPage=" + hasNextPage() + "}"; } } diff --git a/src/main/java/com/meteroid/api/PlansListVersionsOptions.java b/src/main/java/com/meteroid/api/PlansVersionsListOptions.java similarity index 82% rename from src/main/java/com/meteroid/api/PlansListVersionsOptions.java rename to src/main/java/com/meteroid/api/PlansVersionsListOptions.java index 8c3cd41..3c59c94 100644 --- a/src/main/java/com/meteroid/api/PlansListVersionsOptions.java +++ b/src/main/java/com/meteroid/api/PlansVersionsListOptions.java @@ -4,12 +4,12 @@ import java.util.Objects; import java.util.Optional; -/** Optional parameters of {@code listVersions}, immutable: build them with {@link #builder()}. */ -public final class PlansListVersionsOptions { +/** Optional parameters of {@code list}, immutable: build them with {@link #builder()}. */ +public final class PlansVersionsListOptions { private final Integer page; private final Integer perPage; - private PlansListVersionsOptions(Builder builder) { + private PlansVersionsListOptions(Builder builder) { this.page = builder.page; this.perPage = builder.perPage; } @@ -28,7 +28,7 @@ public static Builder builder() { * * @return empty parameters */ - public static PlansListVersionsOptions none() { + public static PlansVersionsListOptions none() { return builder().build(); } @@ -70,7 +70,7 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } - PlansListVersionsOptions that = (PlansListVersionsOptions) o; + PlansVersionsListOptions that = (PlansVersionsListOptions) o; return Objects.equals(page, that.page) && Objects.equals(perPage, that.perPage); } @@ -81,10 +81,10 @@ public int hashCode() { @Override public String toString() { - return "PlansListVersionsOptions{" + "page=" + page + ", perPage=" + perPage + "}"; + return "PlansVersionsListOptions{" + "page=" + page + ", perPage=" + perPage + "}"; } - /** Builds {@link PlansListVersionsOptions}. */ + /** Builds {@link PlansVersionsListOptions}. */ public static final class Builder { private Integer page; private Integer perPage; @@ -118,8 +118,8 @@ public Builder perPage(Integer perPage) { * * @return immutable parameters */ - public PlansListVersionsOptions build() { - return new PlansListVersionsOptions(this); + public PlansVersionsListOptions build() { + return new PlansVersionsListOptions(this); } } } diff --git a/src/main/java/com/meteroid/api/PlansListVersionsPage.java b/src/main/java/com/meteroid/api/PlansVersionsListPage.java similarity index 82% rename from src/main/java/com/meteroid/api/PlansListVersionsPage.java rename to src/main/java/com/meteroid/api/PlansVersionsListPage.java index 27f341e..210517d 100644 --- a/src/main/java/com/meteroid/api/PlansListVersionsPage.java +++ b/src/main/java/com/meteroid/api/PlansVersionsListPage.java @@ -10,13 +10,13 @@ import java.util.function.Supplier; /** - * A page of {@link Plans#listVersions}: the {@link PlanVersionSummary} items of one response, and + * A page of {@link PlansVersions#list}: the {@link PlanVersionSummary} items of one response, and * the properties of its body, {@link PlanVersionListResponse}. * *

Iterating it yields every item from this page on, fetching the next pages as the iteration * goes. */ -public final class PlansListVersionsPage extends Page { +public final class PlansVersionsListPage extends Page { private final PlanVersionListResponse body; /** @@ -26,10 +26,10 @@ public final class PlansListVersionsPage extends Page items, - Supplier next) { + Supplier next) { super(items, next); this.body = body; } @@ -63,6 +63,6 @@ public PaginationResponse paginationMeta() { @Override public String toString() { - return "PlansListVersionsPage{body=" + body + ", hasNextPage=" + hasNextPage() + "}"; + return "PlansVersionsListPage{body=" + body + ", hasNextPage=" + hasNextPage() + "}"; } } diff --git a/src/main/java/com/meteroid/api/Products.java b/src/main/java/com/meteroid/api/Products.java index 651c6df..d799c09 100644 --- a/src/main/java/com/meteroid/api/Products.java +++ b/src/main/java/com/meteroid/api/Products.java @@ -5,12 +5,9 @@ import com.meteroid.RequestOptions; import com.meteroid.internal.MeteroidHttpClient; import com.meteroid.internal.Utils; -import com.meteroid.models.CreateEntitlementsRequest; import com.meteroid.models.CreateProductRequest; -import com.meteroid.models.EntitlementListResponse; import com.meteroid.models.Product; import com.meteroid.models.ProductListResponse; -import com.meteroid.models.ResolvedEntitlementListResponse; import com.meteroid.models.UpdateProductRequest; import okhttp3.HttpUrl; @@ -26,6 +23,8 @@ public final class Products { private final MeteroidHttpClient client; private final WithRawResponse withRawResponse; + private final ProductsEntitlements entitlements; + /** * The operations, sending through {@code client}. * @@ -34,6 +33,8 @@ public final class Products { public Products(MeteroidHttpClient client) { this.client = client; this.withRawResponse = new WithRawResponse(); + + this.entitlements = new ProductsEntitlements(client); } /** @@ -45,6 +46,15 @@ public WithRawResponse withRawResponse() { return withRawResponse; } + /** + * The {@code entitlements} operations. + * + * @return the operations + */ + public ProductsEntitlements entitlements() { + return entitlements; + } + /** * List products * @@ -300,106 +310,6 @@ MeteroidHttpClient.Exchange exchangeArchive( .returningNothing(); } - /** - * List product entitlements - * - * @param productId the {@code product_id} path parameter - * @return the response body - */ - public ResolvedEntitlementListResponse listEntitlements(final String productId) { - return listEntitlements(productId, RequestOptions.none()); - } - - /** - * List product entitlements - * - * @param productId the {@code product_id} path parameter - * @param requestOptions headers, timeout and retries of this call - * @return the response body - */ - public ResolvedEntitlementListResponse listEntitlements( - final String productId, final RequestOptions requestOptions) { - return exchangeListEntitlements(productId, requestOptions).send(); - } - - MeteroidHttpClient.Exchange exchangeListEntitlements( - final String productId, final RequestOptions requestOptions) { - Objects.requireNonNull(productId, "product_id"); - HttpUrl url = - client.newUrlBuilder() - .addPathSegments("api/v1/products") - .addPathSegment(Utils.pathSegment("product_id", productId)) - .addPathSegments("entitlements") - .build(); - return client.call("GET", url) - .errors(com.meteroid.models.RestErrorResponse.class, "401", "404", "429") - .options(requestOptions) - .returning(ResolvedEntitlementListResponse.class); - } - - /** - * Create product entitlements - * - *

A product has no entitlement rows of its own: its entitlements are the feature-level - * defaults of the features scoped to it, which is what GET on this path resolves. - * Every spec must therefore target a feature belonging to product_id. Features - * that already carry a default entitlement are skipped. - * - *

Specs are validated up front, but the writes are not atomic: each feature is written on - * its own, so a failure part-way can leave earlier specs committed. Retrying is safe. - * - * @param productId the {@code product_id} path parameter - * @param createEntitlementsRequest the request body - * @return the response body - */ - public EntitlementListResponse createEntitlement( - final String productId, final CreateEntitlementsRequest createEntitlementsRequest) { - return createEntitlement(productId, createEntitlementsRequest, RequestOptions.none()); - } - - /** - * Create product entitlements - * - *

A product has no entitlement rows of its own: its entitlements are the feature-level - * defaults of the features scoped to it, which is what GET on this path resolves. - * Every spec must therefore target a feature belonging to product_id. Features - * that already carry a default entitlement are skipped. - * - *

Specs are validated up front, but the writes are not atomic: each feature is written on - * its own, so a failure part-way can leave earlier specs committed. Retrying is safe. - * - * @param productId the {@code product_id} path parameter - * @param createEntitlementsRequest the request body - * @param requestOptions headers, timeout and retries of this call - * @return the response body - */ - public EntitlementListResponse createEntitlement( - final String productId, - final CreateEntitlementsRequest createEntitlementsRequest, - final RequestOptions requestOptions) { - return exchangeCreateEntitlement(productId, createEntitlementsRequest, requestOptions) - .send(); - } - - MeteroidHttpClient.Exchange exchangeCreateEntitlement( - final String productId, - final CreateEntitlementsRequest createEntitlementsRequest, - final RequestOptions requestOptions) { - Objects.requireNonNull(productId, "product_id"); - Objects.requireNonNull(createEntitlementsRequest, "body"); - HttpUrl url = - client.newUrlBuilder() - .addPathSegments("api/v1/products") - .addPathSegment(Utils.pathSegment("product_id", productId)) - .addPathSegments("entitlements") - .build(); - return client.call("POST", url) - .json(createEntitlementsRequest) - .errors(com.meteroid.models.RestErrorResponse.class, "400", "401", "404", "429") - .options(requestOptions) - .returning(EntitlementListResponse.class); - } - /** * Unarchive a product * @@ -438,6 +348,15 @@ MeteroidHttpClient.Exchange exchangeUnarchive( public final class WithRawResponse { private WithRawResponse() {} + /** + * The {@code entitlements} operations. + * + * @return the operations + */ + public ProductsEntitlements.WithRawResponse entitlements() { + return Products.this.entitlements.withRawResponse(); + } + /** * List products * @@ -584,74 +503,6 @@ public ApiResponse archive( return Products.this.exchangeArchive(productId, requestOptions).sendRaw(); } - /** - * List product entitlements - * - * @param productId the {@code product_id} path parameter - * @return the status, headers and body - */ - public ApiResponse listEntitlements( - final String productId) { - return listEntitlements(productId, RequestOptions.none()); - } - - /** - * List product entitlements - * - * @param productId the {@code product_id} path parameter - * @param requestOptions headers, timeout and retries of this call - * @return the status, headers and body - */ - public ApiResponse listEntitlements( - final String productId, final RequestOptions requestOptions) { - return Products.this.exchangeListEntitlements(productId, requestOptions).sendRaw(); - } - - /** - * Create product entitlements - * - *

A product has no entitlement rows of its own: its entitlements are the feature-level - * defaults of the features scoped to it, which is what GET on this path - * resolves. Every spec must therefore target a feature belonging to product_id - * . Features that already carry a default entitlement are skipped. - * - *

Specs are validated up front, but the writes are not atomic: each feature is written - * on its own, so a failure part-way can leave earlier specs committed. Retrying is safe. - * - * @param productId the {@code product_id} path parameter - * @param createEntitlementsRequest the request body - * @return the status, headers and body - */ - public ApiResponse createEntitlement( - final String productId, final CreateEntitlementsRequest createEntitlementsRequest) { - return createEntitlement(productId, createEntitlementsRequest, RequestOptions.none()); - } - - /** - * Create product entitlements - * - *

A product has no entitlement rows of its own: its entitlements are the feature-level - * defaults of the features scoped to it, which is what GET on this path - * resolves. Every spec must therefore target a feature belonging to product_id - * . Features that already carry a default entitlement are skipped. - * - *

Specs are validated up front, but the writes are not atomic: each feature is written - * on its own, so a failure part-way can leave earlier specs committed. Retrying is safe. - * - * @param productId the {@code product_id} path parameter - * @param createEntitlementsRequest the request body - * @param requestOptions headers, timeout and retries of this call - * @return the status, headers and body - */ - public ApiResponse createEntitlement( - final String productId, - final CreateEntitlementsRequest createEntitlementsRequest, - final RequestOptions requestOptions) { - return Products.this - .exchangeCreateEntitlement(productId, createEntitlementsRequest, requestOptions) - .sendRaw(); - } - /** * Unarchive a product * diff --git a/src/main/java/com/meteroid/api/ProductsAsync.java b/src/main/java/com/meteroid/api/ProductsAsync.java index a0b8f6d..e11c0f7 100644 --- a/src/main/java/com/meteroid/api/ProductsAsync.java +++ b/src/main/java/com/meteroid/api/ProductsAsync.java @@ -3,12 +3,9 @@ import com.meteroid.ApiResponse; import com.meteroid.RequestOptions; -import com.meteroid.models.CreateEntitlementsRequest; import com.meteroid.models.CreateProductRequest; -import com.meteroid.models.EntitlementListResponse; import com.meteroid.models.Product; import com.meteroid.models.ProductListResponse; -import com.meteroid.models.ResolvedEntitlementListResponse; import com.meteroid.models.UpdateProductRequest; import java.util.List; @@ -22,6 +19,8 @@ public final class ProductsAsync { private final Products sync; private final WithRawResponse withRawResponse; + private final ProductsEntitlementsAsync entitlements; + /** * The operations, sending through {@code sync}. * @@ -30,6 +29,8 @@ public final class ProductsAsync { public ProductsAsync(Products sync) { this.sync = sync; this.withRawResponse = new WithRawResponse(); + + this.entitlements = new ProductsEntitlementsAsync(sync.entitlements()); } /** @@ -41,6 +42,15 @@ public WithRawResponse withRawResponse() { return withRawResponse; } + /** + * The {@code entitlements} operations. + * + * @return the operations + */ + public ProductsEntitlementsAsync entitlements() { + return entitlements; + } + /** * List products * @@ -195,73 +205,6 @@ public CompletableFuture archive( return sync.exchangeArchive(productId, requestOptions).sendAsync(); } - /** - * List product entitlements - * - * @param productId the {@code product_id} path parameter - * @return the response body, once received - */ - public CompletableFuture listEntitlements( - final String productId) { - return listEntitlements(productId, RequestOptions.none()); - } - - /** - * List product entitlements - * - * @param productId the {@code product_id} path parameter - * @param requestOptions headers, timeout and retries of this call - * @return the response body, once received - */ - public CompletableFuture listEntitlements( - final String productId, final RequestOptions requestOptions) { - return sync.exchangeListEntitlements(productId, requestOptions).sendAsync(); - } - - /** - * Create product entitlements - * - *

A product has no entitlement rows of its own: its entitlements are the feature-level - * defaults of the features scoped to it, which is what GET on this path resolves. - * Every spec must therefore target a feature belonging to product_id. Features - * that already carry a default entitlement are skipped. - * - *

Specs are validated up front, but the writes are not atomic: each feature is written on - * its own, so a failure part-way can leave earlier specs committed. Retrying is safe. - * - * @param productId the {@code product_id} path parameter - * @param createEntitlementsRequest the request body - * @return the response body, once received - */ - public CompletableFuture createEntitlement( - final String productId, final CreateEntitlementsRequest createEntitlementsRequest) { - return createEntitlement(productId, createEntitlementsRequest, RequestOptions.none()); - } - - /** - * Create product entitlements - * - *

A product has no entitlement rows of its own: its entitlements are the feature-level - * defaults of the features scoped to it, which is what GET on this path resolves. - * Every spec must therefore target a feature belonging to product_id. Features - * that already carry a default entitlement are skipped. - * - *

Specs are validated up front, but the writes are not atomic: each feature is written on - * its own, so a failure part-way can leave earlier specs committed. Retrying is safe. - * - * @param productId the {@code product_id} path parameter - * @param createEntitlementsRequest the request body - * @param requestOptions headers, timeout and retries of this call - * @return the response body, once received - */ - public CompletableFuture createEntitlement( - final String productId, - final CreateEntitlementsRequest createEntitlementsRequest, - final RequestOptions requestOptions) { - return sync.exchangeCreateEntitlement(productId, createEntitlementsRequest, requestOptions) - .sendAsync(); - } - /** * Unarchive a product * @@ -288,6 +231,15 @@ public CompletableFuture unarchive( public final class WithRawResponse { private WithRawResponse() {} + /** + * The {@code entitlements} operations. + * + * @return the operations + */ + public ProductsEntitlementsAsync.WithRawResponse entitlements() { + return ProductsAsync.this.entitlements.withRawResponse(); + } + /** * List products * @@ -438,74 +390,6 @@ public CompletableFuture> archive( return sync.exchangeArchive(productId, requestOptions).sendRawAsync(); } - /** - * List product entitlements - * - * @param productId the {@code product_id} path parameter - * @return the status, headers and body, once received - */ - public CompletableFuture> listEntitlements( - final String productId) { - return listEntitlements(productId, RequestOptions.none()); - } - - /** - * List product entitlements - * - * @param productId the {@code product_id} path parameter - * @param requestOptions headers, timeout and retries of this call - * @return the status, headers and body, once received - */ - public CompletableFuture> listEntitlements( - final String productId, final RequestOptions requestOptions) { - return sync.exchangeListEntitlements(productId, requestOptions).sendRawAsync(); - } - - /** - * Create product entitlements - * - *

A product has no entitlement rows of its own: its entitlements are the feature-level - * defaults of the features scoped to it, which is what GET on this path - * resolves. Every spec must therefore target a feature belonging to product_id - * . Features that already carry a default entitlement are skipped. - * - *

Specs are validated up front, but the writes are not atomic: each feature is written - * on its own, so a failure part-way can leave earlier specs committed. Retrying is safe. - * - * @param productId the {@code product_id} path parameter - * @param createEntitlementsRequest the request body - * @return the status, headers and body, once received - */ - public CompletableFuture> createEntitlement( - final String productId, final CreateEntitlementsRequest createEntitlementsRequest) { - return createEntitlement(productId, createEntitlementsRequest, RequestOptions.none()); - } - - /** - * Create product entitlements - * - *

A product has no entitlement rows of its own: its entitlements are the feature-level - * defaults of the features scoped to it, which is what GET on this path - * resolves. Every spec must therefore target a feature belonging to product_id - * . Features that already carry a default entitlement are skipped. - * - *

Specs are validated up front, but the writes are not atomic: each feature is written - * on its own, so a failure part-way can leave earlier specs committed. Retrying is safe. - * - * @param productId the {@code product_id} path parameter - * @param createEntitlementsRequest the request body - * @param requestOptions headers, timeout and retries of this call - * @return the status, headers and body, once received - */ - public CompletableFuture> createEntitlement( - final String productId, - final CreateEntitlementsRequest createEntitlementsRequest, - final RequestOptions requestOptions) { - return sync.exchangeCreateEntitlement( - productId, createEntitlementsRequest, requestOptions) - .sendRawAsync(); - } - /** * Unarchive a product * diff --git a/src/main/java/com/meteroid/api/ProductsEntitlements.java b/src/main/java/com/meteroid/api/ProductsEntitlements.java new file mode 100644 index 0000000..e1a9edb --- /dev/null +++ b/src/main/java/com/meteroid/api/ProductsEntitlements.java @@ -0,0 +1,213 @@ +// this file is @generated +package com.meteroid.api; + +import com.meteroid.ApiResponse; +import com.meteroid.RequestOptions; +import com.meteroid.internal.MeteroidHttpClient; +import com.meteroid.internal.Utils; +import com.meteroid.models.CreateEntitlementsRequest; +import com.meteroid.models.EntitlementListResponse; +import com.meteroid.models.ResolvedEntitlementListResponse; + +import okhttp3.HttpUrl; + +import java.util.Objects; + +/** + * The {@code products.entitlements} operations, blocking. {@link #withRawResponse()} has the same + * methods returning the status and headers along with the body. + */ +public final class ProductsEntitlements { + private final MeteroidHttpClient client; + private final WithRawResponse withRawResponse; + + /** + * The operations, sending through {@code client}. + * + * @param client the HTTP client of the SDK + */ + public ProductsEntitlements(MeteroidHttpClient client) { + this.client = client; + this.withRawResponse = new WithRawResponse(); + } + + /** + * The same operations, returning the status and headers along with the body. + * + * @return the operations + */ + public WithRawResponse withRawResponse() { + return withRawResponse; + } + + /** + * List product entitlements + * + * @param productId the {@code product_id} path parameter + * @return the response body + */ + public ResolvedEntitlementListResponse list(final String productId) { + return list(productId, RequestOptions.none()); + } + + /** + * List product entitlements + * + * @param productId the {@code product_id} path parameter + * @param requestOptions headers, timeout and retries of this call + * @return the response body + */ + public ResolvedEntitlementListResponse list( + final String productId, final RequestOptions requestOptions) { + return exchangeList(productId, requestOptions).send(); + } + + MeteroidHttpClient.Exchange exchangeList( + final String productId, final RequestOptions requestOptions) { + Objects.requireNonNull(productId, "product_id"); + HttpUrl url = + client.newUrlBuilder() + .addPathSegments("api/v1/products") + .addPathSegment(Utils.pathSegment("product_id", productId)) + .addPathSegments("entitlements") + .build(); + return client.call("GET", url) + .errors(com.meteroid.models.RestErrorResponse.class, "401", "404", "429") + .options(requestOptions) + .returning(ResolvedEntitlementListResponse.class); + } + + /** + * Create product entitlements + * + *

A product has no entitlement rows of its own: its entitlements are the feature-level + * defaults of the features scoped to it, which is what GET on this path resolves. + * Every spec must therefore target a feature belonging to product_id. Features + * that already carry a default entitlement are skipped. + * + *

Specs are validated up front, but the writes are not atomic: each feature is written on + * its own, so a failure part-way can leave earlier specs committed. Retrying is safe. + * + * @param productId the {@code product_id} path parameter + * @param createEntitlementsRequest the request body + * @return the response body + */ + public EntitlementListResponse create( + final String productId, final CreateEntitlementsRequest createEntitlementsRequest) { + return create(productId, createEntitlementsRequest, RequestOptions.none()); + } + + /** + * Create product entitlements + * + *

A product has no entitlement rows of its own: its entitlements are the feature-level + * defaults of the features scoped to it, which is what GET on this path resolves. + * Every spec must therefore target a feature belonging to product_id. Features + * that already carry a default entitlement are skipped. + * + *

Specs are validated up front, but the writes are not atomic: each feature is written on + * its own, so a failure part-way can leave earlier specs committed. Retrying is safe. + * + * @param productId the {@code product_id} path parameter + * @param createEntitlementsRequest the request body + * @param requestOptions headers, timeout and retries of this call + * @return the response body + */ + public EntitlementListResponse create( + final String productId, + final CreateEntitlementsRequest createEntitlementsRequest, + final RequestOptions requestOptions) { + return exchangeCreate(productId, createEntitlementsRequest, requestOptions).send(); + } + + MeteroidHttpClient.Exchange exchangeCreate( + final String productId, + final CreateEntitlementsRequest createEntitlementsRequest, + final RequestOptions requestOptions) { + Objects.requireNonNull(productId, "product_id"); + Objects.requireNonNull(createEntitlementsRequest, "body"); + HttpUrl url = + client.newUrlBuilder() + .addPathSegments("api/v1/products") + .addPathSegment(Utils.pathSegment("product_id", productId)) + .addPathSegments("entitlements") + .build(); + return client.call("POST", url) + .json(createEntitlementsRequest) + .errors(com.meteroid.models.RestErrorResponse.class, "400", "401", "404", "429") + .options(requestOptions) + .returning(EntitlementListResponse.class); + } + + /** The operations, returning the status and headers along with the body. */ + public final class WithRawResponse { + private WithRawResponse() {} + + /** + * List product entitlements + * + * @param productId the {@code product_id} path parameter + * @return the status, headers and body + */ + public ApiResponse list(final String productId) { + return list(productId, RequestOptions.none()); + } + + /** + * List product entitlements + * + * @param productId the {@code product_id} path parameter + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body + */ + public ApiResponse list( + final String productId, final RequestOptions requestOptions) { + return ProductsEntitlements.this.exchangeList(productId, requestOptions).sendRaw(); + } + + /** + * Create product entitlements + * + *

A product has no entitlement rows of its own: its entitlements are the feature-level + * defaults of the features scoped to it, which is what GET on this path + * resolves. Every spec must therefore target a feature belonging to product_id + * . Features that already carry a default entitlement are skipped. + * + *

Specs are validated up front, but the writes are not atomic: each feature is written + * on its own, so a failure part-way can leave earlier specs committed. Retrying is safe. + * + * @param productId the {@code product_id} path parameter + * @param createEntitlementsRequest the request body + * @return the status, headers and body + */ + public ApiResponse create( + final String productId, final CreateEntitlementsRequest createEntitlementsRequest) { + return create(productId, createEntitlementsRequest, RequestOptions.none()); + } + + /** + * Create product entitlements + * + *

A product has no entitlement rows of its own: its entitlements are the feature-level + * defaults of the features scoped to it, which is what GET on this path + * resolves. Every spec must therefore target a feature belonging to product_id + * . Features that already carry a default entitlement are skipped. + * + *

Specs are validated up front, but the writes are not atomic: each feature is written + * on its own, so a failure part-way can leave earlier specs committed. Retrying is safe. + * + * @param productId the {@code product_id} path parameter + * @param createEntitlementsRequest the request body + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body + */ + public ApiResponse create( + final String productId, + final CreateEntitlementsRequest createEntitlementsRequest, + final RequestOptions requestOptions) { + return ProductsEntitlements.this + .exchangeCreate(productId, createEntitlementsRequest, requestOptions) + .sendRaw(); + } + } +} diff --git a/src/main/java/com/meteroid/api/ProductsEntitlementsAsync.java b/src/main/java/com/meteroid/api/ProductsEntitlementsAsync.java new file mode 100644 index 0000000..f840042 --- /dev/null +++ b/src/main/java/com/meteroid/api/ProductsEntitlementsAsync.java @@ -0,0 +1,176 @@ +// this file is @generated +package com.meteroid.api; + +import com.meteroid.ApiResponse; +import com.meteroid.RequestOptions; +import com.meteroid.models.CreateEntitlementsRequest; +import com.meteroid.models.EntitlementListResponse; +import com.meteroid.models.ResolvedEntitlementListResponse; + +import java.util.concurrent.CompletableFuture; + +/** + * The {@code products.entitlements} operations, without blocking: each method returns a {@link + * CompletableFuture}. Obtained from {@code client.async()}. + */ +public final class ProductsEntitlementsAsync { + private final ProductsEntitlements sync; + private final WithRawResponse withRawResponse; + + /** + * The operations, sending through {@code sync}. + * + * @param sync the blocking operations + */ + public ProductsEntitlementsAsync(ProductsEntitlements sync) { + this.sync = sync; + this.withRawResponse = new WithRawResponse(); + } + + /** + * The same operations, returning the status and headers along with the body. + * + * @return the operations + */ + public WithRawResponse withRawResponse() { + return withRawResponse; + } + + /** + * List product entitlements + * + * @param productId the {@code product_id} path parameter + * @return the response body, once received + */ + public CompletableFuture list(final String productId) { + return list(productId, RequestOptions.none()); + } + + /** + * List product entitlements + * + * @param productId the {@code product_id} path parameter + * @param requestOptions headers, timeout and retries of this call + * @return the response body, once received + */ + public CompletableFuture list( + final String productId, final RequestOptions requestOptions) { + return sync.exchangeList(productId, requestOptions).sendAsync(); + } + + /** + * Create product entitlements + * + *

A product has no entitlement rows of its own: its entitlements are the feature-level + * defaults of the features scoped to it, which is what GET on this path resolves. + * Every spec must therefore target a feature belonging to product_id. Features + * that already carry a default entitlement are skipped. + * + *

Specs are validated up front, but the writes are not atomic: each feature is written on + * its own, so a failure part-way can leave earlier specs committed. Retrying is safe. + * + * @param productId the {@code product_id} path parameter + * @param createEntitlementsRequest the request body + * @return the response body, once received + */ + public CompletableFuture create( + final String productId, final CreateEntitlementsRequest createEntitlementsRequest) { + return create(productId, createEntitlementsRequest, RequestOptions.none()); + } + + /** + * Create product entitlements + * + *

A product has no entitlement rows of its own: its entitlements are the feature-level + * defaults of the features scoped to it, which is what GET on this path resolves. + * Every spec must therefore target a feature belonging to product_id. Features + * that already carry a default entitlement are skipped. + * + *

Specs are validated up front, but the writes are not atomic: each feature is written on + * its own, so a failure part-way can leave earlier specs committed. Retrying is safe. + * + * @param productId the {@code product_id} path parameter + * @param createEntitlementsRequest the request body + * @param requestOptions headers, timeout and retries of this call + * @return the response body, once received + */ + public CompletableFuture create( + final String productId, + final CreateEntitlementsRequest createEntitlementsRequest, + final RequestOptions requestOptions) { + return sync.exchangeCreate(productId, createEntitlementsRequest, requestOptions) + .sendAsync(); + } + + /** The operations, returning the status and headers along with the body. */ + public final class WithRawResponse { + private WithRawResponse() {} + + /** + * List product entitlements + * + * @param productId the {@code product_id} path parameter + * @return the status, headers and body, once received + */ + public CompletableFuture> list( + final String productId) { + return list(productId, RequestOptions.none()); + } + + /** + * List product entitlements + * + * @param productId the {@code product_id} path parameter + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body, once received + */ + public CompletableFuture> list( + final String productId, final RequestOptions requestOptions) { + return sync.exchangeList(productId, requestOptions).sendRawAsync(); + } + + /** + * Create product entitlements + * + *

A product has no entitlement rows of its own: its entitlements are the feature-level + * defaults of the features scoped to it, which is what GET on this path + * resolves. Every spec must therefore target a feature belonging to product_id + * . Features that already carry a default entitlement are skipped. + * + *

Specs are validated up front, but the writes are not atomic: each feature is written + * on its own, so a failure part-way can leave earlier specs committed. Retrying is safe. + * + * @param productId the {@code product_id} path parameter + * @param createEntitlementsRequest the request body + * @return the status, headers and body, once received + */ + public CompletableFuture> create( + final String productId, final CreateEntitlementsRequest createEntitlementsRequest) { + return create(productId, createEntitlementsRequest, RequestOptions.none()); + } + + /** + * Create product entitlements + * + *

A product has no entitlement rows of its own: its entitlements are the feature-level + * defaults of the features scoped to it, which is what GET on this path + * resolves. Every spec must therefore target a feature belonging to product_id + * . Features that already carry a default entitlement are skipped. + * + *

Specs are validated up front, but the writes are not atomic: each feature is written + * on its own, so a failure part-way can leave earlier specs committed. Retrying is safe. + * + * @param productId the {@code product_id} path parameter + * @param createEntitlementsRequest the request body + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body, once received + */ + public CompletableFuture> create( + final String productId, + final CreateEntitlementsRequest createEntitlementsRequest, + final RequestOptions requestOptions) { + return sync.exchangeCreate(productId, createEntitlementsRequest, requestOptions) + .sendRawAsync(); + } + } +} diff --git a/src/test/java/com/meteroid/api/AddOnsEntitlementsTest.java b/src/test/java/com/meteroid/api/AddOnsEntitlementsTest.java new file mode 100644 index 0000000..939cf22 --- /dev/null +++ b/src/test/java/com/meteroid/api/AddOnsEntitlementsTest.java @@ -0,0 +1,40 @@ +// this file is @generated +package com.meteroid.api; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.junit.jupiter.api.Test; + +import java.util.List; + +class AddOnsEntitlementsTest { + + @Test + void list() throws Exception { + PerseidMock mock = + new PerseidMock( + 200, + "application/json", + "{\"data\":[{\"feature\":{\"code\":\"sample\",\"id\":\"feature_id_53\",\"name\":\"sample\"},\"value\":{\"type\":\"BOOLEAN\",\"enabled\":false}}]}"); + mock.client.addOns().entitlements().list("addon_id"); + assertEquals(List.of("GET /api/v1/addons/addon_id/entitlements"), mock.requests); + } + + @Test + void create() throws Exception { + PerseidMock mock = + new PerseidMock( + 200, + "application/json", + "{\"data\":[{\"created_at\":\"2023-12-31T23:59:59.999-05:30\",\"feature_id\":\"feature_id_39\",\"id\":\"entitlement_id_2\",\"updated_at\":\"2024-03-15T10:30:45.123+02:00\",\"value\":{\"type\":\"BOOLEAN\",\"enabled\":false}}]}"); + mock.client + .addOns() + .entitlements() + .create( + "addon_id", + PerseidMock.decode( + com.meteroid.models.CreateEntitlementsRequest.class, + "{\"entitlements\":[{\"feature_id\":\"feature_id_9\",\"value\":{\"type\":\"BOOLEAN\",\"enabled\":false}}]}")); + assertEquals(List.of("POST /api/v1/addons/addon_id/entitlements"), mock.requests); + } +} diff --git a/src/test/java/com/meteroid/api/AddOnsTest.java b/src/test/java/com/meteroid/api/AddOnsTest.java index d8ca736..3d31f3e 100644 --- a/src/test/java/com/meteroid/api/AddOnsTest.java +++ b/src/test/java/com/meteroid/api/AddOnsTest.java @@ -69,34 +69,6 @@ void archive() throws Exception { assertEquals(List.of("POST /api/v1/addons/addon_id/archive"), mock.requests); } - @Test - void listEntitlements() throws Exception { - PerseidMock mock = - new PerseidMock( - 200, - "application/json", - "{\"data\":[{\"feature\":{\"code\":\"sample\",\"id\":\"feature_id_53\",\"name\":\"sample\"},\"value\":{\"type\":\"BOOLEAN\",\"enabled\":false}}]}"); - mock.client.addOns().listEntitlements("addon_id"); - assertEquals(List.of("GET /api/v1/addons/addon_id/entitlements"), mock.requests); - } - - @Test - void createEntitlement() throws Exception { - PerseidMock mock = - new PerseidMock( - 200, - "application/json", - "{\"data\":[{\"created_at\":\"2023-12-31T23:59:59.999-05:30\",\"feature_id\":\"feature_id_39\",\"id\":\"entitlement_id_2\",\"updated_at\":\"2024-03-15T10:30:45.123+02:00\",\"value\":{\"type\":\"BOOLEAN\",\"enabled\":false}}]}"); - mock.client - .addOns() - .createEntitlement( - "addon_id", - PerseidMock.decode( - com.meteroid.models.CreateEntitlementsRequest.class, - "{\"entitlements\":[{\"feature_id\":\"feature_id_9\",\"value\":{\"type\":\"BOOLEAN\",\"enabled\":false}}]}")); - assertEquals(List.of("POST /api/v1/addons/addon_id/entitlements"), mock.requests); - } - @Test void unarchive() throws Exception { PerseidMock mock = new PerseidMock(204, null, ""); diff --git a/src/test/java/com/meteroid/api/PlansTest.java b/src/test/java/com/meteroid/api/PlansTest.java index 510b67d..ec31ff3 100644 --- a/src/test/java/com/meteroid/api/PlansTest.java +++ b/src/test/java/com/meteroid/api/PlansTest.java @@ -66,31 +66,6 @@ void create() throws Exception { assertEquals(List.of("POST /api/v1/plans"), mock.requests); } - @Test - void updateVersionMinimum() throws Exception { - PerseidMock mock = - new PerseidMock( - 200, - "application/json", - "{\"amount\":\"sample\",\"scope\":{\"type\":\"all_components\"}}"); - mock.client - .plans() - .updateVersionMinimum( - "plan_version_id", - PerseidMock.decode( - com.meteroid.models.MinimumCommitment.class, - "{\"amount\":\"sample\",\"scope\":{\"type\":\"all_components\"}}")); - assertEquals(List.of("PUT /api/v1/plans/versions/plan_version_id/minimum"), mock.requests); - } - - @Test - void deleteVersionMinimum() throws Exception { - PerseidMock mock = new PerseidMock(204, null, ""); - mock.client.plans().deleteVersionMinimum("plan_version_id"); - assertEquals( - List.of("DELETE /api/v1/plans/versions/plan_version_id/minimum"), mock.requests); - } - @Test void retrieve() throws Exception { PerseidMock mock = @@ -158,15 +133,4 @@ void unarchive() throws Exception { mock.client.plans().unarchive("plan_id"); assertEquals(List.of("POST /api/v1/plans/plan_id/unarchive"), mock.requests); } - - @Test - void listVersions() throws Exception { - PerseidMock mock = - new PerseidMock( - 200, - "application/json", - "{\"data\":[{\"created_at\":\"2023-12-31T23:59:59.999-05:30\",\"currency\":\"sample\",\"id\":\"plan_version_id_2\",\"is_draft\":true,\"version\":-2147483648}],\"pagination_meta\":{\"page\":-123456789,\"per_page\":-123456789,\"total_items\":-9007199254740993,\"total_pages\":123456789}}"); - mock.client.plans().listVersions("plan_id"); - assertEquals(List.of("GET /api/v1/plans/plan_id/versions"), mock.requests); - } } diff --git a/src/test/java/com/meteroid/api/PlansVersionsTest.java b/src/test/java/com/meteroid/api/PlansVersionsTest.java new file mode 100644 index 0000000..6ab5697 --- /dev/null +++ b/src/test/java/com/meteroid/api/PlansVersionsTest.java @@ -0,0 +1,48 @@ +// this file is @generated +package com.meteroid.api; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.junit.jupiter.api.Test; + +import java.util.List; + +class PlansVersionsTest { + + @Test + void updateMinimum() throws Exception { + PerseidMock mock = + new PerseidMock( + 200, + "application/json", + "{\"amount\":\"sample\",\"scope\":{\"type\":\"all_components\"}}"); + mock.client + .plans() + .versions() + .updateMinimum( + "plan_version_id", + PerseidMock.decode( + com.meteroid.models.MinimumCommitment.class, + "{\"amount\":\"sample\",\"scope\":{\"type\":\"all_components\"}}")); + assertEquals(List.of("PUT /api/v1/plans/versions/plan_version_id/minimum"), mock.requests); + } + + @Test + void deleteMinimum() throws Exception { + PerseidMock mock = new PerseidMock(204, null, ""); + mock.client.plans().versions().deleteMinimum("plan_version_id"); + assertEquals( + List.of("DELETE /api/v1/plans/versions/plan_version_id/minimum"), mock.requests); + } + + @Test + void list() throws Exception { + PerseidMock mock = + new PerseidMock( + 200, + "application/json", + "{\"data\":[{\"created_at\":\"2023-12-31T23:59:59.999-05:30\",\"currency\":\"sample\",\"id\":\"plan_version_id_2\",\"is_draft\":true,\"version\":-2147483648}],\"pagination_meta\":{\"page\":-123456789,\"per_page\":-123456789,\"total_items\":-9007199254740993,\"total_pages\":123456789}}"); + mock.client.plans().versions().list("plan_id"); + assertEquals(List.of("GET /api/v1/plans/plan_id/versions"), mock.requests); + } +} diff --git a/src/test/java/com/meteroid/api/ProductsEntitlementsTest.java b/src/test/java/com/meteroid/api/ProductsEntitlementsTest.java new file mode 100644 index 0000000..b4486f2 --- /dev/null +++ b/src/test/java/com/meteroid/api/ProductsEntitlementsTest.java @@ -0,0 +1,40 @@ +// this file is @generated +package com.meteroid.api; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.junit.jupiter.api.Test; + +import java.util.List; + +class ProductsEntitlementsTest { + + @Test + void list() throws Exception { + PerseidMock mock = + new PerseidMock( + 200, + "application/json", + "{\"data\":[{\"feature\":{\"code\":\"sample\",\"id\":\"feature_id_53\",\"name\":\"sample\"},\"value\":{\"type\":\"BOOLEAN\",\"enabled\":false}}]}"); + mock.client.products().entitlements().list("product_id"); + assertEquals(List.of("GET /api/v1/products/product_id/entitlements"), mock.requests); + } + + @Test + void create() throws Exception { + PerseidMock mock = + new PerseidMock( + 200, + "application/json", + "{\"data\":[{\"created_at\":\"2023-12-31T23:59:59.999-05:30\",\"feature_id\":\"feature_id_39\",\"id\":\"entitlement_id_2\",\"updated_at\":\"2024-03-15T10:30:45.123+02:00\",\"value\":{\"type\":\"BOOLEAN\",\"enabled\":false}}]}"); + mock.client + .products() + .entitlements() + .create( + "product_id", + PerseidMock.decode( + com.meteroid.models.CreateEntitlementsRequest.class, + "{\"entitlements\":[{\"feature_id\":\"feature_id_9\",\"value\":{\"type\":\"BOOLEAN\",\"enabled\":false}}]}")); + assertEquals(List.of("POST /api/v1/products/product_id/entitlements"), mock.requests); + } +} diff --git a/src/test/java/com/meteroid/api/ProductsTest.java b/src/test/java/com/meteroid/api/ProductsTest.java index 7eae272..39f1df2 100644 --- a/src/test/java/com/meteroid/api/ProductsTest.java +++ b/src/test/java/com/meteroid/api/ProductsTest.java @@ -69,34 +69,6 @@ void archive() throws Exception { assertEquals(List.of("POST /api/v1/products/product_id/archive"), mock.requests); } - @Test - void listEntitlements() throws Exception { - PerseidMock mock = - new PerseidMock( - 200, - "application/json", - "{\"data\":[{\"feature\":{\"code\":\"sample\",\"id\":\"feature_id_53\",\"name\":\"sample\"},\"value\":{\"type\":\"BOOLEAN\",\"enabled\":false}}]}"); - mock.client.products().listEntitlements("product_id"); - assertEquals(List.of("GET /api/v1/products/product_id/entitlements"), mock.requests); - } - - @Test - void createEntitlement() throws Exception { - PerseidMock mock = - new PerseidMock( - 200, - "application/json", - "{\"data\":[{\"created_at\":\"2023-12-31T23:59:59.999-05:30\",\"feature_id\":\"feature_id_39\",\"id\":\"entitlement_id_2\",\"updated_at\":\"2024-03-15T10:30:45.123+02:00\",\"value\":{\"type\":\"BOOLEAN\",\"enabled\":false}}]}"); - mock.client - .products() - .createEntitlement( - "product_id", - PerseidMock.decode( - com.meteroid.models.CreateEntitlementsRequest.class, - "{\"entitlements\":[{\"feature_id\":\"feature_id_9\",\"value\":{\"type\":\"BOOLEAN\",\"enabled\":false}}]}")); - assertEquals(List.of("POST /api/v1/products/product_id/entitlements"), mock.requests); - } - @Test void unarchive() throws Exception { PerseidMock mock = new PerseidMock(204, null, "");