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