diff --git a/.fern/metadata.json b/.fern/metadata.json index 77fb3fef..acf2cba9 100644 --- a/.fern/metadata.json +++ b/.fern/metadata.json @@ -14,10 +14,10 @@ "implementation redis.clients:jedis:5.2.0" ] }, - "originGitCommit": "686551a0297d2f37075b3586b030ff32be5c94f7", + "originGitCommit": "31f498c0a9babdc0eec5ae88e1212a254b2f2561", "originGitCommitIsDirty": false, "invokedBy": "ci", - "requestedVersion": "1.5.8", + "requestedVersion": "1.5.9", "ciProvider": "github", - "sdkVersion": "1.5.8" + "sdkVersion": "1.5.9" } \ No newline at end of file diff --git a/.fern/replay.lock b/.fern/replay.lock index 4d7431c0..288e42a6 100644 --- a/.fern/replay.lock +++ b/.fern/replay.lock @@ -54,5 +54,11 @@ generations: cli_version: unknown generator_versions: fernapi/fern-java-sdk: 4.19.2 -current_generation: 075a15a28676baf75bb4cf01a59dba1440bff350 + - commit_sha: 66bda91e3e5e64805291b44f92c7ac83acce3768 + tree_hash: 870032ab7a435781f0909a2c8bf721216f31386e + timestamp: 2026-09-05T06:40:29.255Z + cli_version: unknown + generator_versions: + fernapi/fern-java-sdk: 4.19.2 +current_generation: 66bda91e3e5e64805291b44f92c7ac83acce3768 patches: [] diff --git a/build.gradle b/build.gradle index 028b0a5b..e6187104 100644 --- a/build.gradle +++ b/build.gradle @@ -62,7 +62,7 @@ java { group = 'com.schematichq' -version = '1.5.8' +version = '1.5.9' jar { dependsOn(":generatePomFileForMavenPublication") @@ -93,7 +93,7 @@ publishing { maven(MavenPublication) { groupId = 'com.schematichq' artifactId = 'schematic-java' - version = '1.5.8' + version = '1.5.9' from components.java pom { name = 'Schematic' diff --git a/reference.md b/reference.md index 7d0e8f6a..ac124db1 100644 --- a/reference.md +++ b/reference.md @@ -1156,6 +1156,14 @@ client.accounts().updateOnboardingState(
+**country:** `Optional` + +
+
+ +
+
+ **dismissed:** `Optional`
@@ -3534,6 +3542,181 @@ client.billing().countBillingProducts(
+ + + + +
client.billing.listCompanyBillingProfiles() -> ListCompanyBillingProfilesResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.billing().listCompanyBillingProfiles( + ListCompanyBillingProfilesRequest + .builder() + .companyId("company_id") + .isDefault(true) + .providerType(BillingProviderType.METRONOME) + .limit(1000000L) + .offset(1000000L) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**companyId:** `Optional` + +
+
+ +
+
+ +**isDefault:** `Optional` + +
+
+ +
+
+ +**providerType:** `Optional` + +
+
+ +
+
+ +**limit:** `Optional` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `Optional` — Page offset (default 0) + +
+
+
+
+ + +
+
+
+ +
client.billing.updateCompanyBillingProfile(billingProfileId, request) -> UpdateCompanyBillingProfileResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.billing().updateCompanyBillingProfile( + "billing_profile_id", + UpdateCompanyBillingProfileRequestBody + .builder() + .collectionMethod(BillingCollectionMethod.CHARGE_AUTOMATICALLY) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**billingProfileId:** `String` — billing_profile_id + +
+
+ +
+
+ +**collectionMethod:** `BillingCollectionMethod` + +
+
+ +
+
+ +**daysUntilDue:** `Optional` + +
+
+ +
+
+ +**isDefault:** `Optional` + +
+
+ +
+
+ +**name:** `Optional` + +
+
+ +
+
+ +**paymentMethodId:** `Optional` + +
+
+ +
+
+ +**prorationBehavior:** `Optional` + +
+
+
+
+ +
@@ -5979,7 +6162,7 @@ client.credits().countBillingPlanCreditGrants( -
client.credits.listCreditEventLedger() -> ListCreditEventLedgerResponse +
client.credits.listCreditSpendPolicies() -> ListCreditSpendPoliciesResponse
@@ -5992,15 +6175,16 @@ client.credits().countBillingPlanCreditGrants(
```java -client.credits().listCreditEventLedger( - ListCreditEventLedgerRequest +client.credits().listCreditSpendPolicies( + ListCreditSpendPoliciesRequest .builder() - .companyId("company_id") + .userIds( + Arrays.asList("user_ids") + ) .billingCreditId("billing_credit_id") - .endTime("end_time") - .eventType(CreditEventType.GRANT) - .featureId("feature_id") - .startTime("start_time") + .companyId("company_id") + .scopeType(CreditSpendPolicyScope.COMPANY) + .userId("user_id") .limit(1000000L) .offset(1000000L) .build() @@ -6027,15 +6211,7 @@ client.credits().listCreditEventLedger(
-**companyId:** `String` - -
-
- -
-
- -**endTime:** `Optional` +**companyId:** `Optional`
@@ -6043,7 +6219,7 @@ client.credits().listCreditEventLedger(
-**eventType:** `Optional` +**scopeType:** `Optional`
@@ -6051,7 +6227,7 @@ client.credits().listCreditEventLedger(
-**featureId:** `Optional` +**userId:** `Optional`
@@ -6059,7 +6235,7 @@ client.credits().listCreditEventLedger(
-**startTime:** `Optional` +**userIds:** `Optional`
@@ -6087,7 +6263,7 @@ client.credits().listCreditEventLedger(
-
client.credits.countCreditEventLedger() -> CountCreditEventLedgerResponse +
client.credits.createCreditSpendPolicy(request) -> CreateCreditSpendPolicyResponse
@@ -6100,17 +6276,11 @@ client.credits().listCreditEventLedger(
```java -client.credits().countCreditEventLedger( - CountCreditEventLedgerRequest +client.credits().createCreditSpendPolicy( + CreateCreditSpendPolicyRequestBody .builder() - .companyId("company_id") .billingCreditId("billing_credit_id") - .endTime("end_time") - .eventType(CreditEventType.GRANT) - .featureId("feature_id") - .startTime("start_time") - .limit(1000000L) - .offset(1000000L) + .maxPerDraw(1.1) .build() ); ``` @@ -6127,7 +6297,7 @@ client.credits().countCreditEventLedger(
-**billingCreditId:** `Optional` +**billingCreditId:** `String`
@@ -6135,7 +6305,7 @@ client.credits().countCreditEventLedger(
-**companyId:** `String` +**companyId:** `Optional` — The company the cap applies to. Set exactly one of company_id and user_id.
@@ -6143,7 +6313,7 @@ client.credits().countCreditEventLedger(
-**endTime:** `Optional` +**label:** `Optional`
@@ -6151,7 +6321,7 @@ client.credits().countCreditEventLedger(
-**eventType:** `Optional` +**maxPerDraw:** `Double` — The largest number of credits a single draw may spend.
@@ -6159,31 +6329,47 @@ client.credits().countCreditEventLedger(
-**featureId:** `Optional` +**userId:** `Optional` — The user the cap applies to. Set exactly one of company_id and user_id.
+
+
-
-
-**startTime:** `Optional` -
+
+
client.credits.getCreditSpendPolicy(spendPolicyId) -> GetCreditSpendPolicyResponse
-**limit:** `Optional` — Page limit (default 100) - +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.credits().getCreditSpendPolicy("spend_policy_id"); +``` +
+
+#### ⚙️ Parameters +
-**offset:** `Optional` — Page offset (default 0) +
+
+ +**spendPolicyId:** `String` — spend_policy_id
@@ -6195,8 +6381,7 @@ client.credits().countCreditEventLedger(
-## catalogs -
client.catalogs.listCatalogs() -> ListCatalogsResponse +
client.credits.updateCreditSpendPolicy(spendPolicyId, request) -> UpdateCreditSpendPolicyResponse
@@ -6209,13 +6394,10 @@ client.credits().countCreditEventLedger(
```java -client.catalogs().listCatalogs( - ListCatalogsRequest +client.credits().updateCreditSpendPolicy( + "spend_policy_id", + UpdateCreditSpendPolicyRequestBody .builder() - .isDefault(true) - .q("q") - .limit(1000000L) - .offset(1000000L) .build() ); ``` @@ -6232,15 +6414,7 @@ client.catalogs().listCatalogs(
-**isDefault:** `Optional` - -
-
- -
-
- -**q:** `Optional` — Search by catalog name +**spendPolicyId:** `String` — spend_policy_id
@@ -6248,7 +6422,7 @@ client.catalogs().listCatalogs(
-**limit:** `Optional` — Page limit (default 100) +**label:** `Optional`
@@ -6256,7 +6430,437 @@ client.catalogs().listCatalogs(
-**offset:** `Optional` — Page offset (default 0) +**maxPerDraw:** `Optional` + +
+
+
+
+ + + + +
+ +
client.credits.deleteCreditSpendPolicy(spendPolicyId) -> DeleteCreditSpendPolicyResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.credits().deleteCreditSpendPolicy("spend_policy_id"); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**spendPolicyId:** `String` — spend_policy_id + +
+
+
+
+ + +
+
+
+ +
client.credits.countCreditSpendPolicies() -> CountCreditSpendPoliciesResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.credits().countCreditSpendPolicies( + CountCreditSpendPoliciesRequest + .builder() + .userIds( + Arrays.asList("user_ids") + ) + .billingCreditId("billing_credit_id") + .companyId("company_id") + .scopeType(CreditSpendPolicyScope.COMPANY) + .userId("user_id") + .limit(1000000L) + .offset(1000000L) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**billingCreditId:** `Optional` + +
+
+ +
+
+ +**companyId:** `Optional` + +
+
+ +
+
+ +**scopeType:** `Optional` + +
+
+ +
+
+ +**userId:** `Optional` + +
+
+ +
+
+ +**userIds:** `Optional` + +
+
+ +
+
+ +**limit:** `Optional` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `Optional` — Page offset (default 0) + +
+
+
+
+ + +
+
+
+ +
client.credits.listCreditEventLedger() -> ListCreditEventLedgerResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.credits().listCreditEventLedger( + ListCreditEventLedgerRequest + .builder() + .companyId("company_id") + .billingCreditId("billing_credit_id") + .endTime("end_time") + .eventType(CreditEventType.GRANT) + .featureId("feature_id") + .startTime("start_time") + .limit(1000000L) + .offset(1000000L) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**billingCreditId:** `Optional` + +
+
+ +
+
+ +**companyId:** `String` + +
+
+ +
+
+ +**endTime:** `Optional` + +
+
+ +
+
+ +**eventType:** `Optional` + +
+
+ +
+
+ +**featureId:** `Optional` + +
+
+ +
+
+ +**startTime:** `Optional` + +
+
+ +
+
+ +**limit:** `Optional` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `Optional` — Page offset (default 0) + +
+
+
+
+ + +
+
+
+ +
client.credits.countCreditEventLedger() -> CountCreditEventLedgerResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.credits().countCreditEventLedger( + CountCreditEventLedgerRequest + .builder() + .companyId("company_id") + .billingCreditId("billing_credit_id") + .endTime("end_time") + .eventType(CreditEventType.GRANT) + .featureId("feature_id") + .startTime("start_time") + .limit(1000000L) + .offset(1000000L) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**billingCreditId:** `Optional` + +
+
+ +
+
+ +**companyId:** `String` + +
+
+ +
+
+ +**endTime:** `Optional` + +
+
+ +
+
+ +**eventType:** `Optional` + +
+
+ +
+
+ +**featureId:** `Optional` + +
+
+ +
+
+ +**startTime:** `Optional` + +
+
+ +
+
+ +**limit:** `Optional` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `Optional` — Page offset (default 0) + +
+
+
+
+ + +
+
+
+ +## catalogs +
client.catalogs.listCatalogs() -> ListCatalogsResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.catalogs().listCatalogs( + ListCatalogsRequest + .builder() + .isDefault(true) + .q("q") + .limit(1000000L) + .offset(1000000L) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**isDefault:** `Optional` + +
+
+ +
+
+ +**q:** `Optional` — Search by catalog name + +
+
+ +
+
+ +**limit:** `Optional` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `Optional` — Page offset (default 0)
@@ -16089,64 +16693,174 @@ client.events().listEvents(
-**companyId:** `Optional` - -
-
- +**companyId:** `Optional` + +
+
+ +
+
+ +**eventSubtype:** `Optional` + +
+
+ +
+
+ +**eventTypes:** `Optional` + +
+
+ +
+
+ +**flagId:** `Optional` + +
+
+ +
+
+ +**idempotencyKey:** `Optional` + +
+
+ +
+
+ +**userId:** `Optional` + +
+
+ +
+
+ +**limit:** `Optional` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `Optional` — Page offset (default 0) + +
+
+
+
+ + + + +
+ +
client.events.createEvent(request) -> CreateEventResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.events().createEvent( + CreateEventRequestBody + .builder() + .eventType(EventType.FLAG_CHECK) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `CreateEventRequestBody` + +
+
+
+
+ + +
+
+
+ +
client.events.getEvent(eventId) -> GetEventResponse +
+
+ +#### 🔌 Usage + +
+
+
-**eventSubtype:** `Optional` - +```java +client.events().getEvent("event_id"); +``` +
+
+#### ⚙️ Parameters +
-**eventTypes:** `Optional` - -
-
-
-**flagId:** `Optional` +**eventId:** `String` — event_id
+
+
-
-
-**idempotencyKey:** `Optional` -
+
+
client.events.getOtlpEnvironmentSettings() -> GetOtlpEnvironmentSettingsResponse
-**userId:** `Optional` - -
-
+#### 🔌 Usage
-**limit:** `Optional` — Page limit (default 100) - -
-
-
-**offset:** `Optional` — Page offset (default 0) - +```java +client.events().getOtlpEnvironmentSettings(); +```
@@ -16157,7 +16871,7 @@ client.events().listEvents(
-
client.events.createEvent(request) -> CreateEventResponse +
client.events.upsertOtlpEnvironmentSettings(request) -> UpsertOtlpEnvironmentSettingsResponse
@@ -16170,10 +16884,10 @@ client.events().listEvents(
```java -client.events().createEvent( - CreateEventRequestBody +client.events().upsertOtlpEnvironmentSettings( + UpsertOtlpEnvironmentSettingsRequestBody .builder() - .eventType(EventType.FLAG_CHECK) + .toolEventsEnabled(true) .build() ); ``` @@ -16190,48 +16904,65 @@ client.events().createEvent(
-**request:** `CreateEventRequestBody` +**companyAttribute:** `Optional`
-
-
+
+
+**companyKey:** `Optional` +
-
-
client.events.getEvent(eventId) -> GetEventResponse
-#### 🔌 Usage +**toolEventsEnabled:** `Boolean` + +
+
+**userAttribute:** `Optional` + +
+
+
-```java -client.events().getEvent("event_id"); -``` +**userKey:** `Optional` +
-#### ⚙️ Parameters + + +
+ +
client.events.deleteOtlpEnvironmentSettings() -> DeleteOtlpEnvironmentSettingsResponse
+#### 🔌 Usage +
-**eventId:** `String` — event_id - +
+
+ +```java +client.events().deleteOtlpEnvironmentSettings(); +```
@@ -18240,6 +18971,101 @@ client.integrationsapi().loadSampleDataSet();
+
+
+
+ +
client.integrationsapi.getStripeSandboxClaimLink() -> GetStripeSandboxClaimLinkResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.integrationsapi().getStripeSandboxClaimLink(); +``` +
+
+
+
+ + +
+
+
+ +
client.integrationsapi.getStripeSandboxKeys() -> GetStripeSandboxKeysResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.integrationsapi().getStripeSandboxKeys(); +``` +
+
+
+
+ + +
+
+
+ +
client.integrationsapi.claimStripeSandboxKeys(request) -> ClaimStripeSandboxKeysResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.integrationsapi().claimStripeSandboxKeys( + ClaimStripeSandboxKeysRequestBody + .builder() + .token("token") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**token:** `String` + +
+
+
+
+ +
@@ -18330,6 +19156,100 @@ client.integrationsapi().installStripe( + + +
+ +
client.integrationsapi.installStripeClaimableSandbox(request) -> InstallStripeClaimableSandboxResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.integrationsapi().installStripeClaimableSandbox( + InstallStripeSandboxRequestBody + .builder() + .email("email") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**country:** `Optional` + +
+
+ +
+
+ +**email:** `String` + +
+
+ +
+
+ +**name:** `Optional` + +
+
+ +
+
+ +**seedSampleData:** `Optional` + +
+
+
+
+ + +
+
+
+ +
client.integrationsapi.listStripeSandboxCountries() -> ListStripeSandboxCountriesResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.integrationsapi().listStripeSandboxCountries(); +``` +
+
+
+
+ +
diff --git a/src/main/java/com/schematic/api/core/ClientOptions.java b/src/main/java/com/schematic/api/core/ClientOptions.java index 32b0d048..a0483c84 100644 --- a/src/main/java/com/schematic/api/core/ClientOptions.java +++ b/src/main/java/com/schematic/api/core/ClientOptions.java @@ -47,10 +47,10 @@ private ClientOptions( this.headers.putAll(headers); this.headers.putAll(new HashMap() { { - put("User-Agent", "com.schematichq.schematic-java/1.5.8"); + put("User-Agent", "com.schematichq.schematic-java/1.5.9"); put("X-Fern-Language", "JAVA"); put("X-Fern-SDK-Name", "com.schematichq:schematic-java"); - put("X-Fern-SDK-Version", "1.5.8"); + put("X-Fern-SDK-Version", "1.5.9"); } }); this.headerSuppliers = headerSuppliers; diff --git a/src/main/java/com/schematic/api/errors/PaymentRequiredError.java b/src/main/java/com/schematic/api/errors/PaymentRequiredError.java new file mode 100644 index 00000000..07dea261 --- /dev/null +++ b/src/main/java/com/schematic/api/errors/PaymentRequiredError.java @@ -0,0 +1,33 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.errors; + +import com.schematic.api.core.BaseSchematicApiException; +import com.schematic.api.types.ApiError; +import okhttp3.Response; + +public final class PaymentRequiredError extends BaseSchematicApiException { + /** + * The body of the response that triggered the exception. + */ + private final ApiError body; + + public PaymentRequiredError(ApiError body) { + super("PaymentRequiredError", 402, body); + this.body = body; + } + + public PaymentRequiredError(ApiError body, Response rawResponse) { + super("PaymentRequiredError", 402, body, rawResponse); + this.body = body; + } + + /** + * @return the body + */ + @java.lang.Override + public ApiError body() { + return this.body; + } +} diff --git a/src/main/java/com/schematic/api/resources/accounts/requests/UpdateOnboardingStateRequestBody.java b/src/main/java/com/schematic/api/resources/accounts/requests/UpdateOnboardingStateRequestBody.java index 47ff16cc..fc34b82f 100644 --- a/src/main/java/com/schematic/api/resources/accounts/requests/UpdateOnboardingStateRequestBody.java +++ b/src/main/java/com/schematic/api/resources/accounts/requests/UpdateOnboardingStateRequestBody.java @@ -22,6 +22,8 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = UpdateOnboardingStateRequestBody.Builder.class) public final class UpdateOnboardingStateRequestBody { + private final Optional country; + private final Optional dismissed; private final Optional path; @@ -35,12 +37,14 @@ public final class UpdateOnboardingStateRequestBody { private final Map additionalProperties; private UpdateOnboardingStateRequestBody( + Optional country, Optional dismissed, Optional path, Optional pricingPageUrl, Optional track, Optional websiteUrl, Map additionalProperties) { + this.country = country; this.dismissed = dismissed; this.path = path; this.pricingPageUrl = pricingPageUrl; @@ -49,6 +53,11 @@ private UpdateOnboardingStateRequestBody( this.additionalProperties = additionalProperties; } + @JsonProperty("country") + public Optional getCountry() { + return country; + } + @JsonProperty("dismissed") public Optional getDismissed() { return dismissed; @@ -86,7 +95,8 @@ public Map getAdditionalProperties() { } private boolean equalTo(UpdateOnboardingStateRequestBody other) { - return dismissed.equals(other.dismissed) + return country.equals(other.country) + && dismissed.equals(other.dismissed) && path.equals(other.path) && pricingPageUrl.equals(other.pricingPageUrl) && track.equals(other.track) @@ -95,7 +105,7 @@ private boolean equalTo(UpdateOnboardingStateRequestBody other) { @java.lang.Override public int hashCode() { - return Objects.hash(this.dismissed, this.path, this.pricingPageUrl, this.track, this.websiteUrl); + return Objects.hash(this.country, this.dismissed, this.path, this.pricingPageUrl, this.track, this.websiteUrl); } @java.lang.Override @@ -109,6 +119,8 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { + private Optional country = Optional.empty(); + private Optional dismissed = Optional.empty(); private Optional path = Optional.empty(); @@ -125,6 +137,7 @@ public static final class Builder { private Builder() {} public Builder from(UpdateOnboardingStateRequestBody other) { + country(other.getCountry()); dismissed(other.getDismissed()); path(other.getPath()); pricingPageUrl(other.getPricingPageUrl()); @@ -133,6 +146,17 @@ public Builder from(UpdateOnboardingStateRequestBody other) { return this; } + @JsonSetter(value = "country", nulls = Nulls.SKIP) + public Builder country(Optional country) { + this.country = country; + return this; + } + + public Builder country(String country) { + this.country = Optional.ofNullable(country); + return this; + } + @JsonSetter(value = "dismissed", nulls = Nulls.SKIP) public Builder dismissed(Optional dismissed) { this.dismissed = dismissed; @@ -190,7 +214,7 @@ public Builder websiteUrl(String websiteUrl) { public UpdateOnboardingStateRequestBody build() { return new UpdateOnboardingStateRequestBody( - dismissed, path, pricingPageUrl, track, websiteUrl, additionalProperties); + country, dismissed, path, pricingPageUrl, track, websiteUrl, additionalProperties); } public Builder additionalProperty(String key, Object value) { 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 a6087b7e..14e7c0e7 100644 --- a/src/main/java/com/schematic/api/resources/billing/AsyncBillingClient.java +++ b/src/main/java/com/schematic/api/resources/billing/AsyncBillingClient.java @@ -18,11 +18,13 @@ import com.schematic.api.resources.billing.requests.ListBillingPricesRequest; import com.schematic.api.resources.billing.requests.ListBillingProductPricesRequest; import com.schematic.api.resources.billing.requests.ListBillingProductsRequest; +import com.schematic.api.resources.billing.requests.ListCompanyBillingProfilesRequest; import com.schematic.api.resources.billing.requests.ListCouponsRequest; import com.schematic.api.resources.billing.requests.ListCustomersWithSubscriptionsRequest; import com.schematic.api.resources.billing.requests.ListInvoicesRequest; import com.schematic.api.resources.billing.requests.ListMetersRequest; import com.schematic.api.resources.billing.requests.ListPaymentMethodsRequest; +import com.schematic.api.resources.billing.requests.UpdateCompanyBillingProfileRequestBody; import com.schematic.api.resources.billing.types.CountBillingProductsResponse; import com.schematic.api.resources.billing.types.CountCustomersResponse; import com.schematic.api.resources.billing.types.DeleteBillingCouponResponse; @@ -34,11 +36,13 @@ import com.schematic.api.resources.billing.types.ListBillingPricesResponse; import com.schematic.api.resources.billing.types.ListBillingProductPricesResponse; import com.schematic.api.resources.billing.types.ListBillingProductsResponse; +import com.schematic.api.resources.billing.types.ListCompanyBillingProfilesResponse; import com.schematic.api.resources.billing.types.ListCouponsResponse; import com.schematic.api.resources.billing.types.ListCustomersWithSubscriptionsResponse; import com.schematic.api.resources.billing.types.ListInvoicesResponse; import com.schematic.api.resources.billing.types.ListMetersResponse; import com.schematic.api.resources.billing.types.ListPaymentMethodsResponse; +import com.schematic.api.resources.billing.types.UpdateCompanyBillingProfileResponse; import com.schematic.api.resources.billing.types.UpsertBillingCouponResponse; import com.schematic.api.resources.billing.types.UpsertBillingCustomerResponse; import com.schematic.api.resources.billing.types.UpsertBillingMeterResponse; @@ -346,6 +350,41 @@ public CompletableFuture countBillingProducts( return this.rawClient.countBillingProducts(request, requestOptions).thenApply(response -> response.body()); } + public CompletableFuture listCompanyBillingProfiles() { + return this.rawClient.listCompanyBillingProfiles().thenApply(response -> response.body()); + } + + public CompletableFuture listCompanyBillingProfiles( + RequestOptions requestOptions) { + return this.rawClient.listCompanyBillingProfiles(requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture listCompanyBillingProfiles( + ListCompanyBillingProfilesRequest request) { + return this.rawClient.listCompanyBillingProfiles(request).thenApply(response -> response.body()); + } + + public CompletableFuture listCompanyBillingProfiles( + ListCompanyBillingProfilesRequest request, RequestOptions requestOptions) { + return this.rawClient + .listCompanyBillingProfiles(request, requestOptions) + .thenApply(response -> response.body()); + } + + public CompletableFuture updateCompanyBillingProfile( + String billingProfileId, UpdateCompanyBillingProfileRequestBody request) { + return this.rawClient + .updateCompanyBillingProfile(billingProfileId, request) + .thenApply(response -> response.body()); + } + + public CompletableFuture updateCompanyBillingProfile( + String billingProfileId, UpdateCompanyBillingProfileRequestBody request, RequestOptions requestOptions) { + return this.rawClient + .updateCompanyBillingProfile(billingProfileId, request, requestOptions) + .thenApply(response -> response.body()); + } + public CompletableFuture upsertBillingSubscription( CreateBillingSubscriptionRequestBody request) { return this.rawClient.upsertBillingSubscription(request).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 f0aa3287..d0d59f63 100644 --- a/src/main/java/com/schematic/api/resources/billing/AsyncRawBillingClient.java +++ b/src/main/java/com/schematic/api/resources/billing/AsyncRawBillingClient.java @@ -31,11 +31,13 @@ import com.schematic.api.resources.billing.requests.ListBillingPricesRequest; import com.schematic.api.resources.billing.requests.ListBillingProductPricesRequest; import com.schematic.api.resources.billing.requests.ListBillingProductsRequest; +import com.schematic.api.resources.billing.requests.ListCompanyBillingProfilesRequest; import com.schematic.api.resources.billing.requests.ListCouponsRequest; import com.schematic.api.resources.billing.requests.ListCustomersWithSubscriptionsRequest; import com.schematic.api.resources.billing.requests.ListInvoicesRequest; import com.schematic.api.resources.billing.requests.ListMetersRequest; import com.schematic.api.resources.billing.requests.ListPaymentMethodsRequest; +import com.schematic.api.resources.billing.requests.UpdateCompanyBillingProfileRequestBody; import com.schematic.api.resources.billing.types.CountBillingProductsResponse; import com.schematic.api.resources.billing.types.CountCustomersResponse; import com.schematic.api.resources.billing.types.DeleteBillingCouponResponse; @@ -47,11 +49,13 @@ import com.schematic.api.resources.billing.types.ListBillingPricesResponse; import com.schematic.api.resources.billing.types.ListBillingProductPricesResponse; import com.schematic.api.resources.billing.types.ListBillingProductsResponse; +import com.schematic.api.resources.billing.types.ListCompanyBillingProfilesResponse; import com.schematic.api.resources.billing.types.ListCouponsResponse; import com.schematic.api.resources.billing.types.ListCustomersWithSubscriptionsResponse; import com.schematic.api.resources.billing.types.ListInvoicesResponse; import com.schematic.api.resources.billing.types.ListMetersResponse; import com.schematic.api.resources.billing.types.ListPaymentMethodsResponse; +import com.schematic.api.resources.billing.types.UpdateCompanyBillingProfileResponse; import com.schematic.api.resources.billing.types.UpsertBillingCouponResponse; import com.schematic.api.resources.billing.types.UpsertBillingCustomerResponse; import com.schematic.api.resources.billing.types.UpsertBillingMeterResponse; @@ -2835,6 +2839,248 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { return future; } + public CompletableFuture> + listCompanyBillingProfiles() { + return listCompanyBillingProfiles( + ListCompanyBillingProfilesRequest.builder().build()); + } + + public CompletableFuture> listCompanyBillingProfiles( + RequestOptions requestOptions) { + return listCompanyBillingProfiles( + ListCompanyBillingProfilesRequest.builder().build(), requestOptions); + } + + public CompletableFuture> listCompanyBillingProfiles( + ListCompanyBillingProfilesRequest request) { + return listCompanyBillingProfiles(request, null); + } + + public CompletableFuture> listCompanyBillingProfiles( + ListCompanyBillingProfilesRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/profiles"); + if (request.getCompanyId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "company_id", request.getCompanyId().get(), false); + } + if (request.getIsDefault().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_default", request.getIsDefault().get(), false); + } + if (request.getProviderType().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "provider_type", request.getProviderType().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } + 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, ListCompanyBillingProfilesResponse.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 (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); + } 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> + updateCompanyBillingProfile(String billingProfileId, UpdateCompanyBillingProfileRequestBody request) { + return updateCompanyBillingProfile(billingProfileId, request, null); + } + + public CompletableFuture> + updateCompanyBillingProfile( + String billingProfileId, + UpdateCompanyBillingProfileRequestBody request, + RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/profiles") + .addPathSegment(billingProfileId); + 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); + } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } + 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, UpdateCompanyBillingProfileResponse.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 (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); + } 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> upsertBillingSubscription( CreateBillingSubscriptionRequestBody request) { return upsertBillingSubscription(request, null); 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 97fc2198..6a53e1d4 100644 --- a/src/main/java/com/schematic/api/resources/billing/BillingClient.java +++ b/src/main/java/com/schematic/api/resources/billing/BillingClient.java @@ -18,11 +18,13 @@ import com.schematic.api.resources.billing.requests.ListBillingPricesRequest; import com.schematic.api.resources.billing.requests.ListBillingProductPricesRequest; import com.schematic.api.resources.billing.requests.ListBillingProductsRequest; +import com.schematic.api.resources.billing.requests.ListCompanyBillingProfilesRequest; import com.schematic.api.resources.billing.requests.ListCouponsRequest; import com.schematic.api.resources.billing.requests.ListCustomersWithSubscriptionsRequest; import com.schematic.api.resources.billing.requests.ListInvoicesRequest; import com.schematic.api.resources.billing.requests.ListMetersRequest; import com.schematic.api.resources.billing.requests.ListPaymentMethodsRequest; +import com.schematic.api.resources.billing.requests.UpdateCompanyBillingProfileRequestBody; import com.schematic.api.resources.billing.types.CountBillingProductsResponse; import com.schematic.api.resources.billing.types.CountCustomersResponse; import com.schematic.api.resources.billing.types.DeleteBillingCouponResponse; @@ -34,11 +36,13 @@ import com.schematic.api.resources.billing.types.ListBillingPricesResponse; import com.schematic.api.resources.billing.types.ListBillingProductPricesResponse; import com.schematic.api.resources.billing.types.ListBillingProductsResponse; +import com.schematic.api.resources.billing.types.ListCompanyBillingProfilesResponse; import com.schematic.api.resources.billing.types.ListCouponsResponse; import com.schematic.api.resources.billing.types.ListCustomersWithSubscriptionsResponse; import com.schematic.api.resources.billing.types.ListInvoicesResponse; import com.schematic.api.resources.billing.types.ListMetersResponse; import com.schematic.api.resources.billing.types.ListPaymentMethodsResponse; +import com.schematic.api.resources.billing.types.UpdateCompanyBillingProfileResponse; import com.schematic.api.resources.billing.types.UpsertBillingCouponResponse; import com.schematic.api.resources.billing.types.UpsertBillingCustomerResponse; import com.schematic.api.resources.billing.types.UpsertBillingMeterResponse; @@ -331,6 +335,39 @@ public CountBillingProductsResponse countBillingProducts( return this.rawClient.countBillingProducts(request, requestOptions).body(); } + public ListCompanyBillingProfilesResponse listCompanyBillingProfiles() { + return this.rawClient.listCompanyBillingProfiles().body(); + } + + public ListCompanyBillingProfilesResponse listCompanyBillingProfiles(RequestOptions requestOptions) { + return this.rawClient.listCompanyBillingProfiles(requestOptions).body(); + } + + public ListCompanyBillingProfilesResponse listCompanyBillingProfiles(ListCompanyBillingProfilesRequest request) { + return this.rawClient.listCompanyBillingProfiles(request).body(); + } + + public ListCompanyBillingProfilesResponse listCompanyBillingProfiles( + ListCompanyBillingProfilesRequest request, RequestOptions requestOptions) { + return this.rawClient + .listCompanyBillingProfiles(request, requestOptions) + .body(); + } + + public UpdateCompanyBillingProfileResponse updateCompanyBillingProfile( + String billingProfileId, UpdateCompanyBillingProfileRequestBody request) { + return this.rawClient + .updateCompanyBillingProfile(billingProfileId, request) + .body(); + } + + public UpdateCompanyBillingProfileResponse updateCompanyBillingProfile( + String billingProfileId, UpdateCompanyBillingProfileRequestBody request, RequestOptions requestOptions) { + return this.rawClient + .updateCompanyBillingProfile(billingProfileId, request, requestOptions) + .body(); + } + public UpsertBillingSubscriptionResponse upsertBillingSubscription(CreateBillingSubscriptionRequestBody request) { return this.rawClient.upsertBillingSubscription(request).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 22e8a17b..5b46066a 100644 --- a/src/main/java/com/schematic/api/resources/billing/RawBillingClient.java +++ b/src/main/java/com/schematic/api/resources/billing/RawBillingClient.java @@ -31,11 +31,13 @@ import com.schematic.api.resources.billing.requests.ListBillingPricesRequest; import com.schematic.api.resources.billing.requests.ListBillingProductPricesRequest; import com.schematic.api.resources.billing.requests.ListBillingProductsRequest; +import com.schematic.api.resources.billing.requests.ListCompanyBillingProfilesRequest; import com.schematic.api.resources.billing.requests.ListCouponsRequest; import com.schematic.api.resources.billing.requests.ListCustomersWithSubscriptionsRequest; import com.schematic.api.resources.billing.requests.ListInvoicesRequest; import com.schematic.api.resources.billing.requests.ListMetersRequest; import com.schematic.api.resources.billing.requests.ListPaymentMethodsRequest; +import com.schematic.api.resources.billing.requests.UpdateCompanyBillingProfileRequestBody; import com.schematic.api.resources.billing.types.CountBillingProductsResponse; import com.schematic.api.resources.billing.types.CountCustomersResponse; import com.schematic.api.resources.billing.types.DeleteBillingCouponResponse; @@ -47,11 +49,13 @@ import com.schematic.api.resources.billing.types.ListBillingPricesResponse; import com.schematic.api.resources.billing.types.ListBillingProductPricesResponse; import com.schematic.api.resources.billing.types.ListBillingProductsResponse; +import com.schematic.api.resources.billing.types.ListCompanyBillingProfilesResponse; import com.schematic.api.resources.billing.types.ListCouponsResponse; import com.schematic.api.resources.billing.types.ListCustomersWithSubscriptionsResponse; import com.schematic.api.resources.billing.types.ListInvoicesResponse; import com.schematic.api.resources.billing.types.ListMetersResponse; import com.schematic.api.resources.billing.types.ListPaymentMethodsResponse; +import com.schematic.api.resources.billing.types.UpdateCompanyBillingProfileResponse; import com.schematic.api.resources.billing.types.UpsertBillingCouponResponse; import com.schematic.api.resources.billing.types.UpsertBillingCustomerResponse; import com.schematic.api.resources.billing.types.UpsertBillingMeterResponse; @@ -2237,6 +2241,194 @@ public BaseSchematicHttpResponse countBillingProdu } } + public BaseSchematicHttpResponse listCompanyBillingProfiles() { + return listCompanyBillingProfiles( + ListCompanyBillingProfilesRequest.builder().build()); + } + + public BaseSchematicHttpResponse listCompanyBillingProfiles( + RequestOptions requestOptions) { + return listCompanyBillingProfiles( + ListCompanyBillingProfilesRequest.builder().build(), requestOptions); + } + + public BaseSchematicHttpResponse listCompanyBillingProfiles( + ListCompanyBillingProfilesRequest request) { + return listCompanyBillingProfiles(request, null); + } + + public BaseSchematicHttpResponse listCompanyBillingProfiles( + ListCompanyBillingProfilesRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/profiles"); + if (request.getCompanyId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "company_id", request.getCompanyId().get(), false); + } + if (request.getIsDefault().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_default", request.getIsDefault().get(), false); + } + if (request.getProviderType().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "provider_type", request.getProviderType().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } + 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, ListCompanyBillingProfilesResponse.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 (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse updateCompanyBillingProfile( + String billingProfileId, UpdateCompanyBillingProfileRequestBody request) { + return updateCompanyBillingProfile(billingProfileId, request, null); + } + + public BaseSchematicHttpResponse updateCompanyBillingProfile( + String billingProfileId, UpdateCompanyBillingProfileRequestBody request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/profiles") + .addPathSegment(billingProfileId); + 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); + } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } + 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, UpdateCompanyBillingProfileResponse.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 (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + public BaseSchematicHttpResponse upsertBillingSubscription( CreateBillingSubscriptionRequestBody request) { return upsertBillingSubscription(request, null); diff --git a/src/main/java/com/schematic/api/resources/billing/requests/ListCompanyBillingProfilesRequest.java b/src/main/java/com/schematic/api/resources/billing/requests/ListCompanyBillingProfilesRequest.java new file mode 100644 index 00000000..c277b075 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/billing/requests/ListCompanyBillingProfilesRequest.java @@ -0,0 +1,217 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.billing.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 com.schematic.api.types.BillingProviderType; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ListCompanyBillingProfilesRequest.Builder.class) +public final class ListCompanyBillingProfilesRequest { + private final Optional companyId; + + private final Optional isDefault; + + private final Optional providerType; + + private final Optional limit; + + private final Optional offset; + + private final Map additionalProperties; + + private ListCompanyBillingProfilesRequest( + Optional companyId, + Optional isDefault, + Optional providerType, + Optional limit, + Optional offset, + Map additionalProperties) { + this.companyId = companyId; + this.isDefault = isDefault; + this.providerType = providerType; + this.limit = limit; + this.offset = offset; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("company_id") + public Optional getCompanyId() { + return companyId; + } + + @JsonProperty("is_default") + public Optional getIsDefault() { + return isDefault; + } + + @JsonProperty("provider_type") + public Optional getProviderType() { + return providerType; + } + + /** + * @return Page limit (default 100) + */ + @JsonProperty("limit") + public Optional getLimit() { + return limit; + } + + /** + * @return Page offset (default 0) + */ + @JsonProperty("offset") + public Optional getOffset() { + return offset; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ListCompanyBillingProfilesRequest && equalTo((ListCompanyBillingProfilesRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ListCompanyBillingProfilesRequest other) { + return companyId.equals(other.companyId) + && isDefault.equals(other.isDefault) + && providerType.equals(other.providerType) + && limit.equals(other.limit) + && offset.equals(other.offset); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.companyId, this.isDefault, this.providerType, this.limit, this.offset); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional companyId = Optional.empty(); + + private Optional isDefault = Optional.empty(); + + private Optional providerType = Optional.empty(); + + private Optional limit = Optional.empty(); + + private Optional offset = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ListCompanyBillingProfilesRequest other) { + companyId(other.getCompanyId()); + isDefault(other.getIsDefault()); + providerType(other.getProviderType()); + limit(other.getLimit()); + offset(other.getOffset()); + return this; + } + + @JsonSetter(value = "company_id", nulls = Nulls.SKIP) + public Builder companyId(Optional companyId) { + this.companyId = companyId; + return this; + } + + public Builder companyId(String companyId) { + this.companyId = Optional.ofNullable(companyId); + return this; + } + + @JsonSetter(value = "is_default", nulls = Nulls.SKIP) + public Builder isDefault(Optional isDefault) { + this.isDefault = isDefault; + return this; + } + + public Builder isDefault(Boolean isDefault) { + this.isDefault = Optional.ofNullable(isDefault); + return this; + } + + @JsonSetter(value = "provider_type", nulls = Nulls.SKIP) + public Builder providerType(Optional providerType) { + this.providerType = providerType; + return this; + } + + public Builder providerType(BillingProviderType providerType) { + this.providerType = Optional.ofNullable(providerType); + return this; + } + + /** + *

Page limit (default 100)

+ */ + @JsonSetter(value = "limit", nulls = Nulls.SKIP) + public Builder limit(Optional limit) { + this.limit = limit; + return this; + } + + public Builder limit(Long limit) { + this.limit = Optional.ofNullable(limit); + return this; + } + + /** + *

Page offset (default 0)

+ */ + @JsonSetter(value = "offset", nulls = Nulls.SKIP) + public Builder offset(Optional offset) { + this.offset = offset; + return this; + } + + public Builder offset(Long offset) { + this.offset = Optional.ofNullable(offset); + return this; + } + + public ListCompanyBillingProfilesRequest build() { + return new ListCompanyBillingProfilesRequest( + companyId, isDefault, providerType, limit, offset, additionalProperties); + } + + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + } +} diff --git a/src/main/java/com/schematic/api/resources/billing/requests/UpdateCompanyBillingProfileRequestBody.java b/src/main/java/com/schematic/api/resources/billing/requests/UpdateCompanyBillingProfileRequestBody.java new file mode 100644 index 00000000..fdc5ab23 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/billing/requests/UpdateCompanyBillingProfileRequestBody.java @@ -0,0 +1,288 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.billing.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 com.schematic.api.types.BillingCollectionMethod; +import com.schematic.api.types.ProrationBehavior; +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 = UpdateCompanyBillingProfileRequestBody.Builder.class) +public final class UpdateCompanyBillingProfileRequestBody { + private final BillingCollectionMethod collectionMethod; + + private final Optional daysUntilDue; + + private final Optional isDefault; + + private final Optional name; + + private final Optional paymentMethodId; + + private final Optional prorationBehavior; + + private final Map additionalProperties; + + private UpdateCompanyBillingProfileRequestBody( + BillingCollectionMethod collectionMethod, + Optional daysUntilDue, + Optional isDefault, + Optional name, + Optional paymentMethodId, + Optional prorationBehavior, + Map additionalProperties) { + this.collectionMethod = collectionMethod; + this.daysUntilDue = daysUntilDue; + this.isDefault = isDefault; + this.name = name; + this.paymentMethodId = paymentMethodId; + this.prorationBehavior = prorationBehavior; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("collection_method") + public BillingCollectionMethod getCollectionMethod() { + return collectionMethod; + } + + @JsonProperty("days_until_due") + public Optional getDaysUntilDue() { + return daysUntilDue; + } + + @JsonProperty("is_default") + public Optional getIsDefault() { + return isDefault; + } + + @JsonProperty("name") + public Optional getName() { + return name; + } + + @JsonProperty("payment_method_id") + public Optional getPaymentMethodId() { + return paymentMethodId; + } + + @JsonProperty("proration_behavior") + public Optional getProrationBehavior() { + return prorationBehavior; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof UpdateCompanyBillingProfileRequestBody + && equalTo((UpdateCompanyBillingProfileRequestBody) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(UpdateCompanyBillingProfileRequestBody other) { + return collectionMethod.equals(other.collectionMethod) + && daysUntilDue.equals(other.daysUntilDue) + && isDefault.equals(other.isDefault) + && name.equals(other.name) + && paymentMethodId.equals(other.paymentMethodId) + && prorationBehavior.equals(other.prorationBehavior); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.collectionMethod, + this.daysUntilDue, + this.isDefault, + this.name, + this.paymentMethodId, + this.prorationBehavior); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static CollectionMethodStage builder() { + return new Builder(); + } + + public interface CollectionMethodStage { + _FinalStage collectionMethod(@NotNull BillingCollectionMethod collectionMethod); + + Builder from(UpdateCompanyBillingProfileRequestBody other); + } + + public interface _FinalStage { + UpdateCompanyBillingProfileRequestBody build(); + + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); + + _FinalStage daysUntilDue(Optional daysUntilDue); + + _FinalStage daysUntilDue(Long daysUntilDue); + + _FinalStage isDefault(Optional isDefault); + + _FinalStage isDefault(Boolean isDefault); + + _FinalStage name(Optional name); + + _FinalStage name(String name); + + _FinalStage paymentMethodId(Optional paymentMethodId); + + _FinalStage paymentMethodId(String paymentMethodId); + + _FinalStage prorationBehavior(Optional prorationBehavior); + + _FinalStage prorationBehavior(ProrationBehavior prorationBehavior); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements CollectionMethodStage, _FinalStage { + private BillingCollectionMethod collectionMethod; + + private Optional prorationBehavior = Optional.empty(); + + private Optional paymentMethodId = Optional.empty(); + + private Optional name = Optional.empty(); + + private Optional isDefault = Optional.empty(); + + private Optional daysUntilDue = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(UpdateCompanyBillingProfileRequestBody other) { + collectionMethod(other.getCollectionMethod()); + daysUntilDue(other.getDaysUntilDue()); + isDefault(other.getIsDefault()); + name(other.getName()); + paymentMethodId(other.getPaymentMethodId()); + prorationBehavior(other.getProrationBehavior()); + return this; + } + + @java.lang.Override + @JsonSetter("collection_method") + public _FinalStage collectionMethod(@NotNull BillingCollectionMethod collectionMethod) { + this.collectionMethod = Objects.requireNonNull(collectionMethod, "collectionMethod must not be null"); + return this; + } + + @java.lang.Override + public _FinalStage prorationBehavior(ProrationBehavior prorationBehavior) { + this.prorationBehavior = Optional.ofNullable(prorationBehavior); + return this; + } + + @java.lang.Override + @JsonSetter(value = "proration_behavior", nulls = Nulls.SKIP) + public _FinalStage prorationBehavior(Optional prorationBehavior) { + this.prorationBehavior = prorationBehavior; + return this; + } + + @java.lang.Override + public _FinalStage paymentMethodId(String paymentMethodId) { + this.paymentMethodId = Optional.ofNullable(paymentMethodId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "payment_method_id", nulls = Nulls.SKIP) + public _FinalStage paymentMethodId(Optional paymentMethodId) { + this.paymentMethodId = paymentMethodId; + return this; + } + + @java.lang.Override + public _FinalStage name(String name) { + this.name = Optional.ofNullable(name); + return this; + } + + @java.lang.Override + @JsonSetter(value = "name", nulls = Nulls.SKIP) + public _FinalStage name(Optional name) { + this.name = name; + return this; + } + + @java.lang.Override + public _FinalStage isDefault(Boolean isDefault) { + this.isDefault = Optional.ofNullable(isDefault); + return this; + } + + @java.lang.Override + @JsonSetter(value = "is_default", nulls = Nulls.SKIP) + public _FinalStage isDefault(Optional isDefault) { + this.isDefault = isDefault; + return this; + } + + @java.lang.Override + public _FinalStage daysUntilDue(Long daysUntilDue) { + this.daysUntilDue = Optional.ofNullable(daysUntilDue); + return this; + } + + @java.lang.Override + @JsonSetter(value = "days_until_due", nulls = Nulls.SKIP) + public _FinalStage daysUntilDue(Optional daysUntilDue) { + this.daysUntilDue = daysUntilDue; + return this; + } + + @java.lang.Override + public UpdateCompanyBillingProfileRequestBody build() { + return new UpdateCompanyBillingProfileRequestBody( + collectionMethod, + daysUntilDue, + isDefault, + name, + paymentMethodId, + prorationBehavior, + additionalProperties); + } + + @java.lang.Override + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + @java.lang.Override + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + } +} diff --git a/src/main/java/com/schematic/api/resources/billing/types/ListCompanyBillingProfilesParams.java b/src/main/java/com/schematic/api/resources/billing/types/ListCompanyBillingProfilesParams.java new file mode 100644 index 00000000..f8843574 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/billing/types/ListCompanyBillingProfilesParams.java @@ -0,0 +1,217 @@ +/** + * 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.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.types.BillingProviderType; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ListCompanyBillingProfilesParams.Builder.class) +public final class ListCompanyBillingProfilesParams { + private final Optional companyId; + + private final Optional isDefault; + + private final Optional limit; + + private final Optional offset; + + private final Optional providerType; + + private final Map additionalProperties; + + private ListCompanyBillingProfilesParams( + Optional companyId, + Optional isDefault, + Optional limit, + Optional offset, + Optional providerType, + Map additionalProperties) { + this.companyId = companyId; + this.isDefault = isDefault; + this.limit = limit; + this.offset = offset; + this.providerType = providerType; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("company_id") + public Optional getCompanyId() { + return companyId; + } + + @JsonProperty("is_default") + public Optional getIsDefault() { + return isDefault; + } + + /** + * @return Page limit (default 100) + */ + @JsonProperty("limit") + public Optional getLimit() { + return limit; + } + + /** + * @return Page offset (default 0) + */ + @JsonProperty("offset") + public Optional getOffset() { + return offset; + } + + @JsonProperty("provider_type") + public Optional getProviderType() { + return providerType; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ListCompanyBillingProfilesParams && equalTo((ListCompanyBillingProfilesParams) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ListCompanyBillingProfilesParams other) { + return companyId.equals(other.companyId) + && isDefault.equals(other.isDefault) + && limit.equals(other.limit) + && offset.equals(other.offset) + && providerType.equals(other.providerType); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.companyId, this.isDefault, this.limit, this.offset, this.providerType); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional companyId = Optional.empty(); + + private Optional isDefault = Optional.empty(); + + private Optional limit = Optional.empty(); + + private Optional offset = Optional.empty(); + + private Optional providerType = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ListCompanyBillingProfilesParams other) { + companyId(other.getCompanyId()); + isDefault(other.getIsDefault()); + limit(other.getLimit()); + offset(other.getOffset()); + providerType(other.getProviderType()); + return this; + } + + @JsonSetter(value = "company_id", nulls = Nulls.SKIP) + public Builder companyId(Optional companyId) { + this.companyId = companyId; + return this; + } + + public Builder companyId(String companyId) { + this.companyId = Optional.ofNullable(companyId); + return this; + } + + @JsonSetter(value = "is_default", nulls = Nulls.SKIP) + public Builder isDefault(Optional isDefault) { + this.isDefault = isDefault; + return this; + } + + public Builder isDefault(Boolean isDefault) { + this.isDefault = Optional.ofNullable(isDefault); + return this; + } + + /** + *

Page limit (default 100)

+ */ + @JsonSetter(value = "limit", nulls = Nulls.SKIP) + public Builder limit(Optional limit) { + this.limit = limit; + return this; + } + + public Builder limit(Long limit) { + this.limit = Optional.ofNullable(limit); + return this; + } + + /** + *

Page offset (default 0)

+ */ + @JsonSetter(value = "offset", nulls = Nulls.SKIP) + public Builder offset(Optional offset) { + this.offset = offset; + return this; + } + + public Builder offset(Long offset) { + this.offset = Optional.ofNullable(offset); + return this; + } + + @JsonSetter(value = "provider_type", nulls = Nulls.SKIP) + public Builder providerType(Optional providerType) { + this.providerType = providerType; + return this; + } + + public Builder providerType(BillingProviderType providerType) { + this.providerType = Optional.ofNullable(providerType); + return this; + } + + public ListCompanyBillingProfilesParams build() { + return new ListCompanyBillingProfilesParams( + companyId, isDefault, limit, offset, providerType, additionalProperties); + } + + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + } +} diff --git a/src/main/java/com/schematic/api/resources/billing/types/ListCompanyBillingProfilesResponse.java b/src/main/java/com/schematic/api/resources/billing/types/ListCompanyBillingProfilesResponse.java new file mode 100644 index 00000000..b287a100 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/billing/types/ListCompanyBillingProfilesResponse.java @@ -0,0 +1,177 @@ +/** + * 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.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.types.CompanyBillingProfileResponseData; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ListCompanyBillingProfilesResponse.Builder.class) +public final class ListCompanyBillingProfilesResponse { + private final List data; + + private final ListCompanyBillingProfilesParams params; + + private final Map additionalProperties; + + private ListCompanyBillingProfilesResponse( + List data, + ListCompanyBillingProfilesParams params, + Map additionalProperties) { + this.data = data; + this.params = params; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("data") + public List getData() { + return data; + } + + /** + * @return Input parameters + */ + @JsonProperty("params") + public ListCompanyBillingProfilesParams getParams() { + return params; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ListCompanyBillingProfilesResponse + && equalTo((ListCompanyBillingProfilesResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ListCompanyBillingProfilesResponse 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 ParamsStage builder() { + return new Builder(); + } + + public interface ParamsStage { + /** + *

Input parameters

+ */ + _FinalStage params(@NotNull ListCompanyBillingProfilesParams params); + + Builder from(ListCompanyBillingProfilesResponse other); + } + + public interface _FinalStage { + ListCompanyBillingProfilesResponse build(); + + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); + + _FinalStage data(List data); + + _FinalStage addData(CompanyBillingProfileResponseData data); + + _FinalStage addAllData(List data); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements ParamsStage, _FinalStage { + private ListCompanyBillingProfilesParams params; + + private List data = new ArrayList<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ListCompanyBillingProfilesResponse other) { + data(other.getData()); + params(other.getParams()); + return this; + } + + /** + *

Input parameters

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("params") + public _FinalStage params(@NotNull ListCompanyBillingProfilesParams params) { + this.params = Objects.requireNonNull(params, "params must not be null"); + return this; + } + + @java.lang.Override + public _FinalStage addAllData(List data) { + if (data != null) { + this.data.addAll(data); + } + return this; + } + + @java.lang.Override + public _FinalStage addData(CompanyBillingProfileResponseData data) { + this.data.add(data); + return this; + } + + @java.lang.Override + @JsonSetter(value = "data", nulls = Nulls.SKIP) + public _FinalStage data(List data) { + this.data.clear(); + if (data != null) { + this.data.addAll(data); + } + return this; + } + + @java.lang.Override + public ListCompanyBillingProfilesResponse build() { + return new ListCompanyBillingProfilesResponse(data, params, additionalProperties); + } + + @java.lang.Override + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + @java.lang.Override + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + } +} diff --git a/src/main/java/com/schematic/api/resources/billing/types/UpdateCompanyBillingProfileResponse.java b/src/main/java/com/schematic/api/resources/billing/types/UpdateCompanyBillingProfileResponse.java new file mode 100644 index 00000000..7aed8918 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/billing/types/UpdateCompanyBillingProfileResponse.java @@ -0,0 +1,184 @@ +/** + * 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.CompanyBillingProfileResponseData; +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 = UpdateCompanyBillingProfileResponse.Builder.class) +public final class UpdateCompanyBillingProfileResponse { + private final CompanyBillingProfileResponseData data; + + private final Map params; + + private final Map additionalProperties; + + private UpdateCompanyBillingProfileResponse( + CompanyBillingProfileResponseData data, + Map params, + Map additionalProperties) { + this.data = data; + this.params = params; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("data") + public CompanyBillingProfileResponseData 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 UpdateCompanyBillingProfileResponse + && equalTo((UpdateCompanyBillingProfileResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(UpdateCompanyBillingProfileResponse 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 CompanyBillingProfileResponseData data); + + Builder from(UpdateCompanyBillingProfileResponse other); + } + + public interface _FinalStage { + UpdateCompanyBillingProfileResponse 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 CompanyBillingProfileResponseData data; + + private Map params = new LinkedHashMap<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(UpdateCompanyBillingProfileResponse other) { + data(other.getData()); + params(other.getParams()); + return this; + } + + @java.lang.Override + @JsonSetter("data") + public _FinalStage data(@NotNull CompanyBillingProfileResponseData 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 UpdateCompanyBillingProfileResponse build() { + return new UpdateCompanyBillingProfileResponse(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 1ee266c3..a5bbc3ff 100644 --- a/src/main/java/com/schematic/api/resources/credits/AsyncCreditsClient.java +++ b/src/main/java/com/schematic/api/resources/credits/AsyncCreditsClient.java @@ -13,9 +13,11 @@ import com.schematic.api.resources.credits.requests.CountCompanyGrantsRequest; import com.schematic.api.resources.credits.requests.CountCreditBundlesRequest; import com.schematic.api.resources.credits.requests.CountCreditEventLedgerRequest; +import com.schematic.api.resources.credits.requests.CountCreditSpendPoliciesRequest; import com.schematic.api.resources.credits.requests.CreateBillingCreditRequestBody; import com.schematic.api.resources.credits.requests.CreateCompanyCreditGrant; import com.schematic.api.resources.credits.requests.CreateCreditBundleRequestBody; +import com.schematic.api.resources.credits.requests.CreateCreditSpendPolicyRequestBody; import com.schematic.api.resources.credits.requests.DeleteBillingPlanCreditGrantRequest; import com.schematic.api.resources.credits.requests.ExtendCreditLeaseRequestBody; import com.schematic.api.resources.credits.requests.ListBillingCreditsRequest; @@ -24,9 +26,11 @@ import com.schematic.api.resources.credits.requests.ListCompanyGrantsRequest; import com.schematic.api.resources.credits.requests.ListCreditBundlesRequest; import com.schematic.api.resources.credits.requests.ListCreditEventLedgerRequest; +import com.schematic.api.resources.credits.requests.ListCreditSpendPoliciesRequest; import com.schematic.api.resources.credits.requests.ListGrantsForCreditRequest; import com.schematic.api.resources.credits.requests.UpdateBillingCreditRequestBody; import com.schematic.api.resources.credits.requests.UpdateCreditBundleDetailsRequestBody; +import com.schematic.api.resources.credits.requests.UpdateCreditSpendPolicyRequestBody; import com.schematic.api.resources.credits.requests.ZeroOutGrantRequestBody; import com.schematic.api.resources.credits.types.AcquireCreditLeaseResponse; import com.schematic.api.resources.credits.types.CountBillingCreditsGrantsResponse; @@ -35,13 +39,17 @@ import com.schematic.api.resources.credits.types.CountCompanyGrantsResponse; import com.schematic.api.resources.credits.types.CountCreditBundlesResponse; import com.schematic.api.resources.credits.types.CountCreditEventLedgerResponse; +import com.schematic.api.resources.credits.types.CountCreditSpendPoliciesResponse; import com.schematic.api.resources.credits.types.CreateBillingCreditResponse; import com.schematic.api.resources.credits.types.CreateBillingPlanCreditGrantResponse; import com.schematic.api.resources.credits.types.CreateCreditBundleResponse; +import com.schematic.api.resources.credits.types.CreateCreditSpendPolicyResponse; import com.schematic.api.resources.credits.types.DeleteBillingPlanCreditGrantResponse; import com.schematic.api.resources.credits.types.DeleteCreditBundleResponse; +import com.schematic.api.resources.credits.types.DeleteCreditSpendPolicyResponse; import com.schematic.api.resources.credits.types.ExtendCreditLeaseResponse; import com.schematic.api.resources.credits.types.GetCreditBundleResponse; +import com.schematic.api.resources.credits.types.GetCreditSpendPolicyResponse; import com.schematic.api.resources.credits.types.GetSingleBillingCreditResponse; import com.schematic.api.resources.credits.types.GetSingleBillingPlanCreditGrantResponse; import com.schematic.api.resources.credits.types.GrantBillingCreditsToCompanyResponse; @@ -51,12 +59,14 @@ import com.schematic.api.resources.credits.types.ListCompanyGrantsResponse; import com.schematic.api.resources.credits.types.ListCreditBundlesResponse; import com.schematic.api.resources.credits.types.ListCreditEventLedgerResponse; +import com.schematic.api.resources.credits.types.ListCreditSpendPoliciesResponse; 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; import com.schematic.api.resources.credits.types.UpdateCreditBundleDetailsResponse; +import com.schematic.api.resources.credits.types.UpdateCreditSpendPolicyResponse; import com.schematic.api.resources.credits.types.ZeroOutGrantResponse; import com.schematic.api.types.CreateBillingPlanCreditGrantRequestBody; import com.schematic.api.types.UpdateBillingPlanCreditGrantRequestBody; @@ -452,6 +462,97 @@ public CompletableFuture countBillingPlanC .thenApply(response -> response.body()); } + public CompletableFuture listCreditSpendPolicies() { + return this.rawClient.listCreditSpendPolicies().thenApply(response -> response.body()); + } + + public CompletableFuture listCreditSpendPolicies(RequestOptions requestOptions) { + return this.rawClient.listCreditSpendPolicies(requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture listCreditSpendPolicies( + ListCreditSpendPoliciesRequest request) { + return this.rawClient.listCreditSpendPolicies(request).thenApply(response -> response.body()); + } + + public CompletableFuture listCreditSpendPolicies( + ListCreditSpendPoliciesRequest request, RequestOptions requestOptions) { + return this.rawClient.listCreditSpendPolicies(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture createCreditSpendPolicy( + CreateCreditSpendPolicyRequestBody request) { + return this.rawClient.createCreditSpendPolicy(request).thenApply(response -> response.body()); + } + + public CompletableFuture createCreditSpendPolicy( + CreateCreditSpendPolicyRequestBody request, RequestOptions requestOptions) { + return this.rawClient.createCreditSpendPolicy(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture getCreditSpendPolicy(String spendPolicyId) { + return this.rawClient.getCreditSpendPolicy(spendPolicyId).thenApply(response -> response.body()); + } + + public CompletableFuture getCreditSpendPolicy( + String spendPolicyId, RequestOptions requestOptions) { + return this.rawClient + .getCreditSpendPolicy(spendPolicyId, requestOptions) + .thenApply(response -> response.body()); + } + + public CompletableFuture updateCreditSpendPolicy(String spendPolicyId) { + return this.rawClient.updateCreditSpendPolicy(spendPolicyId).thenApply(response -> response.body()); + } + + public CompletableFuture updateCreditSpendPolicy( + String spendPolicyId, RequestOptions requestOptions) { + return this.rawClient + .updateCreditSpendPolicy(spendPolicyId, requestOptions) + .thenApply(response -> response.body()); + } + + public CompletableFuture updateCreditSpendPolicy( + String spendPolicyId, UpdateCreditSpendPolicyRequestBody request) { + return this.rawClient.updateCreditSpendPolicy(spendPolicyId, request).thenApply(response -> response.body()); + } + + public CompletableFuture updateCreditSpendPolicy( + String spendPolicyId, UpdateCreditSpendPolicyRequestBody request, RequestOptions requestOptions) { + return this.rawClient + .updateCreditSpendPolicy(spendPolicyId, request, requestOptions) + .thenApply(response -> response.body()); + } + + public CompletableFuture deleteCreditSpendPolicy(String spendPolicyId) { + return this.rawClient.deleteCreditSpendPolicy(spendPolicyId).thenApply(response -> response.body()); + } + + public CompletableFuture deleteCreditSpendPolicy( + String spendPolicyId, RequestOptions requestOptions) { + return this.rawClient + .deleteCreditSpendPolicy(spendPolicyId, requestOptions) + .thenApply(response -> response.body()); + } + + public CompletableFuture countCreditSpendPolicies() { + return this.rawClient.countCreditSpendPolicies().thenApply(response -> response.body()); + } + + public CompletableFuture countCreditSpendPolicies(RequestOptions requestOptions) { + return this.rawClient.countCreditSpendPolicies(requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture countCreditSpendPolicies( + CountCreditSpendPoliciesRequest request) { + return this.rawClient.countCreditSpendPolicies(request).thenApply(response -> response.body()); + } + + public CompletableFuture countCreditSpendPolicies( + CountCreditSpendPoliciesRequest request, RequestOptions requestOptions) { + return this.rawClient.countCreditSpendPolicies(request, requestOptions).thenApply(response -> response.body()); + } + public CompletableFuture listCreditEventLedger( ListCreditEventLedgerRequest request) { return this.rawClient.listCreditEventLedger(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 3b6fc3c8..cf7a0c8a 100644 --- a/src/main/java/com/schematic/api/resources/credits/AsyncRawCreditsClient.java +++ b/src/main/java/com/schematic/api/resources/credits/AsyncRawCreditsClient.java @@ -18,6 +18,7 @@ import com.schematic.api.errors.ForbiddenError; import com.schematic.api.errors.InternalServerError; import com.schematic.api.errors.NotFoundError; +import com.schematic.api.errors.PaymentRequiredError; import com.schematic.api.errors.UnauthorizedError; import com.schematic.api.resources.credits.requests.AcquireCreditLeaseRequestBody; import com.schematic.api.resources.credits.requests.CountBillingCreditsGrantsRequest; @@ -26,9 +27,11 @@ import com.schematic.api.resources.credits.requests.CountCompanyGrantsRequest; import com.schematic.api.resources.credits.requests.CountCreditBundlesRequest; import com.schematic.api.resources.credits.requests.CountCreditEventLedgerRequest; +import com.schematic.api.resources.credits.requests.CountCreditSpendPoliciesRequest; import com.schematic.api.resources.credits.requests.CreateBillingCreditRequestBody; import com.schematic.api.resources.credits.requests.CreateCompanyCreditGrant; import com.schematic.api.resources.credits.requests.CreateCreditBundleRequestBody; +import com.schematic.api.resources.credits.requests.CreateCreditSpendPolicyRequestBody; import com.schematic.api.resources.credits.requests.DeleteBillingPlanCreditGrantRequest; import com.schematic.api.resources.credits.requests.ExtendCreditLeaseRequestBody; import com.schematic.api.resources.credits.requests.ListBillingCreditsRequest; @@ -37,9 +40,11 @@ import com.schematic.api.resources.credits.requests.ListCompanyGrantsRequest; import com.schematic.api.resources.credits.requests.ListCreditBundlesRequest; import com.schematic.api.resources.credits.requests.ListCreditEventLedgerRequest; +import com.schematic.api.resources.credits.requests.ListCreditSpendPoliciesRequest; import com.schematic.api.resources.credits.requests.ListGrantsForCreditRequest; import com.schematic.api.resources.credits.requests.UpdateBillingCreditRequestBody; import com.schematic.api.resources.credits.requests.UpdateCreditBundleDetailsRequestBody; +import com.schematic.api.resources.credits.requests.UpdateCreditSpendPolicyRequestBody; import com.schematic.api.resources.credits.requests.ZeroOutGrantRequestBody; import com.schematic.api.resources.credits.types.AcquireCreditLeaseResponse; import com.schematic.api.resources.credits.types.CountBillingCreditsGrantsResponse; @@ -48,13 +53,17 @@ import com.schematic.api.resources.credits.types.CountCompanyGrantsResponse; import com.schematic.api.resources.credits.types.CountCreditBundlesResponse; import com.schematic.api.resources.credits.types.CountCreditEventLedgerResponse; +import com.schematic.api.resources.credits.types.CountCreditSpendPoliciesResponse; import com.schematic.api.resources.credits.types.CreateBillingCreditResponse; import com.schematic.api.resources.credits.types.CreateBillingPlanCreditGrantResponse; import com.schematic.api.resources.credits.types.CreateCreditBundleResponse; +import com.schematic.api.resources.credits.types.CreateCreditSpendPolicyResponse; import com.schematic.api.resources.credits.types.DeleteBillingPlanCreditGrantResponse; import com.schematic.api.resources.credits.types.DeleteCreditBundleResponse; +import com.schematic.api.resources.credits.types.DeleteCreditSpendPolicyResponse; import com.schematic.api.resources.credits.types.ExtendCreditLeaseResponse; import com.schematic.api.resources.credits.types.GetCreditBundleResponse; +import com.schematic.api.resources.credits.types.GetCreditSpendPolicyResponse; import com.schematic.api.resources.credits.types.GetSingleBillingCreditResponse; import com.schematic.api.resources.credits.types.GetSingleBillingPlanCreditGrantResponse; import com.schematic.api.resources.credits.types.GrantBillingCreditsToCompanyResponse; @@ -64,12 +73,14 @@ import com.schematic.api.resources.credits.types.ListCompanyGrantsResponse; import com.schematic.api.resources.credits.types.ListCreditBundlesResponse; import com.schematic.api.resources.credits.types.ListCreditEventLedgerResponse; +import com.schematic.api.resources.credits.types.ListCreditSpendPoliciesResponse; 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; import com.schematic.api.resources.credits.types.UpdateCreditBundleDetailsResponse; +import com.schematic.api.resources.credits.types.UpdateCreditSpendPolicyResponse; import com.schematic.api.resources.credits.types.ZeroOutGrantResponse; import com.schematic.api.types.ApiError; import com.schematic.api.types.CreateBillingPlanCreditGrantRequestBody; @@ -2276,6 +2287,11 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response)); return; + case 402: + future.completeExceptionally(new PaymentRequiredError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; case 403: future.completeExceptionally(new ForbiddenError( ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), @@ -2384,6 +2400,11 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response)); return; + case 402: + future.completeExceptionally(new PaymentRequiredError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; case 403: future.completeExceptionally(new ForbiddenError( ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), @@ -3246,6 +3267,701 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { return future; } + public CompletableFuture> listCreditSpendPolicies() { + return listCreditSpendPolicies(ListCreditSpendPoliciesRequest.builder().build()); + } + + public CompletableFuture> listCreditSpendPolicies( + RequestOptions requestOptions) { + return listCreditSpendPolicies(ListCreditSpendPoliciesRequest.builder().build(), requestOptions); + } + + public CompletableFuture> listCreditSpendPolicies( + ListCreditSpendPoliciesRequest request) { + return listCreditSpendPolicies(request, null); + } + + public CompletableFuture> listCreditSpendPolicies( + ListCreditSpendPoliciesRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/credits/spend-policies"); + if (request.getBillingCreditId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "billing_credit_id", request.getBillingCreditId().get(), false); + } + if (request.getCompanyId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "company_id", request.getCompanyId().get(), false); + } + if (request.getScopeType().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "scope_type", request.getScopeType().get(), false); + } + if (request.getUserId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "user_id", request.getUserId().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + if (request.getUserIds().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "user_ids", request.getUserIds().get(), true); + } + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } + 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, ListCreditSpendPoliciesResponse.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 (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); + } 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> createCreditSpendPolicy( + CreateCreditSpendPolicyRequestBody request) { + return createCreditSpendPolicy(request, null); + } + + public CompletableFuture> createCreditSpendPolicy( + CreateCreditSpendPolicyRequestBody request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/credits/spend-policies"); + 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); + } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } + 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, CreateCreditSpendPolicyResponse.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 (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); + } 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> getCreditSpendPolicy( + String spendPolicyId) { + return getCreditSpendPolicy(spendPolicyId, null); + } + + public CompletableFuture> getCreditSpendPolicy( + String spendPolicyId, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/credits/spend-policies") + .addPathSegment(spendPolicyId); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl.build()) + .method("GET", 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); + } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } + 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, GetCreditSpendPolicyResponse.class), + response)); + return; + } + try { + switch (response.code()) { + 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 (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); + } 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> updateCreditSpendPolicy( + String spendPolicyId) { + return updateCreditSpendPolicy( + spendPolicyId, UpdateCreditSpendPolicyRequestBody.builder().build()); + } + + public CompletableFuture> updateCreditSpendPolicy( + String spendPolicyId, RequestOptions requestOptions) { + return updateCreditSpendPolicy( + spendPolicyId, UpdateCreditSpendPolicyRequestBody.builder().build(), requestOptions); + } + + public CompletableFuture> updateCreditSpendPolicy( + String spendPolicyId, UpdateCreditSpendPolicyRequestBody request) { + return updateCreditSpendPolicy(spendPolicyId, request, null); + } + + public CompletableFuture> updateCreditSpendPolicy( + String spendPolicyId, UpdateCreditSpendPolicyRequestBody request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/credits/spend-policies") + .addPathSegment(spendPolicyId); + 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); + } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } + 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, UpdateCreditSpendPolicyResponse.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 (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); + } 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> deleteCreditSpendPolicy( + String spendPolicyId) { + return deleteCreditSpendPolicy(spendPolicyId, null); + } + + public CompletableFuture> deleteCreditSpendPolicy( + String spendPolicyId, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/credits/spend-policies") + .addPathSegment(spendPolicyId); + 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); + } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } + 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, DeleteCreditSpendPolicyResponse.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 (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); + } 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> countCreditSpendPolicies() { + return countCreditSpendPolicies( + CountCreditSpendPoliciesRequest.builder().build()); + } + + public CompletableFuture> countCreditSpendPolicies( + RequestOptions requestOptions) { + return countCreditSpendPolicies( + CountCreditSpendPoliciesRequest.builder().build(), requestOptions); + } + + public CompletableFuture> countCreditSpendPolicies( + CountCreditSpendPoliciesRequest request) { + return countCreditSpendPolicies(request, null); + } + + public CompletableFuture> countCreditSpendPolicies( + CountCreditSpendPoliciesRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/credits/spend-policies/count"); + if (request.getBillingCreditId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "billing_credit_id", request.getBillingCreditId().get(), false); + } + if (request.getCompanyId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "company_id", request.getCompanyId().get(), false); + } + if (request.getScopeType().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "scope_type", request.getScopeType().get(), false); + } + if (request.getUserId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "user_id", request.getUserId().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + if (request.getUserIds().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "user_ids", request.getUserIds().get(), true); + } + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } + 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, CountCreditSpendPoliciesResponse.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 (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); + } 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> listCreditEventLedger( ListCreditEventLedgerRequest request) { return listCreditEventLedger(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 8889d909..362749de 100644 --- a/src/main/java/com/schematic/api/resources/credits/CreditsClient.java +++ b/src/main/java/com/schematic/api/resources/credits/CreditsClient.java @@ -13,9 +13,11 @@ import com.schematic.api.resources.credits.requests.CountCompanyGrantsRequest; import com.schematic.api.resources.credits.requests.CountCreditBundlesRequest; import com.schematic.api.resources.credits.requests.CountCreditEventLedgerRequest; +import com.schematic.api.resources.credits.requests.CountCreditSpendPoliciesRequest; import com.schematic.api.resources.credits.requests.CreateBillingCreditRequestBody; import com.schematic.api.resources.credits.requests.CreateCompanyCreditGrant; import com.schematic.api.resources.credits.requests.CreateCreditBundleRequestBody; +import com.schematic.api.resources.credits.requests.CreateCreditSpendPolicyRequestBody; import com.schematic.api.resources.credits.requests.DeleteBillingPlanCreditGrantRequest; import com.schematic.api.resources.credits.requests.ExtendCreditLeaseRequestBody; import com.schematic.api.resources.credits.requests.ListBillingCreditsRequest; @@ -24,9 +26,11 @@ import com.schematic.api.resources.credits.requests.ListCompanyGrantsRequest; import com.schematic.api.resources.credits.requests.ListCreditBundlesRequest; import com.schematic.api.resources.credits.requests.ListCreditEventLedgerRequest; +import com.schematic.api.resources.credits.requests.ListCreditSpendPoliciesRequest; import com.schematic.api.resources.credits.requests.ListGrantsForCreditRequest; import com.schematic.api.resources.credits.requests.UpdateBillingCreditRequestBody; import com.schematic.api.resources.credits.requests.UpdateCreditBundleDetailsRequestBody; +import com.schematic.api.resources.credits.requests.UpdateCreditSpendPolicyRequestBody; import com.schematic.api.resources.credits.requests.ZeroOutGrantRequestBody; import com.schematic.api.resources.credits.types.AcquireCreditLeaseResponse; import com.schematic.api.resources.credits.types.CountBillingCreditsGrantsResponse; @@ -35,13 +39,17 @@ import com.schematic.api.resources.credits.types.CountCompanyGrantsResponse; import com.schematic.api.resources.credits.types.CountCreditBundlesResponse; import com.schematic.api.resources.credits.types.CountCreditEventLedgerResponse; +import com.schematic.api.resources.credits.types.CountCreditSpendPoliciesResponse; import com.schematic.api.resources.credits.types.CreateBillingCreditResponse; import com.schematic.api.resources.credits.types.CreateBillingPlanCreditGrantResponse; import com.schematic.api.resources.credits.types.CreateCreditBundleResponse; +import com.schematic.api.resources.credits.types.CreateCreditSpendPolicyResponse; import com.schematic.api.resources.credits.types.DeleteBillingPlanCreditGrantResponse; import com.schematic.api.resources.credits.types.DeleteCreditBundleResponse; +import com.schematic.api.resources.credits.types.DeleteCreditSpendPolicyResponse; import com.schematic.api.resources.credits.types.ExtendCreditLeaseResponse; import com.schematic.api.resources.credits.types.GetCreditBundleResponse; +import com.schematic.api.resources.credits.types.GetCreditSpendPolicyResponse; import com.schematic.api.resources.credits.types.GetSingleBillingCreditResponse; import com.schematic.api.resources.credits.types.GetSingleBillingPlanCreditGrantResponse; import com.schematic.api.resources.credits.types.GrantBillingCreditsToCompanyResponse; @@ -51,12 +59,14 @@ import com.schematic.api.resources.credits.types.ListCompanyGrantsResponse; import com.schematic.api.resources.credits.types.ListCreditBundlesResponse; import com.schematic.api.resources.credits.types.ListCreditEventLedgerResponse; +import com.schematic.api.resources.credits.types.ListCreditSpendPoliciesResponse; 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; import com.schematic.api.resources.credits.types.UpdateCreditBundleDetailsResponse; +import com.schematic.api.resources.credits.types.UpdateCreditSpendPolicyResponse; import com.schematic.api.resources.credits.types.ZeroOutGrantResponse; import com.schematic.api.types.CreateBillingPlanCreditGrantRequestBody; import com.schematic.api.types.UpdateBillingPlanCreditGrantRequestBody; @@ -437,6 +447,93 @@ public CountBillingPlanCreditGrantsResponse countBillingPlanCreditGrants( .body(); } + public ListCreditSpendPoliciesResponse listCreditSpendPolicies() { + return this.rawClient.listCreditSpendPolicies().body(); + } + + public ListCreditSpendPoliciesResponse listCreditSpendPolicies(RequestOptions requestOptions) { + return this.rawClient.listCreditSpendPolicies(requestOptions).body(); + } + + public ListCreditSpendPoliciesResponse listCreditSpendPolicies(ListCreditSpendPoliciesRequest request) { + return this.rawClient.listCreditSpendPolicies(request).body(); + } + + public ListCreditSpendPoliciesResponse listCreditSpendPolicies( + ListCreditSpendPoliciesRequest request, RequestOptions requestOptions) { + return this.rawClient.listCreditSpendPolicies(request, requestOptions).body(); + } + + public CreateCreditSpendPolicyResponse createCreditSpendPolicy(CreateCreditSpendPolicyRequestBody request) { + return this.rawClient.createCreditSpendPolicy(request).body(); + } + + public CreateCreditSpendPolicyResponse createCreditSpendPolicy( + CreateCreditSpendPolicyRequestBody request, RequestOptions requestOptions) { + return this.rawClient.createCreditSpendPolicy(request, requestOptions).body(); + } + + public GetCreditSpendPolicyResponse getCreditSpendPolicy(String spendPolicyId) { + return this.rawClient.getCreditSpendPolicy(spendPolicyId).body(); + } + + public GetCreditSpendPolicyResponse getCreditSpendPolicy(String spendPolicyId, RequestOptions requestOptions) { + return this.rawClient + .getCreditSpendPolicy(spendPolicyId, requestOptions) + .body(); + } + + public UpdateCreditSpendPolicyResponse updateCreditSpendPolicy(String spendPolicyId) { + return this.rawClient.updateCreditSpendPolicy(spendPolicyId).body(); + } + + public UpdateCreditSpendPolicyResponse updateCreditSpendPolicy( + String spendPolicyId, RequestOptions requestOptions) { + return this.rawClient + .updateCreditSpendPolicy(spendPolicyId, requestOptions) + .body(); + } + + public UpdateCreditSpendPolicyResponse updateCreditSpendPolicy( + String spendPolicyId, UpdateCreditSpendPolicyRequestBody request) { + return this.rawClient.updateCreditSpendPolicy(spendPolicyId, request).body(); + } + + public UpdateCreditSpendPolicyResponse updateCreditSpendPolicy( + String spendPolicyId, UpdateCreditSpendPolicyRequestBody request, RequestOptions requestOptions) { + return this.rawClient + .updateCreditSpendPolicy(spendPolicyId, request, requestOptions) + .body(); + } + + public DeleteCreditSpendPolicyResponse deleteCreditSpendPolicy(String spendPolicyId) { + return this.rawClient.deleteCreditSpendPolicy(spendPolicyId).body(); + } + + public DeleteCreditSpendPolicyResponse deleteCreditSpendPolicy( + String spendPolicyId, RequestOptions requestOptions) { + return this.rawClient + .deleteCreditSpendPolicy(spendPolicyId, requestOptions) + .body(); + } + + public CountCreditSpendPoliciesResponse countCreditSpendPolicies() { + return this.rawClient.countCreditSpendPolicies().body(); + } + + public CountCreditSpendPoliciesResponse countCreditSpendPolicies(RequestOptions requestOptions) { + return this.rawClient.countCreditSpendPolicies(requestOptions).body(); + } + + public CountCreditSpendPoliciesResponse countCreditSpendPolicies(CountCreditSpendPoliciesRequest request) { + return this.rawClient.countCreditSpendPolicies(request).body(); + } + + public CountCreditSpendPoliciesResponse countCreditSpendPolicies( + CountCreditSpendPoliciesRequest request, RequestOptions requestOptions) { + return this.rawClient.countCreditSpendPolicies(request, requestOptions).body(); + } + public ListCreditEventLedgerResponse listCreditEventLedger(ListCreditEventLedgerRequest request) { return this.rawClient.listCreditEventLedger(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 fd6f7edf..fd655039 100644 --- a/src/main/java/com/schematic/api/resources/credits/RawCreditsClient.java +++ b/src/main/java/com/schematic/api/resources/credits/RawCreditsClient.java @@ -18,6 +18,7 @@ import com.schematic.api.errors.ForbiddenError; import com.schematic.api.errors.InternalServerError; import com.schematic.api.errors.NotFoundError; +import com.schematic.api.errors.PaymentRequiredError; import com.schematic.api.errors.UnauthorizedError; import com.schematic.api.resources.credits.requests.AcquireCreditLeaseRequestBody; import com.schematic.api.resources.credits.requests.CountBillingCreditsGrantsRequest; @@ -26,9 +27,11 @@ import com.schematic.api.resources.credits.requests.CountCompanyGrantsRequest; import com.schematic.api.resources.credits.requests.CountCreditBundlesRequest; import com.schematic.api.resources.credits.requests.CountCreditEventLedgerRequest; +import com.schematic.api.resources.credits.requests.CountCreditSpendPoliciesRequest; import com.schematic.api.resources.credits.requests.CreateBillingCreditRequestBody; import com.schematic.api.resources.credits.requests.CreateCompanyCreditGrant; import com.schematic.api.resources.credits.requests.CreateCreditBundleRequestBody; +import com.schematic.api.resources.credits.requests.CreateCreditSpendPolicyRequestBody; import com.schematic.api.resources.credits.requests.DeleteBillingPlanCreditGrantRequest; import com.schematic.api.resources.credits.requests.ExtendCreditLeaseRequestBody; import com.schematic.api.resources.credits.requests.ListBillingCreditsRequest; @@ -37,9 +40,11 @@ import com.schematic.api.resources.credits.requests.ListCompanyGrantsRequest; import com.schematic.api.resources.credits.requests.ListCreditBundlesRequest; import com.schematic.api.resources.credits.requests.ListCreditEventLedgerRequest; +import com.schematic.api.resources.credits.requests.ListCreditSpendPoliciesRequest; import com.schematic.api.resources.credits.requests.ListGrantsForCreditRequest; import com.schematic.api.resources.credits.requests.UpdateBillingCreditRequestBody; import com.schematic.api.resources.credits.requests.UpdateCreditBundleDetailsRequestBody; +import com.schematic.api.resources.credits.requests.UpdateCreditSpendPolicyRequestBody; import com.schematic.api.resources.credits.requests.ZeroOutGrantRequestBody; import com.schematic.api.resources.credits.types.AcquireCreditLeaseResponse; import com.schematic.api.resources.credits.types.CountBillingCreditsGrantsResponse; @@ -48,13 +53,17 @@ import com.schematic.api.resources.credits.types.CountCompanyGrantsResponse; import com.schematic.api.resources.credits.types.CountCreditBundlesResponse; import com.schematic.api.resources.credits.types.CountCreditEventLedgerResponse; +import com.schematic.api.resources.credits.types.CountCreditSpendPoliciesResponse; import com.schematic.api.resources.credits.types.CreateBillingCreditResponse; import com.schematic.api.resources.credits.types.CreateBillingPlanCreditGrantResponse; import com.schematic.api.resources.credits.types.CreateCreditBundleResponse; +import com.schematic.api.resources.credits.types.CreateCreditSpendPolicyResponse; import com.schematic.api.resources.credits.types.DeleteBillingPlanCreditGrantResponse; import com.schematic.api.resources.credits.types.DeleteCreditBundleResponse; +import com.schematic.api.resources.credits.types.DeleteCreditSpendPolicyResponse; import com.schematic.api.resources.credits.types.ExtendCreditLeaseResponse; import com.schematic.api.resources.credits.types.GetCreditBundleResponse; +import com.schematic.api.resources.credits.types.GetCreditSpendPolicyResponse; import com.schematic.api.resources.credits.types.GetSingleBillingCreditResponse; import com.schematic.api.resources.credits.types.GetSingleBillingPlanCreditGrantResponse; import com.schematic.api.resources.credits.types.GrantBillingCreditsToCompanyResponse; @@ -64,12 +73,14 @@ import com.schematic.api.resources.credits.types.ListCompanyGrantsResponse; import com.schematic.api.resources.credits.types.ListCreditBundlesResponse; import com.schematic.api.resources.credits.types.ListCreditEventLedgerResponse; +import com.schematic.api.resources.credits.types.ListCreditSpendPoliciesResponse; 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; import com.schematic.api.resources.credits.types.UpdateCreditBundleDetailsResponse; +import com.schematic.api.resources.credits.types.UpdateCreditSpendPolicyResponse; import com.schematic.api.resources.credits.types.ZeroOutGrantResponse; import com.schematic.api.types.ApiError; import com.schematic.api.types.CreateBillingPlanCreditGrantRequestBody; @@ -1778,6 +1789,9 @@ public BaseSchematicHttpResponse acquireCreditLease( case 401: throw new UnauthorizedError( ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 402: + throw new PaymentRequiredError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); case 403: throw new ForbiddenError( ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); @@ -1861,6 +1875,9 @@ public BaseSchematicHttpResponse extendCreditLease( case 401: throw new UnauthorizedError( ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 402: + throw new PaymentRequiredError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); case 403: throw new ForbiddenError( ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); @@ -2527,6 +2544,545 @@ public BaseSchematicHttpResponse countBill } } + public BaseSchematicHttpResponse listCreditSpendPolicies() { + return listCreditSpendPolicies(ListCreditSpendPoliciesRequest.builder().build()); + } + + public BaseSchematicHttpResponse listCreditSpendPolicies( + RequestOptions requestOptions) { + return listCreditSpendPolicies(ListCreditSpendPoliciesRequest.builder().build(), requestOptions); + } + + public BaseSchematicHttpResponse listCreditSpendPolicies( + ListCreditSpendPoliciesRequest request) { + return listCreditSpendPolicies(request, null); + } + + public BaseSchematicHttpResponse listCreditSpendPolicies( + ListCreditSpendPoliciesRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/credits/spend-policies"); + if (request.getBillingCreditId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "billing_credit_id", request.getBillingCreditId().get(), false); + } + if (request.getCompanyId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "company_id", request.getCompanyId().get(), false); + } + if (request.getScopeType().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "scope_type", request.getScopeType().get(), false); + } + if (request.getUserId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "user_id", request.getUserId().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + if (request.getUserIds().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "user_ids", request.getUserIds().get(), true); + } + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } + 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, ListCreditSpendPoliciesResponse.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 (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse createCreditSpendPolicy( + CreateCreditSpendPolicyRequestBody request) { + return createCreditSpendPolicy(request, null); + } + + public BaseSchematicHttpResponse createCreditSpendPolicy( + CreateCreditSpendPolicyRequestBody request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/credits/spend-policies"); + 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); + } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } + 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, CreateCreditSpendPolicyResponse.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 (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse getCreditSpendPolicy(String spendPolicyId) { + return getCreditSpendPolicy(spendPolicyId, null); + } + + public BaseSchematicHttpResponse getCreditSpendPolicy( + String spendPolicyId, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/credits/spend-policies") + .addPathSegment(spendPolicyId); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl.build()) + .method("GET", 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); + } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } + 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, GetCreditSpendPolicyResponse.class), + response); + } + try { + switch (response.code()) { + 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 (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse updateCreditSpendPolicy(String spendPolicyId) { + return updateCreditSpendPolicy( + spendPolicyId, UpdateCreditSpendPolicyRequestBody.builder().build()); + } + + public BaseSchematicHttpResponse updateCreditSpendPolicy( + String spendPolicyId, RequestOptions requestOptions) { + return updateCreditSpendPolicy( + spendPolicyId, UpdateCreditSpendPolicyRequestBody.builder().build(), requestOptions); + } + + public BaseSchematicHttpResponse updateCreditSpendPolicy( + String spendPolicyId, UpdateCreditSpendPolicyRequestBody request) { + return updateCreditSpendPolicy(spendPolicyId, request, null); + } + + public BaseSchematicHttpResponse updateCreditSpendPolicy( + String spendPolicyId, UpdateCreditSpendPolicyRequestBody request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/credits/spend-policies") + .addPathSegment(spendPolicyId); + 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); + } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } + 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, UpdateCreditSpendPolicyResponse.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 (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse deleteCreditSpendPolicy(String spendPolicyId) { + return deleteCreditSpendPolicy(spendPolicyId, null); + } + + public BaseSchematicHttpResponse deleteCreditSpendPolicy( + String spendPolicyId, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/credits/spend-policies") + .addPathSegment(spendPolicyId); + 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); + } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } + 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, DeleteCreditSpendPolicyResponse.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 (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse countCreditSpendPolicies() { + return countCreditSpendPolicies( + CountCreditSpendPoliciesRequest.builder().build()); + } + + public BaseSchematicHttpResponse countCreditSpendPolicies( + RequestOptions requestOptions) { + return countCreditSpendPolicies( + CountCreditSpendPoliciesRequest.builder().build(), requestOptions); + } + + public BaseSchematicHttpResponse countCreditSpendPolicies( + CountCreditSpendPoliciesRequest request) { + return countCreditSpendPolicies(request, null); + } + + public BaseSchematicHttpResponse countCreditSpendPolicies( + CountCreditSpendPoliciesRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/credits/spend-policies/count"); + if (request.getBillingCreditId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "billing_credit_id", request.getBillingCreditId().get(), false); + } + if (request.getCompanyId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "company_id", request.getCompanyId().get(), false); + } + if (request.getScopeType().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "scope_type", request.getScopeType().get(), false); + } + if (request.getUserId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "user_id", request.getUserId().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + if (request.getUserIds().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "user_ids", request.getUserIds().get(), true); + } + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } + 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, CountCreditSpendPoliciesResponse.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 (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + public BaseSchematicHttpResponse listCreditEventLedger( ListCreditEventLedgerRequest request) { return listCreditEventLedger(request, null); diff --git a/src/main/java/com/schematic/api/resources/credits/requests/CountCreditSpendPoliciesRequest.java b/src/main/java/com/schematic/api/resources/credits/requests/CountCreditSpendPoliciesRequest.java new file mode 100644 index 00000000..4590c6d0 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/credits/requests/CountCreditSpendPoliciesRequest.java @@ -0,0 +1,279 @@ +/** + * 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 com.schematic.api.types.CreditSpendPolicyScope; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = CountCreditSpendPoliciesRequest.Builder.class) +public final class CountCreditSpendPoliciesRequest { + private final Optional> userIds; + + private final Optional billingCreditId; + + private final Optional companyId; + + private final Optional scopeType; + + private final Optional userId; + + private final Optional limit; + + private final Optional offset; + + private final Map additionalProperties; + + private CountCreditSpendPoliciesRequest( + Optional> userIds, + Optional billingCreditId, + Optional companyId, + Optional scopeType, + Optional userId, + Optional limit, + Optional offset, + Map additionalProperties) { + this.userIds = userIds; + this.billingCreditId = billingCreditId; + this.companyId = companyId; + this.scopeType = scopeType; + this.userId = userId; + this.limit = limit; + this.offset = offset; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("user_ids") + public Optional> getUserIds() { + return userIds; + } + + @JsonProperty("billing_credit_id") + public Optional getBillingCreditId() { + return billingCreditId; + } + + @JsonProperty("company_id") + public Optional getCompanyId() { + return companyId; + } + + @JsonProperty("scope_type") + public Optional getScopeType() { + return scopeType; + } + + @JsonProperty("user_id") + public Optional getUserId() { + return userId; + } + + /** + * @return Page limit (default 100) + */ + @JsonProperty("limit") + public Optional getLimit() { + return limit; + } + + /** + * @return Page offset (default 0) + */ + @JsonProperty("offset") + public Optional getOffset() { + return offset; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CountCreditSpendPoliciesRequest && equalTo((CountCreditSpendPoliciesRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CountCreditSpendPoliciesRequest other) { + return userIds.equals(other.userIds) + && billingCreditId.equals(other.billingCreditId) + && companyId.equals(other.companyId) + && scopeType.equals(other.scopeType) + && userId.equals(other.userId) + && limit.equals(other.limit) + && offset.equals(other.offset); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.userIds, + this.billingCreditId, + this.companyId, + this.scopeType, + this.userId, + this.limit, + this.offset); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional> userIds = Optional.empty(); + + private Optional billingCreditId = Optional.empty(); + + private Optional companyId = Optional.empty(); + + private Optional scopeType = Optional.empty(); + + private Optional userId = Optional.empty(); + + private Optional limit = Optional.empty(); + + private Optional offset = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(CountCreditSpendPoliciesRequest other) { + userIds(other.getUserIds()); + billingCreditId(other.getBillingCreditId()); + companyId(other.getCompanyId()); + scopeType(other.getScopeType()); + userId(other.getUserId()); + limit(other.getLimit()); + offset(other.getOffset()); + return this; + } + + @JsonSetter(value = "user_ids", nulls = Nulls.SKIP) + public Builder userIds(Optional> userIds) { + this.userIds = userIds; + return this; + } + + public Builder userIds(List userIds) { + this.userIds = Optional.ofNullable(userIds); + return this; + } + + public Builder userIds(String userIds) { + this.userIds = Optional.of(Collections.singletonList(userIds)); + return this; + } + + @JsonSetter(value = "billing_credit_id", nulls = Nulls.SKIP) + public Builder billingCreditId(Optional billingCreditId) { + this.billingCreditId = billingCreditId; + return this; + } + + public Builder billingCreditId(String billingCreditId) { + this.billingCreditId = Optional.ofNullable(billingCreditId); + return this; + } + + @JsonSetter(value = "company_id", nulls = Nulls.SKIP) + public Builder companyId(Optional companyId) { + this.companyId = companyId; + return this; + } + + public Builder companyId(String companyId) { + this.companyId = Optional.ofNullable(companyId); + return this; + } + + @JsonSetter(value = "scope_type", nulls = Nulls.SKIP) + public Builder scopeType(Optional scopeType) { + this.scopeType = scopeType; + return this; + } + + public Builder scopeType(CreditSpendPolicyScope scopeType) { + this.scopeType = Optional.ofNullable(scopeType); + return this; + } + + @JsonSetter(value = "user_id", nulls = Nulls.SKIP) + public Builder userId(Optional userId) { + this.userId = userId; + return this; + } + + public Builder userId(String userId) { + this.userId = Optional.ofNullable(userId); + return this; + } + + /** + *

Page limit (default 100)

+ */ + @JsonSetter(value = "limit", nulls = Nulls.SKIP) + public Builder limit(Optional limit) { + this.limit = limit; + return this; + } + + public Builder limit(Long limit) { + this.limit = Optional.ofNullable(limit); + return this; + } + + /** + *

Page offset (default 0)

+ */ + @JsonSetter(value = "offset", nulls = Nulls.SKIP) + public Builder offset(Optional offset) { + this.offset = offset; + return this; + } + + public Builder offset(Long offset) { + this.offset = Optional.ofNullable(offset); + return this; + } + + public CountCreditSpendPoliciesRequest build() { + return new CountCreditSpendPoliciesRequest( + userIds, billingCreditId, companyId, scopeType, userId, limit, offset, additionalProperties); + } + + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + } +} diff --git a/src/main/java/com/schematic/api/resources/credits/requests/CreateCreditSpendPolicyRequestBody.java b/src/main/java/com/schematic/api/resources/credits/requests/CreateCreditSpendPolicyRequestBody.java new file mode 100644 index 00000000..e1600fe3 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/credits/requests/CreateCreditSpendPolicyRequestBody.java @@ -0,0 +1,274 @@ +/** + * 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.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 = CreateCreditSpendPolicyRequestBody.Builder.class) +public final class CreateCreditSpendPolicyRequestBody { + private final String billingCreditId; + + private final Optional companyId; + + private final Optional label; + + private final double maxPerDraw; + + private final Optional userId; + + private final Map additionalProperties; + + private CreateCreditSpendPolicyRequestBody( + String billingCreditId, + Optional companyId, + Optional label, + double maxPerDraw, + Optional userId, + Map additionalProperties) { + this.billingCreditId = billingCreditId; + this.companyId = companyId; + this.label = label; + this.maxPerDraw = maxPerDraw; + this.userId = userId; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("billing_credit_id") + public String getBillingCreditId() { + return billingCreditId; + } + + /** + * @return The company the cap applies to. Set exactly one of company_id and user_id. + */ + @JsonProperty("company_id") + public Optional getCompanyId() { + return companyId; + } + + @JsonProperty("label") + public Optional getLabel() { + return label; + } + + /** + * @return The largest number of credits a single draw may spend. + */ + @JsonProperty("max_per_draw") + public double getMaxPerDraw() { + return maxPerDraw; + } + + /** + * @return The user the cap applies to. Set exactly one of company_id and user_id. + */ + @JsonProperty("user_id") + public Optional getUserId() { + return userId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CreateCreditSpendPolicyRequestBody + && equalTo((CreateCreditSpendPolicyRequestBody) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CreateCreditSpendPolicyRequestBody other) { + return billingCreditId.equals(other.billingCreditId) + && companyId.equals(other.companyId) + && label.equals(other.label) + && maxPerDraw == other.maxPerDraw + && userId.equals(other.userId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.billingCreditId, this.companyId, this.label, this.maxPerDraw, this.userId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static BillingCreditIdStage builder() { + return new Builder(); + } + + public interface BillingCreditIdStage { + MaxPerDrawStage billingCreditId(@NotNull String billingCreditId); + + Builder from(CreateCreditSpendPolicyRequestBody other); + } + + public interface MaxPerDrawStage { + /** + *

The largest number of credits a single draw may spend.

+ */ + _FinalStage maxPerDraw(double maxPerDraw); + } + + public interface _FinalStage { + CreateCreditSpendPolicyRequestBody build(); + + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); + + /** + *

The company the cap applies to. Set exactly one of company_id and user_id.

+ */ + _FinalStage companyId(Optional companyId); + + _FinalStage companyId(String companyId); + + _FinalStage label(Optional label); + + _FinalStage label(String label); + + /** + *

The user the cap applies to. Set exactly one of company_id and user_id.

+ */ + _FinalStage userId(Optional userId); + + _FinalStage userId(String userId); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements BillingCreditIdStage, MaxPerDrawStage, _FinalStage { + private String billingCreditId; + + private double maxPerDraw; + + private Optional userId = Optional.empty(); + + private Optional label = Optional.empty(); + + private Optional companyId = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(CreateCreditSpendPolicyRequestBody other) { + billingCreditId(other.getBillingCreditId()); + companyId(other.getCompanyId()); + label(other.getLabel()); + maxPerDraw(other.getMaxPerDraw()); + userId(other.getUserId()); + return this; + } + + @java.lang.Override + @JsonSetter("billing_credit_id") + public MaxPerDrawStage billingCreditId(@NotNull String billingCreditId) { + this.billingCreditId = Objects.requireNonNull(billingCreditId, "billingCreditId must not be null"); + return this; + } + + /** + *

The largest number of credits a single draw may spend.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("max_per_draw") + public _FinalStage maxPerDraw(double maxPerDraw) { + this.maxPerDraw = maxPerDraw; + return this; + } + + /** + *

The user the cap applies to. Set exactly one of company_id and user_id.

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

The user the cap applies to. Set exactly one of company_id and user_id.

+ */ + @java.lang.Override + @JsonSetter(value = "user_id", nulls = Nulls.SKIP) + public _FinalStage userId(Optional userId) { + this.userId = userId; + return this; + } + + @java.lang.Override + public _FinalStage label(String label) { + this.label = Optional.ofNullable(label); + return this; + } + + @java.lang.Override + @JsonSetter(value = "label", nulls = Nulls.SKIP) + public _FinalStage label(Optional label) { + this.label = label; + return this; + } + + /** + *

The company the cap applies to. Set exactly one of company_id and user_id.

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

The company the cap applies to. Set exactly one of company_id and user_id.

+ */ + @java.lang.Override + @JsonSetter(value = "company_id", nulls = Nulls.SKIP) + public _FinalStage companyId(Optional companyId) { + this.companyId = companyId; + return this; + } + + @java.lang.Override + public CreateCreditSpendPolicyRequestBody build() { + return new CreateCreditSpendPolicyRequestBody( + billingCreditId, companyId, label, maxPerDraw, userId, 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/ListCreditSpendPoliciesRequest.java b/src/main/java/com/schematic/api/resources/credits/requests/ListCreditSpendPoliciesRequest.java new file mode 100644 index 00000000..36017e93 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/credits/requests/ListCreditSpendPoliciesRequest.java @@ -0,0 +1,279 @@ +/** + * 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 com.schematic.api.types.CreditSpendPolicyScope; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ListCreditSpendPoliciesRequest.Builder.class) +public final class ListCreditSpendPoliciesRequest { + private final Optional> userIds; + + private final Optional billingCreditId; + + private final Optional companyId; + + private final Optional scopeType; + + private final Optional userId; + + private final Optional limit; + + private final Optional offset; + + private final Map additionalProperties; + + private ListCreditSpendPoliciesRequest( + Optional> userIds, + Optional billingCreditId, + Optional companyId, + Optional scopeType, + Optional userId, + Optional limit, + Optional offset, + Map additionalProperties) { + this.userIds = userIds; + this.billingCreditId = billingCreditId; + this.companyId = companyId; + this.scopeType = scopeType; + this.userId = userId; + this.limit = limit; + this.offset = offset; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("user_ids") + public Optional> getUserIds() { + return userIds; + } + + @JsonProperty("billing_credit_id") + public Optional getBillingCreditId() { + return billingCreditId; + } + + @JsonProperty("company_id") + public Optional getCompanyId() { + return companyId; + } + + @JsonProperty("scope_type") + public Optional getScopeType() { + return scopeType; + } + + @JsonProperty("user_id") + public Optional getUserId() { + return userId; + } + + /** + * @return Page limit (default 100) + */ + @JsonProperty("limit") + public Optional getLimit() { + return limit; + } + + /** + * @return Page offset (default 0) + */ + @JsonProperty("offset") + public Optional getOffset() { + return offset; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ListCreditSpendPoliciesRequest && equalTo((ListCreditSpendPoliciesRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ListCreditSpendPoliciesRequest other) { + return userIds.equals(other.userIds) + && billingCreditId.equals(other.billingCreditId) + && companyId.equals(other.companyId) + && scopeType.equals(other.scopeType) + && userId.equals(other.userId) + && limit.equals(other.limit) + && offset.equals(other.offset); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.userIds, + this.billingCreditId, + this.companyId, + this.scopeType, + this.userId, + this.limit, + this.offset); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional> userIds = Optional.empty(); + + private Optional billingCreditId = Optional.empty(); + + private Optional companyId = Optional.empty(); + + private Optional scopeType = Optional.empty(); + + private Optional userId = Optional.empty(); + + private Optional limit = Optional.empty(); + + private Optional offset = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ListCreditSpendPoliciesRequest other) { + userIds(other.getUserIds()); + billingCreditId(other.getBillingCreditId()); + companyId(other.getCompanyId()); + scopeType(other.getScopeType()); + userId(other.getUserId()); + limit(other.getLimit()); + offset(other.getOffset()); + return this; + } + + @JsonSetter(value = "user_ids", nulls = Nulls.SKIP) + public Builder userIds(Optional> userIds) { + this.userIds = userIds; + return this; + } + + public Builder userIds(List userIds) { + this.userIds = Optional.ofNullable(userIds); + return this; + } + + public Builder userIds(String userIds) { + this.userIds = Optional.of(Collections.singletonList(userIds)); + return this; + } + + @JsonSetter(value = "billing_credit_id", nulls = Nulls.SKIP) + public Builder billingCreditId(Optional billingCreditId) { + this.billingCreditId = billingCreditId; + return this; + } + + public Builder billingCreditId(String billingCreditId) { + this.billingCreditId = Optional.ofNullable(billingCreditId); + return this; + } + + @JsonSetter(value = "company_id", nulls = Nulls.SKIP) + public Builder companyId(Optional companyId) { + this.companyId = companyId; + return this; + } + + public Builder companyId(String companyId) { + this.companyId = Optional.ofNullable(companyId); + return this; + } + + @JsonSetter(value = "scope_type", nulls = Nulls.SKIP) + public Builder scopeType(Optional scopeType) { + this.scopeType = scopeType; + return this; + } + + public Builder scopeType(CreditSpendPolicyScope scopeType) { + this.scopeType = Optional.ofNullable(scopeType); + return this; + } + + @JsonSetter(value = "user_id", nulls = Nulls.SKIP) + public Builder userId(Optional userId) { + this.userId = userId; + return this; + } + + public Builder userId(String userId) { + this.userId = Optional.ofNullable(userId); + return this; + } + + /** + *

Page limit (default 100)

+ */ + @JsonSetter(value = "limit", nulls = Nulls.SKIP) + public Builder limit(Optional limit) { + this.limit = limit; + return this; + } + + public Builder limit(Long limit) { + this.limit = Optional.ofNullable(limit); + return this; + } + + /** + *

Page offset (default 0)

+ */ + @JsonSetter(value = "offset", nulls = Nulls.SKIP) + public Builder offset(Optional offset) { + this.offset = offset; + return this; + } + + public Builder offset(Long offset) { + this.offset = Optional.ofNullable(offset); + return this; + } + + public ListCreditSpendPoliciesRequest build() { + return new ListCreditSpendPoliciesRequest( + userIds, billingCreditId, companyId, scopeType, userId, limit, offset, additionalProperties); + } + + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + } +} diff --git a/src/main/java/com/schematic/api/resources/credits/requests/UpdateCreditSpendPolicyRequestBody.java b/src/main/java/com/schematic/api/resources/credits/requests/UpdateCreditSpendPolicyRequestBody.java new file mode 100644 index 00000000..e3500cc6 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/credits/requests/UpdateCreditSpendPolicyRequestBody.java @@ -0,0 +1,129 @@ +/** + * 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.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = UpdateCreditSpendPolicyRequestBody.Builder.class) +public final class UpdateCreditSpendPolicyRequestBody { + private final Optional label; + + private final Optional maxPerDraw; + + private final Map additionalProperties; + + private UpdateCreditSpendPolicyRequestBody( + Optional label, Optional maxPerDraw, Map additionalProperties) { + this.label = label; + this.maxPerDraw = maxPerDraw; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("label") + public Optional getLabel() { + return label; + } + + @JsonProperty("max_per_draw") + public Optional getMaxPerDraw() { + return maxPerDraw; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof UpdateCreditSpendPolicyRequestBody + && equalTo((UpdateCreditSpendPolicyRequestBody) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(UpdateCreditSpendPolicyRequestBody other) { + return label.equals(other.label) && maxPerDraw.equals(other.maxPerDraw); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.label, this.maxPerDraw); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional label = Optional.empty(); + + private Optional maxPerDraw = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(UpdateCreditSpendPolicyRequestBody other) { + label(other.getLabel()); + maxPerDraw(other.getMaxPerDraw()); + return this; + } + + @JsonSetter(value = "label", nulls = Nulls.SKIP) + public Builder label(Optional label) { + this.label = label; + return this; + } + + public Builder label(String label) { + this.label = Optional.ofNullable(label); + return this; + } + + @JsonSetter(value = "max_per_draw", nulls = Nulls.SKIP) + public Builder maxPerDraw(Optional maxPerDraw) { + this.maxPerDraw = maxPerDraw; + return this; + } + + public Builder maxPerDraw(Double maxPerDraw) { + this.maxPerDraw = Optional.ofNullable(maxPerDraw); + return this; + } + + public UpdateCreditSpendPolicyRequestBody build() { + return new UpdateCreditSpendPolicyRequestBody(label, maxPerDraw, additionalProperties); + } + + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + } +} diff --git a/src/main/java/com/schematic/api/resources/credits/types/CountCreditSpendPoliciesParams.java b/src/main/java/com/schematic/api/resources/credits/types/CountCreditSpendPoliciesParams.java new file mode 100644 index 00000000..0febdcee --- /dev/null +++ b/src/main/java/com/schematic/api/resources/credits/types/CountCreditSpendPoliciesParams.java @@ -0,0 +1,273 @@ +/** + * 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.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.types.CreditSpendPolicyScope; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = CountCreditSpendPoliciesParams.Builder.class) +public final class CountCreditSpendPoliciesParams { + private final Optional billingCreditId; + + private final Optional companyId; + + private final Optional limit; + + private final Optional offset; + + private final Optional scopeType; + + private final Optional userId; + + private final Optional> userIds; + + private final Map additionalProperties; + + private CountCreditSpendPoliciesParams( + Optional billingCreditId, + Optional companyId, + Optional limit, + Optional offset, + Optional scopeType, + Optional userId, + Optional> userIds, + Map additionalProperties) { + this.billingCreditId = billingCreditId; + this.companyId = companyId; + this.limit = limit; + this.offset = offset; + this.scopeType = scopeType; + this.userId = userId; + this.userIds = userIds; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("billing_credit_id") + public Optional getBillingCreditId() { + return billingCreditId; + } + + @JsonProperty("company_id") + public Optional getCompanyId() { + return companyId; + } + + /** + * @return Page limit (default 100) + */ + @JsonProperty("limit") + public Optional getLimit() { + return limit; + } + + /** + * @return Page offset (default 0) + */ + @JsonProperty("offset") + public Optional getOffset() { + return offset; + } + + @JsonProperty("scope_type") + public Optional getScopeType() { + return scopeType; + } + + @JsonProperty("user_id") + public Optional getUserId() { + return userId; + } + + @JsonProperty("user_ids") + public Optional> getUserIds() { + return userIds; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CountCreditSpendPoliciesParams && equalTo((CountCreditSpendPoliciesParams) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CountCreditSpendPoliciesParams other) { + return billingCreditId.equals(other.billingCreditId) + && companyId.equals(other.companyId) + && limit.equals(other.limit) + && offset.equals(other.offset) + && scopeType.equals(other.scopeType) + && userId.equals(other.userId) + && userIds.equals(other.userIds); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.billingCreditId, + this.companyId, + this.limit, + this.offset, + this.scopeType, + this.userId, + this.userIds); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional billingCreditId = Optional.empty(); + + private Optional companyId = Optional.empty(); + + private Optional limit = Optional.empty(); + + private Optional offset = Optional.empty(); + + private Optional scopeType = Optional.empty(); + + private Optional userId = Optional.empty(); + + private Optional> userIds = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(CountCreditSpendPoliciesParams other) { + billingCreditId(other.getBillingCreditId()); + companyId(other.getCompanyId()); + limit(other.getLimit()); + offset(other.getOffset()); + scopeType(other.getScopeType()); + userId(other.getUserId()); + userIds(other.getUserIds()); + return this; + } + + @JsonSetter(value = "billing_credit_id", nulls = Nulls.SKIP) + public Builder billingCreditId(Optional billingCreditId) { + this.billingCreditId = billingCreditId; + return this; + } + + public Builder billingCreditId(String billingCreditId) { + this.billingCreditId = Optional.ofNullable(billingCreditId); + return this; + } + + @JsonSetter(value = "company_id", nulls = Nulls.SKIP) + public Builder companyId(Optional companyId) { + this.companyId = companyId; + return this; + } + + public Builder companyId(String companyId) { + this.companyId = Optional.ofNullable(companyId); + return this; + } + + /** + *

Page limit (default 100)

+ */ + @JsonSetter(value = "limit", nulls = Nulls.SKIP) + public Builder limit(Optional limit) { + this.limit = limit; + return this; + } + + public Builder limit(Long limit) { + this.limit = Optional.ofNullable(limit); + return this; + } + + /** + *

Page offset (default 0)

+ */ + @JsonSetter(value = "offset", nulls = Nulls.SKIP) + public Builder offset(Optional offset) { + this.offset = offset; + return this; + } + + public Builder offset(Long offset) { + this.offset = Optional.ofNullable(offset); + return this; + } + + @JsonSetter(value = "scope_type", nulls = Nulls.SKIP) + public Builder scopeType(Optional scopeType) { + this.scopeType = scopeType; + return this; + } + + public Builder scopeType(CreditSpendPolicyScope scopeType) { + this.scopeType = Optional.ofNullable(scopeType); + return this; + } + + @JsonSetter(value = "user_id", nulls = Nulls.SKIP) + public Builder userId(Optional userId) { + this.userId = userId; + return this; + } + + public Builder userId(String userId) { + this.userId = Optional.ofNullable(userId); + return this; + } + + @JsonSetter(value = "user_ids", nulls = Nulls.SKIP) + public Builder userIds(Optional> userIds) { + this.userIds = userIds; + return this; + } + + public Builder userIds(List userIds) { + this.userIds = Optional.ofNullable(userIds); + return this; + } + + public CountCreditSpendPoliciesParams build() { + return new CountCreditSpendPoliciesParams( + billingCreditId, companyId, limit, offset, scopeType, userId, userIds, additionalProperties); + } + + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + } +} diff --git a/src/main/java/com/schematic/api/resources/credits/types/CountCreditSpendPoliciesResponse.java b/src/main/java/com/schematic/api/resources/credits/types/CountCreditSpendPoliciesResponse.java new file mode 100644 index 00000000..2f9add28 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/credits/types/CountCreditSpendPoliciesResponse.java @@ -0,0 +1,152 @@ +/** + * 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.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.types.CountResponse; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = CountCreditSpendPoliciesResponse.Builder.class) +public final class CountCreditSpendPoliciesResponse { + private final CountResponse data; + + private final CountCreditSpendPoliciesParams params; + + private final Map additionalProperties; + + private CountCreditSpendPoliciesResponse( + CountResponse data, CountCreditSpendPoliciesParams params, Map additionalProperties) { + this.data = data; + this.params = params; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("data") + public CountResponse getData() { + return data; + } + + /** + * @return Input parameters + */ + @JsonProperty("params") + public CountCreditSpendPoliciesParams getParams() { + return params; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CountCreditSpendPoliciesResponse && equalTo((CountCreditSpendPoliciesResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CountCreditSpendPoliciesResponse 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 { + ParamsStage data(@NotNull CountResponse data); + + Builder from(CountCreditSpendPoliciesResponse other); + } + + public interface ParamsStage { + /** + *

Input parameters

+ */ + _FinalStage params(@NotNull CountCreditSpendPoliciesParams params); + } + + public interface _FinalStage { + CountCreditSpendPoliciesResponse build(); + + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements DataStage, ParamsStage, _FinalStage { + private CountResponse data; + + private CountCreditSpendPoliciesParams params; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(CountCreditSpendPoliciesResponse other) { + data(other.getData()); + params(other.getParams()); + return this; + } + + @java.lang.Override + @JsonSetter("data") + public ParamsStage data(@NotNull CountResponse 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 + @JsonSetter("params") + public _FinalStage params(@NotNull CountCreditSpendPoliciesParams params) { + this.params = Objects.requireNonNull(params, "params must not be null"); + return this; + } + + @java.lang.Override + public CountCreditSpendPoliciesResponse build() { + return new CountCreditSpendPoliciesResponse(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/CreateCreditSpendPolicyResponse.java b/src/main/java/com/schematic/api/resources/credits/types/CreateCreditSpendPolicyResponse.java new file mode 100644 index 00000000..cf1a0a7a --- /dev/null +++ b/src/main/java/com/schematic/api/resources/credits/types/CreateCreditSpendPolicyResponse.java @@ -0,0 +1,183 @@ +/** + * 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.CreditSpendPolicyResponseData; +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 = CreateCreditSpendPolicyResponse.Builder.class) +public final class CreateCreditSpendPolicyResponse { + private final CreditSpendPolicyResponseData data; + + private final Map params; + + private final Map additionalProperties; + + private CreateCreditSpendPolicyResponse( + CreditSpendPolicyResponseData data, + Map params, + Map additionalProperties) { + this.data = data; + this.params = params; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("data") + public CreditSpendPolicyResponseData 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 CreateCreditSpendPolicyResponse && equalTo((CreateCreditSpendPolicyResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CreateCreditSpendPolicyResponse 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 CreditSpendPolicyResponseData data); + + Builder from(CreateCreditSpendPolicyResponse other); + } + + public interface _FinalStage { + CreateCreditSpendPolicyResponse 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 CreditSpendPolicyResponseData data; + + private Map params = new LinkedHashMap<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(CreateCreditSpendPolicyResponse other) { + data(other.getData()); + params(other.getParams()); + return this; + } + + @java.lang.Override + @JsonSetter("data") + public _FinalStage data(@NotNull CreditSpendPolicyResponseData 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 CreateCreditSpendPolicyResponse build() { + return new CreateCreditSpendPolicyResponse(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/DeleteCreditSpendPolicyResponse.java b/src/main/java/com/schematic/api/resources/credits/types/DeleteCreditSpendPolicyResponse.java new file mode 100644 index 00000000..554baba8 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/credits/types/DeleteCreditSpendPolicyResponse.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.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 = DeleteCreditSpendPolicyResponse.Builder.class) +public final class DeleteCreditSpendPolicyResponse { + private final DeleteResponse data; + + private final Map params; + + private final Map additionalProperties; + + private DeleteCreditSpendPolicyResponse( + 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 DeleteCreditSpendPolicyResponse && equalTo((DeleteCreditSpendPolicyResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DeleteCreditSpendPolicyResponse 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(DeleteCreditSpendPolicyResponse other); + } + + public interface _FinalStage { + DeleteCreditSpendPolicyResponse 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(DeleteCreditSpendPolicyResponse 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 DeleteCreditSpendPolicyResponse build() { + return new DeleteCreditSpendPolicyResponse(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/GetCreditSpendPolicyResponse.java b/src/main/java/com/schematic/api/resources/credits/types/GetCreditSpendPolicyResponse.java new file mode 100644 index 00000000..d8b0c491 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/credits/types/GetCreditSpendPolicyResponse.java @@ -0,0 +1,183 @@ +/** + * 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.CreditSpendPolicyResponseData; +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 = GetCreditSpendPolicyResponse.Builder.class) +public final class GetCreditSpendPolicyResponse { + private final CreditSpendPolicyResponseData data; + + private final Map params; + + private final Map additionalProperties; + + private GetCreditSpendPolicyResponse( + CreditSpendPolicyResponseData data, + Map params, + Map additionalProperties) { + this.data = data; + this.params = params; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("data") + public CreditSpendPolicyResponseData 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 GetCreditSpendPolicyResponse && equalTo((GetCreditSpendPolicyResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(GetCreditSpendPolicyResponse 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 CreditSpendPolicyResponseData data); + + Builder from(GetCreditSpendPolicyResponse other); + } + + public interface _FinalStage { + GetCreditSpendPolicyResponse 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 CreditSpendPolicyResponseData data; + + private Map params = new LinkedHashMap<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(GetCreditSpendPolicyResponse other) { + data(other.getData()); + params(other.getParams()); + return this; + } + + @java.lang.Override + @JsonSetter("data") + public _FinalStage data(@NotNull CreditSpendPolicyResponseData 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 GetCreditSpendPolicyResponse build() { + return new GetCreditSpendPolicyResponse(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/ListCreditSpendPoliciesParams.java b/src/main/java/com/schematic/api/resources/credits/types/ListCreditSpendPoliciesParams.java new file mode 100644 index 00000000..61fa716e --- /dev/null +++ b/src/main/java/com/schematic/api/resources/credits/types/ListCreditSpendPoliciesParams.java @@ -0,0 +1,273 @@ +/** + * 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.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.types.CreditSpendPolicyScope; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ListCreditSpendPoliciesParams.Builder.class) +public final class ListCreditSpendPoliciesParams { + private final Optional billingCreditId; + + private final Optional companyId; + + private final Optional limit; + + private final Optional offset; + + private final Optional scopeType; + + private final Optional userId; + + private final Optional> userIds; + + private final Map additionalProperties; + + private ListCreditSpendPoliciesParams( + Optional billingCreditId, + Optional companyId, + Optional limit, + Optional offset, + Optional scopeType, + Optional userId, + Optional> userIds, + Map additionalProperties) { + this.billingCreditId = billingCreditId; + this.companyId = companyId; + this.limit = limit; + this.offset = offset; + this.scopeType = scopeType; + this.userId = userId; + this.userIds = userIds; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("billing_credit_id") + public Optional getBillingCreditId() { + return billingCreditId; + } + + @JsonProperty("company_id") + public Optional getCompanyId() { + return companyId; + } + + /** + * @return Page limit (default 100) + */ + @JsonProperty("limit") + public Optional getLimit() { + return limit; + } + + /** + * @return Page offset (default 0) + */ + @JsonProperty("offset") + public Optional getOffset() { + return offset; + } + + @JsonProperty("scope_type") + public Optional getScopeType() { + return scopeType; + } + + @JsonProperty("user_id") + public Optional getUserId() { + return userId; + } + + @JsonProperty("user_ids") + public Optional> getUserIds() { + return userIds; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ListCreditSpendPoliciesParams && equalTo((ListCreditSpendPoliciesParams) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ListCreditSpendPoliciesParams other) { + return billingCreditId.equals(other.billingCreditId) + && companyId.equals(other.companyId) + && limit.equals(other.limit) + && offset.equals(other.offset) + && scopeType.equals(other.scopeType) + && userId.equals(other.userId) + && userIds.equals(other.userIds); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.billingCreditId, + this.companyId, + this.limit, + this.offset, + this.scopeType, + this.userId, + this.userIds); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional billingCreditId = Optional.empty(); + + private Optional companyId = Optional.empty(); + + private Optional limit = Optional.empty(); + + private Optional offset = Optional.empty(); + + private Optional scopeType = Optional.empty(); + + private Optional userId = Optional.empty(); + + private Optional> userIds = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ListCreditSpendPoliciesParams other) { + billingCreditId(other.getBillingCreditId()); + companyId(other.getCompanyId()); + limit(other.getLimit()); + offset(other.getOffset()); + scopeType(other.getScopeType()); + userId(other.getUserId()); + userIds(other.getUserIds()); + return this; + } + + @JsonSetter(value = "billing_credit_id", nulls = Nulls.SKIP) + public Builder billingCreditId(Optional billingCreditId) { + this.billingCreditId = billingCreditId; + return this; + } + + public Builder billingCreditId(String billingCreditId) { + this.billingCreditId = Optional.ofNullable(billingCreditId); + return this; + } + + @JsonSetter(value = "company_id", nulls = Nulls.SKIP) + public Builder companyId(Optional companyId) { + this.companyId = companyId; + return this; + } + + public Builder companyId(String companyId) { + this.companyId = Optional.ofNullable(companyId); + return this; + } + + /** + *

Page limit (default 100)

+ */ + @JsonSetter(value = "limit", nulls = Nulls.SKIP) + public Builder limit(Optional limit) { + this.limit = limit; + return this; + } + + public Builder limit(Long limit) { + this.limit = Optional.ofNullable(limit); + return this; + } + + /** + *

Page offset (default 0)

+ */ + @JsonSetter(value = "offset", nulls = Nulls.SKIP) + public Builder offset(Optional offset) { + this.offset = offset; + return this; + } + + public Builder offset(Long offset) { + this.offset = Optional.ofNullable(offset); + return this; + } + + @JsonSetter(value = "scope_type", nulls = Nulls.SKIP) + public Builder scopeType(Optional scopeType) { + this.scopeType = scopeType; + return this; + } + + public Builder scopeType(CreditSpendPolicyScope scopeType) { + this.scopeType = Optional.ofNullable(scopeType); + return this; + } + + @JsonSetter(value = "user_id", nulls = Nulls.SKIP) + public Builder userId(Optional userId) { + this.userId = userId; + return this; + } + + public Builder userId(String userId) { + this.userId = Optional.ofNullable(userId); + return this; + } + + @JsonSetter(value = "user_ids", nulls = Nulls.SKIP) + public Builder userIds(Optional> userIds) { + this.userIds = userIds; + return this; + } + + public Builder userIds(List userIds) { + this.userIds = Optional.ofNullable(userIds); + return this; + } + + public ListCreditSpendPoliciesParams build() { + return new ListCreditSpendPoliciesParams( + billingCreditId, companyId, limit, offset, scopeType, userId, userIds, additionalProperties); + } + + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + } +} diff --git a/src/main/java/com/schematic/api/resources/credits/types/ListCreditSpendPoliciesResponse.java b/src/main/java/com/schematic/api/resources/credits/types/ListCreditSpendPoliciesResponse.java new file mode 100644 index 00000000..a3dc7bb7 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/credits/types/ListCreditSpendPoliciesResponse.java @@ -0,0 +1,176 @@ +/** + * 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.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.types.CreditSpendPolicyResponseData; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ListCreditSpendPoliciesResponse.Builder.class) +public final class ListCreditSpendPoliciesResponse { + private final List data; + + private final ListCreditSpendPoliciesParams params; + + private final Map additionalProperties; + + private ListCreditSpendPoliciesResponse( + List data, + ListCreditSpendPoliciesParams params, + Map additionalProperties) { + this.data = data; + this.params = params; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("data") + public List getData() { + return data; + } + + /** + * @return Input parameters + */ + @JsonProperty("params") + public ListCreditSpendPoliciesParams getParams() { + return params; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ListCreditSpendPoliciesResponse && equalTo((ListCreditSpendPoliciesResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ListCreditSpendPoliciesResponse 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 ParamsStage builder() { + return new Builder(); + } + + public interface ParamsStage { + /** + *

Input parameters

+ */ + _FinalStage params(@NotNull ListCreditSpendPoliciesParams params); + + Builder from(ListCreditSpendPoliciesResponse other); + } + + public interface _FinalStage { + ListCreditSpendPoliciesResponse build(); + + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); + + _FinalStage data(List data); + + _FinalStage addData(CreditSpendPolicyResponseData data); + + _FinalStage addAllData(List data); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements ParamsStage, _FinalStage { + private ListCreditSpendPoliciesParams params; + + private List data = new ArrayList<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ListCreditSpendPoliciesResponse other) { + data(other.getData()); + params(other.getParams()); + return this; + } + + /** + *

Input parameters

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("params") + public _FinalStage params(@NotNull ListCreditSpendPoliciesParams params) { + this.params = Objects.requireNonNull(params, "params must not be null"); + return this; + } + + @java.lang.Override + public _FinalStage addAllData(List data) { + if (data != null) { + this.data.addAll(data); + } + return this; + } + + @java.lang.Override + public _FinalStage addData(CreditSpendPolicyResponseData data) { + this.data.add(data); + return this; + } + + @java.lang.Override + @JsonSetter(value = "data", nulls = Nulls.SKIP) + public _FinalStage data(List data) { + this.data.clear(); + if (data != null) { + this.data.addAll(data); + } + return this; + } + + @java.lang.Override + public ListCreditSpendPoliciesResponse build() { + return new ListCreditSpendPoliciesResponse(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/UpdateCreditSpendPolicyResponse.java b/src/main/java/com/schematic/api/resources/credits/types/UpdateCreditSpendPolicyResponse.java new file mode 100644 index 00000000..66ab2451 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/credits/types/UpdateCreditSpendPolicyResponse.java @@ -0,0 +1,183 @@ +/** + * 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.CreditSpendPolicyResponseData; +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 = UpdateCreditSpendPolicyResponse.Builder.class) +public final class UpdateCreditSpendPolicyResponse { + private final CreditSpendPolicyResponseData data; + + private final Map params; + + private final Map additionalProperties; + + private UpdateCreditSpendPolicyResponse( + CreditSpendPolicyResponseData data, + Map params, + Map additionalProperties) { + this.data = data; + this.params = params; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("data") + public CreditSpendPolicyResponseData 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 UpdateCreditSpendPolicyResponse && equalTo((UpdateCreditSpendPolicyResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(UpdateCreditSpendPolicyResponse 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 CreditSpendPolicyResponseData data); + + Builder from(UpdateCreditSpendPolicyResponse other); + } + + public interface _FinalStage { + UpdateCreditSpendPolicyResponse 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 CreditSpendPolicyResponseData data; + + private Map params = new LinkedHashMap<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(UpdateCreditSpendPolicyResponse other) { + data(other.getData()); + params(other.getParams()); + return this; + } + + @java.lang.Override + @JsonSetter("data") + public _FinalStage data(@NotNull CreditSpendPolicyResponseData 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 UpdateCreditSpendPolicyResponse build() { + return new UpdateCreditSpendPolicyResponse(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/events/AsyncEventsClient.java b/src/main/java/com/schematic/api/resources/events/AsyncEventsClient.java index 3471cdc3..ac3f717b 100644 --- a/src/main/java/com/schematic/api/resources/events/AsyncEventsClient.java +++ b/src/main/java/com/schematic/api/resources/events/AsyncEventsClient.java @@ -8,12 +8,16 @@ import com.schematic.api.resources.events.requests.CreateEventBatchRequestBody; import com.schematic.api.resources.events.requests.GetEventSummariesRequest; import com.schematic.api.resources.events.requests.ListEventsRequest; +import com.schematic.api.resources.events.requests.UpsertOtlpEnvironmentSettingsRequestBody; import com.schematic.api.resources.events.types.CreateEventBatchResponse; import com.schematic.api.resources.events.types.CreateEventResponse; +import com.schematic.api.resources.events.types.DeleteOtlpEnvironmentSettingsResponse; import com.schematic.api.resources.events.types.GetEventResponse; import com.schematic.api.resources.events.types.GetEventSummariesResponse; +import com.schematic.api.resources.events.types.GetOtlpEnvironmentSettingsResponse; import com.schematic.api.resources.events.types.GetSegmentIntegrationStatusResponse; import com.schematic.api.resources.events.types.ListEventsResponse; +import com.schematic.api.resources.events.types.UpsertOtlpEnvironmentSettingsResponse; import com.schematic.api.types.CreateEventRequestBody; import java.util.concurrent.CompletableFuture; @@ -93,6 +97,36 @@ public CompletableFuture getEvent(String eventId, RequestOptio return this.rawClient.getEvent(eventId, requestOptions).thenApply(response -> response.body()); } + public CompletableFuture getOtlpEnvironmentSettings() { + return this.rawClient.getOtlpEnvironmentSettings().thenApply(response -> response.body()); + } + + public CompletableFuture getOtlpEnvironmentSettings( + RequestOptions requestOptions) { + return this.rawClient.getOtlpEnvironmentSettings(requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture upsertOtlpEnvironmentSettings( + UpsertOtlpEnvironmentSettingsRequestBody request) { + return this.rawClient.upsertOtlpEnvironmentSettings(request).thenApply(response -> response.body()); + } + + public CompletableFuture upsertOtlpEnvironmentSettings( + UpsertOtlpEnvironmentSettingsRequestBody request, RequestOptions requestOptions) { + return this.rawClient + .upsertOtlpEnvironmentSettings(request, requestOptions) + .thenApply(response -> response.body()); + } + + public CompletableFuture deleteOtlpEnvironmentSettings() { + return this.rawClient.deleteOtlpEnvironmentSettings().thenApply(response -> response.body()); + } + + public CompletableFuture deleteOtlpEnvironmentSettings( + RequestOptions requestOptions) { + return this.rawClient.deleteOtlpEnvironmentSettings(requestOptions).thenApply(response -> response.body()); + } + public CompletableFuture getSegmentIntegrationStatus() { return this.rawClient.getSegmentIntegrationStatus().thenApply(response -> response.body()); } diff --git a/src/main/java/com/schematic/api/resources/events/AsyncRawEventsClient.java b/src/main/java/com/schematic/api/resources/events/AsyncRawEventsClient.java index 96e579ee..1525f3fd 100644 --- a/src/main/java/com/schematic/api/resources/events/AsyncRawEventsClient.java +++ b/src/main/java/com/schematic/api/resources/events/AsyncRawEventsClient.java @@ -21,12 +21,16 @@ import com.schematic.api.resources.events.requests.CreateEventBatchRequestBody; import com.schematic.api.resources.events.requests.GetEventSummariesRequest; import com.schematic.api.resources.events.requests.ListEventsRequest; +import com.schematic.api.resources.events.requests.UpsertOtlpEnvironmentSettingsRequestBody; import com.schematic.api.resources.events.types.CreateEventBatchResponse; import com.schematic.api.resources.events.types.CreateEventResponse; +import com.schematic.api.resources.events.types.DeleteOtlpEnvironmentSettingsResponse; import com.schematic.api.resources.events.types.GetEventResponse; import com.schematic.api.resources.events.types.GetEventSummariesResponse; +import com.schematic.api.resources.events.types.GetOtlpEnvironmentSettingsResponse; import com.schematic.api.resources.events.types.GetSegmentIntegrationStatusResponse; import com.schematic.api.resources.events.types.ListEventsResponse; +import com.schematic.api.resources.events.types.UpsertOtlpEnvironmentSettingsResponse; import com.schematic.api.types.ApiError; import com.schematic.api.types.CreateEventRequestBody; import java.io.IOException; @@ -609,6 +613,307 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { return future; } + public CompletableFuture> + getOtlpEnvironmentSettings() { + return getOtlpEnvironmentSettings(null); + } + + public CompletableFuture> getOtlpEnvironmentSettings( + RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("otlp/settings"); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl.build()) + .method("GET", 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); + } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } + 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, GetOtlpEnvironmentSettingsResponse.class), + response)); + return; + } + try { + switch (response.code()) { + 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 (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); + } 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> + upsertOtlpEnvironmentSettings(UpsertOtlpEnvironmentSettingsRequestBody request) { + return upsertOtlpEnvironmentSettings(request, null); + } + + public CompletableFuture> + upsertOtlpEnvironmentSettings( + UpsertOtlpEnvironmentSettingsRequestBody request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("otlp/settings"); + 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); + } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } + 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, UpsertOtlpEnvironmentSettingsResponse.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 (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); + } 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> + deleteOtlpEnvironmentSettings() { + return deleteOtlpEnvironmentSettings(null); + } + + public CompletableFuture> + deleteOtlpEnvironmentSettings(RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("otlp/settings"); + 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); + } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } + 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, DeleteOtlpEnvironmentSettingsResponse.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 (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); + } 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> getSegmentIntegrationStatus() { return getSegmentIntegrationStatus(null); diff --git a/src/main/java/com/schematic/api/resources/events/EventsClient.java b/src/main/java/com/schematic/api/resources/events/EventsClient.java index 200366ea..cca225bc 100644 --- a/src/main/java/com/schematic/api/resources/events/EventsClient.java +++ b/src/main/java/com/schematic/api/resources/events/EventsClient.java @@ -8,12 +8,16 @@ import com.schematic.api.resources.events.requests.CreateEventBatchRequestBody; import com.schematic.api.resources.events.requests.GetEventSummariesRequest; import com.schematic.api.resources.events.requests.ListEventsRequest; +import com.schematic.api.resources.events.requests.UpsertOtlpEnvironmentSettingsRequestBody; import com.schematic.api.resources.events.types.CreateEventBatchResponse; import com.schematic.api.resources.events.types.CreateEventResponse; +import com.schematic.api.resources.events.types.DeleteOtlpEnvironmentSettingsResponse; import com.schematic.api.resources.events.types.GetEventResponse; import com.schematic.api.resources.events.types.GetEventSummariesResponse; +import com.schematic.api.resources.events.types.GetOtlpEnvironmentSettingsResponse; import com.schematic.api.resources.events.types.GetSegmentIntegrationStatusResponse; import com.schematic.api.resources.events.types.ListEventsResponse; +import com.schematic.api.resources.events.types.UpsertOtlpEnvironmentSettingsResponse; import com.schematic.api.types.CreateEventRequestBody; public class EventsClient { @@ -91,6 +95,34 @@ public GetEventResponse getEvent(String eventId, RequestOptions requestOptions) return this.rawClient.getEvent(eventId, requestOptions).body(); } + public GetOtlpEnvironmentSettingsResponse getOtlpEnvironmentSettings() { + return this.rawClient.getOtlpEnvironmentSettings().body(); + } + + public GetOtlpEnvironmentSettingsResponse getOtlpEnvironmentSettings(RequestOptions requestOptions) { + return this.rawClient.getOtlpEnvironmentSettings(requestOptions).body(); + } + + public UpsertOtlpEnvironmentSettingsResponse upsertOtlpEnvironmentSettings( + UpsertOtlpEnvironmentSettingsRequestBody request) { + return this.rawClient.upsertOtlpEnvironmentSettings(request).body(); + } + + public UpsertOtlpEnvironmentSettingsResponse upsertOtlpEnvironmentSettings( + UpsertOtlpEnvironmentSettingsRequestBody request, RequestOptions requestOptions) { + return this.rawClient + .upsertOtlpEnvironmentSettings(request, requestOptions) + .body(); + } + + public DeleteOtlpEnvironmentSettingsResponse deleteOtlpEnvironmentSettings() { + return this.rawClient.deleteOtlpEnvironmentSettings().body(); + } + + public DeleteOtlpEnvironmentSettingsResponse deleteOtlpEnvironmentSettings(RequestOptions requestOptions) { + return this.rawClient.deleteOtlpEnvironmentSettings(requestOptions).body(); + } + public GetSegmentIntegrationStatusResponse getSegmentIntegrationStatus() { return this.rawClient.getSegmentIntegrationStatus().body(); } diff --git a/src/main/java/com/schematic/api/resources/events/RawEventsClient.java b/src/main/java/com/schematic/api/resources/events/RawEventsClient.java index 0358da28..e11dda16 100644 --- a/src/main/java/com/schematic/api/resources/events/RawEventsClient.java +++ b/src/main/java/com/schematic/api/resources/events/RawEventsClient.java @@ -21,12 +21,16 @@ import com.schematic.api.resources.events.requests.CreateEventBatchRequestBody; import com.schematic.api.resources.events.requests.GetEventSummariesRequest; import com.schematic.api.resources.events.requests.ListEventsRequest; +import com.schematic.api.resources.events.requests.UpsertOtlpEnvironmentSettingsRequestBody; import com.schematic.api.resources.events.types.CreateEventBatchResponse; import com.schematic.api.resources.events.types.CreateEventResponse; +import com.schematic.api.resources.events.types.DeleteOtlpEnvironmentSettingsResponse; import com.schematic.api.resources.events.types.GetEventResponse; import com.schematic.api.resources.events.types.GetEventSummariesResponse; +import com.schematic.api.resources.events.types.GetOtlpEnvironmentSettingsResponse; import com.schematic.api.resources.events.types.GetSegmentIntegrationStatusResponse; import com.schematic.api.resources.events.types.ListEventsResponse; +import com.schematic.api.resources.events.types.UpsertOtlpEnvironmentSettingsResponse; import com.schematic.api.types.ApiError; import com.schematic.api.types.CreateEventRequestBody; import java.io.IOException; @@ -478,6 +482,231 @@ public BaseSchematicHttpResponse getEvent(String eventId, Requ } } + public BaseSchematicHttpResponse getOtlpEnvironmentSettings() { + return getOtlpEnvironmentSettings(null); + } + + public BaseSchematicHttpResponse getOtlpEnvironmentSettings( + RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("otlp/settings"); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl.build()) + .method("GET", 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); + } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } + 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, GetOtlpEnvironmentSettingsResponse.class), + response); + } + try { + switch (response.code()) { + 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 (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse upsertOtlpEnvironmentSettings( + UpsertOtlpEnvironmentSettingsRequestBody request) { + return upsertOtlpEnvironmentSettings(request, null); + } + + public BaseSchematicHttpResponse upsertOtlpEnvironmentSettings( + UpsertOtlpEnvironmentSettingsRequestBody request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("otlp/settings"); + 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); + } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } + 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, UpsertOtlpEnvironmentSettingsResponse.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 (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse deleteOtlpEnvironmentSettings() { + return deleteOtlpEnvironmentSettings(null); + } + + public BaseSchematicHttpResponse deleteOtlpEnvironmentSettings( + RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("otlp/settings"); + 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); + } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } + 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, DeleteOtlpEnvironmentSettingsResponse.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 (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + public BaseSchematicHttpResponse getSegmentIntegrationStatus() { return getSegmentIntegrationStatus(null); } diff --git a/src/main/java/com/schematic/api/resources/events/requests/UpsertOtlpEnvironmentSettingsRequestBody.java b/src/main/java/com/schematic/api/resources/events/requests/UpsertOtlpEnvironmentSettingsRequestBody.java new file mode 100644 index 00000000..47149f30 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/events/requests/UpsertOtlpEnvironmentSettingsRequestBody.java @@ -0,0 +1,244 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.events.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.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = UpsertOtlpEnvironmentSettingsRequestBody.Builder.class) +public final class UpsertOtlpEnvironmentSettingsRequestBody { + private final Optional companyAttribute; + + private final Optional companyKey; + + private final boolean toolEventsEnabled; + + private final Optional userAttribute; + + private final Optional userKey; + + private final Map additionalProperties; + + private UpsertOtlpEnvironmentSettingsRequestBody( + Optional companyAttribute, + Optional companyKey, + boolean toolEventsEnabled, + Optional userAttribute, + Optional userKey, + Map additionalProperties) { + this.companyAttribute = companyAttribute; + this.companyKey = companyKey; + this.toolEventsEnabled = toolEventsEnabled; + this.userAttribute = userAttribute; + this.userKey = userKey; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("company_attribute") + public Optional getCompanyAttribute() { + return companyAttribute; + } + + @JsonProperty("company_key") + public Optional getCompanyKey() { + return companyKey; + } + + @JsonProperty("tool_events_enabled") + public boolean getToolEventsEnabled() { + return toolEventsEnabled; + } + + @JsonProperty("user_attribute") + public Optional getUserAttribute() { + return userAttribute; + } + + @JsonProperty("user_key") + public Optional getUserKey() { + return userKey; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof UpsertOtlpEnvironmentSettingsRequestBody + && equalTo((UpsertOtlpEnvironmentSettingsRequestBody) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(UpsertOtlpEnvironmentSettingsRequestBody other) { + return companyAttribute.equals(other.companyAttribute) + && companyKey.equals(other.companyKey) + && toolEventsEnabled == other.toolEventsEnabled + && userAttribute.equals(other.userAttribute) + && userKey.equals(other.userKey); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.companyAttribute, this.companyKey, this.toolEventsEnabled, this.userAttribute, this.userKey); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static ToolEventsEnabledStage builder() { + return new Builder(); + } + + public interface ToolEventsEnabledStage { + _FinalStage toolEventsEnabled(boolean toolEventsEnabled); + + Builder from(UpsertOtlpEnvironmentSettingsRequestBody other); + } + + public interface _FinalStage { + UpsertOtlpEnvironmentSettingsRequestBody build(); + + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); + + _FinalStage companyAttribute(Optional companyAttribute); + + _FinalStage companyAttribute(String companyAttribute); + + _FinalStage companyKey(Optional companyKey); + + _FinalStage companyKey(String companyKey); + + _FinalStage userAttribute(Optional userAttribute); + + _FinalStage userAttribute(String userAttribute); + + _FinalStage userKey(Optional userKey); + + _FinalStage userKey(String userKey); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements ToolEventsEnabledStage, _FinalStage { + private boolean toolEventsEnabled; + + private Optional userKey = Optional.empty(); + + private Optional userAttribute = Optional.empty(); + + private Optional companyKey = Optional.empty(); + + private Optional companyAttribute = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(UpsertOtlpEnvironmentSettingsRequestBody other) { + companyAttribute(other.getCompanyAttribute()); + companyKey(other.getCompanyKey()); + toolEventsEnabled(other.getToolEventsEnabled()); + userAttribute(other.getUserAttribute()); + userKey(other.getUserKey()); + return this; + } + + @java.lang.Override + @JsonSetter("tool_events_enabled") + public _FinalStage toolEventsEnabled(boolean toolEventsEnabled) { + this.toolEventsEnabled = toolEventsEnabled; + return this; + } + + @java.lang.Override + public _FinalStage userKey(String userKey) { + this.userKey = Optional.ofNullable(userKey); + return this; + } + + @java.lang.Override + @JsonSetter(value = "user_key", nulls = Nulls.SKIP) + public _FinalStage userKey(Optional userKey) { + this.userKey = userKey; + return this; + } + + @java.lang.Override + public _FinalStage userAttribute(String userAttribute) { + this.userAttribute = Optional.ofNullable(userAttribute); + return this; + } + + @java.lang.Override + @JsonSetter(value = "user_attribute", nulls = Nulls.SKIP) + public _FinalStage userAttribute(Optional userAttribute) { + this.userAttribute = userAttribute; + return this; + } + + @java.lang.Override + public _FinalStage companyKey(String companyKey) { + this.companyKey = Optional.ofNullable(companyKey); + return this; + } + + @java.lang.Override + @JsonSetter(value = "company_key", nulls = Nulls.SKIP) + public _FinalStage companyKey(Optional companyKey) { + this.companyKey = companyKey; + return this; + } + + @java.lang.Override + public _FinalStage companyAttribute(String companyAttribute) { + this.companyAttribute = Optional.ofNullable(companyAttribute); + return this; + } + + @java.lang.Override + @JsonSetter(value = "company_attribute", nulls = Nulls.SKIP) + public _FinalStage companyAttribute(Optional companyAttribute) { + this.companyAttribute = companyAttribute; + return this; + } + + @java.lang.Override + public UpsertOtlpEnvironmentSettingsRequestBody build() { + return new UpsertOtlpEnvironmentSettingsRequestBody( + companyAttribute, companyKey, toolEventsEnabled, userAttribute, userKey, 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/events/types/DeleteOtlpEnvironmentSettingsResponse.java b/src/main/java/com/schematic/api/resources/events/types/DeleteOtlpEnvironmentSettingsResponse.java new file mode 100644 index 00000000..94db7ad1 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/events/types/DeleteOtlpEnvironmentSettingsResponse.java @@ -0,0 +1,182 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.events.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 = DeleteOtlpEnvironmentSettingsResponse.Builder.class) +public final class DeleteOtlpEnvironmentSettingsResponse { + private final DeleteResponse data; + + private final Map params; + + private final Map additionalProperties; + + private DeleteOtlpEnvironmentSettingsResponse( + 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 DeleteOtlpEnvironmentSettingsResponse + && equalTo((DeleteOtlpEnvironmentSettingsResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DeleteOtlpEnvironmentSettingsResponse 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(DeleteOtlpEnvironmentSettingsResponse other); + } + + public interface _FinalStage { + DeleteOtlpEnvironmentSettingsResponse 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(DeleteOtlpEnvironmentSettingsResponse 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 DeleteOtlpEnvironmentSettingsResponse build() { + return new DeleteOtlpEnvironmentSettingsResponse(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/events/types/GetOtlpEnvironmentSettingsResponse.java b/src/main/java/com/schematic/api/resources/events/types/GetOtlpEnvironmentSettingsResponse.java new file mode 100644 index 00000000..3c0d1491 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/events/types/GetOtlpEnvironmentSettingsResponse.java @@ -0,0 +1,184 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.events.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.OtlpEnvironmentSettingsResponseData; +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 = GetOtlpEnvironmentSettingsResponse.Builder.class) +public final class GetOtlpEnvironmentSettingsResponse { + private final OtlpEnvironmentSettingsResponseData data; + + private final Map params; + + private final Map additionalProperties; + + private GetOtlpEnvironmentSettingsResponse( + OtlpEnvironmentSettingsResponseData data, + Map params, + Map additionalProperties) { + this.data = data; + this.params = params; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("data") + public OtlpEnvironmentSettingsResponseData 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 GetOtlpEnvironmentSettingsResponse + && equalTo((GetOtlpEnvironmentSettingsResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(GetOtlpEnvironmentSettingsResponse 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 OtlpEnvironmentSettingsResponseData data); + + Builder from(GetOtlpEnvironmentSettingsResponse other); + } + + public interface _FinalStage { + GetOtlpEnvironmentSettingsResponse 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 OtlpEnvironmentSettingsResponseData data; + + private Map params = new LinkedHashMap<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(GetOtlpEnvironmentSettingsResponse other) { + data(other.getData()); + params(other.getParams()); + return this; + } + + @java.lang.Override + @JsonSetter("data") + public _FinalStage data(@NotNull OtlpEnvironmentSettingsResponseData 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 GetOtlpEnvironmentSettingsResponse build() { + return new GetOtlpEnvironmentSettingsResponse(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/events/types/UpsertOtlpEnvironmentSettingsResponse.java b/src/main/java/com/schematic/api/resources/events/types/UpsertOtlpEnvironmentSettingsResponse.java new file mode 100644 index 00000000..f9396f77 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/events/types/UpsertOtlpEnvironmentSettingsResponse.java @@ -0,0 +1,184 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.events.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.OtlpEnvironmentSettingsResponseData; +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 = UpsertOtlpEnvironmentSettingsResponse.Builder.class) +public final class UpsertOtlpEnvironmentSettingsResponse { + private final OtlpEnvironmentSettingsResponseData data; + + private final Map params; + + private final Map additionalProperties; + + private UpsertOtlpEnvironmentSettingsResponse( + OtlpEnvironmentSettingsResponseData data, + Map params, + Map additionalProperties) { + this.data = data; + this.params = params; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("data") + public OtlpEnvironmentSettingsResponseData 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 UpsertOtlpEnvironmentSettingsResponse + && equalTo((UpsertOtlpEnvironmentSettingsResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(UpsertOtlpEnvironmentSettingsResponse 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 OtlpEnvironmentSettingsResponseData data); + + Builder from(UpsertOtlpEnvironmentSettingsResponse other); + } + + public interface _FinalStage { + UpsertOtlpEnvironmentSettingsResponse 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 OtlpEnvironmentSettingsResponseData data; + + private Map params = new LinkedHashMap<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(UpsertOtlpEnvironmentSettingsResponse other) { + data(other.getData()); + params(other.getParams()); + return this; + } + + @java.lang.Override + @JsonSetter("data") + public _FinalStage data(@NotNull OtlpEnvironmentSettingsResponseData 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 UpsertOtlpEnvironmentSettingsResponse build() { + return new UpsertOtlpEnvironmentSettingsResponse(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/integrationsapi/AsyncIntegrationsapiClient.java b/src/main/java/com/schematic/api/resources/integrationsapi/AsyncIntegrationsapiClient.java index a92b6824..d6c8d2df 100644 --- a/src/main/java/com/schematic/api/resources/integrationsapi/AsyncIntegrationsapiClient.java +++ b/src/main/java/com/schematic/api/resources/integrationsapi/AsyncIntegrationsapiClient.java @@ -5,13 +5,20 @@ import com.schematic.api.core.ClientOptions; import com.schematic.api.core.RequestOptions; +import com.schematic.api.resources.integrationsapi.requests.ClaimStripeSandboxKeysRequestBody; +import com.schematic.api.resources.integrationsapi.requests.InstallStripeSandboxRequestBody; import com.schematic.api.resources.integrationsapi.requests.ListIntegrationsRequest; import com.schematic.api.resources.integrationsapi.requests.StartDataImportRequestBody; import com.schematic.api.resources.integrationsapi.types.AssumeStripeInstalledResponse; +import com.schematic.api.resources.integrationsapi.types.ClaimStripeSandboxKeysResponse; import com.schematic.api.resources.integrationsapi.types.GetIntegrationWebhookUrlResponse; +import com.schematic.api.resources.integrationsapi.types.GetStripeSandboxClaimLinkResponse; +import com.schematic.api.resources.integrationsapi.types.GetStripeSandboxKeysResponse; import com.schematic.api.resources.integrationsapi.types.InstallIntegrationResponse; +import com.schematic.api.resources.integrationsapi.types.InstallStripeClaimableSandboxResponse; import com.schematic.api.resources.integrationsapi.types.InstallStripeResponse; import com.schematic.api.resources.integrationsapi.types.ListIntegrationsResponse; +import com.schematic.api.resources.integrationsapi.types.ListStripeSandboxCountriesResponse; import com.schematic.api.resources.integrationsapi.types.LoadSampleDataSetResponse; import com.schematic.api.resources.integrationsapi.types.RunIntegrationResponse; import com.schematic.api.resources.integrationsapi.types.StartDataImportResponse; @@ -97,6 +104,33 @@ public CompletableFuture loadSampleDataSet(RequestOpt return this.rawClient.loadSampleDataSet(requestOptions).thenApply(response -> response.body()); } + public CompletableFuture getStripeSandboxClaimLink() { + return this.rawClient.getStripeSandboxClaimLink().thenApply(response -> response.body()); + } + + public CompletableFuture getStripeSandboxClaimLink( + RequestOptions requestOptions) { + return this.rawClient.getStripeSandboxClaimLink(requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture getStripeSandboxKeys() { + return this.rawClient.getStripeSandboxKeys().thenApply(response -> response.body()); + } + + public CompletableFuture getStripeSandboxKeys(RequestOptions requestOptions) { + return this.rawClient.getStripeSandboxKeys(requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture claimStripeSandboxKeys( + ClaimStripeSandboxKeysRequestBody request) { + return this.rawClient.claimStripeSandboxKeys(request).thenApply(response -> response.body()); + } + + public CompletableFuture claimStripeSandboxKeys( + ClaimStripeSandboxKeysRequestBody request, RequestOptions requestOptions) { + return this.rawClient.claimStripeSandboxKeys(request, requestOptions).thenApply(response -> response.body()); + } + public CompletableFuture assumeStripeInstalled( InstallIntegrationRequestBody request) { return this.rawClient.assumeStripeInstalled(request).thenApply(response -> response.body()); @@ -116,6 +150,27 @@ public CompletableFuture installStripe( return this.rawClient.installStripe(request, requestOptions).thenApply(response -> response.body()); } + public CompletableFuture installStripeClaimableSandbox( + InstallStripeSandboxRequestBody request) { + return this.rawClient.installStripeClaimableSandbox(request).thenApply(response -> response.body()); + } + + public CompletableFuture installStripeClaimableSandbox( + InstallStripeSandboxRequestBody request, RequestOptions requestOptions) { + return this.rawClient + .installStripeClaimableSandbox(request, requestOptions) + .thenApply(response -> response.body()); + } + + public CompletableFuture listStripeSandboxCountries() { + return this.rawClient.listStripeSandboxCountries().thenApply(response -> response.body()); + } + + public CompletableFuture listStripeSandboxCountries( + RequestOptions requestOptions) { + return this.rawClient.listStripeSandboxCountries(requestOptions).thenApply(response -> response.body()); + } + public CompletableFuture uninstallIntegration(String integrationId) { return this.rawClient.uninstallIntegration(integrationId).thenApply(response -> response.body()); } diff --git a/src/main/java/com/schematic/api/resources/integrationsapi/AsyncRawIntegrationsapiClient.java b/src/main/java/com/schematic/api/resources/integrationsapi/AsyncRawIntegrationsapiClient.java index c07d0d4a..e62ab1c7 100644 --- a/src/main/java/com/schematic/api/resources/integrationsapi/AsyncRawIntegrationsapiClient.java +++ b/src/main/java/com/schematic/api/resources/integrationsapi/AsyncRawIntegrationsapiClient.java @@ -18,13 +18,20 @@ import com.schematic.api.errors.InternalServerError; import com.schematic.api.errors.NotFoundError; import com.schematic.api.errors.UnauthorizedError; +import com.schematic.api.resources.integrationsapi.requests.ClaimStripeSandboxKeysRequestBody; +import com.schematic.api.resources.integrationsapi.requests.InstallStripeSandboxRequestBody; import com.schematic.api.resources.integrationsapi.requests.ListIntegrationsRequest; import com.schematic.api.resources.integrationsapi.requests.StartDataImportRequestBody; import com.schematic.api.resources.integrationsapi.types.AssumeStripeInstalledResponse; +import com.schematic.api.resources.integrationsapi.types.ClaimStripeSandboxKeysResponse; import com.schematic.api.resources.integrationsapi.types.GetIntegrationWebhookUrlResponse; +import com.schematic.api.resources.integrationsapi.types.GetStripeSandboxClaimLinkResponse; +import com.schematic.api.resources.integrationsapi.types.GetStripeSandboxKeysResponse; import com.schematic.api.resources.integrationsapi.types.InstallIntegrationResponse; +import com.schematic.api.resources.integrationsapi.types.InstallStripeClaimableSandboxResponse; import com.schematic.api.resources.integrationsapi.types.InstallStripeResponse; import com.schematic.api.resources.integrationsapi.types.ListIntegrationsResponse; +import com.schematic.api.resources.integrationsapi.types.ListStripeSandboxCountriesResponse; import com.schematic.api.resources.integrationsapi.types.LoadSampleDataSetResponse; import com.schematic.api.resources.integrationsapi.types.RunIntegrationResponse; import com.schematic.api.resources.integrationsapi.types.StartDataImportResponse; @@ -675,6 +682,297 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { return future; } + public CompletableFuture> getStripeSandboxClaimLink() { + return getStripeSandboxClaimLink(null); + } + + public CompletableFuture> getStripeSandboxClaimLink( + RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("integrations/stripe/sandbox/claim-link"); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl.build()) + .method("GET", 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); + } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } + 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, GetStripeSandboxClaimLinkResponse.class), + response)); + return; + } + try { + switch (response.code()) { + 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 (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); + } 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> getStripeSandboxKeys() { + return getStripeSandboxKeys(null); + } + + public CompletableFuture> getStripeSandboxKeys( + RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("integrations/stripe/sandbox/keys"); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl.build()) + .method("GET", 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); + } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } + 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, GetStripeSandboxKeysResponse.class), + response)); + return; + } + try { + switch (response.code()) { + 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 (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); + } 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> claimStripeSandboxKeys( + ClaimStripeSandboxKeysRequestBody request) { + return claimStripeSandboxKeys(request, null); + } + + public CompletableFuture> claimStripeSandboxKeys( + ClaimStripeSandboxKeysRequestBody request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("integrations/stripe/sandbox/keys/claim"); + 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); + } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } + 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, ClaimStripeSandboxKeysResponse.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 (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); + } 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> assumeStripeInstalled( InstallIntegrationRequestBody request) { return assumeStripeInstalled(request, null); @@ -886,6 +1184,207 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { return future; } + public CompletableFuture> + installStripeClaimableSandbox(InstallStripeSandboxRequestBody request) { + return installStripeClaimableSandbox(request, null); + } + + public CompletableFuture> + installStripeClaimableSandbox(InstallStripeSandboxRequestBody request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("integrations/stripe/v2/sandbox"); + 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); + } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } + 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, InstallStripeClaimableSandboxResponse.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 (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); + } 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> + listStripeSandboxCountries() { + return listStripeSandboxCountries(null); + } + + public CompletableFuture> listStripeSandboxCountries( + RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("integrations/stripe/v2/sandbox-countries"); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl.build()) + .method("GET", 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); + } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } + 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, ListStripeSandboxCountriesResponse.class), + response)); + return; + } + try { + switch (response.code()) { + 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 (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); + } 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> uninstallIntegration( String integrationId) { return uninstallIntegration(integrationId, null); diff --git a/src/main/java/com/schematic/api/resources/integrationsapi/IntegrationsapiClient.java b/src/main/java/com/schematic/api/resources/integrationsapi/IntegrationsapiClient.java index 8677ecbf..800285fc 100644 --- a/src/main/java/com/schematic/api/resources/integrationsapi/IntegrationsapiClient.java +++ b/src/main/java/com/schematic/api/resources/integrationsapi/IntegrationsapiClient.java @@ -5,13 +5,20 @@ import com.schematic.api.core.ClientOptions; import com.schematic.api.core.RequestOptions; +import com.schematic.api.resources.integrationsapi.requests.ClaimStripeSandboxKeysRequestBody; +import com.schematic.api.resources.integrationsapi.requests.InstallStripeSandboxRequestBody; import com.schematic.api.resources.integrationsapi.requests.ListIntegrationsRequest; import com.schematic.api.resources.integrationsapi.requests.StartDataImportRequestBody; import com.schematic.api.resources.integrationsapi.types.AssumeStripeInstalledResponse; +import com.schematic.api.resources.integrationsapi.types.ClaimStripeSandboxKeysResponse; import com.schematic.api.resources.integrationsapi.types.GetIntegrationWebhookUrlResponse; +import com.schematic.api.resources.integrationsapi.types.GetStripeSandboxClaimLinkResponse; +import com.schematic.api.resources.integrationsapi.types.GetStripeSandboxKeysResponse; import com.schematic.api.resources.integrationsapi.types.InstallIntegrationResponse; +import com.schematic.api.resources.integrationsapi.types.InstallStripeClaimableSandboxResponse; import com.schematic.api.resources.integrationsapi.types.InstallStripeResponse; import com.schematic.api.resources.integrationsapi.types.ListIntegrationsResponse; +import com.schematic.api.resources.integrationsapi.types.ListStripeSandboxCountriesResponse; import com.schematic.api.resources.integrationsapi.types.LoadSampleDataSetResponse; import com.schematic.api.resources.integrationsapi.types.RunIntegrationResponse; import com.schematic.api.resources.integrationsapi.types.StartDataImportResponse; @@ -92,6 +99,31 @@ public LoadSampleDataSetResponse loadSampleDataSet(RequestOptions requestOptions return this.rawClient.loadSampleDataSet(requestOptions).body(); } + public GetStripeSandboxClaimLinkResponse getStripeSandboxClaimLink() { + return this.rawClient.getStripeSandboxClaimLink().body(); + } + + public GetStripeSandboxClaimLinkResponse getStripeSandboxClaimLink(RequestOptions requestOptions) { + return this.rawClient.getStripeSandboxClaimLink(requestOptions).body(); + } + + public GetStripeSandboxKeysResponse getStripeSandboxKeys() { + return this.rawClient.getStripeSandboxKeys().body(); + } + + public GetStripeSandboxKeysResponse getStripeSandboxKeys(RequestOptions requestOptions) { + return this.rawClient.getStripeSandboxKeys(requestOptions).body(); + } + + public ClaimStripeSandboxKeysResponse claimStripeSandboxKeys(ClaimStripeSandboxKeysRequestBody request) { + return this.rawClient.claimStripeSandboxKeys(request).body(); + } + + public ClaimStripeSandboxKeysResponse claimStripeSandboxKeys( + ClaimStripeSandboxKeysRequestBody request, RequestOptions requestOptions) { + return this.rawClient.claimStripeSandboxKeys(request, requestOptions).body(); + } + public AssumeStripeInstalledResponse assumeStripeInstalled(InstallIntegrationRequestBody request) { return this.rawClient.assumeStripeInstalled(request).body(); } @@ -109,6 +141,26 @@ public InstallStripeResponse installStripe(InstallIntegrationRequestBody request return this.rawClient.installStripe(request, requestOptions).body(); } + public InstallStripeClaimableSandboxResponse installStripeClaimableSandbox( + InstallStripeSandboxRequestBody request) { + return this.rawClient.installStripeClaimableSandbox(request).body(); + } + + public InstallStripeClaimableSandboxResponse installStripeClaimableSandbox( + InstallStripeSandboxRequestBody request, RequestOptions requestOptions) { + return this.rawClient + .installStripeClaimableSandbox(request, requestOptions) + .body(); + } + + public ListStripeSandboxCountriesResponse listStripeSandboxCountries() { + return this.rawClient.listStripeSandboxCountries().body(); + } + + public ListStripeSandboxCountriesResponse listStripeSandboxCountries(RequestOptions requestOptions) { + return this.rawClient.listStripeSandboxCountries(requestOptions).body(); + } + public UninstallIntegrationResponse uninstallIntegration(String integrationId) { return this.rawClient.uninstallIntegration(integrationId).body(); } diff --git a/src/main/java/com/schematic/api/resources/integrationsapi/RawIntegrationsapiClient.java b/src/main/java/com/schematic/api/resources/integrationsapi/RawIntegrationsapiClient.java index a9fb3278..67d2eb37 100644 --- a/src/main/java/com/schematic/api/resources/integrationsapi/RawIntegrationsapiClient.java +++ b/src/main/java/com/schematic/api/resources/integrationsapi/RawIntegrationsapiClient.java @@ -18,13 +18,20 @@ import com.schematic.api.errors.InternalServerError; import com.schematic.api.errors.NotFoundError; import com.schematic.api.errors.UnauthorizedError; +import com.schematic.api.resources.integrationsapi.requests.ClaimStripeSandboxKeysRequestBody; +import com.schematic.api.resources.integrationsapi.requests.InstallStripeSandboxRequestBody; import com.schematic.api.resources.integrationsapi.requests.ListIntegrationsRequest; import com.schematic.api.resources.integrationsapi.requests.StartDataImportRequestBody; import com.schematic.api.resources.integrationsapi.types.AssumeStripeInstalledResponse; +import com.schematic.api.resources.integrationsapi.types.ClaimStripeSandboxKeysResponse; import com.schematic.api.resources.integrationsapi.types.GetIntegrationWebhookUrlResponse; +import com.schematic.api.resources.integrationsapi.types.GetStripeSandboxClaimLinkResponse; +import com.schematic.api.resources.integrationsapi.types.GetStripeSandboxKeysResponse; import com.schematic.api.resources.integrationsapi.types.InstallIntegrationResponse; +import com.schematic.api.resources.integrationsapi.types.InstallStripeClaimableSandboxResponse; import com.schematic.api.resources.integrationsapi.types.InstallStripeResponse; import com.schematic.api.resources.integrationsapi.types.ListIntegrationsResponse; +import com.schematic.api.resources.integrationsapi.types.ListStripeSandboxCountriesResponse; import com.schematic.api.resources.integrationsapi.types.LoadSampleDataSetResponse; import com.schematic.api.resources.integrationsapi.types.RunIntegrationResponse; import com.schematic.api.resources.integrationsapi.types.StartDataImportResponse; @@ -524,6 +531,225 @@ public BaseSchematicHttpResponse loadSampleDataSet(Re } } + public BaseSchematicHttpResponse getStripeSandboxClaimLink() { + return getStripeSandboxClaimLink(null); + } + + public BaseSchematicHttpResponse getStripeSandboxClaimLink( + RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("integrations/stripe/sandbox/claim-link"); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl.build()) + .method("GET", 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); + } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } + 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, GetStripeSandboxClaimLinkResponse.class), + response); + } + try { + switch (response.code()) { + 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 (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse getStripeSandboxKeys() { + return getStripeSandboxKeys(null); + } + + public BaseSchematicHttpResponse getStripeSandboxKeys(RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("integrations/stripe/sandbox/keys"); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl.build()) + .method("GET", 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); + } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } + 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, GetStripeSandboxKeysResponse.class), + response); + } + try { + switch (response.code()) { + 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 (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse claimStripeSandboxKeys( + ClaimStripeSandboxKeysRequestBody request) { + return claimStripeSandboxKeys(request, null); + } + + public BaseSchematicHttpResponse claimStripeSandboxKeys( + ClaimStripeSandboxKeysRequestBody request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("integrations/stripe/sandbox/keys/claim"); + 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); + } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } + 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, ClaimStripeSandboxKeysResponse.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 (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + public BaseSchematicHttpResponse assumeStripeInstalled( InstallIntegrationRequestBody request) { return assumeStripeInstalled(request, null); @@ -684,6 +910,158 @@ public BaseSchematicHttpResponse installStripe( } } + public BaseSchematicHttpResponse installStripeClaimableSandbox( + InstallStripeSandboxRequestBody request) { + return installStripeClaimableSandbox(request, null); + } + + public BaseSchematicHttpResponse installStripeClaimableSandbox( + InstallStripeSandboxRequestBody request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("integrations/stripe/v2/sandbox"); + 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); + } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } + 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, InstallStripeClaimableSandboxResponse.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 (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse listStripeSandboxCountries() { + return listStripeSandboxCountries(null); + } + + public BaseSchematicHttpResponse listStripeSandboxCountries( + RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("integrations/stripe/v2/sandbox-countries"); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl.build()) + .method("GET", 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); + } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } + 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, ListStripeSandboxCountriesResponse.class), + response); + } + try { + switch (response.code()) { + 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 (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + public BaseSchematicHttpResponse uninstallIntegration(String integrationId) { return uninstallIntegration(integrationId, null); } diff --git a/src/main/java/com/schematic/api/resources/integrationsapi/requests/ClaimStripeSandboxKeysRequestBody.java b/src/main/java/com/schematic/api/resources/integrationsapi/requests/ClaimStripeSandboxKeysRequestBody.java new file mode 100644 index 00000000..48790852 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/integrationsapi/requests/ClaimStripeSandboxKeysRequestBody.java @@ -0,0 +1,118 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.integrationsapi.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ClaimStripeSandboxKeysRequestBody.Builder.class) +public final class ClaimStripeSandboxKeysRequestBody { + private final String token; + + private final Map additionalProperties; + + private ClaimStripeSandboxKeysRequestBody(String token, Map additionalProperties) { + this.token = token; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("token") + public String getToken() { + return token; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ClaimStripeSandboxKeysRequestBody && equalTo((ClaimStripeSandboxKeysRequestBody) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ClaimStripeSandboxKeysRequestBody other) { + return token.equals(other.token); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.token); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static TokenStage builder() { + return new Builder(); + } + + public interface TokenStage { + _FinalStage token(@NotNull String token); + + Builder from(ClaimStripeSandboxKeysRequestBody other); + } + + public interface _FinalStage { + ClaimStripeSandboxKeysRequestBody build(); + + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements TokenStage, _FinalStage { + private String token; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ClaimStripeSandboxKeysRequestBody other) { + token(other.getToken()); + return this; + } + + @java.lang.Override + @JsonSetter("token") + public _FinalStage token(@NotNull String token) { + this.token = Objects.requireNonNull(token, "token must not be null"); + return this; + } + + @java.lang.Override + public ClaimStripeSandboxKeysRequestBody build() { + return new ClaimStripeSandboxKeysRequestBody(token, 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/integrationsapi/requests/InstallStripeSandboxRequestBody.java b/src/main/java/com/schematic/api/resources/integrationsapi/requests/InstallStripeSandboxRequestBody.java new file mode 100644 index 00000000..f664118e --- /dev/null +++ b/src/main/java/com/schematic/api/resources/integrationsapi/requests/InstallStripeSandboxRequestBody.java @@ -0,0 +1,212 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.integrationsapi.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.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 = InstallStripeSandboxRequestBody.Builder.class) +public final class InstallStripeSandboxRequestBody { + private final Optional country; + + private final String email; + + private final Optional name; + + private final Optional seedSampleData; + + private final Map additionalProperties; + + private InstallStripeSandboxRequestBody( + Optional country, + String email, + Optional name, + Optional seedSampleData, + Map additionalProperties) { + this.country = country; + this.email = email; + this.name = name; + this.seedSampleData = seedSampleData; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("country") + public Optional getCountry() { + return country; + } + + @JsonProperty("email") + public String getEmail() { + return email; + } + + @JsonProperty("name") + public Optional getName() { + return name; + } + + @JsonProperty("seed_sample_data") + public Optional getSeedSampleData() { + return seedSampleData; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof InstallStripeSandboxRequestBody && equalTo((InstallStripeSandboxRequestBody) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(InstallStripeSandboxRequestBody other) { + return country.equals(other.country) + && email.equals(other.email) + && name.equals(other.name) + && seedSampleData.equals(other.seedSampleData); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.country, this.email, this.name, this.seedSampleData); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static EmailStage builder() { + return new Builder(); + } + + public interface EmailStage { + _FinalStage email(@NotNull String email); + + Builder from(InstallStripeSandboxRequestBody other); + } + + public interface _FinalStage { + InstallStripeSandboxRequestBody build(); + + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); + + _FinalStage country(Optional country); + + _FinalStage country(String country); + + _FinalStage name(Optional name); + + _FinalStage name(String name); + + _FinalStage seedSampleData(Optional seedSampleData); + + _FinalStage seedSampleData(Boolean seedSampleData); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements EmailStage, _FinalStage { + private String email; + + private Optional seedSampleData = Optional.empty(); + + private Optional name = Optional.empty(); + + private Optional country = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(InstallStripeSandboxRequestBody other) { + country(other.getCountry()); + email(other.getEmail()); + name(other.getName()); + seedSampleData(other.getSeedSampleData()); + return this; + } + + @java.lang.Override + @JsonSetter("email") + public _FinalStage email(@NotNull String email) { + this.email = Objects.requireNonNull(email, "email must not be null"); + return this; + } + + @java.lang.Override + public _FinalStage seedSampleData(Boolean seedSampleData) { + this.seedSampleData = Optional.ofNullable(seedSampleData); + return this; + } + + @java.lang.Override + @JsonSetter(value = "seed_sample_data", nulls = Nulls.SKIP) + public _FinalStage seedSampleData(Optional seedSampleData) { + this.seedSampleData = seedSampleData; + return this; + } + + @java.lang.Override + public _FinalStage name(String name) { + this.name = Optional.ofNullable(name); + return this; + } + + @java.lang.Override + @JsonSetter(value = "name", nulls = Nulls.SKIP) + public _FinalStage name(Optional name) { + this.name = name; + return this; + } + + @java.lang.Override + public _FinalStage country(String country) { + this.country = Optional.ofNullable(country); + return this; + } + + @java.lang.Override + @JsonSetter(value = "country", nulls = Nulls.SKIP) + public _FinalStage country(Optional country) { + this.country = country; + return this; + } + + @java.lang.Override + public InstallStripeSandboxRequestBody build() { + return new InstallStripeSandboxRequestBody(country, email, name, seedSampleData, 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/integrationsapi/types/ClaimStripeSandboxKeysResponse.java b/src/main/java/com/schematic/api/resources/integrationsapi/types/ClaimStripeSandboxKeysResponse.java new file mode 100644 index 00000000..e3c3d957 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/integrationsapi/types/ClaimStripeSandboxKeysResponse.java @@ -0,0 +1,183 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.integrationsapi.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.ClaimedStripeSandboxKeysResponseData; +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 = ClaimStripeSandboxKeysResponse.Builder.class) +public final class ClaimStripeSandboxKeysResponse { + private final ClaimedStripeSandboxKeysResponseData data; + + private final Map params; + + private final Map additionalProperties; + + private ClaimStripeSandboxKeysResponse( + ClaimedStripeSandboxKeysResponseData data, + Map params, + Map additionalProperties) { + this.data = data; + this.params = params; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("data") + public ClaimedStripeSandboxKeysResponseData 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 ClaimStripeSandboxKeysResponse && equalTo((ClaimStripeSandboxKeysResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ClaimStripeSandboxKeysResponse 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 ClaimedStripeSandboxKeysResponseData data); + + Builder from(ClaimStripeSandboxKeysResponse other); + } + + public interface _FinalStage { + ClaimStripeSandboxKeysResponse 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 ClaimedStripeSandboxKeysResponseData data; + + private Map params = new LinkedHashMap<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ClaimStripeSandboxKeysResponse other) { + data(other.getData()); + params(other.getParams()); + return this; + } + + @java.lang.Override + @JsonSetter("data") + public _FinalStage data(@NotNull ClaimedStripeSandboxKeysResponseData 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 ClaimStripeSandboxKeysResponse build() { + return new ClaimStripeSandboxKeysResponse(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/integrationsapi/types/GetStripeSandboxClaimLinkResponse.java b/src/main/java/com/schematic/api/resources/integrationsapi/types/GetStripeSandboxClaimLinkResponse.java new file mode 100644 index 00000000..e11e902d --- /dev/null +++ b/src/main/java/com/schematic/api/resources/integrationsapi/types/GetStripeSandboxClaimLinkResponse.java @@ -0,0 +1,181 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.integrationsapi.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.StripeSandboxClaimLink; +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 = GetStripeSandboxClaimLinkResponse.Builder.class) +public final class GetStripeSandboxClaimLinkResponse { + private final StripeSandboxClaimLink data; + + private final Map params; + + private final Map additionalProperties; + + private GetStripeSandboxClaimLinkResponse( + StripeSandboxClaimLink data, Map params, Map additionalProperties) { + this.data = data; + this.params = params; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("data") + public StripeSandboxClaimLink 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 GetStripeSandboxClaimLinkResponse && equalTo((GetStripeSandboxClaimLinkResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(GetStripeSandboxClaimLinkResponse 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 StripeSandboxClaimLink data); + + Builder from(GetStripeSandboxClaimLinkResponse other); + } + + public interface _FinalStage { + GetStripeSandboxClaimLinkResponse 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 StripeSandboxClaimLink data; + + private Map params = new LinkedHashMap<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(GetStripeSandboxClaimLinkResponse other) { + data(other.getData()); + params(other.getParams()); + return this; + } + + @java.lang.Override + @JsonSetter("data") + public _FinalStage data(@NotNull StripeSandboxClaimLink 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 GetStripeSandboxClaimLinkResponse build() { + return new GetStripeSandboxClaimLinkResponse(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/integrationsapi/types/GetStripeSandboxKeysResponse.java b/src/main/java/com/schematic/api/resources/integrationsapi/types/GetStripeSandboxKeysResponse.java new file mode 100644 index 00000000..5aee81b4 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/integrationsapi/types/GetStripeSandboxKeysResponse.java @@ -0,0 +1,183 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.integrationsapi.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.ClaimedStripeSandboxKeysResponseData; +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 = GetStripeSandboxKeysResponse.Builder.class) +public final class GetStripeSandboxKeysResponse { + private final ClaimedStripeSandboxKeysResponseData data; + + private final Map params; + + private final Map additionalProperties; + + private GetStripeSandboxKeysResponse( + ClaimedStripeSandboxKeysResponseData data, + Map params, + Map additionalProperties) { + this.data = data; + this.params = params; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("data") + public ClaimedStripeSandboxKeysResponseData 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 GetStripeSandboxKeysResponse && equalTo((GetStripeSandboxKeysResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(GetStripeSandboxKeysResponse 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 ClaimedStripeSandboxKeysResponseData data); + + Builder from(GetStripeSandboxKeysResponse other); + } + + public interface _FinalStage { + GetStripeSandboxKeysResponse 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 ClaimedStripeSandboxKeysResponseData data; + + private Map params = new LinkedHashMap<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(GetStripeSandboxKeysResponse other) { + data(other.getData()); + params(other.getParams()); + return this; + } + + @java.lang.Override + @JsonSetter("data") + public _FinalStage data(@NotNull ClaimedStripeSandboxKeysResponseData 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 GetStripeSandboxKeysResponse build() { + return new GetStripeSandboxKeysResponse(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/integrationsapi/types/InstallStripeClaimableSandboxResponse.java b/src/main/java/com/schematic/api/resources/integrationsapi/types/InstallStripeClaimableSandboxResponse.java new file mode 100644 index 00000000..a0878198 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/integrationsapi/types/InstallStripeClaimableSandboxResponse.java @@ -0,0 +1,184 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.integrationsapi.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.StripeSandboxInstallResponseData; +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 = InstallStripeClaimableSandboxResponse.Builder.class) +public final class InstallStripeClaimableSandboxResponse { + private final StripeSandboxInstallResponseData data; + + private final Map params; + + private final Map additionalProperties; + + private InstallStripeClaimableSandboxResponse( + StripeSandboxInstallResponseData data, + Map params, + Map additionalProperties) { + this.data = data; + this.params = params; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("data") + public StripeSandboxInstallResponseData 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 InstallStripeClaimableSandboxResponse + && equalTo((InstallStripeClaimableSandboxResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(InstallStripeClaimableSandboxResponse 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 StripeSandboxInstallResponseData data); + + Builder from(InstallStripeClaimableSandboxResponse other); + } + + public interface _FinalStage { + InstallStripeClaimableSandboxResponse 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 StripeSandboxInstallResponseData data; + + private Map params = new LinkedHashMap<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(InstallStripeClaimableSandboxResponse other) { + data(other.getData()); + params(other.getParams()); + return this; + } + + @java.lang.Override + @JsonSetter("data") + public _FinalStage data(@NotNull StripeSandboxInstallResponseData 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 InstallStripeClaimableSandboxResponse build() { + return new InstallStripeClaimableSandboxResponse(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/integrationsapi/types/ListStripeSandboxCountriesResponse.java b/src/main/java/com/schematic/api/resources/integrationsapi/types/ListStripeSandboxCountriesResponse.java new file mode 100644 index 00000000..b4bc6e60 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/integrationsapi/types/ListStripeSandboxCountriesResponse.java @@ -0,0 +1,184 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.integrationsapi.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.StripeSandboxCountriesResponseData; +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 = ListStripeSandboxCountriesResponse.Builder.class) +public final class ListStripeSandboxCountriesResponse { + private final StripeSandboxCountriesResponseData data; + + private final Map params; + + private final Map additionalProperties; + + private ListStripeSandboxCountriesResponse( + StripeSandboxCountriesResponseData data, + Map params, + Map additionalProperties) { + this.data = data; + this.params = params; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("data") + public StripeSandboxCountriesResponseData 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 ListStripeSandboxCountriesResponse + && equalTo((ListStripeSandboxCountriesResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ListStripeSandboxCountriesResponse 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 StripeSandboxCountriesResponseData data); + + Builder from(ListStripeSandboxCountriesResponse other); + } + + public interface _FinalStage { + ListStripeSandboxCountriesResponse 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 StripeSandboxCountriesResponseData data; + + private Map params = new LinkedHashMap<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ListStripeSandboxCountriesResponse other) { + data(other.getData()); + params(other.getParams()); + return this; + } + + @java.lang.Override + @JsonSetter("data") + public _FinalStage data(@NotNull StripeSandboxCountriesResponseData 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 ListStripeSandboxCountriesResponse build() { + return new ListStripeSandboxCountriesResponse(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/ClaimedStripeSandboxKeysResponseData.java b/src/main/java/com/schematic/api/types/ClaimedStripeSandboxKeysResponseData.java new file mode 100644 index 00000000..4ead9b6c --- /dev/null +++ b/src/main/java/com/schematic/api/types/ClaimedStripeSandboxKeysResponseData.java @@ -0,0 +1,166 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ClaimedStripeSandboxKeysResponseData.Builder.class) +public final class ClaimedStripeSandboxKeysResponseData { + private final String publishable; + + private final String sandboxId; + + private final String secret; + + private final Map additionalProperties; + + private ClaimedStripeSandboxKeysResponseData( + String publishable, String sandboxId, String secret, Map additionalProperties) { + this.publishable = publishable; + this.sandboxId = sandboxId; + this.secret = secret; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("publishable") + public String getPublishable() { + return publishable; + } + + @JsonProperty("sandbox_id") + public String getSandboxId() { + return sandboxId; + } + + @JsonProperty("secret") + public String getSecret() { + return secret; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ClaimedStripeSandboxKeysResponseData + && equalTo((ClaimedStripeSandboxKeysResponseData) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ClaimedStripeSandboxKeysResponseData other) { + return publishable.equals(other.publishable) + && sandboxId.equals(other.sandboxId) + && secret.equals(other.secret); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.publishable, this.sandboxId, this.secret); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static PublishableStage builder() { + return new Builder(); + } + + public interface PublishableStage { + SandboxIdStage publishable(@NotNull String publishable); + + Builder from(ClaimedStripeSandboxKeysResponseData other); + } + + public interface SandboxIdStage { + SecretStage sandboxId(@NotNull String sandboxId); + } + + public interface SecretStage { + _FinalStage secret(@NotNull String secret); + } + + public interface _FinalStage { + ClaimedStripeSandboxKeysResponseData build(); + + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements PublishableStage, SandboxIdStage, SecretStage, _FinalStage { + private String publishable; + + private String sandboxId; + + private String secret; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ClaimedStripeSandboxKeysResponseData other) { + publishable(other.getPublishable()); + sandboxId(other.getSandboxId()); + secret(other.getSecret()); + return this; + } + + @java.lang.Override + @JsonSetter("publishable") + public SandboxIdStage publishable(@NotNull String publishable) { + this.publishable = Objects.requireNonNull(publishable, "publishable must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("sandbox_id") + public SecretStage sandboxId(@NotNull String sandboxId) { + this.sandboxId = Objects.requireNonNull(sandboxId, "sandboxId must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("secret") + public _FinalStage secret(@NotNull String secret) { + this.secret = Objects.requireNonNull(secret, "secret must not be null"); + return this; + } + + @java.lang.Override + public ClaimedStripeSandboxKeysResponseData build() { + return new ClaimedStripeSandboxKeysResponseData(publishable, sandboxId, secret, 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/CompanyBillingProfileResponseData.java b/src/main/java/com/schematic/api/types/CompanyBillingProfileResponseData.java new file mode 100644 index 00000000..ed443285 --- /dev/null +++ b/src/main/java/com/schematic/api/types/CompanyBillingProfileResponseData.java @@ -0,0 +1,504 @@ +/** + * 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 = CompanyBillingProfileResponseData.Builder.class) +public final class CompanyBillingProfileResponseData { + private final String accountId; + + private final Optional billingCustomerId; + + private final BillingCollectionMethod collectionMethod; + + private final String companyId; + + private final OffsetDateTime createdAt; + + private final Optional daysUntilDue; + + private final String environmentId; + + private final String id; + + private final boolean isDefault; + + private final Optional name; + + private final Optional paymentMethodId; + + private final Optional prorationBehavior; + + private final BillingProviderType providerType; + + private final OffsetDateTime updatedAt; + + private final Map additionalProperties; + + private CompanyBillingProfileResponseData( + String accountId, + Optional billingCustomerId, + BillingCollectionMethod collectionMethod, + String companyId, + OffsetDateTime createdAt, + Optional daysUntilDue, + String environmentId, + String id, + boolean isDefault, + Optional name, + Optional paymentMethodId, + Optional prorationBehavior, + BillingProviderType providerType, + OffsetDateTime updatedAt, + Map additionalProperties) { + this.accountId = accountId; + this.billingCustomerId = billingCustomerId; + this.collectionMethod = collectionMethod; + this.companyId = companyId; + this.createdAt = createdAt; + this.daysUntilDue = daysUntilDue; + this.environmentId = environmentId; + this.id = id; + this.isDefault = isDefault; + this.name = name; + this.paymentMethodId = paymentMethodId; + this.prorationBehavior = prorationBehavior; + this.providerType = providerType; + this.updatedAt = updatedAt; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("account_id") + public String getAccountId() { + return accountId; + } + + @JsonProperty("billing_customer_id") + public Optional getBillingCustomerId() { + return billingCustomerId; + } + + @JsonProperty("collection_method") + public BillingCollectionMethod getCollectionMethod() { + return collectionMethod; + } + + @JsonProperty("company_id") + public String getCompanyId() { + return companyId; + } + + @JsonProperty("created_at") + public OffsetDateTime getCreatedAt() { + return createdAt; + } + + @JsonProperty("days_until_due") + public Optional getDaysUntilDue() { + return daysUntilDue; + } + + @JsonProperty("environment_id") + public String getEnvironmentId() { + return environmentId; + } + + @JsonProperty("id") + public String getId() { + return id; + } + + @JsonProperty("is_default") + public boolean getIsDefault() { + return isDefault; + } + + @JsonProperty("name") + public Optional getName() { + return name; + } + + @JsonProperty("payment_method_id") + public Optional getPaymentMethodId() { + return paymentMethodId; + } + + @JsonProperty("proration_behavior") + public Optional getProrationBehavior() { + return prorationBehavior; + } + + @JsonProperty("provider_type") + public BillingProviderType getProviderType() { + return providerType; + } + + @JsonProperty("updated_at") + public OffsetDateTime getUpdatedAt() { + return updatedAt; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CompanyBillingProfileResponseData && equalTo((CompanyBillingProfileResponseData) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CompanyBillingProfileResponseData other) { + return accountId.equals(other.accountId) + && billingCustomerId.equals(other.billingCustomerId) + && collectionMethod.equals(other.collectionMethod) + && companyId.equals(other.companyId) + && createdAt.equals(other.createdAt) + && daysUntilDue.equals(other.daysUntilDue) + && environmentId.equals(other.environmentId) + && id.equals(other.id) + && isDefault == other.isDefault + && name.equals(other.name) + && paymentMethodId.equals(other.paymentMethodId) + && prorationBehavior.equals(other.prorationBehavior) + && providerType.equals(other.providerType) + && updatedAt.equals(other.updatedAt); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.accountId, + this.billingCustomerId, + this.collectionMethod, + this.companyId, + this.createdAt, + this.daysUntilDue, + this.environmentId, + this.id, + this.isDefault, + this.name, + this.paymentMethodId, + this.prorationBehavior, + this.providerType, + this.updatedAt); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static AccountIdStage builder() { + return new Builder(); + } + + public interface AccountIdStage { + CollectionMethodStage accountId(@NotNull String accountId); + + Builder from(CompanyBillingProfileResponseData other); + } + + public interface CollectionMethodStage { + CompanyIdStage collectionMethod(@NotNull BillingCollectionMethod collectionMethod); + } + + public interface CompanyIdStage { + CreatedAtStage companyId(@NotNull String companyId); + } + + public interface CreatedAtStage { + EnvironmentIdStage createdAt(@NotNull OffsetDateTime createdAt); + } + + public interface EnvironmentIdStage { + IdStage environmentId(@NotNull String environmentId); + } + + public interface IdStage { + IsDefaultStage id(@NotNull String id); + } + + public interface IsDefaultStage { + ProviderTypeStage isDefault(boolean isDefault); + } + + public interface ProviderTypeStage { + UpdatedAtStage providerType(@NotNull BillingProviderType providerType); + } + + public interface UpdatedAtStage { + _FinalStage updatedAt(@NotNull OffsetDateTime updatedAt); + } + + public interface _FinalStage { + CompanyBillingProfileResponseData build(); + + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); + + _FinalStage billingCustomerId(Optional billingCustomerId); + + _FinalStage billingCustomerId(String billingCustomerId); + + _FinalStage daysUntilDue(Optional daysUntilDue); + + _FinalStage daysUntilDue(Long daysUntilDue); + + _FinalStage name(Optional name); + + _FinalStage name(String name); + + _FinalStage paymentMethodId(Optional paymentMethodId); + + _FinalStage paymentMethodId(String paymentMethodId); + + _FinalStage prorationBehavior(Optional prorationBehavior); + + _FinalStage prorationBehavior(ProrationBehavior prorationBehavior); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder + implements AccountIdStage, + CollectionMethodStage, + CompanyIdStage, + CreatedAtStage, + EnvironmentIdStage, + IdStage, + IsDefaultStage, + ProviderTypeStage, + UpdatedAtStage, + _FinalStage { + private String accountId; + + private BillingCollectionMethod collectionMethod; + + private String companyId; + + private OffsetDateTime createdAt; + + private String environmentId; + + private String id; + + private boolean isDefault; + + private BillingProviderType providerType; + + private OffsetDateTime updatedAt; + + private Optional prorationBehavior = Optional.empty(); + + private Optional paymentMethodId = Optional.empty(); + + private Optional name = Optional.empty(); + + private Optional daysUntilDue = Optional.empty(); + + private Optional billingCustomerId = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(CompanyBillingProfileResponseData other) { + accountId(other.getAccountId()); + billingCustomerId(other.getBillingCustomerId()); + collectionMethod(other.getCollectionMethod()); + companyId(other.getCompanyId()); + createdAt(other.getCreatedAt()); + daysUntilDue(other.getDaysUntilDue()); + environmentId(other.getEnvironmentId()); + id(other.getId()); + isDefault(other.getIsDefault()); + name(other.getName()); + paymentMethodId(other.getPaymentMethodId()); + prorationBehavior(other.getProrationBehavior()); + providerType(other.getProviderType()); + updatedAt(other.getUpdatedAt()); + return this; + } + + @java.lang.Override + @JsonSetter("account_id") + public CollectionMethodStage accountId(@NotNull String accountId) { + this.accountId = Objects.requireNonNull(accountId, "accountId must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("collection_method") + public CompanyIdStage collectionMethod(@NotNull BillingCollectionMethod collectionMethod) { + this.collectionMethod = Objects.requireNonNull(collectionMethod, "collectionMethod must not be null"); + 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 EnvironmentIdStage createdAt(@NotNull OffsetDateTime createdAt) { + this.createdAt = Objects.requireNonNull(createdAt, "createdAt must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("environment_id") + public IdStage environmentId(@NotNull String environmentId) { + this.environmentId = Objects.requireNonNull(environmentId, "environmentId must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("id") + public IsDefaultStage id(@NotNull String id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("is_default") + public ProviderTypeStage isDefault(boolean isDefault) { + this.isDefault = isDefault; + return this; + } + + @java.lang.Override + @JsonSetter("provider_type") + public UpdatedAtStage providerType(@NotNull BillingProviderType providerType) { + this.providerType = Objects.requireNonNull(providerType, "providerType 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 prorationBehavior(ProrationBehavior prorationBehavior) { + this.prorationBehavior = Optional.ofNullable(prorationBehavior); + return this; + } + + @java.lang.Override + @JsonSetter(value = "proration_behavior", nulls = Nulls.SKIP) + public _FinalStage prorationBehavior(Optional prorationBehavior) { + this.prorationBehavior = prorationBehavior; + return this; + } + + @java.lang.Override + public _FinalStage paymentMethodId(String paymentMethodId) { + this.paymentMethodId = Optional.ofNullable(paymentMethodId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "payment_method_id", nulls = Nulls.SKIP) + public _FinalStage paymentMethodId(Optional paymentMethodId) { + this.paymentMethodId = paymentMethodId; + return this; + } + + @java.lang.Override + public _FinalStage name(String name) { + this.name = Optional.ofNullable(name); + return this; + } + + @java.lang.Override + @JsonSetter(value = "name", nulls = Nulls.SKIP) + public _FinalStage name(Optional name) { + this.name = name; + return this; + } + + @java.lang.Override + public _FinalStage daysUntilDue(Long daysUntilDue) { + this.daysUntilDue = Optional.ofNullable(daysUntilDue); + return this; + } + + @java.lang.Override + @JsonSetter(value = "days_until_due", nulls = Nulls.SKIP) + public _FinalStage daysUntilDue(Optional daysUntilDue) { + this.daysUntilDue = daysUntilDue; + return this; + } + + @java.lang.Override + public _FinalStage billingCustomerId(String billingCustomerId) { + this.billingCustomerId = Optional.ofNullable(billingCustomerId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "billing_customer_id", nulls = Nulls.SKIP) + public _FinalStage billingCustomerId(Optional billingCustomerId) { + this.billingCustomerId = billingCustomerId; + return this; + } + + @java.lang.Override + public CompanyBillingProfileResponseData build() { + return new CompanyBillingProfileResponseData( + accountId, + billingCustomerId, + collectionMethod, + companyId, + createdAt, + daysUntilDue, + environmentId, + id, + isDefault, + name, + paymentMethodId, + prorationBehavior, + providerType, + 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/CompanyDetailResponseData.java b/src/main/java/com/schematic/api/types/CompanyDetailResponseData.java index f3c69286..6e5d7917 100644 --- a/src/main/java/com/schematic/api/types/CompanyDetailResponseData.java +++ b/src/main/java/com/schematic/api/types/CompanyDetailResponseData.java @@ -29,6 +29,10 @@ public final class CompanyDetailResponseData { private final Optional> billingCreditBalances; + private final Optional billingProfile; + + private final Optional> billingProfiles; + private final Optional billingSubscription; private final List billingSubscriptions; @@ -80,6 +84,8 @@ public final class CompanyDetailResponseData { private CompanyDetailResponseData( List addOns, Optional> billingCreditBalances, + Optional billingProfile, + Optional> billingProfiles, Optional billingSubscription, List billingSubscriptions, OffsetDateTime createdAt, @@ -106,6 +112,8 @@ private CompanyDetailResponseData( Map additionalProperties) { this.addOns = addOns; this.billingCreditBalances = billingCreditBalances; + this.billingProfile = billingProfile; + this.billingProfiles = billingProfiles; this.billingSubscription = billingSubscription; this.billingSubscriptions = billingSubscriptions; this.createdAt = createdAt; @@ -142,6 +150,16 @@ public Optional> getBillingCreditBalances() { return billingCreditBalances; } + @JsonProperty("billing_profile") + public Optional getBillingProfile() { + return billingProfile; + } + + @JsonProperty("billing_profiles") + public Optional> getBillingProfiles() { + return billingProfiles; + } + @JsonProperty("billing_subscription") public Optional getBillingSubscription() { return billingSubscription; @@ -274,6 +292,8 @@ public Map getAdditionalProperties() { private boolean equalTo(CompanyDetailResponseData other) { return addOns.equals(other.addOns) && billingCreditBalances.equals(other.billingCreditBalances) + && billingProfile.equals(other.billingProfile) + && billingProfiles.equals(other.billingProfiles) && billingSubscription.equals(other.billingSubscription) && billingSubscriptions.equals(other.billingSubscriptions) && createdAt.equals(other.createdAt) @@ -304,6 +324,8 @@ public int hashCode() { return Objects.hash( this.addOns, this.billingCreditBalances, + this.billingProfile, + this.billingProfiles, this.billingSubscription, this.billingSubscriptions, this.createdAt, @@ -381,6 +403,14 @@ public interface _FinalStage { _FinalStage billingCreditBalances(Map billingCreditBalances); + _FinalStage billingProfile(Optional billingProfile); + + _FinalStage billingProfile(CompanyBillingProfileResponseData billingProfile); + + _FinalStage billingProfiles(Optional> billingProfiles); + + _FinalStage billingProfiles(List billingProfiles); + _FinalStage billingSubscription(Optional billingSubscription); _FinalStage billingSubscription(BillingSubscriptionView billingSubscription); @@ -526,6 +556,10 @@ public static final class Builder private Optional billingSubscription = Optional.empty(); + private Optional> billingProfiles = Optional.empty(); + + private Optional billingProfile = Optional.empty(); + private Optional> billingCreditBalances = Optional.empty(); private List addOns = new ArrayList<>(); @@ -539,6 +573,8 @@ private Builder() {} public Builder from(CompanyDetailResponseData other) { addOns(other.getAddOns()); billingCreditBalances(other.getBillingCreditBalances()); + billingProfile(other.getBillingProfile()); + billingProfiles(other.getBillingProfiles()); billingSubscription(other.getBillingSubscription()); billingSubscriptions(other.getBillingSubscriptions()); createdAt(other.getCreatedAt()); @@ -934,6 +970,32 @@ public _FinalStage billingSubscription(Optional billing return this; } + @java.lang.Override + public _FinalStage billingProfiles(List billingProfiles) { + this.billingProfiles = Optional.ofNullable(billingProfiles); + return this; + } + + @java.lang.Override + @JsonSetter(value = "billing_profiles", nulls = Nulls.SKIP) + public _FinalStage billingProfiles(Optional> billingProfiles) { + this.billingProfiles = billingProfiles; + return this; + } + + @java.lang.Override + public _FinalStage billingProfile(CompanyBillingProfileResponseData billingProfile) { + this.billingProfile = Optional.ofNullable(billingProfile); + return this; + } + + @java.lang.Override + @JsonSetter(value = "billing_profile", nulls = Nulls.SKIP) + public _FinalStage billingProfile(Optional billingProfile) { + this.billingProfile = billingProfile; + return this; + } + @java.lang.Override public _FinalStage billingCreditBalances(Map billingCreditBalances) { this.billingCreditBalances = Optional.ofNullable(billingCreditBalances); @@ -976,6 +1038,8 @@ public CompanyDetailResponseData build() { return new CompanyDetailResponseData( addOns, billingCreditBalances, + billingProfile, + billingProfiles, billingSubscription, billingSubscriptions, createdAt, diff --git a/src/main/java/com/schematic/api/types/CompanyOverrideResponseData.java b/src/main/java/com/schematic/api/types/CompanyOverrideResponseData.java index cb23dbed..d22ec1ea 100644 --- a/src/main/java/com/schematic/api/types/CompanyOverrideResponseData.java +++ b/src/main/java/com/schematic/api/types/CompanyOverrideResponseData.java @@ -56,6 +56,10 @@ public final class CompanyOverrideResponseData { private final Optional valueBool; + private final Optional valueCredit; + + private final Optional valueCreditId; + private final Optional valueNumeric; private final Optional valueTrait; @@ -83,6 +87,8 @@ private CompanyOverrideResponseData( Optional ruleIdUsageExceeded, OffsetDateTime updatedAt, Optional valueBool, + Optional valueCredit, + Optional valueCreditId, Optional valueNumeric, Optional valueTrait, Optional valueTraitId, @@ -104,6 +110,8 @@ private CompanyOverrideResponseData( this.ruleIdUsageExceeded = ruleIdUsageExceeded; this.updatedAt = updatedAt; this.valueBool = valueBool; + this.valueCredit = valueCredit; + this.valueCreditId = valueCreditId; this.valueNumeric = valueNumeric; this.valueTrait = valueTrait; this.valueTraitId = valueTraitId; @@ -191,6 +199,16 @@ public Optional getValueBool() { return valueBool; } + @JsonProperty("value_credit") + public Optional getValueCredit() { + return valueCredit; + } + + @JsonProperty("value_credit_id") + public Optional getValueCreditId() { + return valueCreditId; + } + @JsonProperty("value_numeric") public Optional getValueNumeric() { return valueNumeric; @@ -239,6 +257,8 @@ private boolean equalTo(CompanyOverrideResponseData other) { && ruleIdUsageExceeded.equals(other.ruleIdUsageExceeded) && updatedAt.equals(other.updatedAt) && valueBool.equals(other.valueBool) + && valueCredit.equals(other.valueCredit) + && valueCreditId.equals(other.valueCreditId) && valueNumeric.equals(other.valueNumeric) && valueTrait.equals(other.valueTrait) && valueTraitId.equals(other.valueTraitId) @@ -264,6 +284,8 @@ public int hashCode() { this.ruleIdUsageExceeded, this.updatedAt, this.valueBool, + this.valueCredit, + this.valueCreditId, this.valueNumeric, this.valueTrait, this.valueTraitId, @@ -358,6 +380,14 @@ public interface _FinalStage { _FinalStage valueBool(Boolean valueBool); + _FinalStage valueCredit(Optional valueCredit); + + _FinalStage valueCredit(BillingCreditResponseData valueCredit); + + _FinalStage valueCreditId(Optional valueCreditId); + + _FinalStage valueCreditId(String valueCreditId); + _FinalStage valueNumeric(Optional valueNumeric); _FinalStage valueNumeric(Long valueNumeric); @@ -401,6 +431,10 @@ public static final class Builder private Optional valueNumeric = Optional.empty(); + private Optional valueCreditId = Optional.empty(); + + private Optional valueCredit = Optional.empty(); + private Optional valueBool = Optional.empty(); private Optional ruleIdUsageExceeded = Optional.empty(); @@ -444,6 +478,8 @@ public Builder from(CompanyOverrideResponseData other) { ruleIdUsageExceeded(other.getRuleIdUsageExceeded()); updatedAt(other.getUpdatedAt()); valueBool(other.getValueBool()); + valueCredit(other.getValueCredit()); + valueCreditId(other.getValueCreditId()); valueNumeric(other.getValueNumeric()); valueTrait(other.getValueTrait()); valueTraitId(other.getValueTraitId()); @@ -539,6 +575,32 @@ public _FinalStage valueNumeric(Optional valueNumeric) { return this; } + @java.lang.Override + public _FinalStage valueCreditId(String valueCreditId) { + this.valueCreditId = Optional.ofNullable(valueCreditId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "value_credit_id", nulls = Nulls.SKIP) + public _FinalStage valueCreditId(Optional valueCreditId) { + this.valueCreditId = valueCreditId; + return this; + } + + @java.lang.Override + public _FinalStage valueCredit(BillingCreditResponseData valueCredit) { + this.valueCredit = Optional.ofNullable(valueCredit); + return this; + } + + @java.lang.Override + @JsonSetter(value = "value_credit", nulls = Nulls.SKIP) + public _FinalStage valueCredit(Optional valueCredit) { + this.valueCredit = valueCredit; + return this; + } + @java.lang.Override public _FinalStage valueBool(Boolean valueBool) { this.valueBool = Optional.ofNullable(valueBool); @@ -699,6 +761,8 @@ public CompanyOverrideResponseData build() { ruleIdUsageExceeded, updatedAt, valueBool, + valueCredit, + valueCreditId, valueNumeric, valueTrait, valueTraitId, diff --git a/src/main/java/com/schematic/api/types/CreditSpendPolicyResponseData.java b/src/main/java/com/schematic/api/types/CreditSpendPolicyResponseData.java new file mode 100644 index 00000000..b3c1b39e --- /dev/null +++ b/src/main/java/com/schematic/api/types/CreditSpendPolicyResponseData.java @@ -0,0 +1,359 @@ +/** + * 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 = CreditSpendPolicyResponseData.Builder.class) +public final class CreditSpendPolicyResponseData { + private final String billingCreditId; + + private final Optional companyId; + + private final OffsetDateTime createdAt; + + private final String id; + + private final Optional label; + + private final Optional maxPerDraw; + + private final CreditSpendPolicyScope scopeType; + + private final OffsetDateTime updatedAt; + + private final Optional userId; + + private final Map additionalProperties; + + private CreditSpendPolicyResponseData( + String billingCreditId, + Optional companyId, + OffsetDateTime createdAt, + String id, + Optional label, + Optional maxPerDraw, + CreditSpendPolicyScope scopeType, + OffsetDateTime updatedAt, + Optional userId, + Map additionalProperties) { + this.billingCreditId = billingCreditId; + this.companyId = companyId; + this.createdAt = createdAt; + this.id = id; + this.label = label; + this.maxPerDraw = maxPerDraw; + this.scopeType = scopeType; + this.updatedAt = updatedAt; + this.userId = userId; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("billing_credit_id") + public String getBillingCreditId() { + return billingCreditId; + } + + @JsonProperty("company_id") + public Optional getCompanyId() { + return companyId; + } + + @JsonProperty("created_at") + public OffsetDateTime getCreatedAt() { + return createdAt; + } + + @JsonProperty("id") + public String getId() { + return id; + } + + @JsonProperty("label") + public Optional getLabel() { + return label; + } + + @JsonProperty("max_per_draw") + public Optional getMaxPerDraw() { + return maxPerDraw; + } + + @JsonProperty("scope_type") + public CreditSpendPolicyScope getScopeType() { + return scopeType; + } + + @JsonProperty("updated_at") + public OffsetDateTime getUpdatedAt() { + return updatedAt; + } + + @JsonProperty("user_id") + public Optional getUserId() { + return userId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CreditSpendPolicyResponseData && equalTo((CreditSpendPolicyResponseData) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CreditSpendPolicyResponseData other) { + return billingCreditId.equals(other.billingCreditId) + && companyId.equals(other.companyId) + && createdAt.equals(other.createdAt) + && id.equals(other.id) + && label.equals(other.label) + && maxPerDraw.equals(other.maxPerDraw) + && scopeType.equals(other.scopeType) + && updatedAt.equals(other.updatedAt) + && userId.equals(other.userId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.billingCreditId, + this.companyId, + this.createdAt, + this.id, + this.label, + this.maxPerDraw, + this.scopeType, + this.updatedAt, + this.userId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static BillingCreditIdStage builder() { + return new Builder(); + } + + public interface BillingCreditIdStage { + CreatedAtStage billingCreditId(@NotNull String billingCreditId); + + Builder from(CreditSpendPolicyResponseData other); + } + + public interface CreatedAtStage { + IdStage createdAt(@NotNull OffsetDateTime createdAt); + } + + public interface IdStage { + ScopeTypeStage id(@NotNull String id); + } + + public interface ScopeTypeStage { + UpdatedAtStage scopeType(@NotNull CreditSpendPolicyScope scopeType); + } + + public interface UpdatedAtStage { + _FinalStage updatedAt(@NotNull OffsetDateTime updatedAt); + } + + public interface _FinalStage { + CreditSpendPolicyResponseData build(); + + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); + + _FinalStage companyId(Optional companyId); + + _FinalStage companyId(String companyId); + + _FinalStage label(Optional label); + + _FinalStage label(String label); + + _FinalStage maxPerDraw(Optional maxPerDraw); + + _FinalStage maxPerDraw(Double maxPerDraw); + + _FinalStage userId(Optional userId); + + _FinalStage userId(String userId); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder + implements BillingCreditIdStage, CreatedAtStage, IdStage, ScopeTypeStage, UpdatedAtStage, _FinalStage { + private String billingCreditId; + + private OffsetDateTime createdAt; + + private String id; + + private CreditSpendPolicyScope scopeType; + + private OffsetDateTime updatedAt; + + private Optional userId = Optional.empty(); + + private Optional maxPerDraw = Optional.empty(); + + private Optional label = Optional.empty(); + + private Optional companyId = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(CreditSpendPolicyResponseData other) { + billingCreditId(other.getBillingCreditId()); + companyId(other.getCompanyId()); + createdAt(other.getCreatedAt()); + id(other.getId()); + label(other.getLabel()); + maxPerDraw(other.getMaxPerDraw()); + scopeType(other.getScopeType()); + updatedAt(other.getUpdatedAt()); + userId(other.getUserId()); + return this; + } + + @java.lang.Override + @JsonSetter("billing_credit_id") + public CreatedAtStage billingCreditId(@NotNull String billingCreditId) { + this.billingCreditId = Objects.requireNonNull(billingCreditId, "billingCreditId must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("created_at") + public IdStage createdAt(@NotNull OffsetDateTime createdAt) { + this.createdAt = Objects.requireNonNull(createdAt, "createdAt must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("id") + public ScopeTypeStage id(@NotNull String id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("scope_type") + public UpdatedAtStage scopeType(@NotNull CreditSpendPolicyScope scopeType) { + this.scopeType = Objects.requireNonNull(scopeType, "scopeType 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 userId(String userId) { + this.userId = Optional.ofNullable(userId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "user_id", nulls = Nulls.SKIP) + public _FinalStage userId(Optional userId) { + this.userId = userId; + return this; + } + + @java.lang.Override + public _FinalStage maxPerDraw(Double maxPerDraw) { + this.maxPerDraw = Optional.ofNullable(maxPerDraw); + return this; + } + + @java.lang.Override + @JsonSetter(value = "max_per_draw", nulls = Nulls.SKIP) + public _FinalStage maxPerDraw(Optional maxPerDraw) { + this.maxPerDraw = maxPerDraw; + return this; + } + + @java.lang.Override + public _FinalStage label(String label) { + this.label = Optional.ofNullable(label); + return this; + } + + @java.lang.Override + @JsonSetter(value = "label", nulls = Nulls.SKIP) + public _FinalStage label(Optional label) { + this.label = label; + return this; + } + + @java.lang.Override + public _FinalStage companyId(String companyId) { + this.companyId = Optional.ofNullable(companyId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "company_id", nulls = Nulls.SKIP) + public _FinalStage companyId(Optional companyId) { + this.companyId = companyId; + return this; + } + + @java.lang.Override + public CreditSpendPolicyResponseData build() { + return new CreditSpendPolicyResponseData( + billingCreditId, + companyId, + createdAt, + id, + label, + maxPerDraw, + scopeType, + updatedAt, + userId, + 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/CreditSpendPolicyScope.java b/src/main/java/com/schematic/api/types/CreditSpendPolicyScope.java new file mode 100644 index 00000000..95943d1e --- /dev/null +++ b/src/main/java/com/schematic/api/types/CreditSpendPolicyScope.java @@ -0,0 +1,94 @@ +/** + * 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 CreditSpendPolicyScope { + public static final CreditSpendPolicyScope USER = new CreditSpendPolicyScope(Value.USER, "user"); + + public static final CreditSpendPolicyScope COMPANY = new CreditSpendPolicyScope(Value.COMPANY, "company"); + + public static final CreditSpendPolicyScope GROUP = new CreditSpendPolicyScope(Value.GROUP, "group"); + + private final Value value; + + private final String string; + + CreditSpendPolicyScope(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 CreditSpendPolicyScope + && this.string.equals(((CreditSpendPolicyScope) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case USER: + return visitor.visitUser(); + case COMPANY: + return visitor.visitCompany(); + case GROUP: + return visitor.visitGroup(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static CreditSpendPolicyScope valueOf(String value) { + switch (value) { + case "user": + return USER; + case "company": + return COMPANY; + case "group": + return GROUP; + default: + return new CreditSpendPolicyScope(Value.UNKNOWN, value); + } + } + + public enum Value { + COMPANY, + + USER, + + GROUP, + + UNKNOWN + } + + public interface Visitor { + T visitCompany(); + + T visitUser(); + + T visitGroup(); + + T visitUnknown(String unknownType); + } +} diff --git a/src/main/java/com/schematic/api/types/EventBodyInference.java b/src/main/java/com/schematic/api/types/EventBodyInference.java index 876e1db7..921a954a 100644 --- a/src/main/java/com/schematic/api/types/EventBodyInference.java +++ b/src/main/java/com/schematic/api/types/EventBodyInference.java @@ -22,6 +22,8 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = EventBodyInference.Builder.class) public final class EventBodyInference { + private final Optional cacheCreationInputTokens; + private final Optional cachedInputTokens; private final Map company; @@ -53,6 +55,7 @@ public final class EventBodyInference { private final Map additionalProperties; private EventBodyInference( + Optional cacheCreationInputTokens, Optional cachedInputTokens, Map company, Optional cost, @@ -68,6 +71,7 @@ private EventBodyInference( String responseModel, Optional> user, Map additionalProperties) { + this.cacheCreationInputTokens = cacheCreationInputTokens; this.cachedInputTokens = cachedInputTokens; this.company = company; this.cost = cost; @@ -86,7 +90,15 @@ private EventBodyInference( } /** - * @return Number of input tokens served from cache + * @return Number of input tokens written to a prompt cache; a subset of input_tokens + */ + @JsonProperty("cache_creation_input_tokens") + public Optional getCacheCreationInputTokens() { + return cacheCreationInputTokens; + } + + /** + * @return Number of input tokens served from cache; a subset of input_tokens */ @JsonProperty("cached_input_tokens") public Optional getCachedInputTokens() { @@ -126,7 +138,7 @@ public Optional getEvent() { } /** - * @return Number of input tokens for the inference request + * @return Total number of input tokens for the inference request, including those served from and written to a prompt cache */ @JsonProperty("input_tokens") public long getInputTokens() { @@ -209,7 +221,8 @@ public Map getAdditionalProperties() { } private boolean equalTo(EventBodyInference other) { - return cachedInputTokens.equals(other.cachedInputTokens) + return cacheCreationInputTokens.equals(other.cacheCreationInputTokens) + && cachedInputTokens.equals(other.cachedInputTokens) && company.equals(other.company) && cost.equals(other.cost) && currency.equals(other.currency) @@ -228,6 +241,7 @@ private boolean equalTo(EventBodyInference other) { @java.lang.Override public int hashCode() { return Objects.hash( + this.cacheCreationInputTokens, this.cachedInputTokens, this.company, this.cost, @@ -255,7 +269,7 @@ public static InputTokensStage builder() { public interface InputTokensStage { /** - *

Number of input tokens for the inference request

+ *

Total number of input tokens for the inference request, including those served from and written to a prompt cache

*/ OutputTokensStage inputTokens(long inputTokens); @@ -291,7 +305,14 @@ public interface _FinalStage { _FinalStage additionalProperties(Map additionalProperties); /** - *

Number of input tokens served from cache

+ *

Number of input tokens written to a prompt cache; a subset of input_tokens

+ */ + _FinalStage cacheCreationInputTokens(Optional cacheCreationInputTokens); + + _FinalStage cacheCreationInputTokens(Long cacheCreationInputTokens); + + /** + *

Number of input tokens served from cache; a subset of input_tokens

*/ _FinalStage cachedInputTokens(Optional cachedInputTokens); @@ -394,6 +415,8 @@ public static final class Builder private Optional cachedInputTokens = Optional.empty(); + private Optional cacheCreationInputTokens = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -401,6 +424,7 @@ private Builder() {} @java.lang.Override public Builder from(EventBodyInference other) { + cacheCreationInputTokens(other.getCacheCreationInputTokens()); cachedInputTokens(other.getCachedInputTokens()); company(other.getCompany()); cost(other.getCost()); @@ -419,7 +443,7 @@ public Builder from(EventBodyInference other) { } /** - *

Number of input tokens for the inference request

+ *

Total number of input tokens for the inference request, including those served from and written to a prompt cache

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -658,7 +682,7 @@ public _FinalStage company(Map company) { } /** - *

Number of input tokens served from cache

+ *

Number of input tokens served from cache; a subset of input_tokens

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -668,7 +692,7 @@ public _FinalStage cachedInputTokens(Long cachedInputTokens) { } /** - *

Number of input tokens served from cache

+ *

Number of input tokens served from cache; a subset of input_tokens

*/ @java.lang.Override @JsonSetter(value = "cached_input_tokens", nulls = Nulls.SKIP) @@ -677,9 +701,30 @@ public _FinalStage cachedInputTokens(Optional cachedInputTokens) { return this; } + /** + *

Number of input tokens written to a prompt cache; a subset of input_tokens

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

Number of input tokens written to a prompt cache; a subset of input_tokens

+ */ + @java.lang.Override + @JsonSetter(value = "cache_creation_input_tokens", nulls = Nulls.SKIP) + public _FinalStage cacheCreationInputTokens(Optional cacheCreationInputTokens) { + this.cacheCreationInputTokens = cacheCreationInputTokens; + return this; + } + @java.lang.Override public EventBodyInference build() { return new EventBodyInference( + cacheCreationInputTokens, cachedInputTokens, company, cost, diff --git a/src/main/java/com/schematic/api/types/GetOnboardingStateResp.java b/src/main/java/com/schematic/api/types/GetOnboardingStateResp.java index 78649fa1..bbbce83a 100644 --- a/src/main/java/com/schematic/api/types/GetOnboardingStateResp.java +++ b/src/main/java/com/schematic/api/types/GetOnboardingStateResp.java @@ -25,6 +25,8 @@ public final class GetOnboardingStateResp { private final Optional agentConnectedAt; + private final Optional country; + private final Optional dismissedAt; private final Optional environmentId; @@ -49,6 +51,7 @@ public final class GetOnboardingStateResp { private GetOnboardingStateResp( Optional agentConnectedAt, + Optional country, Optional dismissedAt, Optional environmentId, List milestones, @@ -61,6 +64,7 @@ private GetOnboardingStateResp( Optional websiteUrl, Map additionalProperties) { this.agentConnectedAt = agentConnectedAt; + this.country = country; this.dismissedAt = dismissedAt; this.environmentId = environmentId; this.milestones = milestones; @@ -79,6 +83,11 @@ public Optional getAgentConnectedAt() { return agentConnectedAt; } + @JsonProperty("country") + public Optional getCountry() { + return country; + } + @JsonProperty("dismissed_at") public Optional getDismissedAt() { return dismissedAt; @@ -142,6 +151,7 @@ public Map getAdditionalProperties() { private boolean equalTo(GetOnboardingStateResp other) { return agentConnectedAt.equals(other.agentConnectedAt) + && country.equals(other.country) && dismissedAt.equals(other.dismissedAt) && environmentId.equals(other.environmentId) && milestones.equals(other.milestones) @@ -158,6 +168,7 @@ private boolean equalTo(GetOnboardingStateResp other) { public int hashCode() { return Objects.hash( this.agentConnectedAt, + this.country, this.dismissedAt, this.environmentId, this.milestones, @@ -183,6 +194,8 @@ public static Builder builder() { public static final class Builder { private Optional agentConnectedAt = Optional.empty(); + private Optional country = Optional.empty(); + private Optional dismissedAt = Optional.empty(); private Optional environmentId = Optional.empty(); @@ -210,6 +223,7 @@ private Builder() {} public Builder from(GetOnboardingStateResp other) { agentConnectedAt(other.getAgentConnectedAt()); + country(other.getCountry()); dismissedAt(other.getDismissedAt()); environmentId(other.getEnvironmentId()); milestones(other.getMilestones()); @@ -234,6 +248,17 @@ public Builder agentConnectedAt(OffsetDateTime agentConnectedAt) { return this; } + @JsonSetter(value = "country", nulls = Nulls.SKIP) + public Builder country(Optional country) { + this.country = country; + return this; + } + + public Builder country(String country) { + this.country = Optional.ofNullable(country); + return this; + } + @JsonSetter(value = "dismissed_at", nulls = Nulls.SKIP) public Builder dismissedAt(Optional dismissedAt) { this.dismissedAt = dismissedAt; @@ -377,6 +402,7 @@ public Builder websiteUrl(String websiteUrl) { public GetOnboardingStateResp build() { return new GetOnboardingStateResp( agentConnectedAt, + country, dismissedAt, environmentId, milestones, diff --git a/src/main/java/com/schematic/api/types/OtlpEnvironmentSettingsResponseData.java b/src/main/java/com/schematic/api/types/OtlpEnvironmentSettingsResponseData.java new file mode 100644 index 00000000..2bf807b0 --- /dev/null +++ b/src/main/java/com/schematic/api/types/OtlpEnvironmentSettingsResponseData.java @@ -0,0 +1,334 @@ +/** + * 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 = OtlpEnvironmentSettingsResponseData.Builder.class) +public final class OtlpEnvironmentSettingsResponseData { + private final Optional companyAttribute; + + private final Optional companyKey; + + private final OffsetDateTime createdAt; + + private final String environmentId; + + private final boolean toolEventsEnabled; + + private final OffsetDateTime updatedAt; + + private final Optional userAttribute; + + private final Optional userKey; + + private final Map additionalProperties; + + private OtlpEnvironmentSettingsResponseData( + Optional companyAttribute, + Optional companyKey, + OffsetDateTime createdAt, + String environmentId, + boolean toolEventsEnabled, + OffsetDateTime updatedAt, + Optional userAttribute, + Optional userKey, + Map additionalProperties) { + this.companyAttribute = companyAttribute; + this.companyKey = companyKey; + this.createdAt = createdAt; + this.environmentId = environmentId; + this.toolEventsEnabled = toolEventsEnabled; + this.updatedAt = updatedAt; + this.userAttribute = userAttribute; + this.userKey = userKey; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("company_attribute") + public Optional getCompanyAttribute() { + return companyAttribute; + } + + @JsonProperty("company_key") + public Optional getCompanyKey() { + return companyKey; + } + + @JsonProperty("created_at") + public OffsetDateTime getCreatedAt() { + return createdAt; + } + + @JsonProperty("environment_id") + public String getEnvironmentId() { + return environmentId; + } + + @JsonProperty("tool_events_enabled") + public boolean getToolEventsEnabled() { + return toolEventsEnabled; + } + + @JsonProperty("updated_at") + public OffsetDateTime getUpdatedAt() { + return updatedAt; + } + + @JsonProperty("user_attribute") + public Optional getUserAttribute() { + return userAttribute; + } + + @JsonProperty("user_key") + public Optional getUserKey() { + return userKey; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof OtlpEnvironmentSettingsResponseData + && equalTo((OtlpEnvironmentSettingsResponseData) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(OtlpEnvironmentSettingsResponseData other) { + return companyAttribute.equals(other.companyAttribute) + && companyKey.equals(other.companyKey) + && createdAt.equals(other.createdAt) + && environmentId.equals(other.environmentId) + && toolEventsEnabled == other.toolEventsEnabled + && updatedAt.equals(other.updatedAt) + && userAttribute.equals(other.userAttribute) + && userKey.equals(other.userKey); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.companyAttribute, + this.companyKey, + this.createdAt, + this.environmentId, + this.toolEventsEnabled, + this.updatedAt, + this.userAttribute, + this.userKey); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static CreatedAtStage builder() { + return new Builder(); + } + + public interface CreatedAtStage { + EnvironmentIdStage createdAt(@NotNull OffsetDateTime createdAt); + + Builder from(OtlpEnvironmentSettingsResponseData other); + } + + public interface EnvironmentIdStage { + ToolEventsEnabledStage environmentId(@NotNull String environmentId); + } + + public interface ToolEventsEnabledStage { + UpdatedAtStage toolEventsEnabled(boolean toolEventsEnabled); + } + + public interface UpdatedAtStage { + _FinalStage updatedAt(@NotNull OffsetDateTime updatedAt); + } + + public interface _FinalStage { + OtlpEnvironmentSettingsResponseData build(); + + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); + + _FinalStage companyAttribute(Optional companyAttribute); + + _FinalStage companyAttribute(String companyAttribute); + + _FinalStage companyKey(Optional companyKey); + + _FinalStage companyKey(String companyKey); + + _FinalStage userAttribute(Optional userAttribute); + + _FinalStage userAttribute(String userAttribute); + + _FinalStage userKey(Optional userKey); + + _FinalStage userKey(String userKey); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder + implements CreatedAtStage, EnvironmentIdStage, ToolEventsEnabledStage, UpdatedAtStage, _FinalStage { + private OffsetDateTime createdAt; + + private String environmentId; + + private boolean toolEventsEnabled; + + private OffsetDateTime updatedAt; + + private Optional userKey = Optional.empty(); + + private Optional userAttribute = Optional.empty(); + + private Optional companyKey = Optional.empty(); + + private Optional companyAttribute = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(OtlpEnvironmentSettingsResponseData other) { + companyAttribute(other.getCompanyAttribute()); + companyKey(other.getCompanyKey()); + createdAt(other.getCreatedAt()); + environmentId(other.getEnvironmentId()); + toolEventsEnabled(other.getToolEventsEnabled()); + updatedAt(other.getUpdatedAt()); + userAttribute(other.getUserAttribute()); + userKey(other.getUserKey()); + return this; + } + + @java.lang.Override + @JsonSetter("created_at") + public EnvironmentIdStage createdAt(@NotNull OffsetDateTime createdAt) { + this.createdAt = Objects.requireNonNull(createdAt, "createdAt must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("environment_id") + public ToolEventsEnabledStage environmentId(@NotNull String environmentId) { + this.environmentId = Objects.requireNonNull(environmentId, "environmentId must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("tool_events_enabled") + public UpdatedAtStage toolEventsEnabled(boolean toolEventsEnabled) { + this.toolEventsEnabled = toolEventsEnabled; + 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 userKey(String userKey) { + this.userKey = Optional.ofNullable(userKey); + return this; + } + + @java.lang.Override + @JsonSetter(value = "user_key", nulls = Nulls.SKIP) + public _FinalStage userKey(Optional userKey) { + this.userKey = userKey; + return this; + } + + @java.lang.Override + public _FinalStage userAttribute(String userAttribute) { + this.userAttribute = Optional.ofNullable(userAttribute); + return this; + } + + @java.lang.Override + @JsonSetter(value = "user_attribute", nulls = Nulls.SKIP) + public _FinalStage userAttribute(Optional userAttribute) { + this.userAttribute = userAttribute; + return this; + } + + @java.lang.Override + public _FinalStage companyKey(String companyKey) { + this.companyKey = Optional.ofNullable(companyKey); + return this; + } + + @java.lang.Override + @JsonSetter(value = "company_key", nulls = Nulls.SKIP) + public _FinalStage companyKey(Optional companyKey) { + this.companyKey = companyKey; + return this; + } + + @java.lang.Override + public _FinalStage companyAttribute(String companyAttribute) { + this.companyAttribute = Optional.ofNullable(companyAttribute); + return this; + } + + @java.lang.Override + @JsonSetter(value = "company_attribute", nulls = Nulls.SKIP) + public _FinalStage companyAttribute(Optional companyAttribute) { + this.companyAttribute = companyAttribute; + return this; + } + + @java.lang.Override + public OtlpEnvironmentSettingsResponseData build() { + return new OtlpEnvironmentSettingsResponseData( + companyAttribute, + companyKey, + createdAt, + environmentId, + toolEventsEnabled, + updatedAt, + userAttribute, + userKey, + 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/RuleConditionDetailResponseData.java b/src/main/java/com/schematic/api/types/RuleConditionDetailResponseData.java index 0f9d26a9..9392e6be 100644 --- a/src/main/java/com/schematic/api/types/RuleConditionDetailResponseData.java +++ b/src/main/java/com/schematic/api/types/RuleConditionDetailResponseData.java @@ -50,6 +50,8 @@ public final class RuleConditionDetailResponseData { private final ComparableOperator operator; + private final Optional> planVersions; + private final List resourceIds; private final List resources; @@ -82,6 +84,7 @@ private RuleConditionDetailResponseData( Optional metricPeriodMonthReset, Optional metricValue, ComparableOperator operator, + Optional> planVersions, List resourceIds, List resources, String ruleId, @@ -104,6 +107,7 @@ private RuleConditionDetailResponseData( this.metricPeriodMonthReset = metricPeriodMonthReset; this.metricValue = metricValue; this.operator = operator; + this.planVersions = planVersions; this.resourceIds = resourceIds; this.resources = resources; this.ruleId = ruleId; @@ -180,6 +184,11 @@ public ComparableOperator getOperator() { return operator; } + @JsonProperty("plan_versions") + public Optional> getPlanVersions() { + return planVersions; + } + @JsonProperty("resource_ids") public List getResourceIds() { return resourceIds; @@ -245,6 +254,7 @@ private boolean equalTo(RuleConditionDetailResponseData other) { && metricPeriodMonthReset.equals(other.metricPeriodMonthReset) && metricValue.equals(other.metricValue) && operator.equals(other.operator) + && planVersions.equals(other.planVersions) && resourceIds.equals(other.resourceIds) && resources.equals(other.resources) && ruleId.equals(other.ruleId) @@ -271,6 +281,7 @@ public int hashCode() { this.metricPeriodMonthReset, this.metricValue, this.operator, + this.planVersions, this.resourceIds, this.resources, this.ruleId, @@ -363,6 +374,10 @@ public interface _FinalStage { _FinalStage metricValue(Long metricValue); + _FinalStage planVersions(Optional> planVersions); + + _FinalStage planVersions(List planVersions); + _FinalStage resourceIds(List resourceIds); _FinalStage addResourceIds(String resourceIds); @@ -425,6 +440,8 @@ public static final class Builder private List resourceIds = new ArrayList<>(); + private Optional> planVersions = Optional.empty(); + private Optional metricValue = Optional.empty(); private Optional metricPeriodMonthReset = Optional.empty(); @@ -461,6 +478,7 @@ public Builder from(RuleConditionDetailResponseData other) { metricPeriodMonthReset(other.getMetricPeriodMonthReset()); metricValue(other.getMetricValue()); operator(other.getOperator()); + planVersions(other.getPlanVersions()); resourceIds(other.getResourceIds()); resources(other.getResources()); ruleId(other.getRuleId()); @@ -615,6 +633,19 @@ public _FinalStage resourceIds(List resourceIds) { return this; } + @java.lang.Override + public _FinalStage planVersions(List planVersions) { + this.planVersions = Optional.ofNullable(planVersions); + return this; + } + + @java.lang.Override + @JsonSetter(value = "plan_versions", nulls = Nulls.SKIP) + public _FinalStage planVersions(Optional> planVersions) { + this.planVersions = planVersions; + return this; + } + @java.lang.Override public _FinalStage metricValue(Long metricValue) { this.metricValue = Optional.ofNullable(metricValue); @@ -735,6 +766,7 @@ public RuleConditionDetailResponseData build() { metricPeriodMonthReset, metricValue, operator, + planVersions, resourceIds, resources, ruleId, diff --git a/src/main/java/com/schematic/api/types/RuleConditionPlanVersionResponseData.java b/src/main/java/com/schematic/api/types/RuleConditionPlanVersionResponseData.java new file mode 100644 index 00000000..7e3f4613 --- /dev/null +++ b/src/main/java/com/schematic/api/types/RuleConditionPlanVersionResponseData.java @@ -0,0 +1,189 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = RuleConditionPlanVersionResponseData.Builder.class) +public final class RuleConditionPlanVersionResponseData { + private final String id; + + private final String name; + + private final PlanVersionStatus status; + + private final long version; + + private final Map additionalProperties; + + private RuleConditionPlanVersionResponseData( + String id, String name, PlanVersionStatus status, long version, Map additionalProperties) { + this.id = id; + this.name = name; + this.status = status; + this.version = version; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("id") + public String getId() { + return id; + } + + @JsonProperty("name") + public String getName() { + return name; + } + + @JsonProperty("status") + public PlanVersionStatus getStatus() { + return status; + } + + @JsonProperty("version") + public long getVersion() { + return version; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof RuleConditionPlanVersionResponseData + && equalTo((RuleConditionPlanVersionResponseData) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(RuleConditionPlanVersionResponseData other) { + return id.equals(other.id) + && name.equals(other.name) + && status.equals(other.status) + && version == other.version; + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.id, this.name, this.status, this.version); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + NameStage id(@NotNull String id); + + Builder from(RuleConditionPlanVersionResponseData other); + } + + public interface NameStage { + StatusStage name(@NotNull String name); + } + + public interface StatusStage { + VersionStage status(@NotNull PlanVersionStatus status); + } + + public interface VersionStage { + _FinalStage version(long version); + } + + public interface _FinalStage { + RuleConditionPlanVersionResponseData build(); + + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements IdStage, NameStage, StatusStage, VersionStage, _FinalStage { + private String id; + + private String name; + + private PlanVersionStatus status; + + private long version; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(RuleConditionPlanVersionResponseData other) { + id(other.getId()); + name(other.getName()); + status(other.getStatus()); + version(other.getVersion()); + return this; + } + + @java.lang.Override + @JsonSetter("id") + public NameStage id(@NotNull String id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("name") + public StatusStage name(@NotNull String name) { + this.name = Objects.requireNonNull(name, "name must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("status") + public VersionStage status(@NotNull PlanVersionStatus status) { + this.status = Objects.requireNonNull(status, "status must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("version") + public _FinalStage version(long version) { + this.version = version; + return this; + } + + @java.lang.Override + public RuleConditionPlanVersionResponseData build() { + return new RuleConditionPlanVersionResponseData(id, name, status, version, 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/StripeIntegrationConfig.java b/src/main/java/com/schematic/api/types/StripeIntegrationConfig.java index 444349b4..44d45b7a 100644 --- a/src/main/java/com/schematic/api/types/StripeIntegrationConfig.java +++ b/src/main/java/com/schematic/api/types/StripeIntegrationConfig.java @@ -12,6 +12,7 @@ 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; @@ -24,6 +25,12 @@ public final class StripeIntegrationConfig { private final Optional accountName; + private final Optional claimableSandboxExpiresAt; + + private final Optional claimableSandboxId; + + private final Optional claimableSandboxStatus; + private final Optional companyUpdateOnly; private final boolean isSandbox; @@ -39,6 +46,9 @@ public final class StripeIntegrationConfig { private StripeIntegrationConfig( Optional accountId, Optional accountName, + Optional claimableSandboxExpiresAt, + Optional claimableSandboxId, + Optional claimableSandboxStatus, Optional companyUpdateOnly, boolean isSandbox, boolean liveMode, @@ -47,6 +57,9 @@ private StripeIntegrationConfig( Map additionalProperties) { this.accountId = accountId; this.accountName = accountName; + this.claimableSandboxExpiresAt = claimableSandboxExpiresAt; + this.claimableSandboxId = claimableSandboxId; + this.claimableSandboxStatus = claimableSandboxStatus; this.companyUpdateOnly = companyUpdateOnly; this.isSandbox = isSandbox; this.liveMode = liveMode; @@ -71,6 +84,30 @@ public Optional getAccountName() { return accountName; } + /** + * @return When Stripe deletes the sandbox if nobody claims it, 60 days from creation; absent on sandboxes created before it was recorded + */ + @JsonProperty("claimable_sandbox_expires_at") + public Optional getClaimableSandboxExpiresAt() { + return claimableSandboxExpiresAt; + } + + /** + * @return Stripe claimable sandbox this connection was provisioned from; absent for an OAuth connect + */ + @JsonProperty("claimable_sandbox_id") + public Optional getClaimableSandboxId() { + return claimableSandboxId; + } + + /** + * @return Stripe's claim status for the sandbox: unclaimed, claimed, or live + */ + @JsonProperty("claimable_sandbox_status") + public Optional getClaimableSandboxStatus() { + return claimableSandboxStatus; + } + /** * @return When importing Stripe customers, only update existing companies, do not create new companies */ @@ -125,6 +162,9 @@ public Map getAdditionalProperties() { private boolean equalTo(StripeIntegrationConfig other) { return accountId.equals(other.accountId) && accountName.equals(other.accountName) + && claimableSandboxExpiresAt.equals(other.claimableSandboxExpiresAt) + && claimableSandboxId.equals(other.claimableSandboxId) + && claimableSandboxStatus.equals(other.claimableSandboxStatus) && companyUpdateOnly.equals(other.companyUpdateOnly) && isSandbox == other.isSandbox && liveMode == other.liveMode @@ -137,6 +177,9 @@ public int hashCode() { return Objects.hash( this.accountId, this.accountName, + this.claimableSandboxExpiresAt, + this.claimableSandboxId, + this.claimableSandboxStatus, this.companyUpdateOnly, this.isSandbox, this.liveMode, @@ -190,6 +233,27 @@ public interface _FinalStage { _FinalStage accountName(String accountName); + /** + *

When Stripe deletes the sandbox if nobody claims it, 60 days from creation; absent on sandboxes created before it was recorded

+ */ + _FinalStage claimableSandboxExpiresAt(Optional claimableSandboxExpiresAt); + + _FinalStage claimableSandboxExpiresAt(OffsetDateTime claimableSandboxExpiresAt); + + /** + *

Stripe claimable sandbox this connection was provisioned from; absent for an OAuth connect

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

Stripe's claim status for the sandbox: unclaimed, claimed, or live

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

When importing Stripe customers, only update existing companies, do not create new companies

*/ @@ -224,6 +288,12 @@ public static final class Builder implements IsSandboxStage, LiveModeStage, _Fin private Optional companyUpdateOnly = Optional.empty(); + private Optional claimableSandboxStatus = Optional.empty(); + + private Optional claimableSandboxId = Optional.empty(); + + private Optional claimableSandboxExpiresAt = Optional.empty(); + private Optional accountName = Optional.empty(); private Optional accountId = Optional.empty(); @@ -237,6 +307,9 @@ private Builder() {} public Builder from(StripeIntegrationConfig other) { accountId(other.getAccountId()); accountName(other.getAccountName()); + claimableSandboxExpiresAt(other.getClaimableSandboxExpiresAt()); + claimableSandboxId(other.getClaimableSandboxId()); + claimableSandboxStatus(other.getClaimableSandboxStatus()); companyUpdateOnly(other.getCompanyUpdateOnly()); isSandbox(other.getIsSandbox()); liveMode(other.getLiveMode()); @@ -327,6 +400,66 @@ public _FinalStage companyUpdateOnly(Optional companyUpdateOnly) { return this; } + /** + *

Stripe's claim status for the sandbox: unclaimed, claimed, or live

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

Stripe's claim status for the sandbox: unclaimed, claimed, or live

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

Stripe claimable sandbox this connection was provisioned from; absent for an OAuth connect

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

Stripe claimable sandbox this connection was provisioned from; absent for an OAuth connect

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

When Stripe deletes the sandbox if nobody claims it, 60 days from creation; absent on sandboxes created before it was recorded

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

When Stripe deletes the sandbox if nobody claims it, 60 days from creation; absent on sandboxes created before it was recorded

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

Display name of the connected Stripe account

* @return Reference to {@code this} so that method calls can be chained together. @@ -372,6 +505,9 @@ public StripeIntegrationConfig build() { return new StripeIntegrationConfig( accountId, accountName, + claimableSandboxExpiresAt, + claimableSandboxId, + claimableSandboxStatus, companyUpdateOnly, isSandbox, liveMode, diff --git a/src/main/java/com/schematic/api/types/StripeSandboxClaimLink.java b/src/main/java/com/schematic/api/types/StripeSandboxClaimLink.java new file mode 100644 index 00000000..497031bd --- /dev/null +++ b/src/main/java/com/schematic/api/types/StripeSandboxClaimLink.java @@ -0,0 +1,201 @@ +/** + * 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 = StripeSandboxClaimLink.Builder.class) +public final class StripeSandboxClaimLink { + private final String claimUrl; + + private final Optional expiresAt; + + private final String sandboxId; + + private final String status; + + private final Map additionalProperties; + + private StripeSandboxClaimLink( + String claimUrl, + Optional expiresAt, + String sandboxId, + String status, + Map additionalProperties) { + this.claimUrl = claimUrl; + this.expiresAt = expiresAt; + this.sandboxId = sandboxId; + this.status = status; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("claim_url") + public String getClaimUrl() { + return claimUrl; + } + + @JsonProperty("expires_at") + public Optional getExpiresAt() { + return expiresAt; + } + + @JsonProperty("sandbox_id") + public String getSandboxId() { + return sandboxId; + } + + @JsonProperty("status") + public String getStatus() { + return status; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof StripeSandboxClaimLink && equalTo((StripeSandboxClaimLink) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(StripeSandboxClaimLink other) { + return claimUrl.equals(other.claimUrl) + && expiresAt.equals(other.expiresAt) + && sandboxId.equals(other.sandboxId) + && status.equals(other.status); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.claimUrl, this.expiresAt, this.sandboxId, this.status); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static ClaimUrlStage builder() { + return new Builder(); + } + + public interface ClaimUrlStage { + SandboxIdStage claimUrl(@NotNull String claimUrl); + + Builder from(StripeSandboxClaimLink other); + } + + public interface SandboxIdStage { + StatusStage sandboxId(@NotNull String sandboxId); + } + + public interface StatusStage { + _FinalStage status(@NotNull String status); + } + + public interface _FinalStage { + StripeSandboxClaimLink 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 ClaimUrlStage, SandboxIdStage, StatusStage, _FinalStage { + private String claimUrl; + + private String sandboxId; + + private String status; + + private Optional expiresAt = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(StripeSandboxClaimLink other) { + claimUrl(other.getClaimUrl()); + expiresAt(other.getExpiresAt()); + sandboxId(other.getSandboxId()); + status(other.getStatus()); + return this; + } + + @java.lang.Override + @JsonSetter("claim_url") + public SandboxIdStage claimUrl(@NotNull String claimUrl) { + this.claimUrl = Objects.requireNonNull(claimUrl, "claimUrl must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("sandbox_id") + public StatusStage sandboxId(@NotNull String sandboxId) { + this.sandboxId = Objects.requireNonNull(sandboxId, "sandboxId must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("status") + public _FinalStage status(@NotNull String status) { + this.status = Objects.requireNonNull(status, "status must not be null"); + 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 StripeSandboxClaimLink build() { + return new StripeSandboxClaimLink(claimUrl, expiresAt, sandboxId, status, 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/StripeSandboxCountriesResponseData.java b/src/main/java/com/schematic/api/types/StripeSandboxCountriesResponseData.java new file mode 100644 index 00000000..7da9df97 --- /dev/null +++ b/src/main/java/com/schematic/api/types/StripeSandboxCountriesResponseData.java @@ -0,0 +1,117 @@ +/** + * 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.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = StripeSandboxCountriesResponseData.Builder.class) +public final class StripeSandboxCountriesResponseData { + private final List countries; + + private final Map additionalProperties; + + private StripeSandboxCountriesResponseData(List countries, Map additionalProperties) { + this.countries = countries; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("countries") + public List getCountries() { + return countries; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof StripeSandboxCountriesResponseData + && equalTo((StripeSandboxCountriesResponseData) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(StripeSandboxCountriesResponseData other) { + return countries.equals(other.countries); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.countries); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private List countries = new ArrayList<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(StripeSandboxCountriesResponseData other) { + countries(other.getCountries()); + return this; + } + + @JsonSetter(value = "countries", nulls = Nulls.SKIP) + public Builder countries(List countries) { + this.countries.clear(); + if (countries != null) { + this.countries.addAll(countries); + } + return this; + } + + public Builder addCountries(String countries) { + this.countries.add(countries); + return this; + } + + public Builder addAllCountries(List countries) { + if (countries != null) { + this.countries.addAll(countries); + } + return this; + } + + public StripeSandboxCountriesResponseData build() { + return new StripeSandboxCountriesResponseData(countries, additionalProperties); + } + + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + } +} diff --git a/src/main/java/com/schematic/api/types/StripeSandboxInstallResponseData.java b/src/main/java/com/schematic/api/types/StripeSandboxInstallResponseData.java new file mode 100644 index 00000000..8d2e0f06 --- /dev/null +++ b/src/main/java/com/schematic/api/types/StripeSandboxInstallResponseData.java @@ -0,0 +1,301 @@ +/** + * 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 = StripeSandboxInstallResponseData.Builder.class) +public final class StripeSandboxInstallResponseData { + private final Optional apiKeys; + + private final String claimUrl; + + private final Optional claimUrlExpiresAt; + + private final Optional expiresAt; + + private final IntegrationInstallResponseData install; + + private final String sandboxId; + + private final String stripeAccountId; + + private final Map additionalProperties; + + private StripeSandboxInstallResponseData( + Optional apiKeys, + String claimUrl, + Optional claimUrlExpiresAt, + Optional expiresAt, + IntegrationInstallResponseData install, + String sandboxId, + String stripeAccountId, + Map additionalProperties) { + this.apiKeys = apiKeys; + this.claimUrl = claimUrl; + this.claimUrlExpiresAt = claimUrlExpiresAt; + this.expiresAt = expiresAt; + this.install = install; + this.sandboxId = sandboxId; + this.stripeAccountId = stripeAccountId; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("api_keys") + public Optional getApiKeys() { + return apiKeys; + } + + @JsonProperty("claim_url") + public String getClaimUrl() { + return claimUrl; + } + + @JsonProperty("claim_url_expires_at") + public Optional getClaimUrlExpiresAt() { + return claimUrlExpiresAt; + } + + @JsonProperty("expires_at") + public Optional getExpiresAt() { + return expiresAt; + } + + @JsonProperty("install") + public IntegrationInstallResponseData getInstall() { + return install; + } + + @JsonProperty("sandbox_id") + public String getSandboxId() { + return sandboxId; + } + + @JsonProperty("stripe_account_id") + public String getStripeAccountId() { + return stripeAccountId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof StripeSandboxInstallResponseData && equalTo((StripeSandboxInstallResponseData) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(StripeSandboxInstallResponseData other) { + return apiKeys.equals(other.apiKeys) + && claimUrl.equals(other.claimUrl) + && claimUrlExpiresAt.equals(other.claimUrlExpiresAt) + && expiresAt.equals(other.expiresAt) + && install.equals(other.install) + && sandboxId.equals(other.sandboxId) + && stripeAccountId.equals(other.stripeAccountId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.apiKeys, + this.claimUrl, + this.claimUrlExpiresAt, + this.expiresAt, + this.install, + this.sandboxId, + this.stripeAccountId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static ClaimUrlStage builder() { + return new Builder(); + } + + public interface ClaimUrlStage { + InstallStage claimUrl(@NotNull String claimUrl); + + Builder from(StripeSandboxInstallResponseData other); + } + + public interface InstallStage { + SandboxIdStage install(@NotNull IntegrationInstallResponseData install); + } + + public interface SandboxIdStage { + StripeAccountIdStage sandboxId(@NotNull String sandboxId); + } + + public interface StripeAccountIdStage { + _FinalStage stripeAccountId(@NotNull String stripeAccountId); + } + + public interface _FinalStage { + StripeSandboxInstallResponseData build(); + + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); + + _FinalStage apiKeys(Optional apiKeys); + + _FinalStage apiKeys(StripeSandboxKeysResponseData apiKeys); + + _FinalStage claimUrlExpiresAt(Optional claimUrlExpiresAt); + + _FinalStage claimUrlExpiresAt(OffsetDateTime claimUrlExpiresAt); + + _FinalStage expiresAt(Optional expiresAt); + + _FinalStage expiresAt(OffsetDateTime expiresAt); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder + implements ClaimUrlStage, InstallStage, SandboxIdStage, StripeAccountIdStage, _FinalStage { + private String claimUrl; + + private IntegrationInstallResponseData install; + + private String sandboxId; + + private String stripeAccountId; + + private Optional expiresAt = Optional.empty(); + + private Optional claimUrlExpiresAt = Optional.empty(); + + private Optional apiKeys = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(StripeSandboxInstallResponseData other) { + apiKeys(other.getApiKeys()); + claimUrl(other.getClaimUrl()); + claimUrlExpiresAt(other.getClaimUrlExpiresAt()); + expiresAt(other.getExpiresAt()); + install(other.getInstall()); + sandboxId(other.getSandboxId()); + stripeAccountId(other.getStripeAccountId()); + return this; + } + + @java.lang.Override + @JsonSetter("claim_url") + public InstallStage claimUrl(@NotNull String claimUrl) { + this.claimUrl = Objects.requireNonNull(claimUrl, "claimUrl must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("install") + public SandboxIdStage install(@NotNull IntegrationInstallResponseData install) { + this.install = Objects.requireNonNull(install, "install must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("sandbox_id") + public StripeAccountIdStage sandboxId(@NotNull String sandboxId) { + this.sandboxId = Objects.requireNonNull(sandboxId, "sandboxId must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("stripe_account_id") + public _FinalStage stripeAccountId(@NotNull String stripeAccountId) { + this.stripeAccountId = Objects.requireNonNull(stripeAccountId, "stripeAccountId must not be null"); + 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 _FinalStage claimUrlExpiresAt(OffsetDateTime claimUrlExpiresAt) { + this.claimUrlExpiresAt = Optional.ofNullable(claimUrlExpiresAt); + return this; + } + + @java.lang.Override + @JsonSetter(value = "claim_url_expires_at", nulls = Nulls.SKIP) + public _FinalStage claimUrlExpiresAt(Optional claimUrlExpiresAt) { + this.claimUrlExpiresAt = claimUrlExpiresAt; + return this; + } + + @java.lang.Override + public _FinalStage apiKeys(StripeSandboxKeysResponseData apiKeys) { + this.apiKeys = Optional.ofNullable(apiKeys); + return this; + } + + @java.lang.Override + @JsonSetter(value = "api_keys", nulls = Nulls.SKIP) + public _FinalStage apiKeys(Optional apiKeys) { + this.apiKeys = apiKeys; + return this; + } + + @java.lang.Override + public StripeSandboxInstallResponseData build() { + return new StripeSandboxInstallResponseData( + apiKeys, + claimUrl, + claimUrlExpiresAt, + expiresAt, + install, + sandboxId, + stripeAccountId, + 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/StripeSandboxKeysResponseData.java b/src/main/java/com/schematic/api/types/StripeSandboxKeysResponseData.java new file mode 100644 index 00000000..f0df7289 --- /dev/null +++ b/src/main/java/com/schematic/api/types/StripeSandboxKeysResponseData.java @@ -0,0 +1,163 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = StripeSandboxKeysResponseData.Builder.class) +public final class StripeSandboxKeysResponseData { + private final String mcp; + + private final String publishable; + + private final String secret; + + private final Map additionalProperties; + + private StripeSandboxKeysResponseData( + String mcp, String publishable, String secret, Map additionalProperties) { + this.mcp = mcp; + this.publishable = publishable; + this.secret = secret; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("mcp") + public String getMcp() { + return mcp; + } + + @JsonProperty("publishable") + public String getPublishable() { + return publishable; + } + + @JsonProperty("secret") + public String getSecret() { + return secret; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof StripeSandboxKeysResponseData && equalTo((StripeSandboxKeysResponseData) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(StripeSandboxKeysResponseData other) { + return mcp.equals(other.mcp) && publishable.equals(other.publishable) && secret.equals(other.secret); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.mcp, this.publishable, this.secret); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static McpStage builder() { + return new Builder(); + } + + public interface McpStage { + PublishableStage mcp(@NotNull String mcp); + + Builder from(StripeSandboxKeysResponseData other); + } + + public interface PublishableStage { + SecretStage publishable(@NotNull String publishable); + } + + public interface SecretStage { + _FinalStage secret(@NotNull String secret); + } + + public interface _FinalStage { + StripeSandboxKeysResponseData build(); + + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements McpStage, PublishableStage, SecretStage, _FinalStage { + private String mcp; + + private String publishable; + + private String secret; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(StripeSandboxKeysResponseData other) { + mcp(other.getMcp()); + publishable(other.getPublishable()); + secret(other.getSecret()); + return this; + } + + @java.lang.Override + @JsonSetter("mcp") + public PublishableStage mcp(@NotNull String mcp) { + this.mcp = Objects.requireNonNull(mcp, "mcp must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("publishable") + public SecretStage publishable(@NotNull String publishable) { + this.publishable = Objects.requireNonNull(publishable, "publishable must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("secret") + public _FinalStage secret(@NotNull String secret) { + this.secret = Objects.requireNonNull(secret, "secret must not be null"); + return this; + } + + @java.lang.Override + public StripeSandboxKeysResponseData build() { + return new StripeSandboxKeysResponseData(mcp, publishable, secret, 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; + } + } +}