diff --git a/api.md b/api.md index c7649db..1494c41 100644 --- a/api.md +++ b/api.md @@ -14,7 +14,7 @@ item from that page on, and `pages()` every page, fetching the next ones on dema the response body as received. The async client's pages have `nextPage()`, `forEach(...)`, `forEachPage(...)` and `toList()`, returning `CompletableFuture`s. -[Add ons](#add-ons) · [Add ons entitlements](#add-ons-entitlements) · [Batch jobs](#batch-jobs) · [Checkout sessions](#checkout-sessions) · [Connect](#connect) · [Coupons](#coupons) · [Credit notes](#credit-notes) · [Custom properties](#custom-properties) · [Customers](#customers) · [Entitlements](#entitlements) · [Events](#events) · [Features](#features) · [Invoices](#invoices) · [Metrics](#metrics) · [Oauth](#oauth) · [Oauth apps](#oauth-apps) · [Plans](#plans) · [Plans versions](#plans-versions) · [Product families](#product-families) · [Products](#products) · [Products entitlements](#products-entitlements) · [Subscriptions](#subscriptions) · [Usage](#usage) +[Add ons](#add-ons) · [Add ons entitlements](#add-ons-entitlements) · [Batch jobs](#batch-jobs) · [Checkout sessions](#checkout-sessions) · [Connect](#connect) · [Coupons](#coupons) · [Credit notes](#credit-notes) · [Custom properties](#custom-properties) · [Customers](#customers) · [Entitlements](#entitlements) · [Events](#events) · [Features](#features) · [Invoices](#invoices) · [Metrics](#metrics) · [Oauth](#oauth) · [Oauth apps](#oauth-apps) · [Plans](#plans) · [Plans versions](#plans-versions) · [Product families](#product-families) · [Products](#products) · [Products entitlements](#products-entitlements) · [Subscriptions](#subscriptions) · [Usage](#usage) · [Webhook endpoints](#webhook-endpoints) · [Webhook endpoints endpoints](#webhook-endpoints-endpoints) ## Add ons @@ -287,3 +287,26 @@ the response body as received. The async client's pages have `nextPage()`, `forE | `UsageResponse client.usage().retrieveCustomer(String customerId, LocalDate startDate, LocalDate endDate, [UsageRetrieveCustomerOptions options])` | `GET /api/v1/usage/customer/{customer_id}` | [`UsageResponse`](src/main/java/com/meteroid/models/UsageResponse.java) | | `UsageResponse client.usage().retrieveSubscription(String subscriptionId, [UsageRetrieveSubscriptionOptions options])` | `GET /api/v1/usage/subscription/{subscription_id}` | [`UsageResponse`](src/main/java/com/meteroid/models/UsageResponse.java) | | `UsageResponse client.usage().retrieveSummary(LocalDate startDate, LocalDate endDate, [UsageRetrieveSummaryOptions options])` | `GET /api/v1/usage/summary` | [`UsageResponse`](src/main/java/com/meteroid/models/UsageResponse.java) | + +## Webhook endpoints + +[`client.webhookEndpoints()`](src/main/java/com/meteroid/api/WebhookEndpoints.java) + +| Method | Request | Returns | +| --- | --- | --- | +| `WebhookDelivery client.webhookEndpoints().resendWebhookDelivery(String deliveryId)` | `POST /api/v1/webhooks/deliveries/{delivery_id}/resend` | [`WebhookDelivery`](src/main/java/com/meteroid/models/WebhookDelivery.java) | + +### Webhook endpoints endpoints + +[`client.webhookEndpoints().endpoints()`](src/main/java/com/meteroid/api/WebhookEndpointsEndpoints.java) + +| Method | Request | Returns | +| --- | --- | --- | +| `WebhookEndpointListResponse client.webhookEndpoints().endpoints().list()` | `GET /api/v1/webhooks/endpoints` | [`WebhookEndpointListResponse`](src/main/java/com/meteroid/models/WebhookEndpointListResponse.java) | +| `CreatedWebhookEndpoint client.webhookEndpoints().endpoints().create(CreateWebhookEndpointRequest createWebhookEndpointRequest)` | `POST /api/v1/webhooks/endpoints` | [`CreatedWebhookEndpoint`](src/main/java/com/meteroid/models/CreatedWebhookEndpoint.java) | +| `WebhookEndpoint client.webhookEndpoints().endpoints().retrieve(String endpointId)` | `GET /api/v1/webhooks/endpoints/{endpoint_id}` | [`WebhookEndpoint`](src/main/java/com/meteroid/models/WebhookEndpoint.java) | +| `void client.webhookEndpoints().endpoints().delete(String endpointId)` | `DELETE /api/v1/webhooks/endpoints/{endpoint_id}` | nothing | +| `WebhookEndpoint client.webhookEndpoints().endpoints().update(String endpointId, UpdateWebhookEndpointRequest updateWebhookEndpointRequest)` | `PATCH /api/v1/webhooks/endpoints/{endpoint_id}` | [`WebhookEndpoint`](src/main/java/com/meteroid/models/WebhookEndpoint.java) | +| `WebhookEndpointsEndpointsListDeliveriesPage client.webhookEndpoints().endpoints().listDeliveries(String endpointId, [WebhookEndpointsEndpointsListDeliveriesOptions options])` | `GET /api/v1/webhooks/endpoints/{endpoint_id}/deliveries` | [page](src/main/java/com/meteroid/api/WebhookEndpointsEndpointsListDeliveriesPage.java) of [`WebhookDelivery`](src/main/java/com/meteroid/models/WebhookDelivery.java), with the properties of [`WebhookDeliveryListResponse`](src/main/java/com/meteroid/models/WebhookDeliveryListResponse.java) | +| `WebhookEndpointSecret client.webhookEndpoints().endpoints().rotateSecret(String endpointId)` | `POST /api/v1/webhooks/endpoints/{endpoint_id}/rotate-secret` | [`WebhookEndpointSecret`](src/main/java/com/meteroid/models/WebhookEndpointSecret.java) | +| `WebhookEndpointSecret client.webhookEndpoints().endpoints().retrieveSecret(String endpointId)` | `GET /api/v1/webhooks/endpoints/{endpoint_id}/secret` | [`WebhookEndpointSecret`](src/main/java/com/meteroid/models/WebhookEndpointSecret.java) | diff --git a/src/main/java/com/meteroid/Meteroid.java b/src/main/java/com/meteroid/Meteroid.java index 2f06564..02ab491 100644 --- a/src/main/java/com/meteroid/Meteroid.java +++ b/src/main/java/com/meteroid/Meteroid.java @@ -21,6 +21,7 @@ import com.meteroid.api.Products; import com.meteroid.api.Subscriptions; import com.meteroid.api.Usage; +import com.meteroid.api.WebhookEndpoints; import com.meteroid.internal.MeteroidAuth; import com.meteroid.internal.MeteroidHttpClient; @@ -75,6 +76,7 @@ public final class Meteroid implements AutoCloseable { private final Products products; private final Subscriptions subscriptions; private final Usage usage; + private final WebhookEndpoints webhookEndpoints; /** * A client with the default options, its API key and base URL read from the environment. @@ -147,6 +149,7 @@ public Meteroid(MeteroidOptions options) { this.products = new Products(httpClient); this.subscriptions = new Subscriptions(httpClient); this.usage = new Usage(httpClient); + this.webhookEndpoints = new WebhookEndpoints(httpClient); this.withRawResponse = new WithRawResponse(); this.async = new MeteroidAsync(this); } @@ -372,6 +375,15 @@ public Usage usage() { return usage; } + /** + * The {@code webhook_endpoints} operations. + * + * @return the operations + */ + public WebhookEndpoints webhookEndpoints() { + return webhookEndpoints; + } + /** The operations, returning the status and headers along with the body. */ public final class WithRawResponse { private WithRawResponse() {} @@ -555,5 +567,14 @@ public Subscriptions.WithRawResponse subscriptions() { public Usage.WithRawResponse usage() { return usage.withRawResponse(); } + + /** + * The {@code webhook_endpoints} operations. + * + * @return the operations + */ + public WebhookEndpoints.WithRawResponse webhookEndpoints() { + return webhookEndpoints.withRawResponse(); + } } } diff --git a/src/main/java/com/meteroid/MeteroidAsync.java b/src/main/java/com/meteroid/MeteroidAsync.java index f87dc06..664ea14 100644 --- a/src/main/java/com/meteroid/MeteroidAsync.java +++ b/src/main/java/com/meteroid/MeteroidAsync.java @@ -21,6 +21,7 @@ import com.meteroid.api.ProductsAsync; import com.meteroid.api.SubscriptionsAsync; import com.meteroid.api.UsageAsync; +import com.meteroid.api.WebhookEndpointsAsync; /** * The Meteroid client without blocking: every method returns a {@link @@ -50,6 +51,7 @@ public final class MeteroidAsync implements AutoCloseable { private final ProductsAsync products; private final SubscriptionsAsync subscriptions; private final UsageAsync usage; + private final WebhookEndpointsAsync webhookEndpoints; MeteroidAsync(Meteroid sync) { this.sync = sync; @@ -73,6 +75,7 @@ public final class MeteroidAsync implements AutoCloseable { this.products = new ProductsAsync(sync.products()); this.subscriptions = new SubscriptionsAsync(sync.subscriptions()); this.usage = new UsageAsync(sync.usage()); + this.webhookEndpoints = new WebhookEndpointsAsync(sync.webhookEndpoints()); this.withRawResponse = new WithRawResponse(); } @@ -274,6 +277,15 @@ public UsageAsync usage() { return usage; } + /** + * The {@code webhook_endpoints} operations. + * + * @return the operations + */ + public WebhookEndpointsAsync webhookEndpoints() { + return webhookEndpoints; + } + /** Closes the client shared with {@link #sync()}. */ @Override public void close() { @@ -463,5 +475,14 @@ public SubscriptionsAsync.WithRawResponse subscriptions() { public UsageAsync.WithRawResponse usage() { return usage.withRawResponse(); } + + /** + * The {@code webhook_endpoints} operations. + * + * @return the operations + */ + public WebhookEndpointsAsync.WithRawResponse webhookEndpoints() { + return webhookEndpoints.withRawResponse(); + } } } diff --git a/src/main/java/com/meteroid/api/WebhookEndpoints.java b/src/main/java/com/meteroid/api/WebhookEndpoints.java new file mode 100644 index 0000000..c0edd36 --- /dev/null +++ b/src/main/java/com/meteroid/api/WebhookEndpoints.java @@ -0,0 +1,136 @@ +// 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.WebhookDelivery; + +import okhttp3.HttpUrl; + +import java.util.Objects; + +/** + * The {@code webhook_endpoints} operations, blocking. {@link #withRawResponse()} has the same + * methods returning the status and headers along with the body. + */ +public final class WebhookEndpoints { + private final MeteroidHttpClient client; + private final WithRawResponse withRawResponse; + + private final WebhookEndpointsEndpoints endpoints; + + /** + * The operations, sending through {@code client}. + * + * @param client the HTTP client of the SDK + */ + public WebhookEndpoints(MeteroidHttpClient client) { + this.client = client; + this.withRawResponse = new WithRawResponse(); + + this.endpoints = new WebhookEndpointsEndpoints(client); + } + + /** + * The same operations, returning the status and headers along with the body. + * + * @return the operations + */ + public WithRawResponse withRawResponse() { + return withRawResponse; + } + + /** + * The {@code endpoints} operations. + * + * @return the operations + */ + public WebhookEndpointsEndpoints endpoints() { + return endpoints; + } + + /** + * Resend a webhook delivery + * + *

Re-queues the same event for the same endpoint. Fails if the endpoint is disabled. + * + * @param deliveryId the {@code delivery_id} path parameter + * @return the response body + */ + public WebhookDelivery resendWebhookDelivery(final String deliveryId) { + return resendWebhookDelivery(deliveryId, RequestOptions.none()); + } + + /** + * Resend a webhook delivery + * + *

Re-queues the same event for the same endpoint. Fails if the endpoint is disabled. + * + * @param deliveryId the {@code delivery_id} path parameter + * @param requestOptions headers, timeout and retries of this call + * @return the response body + */ + public WebhookDelivery resendWebhookDelivery( + final String deliveryId, final RequestOptions requestOptions) { + return exchangeResendWebhookDelivery(deliveryId, requestOptions).send(); + } + + MeteroidHttpClient.Exchange exchangeResendWebhookDelivery( + final String deliveryId, final RequestOptions requestOptions) { + Objects.requireNonNull(deliveryId, "delivery_id"); + HttpUrl url = + client.newUrlBuilder() + .addPathSegments("api/v1/webhooks/deliveries") + .addPathSegment(Utils.pathSegment("delivery_id", deliveryId)) + .addPathSegments("resend") + .build(); + return client.call("POST", url) + .errors(com.meteroid.models.RestErrorResponse.class, "400", "401", "404", "429") + .options(requestOptions) + .returning(WebhookDelivery.class); + } + + /** The operations, returning the status and headers along with the body. */ + public final class WithRawResponse { + private WithRawResponse() {} + + /** + * The {@code endpoints} operations. + * + * @return the operations + */ + public WebhookEndpointsEndpoints.WithRawResponse endpoints() { + return WebhookEndpoints.this.endpoints.withRawResponse(); + } + + /** + * Resend a webhook delivery + * + *

Re-queues the same event for the same endpoint. Fails if the endpoint is disabled. + * + * @param deliveryId the {@code delivery_id} path parameter + * @return the status, headers and body + */ + public ApiResponse resendWebhookDelivery(final String deliveryId) { + return resendWebhookDelivery(deliveryId, RequestOptions.none()); + } + + /** + * Resend a webhook delivery + * + *

Re-queues the same event for the same endpoint. Fails if the endpoint is disabled. + * + * @param deliveryId the {@code delivery_id} path parameter + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body + */ + public ApiResponse resendWebhookDelivery( + final String deliveryId, final RequestOptions requestOptions) { + return WebhookEndpoints.this + .exchangeResendWebhookDelivery(deliveryId, requestOptions) + .sendRaw(); + } + } +} diff --git a/src/main/java/com/meteroid/api/WebhookEndpointsAsync.java b/src/main/java/com/meteroid/api/WebhookEndpointsAsync.java new file mode 100644 index 0000000..8428e27 --- /dev/null +++ b/src/main/java/com/meteroid/api/WebhookEndpointsAsync.java @@ -0,0 +1,116 @@ +// this file is @generated +package com.meteroid.api; + +import com.meteroid.ApiResponse; +import com.meteroid.RequestOptions; +import com.meteroid.models.WebhookDelivery; + +import java.util.concurrent.CompletableFuture; + +/** + * The {@code webhook_endpoints} operations, without blocking: each method returns a {@link + * CompletableFuture}. Obtained from {@code client.async()}. + */ +public final class WebhookEndpointsAsync { + private final WebhookEndpoints sync; + private final WithRawResponse withRawResponse; + + private final WebhookEndpointsEndpointsAsync endpoints; + + /** + * The operations, sending through {@code sync}. + * + * @param sync the blocking operations + */ + public WebhookEndpointsAsync(WebhookEndpoints sync) { + this.sync = sync; + this.withRawResponse = new WithRawResponse(); + + this.endpoints = new WebhookEndpointsEndpointsAsync(sync.endpoints()); + } + + /** + * The same operations, returning the status and headers along with the body. + * + * @return the operations + */ + public WithRawResponse withRawResponse() { + return withRawResponse; + } + + /** + * The {@code endpoints} operations. + * + * @return the operations + */ + public WebhookEndpointsEndpointsAsync endpoints() { + return endpoints; + } + + /** + * Resend a webhook delivery + * + *

Re-queues the same event for the same endpoint. Fails if the endpoint is disabled. + * + * @param deliveryId the {@code delivery_id} path parameter + * @return the response body, once received + */ + public CompletableFuture resendWebhookDelivery(final String deliveryId) { + return resendWebhookDelivery(deliveryId, RequestOptions.none()); + } + + /** + * Resend a webhook delivery + * + *

Re-queues the same event for the same endpoint. Fails if the endpoint is disabled. + * + * @param deliveryId the {@code delivery_id} path parameter + * @param requestOptions headers, timeout and retries of this call + * @return the response body, once received + */ + public CompletableFuture resendWebhookDelivery( + final String deliveryId, final RequestOptions requestOptions) { + return sync.exchangeResendWebhookDelivery(deliveryId, requestOptions).sendAsync(); + } + + /** The operations, returning the status and headers along with the body. */ + public final class WithRawResponse { + private WithRawResponse() {} + + /** + * The {@code endpoints} operations. + * + * @return the operations + */ + public WebhookEndpointsEndpointsAsync.WithRawResponse endpoints() { + return WebhookEndpointsAsync.this.endpoints.withRawResponse(); + } + + /** + * Resend a webhook delivery + * + *

Re-queues the same event for the same endpoint. Fails if the endpoint is disabled. + * + * @param deliveryId the {@code delivery_id} path parameter + * @return the status, headers and body, once received + */ + public CompletableFuture> resendWebhookDelivery( + final String deliveryId) { + return resendWebhookDelivery(deliveryId, RequestOptions.none()); + } + + /** + * Resend a webhook delivery + * + *

Re-queues the same event for the same endpoint. Fails if the endpoint is disabled. + * + * @param deliveryId the {@code delivery_id} path parameter + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body, once received + */ + public CompletableFuture> resendWebhookDelivery( + final String deliveryId, final RequestOptions requestOptions) { + return sync.exchangeResendWebhookDelivery(deliveryId, requestOptions).sendRawAsync(); + } + } +} diff --git a/src/main/java/com/meteroid/api/WebhookEndpointsEndpoints.java b/src/main/java/com/meteroid/api/WebhookEndpointsEndpoints.java new file mode 100644 index 0000000..4a33a18 --- /dev/null +++ b/src/main/java/com/meteroid/api/WebhookEndpointsEndpoints.java @@ -0,0 +1,705 @@ +// 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.CreateWebhookEndpointRequest; +import com.meteroid.models.CreatedWebhookEndpoint; +import com.meteroid.models.UpdateWebhookEndpointRequest; +import com.meteroid.models.WebhookDelivery; +import com.meteroid.models.WebhookDeliveryListResponse; +import com.meteroid.models.WebhookDeliveryStatus; +import com.meteroid.models.WebhookEndpoint; +import com.meteroid.models.WebhookEndpointListResponse; +import com.meteroid.models.WebhookEndpointSecret; + +import okhttp3.HttpUrl; + +import java.util.List; +import java.util.Objects; + +/** + * The {@code webhook_endpoints.endpoints} operations, blocking. {@link #withRawResponse()} has the + * same methods returning the status and headers along with the body. + */ +public final class WebhookEndpointsEndpoints { + private final MeteroidHttpClient client; + private final WithRawResponse withRawResponse; + + /** + * The operations, sending through {@code client}. + * + * @param client the HTTP client of the SDK + */ + public WebhookEndpointsEndpoints(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 webhook endpoints + * + * @return the response body + */ + public WebhookEndpointListResponse list() { + return list(RequestOptions.none()); + } + + /** + * List webhook endpoints + * + * @param requestOptions headers, timeout and retries of this call + * @return the response body + */ + public WebhookEndpointListResponse list(final RequestOptions requestOptions) { + return exchangeList(requestOptions).send(); + } + + MeteroidHttpClient.Exchange exchangeList( + final RequestOptions requestOptions) { + HttpUrl url = client.newUrlBuilder().addPathSegments("api/v1/webhooks/endpoints").build(); + return client.call("GET", url) + .errors(com.meteroid.models.RestErrorResponse.class, "401", "429") + .options(requestOptions) + .returning(WebhookEndpointListResponse.class); + } + + /** + * Create a webhook endpoint + * + *

The signing secret is returned once, in this response only. + * + * @param createWebhookEndpointRequest the request body + * @return the response body + */ + public CreatedWebhookEndpoint create( + final CreateWebhookEndpointRequest createWebhookEndpointRequest) { + return create(createWebhookEndpointRequest, RequestOptions.none()); + } + + /** + * Create a webhook endpoint + * + *

The signing secret is returned once, in this response only. + * + * @param createWebhookEndpointRequest the request body + * @param requestOptions headers, timeout and retries of this call + * @return the response body + */ + public CreatedWebhookEndpoint create( + final CreateWebhookEndpointRequest createWebhookEndpointRequest, + final RequestOptions requestOptions) { + return exchangeCreate(createWebhookEndpointRequest, requestOptions).send(); + } + + MeteroidHttpClient.Exchange exchangeCreate( + final CreateWebhookEndpointRequest createWebhookEndpointRequest, + final RequestOptions requestOptions) { + Objects.requireNonNull(createWebhookEndpointRequest, "body"); + HttpUrl url = client.newUrlBuilder().addPathSegments("api/v1/webhooks/endpoints").build(); + return client.call("POST", url) + .json(createWebhookEndpointRequest) + .errors(com.meteroid.models.RestErrorResponse.class, "400", "401", "409", "429") + .options(requestOptions) + .returning(CreatedWebhookEndpoint.class); + } + + /** + * Get a webhook endpoint + * + * @param endpointId the {@code endpoint_id} path parameter + * @return the response body + */ + public WebhookEndpoint retrieve(final String endpointId) { + return retrieve(endpointId, RequestOptions.none()); + } + + /** + * Get a webhook endpoint + * + * @param endpointId the {@code endpoint_id} path parameter + * @param requestOptions headers, timeout and retries of this call + * @return the response body + */ + public WebhookEndpoint retrieve(final String endpointId, final RequestOptions requestOptions) { + return exchangeRetrieve(endpointId, requestOptions).send(); + } + + MeteroidHttpClient.Exchange exchangeRetrieve( + final String endpointId, final RequestOptions requestOptions) { + Objects.requireNonNull(endpointId, "endpoint_id"); + HttpUrl url = + client.newUrlBuilder() + .addPathSegments("api/v1/webhooks/endpoints") + .addPathSegment(Utils.pathSegment("endpoint_id", endpointId)) + .build(); + return client.call("GET", url) + .errors(com.meteroid.models.RestErrorResponse.class, "401", "404", "429") + .options(requestOptions) + .returning(WebhookEndpoint.class); + } + + /** + * Delete a webhook endpoint + * + *

The endpoint is archived and its pending deliveries are cancelled. + * + * @param endpointId the {@code endpoint_id} path parameter + */ + public void delete(final String endpointId) { + delete(endpointId, RequestOptions.none()); + } + + /** + * Delete a webhook endpoint + * + *

The endpoint is archived and its pending deliveries are cancelled. + * + * @param endpointId the {@code endpoint_id} path parameter + * @param requestOptions headers, timeout and retries of this call + */ + public void delete(final String endpointId, final RequestOptions requestOptions) { + exchangeDelete(endpointId, requestOptions).send(); + } + + MeteroidHttpClient.Exchange exchangeDelete( + final String endpointId, final RequestOptions requestOptions) { + Objects.requireNonNull(endpointId, "endpoint_id"); + HttpUrl url = + client.newUrlBuilder() + .addPathSegments("api/v1/webhooks/endpoints") + .addPathSegment(Utils.pathSegment("endpoint_id", endpointId)) + .build(); + return client.call("DELETE", url) + .errors(com.meteroid.models.RestErrorResponse.class, "401", "404", "429") + .options(requestOptions) + .returningNothing(); + } + + /** + * Update a webhook endpoint + * + *

Omitted fields are left untouched. Re-enabling a disabled endpoint resets its consecutive + * failure count. + * + * @param endpointId the {@code endpoint_id} path parameter + * @param updateWebhookEndpointRequest the request body + * @return the response body + */ + public WebhookEndpoint update( + final String endpointId, + final UpdateWebhookEndpointRequest updateWebhookEndpointRequest) { + return update(endpointId, updateWebhookEndpointRequest, RequestOptions.none()); + } + + /** + * Update a webhook endpoint + * + *

Omitted fields are left untouched. Re-enabling a disabled endpoint resets its consecutive + * failure count. + * + * @param endpointId the {@code endpoint_id} path parameter + * @param updateWebhookEndpointRequest the request body + * @param requestOptions headers, timeout and retries of this call + * @return the response body + */ + public WebhookEndpoint update( + final String endpointId, + final UpdateWebhookEndpointRequest updateWebhookEndpointRequest, + final RequestOptions requestOptions) { + return exchangeUpdate(endpointId, updateWebhookEndpointRequest, requestOptions).send(); + } + + MeteroidHttpClient.Exchange exchangeUpdate( + final String endpointId, + final UpdateWebhookEndpointRequest updateWebhookEndpointRequest, + final RequestOptions requestOptions) { + Objects.requireNonNull(endpointId, "endpoint_id"); + Objects.requireNonNull(updateWebhookEndpointRequest, "body"); + HttpUrl url = + client.newUrlBuilder() + .addPathSegments("api/v1/webhooks/endpoints") + .addPathSegment(Utils.pathSegment("endpoint_id", endpointId)) + .build(); + return client.call("PATCH", url) + .json(updateWebhookEndpointRequest) + .errors(com.meteroid.models.RestErrorResponse.class, "400", "401", "404", "429") + .options(requestOptions) + .returning(WebhookEndpoint.class); + } + + /** + * List deliveries for a webhook endpoint + * + * @param endpointId the {@code endpoint_id} path parameter + * @return the page: the response body, its items and the way to the next pages + */ + public WebhookEndpointsEndpointsListDeliveriesPage listDeliveries(final String endpointId) { + return listDeliveries( + endpointId, + WebhookEndpointsEndpointsListDeliveriesOptions.none(), + RequestOptions.none()); + } + + /** + * List deliveries for a webhook endpoint + * + * @param endpointId the {@code endpoint_id} path parameter + * @param options the optional parameters + * @return the page: the response body, its items and the way to the next pages + */ + public WebhookEndpointsEndpointsListDeliveriesPage listDeliveries( + final String endpointId, final WebhookEndpointsEndpointsListDeliveriesOptions options) { + return listDeliveries(endpointId, options, RequestOptions.none()); + } + + /** + * List deliveries for a webhook endpoint + * + * @param endpointId the {@code endpoint_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 WebhookEndpointsEndpointsListDeliveriesPage listDeliveries( + final String endpointId, final RequestOptions requestOptions) { + return listDeliveries( + endpointId, WebhookEndpointsEndpointsListDeliveriesOptions.none(), requestOptions); + } + + /** + * List deliveries for a webhook endpoint + * + * @param endpointId the {@code endpoint_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 WebhookEndpointsEndpointsListDeliveriesPage listDeliveries( + final String endpointId, + final WebhookEndpointsEndpointsListDeliveriesOptions options, + final RequestOptions requestOptions) { + return pageOfListDeliveries( + exchangeListDeliveries(endpointId, options, requestOptions).send(), + endpointId, + options, + requestOptions); + } + + MeteroidHttpClient.Exchange exchangeListDeliveries( + final String endpointId, + final WebhookEndpointsEndpointsListDeliveriesOptions options, + final RequestOptions requestOptions) { + Objects.requireNonNull(endpointId, "endpoint_id"); + Objects.requireNonNull(options, "options"); + HttpUrl.Builder url = + client.newUrlBuilder() + .addPathSegments("api/v1/webhooks/endpoints") + .addPathSegment(Utils.pathSegment("endpoint_id", endpointId)) + .addPathSegments("deliveries"); + WebhookDeliveryStatus value1 = options.status().orElse(null); + if (value1 != null) { + url.addQueryParameter("status", Utils.serializeQueryParam(value1)); + } + Integer value2 = options.page().orElse(null); + if (value2 != null) { + url.addQueryParameter("page", Utils.serializeQueryParam(value2)); + } + Integer value3 = options.perPage().orElse(null); + if (value3 != null) { + url.addQueryParameter("per_page", Utils.serializeQueryParam(value3)); + } + return client.call("GET", url.build()) + .errors(com.meteroid.models.RestErrorResponse.class, "401", "404", "429") + .options(requestOptions) + .returning(WebhookDeliveryListResponse.class); + } + + private WebhookEndpointsEndpointsListDeliveriesPage pageOfListDeliveries( + WebhookDeliveryListResponse response, + final String endpointId, + final WebhookEndpointsEndpointsListDeliveriesOptions options, + final RequestOptions requestOptions) { + List items = itemsOfListDeliveries(response); + Integer next = nextOfListDeliveries(response, items, options.page().orElse(0)); + return new WebhookEndpointsEndpointsListDeliveriesPage( + response, + items, + next == null + ? null + : () -> + listDeliveries( + endpointId, + options.toBuilder().page(next).build(), + requestOptions)); + } + + static List itemsOfListDeliveries(WebhookDeliveryListResponse response) { + return Utils.optional(response.data()).orElse(List.of()); + } + + /** The parameter of the page after {@code response}, null after the last one. */ + static Integer nextOfListDeliveries( + WebhookDeliveryListResponse 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; + } + + /** + * Rotate a webhook endpoint secret + * + *

The previous secret keeps signing alongside the new one for 24 hours, so consumers can + * roll over without dropping events. + * + * @param endpointId the {@code endpoint_id} path parameter + * @return the response body + */ + public WebhookEndpointSecret rotateSecret(final String endpointId) { + return rotateSecret(endpointId, RequestOptions.none()); + } + + /** + * Rotate a webhook endpoint secret + * + *

The previous secret keeps signing alongside the new one for 24 hours, so consumers can + * roll over without dropping events. + * + * @param endpointId the {@code endpoint_id} path parameter + * @param requestOptions headers, timeout and retries of this call + * @return the response body + */ + public WebhookEndpointSecret rotateSecret( + final String endpointId, final RequestOptions requestOptions) { + return exchangeRotateSecret(endpointId, requestOptions).send(); + } + + MeteroidHttpClient.Exchange exchangeRotateSecret( + final String endpointId, final RequestOptions requestOptions) { + Objects.requireNonNull(endpointId, "endpoint_id"); + HttpUrl url = + client.newUrlBuilder() + .addPathSegments("api/v1/webhooks/endpoints") + .addPathSegment(Utils.pathSegment("endpoint_id", endpointId)) + .addPathSegments("rotate-secret") + .build(); + return client.call("POST", url) + .errors(com.meteroid.models.RestErrorResponse.class, "401", "404", "429") + .options(requestOptions) + .returning(WebhookEndpointSecret.class); + } + + /** + * Reveal a webhook endpoint secret + * + * @param endpointId the {@code endpoint_id} path parameter + * @return the response body + */ + public WebhookEndpointSecret retrieveSecret(final String endpointId) { + return retrieveSecret(endpointId, RequestOptions.none()); + } + + /** + * Reveal a webhook endpoint secret + * + * @param endpointId the {@code endpoint_id} path parameter + * @param requestOptions headers, timeout and retries of this call + * @return the response body + */ + public WebhookEndpointSecret retrieveSecret( + final String endpointId, final RequestOptions requestOptions) { + return exchangeRetrieveSecret(endpointId, requestOptions).send(); + } + + MeteroidHttpClient.Exchange exchangeRetrieveSecret( + final String endpointId, final RequestOptions requestOptions) { + Objects.requireNonNull(endpointId, "endpoint_id"); + HttpUrl url = + client.newUrlBuilder() + .addPathSegments("api/v1/webhooks/endpoints") + .addPathSegment(Utils.pathSegment("endpoint_id", endpointId)) + .addPathSegments("secret") + .build(); + return client.call("GET", url) + .errors(com.meteroid.models.RestErrorResponse.class, "401", "404", "429") + .options(requestOptions) + .returning(WebhookEndpointSecret.class); + } + + /** The operations, returning the status and headers along with the body. */ + public final class WithRawResponse { + private WithRawResponse() {} + + /** + * List webhook endpoints + * + * @return the status, headers and body + */ + public ApiResponse list() { + return list(RequestOptions.none()); + } + + /** + * List webhook endpoints + * + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body + */ + public ApiResponse list(final RequestOptions requestOptions) { + return WebhookEndpointsEndpoints.this.exchangeList(requestOptions).sendRaw(); + } + + /** + * Create a webhook endpoint + * + *

The signing secret is returned once, in this response only. + * + * @param createWebhookEndpointRequest the request body + * @return the status, headers and body + */ + public ApiResponse create( + final CreateWebhookEndpointRequest createWebhookEndpointRequest) { + return create(createWebhookEndpointRequest, RequestOptions.none()); + } + + /** + * Create a webhook endpoint + * + *

The signing secret is returned once, in this response only. + * + * @param createWebhookEndpointRequest the request body + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body + */ + public ApiResponse create( + final CreateWebhookEndpointRequest createWebhookEndpointRequest, + final RequestOptions requestOptions) { + return WebhookEndpointsEndpoints.this + .exchangeCreate(createWebhookEndpointRequest, requestOptions) + .sendRaw(); + } + + /** + * Get a webhook endpoint + * + * @param endpointId the {@code endpoint_id} path parameter + * @return the status, headers and body + */ + public ApiResponse retrieve(final String endpointId) { + return retrieve(endpointId, RequestOptions.none()); + } + + /** + * Get a webhook endpoint + * + * @param endpointId the {@code endpoint_id} path parameter + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body + */ + public ApiResponse retrieve( + final String endpointId, final RequestOptions requestOptions) { + return WebhookEndpointsEndpoints.this + .exchangeRetrieve(endpointId, requestOptions) + .sendRaw(); + } + + /** + * Delete a webhook endpoint + * + *

The endpoint is archived and its pending deliveries are cancelled. + * + * @param endpointId the {@code endpoint_id} path parameter + * @return the status, headers and body + */ + public ApiResponse delete(final String endpointId) { + return delete(endpointId, RequestOptions.none()); + } + + /** + * Delete a webhook endpoint + * + *

The endpoint is archived and its pending deliveries are cancelled. + * + * @param endpointId the {@code endpoint_id} path parameter + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body + */ + public ApiResponse delete( + final String endpointId, final RequestOptions requestOptions) { + return WebhookEndpointsEndpoints.this + .exchangeDelete(endpointId, requestOptions) + .sendRaw(); + } + + /** + * Update a webhook endpoint + * + *

Omitted fields are left untouched. Re-enabling a disabled endpoint resets its + * consecutive failure count. + * + * @param endpointId the {@code endpoint_id} path parameter + * @param updateWebhookEndpointRequest the request body + * @return the status, headers and body + */ + public ApiResponse update( + final String endpointId, + final UpdateWebhookEndpointRequest updateWebhookEndpointRequest) { + return update(endpointId, updateWebhookEndpointRequest, RequestOptions.none()); + } + + /** + * Update a webhook endpoint + * + *

Omitted fields are left untouched. Re-enabling a disabled endpoint resets its + * consecutive failure count. + * + * @param endpointId the {@code endpoint_id} path parameter + * @param updateWebhookEndpointRequest the request body + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body + */ + public ApiResponse update( + final String endpointId, + final UpdateWebhookEndpointRequest updateWebhookEndpointRequest, + final RequestOptions requestOptions) { + return WebhookEndpointsEndpoints.this + .exchangeUpdate(endpointId, updateWebhookEndpointRequest, requestOptions) + .sendRaw(); + } + + /** + * List deliveries for a webhook endpoint + * + * @param endpointId the {@code endpoint_id} path parameter + * @return the status, headers and page + */ + public ApiResponse listDeliveries( + final String endpointId) { + return listDeliveries( + endpointId, + WebhookEndpointsEndpointsListDeliveriesOptions.none(), + RequestOptions.none()); + } + + /** + * List deliveries for a webhook endpoint + * + * @param endpointId the {@code endpoint_id} path parameter + * @param options the optional parameters + * @return the status, headers and page + */ + public ApiResponse listDeliveries( + final String endpointId, + final WebhookEndpointsEndpointsListDeliveriesOptions options) { + return listDeliveries(endpointId, options, RequestOptions.none()); + } + + /** + * List deliveries for a webhook endpoint + * + * @param endpointId the {@code endpoint_id} path parameter + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and page + */ + public ApiResponse listDeliveries( + final String endpointId, final RequestOptions requestOptions) { + return listDeliveries( + endpointId, + WebhookEndpointsEndpointsListDeliveriesOptions.none(), + requestOptions); + } + + /** + * List deliveries for a webhook endpoint + * + * @param endpointId the {@code endpoint_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 listDeliveries( + final String endpointId, + final WebhookEndpointsEndpointsListDeliveriesOptions options, + final RequestOptions requestOptions) { + ApiResponse response = + exchangeListDeliveries(endpointId, options, requestOptions).sendRaw(); + return new ApiResponse<>( + response.statusCode(), + response.headers(), + pageOfListDeliveries(response.body(), endpointId, options, requestOptions)); + } + + /** + * Rotate a webhook endpoint secret + * + *

The previous secret keeps signing alongside the new one for 24 hours, so consumers can + * roll over without dropping events. + * + * @param endpointId the {@code endpoint_id} path parameter + * @return the status, headers and body + */ + public ApiResponse rotateSecret(final String endpointId) { + return rotateSecret(endpointId, RequestOptions.none()); + } + + /** + * Rotate a webhook endpoint secret + * + *

The previous secret keeps signing alongside the new one for 24 hours, so consumers can + * roll over without dropping events. + * + * @param endpointId the {@code endpoint_id} path parameter + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body + */ + public ApiResponse rotateSecret( + final String endpointId, final RequestOptions requestOptions) { + return WebhookEndpointsEndpoints.this + .exchangeRotateSecret(endpointId, requestOptions) + .sendRaw(); + } + + /** + * Reveal a webhook endpoint secret + * + * @param endpointId the {@code endpoint_id} path parameter + * @return the status, headers and body + */ + public ApiResponse retrieveSecret(final String endpointId) { + return retrieveSecret(endpointId, RequestOptions.none()); + } + + /** + * Reveal a webhook endpoint secret + * + * @param endpointId the {@code endpoint_id} path parameter + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body + */ + public ApiResponse retrieveSecret( + final String endpointId, final RequestOptions requestOptions) { + return WebhookEndpointsEndpoints.this + .exchangeRetrieveSecret(endpointId, requestOptions) + .sendRaw(); + } + } +} diff --git a/src/main/java/com/meteroid/api/WebhookEndpointsEndpointsAsync.java b/src/main/java/com/meteroid/api/WebhookEndpointsEndpointsAsync.java new file mode 100644 index 0000000..a953585 --- /dev/null +++ b/src/main/java/com/meteroid/api/WebhookEndpointsEndpointsAsync.java @@ -0,0 +1,563 @@ +// this file is @generated +package com.meteroid.api; + +import com.meteroid.ApiResponse; +import com.meteroid.RequestOptions; +import com.meteroid.models.CreateWebhookEndpointRequest; +import com.meteroid.models.CreatedWebhookEndpoint; +import com.meteroid.models.UpdateWebhookEndpointRequest; +import com.meteroid.models.WebhookDelivery; +import com.meteroid.models.WebhookDeliveryListResponse; +import com.meteroid.models.WebhookEndpoint; +import com.meteroid.models.WebhookEndpointListResponse; +import com.meteroid.models.WebhookEndpointSecret; + +import java.util.List; +import java.util.concurrent.CompletableFuture; + +/** + * The {@code webhook_endpoints.endpoints} operations, without blocking: each method returns a + * {@link CompletableFuture}. Obtained from {@code client.async()}. + */ +public final class WebhookEndpointsEndpointsAsync { + private final WebhookEndpointsEndpoints sync; + private final WithRawResponse withRawResponse; + + /** + * The operations, sending through {@code sync}. + * + * @param sync the blocking operations + */ + public WebhookEndpointsEndpointsAsync(WebhookEndpointsEndpoints 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 webhook endpoints + * + * @return the response body, once received + */ + public CompletableFuture list() { + return list(RequestOptions.none()); + } + + /** + * List webhook endpoints + * + * @param requestOptions headers, timeout and retries of this call + * @return the response body, once received + */ + public CompletableFuture list( + final RequestOptions requestOptions) { + return sync.exchangeList(requestOptions).sendAsync(); + } + + /** + * Create a webhook endpoint + * + *

The signing secret is returned once, in this response only. + * + * @param createWebhookEndpointRequest the request body + * @return the response body, once received + */ + public CompletableFuture create( + final CreateWebhookEndpointRequest createWebhookEndpointRequest) { + return create(createWebhookEndpointRequest, RequestOptions.none()); + } + + /** + * Create a webhook endpoint + * + *

The signing secret is returned once, in this response only. + * + * @param createWebhookEndpointRequest the request body + * @param requestOptions headers, timeout and retries of this call + * @return the response body, once received + */ + public CompletableFuture create( + final CreateWebhookEndpointRequest createWebhookEndpointRequest, + final RequestOptions requestOptions) { + return sync.exchangeCreate(createWebhookEndpointRequest, requestOptions).sendAsync(); + } + + /** + * Get a webhook endpoint + * + * @param endpointId the {@code endpoint_id} path parameter + * @return the response body, once received + */ + public CompletableFuture retrieve(final String endpointId) { + return retrieve(endpointId, RequestOptions.none()); + } + + /** + * Get a webhook endpoint + * + * @param endpointId the {@code endpoint_id} path parameter + * @param requestOptions headers, timeout and retries of this call + * @return the response body, once received + */ + public CompletableFuture retrieve( + final String endpointId, final RequestOptions requestOptions) { + return sync.exchangeRetrieve(endpointId, requestOptions).sendAsync(); + } + + /** + * Delete a webhook endpoint + * + *

The endpoint is archived and its pending deliveries are cancelled. + * + * @param endpointId the {@code endpoint_id} path parameter + * @return the response body, once received + */ + public CompletableFuture delete(final String endpointId) { + return delete(endpointId, RequestOptions.none()); + } + + /** + * Delete a webhook endpoint + * + *

The endpoint is archived and its pending deliveries are cancelled. + * + * @param endpointId the {@code endpoint_id} path parameter + * @param requestOptions headers, timeout and retries of this call + * @return the response body, once received + */ + public CompletableFuture delete( + final String endpointId, final RequestOptions requestOptions) { + return sync.exchangeDelete(endpointId, requestOptions).sendAsync(); + } + + /** + * Update a webhook endpoint + * + *

Omitted fields are left untouched. Re-enabling a disabled endpoint resets its consecutive + * failure count. + * + * @param endpointId the {@code endpoint_id} path parameter + * @param updateWebhookEndpointRequest the request body + * @return the response body, once received + */ + public CompletableFuture update( + final String endpointId, + final UpdateWebhookEndpointRequest updateWebhookEndpointRequest) { + return update(endpointId, updateWebhookEndpointRequest, RequestOptions.none()); + } + + /** + * Update a webhook endpoint + * + *

Omitted fields are left untouched. Re-enabling a disabled endpoint resets its consecutive + * failure count. + * + * @param endpointId the {@code endpoint_id} path parameter + * @param updateWebhookEndpointRequest the request body + * @param requestOptions headers, timeout and retries of this call + * @return the response body, once received + */ + public CompletableFuture update( + final String endpointId, + final UpdateWebhookEndpointRequest updateWebhookEndpointRequest, + final RequestOptions requestOptions) { + return sync.exchangeUpdate(endpointId, updateWebhookEndpointRequest, requestOptions) + .sendAsync(); + } + + /** + * List deliveries for a webhook endpoint + * + * @param endpointId the {@code endpoint_id} path parameter + * @return the page, once received + */ + public CompletableFuture listDeliveries( + final String endpointId) { + return listDeliveries( + endpointId, + WebhookEndpointsEndpointsListDeliveriesOptions.none(), + RequestOptions.none()); + } + + /** + * List deliveries for a webhook endpoint + * + * @param endpointId the {@code endpoint_id} path parameter + * @param options the optional parameters + * @return the page, once received + */ + public CompletableFuture listDeliveries( + final String endpointId, final WebhookEndpointsEndpointsListDeliveriesOptions options) { + return listDeliveries(endpointId, options, RequestOptions.none()); + } + + /** + * List deliveries for a webhook endpoint + * + * @param endpointId the {@code endpoint_id} path parameter + * @param requestOptions headers, timeout and retries of this call + * @return the page, once received + */ + public CompletableFuture listDeliveries( + final String endpointId, final RequestOptions requestOptions) { + return listDeliveries( + endpointId, WebhookEndpointsEndpointsListDeliveriesOptions.none(), requestOptions); + } + + /** + * List deliveries for a webhook endpoint + * + * @param endpointId the {@code endpoint_id} path parameter + * @param options the optional parameters + * @param requestOptions headers, timeout and retries of this call + * @return the page, once received + */ + public CompletableFuture listDeliveries( + final String endpointId, + final WebhookEndpointsEndpointsListDeliveriesOptions options, + final RequestOptions requestOptions) { + return sync.exchangeListDeliveries(endpointId, options, requestOptions) + .sendAsync() + .thenApply( + response -> + pageOfListDeliveries( + response, endpointId, options, requestOptions)); + } + + private WebhookEndpointsEndpointsListDeliveriesAsyncPage pageOfListDeliveries( + WebhookDeliveryListResponse response, + final String endpointId, + final WebhookEndpointsEndpointsListDeliveriesOptions options, + final RequestOptions requestOptions) { + List items = WebhookEndpointsEndpoints.itemsOfListDeliveries(response); + Integer next = + WebhookEndpointsEndpoints.nextOfListDeliveries( + response, items, options.page().orElse(0)); + return new WebhookEndpointsEndpointsListDeliveriesAsyncPage( + response, + items, + next == null + ? null + : () -> + listDeliveries( + endpointId, + options.toBuilder().page(next).build(), + requestOptions)); + } + + /** + * Rotate a webhook endpoint secret + * + *

The previous secret keeps signing alongside the new one for 24 hours, so consumers can + * roll over without dropping events. + * + * @param endpointId the {@code endpoint_id} path parameter + * @return the response body, once received + */ + public CompletableFuture rotateSecret(final String endpointId) { + return rotateSecret(endpointId, RequestOptions.none()); + } + + /** + * Rotate a webhook endpoint secret + * + *

The previous secret keeps signing alongside the new one for 24 hours, so consumers can + * roll over without dropping events. + * + * @param endpointId the {@code endpoint_id} path parameter + * @param requestOptions headers, timeout and retries of this call + * @return the response body, once received + */ + public CompletableFuture rotateSecret( + final String endpointId, final RequestOptions requestOptions) { + return sync.exchangeRotateSecret(endpointId, requestOptions).sendAsync(); + } + + /** + * Reveal a webhook endpoint secret + * + * @param endpointId the {@code endpoint_id} path parameter + * @return the response body, once received + */ + public CompletableFuture retrieveSecret(final String endpointId) { + return retrieveSecret(endpointId, RequestOptions.none()); + } + + /** + * Reveal a webhook endpoint secret + * + * @param endpointId the {@code endpoint_id} path parameter + * @param requestOptions headers, timeout and retries of this call + * @return the response body, once received + */ + public CompletableFuture retrieveSecret( + final String endpointId, final RequestOptions requestOptions) { + return sync.exchangeRetrieveSecret(endpointId, requestOptions).sendAsync(); + } + + /** The operations, returning the status and headers along with the body. */ + public final class WithRawResponse { + private WithRawResponse() {} + + /** + * List webhook endpoints + * + * @return the status, headers and body, once received + */ + public CompletableFuture> list() { + return list(RequestOptions.none()); + } + + /** + * List webhook endpoints + * + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body, once received + */ + public CompletableFuture> list( + final RequestOptions requestOptions) { + return sync.exchangeList(requestOptions).sendRawAsync(); + } + + /** + * Create a webhook endpoint + * + *

The signing secret is returned once, in this response only. + * + * @param createWebhookEndpointRequest the request body + * @return the status, headers and body, once received + */ + public CompletableFuture> create( + final CreateWebhookEndpointRequest createWebhookEndpointRequest) { + return create(createWebhookEndpointRequest, RequestOptions.none()); + } + + /** + * Create a webhook endpoint + * + *

The signing secret is returned once, in this response only. + * + * @param createWebhookEndpointRequest the request body + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body, once received + */ + public CompletableFuture> create( + final CreateWebhookEndpointRequest createWebhookEndpointRequest, + final RequestOptions requestOptions) { + return sync.exchangeCreate(createWebhookEndpointRequest, requestOptions).sendRawAsync(); + } + + /** + * Get a webhook endpoint + * + * @param endpointId the {@code endpoint_id} path parameter + * @return the status, headers and body, once received + */ + public CompletableFuture> retrieve(final String endpointId) { + return retrieve(endpointId, RequestOptions.none()); + } + + /** + * Get a webhook endpoint + * + * @param endpointId the {@code endpoint_id} path parameter + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body, once received + */ + public CompletableFuture> retrieve( + final String endpointId, final RequestOptions requestOptions) { + return sync.exchangeRetrieve(endpointId, requestOptions).sendRawAsync(); + } + + /** + * Delete a webhook endpoint + * + *

The endpoint is archived and its pending deliveries are cancelled. + * + * @param endpointId the {@code endpoint_id} path parameter + * @return the status, headers and body, once received + */ + public CompletableFuture> delete(final String endpointId) { + return delete(endpointId, RequestOptions.none()); + } + + /** + * Delete a webhook endpoint + * + *

The endpoint is archived and its pending deliveries are cancelled. + * + * @param endpointId the {@code endpoint_id} path parameter + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body, once received + */ + public CompletableFuture> delete( + final String endpointId, final RequestOptions requestOptions) { + return sync.exchangeDelete(endpointId, requestOptions).sendRawAsync(); + } + + /** + * Update a webhook endpoint + * + *

Omitted fields are left untouched. Re-enabling a disabled endpoint resets its + * consecutive failure count. + * + * @param endpointId the {@code endpoint_id} path parameter + * @param updateWebhookEndpointRequest the request body + * @return the status, headers and body, once received + */ + public CompletableFuture> update( + final String endpointId, + final UpdateWebhookEndpointRequest updateWebhookEndpointRequest) { + return update(endpointId, updateWebhookEndpointRequest, RequestOptions.none()); + } + + /** + * Update a webhook endpoint + * + *

Omitted fields are left untouched. Re-enabling a disabled endpoint resets its + * consecutive failure count. + * + * @param endpointId the {@code endpoint_id} path parameter + * @param updateWebhookEndpointRequest the request body + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body, once received + */ + public CompletableFuture> update( + final String endpointId, + final UpdateWebhookEndpointRequest updateWebhookEndpointRequest, + final RequestOptions requestOptions) { + return sync.exchangeUpdate(endpointId, updateWebhookEndpointRequest, requestOptions) + .sendRawAsync(); + } + + /** + * List deliveries for a webhook endpoint + * + * @param endpointId the {@code endpoint_id} path parameter + * @return the status, headers and page, once received + */ + public CompletableFuture> + listDeliveries(final String endpointId) { + return listDeliveries( + endpointId, + WebhookEndpointsEndpointsListDeliveriesOptions.none(), + RequestOptions.none()); + } + + /** + * List deliveries for a webhook endpoint + * + * @param endpointId the {@code endpoint_id} path parameter + * @param options the optional parameters + * @return the status, headers and page, once received + */ + public CompletableFuture> + listDeliveries( + final String endpointId, + final WebhookEndpointsEndpointsListDeliveriesOptions options) { + return listDeliveries(endpointId, options, RequestOptions.none()); + } + + /** + * List deliveries for a webhook endpoint + * + * @param endpointId the {@code endpoint_id} path parameter + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and page, once received + */ + public CompletableFuture> + listDeliveries(final String endpointId, final RequestOptions requestOptions) { + return listDeliveries( + endpointId, + WebhookEndpointsEndpointsListDeliveriesOptions.none(), + requestOptions); + } + + /** + * List deliveries for a webhook endpoint + * + * @param endpointId the {@code endpoint_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> + listDeliveries( + final String endpointId, + final WebhookEndpointsEndpointsListDeliveriesOptions options, + final RequestOptions requestOptions) { + return sync.exchangeListDeliveries(endpointId, options, requestOptions) + .sendRawAsync() + .thenApply( + response -> + new ApiResponse<>( + response.statusCode(), + response.headers(), + pageOfListDeliveries( + response.body(), + endpointId, + options, + requestOptions))); + } + + /** + * Rotate a webhook endpoint secret + * + *

The previous secret keeps signing alongside the new one for 24 hours, so consumers can + * roll over without dropping events. + * + * @param endpointId the {@code endpoint_id} path parameter + * @return the status, headers and body, once received + */ + public CompletableFuture> rotateSecret( + final String endpointId) { + return rotateSecret(endpointId, RequestOptions.none()); + } + + /** + * Rotate a webhook endpoint secret + * + *

The previous secret keeps signing alongside the new one for 24 hours, so consumers can + * roll over without dropping events. + * + * @param endpointId the {@code endpoint_id} path parameter + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body, once received + */ + public CompletableFuture> rotateSecret( + final String endpointId, final RequestOptions requestOptions) { + return sync.exchangeRotateSecret(endpointId, requestOptions).sendRawAsync(); + } + + /** + * Reveal a webhook endpoint secret + * + * @param endpointId the {@code endpoint_id} path parameter + * @return the status, headers and body, once received + */ + public CompletableFuture> retrieveSecret( + final String endpointId) { + return retrieveSecret(endpointId, RequestOptions.none()); + } + + /** + * Reveal a webhook endpoint secret + * + * @param endpointId the {@code endpoint_id} path parameter + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body, once received + */ + public CompletableFuture> retrieveSecret( + final String endpointId, final RequestOptions requestOptions) { + return sync.exchangeRetrieveSecret(endpointId, requestOptions).sendRawAsync(); + } + } +} diff --git a/src/main/java/com/meteroid/api/WebhookEndpointsEndpointsListDeliveriesAsyncPage.java b/src/main/java/com/meteroid/api/WebhookEndpointsEndpointsListDeliveriesAsyncPage.java new file mode 100644 index 0000000..706f821 --- /dev/null +++ b/src/main/java/com/meteroid/api/WebhookEndpointsEndpointsListDeliveriesAsyncPage.java @@ -0,0 +1,71 @@ +// this file is @generated +package com.meteroid.api; + +import com.meteroid.AsyncPage; +import com.meteroid.models.PaginationResponse; +import com.meteroid.models.WebhookDelivery; +import com.meteroid.models.WebhookDeliveryListResponse; + +import java.util.List; +import java.util.concurrent.CompletableFuture; +import java.util.function.Supplier; + +/** + * A page of {@link WebhookEndpointsEndpointsAsync#listDeliveries}: the {@link WebhookDelivery} + * items of one response, and the properties of its body, {@link WebhookDeliveryListResponse}. + */ +public final class WebhookEndpointsEndpointsListDeliveriesAsyncPage + extends AsyncPage { + private final WebhookDeliveryListResponse body; + + /** + * A page, built by the SDK. + * + * @param body the response body + * @param items the items of the page + * @param next fetches the next page, or null on the last page + */ + public WebhookEndpointsEndpointsListDeliveriesAsyncPage( + WebhookDeliveryListResponse body, + List items, + Supplier> next) { + super(items, next); + this.body = body; + } + + /** + * The response body, as received. + * + * @return the body + */ + public WebhookDeliveryListResponse body() { + return body; + } + + /** + * The {@code data} property. + * + * @return the value, never null + */ + public List data() { + return body.data(); + } + + /** + * The {@code pagination_meta} property. + * + * @return the value, never null + */ + public PaginationResponse paginationMeta() { + return body.paginationMeta(); + } + + @Override + public String toString() { + return "WebhookEndpointsEndpointsListDeliveriesAsyncPage{body=" + + body + + ", hasNextPage=" + + hasNextPage() + + "}"; + } +} diff --git a/src/main/java/com/meteroid/api/WebhookEndpointsEndpointsListDeliveriesOptions.java b/src/main/java/com/meteroid/api/WebhookEndpointsEndpointsListDeliveriesOptions.java new file mode 100644 index 0000000..0d09652 --- /dev/null +++ b/src/main/java/com/meteroid/api/WebhookEndpointsEndpointsListDeliveriesOptions.java @@ -0,0 +1,161 @@ +// this file is @generated +package com.meteroid.api; + +import com.meteroid.models.WebhookDeliveryStatus; + +import java.util.Objects; +import java.util.Optional; + +/** Optional parameters of {@code listDeliveries}, immutable: build them with {@link #builder()}. */ +public final class WebhookEndpointsEndpointsListDeliveriesOptions { + private final WebhookDeliveryStatus status; + private final Integer page; + private final Integer perPage; + + private WebhookEndpointsEndpointsListDeliveriesOptions(Builder builder) { + this.status = builder.status; + this.page = builder.page; + this.perPage = builder.perPage; + } + + /** + * A builder of parameters. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * No parameters. + * + * @return empty parameters + */ + public static WebhookEndpointsEndpointsListDeliveriesOptions none() { + return builder().build(); + } + + /** + * A builder starting from these parameters. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.status = status; + builder.page = page; + builder.perPage = perPage; + return builder; + } + + /** + * Only return deliveries in this state. + * + * @return the value, empty when unset + */ + public Optional status() { + return Optional.ofNullable(status); + } + + /** + * Page number (0-indexed) + * + * @return the value, empty when unset + */ + public Optional page() { + return Optional.ofNullable(page); + } + + /** + * Number of items per page + * + * @return the value, empty when unset + */ + public Optional perPage() { + return Optional.ofNullable(perPage); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + WebhookEndpointsEndpointsListDeliveriesOptions that = + (WebhookEndpointsEndpointsListDeliveriesOptions) o; + return Objects.equals(status, that.status) + && Objects.equals(page, that.page) + && Objects.equals(perPage, that.perPage); + } + + @Override + public int hashCode() { + return Objects.hash(status, page, perPage); + } + + @Override + public String toString() { + return "WebhookEndpointsEndpointsListDeliveriesOptions{" + + "status=" + + status + + ", page=" + + page + + ", perPage=" + + perPage + + "}"; + } + + /** Builds {@link WebhookEndpointsEndpointsListDeliveriesOptions}. */ + public static final class Builder { + private WebhookDeliveryStatus status; + private Integer page; + private Integer perPage; + + private Builder() {} + + /** + * Only return deliveries in this state. + * + * @param status the value, null to leave it out + * @return this builder + */ + public Builder status(WebhookDeliveryStatus status) { + this.status = status; + return this; + } + + /** + * Page number (0-indexed) + * + * @param page the value, null to leave it out + * @return this builder + */ + public Builder page(Integer page) { + this.page = page; + return this; + } + + /** + * Number of items per page + * + * @param perPage the value, null to leave it out + * @return this builder + */ + public Builder perPage(Integer perPage) { + this.perPage = perPage; + return this; + } + + /** + * The parameters. + * + * @return immutable parameters + */ + public WebhookEndpointsEndpointsListDeliveriesOptions build() { + return new WebhookEndpointsEndpointsListDeliveriesOptions(this); + } + } +} diff --git a/src/main/java/com/meteroid/api/WebhookEndpointsEndpointsListDeliveriesPage.java b/src/main/java/com/meteroid/api/WebhookEndpointsEndpointsListDeliveriesPage.java new file mode 100644 index 0000000..ccd40c8 --- /dev/null +++ b/src/main/java/com/meteroid/api/WebhookEndpointsEndpointsListDeliveriesPage.java @@ -0,0 +1,73 @@ +// this file is @generated +package com.meteroid.api; + +import com.meteroid.Page; +import com.meteroid.models.PaginationResponse; +import com.meteroid.models.WebhookDelivery; +import com.meteroid.models.WebhookDeliveryListResponse; + +import java.util.List; +import java.util.function.Supplier; + +/** + * A page of {@link WebhookEndpointsEndpoints#listDeliveries}: the {@link WebhookDelivery} items of + * one response, and the properties of its body, {@link WebhookDeliveryListResponse}. + * + *

Iterating it yields every item from this page on, fetching the next pages as the iteration + * goes. + */ +public final class WebhookEndpointsEndpointsListDeliveriesPage + extends Page { + private final WebhookDeliveryListResponse body; + + /** + * A page, built by the SDK. + * + * @param body the response body + * @param items the items of the page + * @param next fetches the next page, or null on the last page + */ + public WebhookEndpointsEndpointsListDeliveriesPage( + WebhookDeliveryListResponse body, + List items, + Supplier next) { + super(items, next); + this.body = body; + } + + /** + * The response body, as received. + * + * @return the body + */ + public WebhookDeliveryListResponse body() { + return body; + } + + /** + * The {@code data} property. + * + * @return the value, never null + */ + public List data() { + return body.data(); + } + + /** + * The {@code pagination_meta} property. + * + * @return the value, never null + */ + public PaginationResponse paginationMeta() { + return body.paginationMeta(); + } + + @Override + public String toString() { + return "WebhookEndpointsEndpointsListDeliveriesPage{body=" + + body + + ", hasNextPage=" + + hasNextPage() + + "}"; + } +} diff --git a/src/main/java/com/meteroid/models/CreateWebhookEndpointRequest.java b/src/main/java/com/meteroid/models/CreateWebhookEndpointRequest.java new file mode 100644 index 0000000..176c733 --- /dev/null +++ b/src/main/java/com/meteroid/models/CreateWebhookEndpointRequest.java @@ -0,0 +1,352 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.JsonField; +import com.meteroid.internal.Utils; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +/** Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonAutoDetect( + getterVisibility = Visibility.NONE, + isGetterVisibility = Visibility.NONE, + setterVisibility = Visibility.NONE) +public final class CreateWebhookEndpointRequest { + @JsonProperty("description") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField description = JsonField.missing(); + + @JsonProperty("event_types") + private List eventTypes; + + @JsonProperty("headers") + private List headers; + + @JsonProperty("rate_limit_per_sec") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField rateLimitPerSec = JsonField.missing(); + + @JsonProperty("url") + private String url; + + private final Map additionalProperties = new LinkedHashMap<>(); + + private CreateWebhookEndpointRequest() {} + + private CreateWebhookEndpointRequest(Builder builder) { + this.description = builder.description; + this.eventTypes = Utils.copyList(builder.eventTypes); + this.headers = Utils.copyList(builder.headers); + this.rateLimitPerSec = builder.rateLimitPerSec; + this.url = builder.url; + this.additionalProperties.putAll(builder.additionalProperties); + } + + /** + * A builder of {@code CreateWebhookEndpointRequest}. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * A builder starting from this value. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.description = description; + builder.eventTypes = Utils.mutableList(eventTypes); + builder.headers = Utils.mutableList(headers); + builder.rateLimitPerSec = rateLimitPerSec; + builder.url = url; + builder.additionalProperties.putAll(additionalProperties); + return builder; + } + + /** + * The {@code description} property. + * + * @return the value, empty when unset or null + */ + public Optional description() { + return description.asOptional(); + } + + /** + * Event types to subscribe to. Omit or leave empty to receive every event type. + * + * @return the value, empty when unset + */ + public Optional> eventTypes() { + return Optional.ofNullable(eventTypes); + } + + /** + * Custom headers sent with every delivery. + * + * @return the value, empty when unset + */ + public Optional> headers() { + return Optional.ofNullable(headers); + } + + /** + * Deliveries started per second, at most (1 to 1000). + * + * @return the value, empty when unset or null + */ + public Optional rateLimitPerSec() { + return rateLimitPerSec.asOptional(); + } + + /** + * HTTPS destination. Private and loopback addresses are rejected unless the instance is + * configured to allow them. + * + * @return the value, never null + */ + public String url() { + return Utils.required(url, "url"); + } + + /** + * Properties this version of the SDK does not know, kept as received and sent back. + * + * @return the properties by name, unmodifiable + */ + public Map additionalProperties() { + return Collections.unmodifiableMap(additionalProperties); + } + + @JsonAnyGetter + private Map anyProperties() { + return additionalProperties; + } + + @JsonAnySetter + private void putAnyProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CreateWebhookEndpointRequest that = (CreateWebhookEndpointRequest) o; + return Objects.equals(description, that.description) + && Objects.equals(eventTypes, that.eventTypes) + && Objects.equals(headers, that.headers) + && Objects.equals(rateLimitPerSec, that.rateLimitPerSec) + && Objects.equals(url, that.url) + && Objects.equals(additionalProperties, that.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash( + description, eventTypes, headers, rateLimitPerSec, url, additionalProperties); + } + + @Override + public String toString() { + return "CreateWebhookEndpointRequest{" + + "description=" + + description + + ", eventTypes=" + + eventTypes + + ", headers=" + + headers + + ", rateLimitPerSec=" + + rateLimitPerSec + + ", url=" + + url + + ", additionalProperties=" + + additionalProperties + + "}"; + } + + /** Builds {@link CreateWebhookEndpointRequest}. */ + public static final class Builder { + private JsonField description = JsonField.missing(); + private List eventTypes; + private List headers; + private JsonField rateLimitPerSec = JsonField.missing(); + private String url; + private final Map additionalProperties = new LinkedHashMap<>(); + + private Builder() {} + + /** + * The {@code description} property. + * + * @param description the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder description(String description) { + this.description = JsonField.ofNullable(description); + return this; + } + + /** + * Event types to subscribe to. Omit or leave empty to receive every event type. + * + * @param eventTypes the value + * @return this builder + */ + public Builder eventTypes(List eventTypes) { + this.eventTypes = Utils.mutableList(eventTypes); + return this; + } + + /** + * Adds an item to {@code event_types}. + * + * @param item the item + * @return this builder + */ + public Builder addEventTypesItem(String item) { + if (this.eventTypes == null) { + this.eventTypes = new ArrayList<>(); + } + this.eventTypes.add(item); + return this; + } + + /** + * Custom headers sent with every delivery. + * + * @param headers the value + * @return this builder + */ + public Builder headers(List headers) { + this.headers = Utils.mutableList(headers); + return this; + } + + /** + * Adds an item to {@code headers}. + * + * @param item the item + * @return this builder + */ + public Builder addHeadersItem(WebhookHeaderInput item) { + if (this.headers == null) { + this.headers = new ArrayList<>(); + } + this.headers.add(item); + return this; + } + + /** + * Deliveries started per second, at most (1 to 1000). + * + * @param rateLimitPerSec the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder rateLimitPerSec(Integer rateLimitPerSec) { + this.rateLimitPerSec = JsonField.ofNullable(rateLimitPerSec); + return this; + } + + /** + * HTTPS destination. Private and loopback addresses are rejected unless the instance is + * configured to allow them. + * + * @param url the value + * @return this builder + */ + public Builder url(String url) { + this.url = url; + return this; + } + + /** + * A property the SDK does not know, sent along. + * + * @param name the property name + * @param value the JSON value + * @return this builder + */ + public Builder putAdditionalProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + return this; + } + + /** + * Properties the SDK does not know, sent along. + * + * @param additionalProperties the properties by name + * @return this builder + */ + public Builder putAllAdditionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + + /** + * Leaves out a property the SDK does not know. + * + * @param name the property name + * @return this builder + */ + public Builder removeAdditionalProperty(String name) { + additionalProperties.remove(name); + return this; + } + + /** + * The {@code CreateWebhookEndpointRequest}. + * + * @return the immutable value + * @throws IllegalStateException when a required property is not set + */ + public CreateWebhookEndpointRequest build() { + Utils.checkRequired(url, "url"); + return new CreateWebhookEndpointRequest(this); + } + } + + /** + * Parse {@code json} as {@code CreateWebhookEndpointRequest}. + * + * @param json the JSON text + * @return the value + * @throws com.meteroid.exceptions.InvalidDataException if it is not valid JSON of this shape + */ + public static CreateWebhookEndpointRequest fromJson(String json) { + return Utils.parse(json, CreateWebhookEndpointRequest.class); + } + + /** + * This value as JSON. + * + * @return the JSON text + */ + public String toJson() { + return Utils.json(this); + } +} diff --git a/src/main/java/com/meteroid/models/CreatedWebhookEndpoint.java b/src/main/java/com/meteroid/models/CreatedWebhookEndpoint.java new file mode 100644 index 0000000..17d874e --- /dev/null +++ b/src/main/java/com/meteroid/models/CreatedWebhookEndpoint.java @@ -0,0 +1,227 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.Unions; +import com.meteroid.internal.Utils; + +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; + +/** + * The signing secret is returned in full here and never again outside the reveal and rotate + * endpoints. + * + *

Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonAutoDetect( + getterVisibility = Visibility.NONE, + isGetterVisibility = Visibility.NONE, + setterVisibility = Visibility.NONE) +public final class CreatedWebhookEndpoint { + @JsonProperty("secret") + private String secret; + + private final Map additionalProperties = new LinkedHashMap<>(); + + private CreatedWebhookEndpoint() {} + + private CreatedWebhookEndpoint(Builder builder) { + this.secret = builder.secret; + this.additionalProperties.putAll(builder.additionalProperties); + } + + /** + * A builder of {@code CreatedWebhookEndpoint}. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * A builder starting from this value. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.secret = secret; + builder.additionalProperties.putAll(additionalProperties); + return builder; + } + + /** + * The properties of {@link WebhookEndpoint}, which this schema extends. + * + * @return the properties of this part + */ + public WebhookEndpoint webhookEndpoint() { + return Unions.convert(additionalProperties, WebhookEndpoint.class); + } + + /** + * The {@code secret} property. + * + * @return the value, never null + */ + public String secret() { + return Utils.required(secret, "secret"); + } + + /** + * Properties this version of the SDK does not know, kept as received and sent back. + * + * @return the properties by name, unmodifiable + */ + public Map additionalProperties() { + Map unknown = new LinkedHashMap<>(additionalProperties); + unknown.keySet().retainAll(webhookEndpoint().additionalProperties().keySet()); + return Collections.unmodifiableMap(unknown); + } + + @JsonAnyGetter + private Map anyProperties() { + return additionalProperties; + } + + @JsonAnySetter + private void putAnyProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CreatedWebhookEndpoint that = (CreatedWebhookEndpoint) o; + return Objects.equals(secret, that.secret) + && Objects.equals(additionalProperties, that.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(secret, additionalProperties); + } + + @Override + public String toString() { + return "CreatedWebhookEndpoint{" + + "secret=" + + secret + + ", additionalProperties=" + + additionalProperties + + "}"; + } + + /** Builds {@link CreatedWebhookEndpoint}. */ + public static final class Builder { + private String secret; + private final Map additionalProperties = new LinkedHashMap<>(); + + private Builder() {} + + /** + * Sets the properties of {@link WebhookEndpoint}, which this schema extends. + * + * @param webhookEndpoint the properties + * @return this builder + */ + public Builder webhookEndpoint(WebhookEndpoint webhookEndpoint) { + additionalProperties.putAll(Utils.properties(webhookEndpoint)); + return this; + } + + /** + * The {@code secret} property. + * + * @param secret the value + * @return this builder + */ + public Builder secret(String secret) { + this.secret = secret; + return this; + } + + /** + * A property the SDK does not know, sent along. + * + * @param name the property name + * @param value the JSON value + * @return this builder + */ + public Builder putAdditionalProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + return this; + } + + /** + * Properties the SDK does not know, sent along. + * + * @param additionalProperties the properties by name + * @return this builder + */ + public Builder putAllAdditionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + + /** + * Leaves out a property the SDK does not know. + * + * @param name the property name + * @return this builder + */ + public Builder removeAdditionalProperty(String name) { + additionalProperties.remove(name); + return this; + } + + /** + * The {@code CreatedWebhookEndpoint}. + * + * @return the immutable value + * @throws IllegalStateException when a required property is not set + */ + public CreatedWebhookEndpoint build() { + Utils.checkRequired(secret, "secret"); + return new CreatedWebhookEndpoint(this); + } + } + + /** + * Parse {@code json} as {@code CreatedWebhookEndpoint}. + * + * @param json the JSON text + * @return the value + * @throws com.meteroid.exceptions.InvalidDataException if it is not valid JSON of this shape + */ + public static CreatedWebhookEndpoint fromJson(String json) { + return Utils.parse(json, CreatedWebhookEndpoint.class); + } + + /** + * This value as JSON. + * + * @return the JSON text + */ + public String toJson() { + return Utils.json(this); + } +} diff --git a/src/main/java/com/meteroid/models/CustomerCreateRequest.java b/src/main/java/com/meteroid/models/CustomerCreateRequest.java index 47b9b8f..8e09069 100644 --- a/src/main/java/com/meteroid/models/CustomerCreateRequest.java +++ b/src/main/java/com/meteroid/models/CustomerCreateRequest.java @@ -250,10 +250,10 @@ public Optional customProperties() { /** * The {@code custom_taxes} property. * - * @return the value, never null + * @return the value, empty when unset */ - public List customTaxes() { - return Utils.required(customTaxes, "custom_taxes"); + public Optional> customTaxes() { + return Optional.ofNullable(customTaxes); } /** @@ -287,10 +287,10 @@ public Optional firstName() { /** * The {@code invoicing_emails} property. * - * @return the value, never null + * @return the value, empty when unset */ - public List invoicingEmails() { - return Utils.required(invoicingEmails, "invoicing_emails"); + public Optional> invoicingEmails() { + return Optional.ofNullable(invoicingEmails); } /** @@ -889,8 +889,6 @@ public Builder removeAdditionalProperty(String name) { */ public CustomerCreateRequest build() { Utils.checkRequired(currency, "currency"); - Utils.checkRequired(customTaxes, "custom_taxes"); - Utils.checkRequired(invoicingEmails, "invoicing_emails"); return new CustomerCreateRequest(this); } } diff --git a/src/main/java/com/meteroid/models/Event.java b/src/main/java/com/meteroid/models/Event.java index 0a551bd..962ff98 100644 --- a/src/main/java/com/meteroid/models/Event.java +++ b/src/main/java/com/meteroid/models/Event.java @@ -9,8 +9,10 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.JsonField; import com.meteroid.internal.Utils; +import java.time.OffsetDateTime; import java.util.Collections; import java.util.LinkedHashMap; import java.util.Map; @@ -38,7 +40,8 @@ public final class Event { private Map properties; @JsonProperty("timestamp") - private String timestamp; + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField timestamp = JsonField.missing(); private final Map additionalProperties = new LinkedHashMap<>(); @@ -118,10 +121,10 @@ public Optional> properties() { * RFC 3339 timestamp. Defaults to ingestion time if omitted. Must be between 24 hours ago and 1 * hour from now. Set allow_backfilling to remove the past limit. * - * @return the value, never null + * @return the value, empty when unset or null */ - public String timestamp() { - return Utils.required(timestamp, "timestamp"); + public Optional timestamp() { + return timestamp.asOptional(); } /** @@ -189,7 +192,7 @@ public static final class Builder { private String customerId; private String eventId; private Map properties; - private String timestamp; + private JsonField timestamp = JsonField.missing(); private final Map additionalProperties = new LinkedHashMap<>(); private Builder() {} @@ -257,11 +260,11 @@ public Builder putPropertiesItem(String key, String item) { * RFC 3339 timestamp. Defaults to ingestion time if omitted. Must be between 24 hours ago * and 1 hour from now. Set allow_backfilling to remove the past limit. * - * @param timestamp the value + * @param timestamp the value, null to send an explicit {@code null} * @return this builder */ - public Builder timestamp(String timestamp) { - this.timestamp = timestamp; + public Builder timestamp(OffsetDateTime timestamp) { + this.timestamp = JsonField.ofNullable(timestamp); return this; } @@ -309,7 +312,6 @@ public Event build() { Utils.checkRequired(code, "code"); Utils.checkRequired(customerId, "customer_id"); Utils.checkRequired(eventId, "event_id"); - Utils.checkRequired(timestamp, "timestamp"); return new Event(this); } } diff --git a/src/main/java/com/meteroid/models/Plan.java b/src/main/java/com/meteroid/models/Plan.java index 6a849d3..7e1bb77 100644 --- a/src/main/java/com/meteroid/models/Plan.java +++ b/src/main/java/com/meteroid/models/Plan.java @@ -40,7 +40,7 @@ public final class Plan { private OffsetDateTime createdAt; @JsonProperty("currency") - private String currency; + private Currency currency; @JsonProperty("description") @JsonInclude(JsonInclude.Include.NON_EMPTY) @@ -195,7 +195,7 @@ public OffsetDateTime createdAt() { * * @return the value, never null */ - public String currency() { + public Currency currency() { return Utils.required(currency, "currency"); } @@ -476,7 +476,7 @@ public static final class Builder { private AvailableParameters availableParameters; private JsonField billingCycles = JsonField.missing(); private OffsetDateTime createdAt; - private String currency; + private Currency currency; private JsonField description = JsonField.missing(); private List entitlements; private String id; @@ -536,7 +536,7 @@ public Builder createdAt(OffsetDateTime createdAt) { * @param currency the value * @return this builder */ - public Builder currency(String currency) { + public Builder currency(Currency currency) { this.currency = currency; return this; } diff --git a/src/main/java/com/meteroid/models/PlanVersionSummary.java b/src/main/java/com/meteroid/models/PlanVersionSummary.java index 951bfa3..f0ab84f 100644 --- a/src/main/java/com/meteroid/models/PlanVersionSummary.java +++ b/src/main/java/com/meteroid/models/PlanVersionSummary.java @@ -29,7 +29,7 @@ public final class PlanVersionSummary { private OffsetDateTime createdAt; @JsonProperty("currency") - private String currency; + private Currency currency; @JsonProperty("id") private String id; @@ -92,7 +92,7 @@ public OffsetDateTime createdAt() { * * @return the value, never null */ - public String currency() { + public Currency currency() { return Utils.required(currency, "currency"); } @@ -185,7 +185,7 @@ public String toString() { /** Builds {@link PlanVersionSummary}. */ public static final class Builder { private OffsetDateTime createdAt; - private String currency; + private Currency currency; private String id; private Boolean isDraft; private Integer version; @@ -210,7 +210,7 @@ public Builder createdAt(OffsetDateTime createdAt) { * @param currency the value * @return this builder */ - public Builder currency(String currency) { + public Builder currency(Currency currency) { this.currency = currency; return this; } diff --git a/src/main/java/com/meteroid/models/UpdateWebhookEndpointRequest.java b/src/main/java/com/meteroid/models/UpdateWebhookEndpointRequest.java new file mode 100644 index 0000000..5eb4568 --- /dev/null +++ b/src/main/java/com/meteroid/models/UpdateWebhookEndpointRequest.java @@ -0,0 +1,392 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.JsonField; +import com.meteroid.internal.Utils; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +/** Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonAutoDetect( + getterVisibility = Visibility.NONE, + isGetterVisibility = Visibility.NONE, + setterVisibility = Visibility.NONE) +public final class UpdateWebhookEndpointRequest { + @JsonProperty("description") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField description = JsonField.missing(); + + @JsonProperty("disabled") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField disabled = JsonField.missing(); + + @JsonProperty("event_types") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField> eventTypes = JsonField.missing(); + + @JsonProperty("headers") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField> headers = JsonField.missing(); + + @JsonProperty("rate_limit_per_sec") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField rateLimitPerSec = JsonField.missing(); + + @JsonProperty("url") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField url = JsonField.missing(); + + private final Map additionalProperties = new LinkedHashMap<>(); + + private UpdateWebhookEndpointRequest() {} + + private UpdateWebhookEndpointRequest(Builder builder) { + this.description = builder.description; + this.disabled = builder.disabled; + this.eventTypes = builder.eventTypes.map(Utils::copyList); + this.headers = builder.headers.map(Utils::copyList); + this.rateLimitPerSec = builder.rateLimitPerSec; + this.url = builder.url; + this.additionalProperties.putAll(builder.additionalProperties); + } + + /** + * A builder of {@code UpdateWebhookEndpointRequest}. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * A builder starting from this value. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.description = description; + builder.disabled = disabled; + builder.eventTypes = eventTypes.map(Utils::mutableList); + builder.headers = headers.map(Utils::mutableList); + builder.rateLimitPerSec = rateLimitPerSec; + builder.url = url; + builder.additionalProperties.putAll(additionalProperties); + return builder; + } + + /** + * Omit to leave unchanged; send null or an empty string to clear. + * + * @return the value, empty when unset or null + */ + public Optional description() { + return description.asOptional(); + } + + /** + * Re-enabling an endpoint also resets its consecutive failure count. + * + * @return the value, empty when unset or null + */ + public Optional disabled() { + return disabled.asOptional(); + } + + /** + * Replaces the subscription list. An empty array subscribes to every event type. + * + * @return the value, empty when unset or null + */ + public Optional> eventTypes() { + return eventTypes.asOptional(); + } + + /** + * Replaces the custom header list. An empty array removes every header. + * + * @return the value, empty when unset or null + */ + public Optional> headers() { + return headers.asOptional(); + } + + /** + * Omit to leave unchanged; send null to remove the rate limit. + * + * @return the value, empty when unset or null + */ + public Optional rateLimitPerSec() { + return rateLimitPerSec.asOptional(); + } + + /** + * The {@code url} property. + * + * @return the value, empty when unset or null + */ + public Optional url() { + return url.asOptional(); + } + + /** + * Properties this version of the SDK does not know, kept as received and sent back. + * + * @return the properties by name, unmodifiable + */ + public Map additionalProperties() { + return Collections.unmodifiableMap(additionalProperties); + } + + @JsonAnyGetter + private Map anyProperties() { + return additionalProperties; + } + + @JsonAnySetter + private void putAnyProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + UpdateWebhookEndpointRequest that = (UpdateWebhookEndpointRequest) o; + return Objects.equals(description, that.description) + && Objects.equals(disabled, that.disabled) + && Objects.equals(eventTypes, that.eventTypes) + && Objects.equals(headers, that.headers) + && Objects.equals(rateLimitPerSec, that.rateLimitPerSec) + && Objects.equals(url, that.url) + && Objects.equals(additionalProperties, that.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash( + description, + disabled, + eventTypes, + headers, + rateLimitPerSec, + url, + additionalProperties); + } + + @Override + public String toString() { + return "UpdateWebhookEndpointRequest{" + + "description=" + + description + + ", disabled=" + + disabled + + ", eventTypes=" + + eventTypes + + ", headers=" + + headers + + ", rateLimitPerSec=" + + rateLimitPerSec + + ", url=" + + url + + ", additionalProperties=" + + additionalProperties + + "}"; + } + + /** Builds {@link UpdateWebhookEndpointRequest}. */ + public static final class Builder { + private JsonField description = JsonField.missing(); + private JsonField disabled = JsonField.missing(); + private JsonField> eventTypes = JsonField.missing(); + private JsonField> headers = JsonField.missing(); + private JsonField rateLimitPerSec = JsonField.missing(); + private JsonField url = JsonField.missing(); + private final Map additionalProperties = new LinkedHashMap<>(); + + private Builder() {} + + /** + * Omit to leave unchanged; send null or an empty string to clear. + * + * @param description the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder description(String description) { + this.description = JsonField.ofNullable(description); + return this; + } + + /** + * Re-enabling an endpoint also resets its consecutive failure count. + * + * @param disabled the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder disabled(Boolean disabled) { + this.disabled = JsonField.ofNullable(disabled); + return this; + } + + /** + * Replaces the subscription list. An empty array subscribes to every event type. + * + * @param eventTypes the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder eventTypes(List eventTypes) { + this.eventTypes = JsonField.ofNullable(Utils.mutableList(eventTypes)); + return this; + } + + /** + * Adds an item to {@code event_types}. + * + * @param item the item + * @return this builder + */ + public Builder addEventTypesItem(String item) { + List items = this.eventTypes.orNull(); + if (items == null) { + items = new ArrayList<>(); + this.eventTypes = JsonField.ofNullable(items); + } + items.add(item); + return this; + } + + /** + * Replaces the custom header list. An empty array removes every header. + * + * @param headers the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder headers(List headers) { + this.headers = JsonField.ofNullable(Utils.mutableList(headers)); + return this; + } + + /** + * Adds an item to {@code headers}. + * + * @param item the item + * @return this builder + */ + public Builder addHeadersItem(WebhookHeaderInput item) { + List items = this.headers.orNull(); + if (items == null) { + items = new ArrayList<>(); + this.headers = JsonField.ofNullable(items); + } + items.add(item); + return this; + } + + /** + * Omit to leave unchanged; send null to remove the rate limit. + * + * @param rateLimitPerSec the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder rateLimitPerSec(Integer rateLimitPerSec) { + this.rateLimitPerSec = JsonField.ofNullable(rateLimitPerSec); + return this; + } + + /** + * The {@code url} property. + * + * @param url the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder url(String url) { + this.url = JsonField.ofNullable(url); + return this; + } + + /** + * A property the SDK does not know, sent along. + * + * @param name the property name + * @param value the JSON value + * @return this builder + */ + public Builder putAdditionalProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + return this; + } + + /** + * Properties the SDK does not know, sent along. + * + * @param additionalProperties the properties by name + * @return this builder + */ + public Builder putAllAdditionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + + /** + * Leaves out a property the SDK does not know. + * + * @param name the property name + * @return this builder + */ + public Builder removeAdditionalProperty(String name) { + additionalProperties.remove(name); + return this; + } + + /** + * The {@code UpdateWebhookEndpointRequest}. + * + * @return the immutable value + * @throws IllegalStateException when a required property is not set + */ + public UpdateWebhookEndpointRequest build() { + return new UpdateWebhookEndpointRequest(this); + } + } + + /** + * Parse {@code json} as {@code UpdateWebhookEndpointRequest}. + * + * @param json the JSON text + * @return the value + * @throws com.meteroid.exceptions.InvalidDataException if it is not valid JSON of this shape + */ + public static UpdateWebhookEndpointRequest fromJson(String json) { + return Utils.parse(json, UpdateWebhookEndpointRequest.class); + } + + /** + * This value as JSON. + * + * @return the JSON text + */ + public String toJson() { + return Utils.json(this); + } +} diff --git a/src/main/java/com/meteroid/models/WebhookDelivery.java b/src/main/java/com/meteroid/models/WebhookDelivery.java new file mode 100644 index 0000000..e0ed965 --- /dev/null +++ b/src/main/java/com/meteroid/models/WebhookDelivery.java @@ -0,0 +1,549 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.JsonField; +import com.meteroid.internal.Utils; + +import java.time.OffsetDateTime; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +/** + * One event queued for one endpoint, with the state of its retry cycle. + * + *

Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonAutoDetect( + getterVisibility = Visibility.NONE, + isGetterVisibility = Visibility.NONE, + setterVisibility = Visibility.NONE) +public final class WebhookDelivery { + @JsonProperty("attempt_count") + private Integer attemptCount; + + @JsonProperty("completed_at") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField completedAt = JsonField.missing(); + + @JsonProperty("created_at") + private OffsetDateTime createdAt; + + @JsonProperty("endpoint_id") + private String endpointId; + + @JsonProperty("event_type") + private String eventType; + + @JsonProperty("id") + private String id; + + @JsonProperty("last_error") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField lastError = JsonField.missing(); + + @JsonProperty("last_response_status") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField lastResponseStatus = JsonField.missing(); + + @JsonProperty("manual") + private Boolean manual; + + @JsonProperty("message_id") + private String messageId; + + @JsonProperty("next_attempt_at") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField nextAttemptAt = JsonField.missing(); + + @JsonProperty("status") + private WebhookDeliveryStatus status; + + private final Map additionalProperties = new LinkedHashMap<>(); + + private WebhookDelivery() {} + + private WebhookDelivery(Builder builder) { + this.attemptCount = builder.attemptCount; + this.completedAt = builder.completedAt; + this.createdAt = builder.createdAt; + this.endpointId = builder.endpointId; + this.eventType = builder.eventType; + this.id = builder.id; + this.lastError = builder.lastError; + this.lastResponseStatus = builder.lastResponseStatus; + this.manual = builder.manual; + this.messageId = builder.messageId; + this.nextAttemptAt = builder.nextAttemptAt; + this.status = builder.status; + this.additionalProperties.putAll(builder.additionalProperties); + } + + /** + * A builder of {@code WebhookDelivery}. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * A builder starting from this value. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.attemptCount = attemptCount; + builder.completedAt = completedAt; + builder.createdAt = createdAt; + builder.endpointId = endpointId; + builder.eventType = eventType; + builder.id = id; + builder.lastError = lastError; + builder.lastResponseStatus = lastResponseStatus; + builder.manual = manual; + builder.messageId = messageId; + builder.nextAttemptAt = nextAttemptAt; + builder.status = status; + builder.additionalProperties.putAll(additionalProperties); + return builder; + } + + /** + * The {@code attempt_count} property. + * + * @return the value, never null + */ + public Integer attemptCount() { + return Utils.required(attemptCount, "attempt_count"); + } + + /** + * The {@code completed_at} property. + * + * @return the value, empty when unset or null + */ + public Optional completedAt() { + return completedAt.asOptional(); + } + + /** + * The {@code created_at} property. + * + * @return the value, never null + */ + public OffsetDateTime createdAt() { + return Utils.required(createdAt, "created_at"); + } + + /** + * The {@code endpoint_id} property. + * + * @return the value, never null + */ + public String endpointId() { + return Utils.required(endpointId, "endpoint_id"); + } + + /** + * The {@code event_type} property. + * + * @return the value, never null + */ + public String eventType() { + return Utils.required(eventType, "event_type"); + } + + /** + * The {@code id} property. + * + * @return the value, never null + */ + public String id() { + return Utils.required(id, "id"); + } + + /** + * The {@code last_error} property. + * + * @return the value, empty when unset or null + */ + public Optional lastError() { + return lastError.asOptional(); + } + + /** + * The {@code last_response_status} property. + * + * @return the value, empty when unset or null + */ + public Optional lastResponseStatus() { + return lastResponseStatus.asOptional(); + } + + /** + * True when the delivery was created by a resend or a test event. + * + * @return the value, never null + */ + public Boolean manual() { + return Utils.required(manual, "manual"); + } + + /** + * The {@code message_id} property. + * + * @return the value, never null + */ + public String messageId() { + return Utils.required(messageId, "message_id"); + } + + /** + * The {@code next_attempt_at} property. + * + * @return the value, empty when unset or null + */ + public Optional nextAttemptAt() { + return nextAttemptAt.asOptional(); + } + + /** + * The {@code status} property. + * + * @return the value, never null + */ + public WebhookDeliveryStatus status() { + return Utils.required(status, "status"); + } + + /** + * Properties this version of the SDK does not know, kept as received and sent back. + * + * @return the properties by name, unmodifiable + */ + public Map additionalProperties() { + return Collections.unmodifiableMap(additionalProperties); + } + + @JsonAnyGetter + private Map anyProperties() { + return additionalProperties; + } + + @JsonAnySetter + private void putAnyProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + WebhookDelivery that = (WebhookDelivery) o; + return Objects.equals(attemptCount, that.attemptCount) + && Objects.equals(completedAt, that.completedAt) + && Objects.equals(createdAt, that.createdAt) + && Objects.equals(endpointId, that.endpointId) + && Objects.equals(eventType, that.eventType) + && Objects.equals(id, that.id) + && Objects.equals(lastError, that.lastError) + && Objects.equals(lastResponseStatus, that.lastResponseStatus) + && Objects.equals(manual, that.manual) + && Objects.equals(messageId, that.messageId) + && Objects.equals(nextAttemptAt, that.nextAttemptAt) + && Objects.equals(status, that.status) + && Objects.equals(additionalProperties, that.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash( + attemptCount, + completedAt, + createdAt, + endpointId, + eventType, + id, + lastError, + lastResponseStatus, + manual, + messageId, + nextAttemptAt, + status, + additionalProperties); + } + + @Override + public String toString() { + return "WebhookDelivery{" + + "attemptCount=" + + attemptCount + + ", completedAt=" + + completedAt + + ", createdAt=" + + createdAt + + ", endpointId=" + + endpointId + + ", eventType=" + + eventType + + ", id=" + + id + + ", lastError=" + + lastError + + ", lastResponseStatus=" + + lastResponseStatus + + ", manual=" + + manual + + ", messageId=" + + messageId + + ", nextAttemptAt=" + + nextAttemptAt + + ", status=" + + status + + ", additionalProperties=" + + additionalProperties + + "}"; + } + + /** Builds {@link WebhookDelivery}. */ + public static final class Builder { + private Integer attemptCount; + private JsonField completedAt = JsonField.missing(); + private OffsetDateTime createdAt; + private String endpointId; + private String eventType; + private String id; + private JsonField lastError = JsonField.missing(); + private JsonField lastResponseStatus = JsonField.missing(); + private Boolean manual; + private String messageId; + private JsonField nextAttemptAt = JsonField.missing(); + private WebhookDeliveryStatus status; + private final Map additionalProperties = new LinkedHashMap<>(); + + private Builder() {} + + /** + * The {@code attempt_count} property. + * + * @param attemptCount the value + * @return this builder + */ + public Builder attemptCount(Integer attemptCount) { + this.attemptCount = attemptCount; + return this; + } + + /** + * The {@code completed_at} property. + * + * @param completedAt the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder completedAt(OffsetDateTime completedAt) { + this.completedAt = JsonField.ofNullable(completedAt); + return this; + } + + /** + * The {@code created_at} property. + * + * @param createdAt the value + * @return this builder + */ + public Builder createdAt(OffsetDateTime createdAt) { + this.createdAt = createdAt; + return this; + } + + /** + * The {@code endpoint_id} property. + * + * @param endpointId the value + * @return this builder + */ + public Builder endpointId(String endpointId) { + this.endpointId = endpointId; + return this; + } + + /** + * The {@code event_type} property. + * + * @param eventType the value + * @return this builder + */ + public Builder eventType(String eventType) { + this.eventType = eventType; + return this; + } + + /** + * The {@code id} property. + * + * @param id the value + * @return this builder + */ + public Builder id(String id) { + this.id = id; + return this; + } + + /** + * The {@code last_error} property. + * + * @param lastError the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder lastError(String lastError) { + this.lastError = JsonField.ofNullable(lastError); + return this; + } + + /** + * The {@code last_response_status} property. + * + * @param lastResponseStatus the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder lastResponseStatus(Integer lastResponseStatus) { + this.lastResponseStatus = JsonField.ofNullable(lastResponseStatus); + return this; + } + + /** + * True when the delivery was created by a resend or a test event. + * + * @param manual the value + * @return this builder + */ + public Builder manual(Boolean manual) { + this.manual = manual; + return this; + } + + /** + * The {@code message_id} property. + * + * @param messageId the value + * @return this builder + */ + public Builder messageId(String messageId) { + this.messageId = messageId; + return this; + } + + /** + * The {@code next_attempt_at} property. + * + * @param nextAttemptAt the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder nextAttemptAt(OffsetDateTime nextAttemptAt) { + this.nextAttemptAt = JsonField.ofNullable(nextAttemptAt); + return this; + } + + /** + * The {@code status} property. + * + * @param status the value + * @return this builder + */ + public Builder status(WebhookDeliveryStatus status) { + this.status = status; + return this; + } + + /** + * A property the SDK does not know, sent along. + * + * @param name the property name + * @param value the JSON value + * @return this builder + */ + public Builder putAdditionalProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + return this; + } + + /** + * Properties the SDK does not know, sent along. + * + * @param additionalProperties the properties by name + * @return this builder + */ + public Builder putAllAdditionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + + /** + * Leaves out a property the SDK does not know. + * + * @param name the property name + * @return this builder + */ + public Builder removeAdditionalProperty(String name) { + additionalProperties.remove(name); + return this; + } + + /** + * The {@code WebhookDelivery}. + * + * @return the immutable value + * @throws IllegalStateException when a required property is not set + */ + public WebhookDelivery build() { + Utils.checkRequired(attemptCount, "attempt_count"); + Utils.checkRequired(createdAt, "created_at"); + Utils.checkRequired(endpointId, "endpoint_id"); + Utils.checkRequired(eventType, "event_type"); + Utils.checkRequired(id, "id"); + Utils.checkRequired(manual, "manual"); + Utils.checkRequired(messageId, "message_id"); + Utils.checkRequired(status, "status"); + return new WebhookDelivery(this); + } + } + + /** + * Parse {@code json} as {@code WebhookDelivery}. + * + * @param json the JSON text + * @return the value + * @throws com.meteroid.exceptions.InvalidDataException if it is not valid JSON of this shape + */ + public static WebhookDelivery fromJson(String json) { + return Utils.parse(json, WebhookDelivery.class); + } + + /** + * This value as JSON. + * + * @return the JSON text + */ + public String toJson() { + return Utils.json(this); + } +} diff --git a/src/main/java/com/meteroid/models/WebhookDeliveryListResponse.java b/src/main/java/com/meteroid/models/WebhookDeliveryListResponse.java new file mode 100644 index 0000000..d76d64e --- /dev/null +++ b/src/main/java/com/meteroid/models/WebhookDeliveryListResponse.java @@ -0,0 +1,245 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.Utils; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonAutoDetect( + getterVisibility = Visibility.NONE, + isGetterVisibility = Visibility.NONE, + setterVisibility = Visibility.NONE) +public final class WebhookDeliveryListResponse { + @JsonProperty("data") + private List data; + + @JsonProperty("pagination_meta") + private PaginationResponse paginationMeta; + + private final Map additionalProperties = new LinkedHashMap<>(); + + private WebhookDeliveryListResponse() {} + + private WebhookDeliveryListResponse(Builder builder) { + this.data = Utils.copyList(builder.data); + this.paginationMeta = builder.paginationMeta; + this.additionalProperties.putAll(builder.additionalProperties); + } + + /** + * A builder of {@code WebhookDeliveryListResponse}. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * A builder starting from this value. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.data = Utils.mutableList(data); + builder.paginationMeta = paginationMeta; + builder.additionalProperties.putAll(additionalProperties); + return builder; + } + + /** + * The {@code data} property. + * + * @return the value, never null + */ + public List data() { + return Utils.required(data, "data"); + } + + /** + * The {@code pagination_meta} property. + * + * @return the value, never null + */ + public PaginationResponse paginationMeta() { + return Utils.required(paginationMeta, "pagination_meta"); + } + + /** + * Properties this version of the SDK does not know, kept as received and sent back. + * + * @return the properties by name, unmodifiable + */ + public Map additionalProperties() { + return Collections.unmodifiableMap(additionalProperties); + } + + @JsonAnyGetter + private Map anyProperties() { + return additionalProperties; + } + + @JsonAnySetter + private void putAnyProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + WebhookDeliveryListResponse that = (WebhookDeliveryListResponse) o; + return Objects.equals(data, that.data) + && Objects.equals(paginationMeta, that.paginationMeta) + && Objects.equals(additionalProperties, that.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(data, paginationMeta, additionalProperties); + } + + @Override + public String toString() { + return "WebhookDeliveryListResponse{" + + "data=" + + data + + ", paginationMeta=" + + paginationMeta + + ", additionalProperties=" + + additionalProperties + + "}"; + } + + /** Builds {@link WebhookDeliveryListResponse}. */ + public static final class Builder { + private List data; + private PaginationResponse paginationMeta; + private final Map additionalProperties = new LinkedHashMap<>(); + + private Builder() {} + + /** + * The {@code data} property. + * + * @param data the value + * @return this builder + */ + public Builder data(List data) { + this.data = Utils.mutableList(data); + return this; + } + + /** + * Adds an item to {@code data}. + * + * @param item the item + * @return this builder + */ + public Builder addDataItem(WebhookDelivery item) { + if (this.data == null) { + this.data = new ArrayList<>(); + } + this.data.add(item); + return this; + } + + /** + * The {@code pagination_meta} property. + * + * @param paginationMeta the value + * @return this builder + */ + public Builder paginationMeta(PaginationResponse paginationMeta) { + this.paginationMeta = paginationMeta; + return this; + } + + /** + * A property the SDK does not know, sent along. + * + * @param name the property name + * @param value the JSON value + * @return this builder + */ + public Builder putAdditionalProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + return this; + } + + /** + * Properties the SDK does not know, sent along. + * + * @param additionalProperties the properties by name + * @return this builder + */ + public Builder putAllAdditionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + + /** + * Leaves out a property the SDK does not know. + * + * @param name the property name + * @return this builder + */ + public Builder removeAdditionalProperty(String name) { + additionalProperties.remove(name); + return this; + } + + /** + * The {@code WebhookDeliveryListResponse}. + * + * @return the immutable value + * @throws IllegalStateException when a required property is not set + */ + public WebhookDeliveryListResponse build() { + Utils.checkRequired(data, "data"); + Utils.checkRequired(paginationMeta, "pagination_meta"); + return new WebhookDeliveryListResponse(this); + } + } + + /** + * Parse {@code json} as {@code WebhookDeliveryListResponse}. + * + * @param json the JSON text + * @return the value + * @throws com.meteroid.exceptions.InvalidDataException if it is not valid JSON of this shape + */ + public static WebhookDeliveryListResponse fromJson(String json) { + return Utils.parse(json, WebhookDeliveryListResponse.class); + } + + /** + * This value as JSON. + * + * @return the JSON text + */ + public String toJson() { + return Utils.json(this); + } +} diff --git a/src/main/java/com/meteroid/models/WebhookDeliveryStatus.java b/src/main/java/com/meteroid/models/WebhookDeliveryStatus.java new file mode 100644 index 0000000..300be53 --- /dev/null +++ b/src/main/java/com/meteroid/models/WebhookDeliveryStatus.java @@ -0,0 +1,157 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import com.meteroid.internal.Utils.ToQueryParam; + +import java.util.Map; +import java.util.Objects; + +/** + * Values this version of the SDK does not know are kept, and sent back unchanged: {@link #value()} + * is an enum to switch on, {@code _UNKNOWN} for them, and {@link #known()} throws on them. + */ +public final class WebhookDeliveryStatus implements ToQueryParam { + /** The value {@code "PENDING"}. */ + public static final WebhookDeliveryStatus PENDING = + new WebhookDeliveryStatus("PENDING", Value.PENDING); + + /** The value {@code "IN_FLIGHT"}. */ + public static final WebhookDeliveryStatus IN_FLIGHT = + new WebhookDeliveryStatus("IN_FLIGHT", Value.IN_FLIGHT); + + /** The value {@code "SUCCEEDED"}. */ + public static final WebhookDeliveryStatus SUCCEEDED = + new WebhookDeliveryStatus("SUCCEEDED", Value.SUCCEEDED); + + /** The value {@code "FAILED"}. */ + public static final WebhookDeliveryStatus FAILED = + new WebhookDeliveryStatus("FAILED", Value.FAILED); + + /** The value {@code "CANCELLED"}. */ + public static final WebhookDeliveryStatus CANCELLED = + new WebhookDeliveryStatus("CANCELLED", Value.CANCELLED); + + private static final Map constants = + Map.ofEntries( + Map.entry("PENDING", PENDING), + Map.entry("IN_FLIGHT", IN_FLIGHT), + Map.entry("SUCCEEDED", SUCCEEDED), + Map.entry("FAILED", FAILED), + Map.entry("CANCELLED", CANCELLED)); + + private final String value; + private final Value variant; + + private WebhookDeliveryStatus(String value, Value variant) { + this.value = value; + this.variant = variant; + } + + /** + * The constant for {@code value}, or an unknown WebhookDeliveryStatus holding it. + * + * @param value the value + * @return the constant + */ + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static WebhookDeliveryStatus of(String value) { + WebhookDeliveryStatus constant = constants.get(Objects.requireNonNull(value, "value")); + return constant != null ? constant : new WebhookDeliveryStatus(value, Value._UNKNOWN); + } + + /** + * The value as sent. + * + * @return the value + */ + @JsonValue + public String asString() { + return value; + } + + /** + * Whether this version of the SDK knows the value. + * + * @return whether it is known + */ + public boolean isKnown() { + return variant != Value._UNKNOWN; + } + + /** + * The value as an enum to switch on, unknown values included. + * + * @return the enum, {@code _UNKNOWN} when unknown + */ + public Value value() { + return variant; + } + + /** + * The value as an enum of the known values only. + * + * @return the enum + * @throws com.meteroid.exceptions.InvalidDataException when this version of the SDK does not + * know the value + */ + public Known known() { + if (!isKnown()) { + throw new com.meteroid.exceptions.InvalidDataException( + "unknown WebhookDeliveryStatus: " + value); + } + return Known.valueOf(variant.name()); + } + + @Override + public String toQueryParam() { + return String.valueOf(value); + } + + @Override + public boolean equals(Object o) { + return o instanceof WebhookDeliveryStatus + && Objects.equals(value, ((WebhookDeliveryStatus) o).value); + } + + @Override + public int hashCode() { + return Objects.hashCode(value); + } + + @Override + public String toString() { + return String.valueOf(value); + } + + /** The values this version of the SDK knows. */ + public enum Known { + /** The {@code PENDING} constant. */ + PENDING, + /** The {@code IN_FLIGHT} constant. */ + IN_FLIGHT, + /** The {@code SUCCEEDED} constant. */ + SUCCEEDED, + /** The {@code FAILED} constant. */ + FAILED, + /** The {@code CANCELLED} constant. */ + CANCELLED + } + + /** The values this version of the SDK knows, and {@code _UNKNOWN} for the others. */ + public enum Value { + /** The {@code PENDING} constant. */ + PENDING, + /** The {@code IN_FLIGHT} constant. */ + IN_FLIGHT, + /** The {@code SUCCEEDED} constant. */ + SUCCEEDED, + /** The {@code FAILED} constant. */ + FAILED, + /** The {@code CANCELLED} constant. */ + CANCELLED, + /** A value this version of the SDK does not know. */ + _UNKNOWN + } +} diff --git a/src/main/java/com/meteroid/models/WebhookEndpoint.java b/src/main/java/com/meteroid/models/WebhookEndpoint.java new file mode 100644 index 0000000..fea34c2 --- /dev/null +++ b/src/main/java/com/meteroid/models/WebhookEndpoint.java @@ -0,0 +1,708 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.JsonField; +import com.meteroid.internal.Utils; + +import java.time.OffsetDateTime; +import java.util.ArrayList; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +/** + * A destination Meteroid POSTs signed event payloads to. + * + *

Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonAutoDetect( + getterVisibility = Visibility.NONE, + isGetterVisibility = Visibility.NONE, + setterVisibility = Visibility.NONE) +public final class WebhookEndpoint { + @JsonProperty("consecutive_failures") + private Integer consecutiveFailures; + + @JsonProperty("created_at") + private OffsetDateTime createdAt; + + @JsonProperty("description") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField description = JsonField.missing(); + + @JsonProperty("disabled") + private Boolean disabled; + + @JsonProperty("disabled_reason") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField disabledReason = JsonField.missing(); + + @JsonProperty("event_types") + private List eventTypes; + + @JsonProperty("headers") + private List headers; + + @JsonProperty("id") + private String id; + + @JsonProperty("last_failure_at") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField lastFailureAt = JsonField.missing(); + + @JsonProperty("last_success_at") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField lastSuccessAt = JsonField.missing(); + + @JsonProperty("max_in_flight") + private Integer maxInFlight; + + @JsonProperty("needs_setup") + private Boolean needsSetup; + + @JsonProperty("paused_until") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField pausedUntil = JsonField.missing(); + + @JsonProperty("rate_limit_per_sec") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField rateLimitPerSec = JsonField.missing(); + + @JsonProperty("updated_at") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField updatedAt = JsonField.missing(); + + @JsonProperty("url") + private String url; + + private final Map additionalProperties = new LinkedHashMap<>(); + + private WebhookEndpoint() {} + + private WebhookEndpoint(Builder builder) { + this.consecutiveFailures = builder.consecutiveFailures; + this.createdAt = builder.createdAt; + this.description = builder.description; + this.disabled = builder.disabled; + this.disabledReason = builder.disabledReason; + this.eventTypes = Utils.copyList(builder.eventTypes); + this.headers = Utils.copyList(builder.headers); + this.id = builder.id; + this.lastFailureAt = builder.lastFailureAt; + this.lastSuccessAt = builder.lastSuccessAt; + this.maxInFlight = builder.maxInFlight; + this.needsSetup = builder.needsSetup; + this.pausedUntil = builder.pausedUntil; + this.rateLimitPerSec = builder.rateLimitPerSec; + this.updatedAt = builder.updatedAt; + this.url = builder.url; + this.additionalProperties.putAll(builder.additionalProperties); + } + + /** + * A builder of {@code WebhookEndpoint}. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * A builder starting from this value. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.consecutiveFailures = consecutiveFailures; + builder.createdAt = createdAt; + builder.description = description; + builder.disabled = disabled; + builder.disabledReason = disabledReason; + builder.eventTypes = Utils.mutableList(eventTypes); + builder.headers = Utils.mutableList(headers); + builder.id = id; + builder.lastFailureAt = lastFailureAt; + builder.lastSuccessAt = lastSuccessAt; + builder.maxInFlight = maxInFlight; + builder.needsSetup = needsSetup; + builder.pausedUntil = pausedUntil; + builder.rateLimitPerSec = rateLimitPerSec; + builder.updatedAt = updatedAt; + builder.url = url; + builder.additionalProperties.putAll(additionalProperties); + return builder; + } + + /** + * Failures since the last success, reset to 0 on any 2xx. + * + * @return the value, never null + */ + public Integer consecutiveFailures() { + return Utils.required(consecutiveFailures, "consecutive_failures"); + } + + /** + * The {@code created_at} property. + * + * @return the value, never null + */ + public OffsetDateTime createdAt() { + return Utils.required(createdAt, "created_at"); + } + + /** + * The {@code description} property. + * + * @return the value, empty when unset or null + */ + public Optional description() { + return description.asOptional(); + } + + /** + * The {@code disabled} property. + * + * @return the value, never null + */ + public Boolean disabled() { + return Utils.required(disabled, "disabled"); + } + + /** + * The {@code disabled_reason} property. + * + * @return the value, empty when unset or null + */ + public Optional disabledReason() { + return disabledReason.asOptional(); + } + + /** + * Subscribed event types. Empty means every event type. + * + * @return the value, never null + */ + public List eventTypes() { + return Utils.required(eventTypes, "event_types"); + } + + /** + * Custom headers sent with every delivery. + * + * @return the value, never null + */ + public List headers() { + return Utils.required(headers, "headers"); + } + + /** + * The {@code id} property. + * + * @return the value, never null + */ + public String id() { + return Utils.required(id, "id"); + } + + /** + * The {@code last_failure_at} property. + * + * @return the value, empty when unset or null + */ + public Optional lastFailureAt() { + return lastFailureAt.asOptional(); + } + + /** + * The {@code last_success_at} property. + * + * @return the value, empty when unset or null + */ + public Optional lastSuccessAt() { + return lastSuccessAt.asOptional(); + } + + /** + * How many deliveries this endpoint may have in flight at once. Read-only; it is set from the + * tenant's environment when the endpoint is created. + * + * @return the value, never null + */ + public Integer maxInFlight() { + return Utils.required(maxInFlight, "max_in_flight"); + } + + /** + * A sensitive header still waits for its value; the endpoint cannot be enabled until it is set. + * + * @return the value, never null + */ + public Boolean needsSetup() { + return Utils.required(needsSetup, "needs_setup"); + } + + /** + * The endpoint was unreachable several times in a row: nothing is sent before this time, then + * it is retried one delivery at a time until it answers again. + * + * @return the value, empty when unset or null + */ + public Optional pausedUntil() { + return pausedUntil.asOptional(); + } + + /** + * Deliveries started per second, at most. + * + * @return the value, empty when unset or null + */ + public Optional rateLimitPerSec() { + return rateLimitPerSec.asOptional(); + } + + /** + * The {@code updated_at} property. + * + * @return the value, empty when unset or null + */ + public Optional updatedAt() { + return updatedAt.asOptional(); + } + + /** + * The {@code url} property. + * + * @return the value, never null + */ + public String url() { + return Utils.required(url, "url"); + } + + /** + * Properties this version of the SDK does not know, kept as received and sent back. + * + * @return the properties by name, unmodifiable + */ + public Map additionalProperties() { + return Collections.unmodifiableMap(additionalProperties); + } + + @JsonAnyGetter + private Map anyProperties() { + return additionalProperties; + } + + @JsonAnySetter + private void putAnyProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + WebhookEndpoint that = (WebhookEndpoint) o; + return Objects.equals(consecutiveFailures, that.consecutiveFailures) + && Objects.equals(createdAt, that.createdAt) + && Objects.equals(description, that.description) + && Objects.equals(disabled, that.disabled) + && Objects.equals(disabledReason, that.disabledReason) + && Objects.equals(eventTypes, that.eventTypes) + && Objects.equals(headers, that.headers) + && Objects.equals(id, that.id) + && Objects.equals(lastFailureAt, that.lastFailureAt) + && Objects.equals(lastSuccessAt, that.lastSuccessAt) + && Objects.equals(maxInFlight, that.maxInFlight) + && Objects.equals(needsSetup, that.needsSetup) + && Objects.equals(pausedUntil, that.pausedUntil) + && Objects.equals(rateLimitPerSec, that.rateLimitPerSec) + && Objects.equals(updatedAt, that.updatedAt) + && Objects.equals(url, that.url) + && Objects.equals(additionalProperties, that.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash( + consecutiveFailures, + createdAt, + description, + disabled, + disabledReason, + eventTypes, + headers, + id, + lastFailureAt, + lastSuccessAt, + maxInFlight, + needsSetup, + pausedUntil, + rateLimitPerSec, + updatedAt, + url, + additionalProperties); + } + + @Override + public String toString() { + return "WebhookEndpoint{" + + "consecutiveFailures=" + + consecutiveFailures + + ", createdAt=" + + createdAt + + ", description=" + + description + + ", disabled=" + + disabled + + ", disabledReason=" + + disabledReason + + ", eventTypes=" + + eventTypes + + ", headers=" + + headers + + ", id=" + + id + + ", lastFailureAt=" + + lastFailureAt + + ", lastSuccessAt=" + + lastSuccessAt + + ", maxInFlight=" + + maxInFlight + + ", needsSetup=" + + needsSetup + + ", pausedUntil=" + + pausedUntil + + ", rateLimitPerSec=" + + rateLimitPerSec + + ", updatedAt=" + + updatedAt + + ", url=" + + url + + ", additionalProperties=" + + additionalProperties + + "}"; + } + + /** Builds {@link WebhookEndpoint}. */ + public static final class Builder { + private Integer consecutiveFailures; + private OffsetDateTime createdAt; + private JsonField description = JsonField.missing(); + private Boolean disabled; + private JsonField disabledReason = JsonField.missing(); + private List eventTypes; + private List headers; + private String id; + private JsonField lastFailureAt = JsonField.missing(); + private JsonField lastSuccessAt = JsonField.missing(); + private Integer maxInFlight; + private Boolean needsSetup; + private JsonField pausedUntil = JsonField.missing(); + private JsonField rateLimitPerSec = JsonField.missing(); + private JsonField updatedAt = JsonField.missing(); + private String url; + private final Map additionalProperties = new LinkedHashMap<>(); + + private Builder() {} + + /** + * Failures since the last success, reset to 0 on any 2xx. + * + * @param consecutiveFailures the value + * @return this builder + */ + public Builder consecutiveFailures(Integer consecutiveFailures) { + this.consecutiveFailures = consecutiveFailures; + return this; + } + + /** + * The {@code created_at} property. + * + * @param createdAt the value + * @return this builder + */ + public Builder createdAt(OffsetDateTime createdAt) { + this.createdAt = createdAt; + return this; + } + + /** + * The {@code description} property. + * + * @param description the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder description(String description) { + this.description = JsonField.ofNullable(description); + return this; + } + + /** + * The {@code disabled} property. + * + * @param disabled the value + * @return this builder + */ + public Builder disabled(Boolean disabled) { + this.disabled = disabled; + return this; + } + + /** + * The {@code disabled_reason} property. + * + * @param disabledReason the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder disabledReason(WebhookEndpointDisabledReason disabledReason) { + this.disabledReason = JsonField.ofNullable(disabledReason); + return this; + } + + /** + * Subscribed event types. Empty means every event type. + * + * @param eventTypes the value + * @return this builder + */ + public Builder eventTypes(List eventTypes) { + this.eventTypes = Utils.mutableList(eventTypes); + return this; + } + + /** + * Adds an item to {@code event_types}. + * + * @param item the item + * @return this builder + */ + public Builder addEventTypesItem(String item) { + if (this.eventTypes == null) { + this.eventTypes = new ArrayList<>(); + } + this.eventTypes.add(item); + return this; + } + + /** + * Custom headers sent with every delivery. + * + * @param headers the value + * @return this builder + */ + public Builder headers(List headers) { + this.headers = Utils.mutableList(headers); + return this; + } + + /** + * Adds an item to {@code headers}. + * + * @param item the item + * @return this builder + */ + public Builder addHeadersItem(WebhookHeader item) { + if (this.headers == null) { + this.headers = new ArrayList<>(); + } + this.headers.add(item); + return this; + } + + /** + * The {@code id} property. + * + * @param id the value + * @return this builder + */ + public Builder id(String id) { + this.id = id; + return this; + } + + /** + * The {@code last_failure_at} property. + * + * @param lastFailureAt the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder lastFailureAt(OffsetDateTime lastFailureAt) { + this.lastFailureAt = JsonField.ofNullable(lastFailureAt); + return this; + } + + /** + * The {@code last_success_at} property. + * + * @param lastSuccessAt the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder lastSuccessAt(OffsetDateTime lastSuccessAt) { + this.lastSuccessAt = JsonField.ofNullable(lastSuccessAt); + return this; + } + + /** + * How many deliveries this endpoint may have in flight at once. Read-only; it is set from + * the tenant's environment when the endpoint is created. + * + * @param maxInFlight the value + * @return this builder + */ + public Builder maxInFlight(Integer maxInFlight) { + this.maxInFlight = maxInFlight; + return this; + } + + /** + * A sensitive header still waits for its value; the endpoint cannot be enabled until it is + * set. + * + * @param needsSetup the value + * @return this builder + */ + public Builder needsSetup(Boolean needsSetup) { + this.needsSetup = needsSetup; + return this; + } + + /** + * The endpoint was unreachable several times in a row: nothing is sent before this time, + * then it is retried one delivery at a time until it answers again. + * + * @param pausedUntil the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder pausedUntil(OffsetDateTime pausedUntil) { + this.pausedUntil = JsonField.ofNullable(pausedUntil); + return this; + } + + /** + * Deliveries started per second, at most. + * + * @param rateLimitPerSec the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder rateLimitPerSec(Integer rateLimitPerSec) { + this.rateLimitPerSec = JsonField.ofNullable(rateLimitPerSec); + return this; + } + + /** + * The {@code updated_at} property. + * + * @param updatedAt the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder updatedAt(OffsetDateTime updatedAt) { + this.updatedAt = JsonField.ofNullable(updatedAt); + return this; + } + + /** + * The {@code url} property. + * + * @param url the value + * @return this builder + */ + public Builder url(String url) { + this.url = url; + return this; + } + + /** + * A property the SDK does not know, sent along. + * + * @param name the property name + * @param value the JSON value + * @return this builder + */ + public Builder putAdditionalProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + return this; + } + + /** + * Properties the SDK does not know, sent along. + * + * @param additionalProperties the properties by name + * @return this builder + */ + public Builder putAllAdditionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + + /** + * Leaves out a property the SDK does not know. + * + * @param name the property name + * @return this builder + */ + public Builder removeAdditionalProperty(String name) { + additionalProperties.remove(name); + return this; + } + + /** + * The {@code WebhookEndpoint}. + * + * @return the immutable value + * @throws IllegalStateException when a required property is not set + */ + public WebhookEndpoint build() { + Utils.checkRequired(consecutiveFailures, "consecutive_failures"); + Utils.checkRequired(createdAt, "created_at"); + Utils.checkRequired(disabled, "disabled"); + Utils.checkRequired(eventTypes, "event_types"); + Utils.checkRequired(headers, "headers"); + Utils.checkRequired(id, "id"); + Utils.checkRequired(maxInFlight, "max_in_flight"); + Utils.checkRequired(needsSetup, "needs_setup"); + Utils.checkRequired(url, "url"); + return new WebhookEndpoint(this); + } + } + + /** + * Parse {@code json} as {@code WebhookEndpoint}. + * + * @param json the JSON text + * @return the value + * @throws com.meteroid.exceptions.InvalidDataException if it is not valid JSON of this shape + */ + public static WebhookEndpoint fromJson(String json) { + return Utils.parse(json, WebhookEndpoint.class); + } + + /** + * This value as JSON. + * + * @return the JSON text + */ + public String toJson() { + return Utils.json(this); + } +} diff --git a/src/main/java/com/meteroid/models/WebhookEndpointDisabledReason.java b/src/main/java/com/meteroid/models/WebhookEndpointDisabledReason.java new file mode 100644 index 0000000..2c75de6 --- /dev/null +++ b/src/main/java/com/meteroid/models/WebhookEndpointDisabledReason.java @@ -0,0 +1,142 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import com.meteroid.internal.Utils.ToQueryParam; + +import java.util.Map; +import java.util.Objects; + +/** + * Values this version of the SDK does not know are kept, and sent back unchanged: {@link #value()} + * is an enum to switch on, {@code _UNKNOWN} for them, and {@link #known()} throws on them. + */ +public final class WebhookEndpointDisabledReason implements ToQueryParam { + /** The value {@code "MANUAL"}. */ + public static final WebhookEndpointDisabledReason MANUAL = + new WebhookEndpointDisabledReason("MANUAL", Value.MANUAL); + + /** The value {@code "AUTO_FAILURES"}. */ + public static final WebhookEndpointDisabledReason AUTO_FAILURES = + new WebhookEndpointDisabledReason("AUTO_FAILURES", Value.AUTO_FAILURES); + + /** The value {@code "GONE"}. */ + public static final WebhookEndpointDisabledReason GONE = + new WebhookEndpointDisabledReason("GONE", Value.GONE); + + private static final Map constants = + Map.ofEntries( + Map.entry("MANUAL", MANUAL), + Map.entry("AUTO_FAILURES", AUTO_FAILURES), + Map.entry("GONE", GONE)); + + private final String value; + private final Value variant; + + private WebhookEndpointDisabledReason(String value, Value variant) { + this.value = value; + this.variant = variant; + } + + /** + * The constant for {@code value}, or an unknown WebhookEndpointDisabledReason holding it. + * + * @param value the value + * @return the constant + */ + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static WebhookEndpointDisabledReason of(String value) { + WebhookEndpointDisabledReason constant = + constants.get(Objects.requireNonNull(value, "value")); + return constant != null + ? constant + : new WebhookEndpointDisabledReason(value, Value._UNKNOWN); + } + + /** + * The value as sent. + * + * @return the value + */ + @JsonValue + public String asString() { + return value; + } + + /** + * Whether this version of the SDK knows the value. + * + * @return whether it is known + */ + public boolean isKnown() { + return variant != Value._UNKNOWN; + } + + /** + * The value as an enum to switch on, unknown values included. + * + * @return the enum, {@code _UNKNOWN} when unknown + */ + public Value value() { + return variant; + } + + /** + * The value as an enum of the known values only. + * + * @return the enum + * @throws com.meteroid.exceptions.InvalidDataException when this version of the SDK does not + * know the value + */ + public Known known() { + if (!isKnown()) { + throw new com.meteroid.exceptions.InvalidDataException( + "unknown WebhookEndpointDisabledReason: " + value); + } + return Known.valueOf(variant.name()); + } + + @Override + public String toQueryParam() { + return String.valueOf(value); + } + + @Override + public boolean equals(Object o) { + return o instanceof WebhookEndpointDisabledReason + && Objects.equals(value, ((WebhookEndpointDisabledReason) o).value); + } + + @Override + public int hashCode() { + return Objects.hashCode(value); + } + + @Override + public String toString() { + return String.valueOf(value); + } + + /** The values this version of the SDK knows. */ + public enum Known { + /** The {@code MANUAL} constant. */ + MANUAL, + /** The {@code AUTO_FAILURES} constant. */ + AUTO_FAILURES, + /** The {@code GONE} constant. */ + GONE + } + + /** The values this version of the SDK knows, and {@code _UNKNOWN} for the others. */ + public enum Value { + /** The {@code MANUAL} constant. */ + MANUAL, + /** The {@code AUTO_FAILURES} constant. */ + AUTO_FAILURES, + /** The {@code GONE} constant. */ + GONE, + /** A value this version of the SDK does not know. */ + _UNKNOWN + } +} diff --git a/src/main/java/com/meteroid/models/WebhookEndpointListResponse.java b/src/main/java/com/meteroid/models/WebhookEndpointListResponse.java new file mode 100644 index 0000000..794675f --- /dev/null +++ b/src/main/java/com/meteroid/models/WebhookEndpointListResponse.java @@ -0,0 +1,215 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.Utils; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonAutoDetect( + getterVisibility = Visibility.NONE, + isGetterVisibility = Visibility.NONE, + setterVisibility = Visibility.NONE) +public final class WebhookEndpointListResponse { + @JsonProperty("data") + private List data; + + private final Map additionalProperties = new LinkedHashMap<>(); + + private WebhookEndpointListResponse() {} + + private WebhookEndpointListResponse(Builder builder) { + this.data = Utils.copyList(builder.data); + this.additionalProperties.putAll(builder.additionalProperties); + } + + /** + * A builder of {@code WebhookEndpointListResponse}. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * A builder starting from this value. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.data = Utils.mutableList(data); + builder.additionalProperties.putAll(additionalProperties); + return builder; + } + + /** + * The {@code data} property. + * + * @return the value, never null + */ + public List data() { + return Utils.required(data, "data"); + } + + /** + * Properties this version of the SDK does not know, kept as received and sent back. + * + * @return the properties by name, unmodifiable + */ + public Map additionalProperties() { + return Collections.unmodifiableMap(additionalProperties); + } + + @JsonAnyGetter + private Map anyProperties() { + return additionalProperties; + } + + @JsonAnySetter + private void putAnyProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + WebhookEndpointListResponse that = (WebhookEndpointListResponse) o; + return Objects.equals(data, that.data) + && Objects.equals(additionalProperties, that.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(data, additionalProperties); + } + + @Override + public String toString() { + return "WebhookEndpointListResponse{" + + "data=" + + data + + ", additionalProperties=" + + additionalProperties + + "}"; + } + + /** Builds {@link WebhookEndpointListResponse}. */ + public static final class Builder { + private List data; + private final Map additionalProperties = new LinkedHashMap<>(); + + private Builder() {} + + /** + * The {@code data} property. + * + * @param data the value + * @return this builder + */ + public Builder data(List data) { + this.data = Utils.mutableList(data); + return this; + } + + /** + * Adds an item to {@code data}. + * + * @param item the item + * @return this builder + */ + public Builder addDataItem(WebhookEndpoint item) { + if (this.data == null) { + this.data = new ArrayList<>(); + } + this.data.add(item); + return this; + } + + /** + * A property the SDK does not know, sent along. + * + * @param name the property name + * @param value the JSON value + * @return this builder + */ + public Builder putAdditionalProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + return this; + } + + /** + * Properties the SDK does not know, sent along. + * + * @param additionalProperties the properties by name + * @return this builder + */ + public Builder putAllAdditionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + + /** + * Leaves out a property the SDK does not know. + * + * @param name the property name + * @return this builder + */ + public Builder removeAdditionalProperty(String name) { + additionalProperties.remove(name); + return this; + } + + /** + * The {@code WebhookEndpointListResponse}. + * + * @return the immutable value + * @throws IllegalStateException when a required property is not set + */ + public WebhookEndpointListResponse build() { + Utils.checkRequired(data, "data"); + return new WebhookEndpointListResponse(this); + } + } + + /** + * Parse {@code json} as {@code WebhookEndpointListResponse}. + * + * @param json the JSON text + * @return the value + * @throws com.meteroid.exceptions.InvalidDataException if it is not valid JSON of this shape + */ + public static WebhookEndpointListResponse fromJson(String json) { + return Utils.parse(json, WebhookEndpointListResponse.class); + } + + /** + * This value as JSON. + * + * @return the JSON text + */ + public String toJson() { + return Utils.json(this); + } +} diff --git a/src/main/java/com/meteroid/models/WebhookEndpointSecret.java b/src/main/java/com/meteroid/models/WebhookEndpointSecret.java new file mode 100644 index 0000000..d9a22a7 --- /dev/null +++ b/src/main/java/com/meteroid/models/WebhookEndpointSecret.java @@ -0,0 +1,199 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.Utils; + +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; + +/** Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonAutoDetect( + getterVisibility = Visibility.NONE, + isGetterVisibility = Visibility.NONE, + setterVisibility = Visibility.NONE) +public final class WebhookEndpointSecret { + @JsonProperty("secret") + private String secret; + + private final Map additionalProperties = new LinkedHashMap<>(); + + private WebhookEndpointSecret() {} + + private WebhookEndpointSecret(Builder builder) { + this.secret = builder.secret; + this.additionalProperties.putAll(builder.additionalProperties); + } + + /** + * A builder of {@code WebhookEndpointSecret}. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * A builder starting from this value. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.secret = secret; + builder.additionalProperties.putAll(additionalProperties); + return builder; + } + + /** + * The {@code secret} property. + * + * @return the value, never null + */ + public String secret() { + return Utils.required(secret, "secret"); + } + + /** + * Properties this version of the SDK does not know, kept as received and sent back. + * + * @return the properties by name, unmodifiable + */ + public Map additionalProperties() { + return Collections.unmodifiableMap(additionalProperties); + } + + @JsonAnyGetter + private Map anyProperties() { + return additionalProperties; + } + + @JsonAnySetter + private void putAnyProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + WebhookEndpointSecret that = (WebhookEndpointSecret) o; + return Objects.equals(secret, that.secret) + && Objects.equals(additionalProperties, that.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(secret, additionalProperties); + } + + @Override + public String toString() { + return "WebhookEndpointSecret{" + + "secret=" + + secret + + ", additionalProperties=" + + additionalProperties + + "}"; + } + + /** Builds {@link WebhookEndpointSecret}. */ + public static final class Builder { + private String secret; + private final Map additionalProperties = new LinkedHashMap<>(); + + private Builder() {} + + /** + * The {@code secret} property. + * + * @param secret the value + * @return this builder + */ + public Builder secret(String secret) { + this.secret = secret; + return this; + } + + /** + * A property the SDK does not know, sent along. + * + * @param name the property name + * @param value the JSON value + * @return this builder + */ + public Builder putAdditionalProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + return this; + } + + /** + * Properties the SDK does not know, sent along. + * + * @param additionalProperties the properties by name + * @return this builder + */ + public Builder putAllAdditionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + + /** + * Leaves out a property the SDK does not know. + * + * @param name the property name + * @return this builder + */ + public Builder removeAdditionalProperty(String name) { + additionalProperties.remove(name); + return this; + } + + /** + * The {@code WebhookEndpointSecret}. + * + * @return the immutable value + * @throws IllegalStateException when a required property is not set + */ + public WebhookEndpointSecret build() { + Utils.checkRequired(secret, "secret"); + return new WebhookEndpointSecret(this); + } + } + + /** + * Parse {@code json} as {@code WebhookEndpointSecret}. + * + * @param json the JSON text + * @return the value + * @throws com.meteroid.exceptions.InvalidDataException if it is not valid JSON of this shape + */ + public static WebhookEndpointSecret fromJson(String json) { + return Utils.parse(json, WebhookEndpointSecret.class); + } + + /** + * This value as JSON. + * + * @return the JSON text + */ + public String toJson() { + return Utils.json(this); + } +} diff --git a/src/main/java/com/meteroid/models/WebhookHeader.java b/src/main/java/com/meteroid/models/WebhookHeader.java new file mode 100644 index 0000000..1f9735f --- /dev/null +++ b/src/main/java/com/meteroid/models/WebhookHeader.java @@ -0,0 +1,296 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.JsonField; +import com.meteroid.internal.Utils; + +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +/** + * A custom header sent with every delivery. A sensitive header never returns its value; set + * says whether it has one. + * + *

Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonAutoDetect( + getterVisibility = Visibility.NONE, + isGetterVisibility = Visibility.NONE, + setterVisibility = Visibility.NONE) +public final class WebhookHeader { + @JsonProperty("name") + private String name; + + @JsonProperty("sensitive") + private Boolean sensitive; + + @JsonProperty("set") + private Boolean set; + + @JsonProperty("value") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField value = JsonField.missing(); + + private final Map additionalProperties = new LinkedHashMap<>(); + + private WebhookHeader() {} + + private WebhookHeader(Builder builder) { + this.name = builder.name; + this.sensitive = builder.sensitive; + this.set = builder.set; + this.value = builder.value; + this.additionalProperties.putAll(builder.additionalProperties); + } + + /** + * A builder of {@code WebhookHeader}. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * A builder starting from this value. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.name = name; + builder.sensitive = sensitive; + builder.set = set; + builder.value = value; + builder.additionalProperties.putAll(additionalProperties); + return builder; + } + + /** + * The {@code name} property. + * + * @return the value, never null + */ + public String name() { + return Utils.required(name, "name"); + } + + /** + * The {@code sensitive} property. + * + * @return the value, never null + */ + public Boolean sensitive() { + return Utils.required(sensitive, "sensitive"); + } + + /** + * The {@code set} property. + * + * @return the value, never null + */ + public Boolean set() { + return Utils.required(set, "set"); + } + + /** + * The {@code value} property. + * + * @return the value, empty when unset or null + */ + public Optional value() { + return value.asOptional(); + } + + /** + * Properties this version of the SDK does not know, kept as received and sent back. + * + * @return the properties by name, unmodifiable + */ + public Map additionalProperties() { + return Collections.unmodifiableMap(additionalProperties); + } + + @JsonAnyGetter + private Map anyProperties() { + return additionalProperties; + } + + @JsonAnySetter + private void putAnyProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + WebhookHeader that = (WebhookHeader) o; + return Objects.equals(name, that.name) + && Objects.equals(sensitive, that.sensitive) + && Objects.equals(set, that.set) + && Objects.equals(value, that.value) + && Objects.equals(additionalProperties, that.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(name, sensitive, set, value, additionalProperties); + } + + @Override + public String toString() { + return "WebhookHeader{" + + "name=" + + name + + ", sensitive=" + + sensitive + + ", set=" + + set + + ", value=" + + value + + ", additionalProperties=" + + additionalProperties + + "}"; + } + + /** Builds {@link WebhookHeader}. */ + public static final class Builder { + private String name; + private Boolean sensitive; + private Boolean set; + private JsonField value = JsonField.missing(); + private final Map additionalProperties = new LinkedHashMap<>(); + + private Builder() {} + + /** + * The {@code name} property. + * + * @param name the value + * @return this builder + */ + public Builder name(String name) { + this.name = name; + return this; + } + + /** + * The {@code sensitive} property. + * + * @param sensitive the value + * @return this builder + */ + public Builder sensitive(Boolean sensitive) { + this.sensitive = sensitive; + return this; + } + + /** + * The {@code set} property. + * + * @param set the value + * @return this builder + */ + public Builder set(Boolean set) { + this.set = set; + return this; + } + + /** + * The {@code value} property. + * + * @param value the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder value(String value) { + this.value = JsonField.ofNullable(value); + return this; + } + + /** + * A property the SDK does not know, sent along. + * + * @param name the property name + * @param value the JSON value + * @return this builder + */ + public Builder putAdditionalProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + return this; + } + + /** + * Properties the SDK does not know, sent along. + * + * @param additionalProperties the properties by name + * @return this builder + */ + public Builder putAllAdditionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + + /** + * Leaves out a property the SDK does not know. + * + * @param name the property name + * @return this builder + */ + public Builder removeAdditionalProperty(String name) { + additionalProperties.remove(name); + return this; + } + + /** + * The {@code WebhookHeader}. + * + * @return the immutable value + * @throws IllegalStateException when a required property is not set + */ + public WebhookHeader build() { + Utils.checkRequired(name, "name"); + Utils.checkRequired(sensitive, "sensitive"); + Utils.checkRequired(set, "set"); + return new WebhookHeader(this); + } + } + + /** + * Parse {@code json} as {@code WebhookHeader}. + * + * @param json the JSON text + * @return the value + * @throws com.meteroid.exceptions.InvalidDataException if it is not valid JSON of this shape + */ + public static WebhookHeader fromJson(String json) { + return Utils.parse(json, WebhookHeader.class); + } + + /** + * This value as JSON. + * + * @return the JSON text + */ + public String toJson() { + return Utils.json(this); + } +} diff --git a/src/main/java/com/meteroid/models/WebhookHeaderInput.java b/src/main/java/com/meteroid/models/WebhookHeaderInput.java new file mode 100644 index 0000000..2976f92 --- /dev/null +++ b/src/main/java/com/meteroid/models/WebhookHeaderInput.java @@ -0,0 +1,265 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.JsonField; +import com.meteroid.internal.Utils; + +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +/** + * A custom header to send with every delivery. A sensitive header is write-only: it is never + * returned, and on update sending it without a value keeps its value. + * + *

Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonAutoDetect( + getterVisibility = Visibility.NONE, + isGetterVisibility = Visibility.NONE, + setterVisibility = Visibility.NONE) +public final class WebhookHeaderInput { + @JsonProperty("name") + private String name; + + @JsonProperty("sensitive") + private Boolean sensitive; + + @JsonProperty("value") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField value = JsonField.missing(); + + private final Map additionalProperties = new LinkedHashMap<>(); + + private WebhookHeaderInput() {} + + private WebhookHeaderInput(Builder builder) { + this.name = builder.name; + this.sensitive = builder.sensitive; + this.value = builder.value; + this.additionalProperties.putAll(builder.additionalProperties); + } + + /** + * A builder of {@code WebhookHeaderInput}. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * A builder starting from this value. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.name = name; + builder.sensitive = sensitive; + builder.value = value; + builder.additionalProperties.putAll(additionalProperties); + return builder; + } + + /** + * The {@code name} property. + * + * @return the value, never null + */ + public String name() { + return Utils.required(name, "name"); + } + + /** + * The {@code sensitive} property. + * + * @return the value, empty when unset + */ + public Optional sensitive() { + return Optional.ofNullable(sensitive); + } + + /** + * The {@code value} property. + * + * @return the value, empty when unset or null + */ + public Optional value() { + return value.asOptional(); + } + + /** + * Properties this version of the SDK does not know, kept as received and sent back. + * + * @return the properties by name, unmodifiable + */ + public Map additionalProperties() { + return Collections.unmodifiableMap(additionalProperties); + } + + @JsonAnyGetter + private Map anyProperties() { + return additionalProperties; + } + + @JsonAnySetter + private void putAnyProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + WebhookHeaderInput that = (WebhookHeaderInput) o; + return Objects.equals(name, that.name) + && Objects.equals(sensitive, that.sensitive) + && Objects.equals(value, that.value) + && Objects.equals(additionalProperties, that.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(name, sensitive, value, additionalProperties); + } + + @Override + public String toString() { + return "WebhookHeaderInput{" + + "name=" + + name + + ", sensitive=" + + sensitive + + ", value=" + + value + + ", additionalProperties=" + + additionalProperties + + "}"; + } + + /** Builds {@link WebhookHeaderInput}. */ + public static final class Builder { + private String name; + private Boolean sensitive; + private JsonField value = JsonField.missing(); + private final Map additionalProperties = new LinkedHashMap<>(); + + private Builder() {} + + /** + * The {@code name} property. + * + * @param name the value + * @return this builder + */ + public Builder name(String name) { + this.name = name; + return this; + } + + /** + * The {@code sensitive} property. + * + * @param sensitive the value + * @return this builder + */ + public Builder sensitive(Boolean sensitive) { + this.sensitive = sensitive; + return this; + } + + /** + * The {@code value} property. + * + * @param value the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder value(String value) { + this.value = JsonField.ofNullable(value); + return this; + } + + /** + * A property the SDK does not know, sent along. + * + * @param name the property name + * @param value the JSON value + * @return this builder + */ + public Builder putAdditionalProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + return this; + } + + /** + * Properties the SDK does not know, sent along. + * + * @param additionalProperties the properties by name + * @return this builder + */ + public Builder putAllAdditionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + + /** + * Leaves out a property the SDK does not know. + * + * @param name the property name + * @return this builder + */ + public Builder removeAdditionalProperty(String name) { + additionalProperties.remove(name); + return this; + } + + /** + * The {@code WebhookHeaderInput}. + * + * @return the immutable value + * @throws IllegalStateException when a required property is not set + */ + public WebhookHeaderInput build() { + Utils.checkRequired(name, "name"); + return new WebhookHeaderInput(this); + } + } + + /** + * Parse {@code json} as {@code WebhookHeaderInput}. + * + * @param json the JSON text + * @return the value + * @throws com.meteroid.exceptions.InvalidDataException if it is not valid JSON of this shape + */ + public static WebhookHeaderInput fromJson(String json) { + return Utils.parse(json, WebhookHeaderInput.class); + } + + /** + * This value as JSON. + * + * @return the JSON text + */ + public String toJson() { + return Utils.json(this); + } +} diff --git a/src/test/java/com/meteroid/api/CustomersTest.java b/src/test/java/com/meteroid/api/CustomersTest.java index 876e31f..b74ac1e 100644 --- a/src/test/java/com/meteroid/api/CustomersTest.java +++ b/src/test/java/com/meteroid/api/CustomersTest.java @@ -32,7 +32,7 @@ void create() throws Exception { .create( PerseidMock.decode( com.meteroid.models.CustomerCreateRequest.class, - "{\"currency\":\"ERN\",\"custom_taxes\":[{\"name\":\"sample\",\"rate\":\"sample\",\"tax_code\":\"sample\"}],\"invoicing_emails\":[\"sample\"]}")); + "{\"currency\":\"ERN\"}")); assertEquals(List.of("POST /api/v1/customers"), mock.requests); } diff --git a/src/test/java/com/meteroid/api/EventsTest.java b/src/test/java/com/meteroid/api/EventsTest.java index b102229..b3ca148 100644 --- a/src/test/java/com/meteroid/api/EventsTest.java +++ b/src/test/java/com/meteroid/api/EventsTest.java @@ -17,7 +17,7 @@ void ingest() throws Exception { .ingest( PerseidMock.decode( com.meteroid.models.IngestEventsRequest.class, - "{\"events\":[{\"code\":\"sample\",\"customer_id\":\"sample\",\"event_id\":\"sample\",\"timestamp\":\"sample\"}]}")); + "{\"events\":[{\"code\":\"sample\",\"customer_id\":\"sample\",\"event_id\":\"sample\"}]}")); assertEquals(List.of("POST /api/v1/events/ingest"), mock.requests); } } diff --git a/src/test/java/com/meteroid/api/PlansTest.java b/src/test/java/com/meteroid/api/PlansTest.java index ec31ff3..f011c0c 100644 --- a/src/test/java/com/meteroid/api/PlansTest.java +++ b/src/test/java/com/meteroid/api/PlansTest.java @@ -45,7 +45,7 @@ void list() throws Exception { new PerseidMock( 200, "application/json", - "{\"data\":[{\"available_parameters\":{},\"created_at\":\"2024-03-15T10:30:45.123+02:00\",\"currency\":\"sample\",\"id\":\"plan_id_78\",\"name\":\"sample\",\"net_terms\":-2147483648,\"plan_type\":\"FREE\",\"price_components\":[{\"id\":\"price_component_id_82\",\"name\":\"sample\"}],\"product_family\":{\"id\":\"product_family_id_59\",\"name\":\"sample\"},\"status\":\"INACTIVE\",\"tax_inclusive\":true,\"version\":-2147483648,\"version_id\":\"plan_version_id_92\"}],\"pagination_meta\":{\"page\":-123456789,\"per_page\":-123456789,\"total_items\":-9007199254740993,\"total_pages\":123456789}}"); + "{\"data\":[{\"available_parameters\":{},\"created_at\":\"2024-03-15T10:30:45.123+02:00\",\"currency\":\"WST\",\"id\":\"plan_id_78\",\"name\":\"sample\",\"net_terms\":-2147483648,\"plan_type\":\"FREE\",\"price_components\":[{\"id\":\"price_component_id_82\",\"name\":\"sample\"}],\"product_family\":{\"id\":\"product_family_id_59\",\"name\":\"sample\"},\"status\":\"INACTIVE\",\"tax_inclusive\":true,\"version\":-2147483648,\"version_id\":\"plan_version_id_92\"}],\"pagination_meta\":{\"page\":-123456789,\"per_page\":-123456789,\"total_items\":-9007199254740993,\"total_pages\":123456789}}"); mock.client.plans().list(); assertEquals(List.of("GET /api/v1/plans"), mock.requests); } @@ -56,7 +56,7 @@ void create() throws Exception { new PerseidMock( 200, "application/json", - "{\"available_parameters\":{},\"created_at\":\"2023-12-31T23:59:59.999-05:30\",\"currency\":\"sample\",\"id\":\"plan_id_13\",\"name\":\"sample\",\"net_terms\":2147483647,\"plan_type\":\"FREE\",\"price_components\":[{\"id\":\"price_component_id_38\",\"name\":\"sample\"}],\"product_family\":{\"id\":\"product_family_id_66\",\"name\":\"sample\"},\"status\":\"ARCHIVED\",\"tax_inclusive\":false,\"version\":123456789,\"version_id\":\"plan_version_id_84\"}"); + "{\"available_parameters\":{},\"created_at\":\"2023-12-31T23:59:59.999-05:30\",\"currency\":\"COP\",\"id\":\"plan_id_13\",\"name\":\"sample\",\"net_terms\":2147483647,\"plan_type\":\"FREE\",\"price_components\":[{\"id\":\"price_component_id_38\",\"name\":\"sample\"}],\"product_family\":{\"id\":\"product_family_id_66\",\"name\":\"sample\"},\"status\":\"ARCHIVED\",\"tax_inclusive\":false,\"version\":123456789,\"version_id\":\"plan_version_id_84\"}"); mock.client .plans() .create( @@ -72,7 +72,7 @@ void retrieve() throws Exception { new PerseidMock( 200, "application/json", - "{\"available_parameters\":{},\"created_at\":\"2023-12-31T23:59:59.999-05:30\",\"currency\":\"sample\",\"id\":\"plan_id_13\",\"name\":\"sample\",\"net_terms\":2147483647,\"plan_type\":\"FREE\",\"price_components\":[{\"id\":\"price_component_id_38\",\"name\":\"sample\"}],\"product_family\":{\"id\":\"product_family_id_66\",\"name\":\"sample\"},\"status\":\"ARCHIVED\",\"tax_inclusive\":false,\"version\":123456789,\"version_id\":\"plan_version_id_84\"}"); + "{\"available_parameters\":{},\"created_at\":\"2023-12-31T23:59:59.999-05:30\",\"currency\":\"COP\",\"id\":\"plan_id_13\",\"name\":\"sample\",\"net_terms\":2147483647,\"plan_type\":\"FREE\",\"price_components\":[{\"id\":\"price_component_id_38\",\"name\":\"sample\"}],\"product_family\":{\"id\":\"product_family_id_66\",\"name\":\"sample\"},\"status\":\"ARCHIVED\",\"tax_inclusive\":false,\"version\":123456789,\"version_id\":\"plan_version_id_84\"}"); mock.client.plans().retrieve("plan_id"); assertEquals(List.of("GET /api/v1/plans/plan_id"), mock.requests); } @@ -83,7 +83,7 @@ void replace() throws Exception { new PerseidMock( 200, "application/json", - "{\"available_parameters\":{},\"created_at\":\"2023-12-31T23:59:59.999-05:30\",\"currency\":\"sample\",\"id\":\"plan_id_13\",\"name\":\"sample\",\"net_terms\":2147483647,\"plan_type\":\"FREE\",\"price_components\":[{\"id\":\"price_component_id_38\",\"name\":\"sample\"}],\"product_family\":{\"id\":\"product_family_id_66\",\"name\":\"sample\"},\"status\":\"ARCHIVED\",\"tax_inclusive\":false,\"version\":123456789,\"version_id\":\"plan_version_id_84\"}"); + "{\"available_parameters\":{},\"created_at\":\"2023-12-31T23:59:59.999-05:30\",\"currency\":\"COP\",\"id\":\"plan_id_13\",\"name\":\"sample\",\"net_terms\":2147483647,\"plan_type\":\"FREE\",\"price_components\":[{\"id\":\"price_component_id_38\",\"name\":\"sample\"}],\"product_family\":{\"id\":\"product_family_id_66\",\"name\":\"sample\"},\"status\":\"ARCHIVED\",\"tax_inclusive\":false,\"version\":123456789,\"version_id\":\"plan_version_id_84\"}"); mock.client .plans() .replace( @@ -100,7 +100,7 @@ void update() throws Exception { new PerseidMock( 200, "application/json", - "{\"available_parameters\":{},\"created_at\":\"2023-12-31T23:59:59.999-05:30\",\"currency\":\"sample\",\"id\":\"plan_id_13\",\"name\":\"sample\",\"net_terms\":2147483647,\"plan_type\":\"FREE\",\"price_components\":[{\"id\":\"price_component_id_38\",\"name\":\"sample\"}],\"product_family\":{\"id\":\"product_family_id_66\",\"name\":\"sample\"},\"status\":\"ARCHIVED\",\"tax_inclusive\":false,\"version\":123456789,\"version_id\":\"plan_version_id_84\"}"); + "{\"available_parameters\":{},\"created_at\":\"2023-12-31T23:59:59.999-05:30\",\"currency\":\"COP\",\"id\":\"plan_id_13\",\"name\":\"sample\",\"net_terms\":2147483647,\"plan_type\":\"FREE\",\"price_components\":[{\"id\":\"price_component_id_38\",\"name\":\"sample\"}],\"product_family\":{\"id\":\"product_family_id_66\",\"name\":\"sample\"},\"status\":\"ARCHIVED\",\"tax_inclusive\":false,\"version\":123456789,\"version_id\":\"plan_version_id_84\"}"); mock.client .plans() .update( @@ -122,7 +122,7 @@ void publish() throws Exception { new PerseidMock( 200, "application/json", - "{\"available_parameters\":{},\"created_at\":\"2023-12-31T23:59:59.999-05:30\",\"currency\":\"sample\",\"id\":\"plan_id_13\",\"name\":\"sample\",\"net_terms\":2147483647,\"plan_type\":\"FREE\",\"price_components\":[{\"id\":\"price_component_id_38\",\"name\":\"sample\"}],\"product_family\":{\"id\":\"product_family_id_66\",\"name\":\"sample\"},\"status\":\"ARCHIVED\",\"tax_inclusive\":false,\"version\":123456789,\"version_id\":\"plan_version_id_84\"}"); + "{\"available_parameters\":{},\"created_at\":\"2023-12-31T23:59:59.999-05:30\",\"currency\":\"COP\",\"id\":\"plan_id_13\",\"name\":\"sample\",\"net_terms\":2147483647,\"plan_type\":\"FREE\",\"price_components\":[{\"id\":\"price_component_id_38\",\"name\":\"sample\"}],\"product_family\":{\"id\":\"product_family_id_66\",\"name\":\"sample\"},\"status\":\"ARCHIVED\",\"tax_inclusive\":false,\"version\":123456789,\"version_id\":\"plan_version_id_84\"}"); mock.client.plans().publish("plan_id"); assertEquals(List.of("POST /api/v1/plans/plan_id/publish"), mock.requests); } diff --git a/src/test/java/com/meteroid/api/PlansVersionsTest.java b/src/test/java/com/meteroid/api/PlansVersionsTest.java index 6ab5697..e473a24 100644 --- a/src/test/java/com/meteroid/api/PlansVersionsTest.java +++ b/src/test/java/com/meteroid/api/PlansVersionsTest.java @@ -41,7 +41,7 @@ void list() throws Exception { 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}}"); + "{\"data\":[{\"created_at\":\"2023-12-31T23:59:59.999-05:30\",\"currency\":\"CVE\",\"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/WebhookEndpointsEndpointsTest.java b/src/test/java/com/meteroid/api/WebhookEndpointsEndpointsTest.java new file mode 100644 index 0000000..40139df --- /dev/null +++ b/src/test/java/com/meteroid/api/WebhookEndpointsEndpointsTest.java @@ -0,0 +1,102 @@ +// 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 WebhookEndpointsEndpointsTest { + + @Test + void list() throws Exception { + PerseidMock mock = + new PerseidMock( + 200, + "application/json", + "{\"data\":[{\"consecutive_failures\":-123456789,\"created_at\":\"2023-12-31T23:59:59.999-05:30\",\"disabled\":true,\"event_types\":[\"sample\"],\"headers\":[{\"name\":\"sample\",\"sensitive\":false,\"set\":true}],\"id\":\"webhook_endpoint_id_25\",\"max_in_flight\":-2147483648,\"needs_setup\":false,\"url\":\"sample\"}]}"); + mock.client.webhookEndpoints().endpoints().list(); + assertEquals(List.of("GET /api/v1/webhooks/endpoints"), mock.requests); + } + + @Test + void create() throws Exception { + PerseidMock mock = + new PerseidMock( + 200, + "application/json", + "{\"consecutive_failures\":-123456789,\"created_at\":\"2023-12-31T23:59:59.999-05:30\",\"disabled\":true,\"event_types\":[\"sample\"],\"headers\":[{\"name\":\"sample\",\"sensitive\":false,\"set\":true}],\"id\":\"webhook_endpoint_id_25\",\"max_in_flight\":-2147483648,\"needs_setup\":false,\"url\":\"sample\",\"secret\":\"sample\"}"); + mock.client + .webhookEndpoints() + .endpoints() + .create( + PerseidMock.decode( + com.meteroid.models.CreateWebhookEndpointRequest.class, + "{\"url\":\"sample\"}")); + assertEquals(List.of("POST /api/v1/webhooks/endpoints"), mock.requests); + } + + @Test + void retrieve() throws Exception { + PerseidMock mock = + new PerseidMock( + 200, + "application/json", + "{\"consecutive_failures\":-2147483648,\"created_at\":\"2024-03-15T10:30:45.123+02:00\",\"disabled\":true,\"event_types\":[\"sample\"],\"headers\":[{\"name\":\"sample\",\"sensitive\":true,\"set\":true}],\"id\":\"webhook_endpoint_id_40\",\"max_in_flight\":-123456789,\"needs_setup\":true,\"url\":\"sample\"}"); + mock.client.webhookEndpoints().endpoints().retrieve("endpoint_id"); + assertEquals(List.of("GET /api/v1/webhooks/endpoints/endpoint_id"), mock.requests); + } + + @Test + void delete() throws Exception { + PerseidMock mock = new PerseidMock(204, null, ""); + mock.client.webhookEndpoints().endpoints().delete("endpoint_id"); + assertEquals(List.of("DELETE /api/v1/webhooks/endpoints/endpoint_id"), mock.requests); + } + + @Test + void update() throws Exception { + PerseidMock mock = + new PerseidMock( + 200, + "application/json", + "{\"consecutive_failures\":-2147483648,\"created_at\":\"2024-03-15T10:30:45.123+02:00\",\"disabled\":true,\"event_types\":[\"sample\"],\"headers\":[{\"name\":\"sample\",\"sensitive\":true,\"set\":true}],\"id\":\"webhook_endpoint_id_40\",\"max_in_flight\":-123456789,\"needs_setup\":true,\"url\":\"sample\"}"); + mock.client + .webhookEndpoints() + .endpoints() + .update( + "endpoint_id", + PerseidMock.decode( + com.meteroid.models.UpdateWebhookEndpointRequest.class, "{}")); + assertEquals(List.of("PATCH /api/v1/webhooks/endpoints/endpoint_id"), mock.requests); + } + + @Test + void listDeliveries() throws Exception { + PerseidMock mock = + new PerseidMock( + 200, + "application/json", + "{\"data\":[{\"attempt_count\":-123456789,\"created_at\":\"2024-03-15T10:30:45.123+02:00\",\"endpoint_id\":\"webhook_endpoint_id_90\",\"event_type\":\"sample\",\"id\":\"webhook_delivery_id_0\",\"manual\":false,\"message_id\":\"event_id_67\",\"status\":\"SUCCEEDED\"}],\"pagination_meta\":{\"page\":-123456789,\"per_page\":-123456789,\"total_items\":-9007199254740993,\"total_pages\":123456789}}"); + mock.client.webhookEndpoints().endpoints().listDeliveries("endpoint_id"); + assertEquals( + List.of("GET /api/v1/webhooks/endpoints/endpoint_id/deliveries"), mock.requests); + } + + @Test + void rotateSecret() throws Exception { + PerseidMock mock = new PerseidMock(200, "application/json", "{\"secret\":\"sample\"}"); + mock.client.webhookEndpoints().endpoints().rotateSecret("endpoint_id"); + assertEquals( + List.of("POST /api/v1/webhooks/endpoints/endpoint_id/rotate-secret"), + mock.requests); + } + + @Test + void retrieveSecret() throws Exception { + PerseidMock mock = new PerseidMock(200, "application/json", "{\"secret\":\"sample\"}"); + mock.client.webhookEndpoints().endpoints().retrieveSecret("endpoint_id"); + assertEquals(List.of("GET /api/v1/webhooks/endpoints/endpoint_id/secret"), mock.requests); + } +} diff --git a/src/test/java/com/meteroid/api/WebhookEndpointsTest.java b/src/test/java/com/meteroid/api/WebhookEndpointsTest.java new file mode 100644 index 0000000..0ac8e42 --- /dev/null +++ b/src/test/java/com/meteroid/api/WebhookEndpointsTest.java @@ -0,0 +1,22 @@ +// this file is @generated +package com.meteroid.api; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.junit.jupiter.api.Test; + +import java.util.List; + +class WebhookEndpointsTest { + + @Test + void resendWebhookDelivery() throws Exception { + PerseidMock mock = + new PerseidMock( + 200, + "application/json", + "{\"attempt_count\":-2147483648,\"created_at\":\"2023-12-31T23:59:59.999-05:30\",\"endpoint_id\":\"webhook_endpoint_id_44\",\"event_type\":\"sample\",\"id\":\"webhook_delivery_id_90\",\"manual\":false,\"message_id\":\"event_id_90\",\"status\":\"IN_FLIGHT\"}"); + mock.client.webhookEndpoints().resendWebhookDelivery("delivery_id"); + assertEquals(List.of("POST /api/v1/webhooks/deliveries/delivery_id/resend"), mock.requests); + } +}