From a2d2c6c85933a569a9ad240f071208acca64c79c Mon Sep 17 00:00:00 2001 From: "fern-api[bot]" <115122769+fern-api[bot]@users.noreply.github.com> Date: Tue, 30 Jun 2026 17:42:22 +0000 Subject: [PATCH 1/2] [fern-generated] Update SDK Generated by Fern CLI Version: unknown Generators: - fernapi/fern-java-sdk: 4.10.7 --- .fern/metadata.json | 6 +- build.gradle | 4 +- reference.md | 190 +++++++++++++ .../com/schematic/api/core/ClientOptions.java | 4 +- .../resources/billing/AsyncBillingClient.java | 30 ++ .../billing/AsyncRawBillingClient.java | 264 ++++++++++++++++++ .../api/resources/billing/BillingClient.java | 27 ++ .../resources/billing/RawBillingClient.java | 189 +++++++++++++ .../types/DeleteBillingCouponResponse.java | 181 ++++++++++++ .../types/DeleteBillingCustomerResponse.java | 181 ++++++++++++ .../types/DeleteBillingInvoiceResponse.java | 181 ++++++++++++ .../requests/CheckoutDataRequestBody.java | 41 ++- .../PublishPlanVersionRequestBody.java | 32 +++ .../webhooks/AsyncRawWebhooksClient.java | 98 +++++++ .../webhooks/AsyncWebhooksClient.java | 14 + .../resources/webhooks/RawWebhooksClient.java | 74 +++++ .../resources/webhooks/WebhooksClient.java | 13 + .../requests/TestWebhookRequestBody.java | 119 ++++++++ .../types/SendTestWebhookActionResponse.java | 181 ++++++++++++ .../types/BillingCreditGrantResponseData.java | 12 +- .../schematic/api/types/CountResponse.java | 12 +- .../api/types/CreditCompanyGrantView.java | 12 +- .../types/CreditEventLedgerResponseData.java | 16 +- .../schematic/api/types/EventBodyTrack.java | 16 +- .../api/types/PlanChangeResponseData.java | 45 +++ .../api/types/RulesEngineSchemaVersion.java | 18 +- .../api/types/TestWebhookResponseData.java | 139 +++++++++ 27 files changed, 2045 insertions(+), 54 deletions(-) create mode 100644 src/main/java/com/schematic/api/resources/billing/types/DeleteBillingCouponResponse.java create mode 100644 src/main/java/com/schematic/api/resources/billing/types/DeleteBillingCustomerResponse.java create mode 100644 src/main/java/com/schematic/api/resources/billing/types/DeleteBillingInvoiceResponse.java create mode 100644 src/main/java/com/schematic/api/resources/webhooks/requests/TestWebhookRequestBody.java create mode 100644 src/main/java/com/schematic/api/resources/webhooks/types/SendTestWebhookActionResponse.java create mode 100644 src/main/java/com/schematic/api/types/TestWebhookResponseData.java diff --git a/.fern/metadata.json b/.fern/metadata.json index 21ea3fa..5346424 100644 --- a/.fern/metadata.json +++ b/.fern/metadata.json @@ -14,10 +14,10 @@ "implementation redis.clients:jedis:5.2.0" ] }, - "originGitCommit": "221a7c7d042bcb7d7609c93552e3c148814df3f5", + "originGitCommit": "deb8532a1f84f6daa08b5c611a66a5ec92f53f0e", "originGitCommitIsDirty": false, "invokedBy": "ci", - "requestedVersion": "1.4.4", + "requestedVersion": "1.4.5", "ciProvider": "github", - "sdkVersion": "1.4.4" + "sdkVersion": "1.4.5" } \ No newline at end of file diff --git a/build.gradle b/build.gradle index cc851a1..a651957 100644 --- a/build.gradle +++ b/build.gradle @@ -52,7 +52,7 @@ java { group = 'com.schematichq' -version = '1.4.4' +version = '1.4.5' jar { dependsOn(":generatePomFileForMavenPublication") @@ -83,7 +83,7 @@ publishing { maven(MavenPublication) { groupId = 'com.schematichq' artifactId = 'schematic-java' - version = '1.4.4' + version = '1.4.5' from components.java pom { name = 'Schematic' diff --git a/reference.md b/reference.md index 9ef8052..a4f50b6 100644 --- a/reference.md +++ b/reference.md @@ -1300,6 +1300,86 @@ client.billing().upsertBillingCoupon( + + + + +
client.billing.deleteBillingCoupon(billingId) -> DeleteBillingCouponResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.billing().deleteBillingCoupon("billing_id"); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**billingId:** `String` — billing_id + +
+
+
+
+ + +
+
+
+ +
client.billing.deleteBillingCustomer(billingId) -> DeleteBillingCustomerResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.billing().deleteBillingCustomer("billing_id"); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**billingId:** `String` — billing_id + +
+
+
+
+ +
@@ -1812,6 +1892,46 @@ client.billing().upsertInvoice( + + + + +
client.billing.deleteBillingInvoice(billingId) -> DeleteBillingInvoiceResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.billing().deleteBillingInvoice("billing_id"); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**billingId:** `String` — billing_id + +
+
+
+
+ +
@@ -6016,6 +6136,14 @@ client.checkout().getCheckoutData(
+**currency:** `Optional` + +
+
+ +
+
+ **selectedPlanId:** `Optional`
@@ -12994,6 +13122,14 @@ client.plans().publishPlanVersion(
+**couponExternalId:** `Optional` + +
+
+ +
+
+ **customerEmail:** `Optional`
@@ -18428,6 +18564,60 @@ client.webhooks().deleteWebhook("webhook_id");
+ +
+ + +
client.webhooks.sendTestWebhookAction(webhookId, request) -> SendTestWebhookActionResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.webhooks().sendTestWebhookAction( + "webhook_id", + TestWebhookRequestBody + .builder() + .requestType(WebhookRequestType.SUBSCRIPTION_TRIAL_ENDED) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**webhookId:** `String` — webhook_id + +
+
+ +
+
+ +**requestType:** `WebhookRequestType` + +
+
+
+
+ +
diff --git a/src/main/java/com/schematic/api/core/ClientOptions.java b/src/main/java/com/schematic/api/core/ClientOptions.java index b0e5fc5..2361d9a 100644 --- a/src/main/java/com/schematic/api/core/ClientOptions.java +++ b/src/main/java/com/schematic/api/core/ClientOptions.java @@ -38,10 +38,10 @@ private ClientOptions( this.headers.putAll(headers); this.headers.putAll(new HashMap() { { - put("User-Agent", "com.schematichq:schematic-java/1.4.4"); + put("User-Agent", "com.schematichq:schematic-java/1.4.5"); put("X-Fern-Language", "JAVA"); put("X-Fern-SDK-Name", "com.schematic.fern:api-sdk"); - put("X-Fern-SDK-Version", "1.4.4"); + put("X-Fern-SDK-Version", "1.4.5"); } }); this.headerSuppliers = headerSuppliers; diff --git a/src/main/java/com/schematic/api/resources/billing/AsyncBillingClient.java b/src/main/java/com/schematic/api/resources/billing/AsyncBillingClient.java index cd9bb7e..a6087b7 100644 --- a/src/main/java/com/schematic/api/resources/billing/AsyncBillingClient.java +++ b/src/main/java/com/schematic/api/resources/billing/AsyncBillingClient.java @@ -25,6 +25,9 @@ import com.schematic.api.resources.billing.requests.ListPaymentMethodsRequest; import com.schematic.api.resources.billing.types.CountBillingProductsResponse; import com.schematic.api.resources.billing.types.CountCustomersResponse; +import com.schematic.api.resources.billing.types.DeleteBillingCouponResponse; +import com.schematic.api.resources.billing.types.DeleteBillingCustomerResponse; +import com.schematic.api.resources.billing.types.DeleteBillingInvoiceResponse; import com.schematic.api.resources.billing.types.DeleteBillingProductResponse; import com.schematic.api.resources.billing.types.DeletePaymentMethodByExternalIdResponse; import com.schematic.api.resources.billing.types.DeleteProductPriceResponse; @@ -89,6 +92,24 @@ public CompletableFuture upsertBillingCoupon( return this.rawClient.upsertBillingCoupon(request, requestOptions).thenApply(response -> response.body()); } + public CompletableFuture deleteBillingCoupon(String billingId) { + return this.rawClient.deleteBillingCoupon(billingId).thenApply(response -> response.body()); + } + + public CompletableFuture deleteBillingCoupon( + String billingId, RequestOptions requestOptions) { + return this.rawClient.deleteBillingCoupon(billingId, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture deleteBillingCustomer(String billingId) { + return this.rawClient.deleteBillingCustomer(billingId).thenApply(response -> response.body()); + } + + public CompletableFuture deleteBillingCustomer( + String billingId, RequestOptions requestOptions) { + return this.rawClient.deleteBillingCustomer(billingId, requestOptions).thenApply(response -> response.body()); + } + public CompletableFuture upsertBillingCustomer( CreateBillingCustomerRequestBody request) { return this.rawClient.upsertBillingCustomer(request).thenApply(response -> response.body()); @@ -155,6 +176,15 @@ public CompletableFuture upsertInvoice( return this.rawClient.upsertInvoice(request, requestOptions).thenApply(response -> response.body()); } + public CompletableFuture deleteBillingInvoice(String billingId) { + return this.rawClient.deleteBillingInvoice(billingId).thenApply(response -> response.body()); + } + + public CompletableFuture deleteBillingInvoice( + String billingId, RequestOptions requestOptions) { + return this.rawClient.deleteBillingInvoice(billingId, requestOptions).thenApply(response -> response.body()); + } + public CompletableFuture listMeters() { return this.rawClient.listMeters().thenApply(response -> response.body()); } diff --git a/src/main/java/com/schematic/api/resources/billing/AsyncRawBillingClient.java b/src/main/java/com/schematic/api/resources/billing/AsyncRawBillingClient.java index 4bc1bf0..baa96d3 100644 --- a/src/main/java/com/schematic/api/resources/billing/AsyncRawBillingClient.java +++ b/src/main/java/com/schematic/api/resources/billing/AsyncRawBillingClient.java @@ -37,6 +37,9 @@ import com.schematic.api.resources.billing.requests.ListPaymentMethodsRequest; import com.schematic.api.resources.billing.types.CountBillingProductsResponse; import com.schematic.api.resources.billing.types.CountCustomersResponse; +import com.schematic.api.resources.billing.types.DeleteBillingCouponResponse; +import com.schematic.api.resources.billing.types.DeleteBillingCustomerResponse; +import com.schematic.api.resources.billing.types.DeleteBillingInvoiceResponse; import com.schematic.api.resources.billing.types.DeleteBillingProductResponse; import com.schematic.api.resources.billing.types.DeletePaymentMethodByExternalIdResponse; import com.schematic.api.resources.billing.types.DeleteProductPriceResponse; @@ -279,6 +282,180 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { return future; } + public CompletableFuture> deleteBillingCoupon( + String billingId) { + return deleteBillingCoupon(billingId, null); + } + + public CompletableFuture> deleteBillingCoupon( + String billingId, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/coupons") + .addPathSegment(billingId); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl.build()) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBodyString, DeleteBillingCouponResponse.class), + response)); + return; + } + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), response.code(), errorBody, response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> deleteBillingCustomer( + String billingId) { + return deleteBillingCustomer(billingId, null); + } + + public CompletableFuture> deleteBillingCustomer( + String billingId, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/customer") + .addPathSegment(billingId); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl.build()) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBodyString, DeleteBillingCustomerResponse.class), + response)); + return; + } + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), response.code(), errorBody, response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + public CompletableFuture> upsertBillingCustomer( CreateBillingCustomerRequestBody request) { return upsertBillingCustomer(request, null); @@ -806,6 +983,93 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { return future; } + public CompletableFuture> deleteBillingInvoice( + String billingId) { + return deleteBillingInvoice(billingId, null); + } + + public CompletableFuture> deleteBillingInvoice( + String billingId, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/invoices") + .addPathSegment(billingId); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl.build()) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBodyString, DeleteBillingInvoiceResponse.class), + response)); + return; + } + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), response.code(), errorBody, response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + public CompletableFuture> listMeters() { return listMeters(ListMetersRequest.builder().build()); } diff --git a/src/main/java/com/schematic/api/resources/billing/BillingClient.java b/src/main/java/com/schematic/api/resources/billing/BillingClient.java index 013d4b9..97fc219 100644 --- a/src/main/java/com/schematic/api/resources/billing/BillingClient.java +++ b/src/main/java/com/schematic/api/resources/billing/BillingClient.java @@ -25,6 +25,9 @@ import com.schematic.api.resources.billing.requests.ListPaymentMethodsRequest; import com.schematic.api.resources.billing.types.CountBillingProductsResponse; import com.schematic.api.resources.billing.types.CountCustomersResponse; +import com.schematic.api.resources.billing.types.DeleteBillingCouponResponse; +import com.schematic.api.resources.billing.types.DeleteBillingCustomerResponse; +import com.schematic.api.resources.billing.types.DeleteBillingInvoiceResponse; import com.schematic.api.resources.billing.types.DeleteBillingProductResponse; import com.schematic.api.resources.billing.types.DeletePaymentMethodByExternalIdResponse; import com.schematic.api.resources.billing.types.DeleteProductPriceResponse; @@ -87,6 +90,22 @@ public UpsertBillingCouponResponse upsertBillingCoupon( return this.rawClient.upsertBillingCoupon(request, requestOptions).body(); } + public DeleteBillingCouponResponse deleteBillingCoupon(String billingId) { + return this.rawClient.deleteBillingCoupon(billingId).body(); + } + + public DeleteBillingCouponResponse deleteBillingCoupon(String billingId, RequestOptions requestOptions) { + return this.rawClient.deleteBillingCoupon(billingId, requestOptions).body(); + } + + public DeleteBillingCustomerResponse deleteBillingCustomer(String billingId) { + return this.rawClient.deleteBillingCustomer(billingId).body(); + } + + public DeleteBillingCustomerResponse deleteBillingCustomer(String billingId, RequestOptions requestOptions) { + return this.rawClient.deleteBillingCustomer(billingId, requestOptions).body(); + } + public UpsertBillingCustomerResponse upsertBillingCustomer(CreateBillingCustomerRequestBody request) { return this.rawClient.upsertBillingCustomer(request).body(); } @@ -148,6 +167,14 @@ public UpsertInvoiceResponse upsertInvoice(CreateInvoiceRequestBody request, Req return this.rawClient.upsertInvoice(request, requestOptions).body(); } + public DeleteBillingInvoiceResponse deleteBillingInvoice(String billingId) { + return this.rawClient.deleteBillingInvoice(billingId).body(); + } + + public DeleteBillingInvoiceResponse deleteBillingInvoice(String billingId, RequestOptions requestOptions) { + return this.rawClient.deleteBillingInvoice(billingId, requestOptions).body(); + } + public ListMetersResponse listMeters() { return this.rawClient.listMeters().body(); } diff --git a/src/main/java/com/schematic/api/resources/billing/RawBillingClient.java b/src/main/java/com/schematic/api/resources/billing/RawBillingClient.java index 2f59639..b3482ed 100644 --- a/src/main/java/com/schematic/api/resources/billing/RawBillingClient.java +++ b/src/main/java/com/schematic/api/resources/billing/RawBillingClient.java @@ -37,6 +37,9 @@ import com.schematic.api.resources.billing.requests.ListPaymentMethodsRequest; import com.schematic.api.resources.billing.types.CountBillingProductsResponse; import com.schematic.api.resources.billing.types.CountCustomersResponse; +import com.schematic.api.resources.billing.types.DeleteBillingCouponResponse; +import com.schematic.api.resources.billing.types.DeleteBillingCustomerResponse; +import com.schematic.api.resources.billing.types.DeleteBillingInvoiceResponse; import com.schematic.api.resources.billing.types.DeleteBillingProductResponse; import com.schematic.api.resources.billing.types.DeletePaymentMethodByExternalIdResponse; import com.schematic.api.resources.billing.types.DeleteProductPriceResponse; @@ -225,6 +228,130 @@ public BaseSchematicHttpResponse upsertBillingCoupo } } + public BaseSchematicHttpResponse deleteBillingCoupon(String billingId) { + return deleteBillingCoupon(billingId, null); + } + + public BaseSchematicHttpResponse deleteBillingCoupon( + String billingId, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/coupons") + .addPathSegment(billingId); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl.build()) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, DeleteBillingCouponResponse.class), + response); + } + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + throw new BaseSchematicApiException( + "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse deleteBillingCustomer(String billingId) { + return deleteBillingCustomer(billingId, null); + } + + public BaseSchematicHttpResponse deleteBillingCustomer( + String billingId, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/customer") + .addPathSegment(billingId); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl.build()) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, DeleteBillingCustomerResponse.class), + response); + } + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + throw new BaseSchematicApiException( + "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + public BaseSchematicHttpResponse upsertBillingCustomer( CreateBillingCustomerRequestBody request) { return upsertBillingCustomer(request, null); @@ -627,6 +754,68 @@ public BaseSchematicHttpResponse upsertInvoice( } } + public BaseSchematicHttpResponse deleteBillingInvoice(String billingId) { + return deleteBillingInvoice(billingId, null); + } + + public BaseSchematicHttpResponse deleteBillingInvoice( + String billingId, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/invoices") + .addPathSegment(billingId); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl.build()) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, DeleteBillingInvoiceResponse.class), + response); + } + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + throw new BaseSchematicApiException( + "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + public BaseSchematicHttpResponse listMeters() { return listMeters(ListMetersRequest.builder().build()); } diff --git a/src/main/java/com/schematic/api/resources/billing/types/DeleteBillingCouponResponse.java b/src/main/java/com/schematic/api/resources/billing/types/DeleteBillingCouponResponse.java new file mode 100644 index 0000000..0183257 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/billing/types/DeleteBillingCouponResponse.java @@ -0,0 +1,181 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.billing.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.types.DeleteResponse; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = DeleteBillingCouponResponse.Builder.class) +public final class DeleteBillingCouponResponse { + private final DeleteResponse data; + + private final Map params; + + private final Map additionalProperties; + + private DeleteBillingCouponResponse( + DeleteResponse data, Map params, Map additionalProperties) { + this.data = data; + this.params = params; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("data") + public DeleteResponse getData() { + return data; + } + + /** + * @return Input parameters + */ + @JsonProperty("params") + public Map getParams() { + return params; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DeleteBillingCouponResponse && equalTo((DeleteBillingCouponResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DeleteBillingCouponResponse other) { + return data.equals(other.data) && params.equals(other.params); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.data, this.params); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static DataStage builder() { + return new Builder(); + } + + public interface DataStage { + _FinalStage data(@NotNull DeleteResponse data); + + Builder from(DeleteBillingCouponResponse other); + } + + public interface _FinalStage { + DeleteBillingCouponResponse build(); + + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); + + /** + *

Input parameters

+ */ + _FinalStage params(Map params); + + _FinalStage putAllParams(Map params); + + _FinalStage params(String key, JsonNode value); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements DataStage, _FinalStage { + private DeleteResponse data; + + private Map params = new LinkedHashMap<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(DeleteBillingCouponResponse other) { + data(other.getData()); + params(other.getParams()); + return this; + } + + @java.lang.Override + @JsonSetter("data") + public _FinalStage data(@NotNull DeleteResponse data) { + this.data = Objects.requireNonNull(data, "data must not be null"); + return this; + } + + /** + *

Input parameters

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage params(String key, JsonNode value) { + this.params.put(key, value); + return this; + } + + /** + *

Input parameters

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage putAllParams(Map params) { + if (params != null) { + this.params.putAll(params); + } + return this; + } + + /** + *

Input parameters

+ */ + @java.lang.Override + @JsonSetter(value = "params", nulls = Nulls.SKIP) + public _FinalStage params(Map params) { + this.params.clear(); + if (params != null) { + this.params.putAll(params); + } + return this; + } + + @java.lang.Override + public DeleteBillingCouponResponse build() { + return new DeleteBillingCouponResponse(data, params, additionalProperties); + } + + @java.lang.Override + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + @java.lang.Override + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + } +} diff --git a/src/main/java/com/schematic/api/resources/billing/types/DeleteBillingCustomerResponse.java b/src/main/java/com/schematic/api/resources/billing/types/DeleteBillingCustomerResponse.java new file mode 100644 index 0000000..a34d567 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/billing/types/DeleteBillingCustomerResponse.java @@ -0,0 +1,181 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.billing.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.types.DeleteResponse; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = DeleteBillingCustomerResponse.Builder.class) +public final class DeleteBillingCustomerResponse { + private final DeleteResponse data; + + private final Map params; + + private final Map additionalProperties; + + private DeleteBillingCustomerResponse( + DeleteResponse data, Map params, Map additionalProperties) { + this.data = data; + this.params = params; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("data") + public DeleteResponse getData() { + return data; + } + + /** + * @return Input parameters + */ + @JsonProperty("params") + public Map getParams() { + return params; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DeleteBillingCustomerResponse && equalTo((DeleteBillingCustomerResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DeleteBillingCustomerResponse other) { + return data.equals(other.data) && params.equals(other.params); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.data, this.params); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static DataStage builder() { + return new Builder(); + } + + public interface DataStage { + _FinalStage data(@NotNull DeleteResponse data); + + Builder from(DeleteBillingCustomerResponse other); + } + + public interface _FinalStage { + DeleteBillingCustomerResponse build(); + + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); + + /** + *

Input parameters

+ */ + _FinalStage params(Map params); + + _FinalStage putAllParams(Map params); + + _FinalStage params(String key, JsonNode value); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements DataStage, _FinalStage { + private DeleteResponse data; + + private Map params = new LinkedHashMap<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(DeleteBillingCustomerResponse other) { + data(other.getData()); + params(other.getParams()); + return this; + } + + @java.lang.Override + @JsonSetter("data") + public _FinalStage data(@NotNull DeleteResponse data) { + this.data = Objects.requireNonNull(data, "data must not be null"); + return this; + } + + /** + *

Input parameters

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage params(String key, JsonNode value) { + this.params.put(key, value); + return this; + } + + /** + *

Input parameters

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage putAllParams(Map params) { + if (params != null) { + this.params.putAll(params); + } + return this; + } + + /** + *

Input parameters

+ */ + @java.lang.Override + @JsonSetter(value = "params", nulls = Nulls.SKIP) + public _FinalStage params(Map params) { + this.params.clear(); + if (params != null) { + this.params.putAll(params); + } + return this; + } + + @java.lang.Override + public DeleteBillingCustomerResponse build() { + return new DeleteBillingCustomerResponse(data, params, additionalProperties); + } + + @java.lang.Override + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + @java.lang.Override + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + } +} diff --git a/src/main/java/com/schematic/api/resources/billing/types/DeleteBillingInvoiceResponse.java b/src/main/java/com/schematic/api/resources/billing/types/DeleteBillingInvoiceResponse.java new file mode 100644 index 0000000..fc0e9db --- /dev/null +++ b/src/main/java/com/schematic/api/resources/billing/types/DeleteBillingInvoiceResponse.java @@ -0,0 +1,181 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.billing.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.types.DeleteResponse; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = DeleteBillingInvoiceResponse.Builder.class) +public final class DeleteBillingInvoiceResponse { + private final DeleteResponse data; + + private final Map params; + + private final Map additionalProperties; + + private DeleteBillingInvoiceResponse( + DeleteResponse data, Map params, Map additionalProperties) { + this.data = data; + this.params = params; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("data") + public DeleteResponse getData() { + return data; + } + + /** + * @return Input parameters + */ + @JsonProperty("params") + public Map getParams() { + return params; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DeleteBillingInvoiceResponse && equalTo((DeleteBillingInvoiceResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DeleteBillingInvoiceResponse other) { + return data.equals(other.data) && params.equals(other.params); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.data, this.params); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static DataStage builder() { + return new Builder(); + } + + public interface DataStage { + _FinalStage data(@NotNull DeleteResponse data); + + Builder from(DeleteBillingInvoiceResponse other); + } + + public interface _FinalStage { + DeleteBillingInvoiceResponse build(); + + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); + + /** + *

Input parameters

+ */ + _FinalStage params(Map params); + + _FinalStage putAllParams(Map params); + + _FinalStage params(String key, JsonNode value); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements DataStage, _FinalStage { + private DeleteResponse data; + + private Map params = new LinkedHashMap<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(DeleteBillingInvoiceResponse other) { + data(other.getData()); + params(other.getParams()); + return this; + } + + @java.lang.Override + @JsonSetter("data") + public _FinalStage data(@NotNull DeleteResponse data) { + this.data = Objects.requireNonNull(data, "data must not be null"); + return this; + } + + /** + *

Input parameters

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage params(String key, JsonNode value) { + this.params.put(key, value); + return this; + } + + /** + *

Input parameters

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage putAllParams(Map params) { + if (params != null) { + this.params.putAll(params); + } + return this; + } + + /** + *

Input parameters

+ */ + @java.lang.Override + @JsonSetter(value = "params", nulls = Nulls.SKIP) + public _FinalStage params(Map params) { + this.params.clear(); + if (params != null) { + this.params.putAll(params); + } + return this; + } + + @java.lang.Override + public DeleteBillingInvoiceResponse build() { + return new DeleteBillingInvoiceResponse(data, params, additionalProperties); + } + + @java.lang.Override + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + @java.lang.Override + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + } +} diff --git a/src/main/java/com/schematic/api/resources/checkout/requests/CheckoutDataRequestBody.java b/src/main/java/com/schematic/api/resources/checkout/requests/CheckoutDataRequestBody.java index 92a936c..f323505 100644 --- a/src/main/java/com/schematic/api/resources/checkout/requests/CheckoutDataRequestBody.java +++ b/src/main/java/com/schematic/api/resources/checkout/requests/CheckoutDataRequestBody.java @@ -23,13 +23,19 @@ public final class CheckoutDataRequestBody { private final String companyId; + private final Optional currency; + private final Optional selectedPlanId; private final Map additionalProperties; private CheckoutDataRequestBody( - String companyId, Optional selectedPlanId, Map additionalProperties) { + String companyId, + Optional currency, + Optional selectedPlanId, + Map additionalProperties) { this.companyId = companyId; + this.currency = currency; this.selectedPlanId = selectedPlanId; this.additionalProperties = additionalProperties; } @@ -39,6 +45,11 @@ public String getCompanyId() { return companyId; } + @JsonProperty("currency") + public Optional getCurrency() { + return currency; + } + @JsonProperty("selected_plan_id") public Optional getSelectedPlanId() { return selectedPlanId; @@ -56,12 +67,14 @@ public Map getAdditionalProperties() { } private boolean equalTo(CheckoutDataRequestBody other) { - return companyId.equals(other.companyId) && selectedPlanId.equals(other.selectedPlanId); + return companyId.equals(other.companyId) + && currency.equals(other.currency) + && selectedPlanId.equals(other.selectedPlanId); } @java.lang.Override public int hashCode() { - return Objects.hash(this.companyId, this.selectedPlanId); + return Objects.hash(this.companyId, this.currency, this.selectedPlanId); } @java.lang.Override @@ -86,6 +99,10 @@ public interface _FinalStage { _FinalStage additionalProperties(Map additionalProperties); + _FinalStage currency(Optional currency); + + _FinalStage currency(String currency); + _FinalStage selectedPlanId(Optional selectedPlanId); _FinalStage selectedPlanId(String selectedPlanId); @@ -97,6 +114,8 @@ public static final class Builder implements CompanyIdStage, _FinalStage { private Optional selectedPlanId = Optional.empty(); + private Optional currency = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -105,6 +124,7 @@ private Builder() {} @java.lang.Override public Builder from(CheckoutDataRequestBody other) { companyId(other.getCompanyId()); + currency(other.getCurrency()); selectedPlanId(other.getSelectedPlanId()); return this; } @@ -129,9 +149,22 @@ public _FinalStage selectedPlanId(Optional selectedPlanId) { return this; } + @java.lang.Override + public _FinalStage currency(String currency) { + this.currency = Optional.ofNullable(currency); + return this; + } + + @java.lang.Override + @JsonSetter(value = "currency", nulls = Nulls.SKIP) + public _FinalStage currency(Optional currency) { + this.currency = currency; + return this; + } + @java.lang.Override public CheckoutDataRequestBody build() { - return new CheckoutDataRequestBody(companyId, selectedPlanId, additionalProperties); + return new CheckoutDataRequestBody(companyId, currency, selectedPlanId, additionalProperties); } @java.lang.Override diff --git a/src/main/java/com/schematic/api/resources/plans/requests/PublishPlanVersionRequestBody.java b/src/main/java/com/schematic/api/resources/plans/requests/PublishPlanVersionRequestBody.java index 02bbce9..50856e9 100644 --- a/src/main/java/com/schematic/api/resources/plans/requests/PublishPlanVersionRequestBody.java +++ b/src/main/java/com/schematic/api/resources/plans/requests/PublishPlanVersionRequestBody.java @@ -27,6 +27,8 @@ public final class PublishPlanVersionRequestBody { private final Optional activationStrategy; + private final Optional couponExternalId; + private final Optional customerEmail; private final Optional daysUntilDue; @@ -39,12 +41,14 @@ public final class PublishPlanVersionRequestBody { private PublishPlanVersionRequestBody( Optional activationStrategy, + Optional couponExternalId, Optional customerEmail, Optional daysUntilDue, List excludedCompanyIds, PlanVersionMigrationStrategy migrationStrategy, Map additionalProperties) { this.activationStrategy = activationStrategy; + this.couponExternalId = couponExternalId; this.customerEmail = customerEmail; this.daysUntilDue = daysUntilDue; this.excludedCompanyIds = excludedCompanyIds; @@ -57,6 +61,11 @@ public Optional getActivationStrategy() { return activationStrategy; } + @JsonProperty("coupon_external_id") + public Optional getCouponExternalId() { + return couponExternalId; + } + @JsonProperty("customer_email") public Optional getCustomerEmail() { return customerEmail; @@ -90,6 +99,7 @@ public Map getAdditionalProperties() { private boolean equalTo(PublishPlanVersionRequestBody other) { return activationStrategy.equals(other.activationStrategy) + && couponExternalId.equals(other.couponExternalId) && customerEmail.equals(other.customerEmail) && daysUntilDue.equals(other.daysUntilDue) && excludedCompanyIds.equals(other.excludedCompanyIds) @@ -100,6 +110,7 @@ private boolean equalTo(PublishPlanVersionRequestBody other) { public int hashCode() { return Objects.hash( this.activationStrategy, + this.couponExternalId, this.customerEmail, this.daysUntilDue, this.excludedCompanyIds, @@ -132,6 +143,10 @@ public interface _FinalStage { _FinalStage activationStrategy(CustomPlanActivationStrategy activationStrategy); + _FinalStage couponExternalId(Optional couponExternalId); + + _FinalStage couponExternalId(String couponExternalId); + _FinalStage customerEmail(Optional customerEmail); _FinalStage customerEmail(String customerEmail); @@ -157,6 +172,8 @@ public static final class Builder implements MigrationStrategyStage, _FinalStage private Optional customerEmail = Optional.empty(); + private Optional couponExternalId = Optional.empty(); + private Optional activationStrategy = Optional.empty(); @JsonAnySetter @@ -167,6 +184,7 @@ private Builder() {} @java.lang.Override public Builder from(PublishPlanVersionRequestBody other) { activationStrategy(other.getActivationStrategy()); + couponExternalId(other.getCouponExternalId()); customerEmail(other.getCustomerEmail()); daysUntilDue(other.getDaysUntilDue()); excludedCompanyIds(other.getExcludedCompanyIds()); @@ -231,6 +249,19 @@ public _FinalStage customerEmail(Optional customerEmail) { return this; } + @java.lang.Override + public _FinalStage couponExternalId(String couponExternalId) { + this.couponExternalId = Optional.ofNullable(couponExternalId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "coupon_external_id", nulls = Nulls.SKIP) + public _FinalStage couponExternalId(Optional couponExternalId) { + this.couponExternalId = couponExternalId; + return this; + } + @java.lang.Override public _FinalStage activationStrategy(CustomPlanActivationStrategy activationStrategy) { this.activationStrategy = Optional.ofNullable(activationStrategy); @@ -248,6 +279,7 @@ public _FinalStage activationStrategy(Optional act public PublishPlanVersionRequestBody build() { return new PublishPlanVersionRequestBody( activationStrategy, + couponExternalId, customerEmail, daysUntilDue, excludedCompanyIds, diff --git a/src/main/java/com/schematic/api/resources/webhooks/AsyncRawWebhooksClient.java b/src/main/java/com/schematic/api/resources/webhooks/AsyncRawWebhooksClient.java index 084b8bd..cd7e62d 100644 --- a/src/main/java/com/schematic/api/resources/webhooks/AsyncRawWebhooksClient.java +++ b/src/main/java/com/schematic/api/resources/webhooks/AsyncRawWebhooksClient.java @@ -22,6 +22,7 @@ import com.schematic.api.resources.webhooks.requests.CreateWebhookRequestBody; import com.schematic.api.resources.webhooks.requests.ListWebhookEventsRequest; import com.schematic.api.resources.webhooks.requests.ListWebhooksRequest; +import com.schematic.api.resources.webhooks.requests.TestWebhookRequestBody; import com.schematic.api.resources.webhooks.requests.UpdateWebhookRequestBody; import com.schematic.api.resources.webhooks.types.CountWebhookEventsResponse; import com.schematic.api.resources.webhooks.types.CountWebhooksResponse; @@ -31,6 +32,7 @@ import com.schematic.api.resources.webhooks.types.GetWebhookResponse; import com.schematic.api.resources.webhooks.types.ListWebhookEventsResponse; import com.schematic.api.resources.webhooks.types.ListWebhooksResponse; +import com.schematic.api.resources.webhooks.types.SendTestWebhookActionResponse; import com.schematic.api.resources.webhooks.types.UpdateWebhookResponse; import com.schematic.api.types.ApiError; import java.io.IOException; @@ -826,6 +828,102 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { return future; } + public CompletableFuture> sendTestWebhookAction( + String webhookId, TestWebhookRequestBody request) { + return sendTestWebhookAction(webhookId, request, null); + } + + public CompletableFuture> sendTestWebhookAction( + String webhookId, TestWebhookRequestBody request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("webhooks") + .addPathSegment(webhookId) + .addPathSegments("test"); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl.build()) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBodyString, SendTestWebhookActionResponse.class), + response)); + return; + } + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), response.code(), errorBody, response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + public CompletableFuture> countWebhooks() { return countWebhooks(CountWebhooksRequest.builder().build()); } diff --git a/src/main/java/com/schematic/api/resources/webhooks/AsyncWebhooksClient.java b/src/main/java/com/schematic/api/resources/webhooks/AsyncWebhooksClient.java index 7ec64b5..76a732d 100644 --- a/src/main/java/com/schematic/api/resources/webhooks/AsyncWebhooksClient.java +++ b/src/main/java/com/schematic/api/resources/webhooks/AsyncWebhooksClient.java @@ -10,6 +10,7 @@ import com.schematic.api.resources.webhooks.requests.CreateWebhookRequestBody; import com.schematic.api.resources.webhooks.requests.ListWebhookEventsRequest; import com.schematic.api.resources.webhooks.requests.ListWebhooksRequest; +import com.schematic.api.resources.webhooks.requests.TestWebhookRequestBody; import com.schematic.api.resources.webhooks.requests.UpdateWebhookRequestBody; import com.schematic.api.resources.webhooks.types.CountWebhookEventsResponse; import com.schematic.api.resources.webhooks.types.CountWebhooksResponse; @@ -19,6 +20,7 @@ import com.schematic.api.resources.webhooks.types.GetWebhookResponse; import com.schematic.api.resources.webhooks.types.ListWebhookEventsResponse; import com.schematic.api.resources.webhooks.types.ListWebhooksResponse; +import com.schematic.api.resources.webhooks.types.SendTestWebhookActionResponse; import com.schematic.api.resources.webhooks.types.UpdateWebhookResponse; import java.util.concurrent.CompletableFuture; @@ -141,6 +143,18 @@ public CompletableFuture deleteWebhook(String webhookId, return this.rawClient.deleteWebhook(webhookId, requestOptions).thenApply(response -> response.body()); } + public CompletableFuture sendTestWebhookAction( + String webhookId, TestWebhookRequestBody request) { + return this.rawClient.sendTestWebhookAction(webhookId, request).thenApply(response -> response.body()); + } + + public CompletableFuture sendTestWebhookAction( + String webhookId, TestWebhookRequestBody request, RequestOptions requestOptions) { + return this.rawClient + .sendTestWebhookAction(webhookId, request, requestOptions) + .thenApply(response -> response.body()); + } + public CompletableFuture countWebhooks() { return this.rawClient.countWebhooks().thenApply(response -> response.body()); } diff --git a/src/main/java/com/schematic/api/resources/webhooks/RawWebhooksClient.java b/src/main/java/com/schematic/api/resources/webhooks/RawWebhooksClient.java index 0375d9f..9c6ca22 100644 --- a/src/main/java/com/schematic/api/resources/webhooks/RawWebhooksClient.java +++ b/src/main/java/com/schematic/api/resources/webhooks/RawWebhooksClient.java @@ -22,6 +22,7 @@ import com.schematic.api.resources.webhooks.requests.CreateWebhookRequestBody; import com.schematic.api.resources.webhooks.requests.ListWebhookEventsRequest; import com.schematic.api.resources.webhooks.requests.ListWebhooksRequest; +import com.schematic.api.resources.webhooks.requests.TestWebhookRequestBody; import com.schematic.api.resources.webhooks.requests.UpdateWebhookRequestBody; import com.schematic.api.resources.webhooks.types.CountWebhookEventsResponse; import com.schematic.api.resources.webhooks.types.CountWebhooksResponse; @@ -31,6 +32,7 @@ import com.schematic.api.resources.webhooks.types.GetWebhookResponse; import com.schematic.api.resources.webhooks.types.ListWebhookEventsResponse; import com.schematic.api.resources.webhooks.types.ListWebhooksResponse; +import com.schematic.api.resources.webhooks.types.SendTestWebhookActionResponse; import com.schematic.api.resources.webhooks.types.UpdateWebhookResponse; import com.schematic.api.types.ApiError; import java.io.IOException; @@ -626,6 +628,78 @@ public BaseSchematicHttpResponse deleteWebhook( } } + public BaseSchematicHttpResponse sendTestWebhookAction( + String webhookId, TestWebhookRequestBody request) { + return sendTestWebhookAction(webhookId, request, null); + } + + public BaseSchematicHttpResponse sendTestWebhookAction( + String webhookId, TestWebhookRequestBody request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("webhooks") + .addPathSegment(webhookId) + .addPathSegments("test"); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl.build()) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, SendTestWebhookActionResponse.class), + response); + } + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + throw new BaseSchematicApiException( + "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + public BaseSchematicHttpResponse countWebhooks() { return countWebhooks(CountWebhooksRequest.builder().build()); } diff --git a/src/main/java/com/schematic/api/resources/webhooks/WebhooksClient.java b/src/main/java/com/schematic/api/resources/webhooks/WebhooksClient.java index 2f3ab88..16390d7 100644 --- a/src/main/java/com/schematic/api/resources/webhooks/WebhooksClient.java +++ b/src/main/java/com/schematic/api/resources/webhooks/WebhooksClient.java @@ -10,6 +10,7 @@ import com.schematic.api.resources.webhooks.requests.CreateWebhookRequestBody; import com.schematic.api.resources.webhooks.requests.ListWebhookEventsRequest; import com.schematic.api.resources.webhooks.requests.ListWebhooksRequest; +import com.schematic.api.resources.webhooks.requests.TestWebhookRequestBody; import com.schematic.api.resources.webhooks.requests.UpdateWebhookRequestBody; import com.schematic.api.resources.webhooks.types.CountWebhookEventsResponse; import com.schematic.api.resources.webhooks.types.CountWebhooksResponse; @@ -19,6 +20,7 @@ import com.schematic.api.resources.webhooks.types.GetWebhookResponse; import com.schematic.api.resources.webhooks.types.ListWebhookEventsResponse; import com.schematic.api.resources.webhooks.types.ListWebhooksResponse; +import com.schematic.api.resources.webhooks.types.SendTestWebhookActionResponse; import com.schematic.api.resources.webhooks.types.UpdateWebhookResponse; public class WebhooksClient { @@ -137,6 +139,17 @@ public DeleteWebhookResponse deleteWebhook(String webhookId, RequestOptions requ return this.rawClient.deleteWebhook(webhookId, requestOptions).body(); } + public SendTestWebhookActionResponse sendTestWebhookAction(String webhookId, TestWebhookRequestBody request) { + return this.rawClient.sendTestWebhookAction(webhookId, request).body(); + } + + public SendTestWebhookActionResponse sendTestWebhookAction( + String webhookId, TestWebhookRequestBody request, RequestOptions requestOptions) { + return this.rawClient + .sendTestWebhookAction(webhookId, request, requestOptions) + .body(); + } + public CountWebhooksResponse countWebhooks() { return this.rawClient.countWebhooks().body(); } diff --git a/src/main/java/com/schematic/api/resources/webhooks/requests/TestWebhookRequestBody.java b/src/main/java/com/schematic/api/resources/webhooks/requests/TestWebhookRequestBody.java new file mode 100644 index 0000000..fdc3af4 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/webhooks/requests/TestWebhookRequestBody.java @@ -0,0 +1,119 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.webhooks.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.types.WebhookRequestType; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = TestWebhookRequestBody.Builder.class) +public final class TestWebhookRequestBody { + private final WebhookRequestType requestType; + + private final Map additionalProperties; + + private TestWebhookRequestBody(WebhookRequestType requestType, Map additionalProperties) { + this.requestType = requestType; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("request_type") + public WebhookRequestType getRequestType() { + return requestType; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof TestWebhookRequestBody && equalTo((TestWebhookRequestBody) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(TestWebhookRequestBody other) { + return requestType.equals(other.requestType); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.requestType); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static RequestTypeStage builder() { + return new Builder(); + } + + public interface RequestTypeStage { + _FinalStage requestType(@NotNull WebhookRequestType requestType); + + Builder from(TestWebhookRequestBody other); + } + + public interface _FinalStage { + TestWebhookRequestBody build(); + + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements RequestTypeStage, _FinalStage { + private WebhookRequestType requestType; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(TestWebhookRequestBody other) { + requestType(other.getRequestType()); + return this; + } + + @java.lang.Override + @JsonSetter("request_type") + public _FinalStage requestType(@NotNull WebhookRequestType requestType) { + this.requestType = Objects.requireNonNull(requestType, "requestType must not be null"); + return this; + } + + @java.lang.Override + public TestWebhookRequestBody build() { + return new TestWebhookRequestBody(requestType, additionalProperties); + } + + @java.lang.Override + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + @java.lang.Override + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + } +} diff --git a/src/main/java/com/schematic/api/resources/webhooks/types/SendTestWebhookActionResponse.java b/src/main/java/com/schematic/api/resources/webhooks/types/SendTestWebhookActionResponse.java new file mode 100644 index 0000000..96c8608 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/webhooks/types/SendTestWebhookActionResponse.java @@ -0,0 +1,181 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.webhooks.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.types.TestWebhookResponseData; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = SendTestWebhookActionResponse.Builder.class) +public final class SendTestWebhookActionResponse { + private final TestWebhookResponseData data; + + private final Map params; + + private final Map additionalProperties; + + private SendTestWebhookActionResponse( + TestWebhookResponseData data, Map params, Map additionalProperties) { + this.data = data; + this.params = params; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("data") + public TestWebhookResponseData getData() { + return data; + } + + /** + * @return Input parameters + */ + @JsonProperty("params") + public Map getParams() { + return params; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof SendTestWebhookActionResponse && equalTo((SendTestWebhookActionResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(SendTestWebhookActionResponse other) { + return data.equals(other.data) && params.equals(other.params); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.data, this.params); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static DataStage builder() { + return new Builder(); + } + + public interface DataStage { + _FinalStage data(@NotNull TestWebhookResponseData data); + + Builder from(SendTestWebhookActionResponse other); + } + + public interface _FinalStage { + SendTestWebhookActionResponse build(); + + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); + + /** + *

Input parameters

+ */ + _FinalStage params(Map params); + + _FinalStage putAllParams(Map params); + + _FinalStage params(String key, JsonNode value); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements DataStage, _FinalStage { + private TestWebhookResponseData data; + + private Map params = new LinkedHashMap<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(SendTestWebhookActionResponse other) { + data(other.getData()); + params(other.getParams()); + return this; + } + + @java.lang.Override + @JsonSetter("data") + public _FinalStage data(@NotNull TestWebhookResponseData data) { + this.data = Objects.requireNonNull(data, "data must not be null"); + return this; + } + + /** + *

Input parameters

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage params(String key, JsonNode value) { + this.params.put(key, value); + return this; + } + + /** + *

Input parameters

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage putAllParams(Map params) { + if (params != null) { + this.params.putAll(params); + } + return this; + } + + /** + *

Input parameters

+ */ + @java.lang.Override + @JsonSetter(value = "params", nulls = Nulls.SKIP) + public _FinalStage params(Map params) { + this.params.clear(); + if (params != null) { + this.params.putAll(params); + } + return this; + } + + @java.lang.Override + public SendTestWebhookActionResponse build() { + return new SendTestWebhookActionResponse(data, params, additionalProperties); + } + + @java.lang.Override + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + @java.lang.Override + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + } +} diff --git a/src/main/java/com/schematic/api/types/BillingCreditGrantResponseData.java b/src/main/java/com/schematic/api/types/BillingCreditGrantResponseData.java index 14abebb..6d193a4 100644 --- a/src/main/java/com/schematic/api/types/BillingCreditGrantResponseData.java +++ b/src/main/java/com/schematic/api/types/BillingCreditGrantResponseData.java @@ -49,7 +49,7 @@ public final class BillingCreditGrantResponseData { private final Optional price; - private final long quantity; + private final double quantity; private final double quantityRemaining; @@ -93,7 +93,7 @@ private BillingCreditGrantResponseData( Optional planId, Optional planName, Optional price, - long quantity, + double quantity, double quantityRemaining, double quantityUsed, boolean renewalEnabled, @@ -204,7 +204,7 @@ public Optional getPrice() { } @JsonProperty("quantity") - public long getQuantity() { + public double getQuantity() { return quantity; } @@ -389,7 +389,7 @@ public interface IdStage { } public interface QuantityStage { - QuantityRemainingStage quantity(long quantity); + QuantityRemainingStage quantity(double quantity); } public interface QuantityRemainingStage { @@ -509,7 +509,7 @@ public static final class Builder private String id; - private long quantity; + private double quantity; private double quantityRemaining; @@ -637,7 +637,7 @@ public QuantityStage id(@NotNull String id) { @java.lang.Override @JsonSetter("quantity") - public QuantityRemainingStage quantity(long quantity) { + public QuantityRemainingStage quantity(double quantity) { this.quantity = quantity; return this; } diff --git a/src/main/java/com/schematic/api/types/CountResponse.java b/src/main/java/com/schematic/api/types/CountResponse.java index 84b2f19..416da2b 100644 --- a/src/main/java/com/schematic/api/types/CountResponse.java +++ b/src/main/java/com/schematic/api/types/CountResponse.java @@ -20,11 +20,11 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = CountResponse.Builder.class) public final class CountResponse { - private final Optional count; + private final Optional count; private final Map additionalProperties; - private CountResponse(Optional count, Map additionalProperties) { + private CountResponse(Optional count, Map additionalProperties) { this.count = count; this.additionalProperties = additionalProperties; } @@ -33,7 +33,7 @@ private CountResponse(Optional count, Map additionalPro * @return The number of resources */ @JsonProperty("count") - public Optional getCount() { + public Optional getCount() { return count; } @@ -68,7 +68,7 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Optional count = Optional.empty(); + private Optional count = Optional.empty(); @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -84,12 +84,12 @@ public Builder from(CountResponse other) { *

The number of resources

*/ @JsonSetter(value = "count", nulls = Nulls.SKIP) - public Builder count(Optional count) { + public Builder count(Optional count) { this.count = count; return this; } - public Builder count(Integer count) { + public Builder count(Long count) { this.count = Optional.ofNullable(count); return this; } diff --git a/src/main/java/com/schematic/api/types/CreditCompanyGrantView.java b/src/main/java/com/schematic/api/types/CreditCompanyGrantView.java index 0d06d11..f6de1cb 100644 --- a/src/main/java/com/schematic/api/types/CreditCompanyGrantView.java +++ b/src/main/java/com/schematic/api/types/CreditCompanyGrantView.java @@ -63,7 +63,7 @@ public final class CreditCompanyGrantView { private final Optional price; - private final long quantity; + private final double quantity; private final double quantityRemaining; @@ -116,7 +116,7 @@ private CreditCompanyGrantView( Optional planName, Optional pluralName, Optional price, - long quantity, + double quantity, double quantityRemaining, double quantityUsed, boolean renewalEnabled, @@ -271,7 +271,7 @@ public Optional getPrice() { } @JsonProperty("quantity") - public long getQuantity() { + public double getQuantity() { return quantity; } @@ -478,7 +478,7 @@ public interface IdStage { } public interface QuantityStage { - QuantityRemainingStage quantity(long quantity); + QuantityRemainingStage quantity(double quantity); } public interface QuantityRemainingStage { @@ -626,7 +626,7 @@ public static final class Builder private String id; - private long quantity; + private double quantity; private double quantityRemaining; @@ -783,7 +783,7 @@ public QuantityStage id(@NotNull String id) { @java.lang.Override @JsonSetter("quantity") - public QuantityRemainingStage quantity(long quantity) { + public QuantityRemainingStage quantity(double quantity) { this.quantity = quantity; return this; } diff --git a/src/main/java/com/schematic/api/types/CreditEventLedgerResponseData.java b/src/main/java/com/schematic/api/types/CreditEventLedgerResponseData.java index fd523ae..d58edec 100644 --- a/src/main/java/com/schematic/api/types/CreditEventLedgerResponseData.java +++ b/src/main/java/com/schematic/api/types/CreditEventLedgerResponseData.java @@ -62,7 +62,7 @@ public final class CreditEventLedgerResponseData { private final Optional grantId; - private final Optional grantQuantity; + private final Optional grantQuantity; private final Optional grantQuantityRemaining; @@ -109,7 +109,7 @@ private CreditEventLedgerResponseData( Optional fromGrantId, Optional grantExpiresAt, Optional grantId, - Optional grantQuantity, + Optional grantQuantity, Optional grantQuantityRemaining, Optional grantReason, Optional grantValidFrom, @@ -258,7 +258,7 @@ public Optional getGrantId() { } @JsonProperty("grant_quantity") - public Optional getGrantQuantity() { + public Optional getGrantQuantity() { return grantQuantity; } @@ -502,9 +502,9 @@ public interface _FinalStage { _FinalStage grantId(String grantId); - _FinalStage grantQuantity(Optional grantQuantity); + _FinalStage grantQuantity(Optional grantQuantity); - _FinalStage grantQuantity(Long grantQuantity); + _FinalStage grantQuantity(Double grantQuantity); _FinalStage grantQuantityRemaining(Optional grantQuantityRemaining); @@ -597,7 +597,7 @@ public static final class Builder private Optional grantQuantityRemaining = Optional.empty(); - private Optional grantQuantity = Optional.empty(); + private Optional grantQuantity = Optional.empty(); private Optional grantId = Optional.empty(); @@ -859,14 +859,14 @@ public _FinalStage grantQuantityRemaining(Optional grantQuantityRemainin } @java.lang.Override - public _FinalStage grantQuantity(Long grantQuantity) { + public _FinalStage grantQuantity(Double grantQuantity) { this.grantQuantity = Optional.ofNullable(grantQuantity); return this; } @java.lang.Override @JsonSetter(value = "grant_quantity", nulls = Nulls.SKIP) - public _FinalStage grantQuantity(Optional grantQuantity) { + public _FinalStage grantQuantity(Optional grantQuantity) { this.grantQuantity = grantQuantity; return this; } diff --git a/src/main/java/com/schematic/api/types/EventBodyTrack.java b/src/main/java/com/schematic/api/types/EventBodyTrack.java index f9a4b48..d4de364 100644 --- a/src/main/java/com/schematic/api/types/EventBodyTrack.java +++ b/src/main/java/com/schematic/api/types/EventBodyTrack.java @@ -28,7 +28,7 @@ public final class EventBodyTrack { private final Optional leaseId; - private final Optional quantity; + private final Optional quantity; private final Optional> traits; @@ -40,7 +40,7 @@ private EventBodyTrack( Optional> company, String event, Optional leaseId, - Optional quantity, + Optional quantity, Optional> traits, Optional> user, Map additionalProperties) { @@ -81,7 +81,7 @@ public Optional getLeaseId() { * @return Optionally specify the quantity of the event */ @JsonProperty("quantity") - public Optional getQuantity() { + public Optional getQuantity() { return quantity; } @@ -168,9 +168,9 @@ public interface _FinalStage { /** *

Optionally specify the quantity of the event

*/ - _FinalStage quantity(Optional quantity); + _FinalStage quantity(Optional quantity); - _FinalStage quantity(Integer quantity); + _FinalStage quantity(Long quantity); /** *

A map of trait names to trait values

@@ -195,7 +195,7 @@ public static final class Builder implements EventStage, _FinalStage { private Optional> traits = Optional.empty(); - private Optional quantity = Optional.empty(); + private Optional quantity = Optional.empty(); private Optional leaseId = Optional.empty(); @@ -274,7 +274,7 @@ public _FinalStage traits(Optional> traits) { * @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override - public _FinalStage quantity(Integer quantity) { + public _FinalStage quantity(Long quantity) { this.quantity = Optional.ofNullable(quantity); return this; } @@ -284,7 +284,7 @@ public _FinalStage quantity(Integer quantity) { */ @java.lang.Override @JsonSetter(value = "quantity", nulls = Nulls.SKIP) - public _FinalStage quantity(Optional quantity) { + public _FinalStage quantity(Optional quantity) { this.quantity = quantity; return this; } diff --git a/src/main/java/com/schematic/api/types/PlanChangeResponseData.java b/src/main/java/com/schematic/api/types/PlanChangeResponseData.java index 9004467..543b3d3 100644 --- a/src/main/java/com/schematic/api/types/PlanChangeResponseData.java +++ b/src/main/java/com/schematic/api/types/PlanChangeResponseData.java @@ -52,6 +52,8 @@ public final class PlanChangeResponseData { private final String id; + private final Optional integration; + private final boolean isVersionUpgrade; private final Optional previousBasePlan; @@ -87,6 +89,7 @@ private PlanChangeResponseData( OffsetDateTime createdAt, String environmentId, String id, + Optional integration, boolean isVersionUpgrade, Optional previousBasePlan, Optional previousBasePlanVersion, @@ -111,6 +114,7 @@ private PlanChangeResponseData( this.createdAt = createdAt; this.environmentId = environmentId; this.id = id; + this.integration = integration; this.isVersionUpgrade = isVersionUpgrade; this.previousBasePlan = previousBasePlan; this.previousBasePlanVersion = previousBasePlanVersion; @@ -199,6 +203,14 @@ public String getId() { return id; } + /** + * @return The integration that performed this change, when the actor is an integration-owned API key (e.g. a billing-provider sync). + */ + @JsonProperty("integration") + public Optional getIntegration() { + return integration; + } + /** * @return True when this change moved the company to a different version of the same plan (e.g. a plan version migration) rather than to a different plan. */ @@ -282,6 +294,7 @@ private boolean equalTo(PlanChangeResponseData other) { && createdAt.equals(other.createdAt) && environmentId.equals(other.environmentId) && id.equals(other.id) + && integration.equals(other.integration) && isVersionUpgrade == other.isVersionUpgrade && previousBasePlan.equals(other.previousBasePlan) && previousBasePlanVersion.equals(other.previousBasePlanVersion) @@ -310,6 +323,7 @@ public int hashCode() { this.createdAt, this.environmentId, this.id, + this.integration, this.isVersionUpgrade, this.previousBasePlan, this.previousBasePlanVersion, @@ -416,6 +430,13 @@ public interface _FinalStage { _FinalStage company(CompanyResponseData company); + /** + *

The integration that performed this change, when the actor is an integration-owned API key (e.g. a billing-provider sync).

+ */ + _FinalStage integration(Optional integration); + + _FinalStage integration(IntegrationResponseData integration); + _FinalStage previousBasePlan(Optional previousBasePlan); _FinalStage previousBasePlan(PlanSnapshotView previousBasePlan); @@ -497,6 +518,8 @@ public static final class Builder private Optional previousBasePlan = Optional.empty(); + private Optional integration = Optional.empty(); + private Optional company = Optional.empty(); private Optional basePlanVersion = Optional.empty(); @@ -534,6 +557,7 @@ public Builder from(PlanChangeResponseData other) { createdAt(other.getCreatedAt()); environmentId(other.getEnvironmentId()); id(other.getId()); + integration(other.getIntegration()); isVersionUpgrade(other.getIsVersionUpgrade()); previousBasePlan(other.getPreviousBasePlan()); previousBasePlanVersion(other.getPreviousBasePlanVersion()); @@ -734,6 +758,26 @@ public _FinalStage previousBasePlan(Optional previousBasePlan) return this; } + /** + *

The integration that performed this change, when the actor is an integration-owned API key (e.g. a billing-provider sync).

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage integration(IntegrationResponseData integration) { + this.integration = Optional.ofNullable(integration); + return this; + } + + /** + *

The integration that performed this change, when the actor is an integration-owned API key (e.g. a billing-provider sync).

+ */ + @java.lang.Override + @JsonSetter(value = "integration", nulls = Nulls.SKIP) + public _FinalStage integration(Optional integration) { + this.integration = integration; + return this; + } + @java.lang.Override public _FinalStage company(CompanyResponseData company) { this.company = Optional.ofNullable(company); @@ -891,6 +935,7 @@ public PlanChangeResponseData build() { createdAt, environmentId, id, + integration, isVersionUpgrade, previousBasePlan, previousBasePlanVersion, diff --git a/src/main/java/com/schematic/api/types/RulesEngineSchemaVersion.java b/src/main/java/com/schematic/api/types/RulesEngineSchemaVersion.java index 60558c9..63dcb73 100644 --- a/src/main/java/com/schematic/api/types/RulesEngineSchemaVersion.java +++ b/src/main/java/com/schematic/api/types/RulesEngineSchemaVersion.java @@ -7,12 +7,12 @@ import com.fasterxml.jackson.annotation.JsonValue; public final class RulesEngineSchemaVersion { + public static final RulesEngineSchemaVersion V_5_B_3_E_7220 = + new RulesEngineSchemaVersion(Value.V_5_B_3_E_7220, "v5b3e7220"); + public static final RulesEngineSchemaVersion PLACEHOLDER_FOR_FERN_COMPATIBILITY = new RulesEngineSchemaVersion( Value.PLACEHOLDER_FOR_FERN_COMPATIBILITY, "placeholder-for-fern-compatibility"); - public static final RulesEngineSchemaVersion V_97288_F_60 = - new RulesEngineSchemaVersion(Value.V_97288_F_60, "v97288f60"); - private final Value value; private final String string; @@ -46,10 +46,10 @@ public int hashCode() { public T visit(Visitor visitor) { switch (value) { + case V_5_B_3_E_7220: + return visitor.visitV5B3E7220(); case PLACEHOLDER_FOR_FERN_COMPATIBILITY: return visitor.visitPlaceholderForFernCompatibility(); - case V_97288_F_60: - return visitor.visitV97288F60(); case UNKNOWN: default: return visitor.visitUnknown(string); @@ -59,17 +59,17 @@ public T visit(Visitor visitor) { @JsonCreator(mode = JsonCreator.Mode.DELEGATING) public static RulesEngineSchemaVersion valueOf(String value) { switch (value) { + case "v5b3e7220": + return V_5_B_3_E_7220; case "placeholder-for-fern-compatibility": return PLACEHOLDER_FOR_FERN_COMPATIBILITY; - case "v97288f60": - return V_97288_F_60; default: return new RulesEngineSchemaVersion(Value.UNKNOWN, value); } } public enum Value { - V_97288_F_60, + V_5_B_3_E_7220, PLACEHOLDER_FOR_FERN_COMPATIBILITY, @@ -77,7 +77,7 @@ public enum Value { } public interface Visitor { - T visitV97288F60(); + T visitV5B3E7220(); T visitPlaceholderForFernCompatibility(); diff --git a/src/main/java/com/schematic/api/types/TestWebhookResponseData.java b/src/main/java/com/schematic/api/types/TestWebhookResponseData.java new file mode 100644 index 0000000..86f5ac1 --- /dev/null +++ b/src/main/java/com/schematic/api/types/TestWebhookResponseData.java @@ -0,0 +1,139 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = TestWebhookResponseData.Builder.class) +public final class TestWebhookResponseData { + private final long responseCode; + + private final boolean success; + + private final Map additionalProperties; + + private TestWebhookResponseData(long responseCode, boolean success, Map additionalProperties) { + this.responseCode = responseCode; + this.success = success; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("response_code") + public long getResponseCode() { + return responseCode; + } + + @JsonProperty("success") + public boolean getSuccess() { + return success; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof TestWebhookResponseData && equalTo((TestWebhookResponseData) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(TestWebhookResponseData other) { + return responseCode == other.responseCode && success == other.success; + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.responseCode, this.success); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static ResponseCodeStage builder() { + return new Builder(); + } + + public interface ResponseCodeStage { + SuccessStage responseCode(long responseCode); + + Builder from(TestWebhookResponseData other); + } + + public interface SuccessStage { + _FinalStage success(boolean success); + } + + public interface _FinalStage { + TestWebhookResponseData build(); + + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements ResponseCodeStage, SuccessStage, _FinalStage { + private long responseCode; + + private boolean success; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(TestWebhookResponseData other) { + responseCode(other.getResponseCode()); + success(other.getSuccess()); + return this; + } + + @java.lang.Override + @JsonSetter("response_code") + public SuccessStage responseCode(long responseCode) { + this.responseCode = responseCode; + return this; + } + + @java.lang.Override + @JsonSetter("success") + public _FinalStage success(boolean success) { + this.success = success; + return this; + } + + @java.lang.Override + public TestWebhookResponseData build() { + return new TestWebhookResponseData(responseCode, success, additionalProperties); + } + + @java.lang.Override + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + @java.lang.Override + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + } +} From 6fcd2ee2f23172386a95d9079a04e0008fec0391 Mon Sep 17 00:00:00 2001 From: Christopher Brady Date: Tue, 30 Jun 2026 11:48:40 -0600 Subject: [PATCH 2/2] quantity is now long --- sample-app/src/main/java/sample/App.java | 2 +- src/main/java/com/schematic/api/Schematic.java | 8 ++++---- .../com/schematic/api/datastream/DataStreamClient.java | 2 +- .../schematic/api/datastream/DataStreamClientTest.java | 6 +++--- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/sample-app/src/main/java/sample/App.java b/sample-app/src/main/java/sample/App.java index 6aa2b47..75211c2 100644 --- a/sample-app/src/main/java/sample/App.java +++ b/sample-app/src/main/java/sample/App.java @@ -261,7 +261,7 @@ private static void handleTrack(HttpExchange exchange) throws IOException { String event = (String) body.get("event"); Map company = toStringMap(body.get("company")); Map user = toStringMap(body.get("user")); - Integer quantity = body.containsKey("quantity") ? ((Number) body.get("quantity")).intValue() : null; + Long quantity = body.containsKey("quantity") ? ((Number) body.get("quantity")).longValue() : null; if (quantity != null) { client.track(event, company, user, null, quantity); diff --git a/src/main/java/com/schematic/api/Schematic.java b/src/main/java/com/schematic/api/Schematic.java index a7e6a99..2c426d5 100644 --- a/src/main/java/com/schematic/api/Schematic.java +++ b/src/main/java/com/schematic/api/Schematic.java @@ -597,7 +597,7 @@ public void identify( public void track( String eventName, Map company, Map user, Map traits) { - track(eventName, company, user, traits, 1, null); + track(eventName, company, user, traits, 1L, null); } public void track( @@ -605,7 +605,7 @@ public void track( Map company, Map user, Map traits, - Integer quantity) { + Long quantity) { track(eventName, company, user, traits, quantity, null); } @@ -615,7 +615,7 @@ public void track( Map user, Map traits, TrackOptions options) { - track(eventName, company, user, traits, 1, options); + track(eventName, company, user, traits, 1L, options); } public void track( @@ -623,7 +623,7 @@ public void track( Map company, Map user, Map traits, - Integer quantity, + Long quantity, TrackOptions options) { if (offline) return; diff --git a/src/main/java/com/schematic/api/datastream/DataStreamClient.java b/src/main/java/com/schematic/api/datastream/DataStreamClient.java index dcf28df..1390106 100644 --- a/src/main/java/com/schematic/api/datastream/DataStreamClient.java +++ b/src/main/java/com/schematic/api/datastream/DataStreamClient.java @@ -466,7 +466,7 @@ public void updateCompanyMetrics(EventBodyTrack event) { } String eventName = event.getEvent(); - int quantity = event.getQuantity().orElse(1); + long quantity = event.getQuantity().orElse(1L); List updatedMetrics = new ArrayList<>(); for (RulesengineCompanyMetric metric : company.getMetrics()) { diff --git a/src/test/java/com/schematic/api/datastream/DataStreamClientTest.java b/src/test/java/com/schematic/api/datastream/DataStreamClientTest.java index 812426d..982b78a 100644 --- a/src/test/java/com/schematic/api/datastream/DataStreamClientTest.java +++ b/src/test/java/com/schematic/api/datastream/DataStreamClientTest.java @@ -784,7 +784,7 @@ void updateCompanyMetrics_incrementsMatchingMetric() { EventBodyTrack trackEvent = EventBodyTrack.builder() .event("api_calls") .company(Collections.singletonMap("customer_id", "cust-1")) - .quantity(5) + .quantity(5L) .build(); client.updateCompanyMetrics(trackEvent); @@ -805,7 +805,7 @@ void updateCompanyMetrics_companyNotInCache_noOp() { EventBodyTrack trackEvent = EventBodyTrack.builder() .event("api_calls") .company(Collections.singletonMap("customer_id", "nonexistent")) - .quantity(1) + .quantity(1L) .build(); assertDoesNotThrow(() -> client.updateCompanyMetrics(trackEvent)); @@ -814,7 +814,7 @@ void updateCompanyMetrics_companyNotInCache_noOp() { @Test void updateCompanyMetrics_noCompanyKeys_noOp() { EventBodyTrack trackEvent = - EventBodyTrack.builder().event("api_calls").quantity(1).build(); + EventBodyTrack.builder().event("api_calls").quantity(1L).build(); assertDoesNotThrow(() -> client.updateCompanyMetrics(trackEvent)); }