diff --git a/.fern/metadata.json b/.fern/metadata.json index 5edca41..4187eb6 100644 --- a/.fern/metadata.json +++ b/.fern/metadata.json @@ -1,7 +1,7 @@ { "cliVersion": "5.6.0", "generatorName": "fernapi/fern-java-sdk", - "generatorVersion": "4.8.7", + "generatorVersion": "4.8.10", "generatorConfig": { "client-class-name": "BaseSchematic", "generate-unknown-as-json-node": true, @@ -14,7 +14,7 @@ "implementation redis.clients:jedis:5.2.0" ] }, - "originGitCommit": "a0658700ca9b3d362ce6594c0740c41d9286e429", + "originGitCommit": "470e0f433ab9bb0e88784674fa2e1efce62ebd9b", "originGitCommitIsDirty": false, "invokedBy": "ci", "requestedVersion": "1.4.0", diff --git a/.fern/replay.lock b/.fern/replay.lock new file mode 100644 index 0000000..68eff77 --- /dev/null +++ b/.fern/replay.lock @@ -0,0 +1,10 @@ +# DO NOT EDIT MANUALLY - Managed by Fern Replay +version: "1.0" +generations: + - commit_sha: 27876f527547fe93937ca0c57e06af8c48b0b3d3 + tree_hash: e5bc3ed8d06e3e62712ea270f63dd06f1808d57a + timestamp: 2026-05-25T11:22:32.078Z + cli_version: unknown + generator_versions: {} +current_generation: 27876f527547fe93937ca0c57e06af8c48b0b3d3 +patches: [] diff --git a/.fernignore b/.fernignore index 2798499..de7d09c 100644 --- a/.fernignore +++ b/.fernignore @@ -32,3 +32,6 @@ src/test/java/com/schematic/api/TestSchematic.java src/test/java/com/schematic/api/cache/RedisCacheProviderTest.java src/test/java/com/schematic/api/datastream/ src/test/java/com/schematic/webhook/ +.fern/replay.lock +.fern/replay.yml +.gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..74928d6 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +.fern/replay.lock linguist-generated=true diff --git a/reference.md b/reference.md index 6938eb4..52ed1da 100644 --- a/reference.md +++ b/reference.md @@ -2063,6 +2063,46 @@ client.billing().upsertPaymentMethod( + + + + +
client.billing.deletePaymentMethodByExternalId(billingId) -> DeletePaymentMethodByExternalIdResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.billing().deletePaymentMethodByExternalId("billing_id"); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**billingId:** `String` — billing_id + +
+
+
+
+ +
@@ -4893,6 +4933,192 @@ client.credits().listGrantsForCredit( + + + + +
client.credits.acquireCreditLease(request) -> AcquireCreditLeaseResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.credits().acquireCreditLease( + AcquireCreditLeaseRequestBody + .builder() + .companyId("company_id") + .creditTypeId("credit_type_id") + .requestedAmount(1.1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**companyId:** `String` + +
+
+ +
+
+ +**creditTypeId:** `String` + +
+
+ +
+
+ +**expiresAt:** `Optional` + +
+
+ +
+
+ +**requestedAmount:** `Double` + +
+
+
+
+ + +
+
+
+ +
client.credits.extendCreditLease(leaseId, request) -> ExtendCreditLeaseResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.credits().extendCreditLease( + "lease_id", + ExtendCreditLeaseRequestBody + .builder() + .additionalAmount(1.1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**leaseId:** `String` — lease_id + +
+
+ +
+
+ +**additionalAmount:** `Double` + +
+
+ +
+
+ +**expiresAt:** `Optional` + +
+
+
+
+ + +
+
+
+ +
client.credits.releaseCreditLease(leaseId, request) -> ReleaseCreditLeaseResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.credits().releaseCreditLease( + "lease_id", + new HashMap() {{ + put("key", ObjectMappers.JSON_MAPPER.valueToTree("value")); + }} +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**leaseId:** `String` — lease_id + +
+
+ +
+
+ +**request:** `Map` + +
+
+
+
+ +
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 7dbe364..cd9bb7e 100644 --- a/src/main/java/com/schematic/api/resources/billing/AsyncBillingClient.java +++ b/src/main/java/com/schematic/api/resources/billing/AsyncBillingClient.java @@ -26,6 +26,7 @@ import com.schematic.api.resources.billing.types.CountBillingProductsResponse; import com.schematic.api.resources.billing.types.CountCustomersResponse; import com.schematic.api.resources.billing.types.DeleteBillingProductResponse; +import com.schematic.api.resources.billing.types.DeletePaymentMethodByExternalIdResponse; import com.schematic.api.resources.billing.types.DeleteProductPriceResponse; import com.schematic.api.resources.billing.types.ListBillingPricesResponse; import com.schematic.api.resources.billing.types.ListBillingProductPricesResponse; @@ -197,6 +198,18 @@ public CompletableFuture upsertPaymentMethod( return this.rawClient.upsertPaymentMethod(request, requestOptions).thenApply(response -> response.body()); } + public CompletableFuture deletePaymentMethodByExternalId( + String billingId) { + return this.rawClient.deletePaymentMethodByExternalId(billingId).thenApply(response -> response.body()); + } + + public CompletableFuture deletePaymentMethodByExternalId( + String billingId, RequestOptions requestOptions) { + return this.rawClient + .deletePaymentMethodByExternalId(billingId, requestOptions) + .thenApply(response -> response.body()); + } + public CompletableFuture listBillingPrices() { return this.rawClient.listBillingPrices().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 b2f6da6..c3f35c3 100644 --- a/src/main/java/com/schematic/api/resources/billing/AsyncRawBillingClient.java +++ b/src/main/java/com/schematic/api/resources/billing/AsyncRawBillingClient.java @@ -38,6 +38,7 @@ import com.schematic.api.resources.billing.types.CountBillingProductsResponse; import com.schematic.api.resources.billing.types.CountCustomersResponse; import com.schematic.api.resources.billing.types.DeleteBillingProductResponse; +import com.schematic.api.resources.billing.types.DeletePaymentMethodByExternalIdResponse; import com.schematic.api.resources.billing.types.DeleteProductPriceResponse; import com.schematic.api.resources.billing.types.ListBillingPricesResponse; import com.schematic.api.resources.billing.types.ListBillingProductPricesResponse; @@ -1196,6 +1197,94 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { return future; } + public CompletableFuture> + deletePaymentMethodByExternalId(String billingId) { + return deletePaymentMethodByExternalId(billingId, null); + } + + public CompletableFuture> + deletePaymentMethodByExternalId(String billingId, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/payment-methods") + .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, DeletePaymentMethodByExternalIdResponse.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> listBillingPrices() { return listBillingPrices(ListBillingPricesRequest.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 911e983..013d4b9 100644 --- a/src/main/java/com/schematic/api/resources/billing/BillingClient.java +++ b/src/main/java/com/schematic/api/resources/billing/BillingClient.java @@ -26,6 +26,7 @@ import com.schematic.api.resources.billing.types.CountBillingProductsResponse; import com.schematic.api.resources.billing.types.CountCustomersResponse; import com.schematic.api.resources.billing.types.DeleteBillingProductResponse; +import com.schematic.api.resources.billing.types.DeletePaymentMethodByExternalIdResponse; import com.schematic.api.resources.billing.types.DeleteProductPriceResponse; import com.schematic.api.resources.billing.types.ListBillingPricesResponse; import com.schematic.api.resources.billing.types.ListBillingProductPricesResponse; @@ -190,6 +191,17 @@ public UpsertPaymentMethodResponse upsertPaymentMethod( return this.rawClient.upsertPaymentMethod(request, requestOptions).body(); } + public DeletePaymentMethodByExternalIdResponse deletePaymentMethodByExternalId(String billingId) { + return this.rawClient.deletePaymentMethodByExternalId(billingId).body(); + } + + public DeletePaymentMethodByExternalIdResponse deletePaymentMethodByExternalId( + String billingId, RequestOptions requestOptions) { + return this.rawClient + .deletePaymentMethodByExternalId(billingId, requestOptions) + .body(); + } + public ListBillingPricesResponse listBillingPrices() { return this.rawClient.listBillingPrices().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 74a4f8d..eba395e 100644 --- a/src/main/java/com/schematic/api/resources/billing/RawBillingClient.java +++ b/src/main/java/com/schematic/api/resources/billing/RawBillingClient.java @@ -38,6 +38,7 @@ import com.schematic.api.resources.billing.types.CountBillingProductsResponse; import com.schematic.api.resources.billing.types.CountCustomersResponse; import com.schematic.api.resources.billing.types.DeleteBillingProductResponse; +import com.schematic.api.resources.billing.types.DeletePaymentMethodByExternalIdResponse; import com.schematic.api.resources.billing.types.DeleteProductPriceResponse; import com.schematic.api.resources.billing.types.ListBillingPricesResponse; import com.schematic.api.resources.billing.types.ListBillingProductPricesResponse; @@ -919,6 +920,70 @@ public BaseSchematicHttpResponse upsertPaymentMetho } } + public BaseSchematicHttpResponse deletePaymentMethodByExternalId( + String billingId) { + return deletePaymentMethodByExternalId(billingId, null); + } + + public BaseSchematicHttpResponse deletePaymentMethodByExternalId( + String billingId, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/payment-methods") + .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, DeletePaymentMethodByExternalIdResponse.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 listBillingPrices() { return listBillingPrices(ListBillingPricesRequest.builder().build()); } diff --git a/src/main/java/com/schematic/api/resources/billing/types/DeletePaymentMethodByExternalIdResponse.java b/src/main/java/com/schematic/api/resources/billing/types/DeletePaymentMethodByExternalIdResponse.java new file mode 100644 index 0000000..e8c5cbf --- /dev/null +++ b/src/main/java/com/schematic/api/resources/billing/types/DeletePaymentMethodByExternalIdResponse.java @@ -0,0 +1,182 @@ +/** + * 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 = DeletePaymentMethodByExternalIdResponse.Builder.class) +public final class DeletePaymentMethodByExternalIdResponse { + private final DeleteResponse data; + + private final Map params; + + private final Map additionalProperties; + + private DeletePaymentMethodByExternalIdResponse( + 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 DeletePaymentMethodByExternalIdResponse + && equalTo((DeletePaymentMethodByExternalIdResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DeletePaymentMethodByExternalIdResponse 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(DeletePaymentMethodByExternalIdResponse other); + } + + public interface _FinalStage { + DeletePaymentMethodByExternalIdResponse 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(DeletePaymentMethodByExternalIdResponse 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 DeletePaymentMethodByExternalIdResponse build() { + return new DeletePaymentMethodByExternalIdResponse(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/credits/AsyncCreditsClient.java b/src/main/java/com/schematic/api/resources/credits/AsyncCreditsClient.java index 00695b7..93a982f 100644 --- a/src/main/java/com/schematic/api/resources/credits/AsyncCreditsClient.java +++ b/src/main/java/com/schematic/api/resources/credits/AsyncCreditsClient.java @@ -3,8 +3,10 @@ */ package com.schematic.api.resources.credits; +import com.fasterxml.jackson.databind.JsonNode; import com.schematic.api.core.ClientOptions; import com.schematic.api.core.RequestOptions; +import com.schematic.api.resources.credits.requests.AcquireCreditLeaseRequestBody; import com.schematic.api.resources.credits.requests.CountBillingCreditsGrantsRequest; import com.schematic.api.resources.credits.requests.CountBillingCreditsRequest; import com.schematic.api.resources.credits.requests.CountBillingPlanCreditGrantsRequest; @@ -16,6 +18,7 @@ import com.schematic.api.resources.credits.requests.CreateCompanyCreditGrant; import com.schematic.api.resources.credits.requests.CreateCreditBundleRequestBody; import com.schematic.api.resources.credits.requests.DeleteBillingPlanCreditGrantRequest; +import com.schematic.api.resources.credits.requests.ExtendCreditLeaseRequestBody; import com.schematic.api.resources.credits.requests.GetEnrichedCreditLedgerRequest; import com.schematic.api.resources.credits.requests.ListBillingCreditsRequest; import com.schematic.api.resources.credits.requests.ListBillingPlanCreditGrantsRequest; @@ -27,6 +30,7 @@ import com.schematic.api.resources.credits.requests.UpdateBillingCreditRequestBody; import com.schematic.api.resources.credits.requests.UpdateCreditBundleDetailsRequestBody; import com.schematic.api.resources.credits.requests.ZeroOutGrantRequestBody; +import com.schematic.api.resources.credits.types.AcquireCreditLeaseResponse; import com.schematic.api.resources.credits.types.CountBillingCreditsGrantsResponse; import com.schematic.api.resources.credits.types.CountBillingCreditsResponse; import com.schematic.api.resources.credits.types.CountBillingPlanCreditGrantsResponse; @@ -39,6 +43,7 @@ import com.schematic.api.resources.credits.types.CreateCreditBundleResponse; import com.schematic.api.resources.credits.types.DeleteBillingPlanCreditGrantResponse; import com.schematic.api.resources.credits.types.DeleteCreditBundleResponse; +import com.schematic.api.resources.credits.types.ExtendCreditLeaseResponse; import com.schematic.api.resources.credits.types.GetCreditBundleResponse; import com.schematic.api.resources.credits.types.GetEnrichedCreditLedgerResponse; import com.schematic.api.resources.credits.types.GetSingleBillingCreditResponse; @@ -51,6 +56,7 @@ import com.schematic.api.resources.credits.types.ListCreditBundlesResponse; import com.schematic.api.resources.credits.types.ListCreditEventLedgerResponse; import com.schematic.api.resources.credits.types.ListGrantsForCreditResponse; +import com.schematic.api.resources.credits.types.ReleaseCreditLeaseResponse; import com.schematic.api.resources.credits.types.SoftDeleteBillingCreditResponse; import com.schematic.api.resources.credits.types.UpdateBillingCreditResponse; import com.schematic.api.resources.credits.types.UpdateBillingPlanCreditGrantResponse; @@ -58,6 +64,7 @@ import com.schematic.api.resources.credits.types.ZeroOutGrantResponse; import com.schematic.api.types.CreateBillingPlanCreditGrantRequestBody; import com.schematic.api.types.UpdateBillingPlanCreditGrantRequestBody; +import java.util.Map; import java.util.concurrent.CompletableFuture; public class AsyncCreditsClient { @@ -331,6 +338,39 @@ public CompletableFuture listGrantsForCredit( return this.rawClient.listGrantsForCredit(request, requestOptions).thenApply(response -> response.body()); } + public CompletableFuture acquireCreditLease(AcquireCreditLeaseRequestBody request) { + return this.rawClient.acquireCreditLease(request).thenApply(response -> response.body()); + } + + public CompletableFuture acquireCreditLease( + AcquireCreditLeaseRequestBody request, RequestOptions requestOptions) { + return this.rawClient.acquireCreditLease(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture extendCreditLease( + String leaseId, ExtendCreditLeaseRequestBody request) { + return this.rawClient.extendCreditLease(leaseId, request).thenApply(response -> response.body()); + } + + public CompletableFuture extendCreditLease( + String leaseId, ExtendCreditLeaseRequestBody request, RequestOptions requestOptions) { + return this.rawClient + .extendCreditLease(leaseId, request, requestOptions) + .thenApply(response -> response.body()); + } + + public CompletableFuture releaseCreditLease( + String leaseId, Map request) { + return this.rawClient.releaseCreditLease(leaseId, request).thenApply(response -> response.body()); + } + + public CompletableFuture releaseCreditLease( + String leaseId, Map request, RequestOptions requestOptions) { + return this.rawClient + .releaseCreditLease(leaseId, request, requestOptions) + .thenApply(response -> response.body()); + } + public CompletableFuture getEnrichedCreditLedger( GetEnrichedCreditLedgerRequest request) { return this.rawClient.getEnrichedCreditLedger(request).thenApply(response -> response.body()); diff --git a/src/main/java/com/schematic/api/resources/credits/AsyncRawCreditsClient.java b/src/main/java/com/schematic/api/resources/credits/AsyncRawCreditsClient.java index f1f478a..0a5a03f 100644 --- a/src/main/java/com/schematic/api/resources/credits/AsyncRawCreditsClient.java +++ b/src/main/java/com/schematic/api/resources/credits/AsyncRawCreditsClient.java @@ -4,6 +4,7 @@ package com.schematic.api.resources.credits; import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonNode; import com.schematic.api.core.BaseSchematicApiException; import com.schematic.api.core.BaseSchematicException; import com.schematic.api.core.BaseSchematicHttpResponse; @@ -17,6 +18,7 @@ import com.schematic.api.errors.InternalServerError; import com.schematic.api.errors.NotFoundError; import com.schematic.api.errors.UnauthorizedError; +import com.schematic.api.resources.credits.requests.AcquireCreditLeaseRequestBody; import com.schematic.api.resources.credits.requests.CountBillingCreditsGrantsRequest; import com.schematic.api.resources.credits.requests.CountBillingCreditsRequest; import com.schematic.api.resources.credits.requests.CountBillingPlanCreditGrantsRequest; @@ -28,6 +30,7 @@ import com.schematic.api.resources.credits.requests.CreateCompanyCreditGrant; import com.schematic.api.resources.credits.requests.CreateCreditBundleRequestBody; import com.schematic.api.resources.credits.requests.DeleteBillingPlanCreditGrantRequest; +import com.schematic.api.resources.credits.requests.ExtendCreditLeaseRequestBody; import com.schematic.api.resources.credits.requests.GetEnrichedCreditLedgerRequest; import com.schematic.api.resources.credits.requests.ListBillingCreditsRequest; import com.schematic.api.resources.credits.requests.ListBillingPlanCreditGrantsRequest; @@ -39,6 +42,7 @@ import com.schematic.api.resources.credits.requests.UpdateBillingCreditRequestBody; import com.schematic.api.resources.credits.requests.UpdateCreditBundleDetailsRequestBody; import com.schematic.api.resources.credits.requests.ZeroOutGrantRequestBody; +import com.schematic.api.resources.credits.types.AcquireCreditLeaseResponse; import com.schematic.api.resources.credits.types.CountBillingCreditsGrantsResponse; import com.schematic.api.resources.credits.types.CountBillingCreditsResponse; import com.schematic.api.resources.credits.types.CountBillingPlanCreditGrantsResponse; @@ -51,6 +55,7 @@ import com.schematic.api.resources.credits.types.CreateCreditBundleResponse; import com.schematic.api.resources.credits.types.DeleteBillingPlanCreditGrantResponse; import com.schematic.api.resources.credits.types.DeleteCreditBundleResponse; +import com.schematic.api.resources.credits.types.ExtendCreditLeaseResponse; import com.schematic.api.resources.credits.types.GetCreditBundleResponse; import com.schematic.api.resources.credits.types.GetEnrichedCreditLedgerResponse; import com.schematic.api.resources.credits.types.GetSingleBillingCreditResponse; @@ -63,6 +68,7 @@ import com.schematic.api.resources.credits.types.ListCreditBundlesResponse; import com.schematic.api.resources.credits.types.ListCreditEventLedgerResponse; import com.schematic.api.resources.credits.types.ListGrantsForCreditResponse; +import com.schematic.api.resources.credits.types.ReleaseCreditLeaseResponse; import com.schematic.api.resources.credits.types.SoftDeleteBillingCreditResponse; import com.schematic.api.resources.credits.types.UpdateBillingCreditResponse; import com.schematic.api.resources.credits.types.UpdateBillingPlanCreditGrantResponse; @@ -72,6 +78,7 @@ import com.schematic.api.types.CreateBillingPlanCreditGrantRequestBody; import com.schematic.api.types.UpdateBillingPlanCreditGrantRequestBody; import java.io.IOException; +import java.util.Map; import java.util.concurrent.CompletableFuture; import okhttp3.Call; import okhttp3.Callback; @@ -2001,6 +2008,292 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { return future; } + public CompletableFuture> acquireCreditLease( + AcquireCreditLeaseRequestBody request) { + return acquireCreditLease(request, null); + } + + public CompletableFuture> acquireCreditLease( + AcquireCreditLeaseRequestBody request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/credits/lease"); + 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, AcquireCreditLeaseResponse.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> extendCreditLease( + String leaseId, ExtendCreditLeaseRequestBody request) { + return extendCreditLease(leaseId, request, null); + } + + public CompletableFuture> extendCreditLease( + String leaseId, ExtendCreditLeaseRequestBody request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/credits/lease") + .addPathSegment(leaseId) + .addPathSegments("extend"); + 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("PUT", 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, ExtendCreditLeaseResponse.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> releaseCreditLease( + String leaseId, Map request) { + return releaseCreditLease(leaseId, request, null); + } + + public CompletableFuture> releaseCreditLease( + String leaseId, Map request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/credits/lease") + .addPathSegment(leaseId) + .addPathSegments("release"); + 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("PUT", 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, ReleaseCreditLeaseResponse.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> getEnrichedCreditLedger( GetEnrichedCreditLedgerRequest request) { return getEnrichedCreditLedger(request, null); diff --git a/src/main/java/com/schematic/api/resources/credits/CreditsClient.java b/src/main/java/com/schematic/api/resources/credits/CreditsClient.java index 56b2735..05961a5 100644 --- a/src/main/java/com/schematic/api/resources/credits/CreditsClient.java +++ b/src/main/java/com/schematic/api/resources/credits/CreditsClient.java @@ -3,8 +3,10 @@ */ package com.schematic.api.resources.credits; +import com.fasterxml.jackson.databind.JsonNode; import com.schematic.api.core.ClientOptions; import com.schematic.api.core.RequestOptions; +import com.schematic.api.resources.credits.requests.AcquireCreditLeaseRequestBody; import com.schematic.api.resources.credits.requests.CountBillingCreditsGrantsRequest; import com.schematic.api.resources.credits.requests.CountBillingCreditsRequest; import com.schematic.api.resources.credits.requests.CountBillingPlanCreditGrantsRequest; @@ -16,6 +18,7 @@ import com.schematic.api.resources.credits.requests.CreateCompanyCreditGrant; import com.schematic.api.resources.credits.requests.CreateCreditBundleRequestBody; import com.schematic.api.resources.credits.requests.DeleteBillingPlanCreditGrantRequest; +import com.schematic.api.resources.credits.requests.ExtendCreditLeaseRequestBody; import com.schematic.api.resources.credits.requests.GetEnrichedCreditLedgerRequest; import com.schematic.api.resources.credits.requests.ListBillingCreditsRequest; import com.schematic.api.resources.credits.requests.ListBillingPlanCreditGrantsRequest; @@ -27,6 +30,7 @@ import com.schematic.api.resources.credits.requests.UpdateBillingCreditRequestBody; import com.schematic.api.resources.credits.requests.UpdateCreditBundleDetailsRequestBody; import com.schematic.api.resources.credits.requests.ZeroOutGrantRequestBody; +import com.schematic.api.resources.credits.types.AcquireCreditLeaseResponse; import com.schematic.api.resources.credits.types.CountBillingCreditsGrantsResponse; import com.schematic.api.resources.credits.types.CountBillingCreditsResponse; import com.schematic.api.resources.credits.types.CountBillingPlanCreditGrantsResponse; @@ -39,6 +43,7 @@ import com.schematic.api.resources.credits.types.CreateCreditBundleResponse; import com.schematic.api.resources.credits.types.DeleteBillingPlanCreditGrantResponse; import com.schematic.api.resources.credits.types.DeleteCreditBundleResponse; +import com.schematic.api.resources.credits.types.ExtendCreditLeaseResponse; import com.schematic.api.resources.credits.types.GetCreditBundleResponse; import com.schematic.api.resources.credits.types.GetEnrichedCreditLedgerResponse; import com.schematic.api.resources.credits.types.GetSingleBillingCreditResponse; @@ -51,6 +56,7 @@ import com.schematic.api.resources.credits.types.ListCreditBundlesResponse; import com.schematic.api.resources.credits.types.ListCreditEventLedgerResponse; import com.schematic.api.resources.credits.types.ListGrantsForCreditResponse; +import com.schematic.api.resources.credits.types.ReleaseCreditLeaseResponse; import com.schematic.api.resources.credits.types.SoftDeleteBillingCreditResponse; import com.schematic.api.resources.credits.types.UpdateBillingCreditResponse; import com.schematic.api.resources.credits.types.UpdateBillingPlanCreditGrantResponse; @@ -58,6 +64,7 @@ import com.schematic.api.resources.credits.types.ZeroOutGrantResponse; import com.schematic.api.types.CreateBillingPlanCreditGrantRequestBody; import com.schematic.api.types.UpdateBillingPlanCreditGrantRequestBody; +import java.util.Map; public class CreditsClient { protected final ClientOptions clientOptions; @@ -322,6 +329,37 @@ public ListGrantsForCreditResponse listGrantsForCredit( return this.rawClient.listGrantsForCredit(request, requestOptions).body(); } + public AcquireCreditLeaseResponse acquireCreditLease(AcquireCreditLeaseRequestBody request) { + return this.rawClient.acquireCreditLease(request).body(); + } + + public AcquireCreditLeaseResponse acquireCreditLease( + AcquireCreditLeaseRequestBody request, RequestOptions requestOptions) { + return this.rawClient.acquireCreditLease(request, requestOptions).body(); + } + + public ExtendCreditLeaseResponse extendCreditLease(String leaseId, ExtendCreditLeaseRequestBody request) { + return this.rawClient.extendCreditLease(leaseId, request).body(); + } + + public ExtendCreditLeaseResponse extendCreditLease( + String leaseId, ExtendCreditLeaseRequestBody request, RequestOptions requestOptions) { + return this.rawClient + .extendCreditLease(leaseId, request, requestOptions) + .body(); + } + + public ReleaseCreditLeaseResponse releaseCreditLease(String leaseId, Map request) { + return this.rawClient.releaseCreditLease(leaseId, request).body(); + } + + public ReleaseCreditLeaseResponse releaseCreditLease( + String leaseId, Map request, RequestOptions requestOptions) { + return this.rawClient + .releaseCreditLease(leaseId, request, requestOptions) + .body(); + } + public GetEnrichedCreditLedgerResponse getEnrichedCreditLedger(GetEnrichedCreditLedgerRequest request) { return this.rawClient.getEnrichedCreditLedger(request).body(); } diff --git a/src/main/java/com/schematic/api/resources/credits/RawCreditsClient.java b/src/main/java/com/schematic/api/resources/credits/RawCreditsClient.java index e3b88ec..cfddf47 100644 --- a/src/main/java/com/schematic/api/resources/credits/RawCreditsClient.java +++ b/src/main/java/com/schematic/api/resources/credits/RawCreditsClient.java @@ -4,6 +4,7 @@ package com.schematic.api.resources.credits; import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonNode; import com.schematic.api.core.BaseSchematicApiException; import com.schematic.api.core.BaseSchematicException; import com.schematic.api.core.BaseSchematicHttpResponse; @@ -17,6 +18,7 @@ import com.schematic.api.errors.InternalServerError; import com.schematic.api.errors.NotFoundError; import com.schematic.api.errors.UnauthorizedError; +import com.schematic.api.resources.credits.requests.AcquireCreditLeaseRequestBody; import com.schematic.api.resources.credits.requests.CountBillingCreditsGrantsRequest; import com.schematic.api.resources.credits.requests.CountBillingCreditsRequest; import com.schematic.api.resources.credits.requests.CountBillingPlanCreditGrantsRequest; @@ -28,6 +30,7 @@ import com.schematic.api.resources.credits.requests.CreateCompanyCreditGrant; import com.schematic.api.resources.credits.requests.CreateCreditBundleRequestBody; import com.schematic.api.resources.credits.requests.DeleteBillingPlanCreditGrantRequest; +import com.schematic.api.resources.credits.requests.ExtendCreditLeaseRequestBody; import com.schematic.api.resources.credits.requests.GetEnrichedCreditLedgerRequest; import com.schematic.api.resources.credits.requests.ListBillingCreditsRequest; import com.schematic.api.resources.credits.requests.ListBillingPlanCreditGrantsRequest; @@ -39,6 +42,7 @@ import com.schematic.api.resources.credits.requests.UpdateBillingCreditRequestBody; import com.schematic.api.resources.credits.requests.UpdateCreditBundleDetailsRequestBody; import com.schematic.api.resources.credits.requests.ZeroOutGrantRequestBody; +import com.schematic.api.resources.credits.types.AcquireCreditLeaseResponse; import com.schematic.api.resources.credits.types.CountBillingCreditsGrantsResponse; import com.schematic.api.resources.credits.types.CountBillingCreditsResponse; import com.schematic.api.resources.credits.types.CountBillingPlanCreditGrantsResponse; @@ -51,6 +55,7 @@ import com.schematic.api.resources.credits.types.CreateCreditBundleResponse; import com.schematic.api.resources.credits.types.DeleteBillingPlanCreditGrantResponse; import com.schematic.api.resources.credits.types.DeleteCreditBundleResponse; +import com.schematic.api.resources.credits.types.ExtendCreditLeaseResponse; import com.schematic.api.resources.credits.types.GetCreditBundleResponse; import com.schematic.api.resources.credits.types.GetEnrichedCreditLedgerResponse; import com.schematic.api.resources.credits.types.GetSingleBillingCreditResponse; @@ -63,6 +68,7 @@ import com.schematic.api.resources.credits.types.ListCreditBundlesResponse; import com.schematic.api.resources.credits.types.ListCreditEventLedgerResponse; import com.schematic.api.resources.credits.types.ListGrantsForCreditResponse; +import com.schematic.api.resources.credits.types.ReleaseCreditLeaseResponse; import com.schematic.api.resources.credits.types.SoftDeleteBillingCreditResponse; import com.schematic.api.resources.credits.types.UpdateBillingCreditResponse; import com.schematic.api.resources.credits.types.UpdateBillingPlanCreditGrantResponse; @@ -72,6 +78,7 @@ import com.schematic.api.types.CreateBillingPlanCreditGrantRequestBody; import com.schematic.api.types.UpdateBillingPlanCreditGrantRequestBody; import java.io.IOException; +import java.util.Map; import okhttp3.Headers; import okhttp3.HttpUrl; import okhttp3.OkHttpClient; @@ -1529,6 +1536,220 @@ public BaseSchematicHttpResponse listGrantsForCredi } } + public BaseSchematicHttpResponse acquireCreditLease( + AcquireCreditLeaseRequestBody request) { + return acquireCreditLease(request, null); + } + + public BaseSchematicHttpResponse acquireCreditLease( + AcquireCreditLeaseRequestBody request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/credits/lease"); + 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, AcquireCreditLeaseResponse.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 extendCreditLease( + String leaseId, ExtendCreditLeaseRequestBody request) { + return extendCreditLease(leaseId, request, null); + } + + public BaseSchematicHttpResponse extendCreditLease( + String leaseId, ExtendCreditLeaseRequestBody request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/credits/lease") + .addPathSegment(leaseId) + .addPathSegments("extend"); + 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("PUT", 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, ExtendCreditLeaseResponse.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 releaseCreditLease( + String leaseId, Map request) { + return releaseCreditLease(leaseId, request, null); + } + + public BaseSchematicHttpResponse releaseCreditLease( + String leaseId, Map request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/credits/lease") + .addPathSegment(leaseId) + .addPathSegments("release"); + 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("PUT", 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, ReleaseCreditLeaseResponse.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 getEnrichedCreditLedger( GetEnrichedCreditLedgerRequest request) { return getEnrichedCreditLedger(request, null); diff --git a/src/main/java/com/schematic/api/resources/credits/requests/AcquireCreditLeaseRequestBody.java b/src/main/java/com/schematic/api/resources/credits/requests/AcquireCreditLeaseRequestBody.java new file mode 100644 index 0000000..ad9c336 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/credits/requests/AcquireCreditLeaseRequestBody.java @@ -0,0 +1,202 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.credits.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.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import java.time.OffsetDateTime; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = AcquireCreditLeaseRequestBody.Builder.class) +public final class AcquireCreditLeaseRequestBody { + private final String companyId; + + private final String creditTypeId; + + private final Optional expiresAt; + + private final double requestedAmount; + + private final Map additionalProperties; + + private AcquireCreditLeaseRequestBody( + String companyId, + String creditTypeId, + Optional expiresAt, + double requestedAmount, + Map additionalProperties) { + this.companyId = companyId; + this.creditTypeId = creditTypeId; + this.expiresAt = expiresAt; + this.requestedAmount = requestedAmount; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("company_id") + public String getCompanyId() { + return companyId; + } + + @JsonProperty("credit_type_id") + public String getCreditTypeId() { + return creditTypeId; + } + + @JsonProperty("expires_at") + public Optional getExpiresAt() { + return expiresAt; + } + + @JsonProperty("requested_amount") + public double getRequestedAmount() { + return requestedAmount; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof AcquireCreditLeaseRequestBody && equalTo((AcquireCreditLeaseRequestBody) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(AcquireCreditLeaseRequestBody other) { + return companyId.equals(other.companyId) + && creditTypeId.equals(other.creditTypeId) + && expiresAt.equals(other.expiresAt) + && requestedAmount == other.requestedAmount; + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.companyId, this.creditTypeId, this.expiresAt, this.requestedAmount); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static CompanyIdStage builder() { + return new Builder(); + } + + public interface CompanyIdStage { + CreditTypeIdStage companyId(@NotNull String companyId); + + Builder from(AcquireCreditLeaseRequestBody other); + } + + public interface CreditTypeIdStage { + RequestedAmountStage creditTypeId(@NotNull String creditTypeId); + } + + public interface RequestedAmountStage { + _FinalStage requestedAmount(double requestedAmount); + } + + public interface _FinalStage { + AcquireCreditLeaseRequestBody build(); + + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); + + _FinalStage expiresAt(Optional expiresAt); + + _FinalStage expiresAt(OffsetDateTime expiresAt); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements CompanyIdStage, CreditTypeIdStage, RequestedAmountStage, _FinalStage { + private String companyId; + + private String creditTypeId; + + private double requestedAmount; + + private Optional expiresAt = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(AcquireCreditLeaseRequestBody other) { + companyId(other.getCompanyId()); + creditTypeId(other.getCreditTypeId()); + expiresAt(other.getExpiresAt()); + requestedAmount(other.getRequestedAmount()); + return this; + } + + @java.lang.Override + @JsonSetter("company_id") + public CreditTypeIdStage companyId(@NotNull String companyId) { + this.companyId = Objects.requireNonNull(companyId, "companyId must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("credit_type_id") + public RequestedAmountStage creditTypeId(@NotNull String creditTypeId) { + this.creditTypeId = Objects.requireNonNull(creditTypeId, "creditTypeId must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("requested_amount") + public _FinalStage requestedAmount(double requestedAmount) { + this.requestedAmount = requestedAmount; + return this; + } + + @java.lang.Override + public _FinalStage expiresAt(OffsetDateTime expiresAt) { + this.expiresAt = Optional.ofNullable(expiresAt); + return this; + } + + @java.lang.Override + @JsonSetter(value = "expires_at", nulls = Nulls.SKIP) + public _FinalStage expiresAt(Optional expiresAt) { + this.expiresAt = expiresAt; + return this; + } + + @java.lang.Override + public AcquireCreditLeaseRequestBody build() { + return new AcquireCreditLeaseRequestBody( + companyId, creditTypeId, expiresAt, requestedAmount, 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/credits/requests/ExtendCreditLeaseRequestBody.java b/src/main/java/com/schematic/api/resources/credits/requests/ExtendCreditLeaseRequestBody.java new file mode 100644 index 0000000..cbd58ec --- /dev/null +++ b/src/main/java/com/schematic/api/resources/credits/requests/ExtendCreditLeaseRequestBody.java @@ -0,0 +1,149 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.credits.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.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import java.time.OffsetDateTime; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ExtendCreditLeaseRequestBody.Builder.class) +public final class ExtendCreditLeaseRequestBody { + private final double additionalAmount; + + private final Optional expiresAt; + + private final Map additionalProperties; + + private ExtendCreditLeaseRequestBody( + double additionalAmount, Optional expiresAt, Map additionalProperties) { + this.additionalAmount = additionalAmount; + this.expiresAt = expiresAt; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("additional_amount") + public double getAdditionalAmount() { + return additionalAmount; + } + + @JsonProperty("expires_at") + public Optional getExpiresAt() { + return expiresAt; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ExtendCreditLeaseRequestBody && equalTo((ExtendCreditLeaseRequestBody) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ExtendCreditLeaseRequestBody other) { + return additionalAmount == other.additionalAmount && expiresAt.equals(other.expiresAt); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.additionalAmount, this.expiresAt); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static AdditionalAmountStage builder() { + return new Builder(); + } + + public interface AdditionalAmountStage { + _FinalStage additionalAmount(double additionalAmount); + + Builder from(ExtendCreditLeaseRequestBody other); + } + + public interface _FinalStage { + ExtendCreditLeaseRequestBody build(); + + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); + + _FinalStage expiresAt(Optional expiresAt); + + _FinalStage expiresAt(OffsetDateTime expiresAt); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements AdditionalAmountStage, _FinalStage { + private double additionalAmount; + + private Optional expiresAt = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ExtendCreditLeaseRequestBody other) { + additionalAmount(other.getAdditionalAmount()); + expiresAt(other.getExpiresAt()); + return this; + } + + @java.lang.Override + @JsonSetter("additional_amount") + public _FinalStage additionalAmount(double additionalAmount) { + this.additionalAmount = additionalAmount; + return this; + } + + @java.lang.Override + public _FinalStage expiresAt(OffsetDateTime expiresAt) { + this.expiresAt = Optional.ofNullable(expiresAt); + return this; + } + + @java.lang.Override + @JsonSetter(value = "expires_at", nulls = Nulls.SKIP) + public _FinalStage expiresAt(Optional expiresAt) { + this.expiresAt = expiresAt; + return this; + } + + @java.lang.Override + public ExtendCreditLeaseRequestBody build() { + return new ExtendCreditLeaseRequestBody(additionalAmount, expiresAt, 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/credits/types/AcquireCreditLeaseResponse.java b/src/main/java/com/schematic/api/resources/credits/types/AcquireCreditLeaseResponse.java new file mode 100644 index 0000000..9d374e3 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/credits/types/AcquireCreditLeaseResponse.java @@ -0,0 +1,181 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.credits.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.CreditLeaseResponseData; +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 = AcquireCreditLeaseResponse.Builder.class) +public final class AcquireCreditLeaseResponse { + private final CreditLeaseResponseData data; + + private final Map params; + + private final Map additionalProperties; + + private AcquireCreditLeaseResponse( + CreditLeaseResponseData data, Map params, Map additionalProperties) { + this.data = data; + this.params = params; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("data") + public CreditLeaseResponseData 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 AcquireCreditLeaseResponse && equalTo((AcquireCreditLeaseResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(AcquireCreditLeaseResponse 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 CreditLeaseResponseData data); + + Builder from(AcquireCreditLeaseResponse other); + } + + public interface _FinalStage { + AcquireCreditLeaseResponse 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 CreditLeaseResponseData data; + + private Map params = new LinkedHashMap<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(AcquireCreditLeaseResponse other) { + data(other.getData()); + params(other.getParams()); + return this; + } + + @java.lang.Override + @JsonSetter("data") + public _FinalStage data(@NotNull CreditLeaseResponseData 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 AcquireCreditLeaseResponse build() { + return new AcquireCreditLeaseResponse(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/credits/types/ExtendCreditLeaseResponse.java b/src/main/java/com/schematic/api/resources/credits/types/ExtendCreditLeaseResponse.java new file mode 100644 index 0000000..7bbfff2 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/credits/types/ExtendCreditLeaseResponse.java @@ -0,0 +1,181 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.credits.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.CreditLeaseResponseData; +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 = ExtendCreditLeaseResponse.Builder.class) +public final class ExtendCreditLeaseResponse { + private final CreditLeaseResponseData data; + + private final Map params; + + private final Map additionalProperties; + + private ExtendCreditLeaseResponse( + CreditLeaseResponseData data, Map params, Map additionalProperties) { + this.data = data; + this.params = params; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("data") + public CreditLeaseResponseData 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 ExtendCreditLeaseResponse && equalTo((ExtendCreditLeaseResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ExtendCreditLeaseResponse 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 CreditLeaseResponseData data); + + Builder from(ExtendCreditLeaseResponse other); + } + + public interface _FinalStage { + ExtendCreditLeaseResponse 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 CreditLeaseResponseData data; + + private Map params = new LinkedHashMap<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ExtendCreditLeaseResponse other) { + data(other.getData()); + params(other.getParams()); + return this; + } + + @java.lang.Override + @JsonSetter("data") + public _FinalStage data(@NotNull CreditLeaseResponseData 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 ExtendCreditLeaseResponse build() { + return new ExtendCreditLeaseResponse(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/credits/types/ReleaseCreditLeaseResponse.java b/src/main/java/com/schematic/api/resources/credits/types/ReleaseCreditLeaseResponse.java new file mode 100644 index 0000000..7d084f9 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/credits/types/ReleaseCreditLeaseResponse.java @@ -0,0 +1,181 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.credits.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.CreditLeaseResponseData; +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 = ReleaseCreditLeaseResponse.Builder.class) +public final class ReleaseCreditLeaseResponse { + private final CreditLeaseResponseData data; + + private final Map params; + + private final Map additionalProperties; + + private ReleaseCreditLeaseResponse( + CreditLeaseResponseData data, Map params, Map additionalProperties) { + this.data = data; + this.params = params; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("data") + public CreditLeaseResponseData 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 ReleaseCreditLeaseResponse && equalTo((ReleaseCreditLeaseResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ReleaseCreditLeaseResponse 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 CreditLeaseResponseData data); + + Builder from(ReleaseCreditLeaseResponse other); + } + + public interface _FinalStage { + ReleaseCreditLeaseResponse 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 CreditLeaseResponseData data; + + private Map params = new LinkedHashMap<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ReleaseCreditLeaseResponse other) { + data(other.getData()); + params(other.getParams()); + return this; + } + + @java.lang.Override + @JsonSetter("data") + public _FinalStage data(@NotNull CreditLeaseResponseData 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 ReleaseCreditLeaseResponse build() { + return new ReleaseCreditLeaseResponse(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/BillingProductPlanResponseData.java b/src/main/java/com/schematic/api/types/BillingProductPlanResponseData.java index 528e792..bdd7808 100644 --- a/src/main/java/com/schematic/api/types/BillingProductPlanResponseData.java +++ b/src/main/java/com/schematic/api/types/BillingProductPlanResponseData.java @@ -25,6 +25,8 @@ public final class BillingProductPlanResponseData { private final String billingProductId; + private final BillingStrategy billingStrategy; + private final ChargeType chargeType; private final BillingProviderType controlledBy; @@ -48,6 +50,7 @@ public final class BillingProductPlanResponseData { private BillingProductPlanResponseData( String accountId, String billingProductId, + BillingStrategy billingStrategy, ChargeType chargeType, BillingProviderType controlledBy, String environmentId, @@ -60,6 +63,7 @@ private BillingProductPlanResponseData( Map additionalProperties) { this.accountId = accountId; this.billingProductId = billingProductId; + this.billingStrategy = billingStrategy; this.chargeType = chargeType; this.controlledBy = controlledBy; this.environmentId = environmentId; @@ -82,6 +86,11 @@ public String getBillingProductId() { return billingProductId; } + @JsonProperty("billing_strategy") + public BillingStrategy getBillingStrategy() { + return billingStrategy; + } + @JsonProperty("charge_type") public ChargeType getChargeType() { return chargeType; @@ -141,6 +150,7 @@ public Map getAdditionalProperties() { private boolean equalTo(BillingProductPlanResponseData other) { return accountId.equals(other.accountId) && billingProductId.equals(other.billingProductId) + && billingStrategy.equals(other.billingStrategy) && chargeType.equals(other.chargeType) && controlledBy.equals(other.controlledBy) && environmentId.equals(other.environmentId) @@ -157,6 +167,7 @@ public int hashCode() { return Objects.hash( this.accountId, this.billingProductId, + this.billingStrategy, this.chargeType, this.controlledBy, this.environmentId, @@ -184,7 +195,11 @@ public interface AccountIdStage { } public interface BillingProductIdStage { - ChargeTypeStage billingProductId(@NotNull String billingProductId); + BillingStrategyStage billingProductId(@NotNull String billingProductId); + } + + public interface BillingStrategyStage { + ChargeTypeStage billingStrategy(@NotNull BillingStrategy billingStrategy); } public interface ChargeTypeStage { @@ -235,6 +250,7 @@ public interface _FinalStage { public static final class Builder implements AccountIdStage, BillingProductIdStage, + BillingStrategyStage, ChargeTypeStage, ControlledByStage, EnvironmentIdStage, @@ -245,6 +261,8 @@ public static final class Builder private String billingProductId; + private BillingStrategy billingStrategy; + private ChargeType chargeType; private BillingProviderType controlledBy; @@ -272,6 +290,7 @@ private Builder() {} public Builder from(BillingProductPlanResponseData other) { accountId(other.getAccountId()); billingProductId(other.getBillingProductId()); + billingStrategy(other.getBillingStrategy()); chargeType(other.getChargeType()); controlledBy(other.getControlledBy()); environmentId(other.getEnvironmentId()); @@ -293,11 +312,18 @@ public BillingProductIdStage accountId(@NotNull String accountId) { @java.lang.Override @JsonSetter("billing_product_id") - public ChargeTypeStage billingProductId(@NotNull String billingProductId) { + public BillingStrategyStage billingProductId(@NotNull String billingProductId) { this.billingProductId = Objects.requireNonNull(billingProductId, "billingProductId must not be null"); return this; } + @java.lang.Override + @JsonSetter("billing_strategy") + public ChargeTypeStage billingStrategy(@NotNull BillingStrategy billingStrategy) { + this.billingStrategy = Objects.requireNonNull(billingStrategy, "billingStrategy must not be null"); + return this; + } + @java.lang.Override @JsonSetter("charge_type") public ControlledByStage chargeType(@NotNull ChargeType chargeType) { @@ -390,6 +416,7 @@ public BillingProductPlanResponseData build() { return new BillingProductPlanResponseData( accountId, billingProductId, + billingStrategy, chargeType, controlledBy, environmentId, diff --git a/src/main/java/com/schematic/api/types/BillingStrategy.java b/src/main/java/com/schematic/api/types/BillingStrategy.java new file mode 100644 index 0000000..fd3322e --- /dev/null +++ b/src/main/java/com/schematic/api/types/BillingStrategy.java @@ -0,0 +1,95 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +public final class BillingStrategy { + public static final BillingStrategy SCHEMATIC_MANAGED = + new BillingStrategy(Value.SCHEMATIC_MANAGED, "schematic_managed"); + + public static final BillingStrategy PROVIDER_MANAGED = + new BillingStrategy(Value.PROVIDER_MANAGED, "provider_managed"); + + public static final BillingStrategy NO_BILLING = new BillingStrategy(Value.NO_BILLING, "no_billing"); + + private final Value value; + + private final String string; + + BillingStrategy(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof BillingStrategy && this.string.equals(((BillingStrategy) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case SCHEMATIC_MANAGED: + return visitor.visitSchematicManaged(); + case PROVIDER_MANAGED: + return visitor.visitProviderManaged(); + case NO_BILLING: + return visitor.visitNoBilling(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static BillingStrategy valueOf(String value) { + switch (value) { + case "schematic_managed": + return SCHEMATIC_MANAGED; + case "provider_managed": + return PROVIDER_MANAGED; + case "no_billing": + return NO_BILLING; + default: + return new BillingStrategy(Value.UNKNOWN, value); + } + } + + public enum Value { + SCHEMATIC_MANAGED, + + PROVIDER_MANAGED, + + NO_BILLING, + + UNKNOWN + } + + public interface Visitor { + T visitSchematicManaged(); + + T visitProviderManaged(); + + T visitNoBilling(); + + T visitUnknown(String unknownType); + } +} diff --git a/src/main/java/com/schematic/api/types/ChargeType.java b/src/main/java/com/schematic/api/types/ChargeType.java index 36426db..90dcbd1 100644 --- a/src/main/java/com/schematic/api/types/ChargeType.java +++ b/src/main/java/com/schematic/api/types/ChargeType.java @@ -13,6 +13,8 @@ public final class ChargeType { public static final ChargeType ONE_TIME = new ChargeType(Value.ONE_TIME, "one_time"); + public static final ChargeType NONE = new ChargeType(Value.NONE, "none"); + private final Value value; private final String string; @@ -50,6 +52,8 @@ public T visit(Visitor visitor) { return visitor.visitFree(); case ONE_TIME: return visitor.visitOneTime(); + case NONE: + return visitor.visitNone(); case UNKNOWN: default: return visitor.visitUnknown(string); @@ -65,6 +69,8 @@ public static ChargeType valueOf(String value) { return FREE; case "one_time": return ONE_TIME; + case "none": + return NONE; default: return new ChargeType(Value.UNKNOWN, value); } @@ -73,6 +79,8 @@ public static ChargeType valueOf(String value) { public enum Value { FREE, + NONE, + ONE_TIME, RECURRING, @@ -83,6 +91,8 @@ public enum Value { public interface Visitor { T visitFree(); + T visitNone(); + T visitOneTime(); T visitRecurring(); diff --git a/src/main/java/com/schematic/api/types/CompanyPlanDetailResponseData.java b/src/main/java/com/schematic/api/types/CompanyPlanDetailResponseData.java index 7601d7d..1ef196f 100644 --- a/src/main/java/com/schematic/api/types/CompanyPlanDetailResponseData.java +++ b/src/main/java/com/schematic/api/types/CompanyPlanDetailResponseData.java @@ -32,6 +32,8 @@ public final class CompanyPlanDetailResponseData { private final Optional billingProduct; + private final BillingStrategy billingStrategy; + private final ChargeType chargeType; private final boolean companyCanTrial; @@ -111,6 +113,7 @@ private CompanyPlanDetailResponseData( Optional audienceType, Optional billingLinkedResource, Optional billingProduct, + BillingStrategy billingStrategy, ChargeType chargeType, boolean companyCanTrial, long companyCount, @@ -152,6 +155,7 @@ private CompanyPlanDetailResponseData( this.audienceType = audienceType; this.billingLinkedResource = billingLinkedResource; this.billingProduct = billingProduct; + this.billingStrategy = billingStrategy; this.chargeType = chargeType; this.companyCanTrial = companyCanTrial; this.companyCount = companyCount; @@ -211,6 +215,11 @@ public Optional getBillingProduct() { return billingProduct; } + @JsonProperty("billing_strategy") + public BillingStrategy getBillingStrategy() { + return billingStrategy; + } + @JsonProperty("charge_type") public ChargeType getChargeType() { return chargeType; @@ -326,6 +335,9 @@ public boolean getIsDefault() { return isDefault; } + /** + * @return Deprecated: Use BillingStrategy instead + */ @JsonProperty("is_free") public boolean getIsFree() { return isFree; @@ -407,6 +419,7 @@ private boolean equalTo(CompanyPlanDetailResponseData other) { && audienceType.equals(other.audienceType) && billingLinkedResource.equals(other.billingLinkedResource) && billingProduct.equals(other.billingProduct) + && billingStrategy.equals(other.billingStrategy) && chargeType.equals(other.chargeType) && companyCanTrial == other.companyCanTrial && companyCount == other.companyCount @@ -452,6 +465,7 @@ public int hashCode() { this.audienceType, this.billingLinkedResource, this.billingProduct, + this.billingStrategy, this.chargeType, this.companyCanTrial, this.companyCount, @@ -495,16 +509,20 @@ public String toString() { return ObjectMappers.stringify(this); } - public static ChargeTypeStage builder() { + public static BillingStrategyStage builder() { return new Builder(); } - public interface ChargeTypeStage { - CompanyCanTrialStage chargeType(@NotNull ChargeType chargeType); + public interface BillingStrategyStage { + ChargeTypeStage billingStrategy(@NotNull BillingStrategy billingStrategy); Builder from(CompanyPlanDetailResponseData other); } + public interface ChargeTypeStage { + CompanyCanTrialStage chargeType(@NotNull ChargeType chargeType); + } + public interface CompanyCanTrialStage { CompanyCountStage companyCanTrial(boolean companyCanTrial); } @@ -550,6 +568,9 @@ public interface IsDefaultStage { } public interface IsFreeStage { + /** + *

Deprecated: Use BillingStrategy instead

+ */ IsTrialableStage isFree(boolean isFree); } @@ -685,7 +706,8 @@ public interface _FinalStage { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder - implements ChargeTypeStage, + implements BillingStrategyStage, + ChargeTypeStage, CompanyCanTrialStage, CompanyCountStage, ControlledByStage, @@ -704,6 +726,8 @@ public static final class Builder UpdatedAtStage, ValidStage, _FinalStage { + private BillingStrategy billingStrategy; + private ChargeType chargeType; private boolean companyCanTrial; @@ -795,6 +819,7 @@ public Builder from(CompanyPlanDetailResponseData other) { audienceType(other.getAudienceType()); billingLinkedResource(other.getBillingLinkedResource()); billingProduct(other.getBillingProduct()); + billingStrategy(other.getBillingStrategy()); chargeType(other.getChargeType()); companyCanTrial(other.getCompanyCanTrial()); companyCount(other.getCompanyCount()); @@ -834,6 +859,13 @@ public Builder from(CompanyPlanDetailResponseData other) { return this; } + @java.lang.Override + @JsonSetter("billing_strategy") + public ChargeTypeStage billingStrategy(@NotNull BillingStrategy billingStrategy) { + this.billingStrategy = Objects.requireNonNull(billingStrategy, "billingStrategy must not be null"); + return this; + } + @java.lang.Override @JsonSetter("charge_type") public CompanyCanTrialStage chargeType(@NotNull ChargeType chargeType) { @@ -918,6 +950,11 @@ public IsFreeStage isDefault(boolean isDefault) { return this; } + /** + *

Deprecated: Use BillingStrategy instead

+ *

Deprecated: Use BillingStrategy instead

+ * @return Reference to {@code this} so that method calls can be chained together. + */ @java.lang.Override @JsonSetter("is_free") public IsTrialableStage isFree(boolean isFree) { @@ -1330,6 +1367,7 @@ public CompanyPlanDetailResponseData build() { audienceType, billingLinkedResource, billingProduct, + billingStrategy, chargeType, companyCanTrial, companyCount, diff --git a/src/main/java/com/schematic/api/types/CreateEventRequestBody.java b/src/main/java/com/schematic/api/types/CreateEventRequestBody.java index 023a677..a0efb2b 100644 --- a/src/main/java/com/schematic/api/types/CreateEventRequestBody.java +++ b/src/main/java/com/schematic/api/types/CreateEventRequestBody.java @@ -22,6 +22,8 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = CreateEventRequestBody.Builder.class) public final class CreateEventRequestBody { + private final Optional backfill; + private final Optional body; private final EventType eventType; @@ -30,21 +32,35 @@ public final class CreateEventRequestBody { private final Optional sentAt; + private final Optional trustedClientClock; + private final Map additionalProperties; private CreateEventRequestBody( + Optional backfill, Optional body, EventType eventType, Optional idempotencyKey, Optional sentAt, + Optional trustedClientClock, Map additionalProperties) { + this.backfill = backfill; this.body = body; this.eventType = eventType; this.idempotencyKey = idempotencyKey; this.sentAt = sentAt; + this.trustedClientClock = trustedClientClock; this.additionalProperties = additionalProperties; } + /** + * @return Requires a secret API key, and trusted_client_clock. Import historical data without affecting billing. + */ + @JsonProperty("backfill") + public Optional getBackfill() { + return backfill; + } + @JsonProperty("body") public Optional getBody() { return body; @@ -74,6 +90,14 @@ public Optional getSentAt() { return sentAt; } + /** + * @return Requires a secret API key and sent_at. Use sent_at as the effective timestamp. + */ + @JsonProperty("trusted_client_clock") + public Optional getTrustedClientClock() { + return trustedClientClock; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -86,15 +110,18 @@ public Map getAdditionalProperties() { } private boolean equalTo(CreateEventRequestBody other) { - return body.equals(other.body) + return backfill.equals(other.backfill) + && body.equals(other.body) && eventType.equals(other.eventType) && idempotencyKey.equals(other.idempotencyKey) - && sentAt.equals(other.sentAt); + && sentAt.equals(other.sentAt) + && trustedClientClock.equals(other.trustedClientClock); } @java.lang.Override public int hashCode() { - return Objects.hash(this.body, this.eventType, this.idempotencyKey, this.sentAt); + return Objects.hash( + this.backfill, this.body, this.eventType, this.idempotencyKey, this.sentAt, this.trustedClientClock); } @java.lang.Override @@ -122,6 +149,13 @@ public interface _FinalStage { _FinalStage additionalProperties(Map additionalProperties); + /** + *

Requires a secret API key, and trusted_client_clock. Import historical data without affecting billing.

+ */ + _FinalStage backfill(Optional backfill); + + _FinalStage backfill(Boolean backfill); + _FinalStage body(Optional body); _FinalStage body(EventBody body); @@ -139,18 +173,29 @@ public interface _FinalStage { _FinalStage sentAt(Optional sentAt); _FinalStage sentAt(OffsetDateTime sentAt); + + /** + *

Requires a secret API key and sent_at. Use sent_at as the effective timestamp.

+ */ + _FinalStage trustedClientClock(Optional trustedClientClock); + + _FinalStage trustedClientClock(Boolean trustedClientClock); } @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder implements EventTypeStage, _FinalStage { private EventType eventType; + private Optional trustedClientClock = Optional.empty(); + private Optional sentAt = Optional.empty(); private Optional idempotencyKey = Optional.empty(); private Optional body = Optional.empty(); + private Optional backfill = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -158,10 +203,12 @@ private Builder() {} @java.lang.Override public Builder from(CreateEventRequestBody other) { + backfill(other.getBackfill()); body(other.getBody()); eventType(other.getEventType()); idempotencyKey(other.getIdempotencyKey()); sentAt(other.getSentAt()); + trustedClientClock(other.getTrustedClientClock()); return this; } @@ -177,6 +224,26 @@ public _FinalStage eventType(@NotNull EventType eventType) { return this; } + /** + *

Requires a secret API key and sent_at. Use sent_at as the effective timestamp.

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

Requires a secret API key and sent_at. Use sent_at as the effective timestamp.

+ */ + @java.lang.Override + @JsonSetter(value = "trusted_client_clock", nulls = Nulls.SKIP) + public _FinalStage trustedClientClock(Optional trustedClientClock) { + this.trustedClientClock = trustedClientClock; + return this; + } + /** *

Optionally provide a timestamp at which the event was sent to Schematic

* @return Reference to {@code this} so that method calls can be chained together. @@ -230,9 +297,30 @@ public _FinalStage body(Optional body) { return this; } + /** + *

Requires a secret API key, and trusted_client_clock. Import historical data without affecting billing.

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

Requires a secret API key, and trusted_client_clock. Import historical data without affecting billing.

+ */ + @java.lang.Override + @JsonSetter(value = "backfill", nulls = Nulls.SKIP) + public _FinalStage backfill(Optional backfill) { + this.backfill = backfill; + return this; + } + @java.lang.Override public CreateEventRequestBody build() { - return new CreateEventRequestBody(body, eventType, idempotencyKey, sentAt, additionalProperties); + return new CreateEventRequestBody( + backfill, body, eventType, idempotencyKey, sentAt, trustedClientClock, additionalProperties); } @java.lang.Override diff --git a/src/main/java/com/schematic/api/types/CreditLeaseResponseData.java b/src/main/java/com/schematic/api/types/CreditLeaseResponseData.java new file mode 100644 index 0000000..3b6c1be --- /dev/null +++ b/src/main/java/com/schematic/api/types/CreditLeaseResponseData.java @@ -0,0 +1,322 @@ +/** + * 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.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import java.time.OffsetDateTime; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = CreditLeaseResponseData.Builder.class) +public final class CreditLeaseResponseData { + private final String companyId; + + private final OffsetDateTime createdAt; + + private final String creditTypeId; + + private final OffsetDateTime expiresAt; + + private final double grantedAmount; + + private final String id; + + private final Optional releasedAt; + + private final OffsetDateTime updatedAt; + + private final Map additionalProperties; + + private CreditLeaseResponseData( + String companyId, + OffsetDateTime createdAt, + String creditTypeId, + OffsetDateTime expiresAt, + double grantedAmount, + String id, + Optional releasedAt, + OffsetDateTime updatedAt, + Map additionalProperties) { + this.companyId = companyId; + this.createdAt = createdAt; + this.creditTypeId = creditTypeId; + this.expiresAt = expiresAt; + this.grantedAmount = grantedAmount; + this.id = id; + this.releasedAt = releasedAt; + this.updatedAt = updatedAt; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("company_id") + public String getCompanyId() { + return companyId; + } + + @JsonProperty("created_at") + public OffsetDateTime getCreatedAt() { + return createdAt; + } + + @JsonProperty("credit_type_id") + public String getCreditTypeId() { + return creditTypeId; + } + + @JsonProperty("expires_at") + public OffsetDateTime getExpiresAt() { + return expiresAt; + } + + @JsonProperty("granted_amount") + public double getGrantedAmount() { + return grantedAmount; + } + + @JsonProperty("id") + public String getId() { + return id; + } + + @JsonProperty("released_at") + public Optional getReleasedAt() { + return releasedAt; + } + + @JsonProperty("updated_at") + public OffsetDateTime getUpdatedAt() { + return updatedAt; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CreditLeaseResponseData && equalTo((CreditLeaseResponseData) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CreditLeaseResponseData other) { + return companyId.equals(other.companyId) + && createdAt.equals(other.createdAt) + && creditTypeId.equals(other.creditTypeId) + && expiresAt.equals(other.expiresAt) + && grantedAmount == other.grantedAmount + && id.equals(other.id) + && releasedAt.equals(other.releasedAt) + && updatedAt.equals(other.updatedAt); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.companyId, + this.createdAt, + this.creditTypeId, + this.expiresAt, + this.grantedAmount, + this.id, + this.releasedAt, + this.updatedAt); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static CompanyIdStage builder() { + return new Builder(); + } + + public interface CompanyIdStage { + CreatedAtStage companyId(@NotNull String companyId); + + Builder from(CreditLeaseResponseData other); + } + + public interface CreatedAtStage { + CreditTypeIdStage createdAt(@NotNull OffsetDateTime createdAt); + } + + public interface CreditTypeIdStage { + ExpiresAtStage creditTypeId(@NotNull String creditTypeId); + } + + public interface ExpiresAtStage { + GrantedAmountStage expiresAt(@NotNull OffsetDateTime expiresAt); + } + + public interface GrantedAmountStage { + IdStage grantedAmount(double grantedAmount); + } + + public interface IdStage { + UpdatedAtStage id(@NotNull String id); + } + + public interface UpdatedAtStage { + _FinalStage updatedAt(@NotNull OffsetDateTime updatedAt); + } + + public interface _FinalStage { + CreditLeaseResponseData build(); + + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); + + _FinalStage releasedAt(Optional releasedAt); + + _FinalStage releasedAt(OffsetDateTime releasedAt); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder + implements CompanyIdStage, + CreatedAtStage, + CreditTypeIdStage, + ExpiresAtStage, + GrantedAmountStage, + IdStage, + UpdatedAtStage, + _FinalStage { + private String companyId; + + private OffsetDateTime createdAt; + + private String creditTypeId; + + private OffsetDateTime expiresAt; + + private double grantedAmount; + + private String id; + + private OffsetDateTime updatedAt; + + private Optional releasedAt = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(CreditLeaseResponseData other) { + companyId(other.getCompanyId()); + createdAt(other.getCreatedAt()); + creditTypeId(other.getCreditTypeId()); + expiresAt(other.getExpiresAt()); + grantedAmount(other.getGrantedAmount()); + id(other.getId()); + releasedAt(other.getReleasedAt()); + updatedAt(other.getUpdatedAt()); + return this; + } + + @java.lang.Override + @JsonSetter("company_id") + public CreatedAtStage companyId(@NotNull String companyId) { + this.companyId = Objects.requireNonNull(companyId, "companyId must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("created_at") + public CreditTypeIdStage createdAt(@NotNull OffsetDateTime createdAt) { + this.createdAt = Objects.requireNonNull(createdAt, "createdAt must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("credit_type_id") + public ExpiresAtStage creditTypeId(@NotNull String creditTypeId) { + this.creditTypeId = Objects.requireNonNull(creditTypeId, "creditTypeId must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("expires_at") + public GrantedAmountStage expiresAt(@NotNull OffsetDateTime expiresAt) { + this.expiresAt = Objects.requireNonNull(expiresAt, "expiresAt must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("granted_amount") + public IdStage grantedAmount(double grantedAmount) { + this.grantedAmount = grantedAmount; + return this; + } + + @java.lang.Override + @JsonSetter("id") + public UpdatedAtStage id(@NotNull String id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("updated_at") + public _FinalStage updatedAt(@NotNull OffsetDateTime updatedAt) { + this.updatedAt = Objects.requireNonNull(updatedAt, "updatedAt must not be null"); + return this; + } + + @java.lang.Override + public _FinalStage releasedAt(OffsetDateTime releasedAt) { + this.releasedAt = Optional.ofNullable(releasedAt); + return this; + } + + @java.lang.Override + @JsonSetter(value = "released_at", nulls = Nulls.SKIP) + public _FinalStage releasedAt(Optional releasedAt) { + this.releasedAt = releasedAt; + return this; + } + + @java.lang.Override + public CreditLeaseResponseData build() { + return new CreditLeaseResponseData( + companyId, + createdAt, + creditTypeId, + expiresAt, + grantedAmount, + id, + releasedAt, + updatedAt, + 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/DataEventPayload.java b/src/main/java/com/schematic/api/types/DataEventPayload.java index de6b7ac..aa7c8f3 100644 --- a/src/main/java/com/schematic/api/types/DataEventPayload.java +++ b/src/main/java/com/schematic/api/types/DataEventPayload.java @@ -25,27 +25,35 @@ public final class DataEventPayload { private final String apiKey; + private final Optional backfill; + private final Optional> body; private final Optional idempotencyKey; private final Optional sentAt; + private final Optional trustedClientClock; + private final EventType type; private final Map additionalProperties; private DataEventPayload( String apiKey, + Optional backfill, Optional> body, Optional idempotencyKey, Optional sentAt, + Optional trustedClientClock, EventType type, Map additionalProperties) { this.apiKey = apiKey; + this.backfill = backfill; this.body = body; this.idempotencyKey = idempotencyKey; this.sentAt = sentAt; + this.trustedClientClock = trustedClientClock; this.type = type; this.additionalProperties = additionalProperties; } @@ -55,6 +63,11 @@ public String getApiKey() { return apiKey; } + @JsonProperty("backfill") + public Optional getBackfill() { + return backfill; + } + @JsonProperty("body") public Optional> getBody() { return body; @@ -70,6 +83,11 @@ public Optional getSentAt() { return sentAt; } + @JsonProperty("trusted_client_clock") + public Optional getTrustedClientClock() { + return trustedClientClock; + } + @JsonProperty("type") public EventType getType() { return type; @@ -88,15 +106,24 @@ public Map getAdditionalProperties() { private boolean equalTo(DataEventPayload other) { return apiKey.equals(other.apiKey) + && backfill.equals(other.backfill) && body.equals(other.body) && idempotencyKey.equals(other.idempotencyKey) && sentAt.equals(other.sentAt) + && trustedClientClock.equals(other.trustedClientClock) && type.equals(other.type); } @java.lang.Override public int hashCode() { - return Objects.hash(this.apiKey, this.body, this.idempotencyKey, this.sentAt, this.type); + return Objects.hash( + this.apiKey, + this.backfill, + this.body, + this.idempotencyKey, + this.sentAt, + this.trustedClientClock, + this.type); } @java.lang.Override @@ -125,6 +152,10 @@ public interface _FinalStage { _FinalStage additionalProperties(Map additionalProperties); + _FinalStage backfill(Optional backfill); + + _FinalStage backfill(Boolean backfill); + _FinalStage body(Optional> body); _FinalStage body(Map body); @@ -136,6 +167,10 @@ public interface _FinalStage { _FinalStage sentAt(Optional sentAt); _FinalStage sentAt(OffsetDateTime sentAt); + + _FinalStage trustedClientClock(Optional trustedClientClock); + + _FinalStage trustedClientClock(Boolean trustedClientClock); } @JsonIgnoreProperties(ignoreUnknown = true) @@ -144,12 +179,16 @@ public static final class Builder implements ApiKeyStage, TypeStage, _FinalStage private EventType type; + private Optional trustedClientClock = Optional.empty(); + private Optional sentAt = Optional.empty(); private Optional idempotencyKey = Optional.empty(); private Optional> body = Optional.empty(); + private Optional backfill = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -158,9 +197,11 @@ private Builder() {} @java.lang.Override public Builder from(DataEventPayload other) { apiKey(other.getApiKey()); + backfill(other.getBackfill()); body(other.getBody()); idempotencyKey(other.getIdempotencyKey()); sentAt(other.getSentAt()); + trustedClientClock(other.getTrustedClientClock()); type(other.getType()); return this; } @@ -179,6 +220,19 @@ public _FinalStage type(@NotNull EventType type) { return this; } + @java.lang.Override + public _FinalStage trustedClientClock(Boolean trustedClientClock) { + this.trustedClientClock = Optional.ofNullable(trustedClientClock); + return this; + } + + @java.lang.Override + @JsonSetter(value = "trusted_client_clock", nulls = Nulls.SKIP) + public _FinalStage trustedClientClock(Optional trustedClientClock) { + this.trustedClientClock = trustedClientClock; + return this; + } + @java.lang.Override public _FinalStage sentAt(OffsetDateTime sentAt) { this.sentAt = Optional.ofNullable(sentAt); @@ -218,9 +272,23 @@ public _FinalStage body(Optional> body) { return this; } + @java.lang.Override + public _FinalStage backfill(Boolean backfill) { + this.backfill = Optional.ofNullable(backfill); + return this; + } + + @java.lang.Override + @JsonSetter(value = "backfill", nulls = Nulls.SKIP) + public _FinalStage backfill(Optional backfill) { + this.backfill = backfill; + return this; + } + @java.lang.Override public DataEventPayload build() { - return new DataEventPayload(apiKey, body, idempotencyKey, sentAt, type, additionalProperties); + return new DataEventPayload( + apiKey, backfill, body, idempotencyKey, sentAt, trustedClientClock, type, additionalProperties); } @java.lang.Override diff --git a/src/main/java/com/schematic/api/types/EventBodyTrack.java b/src/main/java/com/schematic/api/types/EventBodyTrack.java index 4585ad5..f9a4b48 100644 --- a/src/main/java/com/schematic/api/types/EventBodyTrack.java +++ b/src/main/java/com/schematic/api/types/EventBodyTrack.java @@ -26,6 +26,8 @@ public final class EventBodyTrack { private final String event; + private final Optional leaseId; + private final Optional quantity; private final Optional> traits; @@ -37,12 +39,14 @@ public final class EventBodyTrack { private EventBodyTrack( Optional> company, String event, + Optional leaseId, Optional quantity, Optional> traits, Optional> user, Map additionalProperties) { this.company = company; this.event = event; + this.leaseId = leaseId; this.quantity = quantity; this.traits = traits; this.user = user; @@ -65,6 +69,14 @@ public String getEvent() { return event; } + /** + * @return Credit lease ID this track event is redeeming against + */ + @JsonProperty("lease_id") + public Optional getLeaseId() { + return leaseId; + } + /** * @return Optionally specify the quantity of the event */ @@ -103,6 +115,7 @@ public Map getAdditionalProperties() { private boolean equalTo(EventBodyTrack other) { return company.equals(other.company) && event.equals(other.event) + && leaseId.equals(other.leaseId) && quantity.equals(other.quantity) && traits.equals(other.traits) && user.equals(other.user); @@ -110,7 +123,7 @@ private boolean equalTo(EventBodyTrack other) { @java.lang.Override public int hashCode() { - return Objects.hash(this.company, this.event, this.quantity, this.traits, this.user); + return Objects.hash(this.company, this.event, this.leaseId, this.quantity, this.traits, this.user); } @java.lang.Override @@ -145,6 +158,13 @@ public interface _FinalStage { _FinalStage company(Map company); + /** + *

Credit lease ID this track event is redeeming against

+ */ + _FinalStage leaseId(Optional leaseId); + + _FinalStage leaseId(String leaseId); + /** *

Optionally specify the quantity of the event

*/ @@ -177,6 +197,8 @@ public static final class Builder implements EventStage, _FinalStage { private Optional quantity = Optional.empty(); + private Optional leaseId = Optional.empty(); + private Optional> company = Optional.empty(); @JsonAnySetter @@ -188,6 +210,7 @@ private Builder() {} public Builder from(EventBodyTrack other) { company(other.getCompany()); event(other.getEvent()); + leaseId(other.getLeaseId()); quantity(other.getQuantity()); traits(other.getTraits()); user(other.getUser()); @@ -266,6 +289,26 @@ public _FinalStage quantity(Optional quantity) { return this; } + /** + *

Credit lease ID this track event is redeeming against

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

Credit lease ID this track event is redeeming against

+ */ + @java.lang.Override + @JsonSetter(value = "lease_id", nulls = Nulls.SKIP) + public _FinalStage leaseId(Optional leaseId) { + this.leaseId = leaseId; + return this; + } + /** *

Key-value pairs to identify company associated with track event

* @return Reference to {@code this} so that method calls can be chained together. @@ -288,7 +331,7 @@ public _FinalStage company(Optional> company) { @java.lang.Override public EventBodyTrack build() { - return new EventBodyTrack(company, event, quantity, traits, user, additionalProperties); + return new EventBodyTrack(company, event, leaseId, quantity, traits, user, additionalProperties); } @java.lang.Override diff --git a/src/main/java/com/schematic/api/types/FeatureView.java b/src/main/java/com/schematic/api/types/FeatureView.java index c483393..ac01594 100644 --- a/src/main/java/com/schematic/api/types/FeatureView.java +++ b/src/main/java/com/schematic/api/types/FeatureView.java @@ -60,6 +60,8 @@ public final class FeatureView { private final OffsetDateTime updatedAt; + private final Optional usageLimitTraitId; + private final Map additionalProperties; private FeatureView( @@ -81,6 +83,7 @@ private FeatureView( Optional trait, Optional traitId, OffsetDateTime updatedAt, + Optional usageLimitTraitId, Map additionalProperties) { this.accountId = accountId; this.billingLinkedResource = billingLinkedResource; @@ -100,6 +103,7 @@ private FeatureView( this.trait = trait; this.traitId = traitId; this.updatedAt = updatedAt; + this.usageLimitTraitId = usageLimitTraitId; this.additionalProperties = additionalProperties; } @@ -193,6 +197,11 @@ public OffsetDateTime getUpdatedAt() { return updatedAt; } + @JsonProperty("usage_limit_trait_id") + public Optional getUsageLimitTraitId() { + return usageLimitTraitId; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -222,7 +231,8 @@ private boolean equalTo(FeatureView other) { && singularName.equals(other.singularName) && trait.equals(other.trait) && traitId.equals(other.traitId) - && updatedAt.equals(other.updatedAt); + && updatedAt.equals(other.updatedAt) + && usageLimitTraitId.equals(other.usageLimitTraitId); } @java.lang.Override @@ -245,7 +255,8 @@ public int hashCode() { this.singularName, this.trait, this.traitId, - this.updatedAt); + this.updatedAt, + this.usageLimitTraitId); } @java.lang.Override @@ -341,6 +352,10 @@ public interface _FinalStage { _FinalStage traitId(Optional traitId); _FinalStage traitId(String traitId); + + _FinalStage usageLimitTraitId(Optional usageLimitTraitId); + + _FinalStage usageLimitTraitId(String usageLimitTraitId); } @JsonIgnoreProperties(ignoreUnknown = true) @@ -370,6 +385,8 @@ public static final class Builder private OffsetDateTime updatedAt; + private Optional usageLimitTraitId = Optional.empty(); + private Optional traitId = Optional.empty(); private Optional trait = Optional.empty(); @@ -415,6 +432,7 @@ public Builder from(FeatureView other) { trait(other.getTrait()); traitId(other.getTraitId()); updatedAt(other.getUpdatedAt()); + usageLimitTraitId(other.getUsageLimitTraitId()); return this; } @@ -474,6 +492,19 @@ public _FinalStage updatedAt(@NotNull OffsetDateTime updatedAt) { return this; } + @java.lang.Override + public _FinalStage usageLimitTraitId(String usageLimitTraitId) { + this.usageLimitTraitId = Optional.ofNullable(usageLimitTraitId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "usage_limit_trait_id", nulls = Nulls.SKIP) + public _FinalStage usageLimitTraitId(Optional usageLimitTraitId) { + this.usageLimitTraitId = usageLimitTraitId; + return this; + } + @java.lang.Override public _FinalStage traitId(String traitId) { this.traitId = Optional.ofNullable(traitId); @@ -647,6 +678,7 @@ public FeatureView build() { trait, traitId, updatedAt, + usageLimitTraitId, additionalProperties); } diff --git a/src/main/java/com/schematic/api/types/PlanDetailResponseData.java b/src/main/java/com/schematic/api/types/PlanDetailResponseData.java index 521f21e..a75bfa5 100644 --- a/src/main/java/com/schematic/api/types/PlanDetailResponseData.java +++ b/src/main/java/com/schematic/api/types/PlanDetailResponseData.java @@ -32,6 +32,8 @@ public final class PlanDetailResponseData { private final Optional billingProduct; + private final BillingStrategy billingStrategy; + private final ChargeType chargeType; private final long companyCount; @@ -91,6 +93,7 @@ private PlanDetailResponseData( Optional audienceType, Optional billingLinkedResource, Optional billingProduct, + BillingStrategy billingStrategy, ChargeType chargeType, long companyCount, Optional companyId, @@ -122,6 +125,7 @@ private PlanDetailResponseData( this.audienceType = audienceType; this.billingLinkedResource = billingLinkedResource; this.billingProduct = billingProduct; + this.billingStrategy = billingStrategy; this.chargeType = chargeType; this.companyCount = companyCount; this.companyId = companyId; @@ -171,6 +175,11 @@ public Optional getBillingProduct() { return billingProduct; } + @JsonProperty("billing_strategy") + public BillingStrategy getBillingStrategy() { + return billingStrategy; + } + @JsonProperty("charge_type") public ChargeType getChargeType() { return chargeType; @@ -246,6 +255,9 @@ public boolean getIsDefault() { return isDefault; } + /** + * @return Deprecated: Use BillingStrategy instead + */ @JsonProperty("is_free") public boolean getIsFree() { return isFree; @@ -317,6 +329,7 @@ private boolean equalTo(PlanDetailResponseData other) { && audienceType.equals(other.audienceType) && billingLinkedResource.equals(other.billingLinkedResource) && billingProduct.equals(other.billingProduct) + && billingStrategy.equals(other.billingStrategy) && chargeType.equals(other.chargeType) && companyCount == other.companyCount && companyId.equals(other.companyId) @@ -352,6 +365,7 @@ public int hashCode() { this.audienceType, this.billingLinkedResource, this.billingProduct, + this.billingStrategy, this.chargeType, this.companyCount, this.companyId, @@ -385,16 +399,20 @@ public String toString() { return ObjectMappers.stringify(this); } - public static ChargeTypeStage builder() { + public static BillingStrategyStage builder() { return new Builder(); } - public interface ChargeTypeStage { - CompanyCountStage chargeType(@NotNull ChargeType chargeType); + public interface BillingStrategyStage { + ChargeTypeStage billingStrategy(@NotNull BillingStrategy billingStrategy); Builder from(PlanDetailResponseData other); } + public interface ChargeTypeStage { + CompanyCountStage chargeType(@NotNull ChargeType chargeType); + } + public interface CompanyCountStage { ControlledByStage companyCount(long companyCount); } @@ -424,6 +442,9 @@ public interface IsDefaultStage { } public interface IsFreeStage { + /** + *

Deprecated: Use BillingStrategy instead

+ */ IsTrialableStage isFree(boolean isFree); } @@ -527,7 +548,8 @@ public interface _FinalStage { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder - implements ChargeTypeStage, + implements BillingStrategyStage, + ChargeTypeStage, CompanyCountStage, ControlledByStage, CreatedAtStage, @@ -541,6 +563,8 @@ public static final class Builder PlanTypeStage, UpdatedAtStage, _FinalStage { + private BillingStrategy billingStrategy; + private ChargeType chargeType; private long companyCount; @@ -612,6 +636,7 @@ public Builder from(PlanDetailResponseData other) { audienceType(other.getAudienceType()); billingLinkedResource(other.getBillingLinkedResource()); billingProduct(other.getBillingProduct()); + billingStrategy(other.getBillingStrategy()); chargeType(other.getChargeType()); companyCount(other.getCompanyCount()); companyId(other.getCompanyId()); @@ -641,6 +666,13 @@ public Builder from(PlanDetailResponseData other) { return this; } + @java.lang.Override + @JsonSetter("billing_strategy") + public ChargeTypeStage billingStrategy(@NotNull BillingStrategy billingStrategy) { + this.billingStrategy = Objects.requireNonNull(billingStrategy, "billingStrategy must not be null"); + return this; + } + @java.lang.Override @JsonSetter("charge_type") public CompanyCountStage chargeType(@NotNull ChargeType chargeType) { @@ -697,6 +729,11 @@ public IsFreeStage isDefault(boolean isDefault) { return this; } + /** + *

Deprecated: Use BillingStrategy instead

+ *

Deprecated: Use BillingStrategy instead

+ * @return Reference to {@code this} so that method calls can be chained together. + */ @java.lang.Override @JsonSetter("is_free") public IsTrialableStage isFree(boolean isFree) { @@ -994,6 +1031,7 @@ public PlanDetailResponseData build() { audienceType, billingLinkedResource, billingProduct, + billingStrategy, chargeType, companyCount, companyId, diff --git a/src/main/java/com/schematic/api/types/PlanGroupPlanDetailResponseData.java b/src/main/java/com/schematic/api/types/PlanGroupPlanDetailResponseData.java index 7fe2f86..3d1f86e 100644 --- a/src/main/java/com/schematic/api/types/PlanGroupPlanDetailResponseData.java +++ b/src/main/java/com/schematic/api/types/PlanGroupPlanDetailResponseData.java @@ -32,6 +32,8 @@ public final class PlanGroupPlanDetailResponseData { private final Optional billingProduct; + private final BillingStrategy billingStrategy; + private final ChargeType chargeType; private final long companyCount; @@ -99,6 +101,7 @@ private PlanGroupPlanDetailResponseData( Optional audienceType, Optional billingLinkedResource, Optional billingProduct, + BillingStrategy billingStrategy, ChargeType chargeType, long companyCount, Optional companyId, @@ -134,6 +137,7 @@ private PlanGroupPlanDetailResponseData( this.audienceType = audienceType; this.billingLinkedResource = billingLinkedResource; this.billingProduct = billingProduct; + this.billingStrategy = billingStrategy; this.chargeType = chargeType; this.companyCount = companyCount; this.companyId = companyId; @@ -187,6 +191,11 @@ public Optional getBillingProduct() { return billingProduct; } + @JsonProperty("billing_strategy") + public BillingStrategy getBillingStrategy() { + return billingStrategy; + } + @JsonProperty("charge_type") public ChargeType getChargeType() { return chargeType; @@ -282,6 +291,9 @@ public boolean getIsDefault() { return isDefault; } + /** + * @return Deprecated: Use BillingStrategy instead + */ @JsonProperty("is_free") public boolean getIsFree() { return isFree; @@ -353,6 +365,7 @@ private boolean equalTo(PlanGroupPlanDetailResponseData other) { && audienceType.equals(other.audienceType) && billingLinkedResource.equals(other.billingLinkedResource) && billingProduct.equals(other.billingProduct) + && billingStrategy.equals(other.billingStrategy) && chargeType.equals(other.chargeType) && companyCount == other.companyCount && companyId.equals(other.companyId) @@ -392,6 +405,7 @@ public int hashCode() { this.audienceType, this.billingLinkedResource, this.billingProduct, + this.billingStrategy, this.chargeType, this.companyCount, this.companyId, @@ -429,16 +443,20 @@ public String toString() { return ObjectMappers.stringify(this); } - public static ChargeTypeStage builder() { + public static BillingStrategyStage builder() { return new Builder(); } - public interface ChargeTypeStage { - CompanyCountStage chargeType(@NotNull ChargeType chargeType); + public interface BillingStrategyStage { + ChargeTypeStage billingStrategy(@NotNull BillingStrategy billingStrategy); Builder from(PlanGroupPlanDetailResponseData other); } + public interface ChargeTypeStage { + CompanyCountStage chargeType(@NotNull ChargeType chargeType); + } + public interface CompanyCountStage { ControlledByStage companyCount(long companyCount); } @@ -472,6 +490,9 @@ public interface IsDefaultStage { } public interface IsFreeStage { + /** + *

Deprecated: Use BillingStrategy instead

+ */ IsTrialableStage isFree(boolean isFree); } @@ -591,7 +612,8 @@ public interface _FinalStage { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder - implements ChargeTypeStage, + implements BillingStrategyStage, + ChargeTypeStage, CompanyCountStage, ControlledByStage, CreatedAtStage, @@ -606,6 +628,8 @@ public static final class Builder PlanTypeStage, UpdatedAtStage, _FinalStage { + private BillingStrategy billingStrategy; + private ChargeType chargeType; private long companyCount; @@ -685,6 +709,7 @@ public Builder from(PlanGroupPlanDetailResponseData other) { audienceType(other.getAudienceType()); billingLinkedResource(other.getBillingLinkedResource()); billingProduct(other.getBillingProduct()); + billingStrategy(other.getBillingStrategy()); chargeType(other.getChargeType()); companyCount(other.getCompanyCount()); companyId(other.getCompanyId()); @@ -718,6 +743,13 @@ public Builder from(PlanGroupPlanDetailResponseData other) { return this; } + @java.lang.Override + @JsonSetter("billing_strategy") + public ChargeTypeStage billingStrategy(@NotNull BillingStrategy billingStrategy) { + this.billingStrategy = Objects.requireNonNull(billingStrategy, "billingStrategy must not be null"); + return this; + } + @java.lang.Override @JsonSetter("charge_type") public CompanyCountStage chargeType(@NotNull ChargeType chargeType) { @@ -781,6 +813,11 @@ public IsFreeStage isDefault(boolean isDefault) { return this; } + /** + *

Deprecated: Use BillingStrategy instead

+ *

Deprecated: Use BillingStrategy instead

+ * @return Reference to {@code this} so that method calls can be chained together. + */ @java.lang.Override @JsonSetter("is_free") public IsTrialableStage isFree(boolean isFree) { @@ -1139,6 +1176,7 @@ public PlanGroupPlanDetailResponseData build() { audienceType, billingLinkedResource, billingProduct, + billingStrategy, chargeType, companyCount, companyId, diff --git a/src/main/java/com/schematic/api/types/PlanViewPublicResponseData.java b/src/main/java/com/schematic/api/types/PlanViewPublicResponseData.java index c7d78a8..00d0ab8 100644 --- a/src/main/java/com/schematic/api/types/PlanViewPublicResponseData.java +++ b/src/main/java/com/schematic/api/types/PlanViewPublicResponseData.java @@ -32,6 +32,8 @@ public final class PlanViewPublicResponseData { private final Optional billingProduct; + private final BillingStrategy billingStrategy; + private final ChargeType chargeType; private final long companyCount; @@ -101,6 +103,7 @@ private PlanViewPublicResponseData( Optional audienceType, Optional billingLinkedResource, Optional billingProduct, + BillingStrategy billingStrategy, ChargeType chargeType, long companyCount, Optional companyId, @@ -137,6 +140,7 @@ private PlanViewPublicResponseData( this.audienceType = audienceType; this.billingLinkedResource = billingLinkedResource; this.billingProduct = billingProduct; + this.billingStrategy = billingStrategy; this.chargeType = chargeType; this.companyCount = companyCount; this.companyId = companyId; @@ -191,6 +195,11 @@ public Optional getBillingProduct() { return billingProduct; } + @JsonProperty("billing_strategy") + public BillingStrategy getBillingStrategy() { + return billingStrategy; + } + @JsonProperty("charge_type") public ChargeType getChargeType() { return chargeType; @@ -291,6 +300,9 @@ public boolean getIsDefault() { return isDefault; } + /** + * @return Deprecated: Use BillingStrategy instead + */ @JsonProperty("is_free") public boolean getIsFree() { return isFree; @@ -362,6 +374,7 @@ private boolean equalTo(PlanViewPublicResponseData other) { && audienceType.equals(other.audienceType) && billingLinkedResource.equals(other.billingLinkedResource) && billingProduct.equals(other.billingProduct) + && billingStrategy.equals(other.billingStrategy) && chargeType.equals(other.chargeType) && companyCount == other.companyCount && companyId.equals(other.companyId) @@ -402,6 +415,7 @@ public int hashCode() { this.audienceType, this.billingLinkedResource, this.billingProduct, + this.billingStrategy, this.chargeType, this.companyCount, this.companyId, @@ -440,16 +454,20 @@ public String toString() { return ObjectMappers.stringify(this); } - public static ChargeTypeStage builder() { + public static BillingStrategyStage builder() { return new Builder(); } - public interface ChargeTypeStage { - CompanyCountStage chargeType(@NotNull ChargeType chargeType); + public interface BillingStrategyStage { + ChargeTypeStage billingStrategy(@NotNull BillingStrategy billingStrategy); Builder from(PlanViewPublicResponseData other); } + public interface ChargeTypeStage { + CompanyCountStage chargeType(@NotNull ChargeType chargeType); + } + public interface CompanyCountStage { ControlledByStage companyCount(long companyCount); } @@ -487,6 +505,9 @@ public interface IsDefaultStage { } public interface IsFreeStage { + /** + *

Deprecated: Use BillingStrategy instead

+ */ IsTrialableStage isFree(boolean isFree); } @@ -608,7 +629,8 @@ public interface _FinalStage { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder - implements ChargeTypeStage, + implements BillingStrategyStage, + ChargeTypeStage, CompanyCountStage, ControlledByStage, CreatedAtStage, @@ -624,6 +646,8 @@ public static final class Builder PlanTypeStage, UpdatedAtStage, _FinalStage { + private BillingStrategy billingStrategy; + private ChargeType chargeType; private long companyCount; @@ -705,6 +729,7 @@ public Builder from(PlanViewPublicResponseData other) { audienceType(other.getAudienceType()); billingLinkedResource(other.getBillingLinkedResource()); billingProduct(other.getBillingProduct()); + billingStrategy(other.getBillingStrategy()); chargeType(other.getChargeType()); companyCount(other.getCompanyCount()); companyId(other.getCompanyId()); @@ -739,6 +764,13 @@ public Builder from(PlanViewPublicResponseData other) { return this; } + @java.lang.Override + @JsonSetter("billing_strategy") + public ChargeTypeStage billingStrategy(@NotNull BillingStrategy billingStrategy) { + this.billingStrategy = Objects.requireNonNull(billingStrategy, "billingStrategy must not be null"); + return this; + } + @java.lang.Override @JsonSetter("charge_type") public CompanyCountStage chargeType(@NotNull ChargeType chargeType) { @@ -809,6 +841,11 @@ public IsFreeStage isDefault(boolean isDefault) { return this; } + /** + *

Deprecated: Use BillingStrategy instead

+ *

Deprecated: Use BillingStrategy instead

+ * @return Reference to {@code this} so that method calls can be chained together. + */ @java.lang.Override @JsonSetter("is_free") public IsTrialableStage isFree(boolean isFree) { @@ -1177,6 +1214,7 @@ public PlanViewPublicResponseData build() { audienceType, billingLinkedResource, billingProduct, + billingStrategy, chargeType, companyCount, companyId, diff --git a/src/main/java/com/schematic/api/types/UpsertBillingProductRequestBody.java b/src/main/java/com/schematic/api/types/UpsertBillingProductRequestBody.java index 0fa6cbb..5fd07e0 100644 --- a/src/main/java/com/schematic/api/types/UpsertBillingProductRequestBody.java +++ b/src/main/java/com/schematic/api/types/UpsertBillingProductRequestBody.java @@ -24,6 +24,8 @@ public final class UpsertBillingProductRequestBody { private final Optional billingProductId; + private final Optional billingStrategy; + private final ChargeType chargeType; private final Optional currency; @@ -54,6 +56,7 @@ public final class UpsertBillingProductRequestBody { private UpsertBillingProductRequestBody( Optional billingProductId, + Optional billingStrategy, ChargeType chargeType, Optional currency, Optional> currencyPrices, @@ -69,6 +72,7 @@ private UpsertBillingProductRequestBody( Optional yearlyPriceId, Map additionalProperties) { this.billingProductId = billingProductId; + this.billingStrategy = billingStrategy; this.chargeType = chargeType; this.currency = currency; this.currencyPrices = currencyPrices; @@ -90,6 +94,11 @@ public Optional getBillingProductId() { return billingProductId; } + @JsonProperty("billing_strategy") + public Optional getBillingStrategy() { + return billingStrategy; + } + @JsonProperty("charge_type") public ChargeType getChargeType() { return chargeType; @@ -168,6 +177,7 @@ public Map getAdditionalProperties() { private boolean equalTo(UpsertBillingProductRequestBody other) { return billingProductId.equals(other.billingProductId) + && billingStrategy.equals(other.billingStrategy) && chargeType.equals(other.chargeType) && currency.equals(other.currency) && currencyPrices.equals(other.currencyPrices) @@ -187,6 +197,7 @@ private boolean equalTo(UpsertBillingProductRequestBody other) { public int hashCode() { return Objects.hash( this.billingProductId, + this.billingStrategy, this.chargeType, this.currency, this.currencyPrices, @@ -232,6 +243,10 @@ public interface _FinalStage { _FinalStage billingProductId(String billingProductId); + _FinalStage billingStrategy(Optional billingStrategy); + + _FinalStage billingStrategy(BillingStrategy billingStrategy); + _FinalStage currency(Optional currency); _FinalStage currency(String currency); @@ -305,6 +320,8 @@ public static final class Builder implements ChargeTypeStage, IsTrialableStage, private Optional currency = Optional.empty(); + private Optional billingStrategy = Optional.empty(); + private Optional billingProductId = Optional.empty(); @JsonAnySetter @@ -315,6 +332,7 @@ private Builder() {} @java.lang.Override public Builder from(UpsertBillingProductRequestBody other) { billingProductId(other.getBillingProductId()); + billingStrategy(other.getBillingStrategy()); chargeType(other.getChargeType()); currency(other.getCurrency()); currencyPrices(other.getCurrencyPrices()); @@ -488,6 +506,19 @@ public _FinalStage currency(Optional currency) { return this; } + @java.lang.Override + public _FinalStage billingStrategy(BillingStrategy billingStrategy) { + this.billingStrategy = Optional.ofNullable(billingStrategy); + return this; + } + + @java.lang.Override + @JsonSetter(value = "billing_strategy", nulls = Nulls.SKIP) + public _FinalStage billingStrategy(Optional billingStrategy) { + this.billingStrategy = billingStrategy; + return this; + } + @java.lang.Override public _FinalStage billingProductId(String billingProductId) { this.billingProductId = Optional.ofNullable(billingProductId); @@ -505,6 +536,7 @@ public _FinalStage billingProductId(Optional billingProductId) { public UpsertBillingProductRequestBody build() { return new UpsertBillingProductRequestBody( billingProductId, + billingStrategy, chargeType, currency, currencyPrices,