diff --git a/.fern/metadata.json b/.fern/metadata.json index bbb3460..99fd6b2 100644 --- a/.fern/metadata.json +++ b/.fern/metadata.json @@ -1,7 +1,7 @@ { "cliVersion": "5.50.0", "generatorName": "fernapi/fern-java-sdk", - "generatorVersion": "4.32.4", + "generatorVersion": "4.37.6", "generatorConfig": { "client-class-name": "BaseSchematic", "generate-unknown-as-json-node": true, @@ -15,10 +15,10 @@ "testImplementation com.github.codemonstur:embedded-redis:1.4.3" ] }, - "originGitCommit": "9c3d404a6ed3ff63811ecbef9e2814ea8607f22d", + "originGitCommit": "e6a4fb2c8313262a81b70c5f06e15eaeb196abba", "originGitCommitIsDirty": false, "invokedBy": "ci", - "requestedVersion": "1.6.6", + "requestedVersion": "1.6.7", "ciProvider": "github", - "sdkVersion": "1.6.6" + "sdkVersion": "1.6.7" } \ No newline at end of file diff --git a/.fern/replay.lock b/.fern/replay.lock index d4c73e6..d72268e 100644 --- a/.fern/replay.lock +++ b/.fern/replay.lock @@ -114,5 +114,11 @@ generations: cli_version: unknown generator_versions: fernapi/fern-java-sdk: 4.32.4 -current_generation: 241fd3e8a164b4508d294c67575c80b5b9de45ae + - commit_sha: efc21d6498edf8adc5d32669e6def6e124fbe540 + tree_hash: 5426c5251177f6fc606799e880cc2800d741c19a + timestamp: 2026-11-02T10:06:37.287Z + cli_version: unknown + generator_versions: + fernapi/fern-java-sdk: 4.37.6 +current_generation: efc21d6498edf8adc5d32669e6def6e124fbe540 patches: [] diff --git a/build.gradle b/build.gradle index e22ec55..e5be78a 100644 --- a/build.gradle +++ b/build.gradle @@ -63,7 +63,7 @@ java { group = 'com.schematichq' -version = '1.6.6' +version = '1.6.7' jar { dependsOn(":generatePomFileForMavenPublication") @@ -94,7 +94,7 @@ publishing { maven(MavenPublication) { groupId = 'com.schematichq' artifactId = 'schematic-java' - version = '1.6.6' + version = '1.6.7' from components.java pom { name = 'Schematic' diff --git a/reference.md b/reference.md index 312d1b0..290eb62 100644 --- a/reference.md +++ b/reference.md @@ -642,6 +642,7 @@ client.accounts().listAuditLogs( ListAuditLogsRequest .builder() .actorType(ActorType.API_KEY) + .companyId("company_id") .endTime(OffsetDateTime.parse("2024-01-15T09:30:00Z")) .environmentId("environment_id") .q("q") @@ -672,6 +673,14 @@ client.accounts().listAuditLogs(
+**companyId:** `Optional` + +
+
+ +
+
+ **endTime:** `Optional`
@@ -781,6 +790,7 @@ client.accounts().countAuditLogs( CountAuditLogsRequest .builder() .actorType(ActorType.API_KEY) + .companyId("company_id") .endTime(OffsetDateTime.parse("2024-01-15T09:30:00Z")) .environmentId("environment_id") .q("q") @@ -811,6 +821,14 @@ client.accounts().countAuditLogs(
+**companyId:** `Optional` + +
+
+ +
+
+ **endTime:** `Optional`
@@ -3562,6 +3580,14 @@ client.billing().updateCompanyBillingProfile(
+**currency:** `Optional` + +
+
+ +
+
+ **daysUntilDue:** `Optional`
@@ -3570,6 +3596,14 @@ client.billing().updateCompanyBillingProfile(
+**gatingDays:** `Optional` + +
+
+ +
+
+ **isDefault:** `Optional`
@@ -3586,6 +3620,22 @@ client.billing().updateCompanyBillingProfile(
+**overdraftLimit:** `Optional` + +
+
+ +
+
+ +**paymentGating:** `Optional` + +
+
+ +
+
+ **paymentMethodId:** `Optional`
@@ -6826,7 +6876,7 @@ client.credits().reserveCredits(
-**expiresAt:** `Optional` — When the hold lapses if no track event settles it; defaults to one minute from now and may be at most one hour out. The unspent hold is refunded on expiry +**expiresAt:** `Optional` — When the hold lapses if no track event settles it; defaults to one minute from now and may be at most 24 hours out. The unspent hold is refunded on expiry
@@ -9175,6 +9225,7 @@ client.companies().listCompanies( .subscriptionTypes( Arrays.asList(SubscriptionType.FREE) ) + .cancelAtPeriodEnd(true) .hasScheduledDowngrade(true) .monetizedSubscriptions(true) .planId("plan_id") @@ -9206,6 +9257,14 @@ client.companies().listCompanies(
+**cancelAtPeriodEnd:** `Optional` — If true, filter companies with an active subscription that is set to cancel at the end of the current period; if false, filter companies without one + +
+
+ +
+
+ **creditTypeIds:** `Optional` — Filter companies by one or more credit type IDs (each ID starts with bcrd_)
@@ -9214,7 +9273,7 @@ client.companies().listCompanies(
-**hasScheduledDowngrade:** `Optional` — Filter companies that have a pending scheduled downgrade +**hasScheduledDowngrade:** `Optional` — If true, filter companies that have a pending scheduled downgrade; if false, filter companies that do not
@@ -9526,6 +9585,69 @@ client.companies().deleteCompany(
+ +
+ + +
client.companies.getCompanyInferenceCost(companyId) -> GetCompanyInferenceCostResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.companies().getCompanyInferenceCost( + "company_id", + GetCompanyInferenceCostRequest + .builder() + .endTime(OffsetDateTime.parse("2024-01-15T09:30:00Z")) + .startTime(OffsetDateTime.parse("2024-01-15T09:30:00Z")) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**companyId:** `String` — company_id + +
+
+ +
+
+ +**endTime:** `Optional` — End of the window (exclusive). Pass together with start_time; when both are omitted, the company's current billing period is used + +
+
+ +
+
+ +**startTime:** `Optional` — Start of the window (inclusive). Pass together with end_time; when both are omitted, the company's current billing period is used + +
+
+
+
+ +
@@ -9564,6 +9686,7 @@ client.companies().countCompanies( .subscriptionTypes( Arrays.asList(SubscriptionType.FREE) ) + .cancelAtPeriodEnd(true) .hasScheduledDowngrade(true) .monetizedSubscriptions(true) .planId("plan_id") @@ -9595,6 +9718,14 @@ client.companies().countCompanies(
+**cancelAtPeriodEnd:** `Optional` — If true, filter companies with an active subscription that is set to cancel at the end of the current period; if false, filter companies without one + +
+
+ +
+
+ **creditTypeIds:** `Optional` — Filter companies by one or more credit type IDs (each ID starts with bcrd_)
@@ -9603,7 +9734,7 @@ client.companies().countCompanies(
-**hasScheduledDowngrade:** `Optional` — Filter companies that have a pending scheduled downgrade +**hasScheduledDowngrade:** `Optional` — If true, filter companies that have a pending scheduled downgrade; if false, filter companies that do not
@@ -11214,7 +11345,7 @@ client.companies().listPlanChanges( .companyIds( Arrays.asList("company_ids") ) - .action(PlanChangeAction.AMENDMENT) + .action(PlanChangeAction.ACCESS_REINSTATED) .basePlanAction(PlanChangeBasePlanAction.FALLBACK) .companyId("company_id") .limit(1000000L) @@ -19637,7 +19768,7 @@ client.features().checkAndReserveFlag(
-**expiresAt:** `Optional` — When the hold lapses if no track or inference event settles it; defaults to one minute from now and may be at most one hour out. The unspent hold is refunded on expiry +**expiresAt:** `Optional` — When the hold lapses if no track or inference event settles it; defaults to one minute from now and may be at most 24 hours out. The unspent hold is refunded on expiry
diff --git a/src/main/java/com/schematic/api/AsyncBaseSchematicBuilder.java b/src/main/java/com/schematic/api/AsyncBaseSchematicBuilder.java index 36480b0..c2c3282 100644 --- a/src/main/java/com/schematic/api/AsyncBaseSchematicBuilder.java +++ b/src/main/java/com/schematic/api/AsyncBaseSchematicBuilder.java @@ -6,9 +6,14 @@ import com.schematic.api.core.ClientOptions; import com.schematic.api.core.Environment; import com.schematic.api.core.LogConfig; +import java.time.Duration; +import java.util.ArrayList; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Optional; +import java.util.Set; import okhttp3.OkHttpClient; public class AsyncBaseSchematicBuilder { @@ -16,6 +21,12 @@ public class AsyncBaseSchematicBuilder { private Optional maxRetries = Optional.empty(); + private Optional maxConcurrentRequests = Optional.empty(); + + private Optional> retryOnStatusCodes = Optional.empty(); + + private Optional> retryDelays = Optional.empty(); + private Optional initialRetryDelayMillis = Optional.empty(); private Optional maxRetryDelayMillis = Optional.empty(); @@ -66,6 +77,41 @@ public AsyncBaseSchematicBuilder maxRetries(int maxRetries) { return this; } + /** + * Caps the number of in-flight requests (sync and async) the client will have at once. Unlimited unless set; must be positive. + */ + public AsyncBaseSchematicBuilder maxConcurrentRequests(int maxConcurrentRequests) { + this.maxConcurrentRequests = Optional.of(maxConcurrentRequests); + return this; + } + + /** + * Restricts automatic retries to responses with one of the given HTTP status codes (for example {@code 429} only, or {@code 429} and {@code 503}), replacing the default set of 408, 429 and 5xx. Codes not listed are returned as-is. Retry-After handling and the other retry settings are unchanged. + */ + public AsyncBaseSchematicBuilder retryOnStatusCodes(Set retryOnStatusCodes) { + if (retryOnStatusCodes == null) { + throw new IllegalArgumentException("retryOnStatusCodes must not be null"); + } + this.retryOnStatusCodes = Optional.of(retryOnStatusCodes); + return this; + } + + /** + * Sets an explicit retry schedule: the n-th retry waits for the n-th duration and the request stops retrying once the list is exhausted, so the list size replaces {@code maxRetries} and the exponential backoff settings. Delays are used as-is (no jitter); a {@code Retry-After} / {@code X-RateLimit-Reset} header still takes precedence for that attempt. + */ + public AsyncBaseSchematicBuilder retryDelays(List retryDelays) { + if (retryDelays == null) { + throw new IllegalArgumentException("retryDelays must not be null"); + } + for (Duration delay : retryDelays) { + if (delay == null || delay.isNegative()) { + throw new IllegalArgumentException("retryDelays must only contain non-negative durations: " + delay); + } + } + this.retryDelays = Optional.of(Collections.unmodifiableList(new ArrayList<>(retryDelays))); + return this; + } + /** * Sets the initial delay (in milliseconds) used for exponential backoff between retries. Defaults to 1000 milliseconds. */ @@ -126,6 +172,7 @@ protected ClientOptions buildClientOptions() { setHttpClient(builder); setTimeouts(builder); setRetries(builder); + setConcurrencyLimit(builder); setLogging(builder); for (Map.Entry header : this.customHeaders.entrySet()) { builder.addHeader(header.getKey(), header.getValue()); @@ -196,6 +243,24 @@ protected void setRetries(ClientOptions.Builder builder) { if (this.retryJitterFactor.isPresent()) { builder.retryJitterFactor(this.retryJitterFactor.get()); } + if (this.retryOnStatusCodes.isPresent()) { + builder.retryOnStatusCodes(this.retryOnStatusCodes.get()); + } + if (this.retryDelays.isPresent()) { + builder.retryDelays(this.retryDelays.get()); + } + } + + /** + * Applies the in-flight request cap, if one was configured. + * Override this method to customize concurrency limiting. + * + * @param builder The ClientOptions.Builder to configure + */ + protected void setConcurrencyLimit(ClientOptions.Builder builder) { + if (this.maxConcurrentRequests.isPresent()) { + builder.maxConcurrentRequests(this.maxConcurrentRequests.get()); + } } /** diff --git a/src/main/java/com/schematic/api/BaseSchematicBuilder.java b/src/main/java/com/schematic/api/BaseSchematicBuilder.java index 4fa8f6a..19ad28e 100644 --- a/src/main/java/com/schematic/api/BaseSchematicBuilder.java +++ b/src/main/java/com/schematic/api/BaseSchematicBuilder.java @@ -6,9 +6,14 @@ import com.schematic.api.core.ClientOptions; import com.schematic.api.core.Environment; import com.schematic.api.core.LogConfig; +import java.time.Duration; +import java.util.ArrayList; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Optional; +import java.util.Set; import okhttp3.OkHttpClient; public class BaseSchematicBuilder { @@ -16,6 +21,12 @@ public class BaseSchematicBuilder { private Optional maxRetries = Optional.empty(); + private Optional maxConcurrentRequests = Optional.empty(); + + private Optional> retryOnStatusCodes = Optional.empty(); + + private Optional> retryDelays = Optional.empty(); + private Optional initialRetryDelayMillis = Optional.empty(); private Optional maxRetryDelayMillis = Optional.empty(); @@ -66,6 +77,41 @@ public BaseSchematicBuilder maxRetries(int maxRetries) { return this; } + /** + * Caps the number of in-flight requests (sync and async) the client will have at once. Unlimited unless set; must be positive. + */ + public BaseSchematicBuilder maxConcurrentRequests(int maxConcurrentRequests) { + this.maxConcurrentRequests = Optional.of(maxConcurrentRequests); + return this; + } + + /** + * Restricts automatic retries to responses with one of the given HTTP status codes (for example {@code 429} only, or {@code 429} and {@code 503}), replacing the default set of 408, 429 and 5xx. Codes not listed are returned as-is. Retry-After handling and the other retry settings are unchanged. + */ + public BaseSchematicBuilder retryOnStatusCodes(Set retryOnStatusCodes) { + if (retryOnStatusCodes == null) { + throw new IllegalArgumentException("retryOnStatusCodes must not be null"); + } + this.retryOnStatusCodes = Optional.of(retryOnStatusCodes); + return this; + } + + /** + * Sets an explicit retry schedule: the n-th retry waits for the n-th duration and the request stops retrying once the list is exhausted, so the list size replaces {@code maxRetries} and the exponential backoff settings. Delays are used as-is (no jitter); a {@code Retry-After} / {@code X-RateLimit-Reset} header still takes precedence for that attempt. + */ + public BaseSchematicBuilder retryDelays(List retryDelays) { + if (retryDelays == null) { + throw new IllegalArgumentException("retryDelays must not be null"); + } + for (Duration delay : retryDelays) { + if (delay == null || delay.isNegative()) { + throw new IllegalArgumentException("retryDelays must only contain non-negative durations: " + delay); + } + } + this.retryDelays = Optional.of(Collections.unmodifiableList(new ArrayList<>(retryDelays))); + return this; + } + /** * Sets the initial delay (in milliseconds) used for exponential backoff between retries. Defaults to 1000 milliseconds. */ @@ -126,6 +172,7 @@ protected ClientOptions buildClientOptions() { setHttpClient(builder); setTimeouts(builder); setRetries(builder); + setConcurrencyLimit(builder); setLogging(builder); for (Map.Entry header : this.customHeaders.entrySet()) { builder.addHeader(header.getKey(), header.getValue()); @@ -196,6 +243,24 @@ protected void setRetries(ClientOptions.Builder builder) { if (this.retryJitterFactor.isPresent()) { builder.retryJitterFactor(this.retryJitterFactor.get()); } + if (this.retryOnStatusCodes.isPresent()) { + builder.retryOnStatusCodes(this.retryOnStatusCodes.get()); + } + if (this.retryDelays.isPresent()) { + builder.retryDelays(this.retryDelays.get()); + } + } + + /** + * Applies the in-flight request cap, if one was configured. + * Override this method to customize concurrency limiting. + * + * @param builder The ClientOptions.Builder to configure + */ + protected void setConcurrencyLimit(ClientOptions.Builder builder) { + if (this.maxConcurrentRequests.isPresent()) { + builder.maxConcurrentRequests(this.maxConcurrentRequests.get()); + } } /** diff --git a/src/main/java/com/schematic/api/core/ClientOptions.java b/src/main/java/com/schematic/api/core/ClientOptions.java index 83cc796..c6325f6 100644 --- a/src/main/java/com/schematic/api/core/ClientOptions.java +++ b/src/main/java/com/schematic/api/core/ClientOptions.java @@ -3,8 +3,12 @@ */ package com.schematic.api.core; +import java.time.Duration; import java.util.ArrayList; +import java.util.Collections; import java.util.HashMap; +import java.util.HashSet; +import java.util.List; import java.util.Map; import java.util.Optional; import java.util.Set; @@ -12,6 +16,7 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; import java.util.function.Supplier; +import okhttp3.Interceptor; import okhttp3.OkHttpClient; public final class ClientOptions { @@ -39,6 +44,10 @@ public final class ClientOptions { private final Optional retryJitterFactor; + private final Optional> retryOnStatusCodes; + + private final Optional> retryDelays; + private final Optional logging; private ClientOptions( @@ -54,16 +63,18 @@ private ClientOptions( Optional initialRetryDelayMillis, Optional maxRetryDelayMillis, Optional retryJitterFactor, + Optional> retryOnStatusCodes, + Optional> retryDelays, Optional logging) { this.environment = environment; this.headers = new HashMap<>(); this.headers.putAll(headers); this.headers.putAll(new HashMap() { { - put("User-Agent", "com.schematichq.schematic-java/1.6.6"); + put("User-Agent", "com.schematichq.schematic-java/1.6.7"); put("X-Fern-Language", "JAVA"); put("X-Fern-SDK-Name", "com.schematichq:schematic-java"); - put("X-Fern-SDK-Version", "1.6.6"); + put("X-Fern-SDK-Version", "1.6.7"); } }); this.headerSuppliers = headerSuppliers; @@ -76,6 +87,8 @@ private ClientOptions( this.initialRetryDelayMillis = initialRetryDelayMillis; this.maxRetryDelayMillis = maxRetryDelayMillis; this.retryJitterFactor = retryJitterFactor; + this.retryOnStatusCodes = retryOnStatusCodes; + this.retryDelays = retryDelays; this.logging = logging; } @@ -134,6 +147,14 @@ public Optional retryJitterFactor() { return this.retryJitterFactor; } + public Optional> retryOnStatusCodes() { + return this.retryOnStatusCodes; + } + + public Optional> retryDelays() { + return this.retryDelays; + } + /** * Releases resources owned by this client. Only shuts down the underlying OkHttpClient's * dispatcher executor and evicts its connection pool when this client created that @@ -219,8 +240,14 @@ public static class Builder { private Optional retryJitterFactor = Optional.empty(); + private Optional> retryOnStatusCodes = Optional.empty(); + + private Optional> retryDelays = Optional.empty(); + private Optional timeout = Optional.empty(); + private Optional maxConcurrentRequests = Optional.empty(); + private OkHttpClient httpClient = null; private boolean ownsHttpClient = true; @@ -296,6 +323,66 @@ public Builder retryJitterFactor(double retryJitterFactor) { return this; } + /** + * Restricts automatic retries to responses with one of the given HTTP status codes, + * for example {@code 429} only, or {@code 429} and {@code 503}. Replaces the default + * set, so codes not listed here (such as other 5xx) are returned as-is instead of being + * retried. An empty set disables status-based retries. Retry-After handling, maxRetries() and + * the backoff settings are unchanged. + */ + public Builder retryOnStatusCodes(Set retryOnStatusCodes) { + if (retryOnStatusCodes == null) { + throw new IllegalArgumentException("retryOnStatusCodes must not be null"); + } + for (Integer statusCode : retryOnStatusCodes) { + if (statusCode == null || statusCode < 100 || statusCode > 599) { + throw new IllegalArgumentException( + "retryOnStatusCodes contains an invalid HTTP status code: " + statusCode); + } + } + this.retryOnStatusCodes = Optional.of(Collections.unmodifiableSet(new HashSet<>(retryOnStatusCodes))); + return this; + } + + /** + * Sets an explicit retry schedule: the n-th retry waits for the n-th duration and the + * request stops retrying once the list is exhausted, e.g. {@code List.of(Duration.ofSeconds(1), + * Duration.ofSeconds(5), Duration.ofSeconds(30))} retries at most three times. The list size + * replaces maxRetries() and the exponential backoff settings; delays are used as-is (no jitter). + * A {@code Retry-After} / {@code X-RateLimit-Reset} header still takes precedence over the + * scheduled delay for that attempt. An empty list disables retries. + */ + public Builder retryDelays(List retryDelays) { + if (retryDelays == null) { + throw new IllegalArgumentException("retryDelays must not be null"); + } + for (Duration delay : retryDelays) { + if (delay == null || delay.isNegative()) { + throw new IllegalArgumentException( + "retryDelays must only contain non-negative durations: " + delay); + } + } + this.retryDelays = Optional.of(Collections.unmodifiableList(new ArrayList<>(retryDelays))); + return this; + } + + /** + * Caps the number of requests that may be in flight at the same time, for both the + * synchronous and the asynchronous client. Defaults to no limit. + * A request holds a slot from the moment it is sent until its response body is + * closed; a caller that needs a slot waits (bounded by the call timeout) until one is + * free. Retries waiting for their backoff delay do not hold a slot. Also applies to + * an OkHttpClient supplied via httpClient(), whose own dispatcher limits still bound + * asynchronous calls. + */ + public Builder maxConcurrentRequests(int maxConcurrentRequests) { + if (maxConcurrentRequests <= 0) { + throw new IllegalArgumentException("maxConcurrentRequests must be positive"); + } + this.maxConcurrentRequests = Optional.of(maxConcurrentRequests); + return this; + } + /** * Sets the underlying OkHttp client. The caller retains ownership of its lifecycle: * close() will not shut down its dispatcher executor or evict its connection pool. @@ -324,6 +411,20 @@ public ClientOptions build() { .connectTimeout(0, TimeUnit.SECONDS) .writeTimeout(0, TimeUnit.SECONDS) .readTimeout(0, TimeUnit.SECONDS)); + List interceptors = httpClientBuilder.interceptors(); + for (int i = 0; i < interceptors.size(); i++) { + if (interceptors.get(i) instanceof RetryInterceptor) { + interceptors.set( + i, + new RetryInterceptor( + this.maxRetries, + this.initialRetryDelayMillis, + this.maxRetryDelayMillis, + this.retryJitterFactor, + this.retryOnStatusCodes, + this.retryDelays)); + } + } } else { httpClientBuilder .callTimeout(this.timeout.orElse(60), TimeUnit.SECONDS) @@ -334,9 +435,18 @@ public ClientOptions build() { this.maxRetries, this.initialRetryDelayMillis, this.maxRetryDelayMillis, - this.retryJitterFactor)); + this.retryJitterFactor, + this.retryOnStatusCodes, + this.retryDelays)); } + this.maxConcurrentRequests.ifPresent(limit -> { + httpClientBuilder + .interceptors() + .removeIf(interceptor -> interceptor instanceof ConcurrencyLimitingInterceptor); + httpClientBuilder.addInterceptor(new ConcurrencyLimitingInterceptor(limit)); + }); + Logger logger = Logger.from(this.logging); httpClientBuilder.addInterceptor(new LoggingInterceptor(logger)); httpClientBuilder.addInterceptor(new ResponseDecompressionInterceptor()); @@ -361,6 +471,8 @@ public ClientOptions build() { this.initialRetryDelayMillis, this.maxRetryDelayMillis, this.retryJitterFactor, + this.retryOnStatusCodes, + this.retryDelays, this.logging); } @@ -381,6 +493,8 @@ public static Builder from(ClientOptions clientOptions) { builder.initialRetryDelayMillis = clientOptions.initialRetryDelayMillis(); builder.maxRetryDelayMillis = clientOptions.maxRetryDelayMillis(); builder.retryJitterFactor = clientOptions.retryJitterFactor(); + builder.retryOnStatusCodes = clientOptions.retryOnStatusCodes(); + builder.retryDelays = clientOptions.retryDelays(); builder.logging = clientOptions.logging(); return builder; } diff --git a/src/main/java/com/schematic/api/core/ConcurrencyLimitingInterceptor.java b/src/main/java/com/schematic/api/core/ConcurrencyLimitingInterceptor.java new file mode 100644 index 0000000..b9e60cb --- /dev/null +++ b/src/main/java/com/schematic/api/core/ConcurrencyLimitingInterceptor.java @@ -0,0 +1,150 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.core; + +import java.io.IOException; +import java.io.InterruptedIOException; +import java.util.concurrent.Semaphore; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicBoolean; +import okhttp3.Call; +import okhttp3.Interceptor; +import okhttp3.MediaType; +import okhttp3.Response; +import okhttp3.ResponseBody; +import okio.BufferedSource; +import okio.ForwardingSource; +import okio.Okio; + +/** + * Caps how many requests are in flight at the same time. OkHttp itself only bounds idle connections (the connection + * pool) and asynchronous calls (the dispatcher), so a synchronous client is otherwise limited only by the number of + * calling threads. + * + *

A permit is taken before a request is sent and handed back once its response body has been closed (or the + * request failed), so both {@code execute()} and {@code enqueue()} callers are bounded. A caller waiting for a permit + * gives up as soon as its call is cancelled, which is also what the call timeout does when it fires, so the wait never + * outlives the call timeout. Retries scheduled by {@code RetryInterceptor} release their permit while they wait for + * the backoff delay, because that interceptor runs before this one. + * + *

The generated clients always close response bodies (try-with-resources). Code that uses the {@code OkHttpClient} + * directly must do the same: a response body that is never closed keeps its permit for good. + */ +public class ConcurrencyLimitingInterceptor implements Interceptor { + + private static final long CANCELLATION_POLL_NANOS = TimeUnit.MILLISECONDS.toNanos(100); + + private final int maxConcurrentRequests; + private final Semaphore permits; + + public ConcurrencyLimitingInterceptor(int maxConcurrentRequests) { + if (maxConcurrentRequests <= 0) { + throw new IllegalArgumentException("maxConcurrentRequests must be positive"); + } + this.maxConcurrentRequests = maxConcurrentRequests; + this.permits = new Semaphore(maxConcurrentRequests, true); + } + + public int getMaxConcurrentRequests() { + return maxConcurrentRequests; + } + + /** Number of requests that could start right now without waiting. */ + public int availablePermits() { + return permits.availablePermits(); + } + + @Override + public Response intercept(Chain chain) throws IOException { + acquirePermit(chain.call()); + Response response; + try { + response = chain.proceed(chain.request()); + } catch (Throwable t) { + permits.release(); + throw t; + } + ResponseBody body = response.body(); + if (body == null) { + permits.release(); + return response; + } + return response.newBuilder() + .body(new PermitReleasingResponseBody(body, permits)) + .build(); + } + + /** + * Waits for a permit in short slices so that cancellation of the call (explicit, or by OkHttp's call timeout + * watchdog) is honoured promptly. The configured call timeout is also applied as an absolute upper bound. + */ + private void acquirePermit(Call call) throws IOException { + long callTimeoutNanos = call.timeout().timeoutNanos(); + long deadlineNanos = callTimeoutNanos > 0 ? System.nanoTime() + callTimeoutNanos : Long.MAX_VALUE; + try { + while (true) { + if (call.isCanceled()) { + throw new IOException("Canceled"); + } + long waitNanos = CANCELLATION_POLL_NANOS; + if (deadlineNanos != Long.MAX_VALUE) { + long remainingNanos = deadlineNanos - System.nanoTime(); + if (remainingNanos <= 0) { + throw new InterruptedIOException("Timed out waiting for one of " + maxConcurrentRequests + + " concurrent request permits"); + } + waitNanos = Math.min(waitNanos, remainingNanos); + } + if (permits.tryAcquire(waitNanos, TimeUnit.NANOSECONDS)) { + return; + } + } + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + InterruptedIOException interrupted = + new InterruptedIOException("Interrupted while waiting for a concurrent request permit"); + interrupted.initCause(e); + throw interrupted; + } + } + + /** Closes the wrapped body and releases the permit exactly once, when the body is closed. */ + private static final class PermitReleasingResponseBody extends ResponseBody { + + private final ResponseBody delegate; + private final BufferedSource source; + private final AtomicBoolean released = new AtomicBoolean(false); + + PermitReleasingResponseBody(ResponseBody delegate, Semaphore permits) { + this.delegate = delegate; + this.source = Okio.buffer(new ForwardingSource(delegate.source()) { + @Override + public void close() throws IOException { + try { + delegate.close(); + } finally { + if (released.compareAndSet(false, true)) { + permits.release(); + } + } + } + }); + } + + @Override + public MediaType contentType() { + return delegate.contentType(); + } + + @Override + public long contentLength() { + return delegate.contentLength(); + } + + @Override + public BufferedSource source() { + return source; + } + } +} diff --git a/src/main/java/com/schematic/api/core/ObjectMappers.java b/src/main/java/com/schematic/api/core/ObjectMappers.java index 245e74e..771068b 100644 --- a/src/main/java/com/schematic/api/core/ObjectMappers.java +++ b/src/main/java/com/schematic/api/core/ObjectMappers.java @@ -3,34 +3,27 @@ */ package com.schematic.api.core; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; -import com.fasterxml.jackson.databind.json.JsonMapper; import com.fasterxml.jackson.datatype.jdk8.Jdk8Module; import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import java.io.IOException; public final class ObjectMappers { - public static final ObjectMapper JSON_MAPPER = JsonMapper.builder() - .addModule(new Jdk8Module()) - .addModule(new JavaTimeModule()) - .addModule(DateTimeDeserializer.getModule()) - .addModule(DoubleSerializer.getModule()) + public static final ObjectMapper JSON_MAPPER = new ObjectMapper() + .registerModule(new Jdk8Module()) + .registerModule(new JavaTimeModule()) + .registerModule(DateTimeDeserializer.getModule()) + .registerModule(DoubleSerializer.getModule()) .disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES) - .disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) - .build(); + .disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); private ObjectMappers() {} public static String stringify(Object o) { try { - return JSON_MAPPER - .setSerializationInclusion(JsonInclude.Include.ALWAYS) - .writerWithDefaultPrettyPrinter() - .writeValueAsString(o); + return JSON_MAPPER.writerWithDefaultPrettyPrinter().writeValueAsString(o); } catch (IOException e) { return o.getClass().getName() + "@" + Integer.toHexString(o.hashCode()); } @@ -39,7 +32,7 @@ public static String stringify(Object o) { public static Object parseErrorBody(String responseBodyString) { try { return JSON_MAPPER.readValue(responseBodyString, Object.class); - } catch (JsonProcessingException ignored) { + } catch (IOException ignored) { return responseBodyString; } } diff --git a/src/main/java/com/schematic/api/core/RetryInterceptor.java b/src/main/java/com/schematic/api/core/RetryInterceptor.java index cc0f24e..509fe65 100644 --- a/src/main/java/com/schematic/api/core/RetryInterceptor.java +++ b/src/main/java/com/schematic/api/core/RetryInterceptor.java @@ -9,8 +9,13 @@ import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; import java.time.format.DateTimeParseException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; import java.util.Optional; import java.util.Random; +import java.util.Set; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.ScheduledThreadPoolExecutor; import java.util.concurrent.TimeUnit; @@ -34,6 +39,8 @@ public class RetryInterceptor implements Interceptor { private final Duration initialRetryDelay; private final Duration maxRetryDelay; private final double jitterFactor; + private final Optional> retryOnStatusCodes; + private final Optional> retryDelays; private final Random random = new Random(); public RetryInterceptor(int maxRetries) { @@ -45,6 +52,41 @@ public RetryInterceptor( Optional initialRetryDelayMillis, Optional maxRetryDelayMillis, Optional jitterFactor) { + this(maxRetries, initialRetryDelayMillis, maxRetryDelayMillis, jitterFactor, Optional.empty()); + } + + /** + * @param retryOnStatusCodes when present, the only HTTP status codes that trigger a retry; when empty, the + * generated default set (see {@link #shouldRetry(int)}) is used. + */ + public RetryInterceptor( + int maxRetries, + Optional initialRetryDelayMillis, + Optional maxRetryDelayMillis, + Optional jitterFactor, + Optional> retryOnStatusCodes) { + this( + maxRetries, + initialRetryDelayMillis, + maxRetryDelayMillis, + jitterFactor, + retryOnStatusCodes, + Optional.empty()); + } + + /** + * @param retryDelays when present, an explicit retry schedule: the n-th retry waits for the n-th duration and the + * call stops retrying once the list is exhausted, so its size replaces {@code maxRetries} (a per-request + * {@link MaxRetriesOverride} can still lower the count). The exponential backoff settings are not used, but a + * {@code Retry-After} / {@code X-RateLimit-Reset} header still takes precedence over the scheduled delay. + */ + public RetryInterceptor( + int maxRetries, + Optional initialRetryDelayMillis, + Optional maxRetryDelayMillis, + Optional jitterFactor, + Optional> retryOnStatusCodes, + Optional> retryDelays) { initialRetryDelayMillis.ifPresent(delay -> { if (delay < 0) { throw new IllegalArgumentException("initialRetryDelayMillis must be non-negative"); @@ -64,6 +106,31 @@ public RetryInterceptor( this.initialRetryDelay = initialRetryDelayMillis.map(Duration::ofMillis).orElse(DEFAULT_INITIAL_RETRY_DELAY); this.maxRetryDelay = maxRetryDelayMillis.map(Duration::ofMillis).orElse(DEFAULT_MAX_RETRY_DELAY); this.jitterFactor = jitterFactor.orElse(DEFAULT_JITTER_FACTOR); + this.retryOnStatusCodes = retryOnStatusCodes.map(RetryInterceptor::copyStatusCodes); + this.retryDelays = retryDelays.map(RetryInterceptor::copyRetryDelays); + } + + private static List copyRetryDelays(List delays) { + List copy = new ArrayList<>(delays.size()); + for (Duration delay : delays) { + if (delay == null || delay.isNegative()) { + throw new IllegalArgumentException("retryDelays must only contain non-negative durations: " + delay); + } + copy.add(delay); + } + return Collections.unmodifiableList(copy); + } + + private static Set copyStatusCodes(Set statusCodes) { + Set copy = new HashSet<>(); + for (Integer statusCode : statusCodes) { + if (statusCode == null || statusCode < 100 || statusCode > 599) { + throw new IllegalArgumentException( + "retryOnStatusCodes contains an invalid HTTP status code: " + statusCode); + } + copy.add(statusCode); + } + return Collections.unmodifiableSet(copy); } @Override @@ -85,6 +152,10 @@ public Response intercept(Chain chain) throws IOException { private int resolveMaxRetries(Request request) { MaxRetriesOverride override = request.tag(MaxRetriesOverride.class); + if (retryDelays.isPresent()) { + int scheduled = retryDelays.get().size(); + return override != null ? Math.min(override.getValue(), scheduled) : scheduled; + } return override != null ? override.getValue() : this.maxRetries; } @@ -171,6 +242,7 @@ private static ScheduledThreadPoolExecutor create() { } private static final class AsyncRetryingCall implements AsyncCall, Callback { + private final RetryInterceptor retryInterceptor; private final OkHttpClient client; private final Request request; private final ExponentialBackoff backoff; @@ -186,6 +258,7 @@ private static final class AsyncRetryingCall implements AsyncCall, Callback { private boolean completed; AsyncRetryingCall(RetryInterceptor retryInterceptor, OkHttpClient client, Request request, int maxRetries) { + this.retryInterceptor = retryInterceptor; this.client = client; this.request = request.newBuilder() .tag(AsyncAttempt.class, AsyncAttempt.INSTANCE) @@ -242,7 +315,7 @@ private void startRetry() { @Override public void onResponse(Call call, Response response) throws IOException { - if (backoff != null && shouldRetry(response.code())) { + if (backoff != null && retryInterceptor.shouldRetry(response.code())) { Optional delay = backoff.nextBackoff(response); if (delay.isPresent()) { Response buffered = bufferResponse(response); @@ -440,6 +513,13 @@ private Duration getRetryDelayFromHeaders(Response response, int retryAttempt) { } } + // An explicit schedule replaces exponential backoff (no jitter: the caller chose the exact delays). The + // attempt count is bounded by the schedule size in resolveMaxRetries; clamp defensively anyway. + if (retryDelays.isPresent() && !retryDelays.get().isEmpty()) { + List schedule = retryDelays.get(); + return schedule.get(Math.min(retryAttempt, schedule.size() - 1)); + } + // Fall back to exponential backoff, with symmetric jitter long initialDelayMillis = initialRetryDelay.toMillis(); long maxDelayMillis = maxRetryDelay.toMillis(); @@ -499,7 +579,10 @@ private long addSymmetricJitter(long delayMs) { return (long) (delayMs * jitterMultiplier); } - private static boolean shouldRetry(int statusCode) { + private boolean shouldRetry(int statusCode) { + if (retryOnStatusCodes.isPresent()) { + return retryOnStatusCodes.get().contains(statusCode); + } return statusCode == 408 || statusCode == 429 || statusCode >= 500; } diff --git a/src/main/java/com/schematic/api/resources/accounts/AsyncRawAccountsClient.java b/src/main/java/com/schematic/api/resources/accounts/AsyncRawAccountsClient.java index 0acf2be..302783d 100644 --- a/src/main/java/com/schematic/api/resources/accounts/AsyncRawAccountsClient.java +++ b/src/main/java/com/schematic/api/resources/accounts/AsyncRawAccountsClient.java @@ -777,6 +777,10 @@ public CompletableFuture> listA QueryStringMapper.addQueryParameter( httpUrl, "actor_type", request.getActorType().get(), false); } + if (request.getCompanyId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "company_id", request.getCompanyId().get(), false); + } if (request.getEndTime().isPresent()) { QueryStringMapper.addQueryParameter( httpUrl, "end_time", request.getEndTime().get(), false); @@ -1014,6 +1018,10 @@ public CompletableFuture> coun QueryStringMapper.addQueryParameter( httpUrl, "actor_type", request.getActorType().get(), false); } + if (request.getCompanyId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "company_id", request.getCompanyId().get(), false); + } if (request.getEndTime().isPresent()) { QueryStringMapper.addQueryParameter( httpUrl, "end_time", request.getEndTime().get(), false); diff --git a/src/main/java/com/schematic/api/resources/accounts/RawAccountsClient.java b/src/main/java/com/schematic/api/resources/accounts/RawAccountsClient.java index 19f919f..58ab83a 100644 --- a/src/main/java/com/schematic/api/resources/accounts/RawAccountsClient.java +++ b/src/main/java/com/schematic/api/resources/accounts/RawAccountsClient.java @@ -584,6 +584,10 @@ public BaseSchematicHttpResponse listAuditLogs( QueryStringMapper.addQueryParameter( httpUrl, "actor_type", request.getActorType().get(), false); } + if (request.getCompanyId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "company_id", request.getCompanyId().get(), false); + } if (request.getEndTime().isPresent()) { QueryStringMapper.addQueryParameter( httpUrl, "end_time", request.getEndTime().get(), false); @@ -759,6 +763,10 @@ public BaseSchematicHttpResponse countAuditLogs( QueryStringMapper.addQueryParameter( httpUrl, "actor_type", request.getActorType().get(), false); } + if (request.getCompanyId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "company_id", request.getCompanyId().get(), false); + } if (request.getEndTime().isPresent()) { QueryStringMapper.addQueryParameter( httpUrl, "end_time", request.getEndTime().get(), false); diff --git a/src/main/java/com/schematic/api/resources/accounts/requests/CountAuditLogsRequest.java b/src/main/java/com/schematic/api/resources/accounts/requests/CountAuditLogsRequest.java index 58bed38..e52fcb7 100644 --- a/src/main/java/com/schematic/api/resources/accounts/requests/CountAuditLogsRequest.java +++ b/src/main/java/com/schematic/api/resources/accounts/requests/CountAuditLogsRequest.java @@ -24,6 +24,8 @@ public final class CountAuditLogsRequest { private final Optional actorType; + private final Optional companyId; + private final Optional endTime; private final Optional environmentId; @@ -40,6 +42,7 @@ public final class CountAuditLogsRequest { private CountAuditLogsRequest( Optional actorType, + Optional companyId, Optional endTime, Optional environmentId, Optional q, @@ -48,6 +51,7 @@ private CountAuditLogsRequest( Optional offset, Map additionalProperties) { this.actorType = actorType; + this.companyId = companyId; this.endTime = endTime; this.environmentId = environmentId; this.q = q; @@ -62,6 +66,11 @@ public Optional getActorType() { return actorType; } + @JsonProperty("company_id") + public Optional getCompanyId() { + return companyId; + } + @JsonProperty("end_time") public Optional getEndTime() { return endTime; @@ -111,6 +120,7 @@ public Map getAdditionalProperties() { private boolean equalTo(CountAuditLogsRequest other) { return actorType.equals(other.actorType) + && companyId.equals(other.companyId) && endTime.equals(other.endTime) && environmentId.equals(other.environmentId) && q.equals(other.q) @@ -122,7 +132,14 @@ private boolean equalTo(CountAuditLogsRequest other) { @java.lang.Override public int hashCode() { return Objects.hash( - this.actorType, this.endTime, this.environmentId, this.q, this.startTime, this.limit, this.offset); + this.actorType, + this.companyId, + this.endTime, + this.environmentId, + this.q, + this.startTime, + this.limit, + this.offset); } @java.lang.Override @@ -138,6 +155,8 @@ public static Builder builder() { public static final class Builder { private Optional actorType = Optional.empty(); + private Optional companyId = Optional.empty(); + private Optional endTime = Optional.empty(); private Optional environmentId = Optional.empty(); @@ -156,6 +175,7 @@ private Builder() {} public Builder from(CountAuditLogsRequest other) { actorType(other.getActorType()); + companyId(other.getCompanyId()); endTime(other.getEndTime()); environmentId(other.getEnvironmentId()); q(other.getQ()); @@ -176,6 +196,17 @@ public Builder actorType(ActorType actorType) { 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 = "end_time", nulls = Nulls.SKIP) public Builder endTime(Optional endTime) { this.endTime = endTime; @@ -250,12 +281,13 @@ public Builder offset(Long offset) { public CountAuditLogsRequest build() { return new CountAuditLogsRequest( - actorType, endTime, environmentId, q, startTime, limit, offset, additionalProperties); + actorType, companyId, endTime, environmentId, q, startTime, limit, offset, additionalProperties); } @JsonAnySetter private void putAdditionalPropertyFromJson(String key, Object value) { if (key.equalsIgnoreCase("actor_type") + || key.equalsIgnoreCase("company_id") || key.equalsIgnoreCase("end_time") || key.equalsIgnoreCase("environment_id") || key.equalsIgnoreCase("q") diff --git a/src/main/java/com/schematic/api/resources/accounts/requests/ListAuditLogsRequest.java b/src/main/java/com/schematic/api/resources/accounts/requests/ListAuditLogsRequest.java index 9d6761b..6f35398 100644 --- a/src/main/java/com/schematic/api/resources/accounts/requests/ListAuditLogsRequest.java +++ b/src/main/java/com/schematic/api/resources/accounts/requests/ListAuditLogsRequest.java @@ -24,6 +24,8 @@ public final class ListAuditLogsRequest { private final Optional actorType; + private final Optional companyId; + private final Optional endTime; private final Optional environmentId; @@ -40,6 +42,7 @@ public final class ListAuditLogsRequest { private ListAuditLogsRequest( Optional actorType, + Optional companyId, Optional endTime, Optional environmentId, Optional q, @@ -48,6 +51,7 @@ private ListAuditLogsRequest( Optional offset, Map additionalProperties) { this.actorType = actorType; + this.companyId = companyId; this.endTime = endTime; this.environmentId = environmentId; this.q = q; @@ -62,6 +66,11 @@ public Optional getActorType() { return actorType; } + @JsonProperty("company_id") + public Optional getCompanyId() { + return companyId; + } + @JsonProperty("end_time") public Optional getEndTime() { return endTime; @@ -111,6 +120,7 @@ public Map getAdditionalProperties() { private boolean equalTo(ListAuditLogsRequest other) { return actorType.equals(other.actorType) + && companyId.equals(other.companyId) && endTime.equals(other.endTime) && environmentId.equals(other.environmentId) && q.equals(other.q) @@ -122,7 +132,14 @@ private boolean equalTo(ListAuditLogsRequest other) { @java.lang.Override public int hashCode() { return Objects.hash( - this.actorType, this.endTime, this.environmentId, this.q, this.startTime, this.limit, this.offset); + this.actorType, + this.companyId, + this.endTime, + this.environmentId, + this.q, + this.startTime, + this.limit, + this.offset); } @java.lang.Override @@ -138,6 +155,8 @@ public static Builder builder() { public static final class Builder { private Optional actorType = Optional.empty(); + private Optional companyId = Optional.empty(); + private Optional endTime = Optional.empty(); private Optional environmentId = Optional.empty(); @@ -156,6 +175,7 @@ private Builder() {} public Builder from(ListAuditLogsRequest other) { actorType(other.getActorType()); + companyId(other.getCompanyId()); endTime(other.getEndTime()); environmentId(other.getEnvironmentId()); q(other.getQ()); @@ -176,6 +196,17 @@ public Builder actorType(ActorType actorType) { 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 = "end_time", nulls = Nulls.SKIP) public Builder endTime(Optional endTime) { this.endTime = endTime; @@ -250,12 +281,13 @@ public Builder offset(Long offset) { public ListAuditLogsRequest build() { return new ListAuditLogsRequest( - actorType, endTime, environmentId, q, startTime, limit, offset, additionalProperties); + actorType, companyId, endTime, environmentId, q, startTime, limit, offset, additionalProperties); } @JsonAnySetter private void putAdditionalPropertyFromJson(String key, Object value) { if (key.equalsIgnoreCase("actor_type") + || key.equalsIgnoreCase("company_id") || key.equalsIgnoreCase("end_time") || key.equalsIgnoreCase("environment_id") || key.equalsIgnoreCase("q") diff --git a/src/main/java/com/schematic/api/resources/accounts/types/CountAuditLogsParams.java b/src/main/java/com/schematic/api/resources/accounts/types/CountAuditLogsParams.java index 694d7a7..1fa5913 100644 --- a/src/main/java/com/schematic/api/resources/accounts/types/CountAuditLogsParams.java +++ b/src/main/java/com/schematic/api/resources/accounts/types/CountAuditLogsParams.java @@ -24,6 +24,8 @@ public final class CountAuditLogsParams { private final Optional actorType; + private final Optional companyId; + private final Optional endTime; private final Optional environmentId; @@ -40,6 +42,7 @@ public final class CountAuditLogsParams { private CountAuditLogsParams( Optional actorType, + Optional companyId, Optional endTime, Optional environmentId, Optional limit, @@ -48,6 +51,7 @@ private CountAuditLogsParams( Optional startTime, Map additionalProperties) { this.actorType = actorType; + this.companyId = companyId; this.endTime = endTime; this.environmentId = environmentId; this.limit = limit; @@ -62,6 +66,11 @@ public Optional getActorType() { return actorType; } + @JsonProperty("company_id") + public Optional getCompanyId() { + return companyId; + } + @JsonProperty("end_time") public Optional getEndTime() { return endTime; @@ -111,6 +120,7 @@ public Map getAdditionalProperties() { private boolean equalTo(CountAuditLogsParams other) { return actorType.equals(other.actorType) + && companyId.equals(other.companyId) && endTime.equals(other.endTime) && environmentId.equals(other.environmentId) && limit.equals(other.limit) @@ -122,7 +132,14 @@ private boolean equalTo(CountAuditLogsParams other) { @java.lang.Override public int hashCode() { return Objects.hash( - this.actorType, this.endTime, this.environmentId, this.limit, this.offset, this.q, this.startTime); + this.actorType, + this.companyId, + this.endTime, + this.environmentId, + this.limit, + this.offset, + this.q, + this.startTime); } @java.lang.Override @@ -138,6 +155,8 @@ public static Builder builder() { public static final class Builder { private Optional actorType = Optional.empty(); + private Optional companyId = Optional.empty(); + private Optional endTime = Optional.empty(); private Optional environmentId = Optional.empty(); @@ -156,6 +175,7 @@ private Builder() {} public Builder from(CountAuditLogsParams other) { actorType(other.getActorType()); + companyId(other.getCompanyId()); endTime(other.getEndTime()); environmentId(other.getEnvironmentId()); limit(other.getLimit()); @@ -176,6 +196,17 @@ public Builder actorType(ActorType actorType) { 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 = "end_time", nulls = Nulls.SKIP) public Builder endTime(Optional endTime) { this.endTime = endTime; @@ -250,12 +281,13 @@ public Builder startTime(OffsetDateTime startTime) { public CountAuditLogsParams build() { return new CountAuditLogsParams( - actorType, endTime, environmentId, limit, offset, q, startTime, additionalProperties); + actorType, companyId, endTime, environmentId, limit, offset, q, startTime, additionalProperties); } @JsonAnySetter private void putAdditionalPropertyFromJson(String key, Object value) { if (key.equalsIgnoreCase("actor_type") + || key.equalsIgnoreCase("company_id") || key.equalsIgnoreCase("end_time") || key.equalsIgnoreCase("environment_id") || key.equalsIgnoreCase("limit") diff --git a/src/main/java/com/schematic/api/resources/accounts/types/ListAuditLogsParams.java b/src/main/java/com/schematic/api/resources/accounts/types/ListAuditLogsParams.java index 93b70e6..15630e4 100644 --- a/src/main/java/com/schematic/api/resources/accounts/types/ListAuditLogsParams.java +++ b/src/main/java/com/schematic/api/resources/accounts/types/ListAuditLogsParams.java @@ -24,6 +24,8 @@ public final class ListAuditLogsParams { private final Optional actorType; + private final Optional companyId; + private final Optional endTime; private final Optional environmentId; @@ -40,6 +42,7 @@ public final class ListAuditLogsParams { private ListAuditLogsParams( Optional actorType, + Optional companyId, Optional endTime, Optional environmentId, Optional limit, @@ -48,6 +51,7 @@ private ListAuditLogsParams( Optional startTime, Map additionalProperties) { this.actorType = actorType; + this.companyId = companyId; this.endTime = endTime; this.environmentId = environmentId; this.limit = limit; @@ -62,6 +66,11 @@ public Optional getActorType() { return actorType; } + @JsonProperty("company_id") + public Optional getCompanyId() { + return companyId; + } + @JsonProperty("end_time") public Optional getEndTime() { return endTime; @@ -111,6 +120,7 @@ public Map getAdditionalProperties() { private boolean equalTo(ListAuditLogsParams other) { return actorType.equals(other.actorType) + && companyId.equals(other.companyId) && endTime.equals(other.endTime) && environmentId.equals(other.environmentId) && limit.equals(other.limit) @@ -122,7 +132,14 @@ private boolean equalTo(ListAuditLogsParams other) { @java.lang.Override public int hashCode() { return Objects.hash( - this.actorType, this.endTime, this.environmentId, this.limit, this.offset, this.q, this.startTime); + this.actorType, + this.companyId, + this.endTime, + this.environmentId, + this.limit, + this.offset, + this.q, + this.startTime); } @java.lang.Override @@ -138,6 +155,8 @@ public static Builder builder() { public static final class Builder { private Optional actorType = Optional.empty(); + private Optional companyId = Optional.empty(); + private Optional endTime = Optional.empty(); private Optional environmentId = Optional.empty(); @@ -156,6 +175,7 @@ private Builder() {} public Builder from(ListAuditLogsParams other) { actorType(other.getActorType()); + companyId(other.getCompanyId()); endTime(other.getEndTime()); environmentId(other.getEnvironmentId()); limit(other.getLimit()); @@ -176,6 +196,17 @@ public Builder actorType(ActorType actorType) { 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 = "end_time", nulls = Nulls.SKIP) public Builder endTime(Optional endTime) { this.endTime = endTime; @@ -250,12 +281,13 @@ public Builder startTime(OffsetDateTime startTime) { public ListAuditLogsParams build() { return new ListAuditLogsParams( - actorType, endTime, environmentId, limit, offset, q, startTime, additionalProperties); + actorType, companyId, endTime, environmentId, limit, offset, q, startTime, additionalProperties); } @JsonAnySetter private void putAdditionalPropertyFromJson(String key, Object value) { if (key.equalsIgnoreCase("actor_type") + || key.equalsIgnoreCase("company_id") || key.equalsIgnoreCase("end_time") || key.equalsIgnoreCase("environment_id") || key.equalsIgnoreCase("limit") 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 index 5bc75ed..8c04bcf 100644 --- a/src/main/java/com/schematic/api/resources/billing/requests/UpdateCompanyBillingProfileRequestBody.java +++ b/src/main/java/com/schematic/api/resources/billing/requests/UpdateCompanyBillingProfileRequestBody.java @@ -13,6 +13,8 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.schematic.api.core.ObjectMappers; import com.schematic.api.types.BillingCollectionMethod; +import com.schematic.api.types.Currency; +import com.schematic.api.types.PaymentGating; import com.schematic.api.types.ProrationBehavior; import java.util.HashMap; import java.util.Map; @@ -25,12 +27,20 @@ public final class UpdateCompanyBillingProfileRequestBody { private final BillingCollectionMethod collectionMethod; + private final Optional currency; + private final Optional daysUntilDue; + private final Optional gatingDays; + private final Optional isDefault; private final Optional name; + private final Optional overdraftLimit; + + private final Optional paymentGating; + private final Optional paymentMethodId; private final Optional prorationBehavior; @@ -39,16 +49,24 @@ public final class UpdateCompanyBillingProfileRequestBody { private UpdateCompanyBillingProfileRequestBody( BillingCollectionMethod collectionMethod, + Optional currency, Optional daysUntilDue, + Optional gatingDays, Optional isDefault, Optional name, + Optional overdraftLimit, + Optional paymentGating, Optional paymentMethodId, Optional prorationBehavior, Map additionalProperties) { this.collectionMethod = collectionMethod; + this.currency = currency; this.daysUntilDue = daysUntilDue; + this.gatingDays = gatingDays; this.isDefault = isDefault; this.name = name; + this.overdraftLimit = overdraftLimit; + this.paymentGating = paymentGating; this.paymentMethodId = paymentMethodId; this.prorationBehavior = prorationBehavior; this.additionalProperties = additionalProperties; @@ -59,11 +77,21 @@ public BillingCollectionMethod getCollectionMethod() { return collectionMethod; } + @JsonProperty("currency") + public Optional getCurrency() { + return currency; + } + @JsonProperty("days_until_due") public Optional getDaysUntilDue() { return daysUntilDue; } + @JsonProperty("gating_days") + public Optional getGatingDays() { + return gatingDays; + } + @JsonProperty("is_default") public Optional getIsDefault() { return isDefault; @@ -74,6 +102,16 @@ public Optional getName() { return name; } + @JsonProperty("overdraft_limit") + public Optional getOverdraftLimit() { + return overdraftLimit; + } + + @JsonProperty("payment_gating") + public Optional getPaymentGating() { + return paymentGating; + } + @JsonProperty("payment_method_id") public Optional getPaymentMethodId() { return paymentMethodId; @@ -98,9 +136,13 @@ public Map getAdditionalProperties() { private boolean equalTo(UpdateCompanyBillingProfileRequestBody other) { return collectionMethod.equals(other.collectionMethod) + && currency.equals(other.currency) && daysUntilDue.equals(other.daysUntilDue) + && gatingDays.equals(other.gatingDays) && isDefault.equals(other.isDefault) && name.equals(other.name) + && overdraftLimit.equals(other.overdraftLimit) + && paymentGating.equals(other.paymentGating) && paymentMethodId.equals(other.paymentMethodId) && prorationBehavior.equals(other.prorationBehavior); } @@ -109,9 +151,13 @@ private boolean equalTo(UpdateCompanyBillingProfileRequestBody other) { public int hashCode() { return Objects.hash( this.collectionMethod, + this.currency, this.daysUntilDue, + this.gatingDays, this.isDefault, this.name, + this.overdraftLimit, + this.paymentGating, this.paymentMethodId, this.prorationBehavior); } @@ -138,10 +184,18 @@ public interface _FinalStage { _FinalStage additionalProperties(Map additionalProperties); + _FinalStage currency(Optional currency); + + _FinalStage currency(Currency currency); + _FinalStage daysUntilDue(Optional daysUntilDue); _FinalStage daysUntilDue(Long daysUntilDue); + _FinalStage gatingDays(Optional gatingDays); + + _FinalStage gatingDays(Long gatingDays); + _FinalStage isDefault(Optional isDefault); _FinalStage isDefault(Boolean isDefault); @@ -150,6 +204,14 @@ public interface _FinalStage { _FinalStage name(String name); + _FinalStage overdraftLimit(Optional overdraftLimit); + + _FinalStage overdraftLimit(Long overdraftLimit); + + _FinalStage paymentGating(Optional paymentGating); + + _FinalStage paymentGating(PaymentGating paymentGating); + _FinalStage paymentMethodId(Optional paymentMethodId); _FinalStage paymentMethodId(String paymentMethodId); @@ -167,12 +229,20 @@ public static final class Builder implements CollectionMethodStage, _FinalStage private Optional paymentMethodId = Optional.empty(); + private Optional paymentGating = Optional.empty(); + + private Optional overdraftLimit = Optional.empty(); + private Optional name = Optional.empty(); private Optional isDefault = Optional.empty(); + private Optional gatingDays = Optional.empty(); + private Optional daysUntilDue = Optional.empty(); + private Optional currency = Optional.empty(); + private Map additionalProperties = new HashMap<>(); private Builder() {} @@ -180,9 +250,13 @@ private Builder() {} @java.lang.Override public Builder from(UpdateCompanyBillingProfileRequestBody other) { collectionMethod(other.getCollectionMethod()); + currency(other.getCurrency()); daysUntilDue(other.getDaysUntilDue()); + gatingDays(other.getGatingDays()); isDefault(other.getIsDefault()); name(other.getName()); + overdraftLimit(other.getOverdraftLimit()); + paymentGating(other.getPaymentGating()); paymentMethodId(other.getPaymentMethodId()); prorationBehavior(other.getProrationBehavior()); return this; @@ -221,6 +295,32 @@ public _FinalStage paymentMethodId(Optional paymentMethodId) { return this; } + @java.lang.Override + public _FinalStage paymentGating(PaymentGating paymentGating) { + this.paymentGating = Optional.ofNullable(paymentGating); + return this; + } + + @java.lang.Override + @JsonSetter(value = "payment_gating", nulls = Nulls.SKIP) + public _FinalStage paymentGating(Optional paymentGating) { + this.paymentGating = paymentGating; + return this; + } + + @java.lang.Override + public _FinalStage overdraftLimit(Long overdraftLimit) { + this.overdraftLimit = Optional.ofNullable(overdraftLimit); + return this; + } + + @java.lang.Override + @JsonSetter(value = "overdraft_limit", nulls = Nulls.SKIP) + public _FinalStage overdraftLimit(Optional overdraftLimit) { + this.overdraftLimit = overdraftLimit; + return this; + } + @java.lang.Override public _FinalStage name(String name) { this.name = Optional.ofNullable(name); @@ -247,6 +347,19 @@ public _FinalStage isDefault(Optional isDefault) { return this; } + @java.lang.Override + public _FinalStage gatingDays(Long gatingDays) { + this.gatingDays = Optional.ofNullable(gatingDays); + return this; + } + + @java.lang.Override + @JsonSetter(value = "gating_days", nulls = Nulls.SKIP) + public _FinalStage gatingDays(Optional gatingDays) { + this.gatingDays = gatingDays; + return this; + } + @java.lang.Override public _FinalStage daysUntilDue(Long daysUntilDue) { this.daysUntilDue = Optional.ofNullable(daysUntilDue); @@ -260,13 +373,30 @@ public _FinalStage daysUntilDue(Optional daysUntilDue) { return this; } + @java.lang.Override + public _FinalStage currency(Currency currency) { + this.currency = Optional.ofNullable(currency); + return this; + } + + @java.lang.Override + @JsonSetter(value = "currency", nulls = Nulls.SKIP) + public _FinalStage currency(Optional currency) { + this.currency = currency; + return this; + } + @java.lang.Override public UpdateCompanyBillingProfileRequestBody build() { return new UpdateCompanyBillingProfileRequestBody( collectionMethod, + currency, daysUntilDue, + gatingDays, isDefault, name, + overdraftLimit, + paymentGating, paymentMethodId, prorationBehavior, additionalProperties); @@ -275,9 +405,13 @@ public UpdateCompanyBillingProfileRequestBody build() { @JsonAnySetter private void putAdditionalPropertyFromJson(String key, Object value) { if (key.equalsIgnoreCase("collection_method") + || key.equalsIgnoreCase("currency") || key.equalsIgnoreCase("days_until_due") + || key.equalsIgnoreCase("gating_days") || key.equalsIgnoreCase("is_default") || key.equalsIgnoreCase("name") + || key.equalsIgnoreCase("overdraft_limit") + || key.equalsIgnoreCase("payment_gating") || key.equalsIgnoreCase("payment_method_id") || key.equalsIgnoreCase("proration_behavior")) { return; diff --git a/src/main/java/com/schematic/api/resources/companies/AsyncCompaniesClient.java b/src/main/java/com/schematic/api/resources/companies/AsyncCompaniesClient.java index f404a28..4e3823f 100644 --- a/src/main/java/com/schematic/api/resources/companies/AsyncCompaniesClient.java +++ b/src/main/java/com/schematic/api/resources/companies/AsyncCompaniesClient.java @@ -18,6 +18,7 @@ import com.schematic.api.resources.companies.requests.GetActiveCompanySubscriptionRequest; import com.schematic.api.resources.companies.requests.GetBillingEntityChildSubscriptionsRequest; import com.schematic.api.resources.companies.requests.GetCompanyBillingEntityRequest; +import com.schematic.api.resources.companies.requests.GetCompanyInferenceCostRequest; import com.schematic.api.resources.companies.requests.GetEntityTraitValuesRequest; import com.schematic.api.resources.companies.requests.GetOrCreateCompanyMembershipRequestBody; import com.schematic.api.resources.companies.requests.ListCompaniesRequest; @@ -50,6 +51,7 @@ import com.schematic.api.resources.companies.types.GetActiveCompanySubscriptionResponse; import com.schematic.api.resources.companies.types.GetBillingEntityChildSubscriptionsResponse; import com.schematic.api.resources.companies.types.GetCompanyBillingEntityResponse; +import com.schematic.api.resources.companies.types.GetCompanyInferenceCostResponse; import com.schematic.api.resources.companies.types.GetCompanyResponse; import com.schematic.api.resources.companies.types.GetEntityTraitDefinitionResponse; import com.schematic.api.resources.companies.types.GetEntityTraitDefinitionUsageResponse; @@ -243,6 +245,57 @@ public CompletableFuture deleteCompany( return future; } + public CompletableFuture getCompanyInferenceCost(String companyId) { + CompletableFuture> rawFuture = + this.rawClient.getCompanyInferenceCost(companyId); + CompletableFuture future = rawFuture.thenApply(response -> response.body()); + future.whenComplete((result_, throwable_) -> { + if (future.isCancelled()) { + rawFuture.cancel(true); + } + }); + return future; + } + + public CompletableFuture getCompanyInferenceCost( + String companyId, RequestOptions requestOptions) { + CompletableFuture> rawFuture = + this.rawClient.getCompanyInferenceCost(companyId, requestOptions); + CompletableFuture future = rawFuture.thenApply(response -> response.body()); + future.whenComplete((result_, throwable_) -> { + if (future.isCancelled()) { + rawFuture.cancel(true); + } + }); + return future; + } + + public CompletableFuture getCompanyInferenceCost( + String companyId, GetCompanyInferenceCostRequest request) { + CompletableFuture> rawFuture = + this.rawClient.getCompanyInferenceCost(companyId, request); + CompletableFuture future = rawFuture.thenApply(response -> response.body()); + future.whenComplete((result_, throwable_) -> { + if (future.isCancelled()) { + rawFuture.cancel(true); + } + }); + return future; + } + + public CompletableFuture getCompanyInferenceCost( + String companyId, GetCompanyInferenceCostRequest request, RequestOptions requestOptions) { + CompletableFuture> rawFuture = + this.rawClient.getCompanyInferenceCost(companyId, request, requestOptions); + CompletableFuture future = rawFuture.thenApply(response -> response.body()); + future.whenComplete((result_, throwable_) -> { + if (future.isCancelled()) { + rawFuture.cancel(true); + } + }); + return future; + } + public CompletableFuture countCompanies() { CompletableFuture> rawFuture = this.rawClient.countCompanies(); diff --git a/src/main/java/com/schematic/api/resources/companies/AsyncRawCompaniesClient.java b/src/main/java/com/schematic/api/resources/companies/AsyncRawCompaniesClient.java index fedc651..8efd06c 100644 --- a/src/main/java/com/schematic/api/resources/companies/AsyncRawCompaniesClient.java +++ b/src/main/java/com/schematic/api/resources/companies/AsyncRawCompaniesClient.java @@ -32,6 +32,7 @@ import com.schematic.api.resources.companies.requests.GetActiveCompanySubscriptionRequest; import com.schematic.api.resources.companies.requests.GetBillingEntityChildSubscriptionsRequest; import com.schematic.api.resources.companies.requests.GetCompanyBillingEntityRequest; +import com.schematic.api.resources.companies.requests.GetCompanyInferenceCostRequest; import com.schematic.api.resources.companies.requests.GetEntityTraitValuesRequest; import com.schematic.api.resources.companies.requests.GetOrCreateCompanyMembershipRequestBody; import com.schematic.api.resources.companies.requests.ListCompaniesRequest; @@ -64,6 +65,7 @@ import com.schematic.api.resources.companies.types.GetActiveCompanySubscriptionResponse; import com.schematic.api.resources.companies.types.GetBillingEntityChildSubscriptionsResponse; import com.schematic.api.resources.companies.types.GetCompanyBillingEntityResponse; +import com.schematic.api.resources.companies.types.GetCompanyInferenceCostResponse; import com.schematic.api.resources.companies.types.GetCompanyResponse; import com.schematic.api.resources.companies.types.GetEntityTraitDefinitionResponse; import com.schematic.api.resources.companies.types.GetEntityTraitDefinitionUsageResponse; @@ -132,6 +134,13 @@ public CompletableFuture> listC HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("companies"); + if (request.getCancelAtPeriodEnd().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "cancel_at_period_end", + request.getCancelAtPeriodEnd().get(), + false); + } if (request.getHasScheduledDowngrade().isPresent()) { QueryStringMapper.addQueryParameter( httpUrl, @@ -672,6 +681,128 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { return future; } + public CompletableFuture> getCompanyInferenceCost( + String companyId) { + return getCompanyInferenceCost( + companyId, GetCompanyInferenceCostRequest.builder().build()); + } + + public CompletableFuture> getCompanyInferenceCost( + String companyId, RequestOptions requestOptions) { + return getCompanyInferenceCost( + companyId, GetCompanyInferenceCostRequest.builder().build(), requestOptions); + } + + public CompletableFuture> getCompanyInferenceCost( + String companyId, GetCompanyInferenceCostRequest request) { + return getCompanyInferenceCost(companyId, request, null); + } + + public CompletableFuture> getCompanyInferenceCost( + String companyId, GetCompanyInferenceCostRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("companies") + .addPathSegment(PathSegments.validate(companyId)) + .addPathSegments("inference-cost"); + if (request.getEndTime().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "end_time", request.getEndTime().get(), false); + } + if (request.getStartTime().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "start_time", request.getStartTime().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<>(); + RetryInterceptor.AsyncCall okhttpCall = RetryInterceptor.newAsyncCall(client, okhttpRequest); + okhttpCall.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, GetCompanyInferenceCostResponse.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)); + } + }); + future.whenComplete((result_, throwable_) -> { + if (future.isCancelled()) { + okhttpCall.cancel(); + } + }); + return future; + } + public CompletableFuture> countCompanies() { return countCompanies(CountCompaniesRequest.builder().build()); } @@ -691,6 +822,13 @@ public CompletableFuture> coun HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("companies/count"); + if (request.getCancelAtPeriodEnd().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "cancel_at_period_end", + request.getCancelAtPeriodEnd().get(), + false); + } if (request.getHasScheduledDowngrade().isPresent()) { QueryStringMapper.addQueryParameter( httpUrl, diff --git a/src/main/java/com/schematic/api/resources/companies/CompaniesClient.java b/src/main/java/com/schematic/api/resources/companies/CompaniesClient.java index 7b6fe1c..56ea3d4 100644 --- a/src/main/java/com/schematic/api/resources/companies/CompaniesClient.java +++ b/src/main/java/com/schematic/api/resources/companies/CompaniesClient.java @@ -17,6 +17,7 @@ import com.schematic.api.resources.companies.requests.GetActiveCompanySubscriptionRequest; import com.schematic.api.resources.companies.requests.GetBillingEntityChildSubscriptionsRequest; import com.schematic.api.resources.companies.requests.GetCompanyBillingEntityRequest; +import com.schematic.api.resources.companies.requests.GetCompanyInferenceCostRequest; import com.schematic.api.resources.companies.requests.GetEntityTraitValuesRequest; import com.schematic.api.resources.companies.requests.GetOrCreateCompanyMembershipRequestBody; import com.schematic.api.resources.companies.requests.ListCompaniesRequest; @@ -49,6 +50,7 @@ import com.schematic.api.resources.companies.types.GetActiveCompanySubscriptionResponse; import com.schematic.api.resources.companies.types.GetBillingEntityChildSubscriptionsResponse; import com.schematic.api.resources.companies.types.GetCompanyBillingEntityResponse; +import com.schematic.api.resources.companies.types.GetCompanyInferenceCostResponse; import com.schematic.api.resources.companies.types.GetCompanyResponse; import com.schematic.api.resources.companies.types.GetEntityTraitDefinitionResponse; import com.schematic.api.resources.companies.types.GetEntityTraitDefinitionUsageResponse; @@ -144,6 +146,26 @@ public DeleteCompanyResponse deleteCompany( return this.rawClient.deleteCompany(companyId, request, requestOptions).body(); } + public GetCompanyInferenceCostResponse getCompanyInferenceCost(String companyId) { + return this.rawClient.getCompanyInferenceCost(companyId).body(); + } + + public GetCompanyInferenceCostResponse getCompanyInferenceCost(String companyId, RequestOptions requestOptions) { + return this.rawClient.getCompanyInferenceCost(companyId, requestOptions).body(); + } + + public GetCompanyInferenceCostResponse getCompanyInferenceCost( + String companyId, GetCompanyInferenceCostRequest request) { + return this.rawClient.getCompanyInferenceCost(companyId, request).body(); + } + + public GetCompanyInferenceCostResponse getCompanyInferenceCost( + String companyId, GetCompanyInferenceCostRequest request, RequestOptions requestOptions) { + return this.rawClient + .getCompanyInferenceCost(companyId, request, requestOptions) + .body(); + } + public CountCompaniesResponse countCompanies() { return this.rawClient.countCompanies().body(); } diff --git a/src/main/java/com/schematic/api/resources/companies/RawCompaniesClient.java b/src/main/java/com/schematic/api/resources/companies/RawCompaniesClient.java index fcf8ca6..03b0530 100644 --- a/src/main/java/com/schematic/api/resources/companies/RawCompaniesClient.java +++ b/src/main/java/com/schematic/api/resources/companies/RawCompaniesClient.java @@ -32,6 +32,7 @@ import com.schematic.api.resources.companies.requests.GetActiveCompanySubscriptionRequest; import com.schematic.api.resources.companies.requests.GetBillingEntityChildSubscriptionsRequest; import com.schematic.api.resources.companies.requests.GetCompanyBillingEntityRequest; +import com.schematic.api.resources.companies.requests.GetCompanyInferenceCostRequest; import com.schematic.api.resources.companies.requests.GetEntityTraitValuesRequest; import com.schematic.api.resources.companies.requests.GetOrCreateCompanyMembershipRequestBody; import com.schematic.api.resources.companies.requests.ListCompaniesRequest; @@ -64,6 +65,7 @@ import com.schematic.api.resources.companies.types.GetActiveCompanySubscriptionResponse; import com.schematic.api.resources.companies.types.GetBillingEntityChildSubscriptionsResponse; import com.schematic.api.resources.companies.types.GetCompanyBillingEntityResponse; +import com.schematic.api.resources.companies.types.GetCompanyInferenceCostResponse; import com.schematic.api.resources.companies.types.GetCompanyResponse; import com.schematic.api.resources.companies.types.GetEntityTraitDefinitionResponse; import com.schematic.api.resources.companies.types.GetEntityTraitDefinitionUsageResponse; @@ -126,6 +128,13 @@ public BaseSchematicHttpResponse listCompanies( HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("companies"); + if (request.getCancelAtPeriodEnd().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "cancel_at_period_end", + request.getCancelAtPeriodEnd().get(), + false); + } if (request.getHasScheduledDowngrade().isPresent()) { QueryStringMapper.addQueryParameter( httpUrl, @@ -542,6 +551,97 @@ public BaseSchematicHttpResponse deleteCompany( } } + public BaseSchematicHttpResponse getCompanyInferenceCost(String companyId) { + return getCompanyInferenceCost( + companyId, GetCompanyInferenceCostRequest.builder().build()); + } + + public BaseSchematicHttpResponse getCompanyInferenceCost( + String companyId, RequestOptions requestOptions) { + return getCompanyInferenceCost( + companyId, GetCompanyInferenceCostRequest.builder().build(), requestOptions); + } + + public BaseSchematicHttpResponse getCompanyInferenceCost( + String companyId, GetCompanyInferenceCostRequest request) { + return getCompanyInferenceCost(companyId, request, null); + } + + public BaseSchematicHttpResponse getCompanyInferenceCost( + String companyId, GetCompanyInferenceCostRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("companies") + .addPathSegment(PathSegments.validate(companyId)) + .addPathSegments("inference-cost"); + if (request.getEndTime().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "end_time", request.getEndTime().get(), false); + } + if (request.getStartTime().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "start_time", request.getStartTime().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, GetCompanyInferenceCostResponse.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 countCompanies() { return countCompanies(CountCompaniesRequest.builder().build()); } @@ -559,6 +659,13 @@ public BaseSchematicHttpResponse countCompanies( HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("companies/count"); + if (request.getCancelAtPeriodEnd().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "cancel_at_period_end", + request.getCancelAtPeriodEnd().get(), + false); + } if (request.getHasScheduledDowngrade().isPresent()) { QueryStringMapper.addQueryParameter( httpUrl, diff --git a/src/main/java/com/schematic/api/resources/companies/requests/CountCompaniesRequest.java b/src/main/java/com/schematic/api/resources/companies/requests/CountCompaniesRequest.java index 567a0e0..91fd1c4 100644 --- a/src/main/java/com/schematic/api/resources/companies/requests/CountCompaniesRequest.java +++ b/src/main/java/com/schematic/api/resources/companies/requests/CountCompaniesRequest.java @@ -37,6 +37,8 @@ public final class CountCompaniesRequest { private final Optional> subscriptionTypes; + private final Optional cancelAtPeriodEnd; + private final Optional hasScheduledDowngrade; private final Optional monetizedSubscriptions; @@ -76,6 +78,7 @@ private CountCompaniesRequest( Optional> planVersionIds, Optional> subscriptionStatuses, Optional> subscriptionTypes, + Optional cancelAtPeriodEnd, Optional hasScheduledDowngrade, Optional monetizedSubscriptions, Optional planId, @@ -98,6 +101,7 @@ private CountCompaniesRequest( this.planVersionIds = planVersionIds; this.subscriptionStatuses = subscriptionStatuses; this.subscriptionTypes = subscriptionTypes; + this.cancelAtPeriodEnd = cancelAtPeriodEnd; this.hasScheduledDowngrade = hasScheduledDowngrade; this.monetizedSubscriptions = monetizedSubscriptions; this.planId = planId; @@ -165,7 +169,15 @@ public Optional> getSubscriptionTypes() { } /** - * @return Filter companies that have a pending scheduled downgrade + * @return If true, filter companies with an active subscription that is set to cancel at the end of the current period; if false, filter companies without one + */ + @JsonProperty("cancel_at_period_end") + public Optional getCancelAtPeriodEnd() { + return cancelAtPeriodEnd; + } + + /** + * @return If true, filter companies that have a pending scheduled downgrade; if false, filter companies that do not */ @JsonProperty("has_scheduled_downgrade") public Optional getHasScheduledDowngrade() { @@ -302,6 +314,7 @@ private boolean equalTo(CountCompaniesRequest other) { && planVersionIds.equals(other.planVersionIds) && subscriptionStatuses.equals(other.subscriptionStatuses) && subscriptionTypes.equals(other.subscriptionTypes) + && cancelAtPeriodEnd.equals(other.cancelAtPeriodEnd) && hasScheduledDowngrade.equals(other.hasScheduledDowngrade) && monetizedSubscriptions.equals(other.monetizedSubscriptions) && planId.equals(other.planId) @@ -328,6 +341,7 @@ public int hashCode() { this.planVersionIds, this.subscriptionStatuses, this.subscriptionTypes, + this.cancelAtPeriodEnd, this.hasScheduledDowngrade, this.monetizedSubscriptions, this.planId, @@ -368,6 +382,8 @@ public static final class Builder { private Optional> subscriptionTypes = Optional.empty(); + private Optional cancelAtPeriodEnd = Optional.empty(); + private Optional hasScheduledDowngrade = Optional.empty(); private Optional monetizedSubscriptions = Optional.empty(); @@ -409,6 +425,7 @@ public Builder from(CountCompaniesRequest other) { planVersionIds(other.getPlanVersionIds()); subscriptionStatuses(other.getSubscriptionStatuses()); subscriptionTypes(other.getSubscriptionTypes()); + cancelAtPeriodEnd(other.getCancelAtPeriodEnd()); hasScheduledDowngrade(other.getHasScheduledDowngrade()); monetizedSubscriptions(other.getMonetizedSubscriptions()); planId(other.getPlanId()); @@ -542,7 +559,21 @@ public Builder subscriptionTypes(SubscriptionType subscriptionTypes) { } /** - *

Filter companies that have a pending scheduled downgrade

+ *

If true, filter companies with an active subscription that is set to cancel at the end of the current period; if false, filter companies without one

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

If true, filter companies that have a pending scheduled downgrade; if false, filter companies that do not

*/ @JsonSetter(value = "has_scheduled_downgrade", nulls = Nulls.SKIP) public Builder hasScheduledDowngrade(Optional hasScheduledDowngrade) { @@ -759,6 +790,7 @@ public CountCompaniesRequest build() { planVersionIds, subscriptionStatuses, subscriptionTypes, + cancelAtPeriodEnd, hasScheduledDowngrade, monetizedSubscriptions, planId, @@ -785,6 +817,7 @@ private void putAdditionalPropertyFromJson(String key, Object value) { || key.equalsIgnoreCase("plan_version_ids") || key.equalsIgnoreCase("subscription_statuses") || key.equalsIgnoreCase("subscription_types") + || key.equalsIgnoreCase("cancel_at_period_end") || key.equalsIgnoreCase("has_scheduled_downgrade") || key.equalsIgnoreCase("monetized_subscriptions") || key.equalsIgnoreCase("plan_id") diff --git a/src/main/java/com/schematic/api/resources/companies/requests/GetCompanyInferenceCostRequest.java b/src/main/java/com/schematic/api/resources/companies/requests/GetCompanyInferenceCostRequest.java new file mode 100644 index 0000000..1ce2dc7 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/companies/requests/GetCompanyInferenceCostRequest.java @@ -0,0 +1,150 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.companies.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import java.time.OffsetDateTime; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = GetCompanyInferenceCostRequest.Builder.class) +public final class GetCompanyInferenceCostRequest { + private final Optional endTime; + + private final Optional startTime; + + private final Map additionalProperties; + + private GetCompanyInferenceCostRequest( + Optional endTime, + Optional startTime, + Map additionalProperties) { + this.endTime = endTime; + this.startTime = startTime; + this.additionalProperties = additionalProperties; + } + + /** + * @return End of the window (exclusive). Pass together with start_time; when both are omitted, the company's current billing period is used + */ + @JsonProperty("end_time") + public Optional getEndTime() { + return endTime; + } + + /** + * @return Start of the window (inclusive). Pass together with end_time; when both are omitted, the company's current billing period is used + */ + @JsonProperty("start_time") + public Optional getStartTime() { + return startTime; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof GetCompanyInferenceCostRequest && equalTo((GetCompanyInferenceCostRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(GetCompanyInferenceCostRequest other) { + return endTime.equals(other.endTime) && startTime.equals(other.startTime); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.endTime, this.startTime); + } + + @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 endTime = Optional.empty(); + + private Optional startTime = Optional.empty(); + + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(GetCompanyInferenceCostRequest other) { + endTime(other.getEndTime()); + startTime(other.getStartTime()); + return this; + } + + /** + *

End of the window (exclusive). Pass together with start_time; when both are omitted, the company's current billing period is used

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

Start of the window (inclusive). Pass together with end_time; when both are omitted, the company's current billing period is used

+ */ + @JsonSetter(value = "start_time", nulls = Nulls.SKIP) + public Builder startTime(Optional startTime) { + this.startTime = startTime; + return this; + } + + public Builder startTime(OffsetDateTime startTime) { + this.startTime = Optional.ofNullable(startTime); + return this; + } + + public GetCompanyInferenceCostRequest build() { + return new GetCompanyInferenceCostRequest(endTime, startTime, additionalProperties); + } + + @JsonAnySetter + private void putAdditionalPropertyFromJson(String key, Object value) { + if (key.equalsIgnoreCase("end_time") || key.equalsIgnoreCase("start_time")) { + return; + } + this.additionalProperties.put(key, value); + } + + 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/companies/requests/ListCompaniesRequest.java b/src/main/java/com/schematic/api/resources/companies/requests/ListCompaniesRequest.java index f5b653d..e8f6fc5 100644 --- a/src/main/java/com/schematic/api/resources/companies/requests/ListCompaniesRequest.java +++ b/src/main/java/com/schematic/api/resources/companies/requests/ListCompaniesRequest.java @@ -37,6 +37,8 @@ public final class ListCompaniesRequest { private final Optional> subscriptionTypes; + private final Optional cancelAtPeriodEnd; + private final Optional hasScheduledDowngrade; private final Optional monetizedSubscriptions; @@ -76,6 +78,7 @@ private ListCompaniesRequest( Optional> planVersionIds, Optional> subscriptionStatuses, Optional> subscriptionTypes, + Optional cancelAtPeriodEnd, Optional hasScheduledDowngrade, Optional monetizedSubscriptions, Optional planId, @@ -98,6 +101,7 @@ private ListCompaniesRequest( this.planVersionIds = planVersionIds; this.subscriptionStatuses = subscriptionStatuses; this.subscriptionTypes = subscriptionTypes; + this.cancelAtPeriodEnd = cancelAtPeriodEnd; this.hasScheduledDowngrade = hasScheduledDowngrade; this.monetizedSubscriptions = monetizedSubscriptions; this.planId = planId; @@ -165,7 +169,15 @@ public Optional> getSubscriptionTypes() { } /** - * @return Filter companies that have a pending scheduled downgrade + * @return If true, filter companies with an active subscription that is set to cancel at the end of the current period; if false, filter companies without one + */ + @JsonProperty("cancel_at_period_end") + public Optional getCancelAtPeriodEnd() { + return cancelAtPeriodEnd; + } + + /** + * @return If true, filter companies that have a pending scheduled downgrade; if false, filter companies that do not */ @JsonProperty("has_scheduled_downgrade") public Optional getHasScheduledDowngrade() { @@ -302,6 +314,7 @@ private boolean equalTo(ListCompaniesRequest other) { && planVersionIds.equals(other.planVersionIds) && subscriptionStatuses.equals(other.subscriptionStatuses) && subscriptionTypes.equals(other.subscriptionTypes) + && cancelAtPeriodEnd.equals(other.cancelAtPeriodEnd) && hasScheduledDowngrade.equals(other.hasScheduledDowngrade) && monetizedSubscriptions.equals(other.monetizedSubscriptions) && planId.equals(other.planId) @@ -328,6 +341,7 @@ public int hashCode() { this.planVersionIds, this.subscriptionStatuses, this.subscriptionTypes, + this.cancelAtPeriodEnd, this.hasScheduledDowngrade, this.monetizedSubscriptions, this.planId, @@ -368,6 +382,8 @@ public static final class Builder { private Optional> subscriptionTypes = Optional.empty(); + private Optional cancelAtPeriodEnd = Optional.empty(); + private Optional hasScheduledDowngrade = Optional.empty(); private Optional monetizedSubscriptions = Optional.empty(); @@ -409,6 +425,7 @@ public Builder from(ListCompaniesRequest other) { planVersionIds(other.getPlanVersionIds()); subscriptionStatuses(other.getSubscriptionStatuses()); subscriptionTypes(other.getSubscriptionTypes()); + cancelAtPeriodEnd(other.getCancelAtPeriodEnd()); hasScheduledDowngrade(other.getHasScheduledDowngrade()); monetizedSubscriptions(other.getMonetizedSubscriptions()); planId(other.getPlanId()); @@ -542,7 +559,21 @@ public Builder subscriptionTypes(SubscriptionType subscriptionTypes) { } /** - *

Filter companies that have a pending scheduled downgrade

+ *

If true, filter companies with an active subscription that is set to cancel at the end of the current period; if false, filter companies without one

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

If true, filter companies that have a pending scheduled downgrade; if false, filter companies that do not

*/ @JsonSetter(value = "has_scheduled_downgrade", nulls = Nulls.SKIP) public Builder hasScheduledDowngrade(Optional hasScheduledDowngrade) { @@ -759,6 +790,7 @@ public ListCompaniesRequest build() { planVersionIds, subscriptionStatuses, subscriptionTypes, + cancelAtPeriodEnd, hasScheduledDowngrade, monetizedSubscriptions, planId, @@ -785,6 +817,7 @@ private void putAdditionalPropertyFromJson(String key, Object value) { || key.equalsIgnoreCase("plan_version_ids") || key.equalsIgnoreCase("subscription_statuses") || key.equalsIgnoreCase("subscription_types") + || key.equalsIgnoreCase("cancel_at_period_end") || key.equalsIgnoreCase("has_scheduled_downgrade") || key.equalsIgnoreCase("monetized_subscriptions") || key.equalsIgnoreCase("plan_id") diff --git a/src/main/java/com/schematic/api/resources/companies/types/CountCompaniesParams.java b/src/main/java/com/schematic/api/resources/companies/types/CountCompaniesParams.java index c1383a8..c3ec384 100644 --- a/src/main/java/com/schematic/api/resources/companies/types/CountCompaniesParams.java +++ b/src/main/java/com/schematic/api/resources/companies/types/CountCompaniesParams.java @@ -24,6 +24,8 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = CountCompaniesParams.Builder.class) public final class CountCompaniesParams { + private final Optional cancelAtPeriodEnd; + private final Optional> creditTypeIds; private final Optional hasScheduledDowngrade; @@ -69,6 +71,7 @@ public final class CountCompaniesParams { private final Map additionalProperties; private CountCompaniesParams( + Optional cancelAtPeriodEnd, Optional> creditTypeIds, Optional hasScheduledDowngrade, Optional> ids, @@ -91,6 +94,7 @@ private CountCompaniesParams( Optional withoutPlan, Optional withoutSubscription, Map additionalProperties) { + this.cancelAtPeriodEnd = cancelAtPeriodEnd; this.creditTypeIds = creditTypeIds; this.hasScheduledDowngrade = hasScheduledDowngrade; this.ids = ids; @@ -115,6 +119,14 @@ private CountCompaniesParams( this.additionalProperties = additionalProperties; } + /** + * @return If true, filter companies with an active subscription that is set to cancel at the end of the current period; if false, filter companies without one + */ + @JsonProperty("cancel_at_period_end") + public Optional getCancelAtPeriodEnd() { + return cancelAtPeriodEnd; + } + /** * @return Filter companies by one or more credit type IDs (each ID starts with bcrd_) */ @@ -124,7 +136,7 @@ public Optional> getCreditTypeIds() { } /** - * @return Filter companies that have a pending scheduled downgrade + * @return If true, filter companies that have a pending scheduled downgrade; if false, filter companies that do not */ @JsonProperty("has_scheduled_downgrade") public Optional getHasScheduledDowngrade() { @@ -295,7 +307,8 @@ public Map getAdditionalProperties() { } private boolean equalTo(CountCompaniesParams other) { - return creditTypeIds.equals(other.creditTypeIds) + return cancelAtPeriodEnd.equals(other.cancelAtPeriodEnd) + && creditTypeIds.equals(other.creditTypeIds) && hasScheduledDowngrade.equals(other.hasScheduledDowngrade) && ids.equals(other.ids) && limit.equals(other.limit) @@ -321,6 +334,7 @@ private boolean equalTo(CountCompaniesParams other) { @java.lang.Override public int hashCode() { return Objects.hash( + this.cancelAtPeriodEnd, this.creditTypeIds, this.hasScheduledDowngrade, this.ids, @@ -355,6 +369,8 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { + private Optional cancelAtPeriodEnd = Optional.empty(); + private Optional> creditTypeIds = Optional.empty(); private Optional hasScheduledDowngrade = Optional.empty(); @@ -402,6 +418,7 @@ public static final class Builder { private Builder() {} public Builder from(CountCompaniesParams other) { + cancelAtPeriodEnd(other.getCancelAtPeriodEnd()); creditTypeIds(other.getCreditTypeIds()); hasScheduledDowngrade(other.getHasScheduledDowngrade()); ids(other.getIds()); @@ -426,6 +443,20 @@ public Builder from(CountCompaniesParams other) { return this; } + /** + *

If true, filter companies with an active subscription that is set to cancel at the end of the current period; if false, filter companies without one

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

Filter companies by one or more credit type IDs (each ID starts with bcrd_)

*/ @@ -441,7 +472,7 @@ public Builder creditTypeIds(List creditTypeIds) { } /** - *

Filter companies that have a pending scheduled downgrade

+ *

If true, filter companies that have a pending scheduled downgrade; if false, filter companies that do not

*/ @JsonSetter(value = "has_scheduled_downgrade", nulls = Nulls.SKIP) public Builder hasScheduledDowngrade(Optional hasScheduledDowngrade) { @@ -722,6 +753,7 @@ public Builder withoutSubscription(Boolean withoutSubscription) { public CountCompaniesParams build() { return new CountCompaniesParams( + cancelAtPeriodEnd, creditTypeIds, hasScheduledDowngrade, ids, @@ -748,7 +780,8 @@ public CountCompaniesParams build() { @JsonAnySetter private void putAdditionalPropertyFromJson(String key, Object value) { - if (key.equalsIgnoreCase("credit_type_ids") + if (key.equalsIgnoreCase("cancel_at_period_end") + || key.equalsIgnoreCase("credit_type_ids") || key.equalsIgnoreCase("has_scheduled_downgrade") || key.equalsIgnoreCase("ids") || key.equalsIgnoreCase("limit") diff --git a/src/main/java/com/schematic/api/resources/companies/types/GetCompanyInferenceCostParams.java b/src/main/java/com/schematic/api/resources/companies/types/GetCompanyInferenceCostParams.java new file mode 100644 index 0000000..f7db10f --- /dev/null +++ b/src/main/java/com/schematic/api/resources/companies/types/GetCompanyInferenceCostParams.java @@ -0,0 +1,150 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.companies.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import java.time.OffsetDateTime; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = GetCompanyInferenceCostParams.Builder.class) +public final class GetCompanyInferenceCostParams { + private final Optional endTime; + + private final Optional startTime; + + private final Map additionalProperties; + + private GetCompanyInferenceCostParams( + Optional endTime, + Optional startTime, + Map additionalProperties) { + this.endTime = endTime; + this.startTime = startTime; + this.additionalProperties = additionalProperties; + } + + /** + * @return End of the window (exclusive). Pass together with start_time; when both are omitted, the company's current billing period is used + */ + @JsonProperty("end_time") + public Optional getEndTime() { + return endTime; + } + + /** + * @return Start of the window (inclusive). Pass together with end_time; when both are omitted, the company's current billing period is used + */ + @JsonProperty("start_time") + public Optional getStartTime() { + return startTime; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof GetCompanyInferenceCostParams && equalTo((GetCompanyInferenceCostParams) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(GetCompanyInferenceCostParams other) { + return endTime.equals(other.endTime) && startTime.equals(other.startTime); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.endTime, this.startTime); + } + + @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 endTime = Optional.empty(); + + private Optional startTime = Optional.empty(); + + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(GetCompanyInferenceCostParams other) { + endTime(other.getEndTime()); + startTime(other.getStartTime()); + return this; + } + + /** + *

End of the window (exclusive). Pass together with start_time; when both are omitted, the company's current billing period is used

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

Start of the window (inclusive). Pass together with end_time; when both are omitted, the company's current billing period is used

+ */ + @JsonSetter(value = "start_time", nulls = Nulls.SKIP) + public Builder startTime(Optional startTime) { + this.startTime = startTime; + return this; + } + + public Builder startTime(OffsetDateTime startTime) { + this.startTime = Optional.ofNullable(startTime); + return this; + } + + public GetCompanyInferenceCostParams build() { + return new GetCompanyInferenceCostParams(endTime, startTime, additionalProperties); + } + + @JsonAnySetter + private void putAdditionalPropertyFromJson(String key, Object value) { + if (key.equalsIgnoreCase("end_time") || key.equalsIgnoreCase("start_time")) { + return; + } + this.additionalProperties.put(key, value); + } + + 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/companies/types/GetCompanyInferenceCostResponse.java b/src/main/java/com/schematic/api/resources/companies/types/GetCompanyInferenceCostResponse.java new file mode 100644 index 0000000..4ab77ab --- /dev/null +++ b/src/main/java/com/schematic/api/resources/companies/types/GetCompanyInferenceCostResponse.java @@ -0,0 +1,161 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.companies.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.types.CompanyInferenceCostResponseData; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = GetCompanyInferenceCostResponse.Builder.class) +public final class GetCompanyInferenceCostResponse { + private final CompanyInferenceCostResponseData data; + + private final GetCompanyInferenceCostParams params; + + private final Map additionalProperties; + + private GetCompanyInferenceCostResponse( + CompanyInferenceCostResponseData data, + GetCompanyInferenceCostParams params, + Map additionalProperties) { + this.data = data; + this.params = params; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("data") + public CompanyInferenceCostResponseData getData() { + return data; + } + + /** + * @return Input parameters + */ + @JsonProperty("params") + public GetCompanyInferenceCostParams getParams() { + return params; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof GetCompanyInferenceCostResponse && equalTo((GetCompanyInferenceCostResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(GetCompanyInferenceCostResponse other) { + return data.equals(other.data) && params.equals(other.params); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.data, this.params); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static DataStage builder() { + return new Builder(); + } + + public interface DataStage { + ParamsStage data(@NotNull CompanyInferenceCostResponseData data); + + Builder from(GetCompanyInferenceCostResponse other); + } + + public interface ParamsStage { + /** + *

Input parameters

+ */ + _FinalStage params(@NotNull GetCompanyInferenceCostParams params); + } + + public interface _FinalStage { + GetCompanyInferenceCostResponse build(); + + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements DataStage, ParamsStage, _FinalStage { + private CompanyInferenceCostResponseData data; + + private GetCompanyInferenceCostParams params; + + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(GetCompanyInferenceCostResponse other) { + data(other.getData()); + params(other.getParams()); + return this; + } + + @java.lang.Override + @JsonSetter("data") + public ParamsStage data(@NotNull CompanyInferenceCostResponseData data) { + this.data = Objects.requireNonNull(data, "data must not be null"); + return this; + } + + /** + *

Input parameters

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("params") + public _FinalStage params(@NotNull GetCompanyInferenceCostParams params) { + this.params = Objects.requireNonNull(params, "params must not be null"); + return this; + } + + @java.lang.Override + public GetCompanyInferenceCostResponse build() { + return new GetCompanyInferenceCostResponse(data, params, additionalProperties); + } + + @JsonAnySetter + private void putAdditionalPropertyFromJson(String key, Object value) { + if (key.equalsIgnoreCase("data") || key.equalsIgnoreCase("params")) { + return; + } + this.additionalProperties.put(key, value); + } + + @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/companies/types/ListCompaniesParams.java b/src/main/java/com/schematic/api/resources/companies/types/ListCompaniesParams.java index cb8592b..a1a4104 100644 --- a/src/main/java/com/schematic/api/resources/companies/types/ListCompaniesParams.java +++ b/src/main/java/com/schematic/api/resources/companies/types/ListCompaniesParams.java @@ -24,6 +24,8 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = ListCompaniesParams.Builder.class) public final class ListCompaniesParams { + private final Optional cancelAtPeriodEnd; + private final Optional> creditTypeIds; private final Optional hasScheduledDowngrade; @@ -69,6 +71,7 @@ public final class ListCompaniesParams { private final Map additionalProperties; private ListCompaniesParams( + Optional cancelAtPeriodEnd, Optional> creditTypeIds, Optional hasScheduledDowngrade, Optional> ids, @@ -91,6 +94,7 @@ private ListCompaniesParams( Optional withoutPlan, Optional withoutSubscription, Map additionalProperties) { + this.cancelAtPeriodEnd = cancelAtPeriodEnd; this.creditTypeIds = creditTypeIds; this.hasScheduledDowngrade = hasScheduledDowngrade; this.ids = ids; @@ -115,6 +119,14 @@ private ListCompaniesParams( this.additionalProperties = additionalProperties; } + /** + * @return If true, filter companies with an active subscription that is set to cancel at the end of the current period; if false, filter companies without one + */ + @JsonProperty("cancel_at_period_end") + public Optional getCancelAtPeriodEnd() { + return cancelAtPeriodEnd; + } + /** * @return Filter companies by one or more credit type IDs (each ID starts with bcrd_) */ @@ -124,7 +136,7 @@ public Optional> getCreditTypeIds() { } /** - * @return Filter companies that have a pending scheduled downgrade + * @return If true, filter companies that have a pending scheduled downgrade; if false, filter companies that do not */ @JsonProperty("has_scheduled_downgrade") public Optional getHasScheduledDowngrade() { @@ -295,7 +307,8 @@ public Map getAdditionalProperties() { } private boolean equalTo(ListCompaniesParams other) { - return creditTypeIds.equals(other.creditTypeIds) + return cancelAtPeriodEnd.equals(other.cancelAtPeriodEnd) + && creditTypeIds.equals(other.creditTypeIds) && hasScheduledDowngrade.equals(other.hasScheduledDowngrade) && ids.equals(other.ids) && limit.equals(other.limit) @@ -321,6 +334,7 @@ private boolean equalTo(ListCompaniesParams other) { @java.lang.Override public int hashCode() { return Objects.hash( + this.cancelAtPeriodEnd, this.creditTypeIds, this.hasScheduledDowngrade, this.ids, @@ -355,6 +369,8 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { + private Optional cancelAtPeriodEnd = Optional.empty(); + private Optional> creditTypeIds = Optional.empty(); private Optional hasScheduledDowngrade = Optional.empty(); @@ -402,6 +418,7 @@ public static final class Builder { private Builder() {} public Builder from(ListCompaniesParams other) { + cancelAtPeriodEnd(other.getCancelAtPeriodEnd()); creditTypeIds(other.getCreditTypeIds()); hasScheduledDowngrade(other.getHasScheduledDowngrade()); ids(other.getIds()); @@ -426,6 +443,20 @@ public Builder from(ListCompaniesParams other) { return this; } + /** + *

If true, filter companies with an active subscription that is set to cancel at the end of the current period; if false, filter companies without one

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

Filter companies by one or more credit type IDs (each ID starts with bcrd_)

*/ @@ -441,7 +472,7 @@ public Builder creditTypeIds(List creditTypeIds) { } /** - *

Filter companies that have a pending scheduled downgrade

+ *

If true, filter companies that have a pending scheduled downgrade; if false, filter companies that do not

*/ @JsonSetter(value = "has_scheduled_downgrade", nulls = Nulls.SKIP) public Builder hasScheduledDowngrade(Optional hasScheduledDowngrade) { @@ -722,6 +753,7 @@ public Builder withoutSubscription(Boolean withoutSubscription) { public ListCompaniesParams build() { return new ListCompaniesParams( + cancelAtPeriodEnd, creditTypeIds, hasScheduledDowngrade, ids, @@ -748,7 +780,8 @@ public ListCompaniesParams build() { @JsonAnySetter private void putAdditionalPropertyFromJson(String key, Object value) { - if (key.equalsIgnoreCase("credit_type_ids") + if (key.equalsIgnoreCase("cancel_at_period_end") + || key.equalsIgnoreCase("credit_type_ids") || key.equalsIgnoreCase("has_scheduled_downgrade") || key.equalsIgnoreCase("ids") || key.equalsIgnoreCase("limit") diff --git a/src/main/java/com/schematic/api/resources/credits/requests/ReserveCreditsRequestBody.java b/src/main/java/com/schematic/api/resources/credits/requests/ReserveCreditsRequestBody.java index 1862b84..ecd0d81 100644 --- a/src/main/java/com/schematic/api/resources/credits/requests/ReserveCreditsRequestBody.java +++ b/src/main/java/com/schematic/api/resources/credits/requests/ReserveCreditsRequestBody.java @@ -68,7 +68,7 @@ public String getCreditTypeId() { } /** - * @return When the hold lapses if no track event settles it; defaults to one minute from now and may be at most one hour out. The unspent hold is refunded on expiry + * @return When the hold lapses if no track event settles it; defaults to one minute from now and may be at most 24 hours out. The unspent hold is refunded on expiry */ @JsonProperty("expires_at") public Optional getExpiresAt() { @@ -141,7 +141,7 @@ public interface _FinalStage { _FinalStage additionalProperties(Map additionalProperties); /** - *

When the hold lapses if no track event settles it; defaults to one minute from now and may be at most one hour out. The unspent hold is refunded on expiry

+ *

When the hold lapses if no track event settles it; defaults to one minute from now and may be at most 24 hours out. The unspent hold is refunded on expiry

*/ _FinalStage expiresAt(Optional expiresAt); @@ -227,7 +227,7 @@ public _FinalStage idempotencyKey(Optional idempotencyKey) { } /** - *

When the hold lapses if no track event settles it; defaults to one minute from now and may be at most one hour out. The unspent hold is refunded on expiry

+ *

When the hold lapses if no track event settles it; defaults to one minute from now and may be at most 24 hours out. The unspent hold is refunded on expiry

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

When the hold lapses if no track event settles it; defaults to one minute from now and may be at most one hour out. The unspent hold is refunded on expiry

+ *

When the hold lapses if no track event settles it; defaults to one minute from now and may be at most 24 hours out. The unspent hold is refunded on expiry

*/ @java.lang.Override @JsonSetter(value = "expires_at", nulls = Nulls.SKIP) diff --git a/src/main/java/com/schematic/api/resources/features/requests/CheckAndReserveFlagRequestBody.java b/src/main/java/com/schematic/api/resources/features/requests/CheckAndReserveFlagRequestBody.java index 5dd0dc2..fde9ee7 100644 --- a/src/main/java/com/schematic/api/resources/features/requests/CheckAndReserveFlagRequestBody.java +++ b/src/main/java/com/schematic/api/resources/features/requests/CheckAndReserveFlagRequestBody.java @@ -59,7 +59,7 @@ public Optional> getCompany() { } /** - * @return When the hold lapses if no track or inference event settles it; defaults to one minute from now and may be at most one hour out. The unspent hold is refunded on expiry + * @return When the hold lapses if no track or inference event settles it; defaults to one minute from now and may be at most 24 hours out. The unspent hold is refunded on expiry */ @JsonProperty("expires_at") public Optional getExpiresAt() { @@ -170,7 +170,7 @@ public Builder company(Map company) { } /** - *

When the hold lapses if no track or inference event settles it; defaults to one minute from now and may be at most one hour out. The unspent hold is refunded on expiry

+ *

When the hold lapses if no track or inference event settles it; defaults to one minute from now and may be at most 24 hours out. The unspent hold is refunded on expiry

*/ @JsonSetter(value = "expires_at", nulls = Nulls.SKIP) public Builder expiresAt(Optional expiresAt) { diff --git a/src/main/java/com/schematic/api/types/AuditLogCompanyResponseData.java b/src/main/java/com/schematic/api/types/AuditLogCompanyResponseData.java new file mode 100644 index 0000000..591e2fe --- /dev/null +++ b/src/main/java/com/schematic/api/types/AuditLogCompanyResponseData.java @@ -0,0 +1,147 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = AuditLogCompanyResponseData.Builder.class) +public final class AuditLogCompanyResponseData { + private final String id; + + private final String name; + + private final Map additionalProperties; + + private AuditLogCompanyResponseData(String id, String name, Map additionalProperties) { + this.id = id; + this.name = name; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("id") + public String getId() { + return id; + } + + @JsonProperty("name") + public String getName() { + return name; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof AuditLogCompanyResponseData && equalTo((AuditLogCompanyResponseData) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(AuditLogCompanyResponseData other) { + return id.equals(other.id) && name.equals(other.name); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.id, this.name); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + NameStage id(@NotNull String id); + + Builder from(AuditLogCompanyResponseData other); + } + + public interface NameStage { + _FinalStage name(@NotNull String name); + } + + public interface _FinalStage { + AuditLogCompanyResponseData build(); + + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements IdStage, NameStage, _FinalStage { + private String id; + + private String name; + + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(AuditLogCompanyResponseData other) { + id(other.getId()); + name(other.getName()); + return this; + } + + @java.lang.Override + @JsonSetter("id") + public NameStage id(@NotNull String id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("name") + public _FinalStage name(@NotNull String name) { + this.name = Objects.requireNonNull(name, "name must not be null"); + return this; + } + + @java.lang.Override + public AuditLogCompanyResponseData build() { + return new AuditLogCompanyResponseData(id, name, additionalProperties); + } + + @JsonAnySetter + private void putAdditionalPropertyFromJson(String key, Object value) { + if (key.equalsIgnoreCase("id") || key.equalsIgnoreCase("name")) { + return; + } + this.additionalProperties.put(key, value); + } + + @java.lang.Override + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + @java.lang.Override + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + } +} diff --git a/src/main/java/com/schematic/api/types/AuditLogListResponseData.java b/src/main/java/com/schematic/api/types/AuditLogListResponseData.java index a22e323..b370b12 100644 --- a/src/main/java/com/schematic/api/types/AuditLogListResponseData.java +++ b/src/main/java/com/schematic/api/types/AuditLogListResponseData.java @@ -28,6 +28,10 @@ public final class AuditLogListResponseData { private final Optional apiKeyId; + private final Optional company; + + private final Optional companyId; + private final Optional endedAt; private final Optional environment; @@ -62,6 +66,8 @@ private AuditLogListResponseData( ActorType actorType, Optional apiKey, Optional apiKeyId, + Optional company, + Optional companyId, Optional endedAt, Optional environment, Optional environmentId, @@ -80,6 +86,8 @@ private AuditLogListResponseData( this.actorType = actorType; this.apiKey = apiKey; this.apiKeyId = apiKeyId; + this.company = company; + this.companyId = companyId; this.endedAt = endedAt; this.environment = environment; this.environmentId = environmentId; @@ -112,6 +120,16 @@ public Optional getApiKeyId() { return apiKeyId; } + @JsonProperty("company") + public Optional getCompany() { + return company; + } + + @JsonProperty("company_id") + public Optional getCompanyId() { + return companyId; + } + @JsonProperty("ended_at") public Optional getEndedAt() { return endedAt; @@ -137,6 +155,9 @@ public String getMethod() { return method; } + /** + * @return Always null. Use resource_id_string. + */ @JsonProperty("resource_id") public Optional getResourceId() { return resourceId; @@ -197,6 +218,8 @@ private boolean equalTo(AuditLogListResponseData other) { return actorType.equals(other.actorType) && apiKey.equals(other.apiKey) && apiKeyId.equals(other.apiKeyId) + && company.equals(other.company) + && companyId.equals(other.companyId) && endedAt.equals(other.endedAt) && environment.equals(other.environment) && environmentId.equals(other.environmentId) @@ -219,6 +242,8 @@ public int hashCode() { this.actorType, this.apiKey, this.apiKeyId, + this.company, + this.companyId, this.endedAt, this.environment, this.environmentId, @@ -281,6 +306,14 @@ public interface _FinalStage { _FinalStage apiKeyId(String apiKeyId); + _FinalStage company(Optional company); + + _FinalStage company(AuditLogCompanyResponseData company); + + _FinalStage companyId(Optional companyId); + + _FinalStage companyId(String companyId); + _FinalStage endedAt(Optional endedAt); _FinalStage endedAt(OffsetDateTime endedAt); @@ -293,6 +326,9 @@ public interface _FinalStage { _FinalStage environmentId(String environmentId); + /** + *

Always null. Use resource_id_string.

+ */ _FinalStage resourceId(Optional resourceId); _FinalStage resourceId(Long resourceId); @@ -355,6 +391,10 @@ public static final class Builder private Optional endedAt = Optional.empty(); + private Optional companyId = Optional.empty(); + + private Optional company = Optional.empty(); + private Optional apiKeyId = Optional.empty(); private Optional apiKey = Optional.empty(); @@ -368,6 +408,8 @@ public Builder from(AuditLogListResponseData other) { actorType(other.getActorType()); apiKey(other.getApiKey()); apiKeyId(other.getApiKeyId()); + company(other.getCompany()); + companyId(other.getCompanyId()); endedAt(other.getEndedAt()); environment(other.getEnvironment()); environmentId(other.getEnvironmentId()); @@ -498,12 +540,19 @@ public _FinalStage resourceIdString(Optional resourceIdString) { return this; } + /** + *

Always null. Use resource_id_string.

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

Always null. Use resource_id_string.

+ */ @java.lang.Override @JsonSetter(value = "resource_id", nulls = Nulls.SKIP) public _FinalStage resourceId(Optional resourceId) { @@ -550,6 +599,32 @@ public _FinalStage endedAt(Optional endedAt) { return this; } + @java.lang.Override + public _FinalStage companyId(String companyId) { + this.companyId = Optional.ofNullable(companyId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "company_id", nulls = Nulls.SKIP) + public _FinalStage companyId(Optional companyId) { + this.companyId = companyId; + return this; + } + + @java.lang.Override + public _FinalStage company(AuditLogCompanyResponseData company) { + this.company = Optional.ofNullable(company); + return this; + } + + @java.lang.Override + @JsonSetter(value = "company", nulls = Nulls.SKIP) + public _FinalStage company(Optional company) { + this.company = company; + return this; + } + @java.lang.Override public _FinalStage apiKeyId(String apiKeyId) { this.apiKeyId = Optional.ofNullable(apiKeyId); @@ -582,6 +657,8 @@ public AuditLogListResponseData build() { actorType, apiKey, apiKeyId, + company, + companyId, endedAt, environment, environmentId, @@ -604,6 +681,8 @@ private void putAdditionalPropertyFromJson(String key, Object value) { if (key.equalsIgnoreCase("actor_type") || key.equalsIgnoreCase("api_key") || key.equalsIgnoreCase("api_key_id") + || key.equalsIgnoreCase("company") + || key.equalsIgnoreCase("company_id") || key.equalsIgnoreCase("ended_at") || key.equalsIgnoreCase("environment") || key.equalsIgnoreCase("environment_id") diff --git a/src/main/java/com/schematic/api/types/AuditLogResponseData.java b/src/main/java/com/schematic/api/types/AuditLogResponseData.java index 71e9a8a..4bbe59d 100644 --- a/src/main/java/com/schematic/api/types/AuditLogResponseData.java +++ b/src/main/java/com/schematic/api/types/AuditLogResponseData.java @@ -30,6 +30,10 @@ public final class AuditLogResponseData { private final Optional apiKeyId; + private final Optional company; + + private final Optional companyId; + private final Optional endedAt; private final Optional environment; @@ -71,6 +75,8 @@ private AuditLogResponseData( ActorType actorType, Optional apiKey, Optional apiKeyId, + Optional company, + Optional companyId, Optional endedAt, Optional environment, Optional environmentId, @@ -93,6 +99,8 @@ private AuditLogResponseData( this.actorType = actorType; this.apiKey = apiKey; this.apiKeyId = apiKeyId; + this.company = company; + this.companyId = companyId; this.endedAt = endedAt; this.environment = environment; this.environmentId = environmentId; @@ -133,6 +141,16 @@ public Optional getApiKeyId() { return apiKeyId; } + @JsonProperty("company") + public Optional getCompany() { + return company; + } + + @JsonProperty("company_id") + public Optional getCompanyId() { + return companyId; + } + @JsonProperty("ended_at") public Optional getEndedAt() { return endedAt; @@ -163,6 +181,9 @@ public Optional getReqBody() { return reqBody; } + /** + * @return Always null. Use resource_id_string. + */ @JsonProperty("resource_id") public Optional getResourceId() { return resourceId; @@ -234,6 +255,8 @@ private boolean equalTo(AuditLogResponseData other) { && actorType.equals(other.actorType) && apiKey.equals(other.apiKey) && apiKeyId.equals(other.apiKeyId) + && company.equals(other.company) + && companyId.equals(other.companyId) && endedAt.equals(other.endedAt) && environment.equals(other.environment) && environmentId.equals(other.environmentId) @@ -260,6 +283,8 @@ public int hashCode() { this.actorType, this.apiKey, this.apiKeyId, + this.company, + this.companyId, this.endedAt, this.environment, this.environmentId, @@ -329,6 +354,14 @@ public interface _FinalStage { _FinalStage apiKeyId(String apiKeyId); + _FinalStage company(Optional company); + + _FinalStage company(AuditLogCompanyResponseData company); + + _FinalStage companyId(Optional companyId); + + _FinalStage companyId(String companyId); + _FinalStage endedAt(Optional endedAt); _FinalStage endedAt(OffsetDateTime endedAt); @@ -345,6 +378,9 @@ public interface _FinalStage { _FinalStage reqBody(String reqBody); + /** + *

Always null. Use resource_id_string.

+ */ _FinalStage resourceId(Optional resourceId); _FinalStage resourceId(Long resourceId); @@ -421,6 +457,10 @@ public static final class Builder private Optional endedAt = Optional.empty(); + private Optional companyId = Optional.empty(); + + private Optional company = Optional.empty(); + private Optional apiKeyId = Optional.empty(); private Optional apiKey = Optional.empty(); @@ -437,6 +477,8 @@ public Builder from(AuditLogResponseData other) { actorType(other.getActorType()); apiKey(other.getApiKey()); apiKeyId(other.getApiKeyId()); + company(other.getCompany()); + companyId(other.getCompanyId()); endedAt(other.getEndedAt()); environment(other.getEnvironment()); environmentId(other.getEnvironmentId()); @@ -596,12 +638,19 @@ public _FinalStage resourceIdString(Optional resourceIdString) { return this; } + /** + *

Always null. Use resource_id_string.

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

Always null. Use resource_id_string.

+ */ @java.lang.Override @JsonSetter(value = "resource_id", nulls = Nulls.SKIP) public _FinalStage resourceId(Optional resourceId) { @@ -661,6 +710,32 @@ public _FinalStage endedAt(Optional endedAt) { return this; } + @java.lang.Override + public _FinalStage companyId(String companyId) { + this.companyId = Optional.ofNullable(companyId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "company_id", nulls = Nulls.SKIP) + public _FinalStage companyId(Optional companyId) { + this.companyId = companyId; + return this; + } + + @java.lang.Override + public _FinalStage company(AuditLogCompanyResponseData company) { + this.company = Optional.ofNullable(company); + return this; + } + + @java.lang.Override + @JsonSetter(value = "company", nulls = Nulls.SKIP) + public _FinalStage company(Optional company) { + this.company = company; + return this; + } + @java.lang.Override public _FinalStage apiKeyId(String apiKeyId) { this.apiKeyId = Optional.ofNullable(apiKeyId); @@ -707,6 +782,8 @@ public AuditLogResponseData build() { actorType, apiKey, apiKeyId, + company, + companyId, endedAt, environment, environmentId, @@ -733,6 +810,8 @@ private void putAdditionalPropertyFromJson(String key, Object value) { || key.equalsIgnoreCase("actor_type") || key.equalsIgnoreCase("api_key") || key.equalsIgnoreCase("api_key_id") + || key.equalsIgnoreCase("company") + || key.equalsIgnoreCase("company_id") || key.equalsIgnoreCase("ended_at") || key.equalsIgnoreCase("environment") || key.equalsIgnoreCase("environment_id") diff --git a/src/main/java/com/schematic/api/types/BillingInvoiceDetailResponseData.java b/src/main/java/com/schematic/api/types/BillingInvoiceDetailResponseData.java index 150b46c..4cd13ce 100644 --- a/src/main/java/com/schematic/api/types/BillingInvoiceDetailResponseData.java +++ b/src/main/java/com/schematic/api/types/BillingInvoiceDetailResponseData.java @@ -24,6 +24,8 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = BillingInvoiceDetailResponseData.Builder.class) public final class BillingInvoiceDetailResponseData { + private final long amountDue; + private final long amountPaid; private final long amountRemaining; @@ -46,6 +48,8 @@ public final class BillingInvoiceDetailResponseData { private final Optional dueAt; + private final long endingBalance; + private final Optional externalId; private final Optional finalizedAt; @@ -66,6 +70,8 @@ public final class BillingInvoiceDetailResponseData { private final List settlements; + private final long startingBalance; + private final InvoiceStatus status; private final Optional subscriptionExternalId; @@ -85,6 +91,7 @@ public final class BillingInvoiceDetailResponseData { private final Map additionalProperties; private BillingInvoiceDetailResponseData( + long amountDue, long amountPaid, long amountRemaining, Optional collectionState, @@ -96,6 +103,7 @@ private BillingInvoiceDetailResponseData( long discount, Optional documentState, Optional dueAt, + long endingBalance, Optional externalId, Optional finalizedAt, String id, @@ -106,6 +114,7 @@ private BillingInvoiceDetailResponseData( Optional periodStart, BillingProviderType providerType, List settlements, + long startingBalance, InvoiceStatus status, Optional subscriptionExternalId, Optional subscriptionId, @@ -115,6 +124,7 @@ private BillingInvoiceDetailResponseData( long total, Optional url, Map additionalProperties) { + this.amountDue = amountDue; this.amountPaid = amountPaid; this.amountRemaining = amountRemaining; this.collectionState = collectionState; @@ -126,6 +136,7 @@ private BillingInvoiceDetailResponseData( this.discount = discount; this.documentState = documentState; this.dueAt = dueAt; + this.endingBalance = endingBalance; this.externalId = externalId; this.finalizedAt = finalizedAt; this.id = id; @@ -136,6 +147,7 @@ private BillingInvoiceDetailResponseData( this.periodStart = periodStart; this.providerType = providerType; this.settlements = settlements; + this.startingBalance = startingBalance; this.status = status; this.subscriptionExternalId = subscriptionExternalId; this.subscriptionId = subscriptionId; @@ -147,6 +159,14 @@ private BillingInvoiceDetailResponseData( this.additionalProperties = additionalProperties; } + /** + * @return What the company is asked to pay: the total less any balance applied to it, never below zero. Zero on a draft. + */ + @JsonProperty("amount_due") + public long getAmountDue() { + return amountDue; + } + @JsonProperty("amount_paid") public long getAmountPaid() { return amountPaid; @@ -214,6 +234,14 @@ public Optional getDueAt() { return dueAt; } + /** + * @return The company's balance after this invoice, in minor units. Below zero is credit the next invoice takes off what is due. + */ + @JsonProperty("ending_balance") + public long getEndingBalance() { + return endingBalance; + } + /** * @return The billing provider's invoice ID. Null on an invoice Schematic issued. */ @@ -276,6 +304,14 @@ public List getSettlements() { return settlements; } + /** + * @return The company's balance before this invoice, in minor units. Below zero is credit applied to this invoice. + */ + @JsonProperty("starting_balance") + public long getStartingBalance() { + return startingBalance; + } + @JsonProperty("status") public InvoiceStatus getStatus() { return status; @@ -343,7 +379,8 @@ public Map getAdditionalProperties() { } private boolean equalTo(BillingInvoiceDetailResponseData other) { - return amountPaid == other.amountPaid + return amountDue == other.amountDue + && amountPaid == other.amountPaid && amountRemaining == other.amountRemaining && collectionState.equals(other.collectionState) && collector.equals(other.collector) @@ -354,6 +391,7 @@ private boolean equalTo(BillingInvoiceDetailResponseData other) { && discount == other.discount && documentState.equals(other.documentState) && dueAt.equals(other.dueAt) + && endingBalance == other.endingBalance && externalId.equals(other.externalId) && finalizedAt.equals(other.finalizedAt) && id.equals(other.id) @@ -364,6 +402,7 @@ private boolean equalTo(BillingInvoiceDetailResponseData other) { && periodStart.equals(other.periodStart) && providerType.equals(other.providerType) && settlements.equals(other.settlements) + && startingBalance == other.startingBalance && status.equals(other.status) && subscriptionExternalId.equals(other.subscriptionExternalId) && subscriptionId.equals(other.subscriptionId) @@ -377,6 +416,7 @@ private boolean equalTo(BillingInvoiceDetailResponseData other) { @java.lang.Override public int hashCode() { return Objects.hash( + this.amountDue, this.amountPaid, this.amountRemaining, this.collectionState, @@ -388,6 +428,7 @@ public int hashCode() { this.discount, this.documentState, this.dueAt, + this.endingBalance, this.externalId, this.finalizedAt, this.id, @@ -398,6 +439,7 @@ public int hashCode() { this.periodStart, this.providerType, this.settlements, + this.startingBalance, this.status, this.subscriptionExternalId, this.subscriptionId, @@ -413,16 +455,23 @@ public String toString() { return ObjectMappers.stringify(this); } - public static AmountPaidStage builder() { + public static AmountDueStage builder() { return new Builder(); } - public interface AmountPaidStage { - AmountRemainingStage amountPaid(long amountPaid); + public interface AmountDueStage { + /** + *

What the company is asked to pay: the total less any balance applied to it, never below zero. Zero on a draft.

+ */ + AmountPaidStage amountDue(long amountDue); Builder from(BillingInvoiceDetailResponseData other); } + public interface AmountPaidStage { + AmountRemainingStage amountPaid(long amountPaid); + } + public interface AmountRemainingStage { CompanyIdStage amountRemaining(long amountRemaining); } @@ -443,7 +492,14 @@ public interface DiscountStage { /** *

What discounts took off the subtotal, in minor units of the invoice's currency. Zero on an invoice Schematic issued.

*/ - IdStage discount(long discount); + EndingBalanceStage discount(long discount); + } + + public interface EndingBalanceStage { + /** + *

The company's balance after this invoice, in minor units. Below zero is credit the next invoice takes off what is due.

+ */ + IdStage endingBalance(long endingBalance); } public interface IdStage { @@ -451,7 +507,14 @@ public interface IdStage { } public interface ProviderTypeStage { - StatusStage providerType(@NotNull BillingProviderType providerType); + StartingBalanceStage providerType(@NotNull BillingProviderType providerType); + } + + public interface StartingBalanceStage { + /** + *

The company's balance before this invoice, in minor units. Below zero is credit applied to this invoice.

+ */ + StatusStage startingBalance(long startingBalance); } public interface StatusStage { @@ -588,19 +651,24 @@ public interface _FinalStage { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder - implements AmountPaidStage, + implements AmountDueStage, + AmountPaidStage, AmountRemainingStage, CompanyIdStage, CreatedAtStage, CurrencyStage, DiscountStage, + EndingBalanceStage, IdStage, ProviderTypeStage, + StartingBalanceStage, StatusStage, SubtotalStage, TaxStage, TotalStage, _FinalStage { + private long amountDue; + private long amountPaid; private long amountRemaining; @@ -613,10 +681,14 @@ public static final class Builder private long discount; + private long endingBalance; + private String id; private BillingProviderType providerType; + private long startingBalance; + private InvoiceStatus status; private long subtotal; @@ -665,6 +737,7 @@ private Builder() {} @java.lang.Override public Builder from(BillingInvoiceDetailResponseData other) { + amountDue(other.getAmountDue()); amountPaid(other.getAmountPaid()); amountRemaining(other.getAmountRemaining()); collectionState(other.getCollectionState()); @@ -676,6 +749,7 @@ public Builder from(BillingInvoiceDetailResponseData other) { discount(other.getDiscount()); documentState(other.getDocumentState()); dueAt(other.getDueAt()); + endingBalance(other.getEndingBalance()); externalId(other.getExternalId()); finalizedAt(other.getFinalizedAt()); id(other.getId()); @@ -686,6 +760,7 @@ public Builder from(BillingInvoiceDetailResponseData other) { periodStart(other.getPeriodStart()); providerType(other.getProviderType()); settlements(other.getSettlements()); + startingBalance(other.getStartingBalance()); status(other.getStatus()); subscriptionExternalId(other.getSubscriptionExternalId()); subscriptionId(other.getSubscriptionId()); @@ -697,6 +772,17 @@ public Builder from(BillingInvoiceDetailResponseData other) { return this; } + /** + *

What the company is asked to pay: the total less any balance applied to it, never below zero. Zero on a draft.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("amount_due") + public AmountPaidStage amountDue(long amountDue) { + this.amountDue = amountDue; + return this; + } + @java.lang.Override @JsonSetter("amount_paid") public AmountRemainingStage amountPaid(long amountPaid) { @@ -738,11 +824,22 @@ public DiscountStage currency(@NotNull Currency currency) { */ @java.lang.Override @JsonSetter("discount") - public IdStage discount(long discount) { + public EndingBalanceStage discount(long discount) { this.discount = discount; return this; } + /** + *

The company's balance after this invoice, in minor units. Below zero is credit the next invoice takes off what is due.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("ending_balance") + public IdStage endingBalance(long endingBalance) { + this.endingBalance = endingBalance; + return this; + } + @java.lang.Override @JsonSetter("id") public ProviderTypeStage id(@NotNull String id) { @@ -752,11 +849,22 @@ public ProviderTypeStage id(@NotNull String id) { @java.lang.Override @JsonSetter("provider_type") - public StatusStage providerType(@NotNull BillingProviderType providerType) { + public StartingBalanceStage providerType(@NotNull BillingProviderType providerType) { this.providerType = Objects.requireNonNull(providerType, "providerType must not be null"); return this; } + /** + *

The company's balance before this invoice, in minor units. Below zero is credit applied to this invoice.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("starting_balance") + public StatusStage startingBalance(long startingBalance) { + this.startingBalance = startingBalance; + return this; + } + @java.lang.Override @JsonSetter("status") public SubtotalStage status(@NotNull InvoiceStatus status) { @@ -1112,6 +1220,7 @@ public _FinalStage collectionState(Optional collectionSt @java.lang.Override public BillingInvoiceDetailResponseData build() { return new BillingInvoiceDetailResponseData( + amountDue, amountPaid, amountRemaining, collectionState, @@ -1123,6 +1232,7 @@ public BillingInvoiceDetailResponseData build() { discount, documentState, dueAt, + endingBalance, externalId, finalizedAt, id, @@ -1133,6 +1243,7 @@ public BillingInvoiceDetailResponseData build() { periodStart, providerType, settlements, + startingBalance, status, subscriptionExternalId, subscriptionId, @@ -1146,7 +1257,8 @@ public BillingInvoiceDetailResponseData build() { @JsonAnySetter private void putAdditionalPropertyFromJson(String key, Object value) { - if (key.equalsIgnoreCase("amount_paid") + if (key.equalsIgnoreCase("amount_due") + || key.equalsIgnoreCase("amount_paid") || key.equalsIgnoreCase("amount_remaining") || key.equalsIgnoreCase("collection_state") || key.equalsIgnoreCase("collector") @@ -1157,6 +1269,7 @@ private void putAdditionalPropertyFromJson(String key, Object value) { || key.equalsIgnoreCase("discount") || key.equalsIgnoreCase("document_state") || key.equalsIgnoreCase("due_at") + || key.equalsIgnoreCase("ending_balance") || key.equalsIgnoreCase("external_id") || key.equalsIgnoreCase("finalized_at") || key.equalsIgnoreCase("id") @@ -1167,6 +1280,7 @@ private void putAdditionalPropertyFromJson(String key, Object value) { || key.equalsIgnoreCase("period_start") || key.equalsIgnoreCase("provider_type") || key.equalsIgnoreCase("settlements") + || key.equalsIgnoreCase("starting_balance") || key.equalsIgnoreCase("status") || key.equalsIgnoreCase("subscription_external_id") || key.equalsIgnoreCase("subscription_id") diff --git a/src/main/java/com/schematic/api/types/BillingInvoiceLineResponseData.java b/src/main/java/com/schematic/api/types/BillingInvoiceLineResponseData.java index e7610b2..e35f8b9 100644 --- a/src/main/java/com/schematic/api/types/BillingInvoiceLineResponseData.java +++ b/src/main/java/com/schematic/api/types/BillingInvoiceLineResponseData.java @@ -40,6 +40,8 @@ public final class BillingInvoiceLineResponseData { private final Optional periodStart; + private final Optional prorationFraction; + private final Optional quantity; private final Optional subscriptionLineId; @@ -59,6 +61,7 @@ private BillingInvoiceLineResponseData( InvoiceLineKind kind, Optional periodEnd, Optional periodStart, + Optional prorationFraction, Optional quantity, Optional subscriptionLineId, boolean taxable, @@ -72,6 +75,7 @@ private BillingInvoiceLineResponseData( this.kind = kind; this.periodEnd = periodEnd; this.periodStart = periodStart; + this.prorationFraction = prorationFraction; this.quantity = quantity; this.subscriptionLineId = subscriptionLineId; this.taxable = taxable; @@ -96,7 +100,7 @@ public List getChargeIds() { } /** - * @return What the line bills for: the product, plan, add-on or credit. Null when the line has no subscription line behind it. + * @return What the line bills for: the product, plan, add-on or credit, and for part of a period, which part. Null when the line has no subscription line behind it. */ @JsonProperty("description") public Optional getDescription() { @@ -134,6 +138,14 @@ public Optional getPeriodStart() { return periodStart; } + /** + * @return The share of a full billing period the line bills, as a decimal from 0 to 1. Null when the line bills a whole period. + */ + @JsonProperty("proration_fraction") + public Optional getProrationFraction() { + return prorationFraction; + } + @JsonProperty("quantity") public Optional getQuantity() { return quantity; @@ -174,6 +186,7 @@ private boolean equalTo(BillingInvoiceLineResponseData other) { && kind.equals(other.kind) && periodEnd.equals(other.periodEnd) && periodStart.equals(other.periodStart) + && prorationFraction.equals(other.prorationFraction) && quantity.equals(other.quantity) && subscriptionLineId.equals(other.subscriptionLineId) && taxable == other.taxable @@ -191,6 +204,7 @@ public int hashCode() { this.kind, this.periodEnd, this.periodStart, + this.prorationFraction, this.quantity, this.subscriptionLineId, this.taxable, @@ -240,7 +254,7 @@ public interface _FinalStage { _FinalStage addAllChargeIds(List chargeIds); /** - *

What the line bills for: the product, plan, add-on or credit. Null when the line has no subscription line behind it.

+ *

What the line bills for: the product, plan, add-on or credit, and for part of a period, which part. Null when the line has no subscription line behind it.

*/ _FinalStage description(Optional description); @@ -268,6 +282,13 @@ public interface _FinalStage { _FinalStage periodStart(OffsetDateTime periodStart); + /** + *

The share of a full billing period the line bills, as a decimal from 0 to 1. Null when the line bills a whole period.

+ */ + _FinalStage prorationFraction(Optional prorationFraction); + + _FinalStage prorationFraction(String prorationFraction); + _FinalStage quantity(Optional quantity); _FinalStage quantity(Long quantity); @@ -295,6 +316,8 @@ public static final class Builder implements AmountStage, KindStage, TaxableStag private Optional quantity = Optional.empty(); + private Optional prorationFraction = Optional.empty(); + private Optional periodStart = Optional.empty(); private Optional periodEnd = Optional.empty(); @@ -321,6 +344,7 @@ public Builder from(BillingInvoiceLineResponseData other) { kind(other.getKind()); periodEnd(other.getPeriodEnd()); periodStart(other.getPeriodStart()); + prorationFraction(other.getProrationFraction()); quantity(other.getQuantity()); subscriptionLineId(other.getSubscriptionLineId()); taxable(other.getTaxable()); @@ -392,6 +416,26 @@ public _FinalStage quantity(Optional quantity) { return this; } + /** + *

The share of a full billing period the line bills, as a decimal from 0 to 1. Null when the line bills a whole period.

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

The share of a full billing period the line bills, as a decimal from 0 to 1. Null when the line bills a whole period.

+ */ + @java.lang.Override + @JsonSetter(value = "proration_fraction", nulls = Nulls.SKIP) + public _FinalStage prorationFraction(Optional prorationFraction) { + this.prorationFraction = prorationFraction; + return this; + } + @java.lang.Override public _FinalStage periodStart(OffsetDateTime periodStart) { this.periodStart = Optional.ofNullable(periodStart); @@ -459,7 +503,7 @@ public _FinalStage externalId(Optional externalId) { } /** - *

What the line bills for: the product, plan, add-on or credit. Null when the line has no subscription line behind it.

+ *

What the line bills for: the product, plan, add-on or credit, and for part of a period, which part. Null when the line has no subscription line behind it.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -469,7 +513,7 @@ public _FinalStage description(String description) { } /** - *

What the line bills for: the product, plan, add-on or credit. Null when the line has no subscription line behind it.

+ *

What the line bills for: the product, plan, add-on or credit, and for part of a period, which part. Null when the line has no subscription line behind it.

*/ @java.lang.Override @JsonSetter(value = "description", nulls = Nulls.SKIP) @@ -524,6 +568,7 @@ public BillingInvoiceLineResponseData build() { kind, periodEnd, periodStart, + prorationFraction, quantity, subscriptionLineId, taxable, @@ -541,6 +586,7 @@ private void putAdditionalPropertyFromJson(String key, Object value) { || key.equalsIgnoreCase("kind") || key.equalsIgnoreCase("period_end") || key.equalsIgnoreCase("period_start") + || key.equalsIgnoreCase("proration_fraction") || key.equalsIgnoreCase("quantity") || key.equalsIgnoreCase("subscription_line_id") || key.equalsIgnoreCase("taxable") diff --git a/src/main/java/com/schematic/api/types/BillingInvoiceResponseData.java b/src/main/java/com/schematic/api/types/BillingInvoiceResponseData.java index 6a9859b..f39f0f1 100644 --- a/src/main/java/com/schematic/api/types/BillingInvoiceResponseData.java +++ b/src/main/java/com/schematic/api/types/BillingInvoiceResponseData.java @@ -22,6 +22,8 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = BillingInvoiceResponseData.Builder.class) public final class BillingInvoiceResponseData { + private final long amountDue; + private final long amountPaid; private final long amountRemaining; @@ -42,6 +44,8 @@ public final class BillingInvoiceResponseData { private final Optional dueAt; + private final long endingBalance; + private final Optional externalId; private final Optional finalizedAt; @@ -56,6 +60,8 @@ public final class BillingInvoiceResponseData { private final BillingProviderType providerType; + private final long startingBalance; + private final InvoiceStatus status; private final Optional subscriptionExternalId; @@ -69,6 +75,7 @@ public final class BillingInvoiceResponseData { private final Map additionalProperties; private BillingInvoiceResponseData( + long amountDue, long amountPaid, long amountRemaining, Optional collectionState, @@ -79,6 +86,7 @@ private BillingInvoiceResponseData( Currency currency, Optional documentState, Optional dueAt, + long endingBalance, Optional externalId, Optional finalizedAt, String id, @@ -86,12 +94,14 @@ private BillingInvoiceResponseData( Optional periodEnd, Optional periodStart, BillingProviderType providerType, + long startingBalance, InvoiceStatus status, Optional subscriptionExternalId, long subtotal, long total, Optional url, Map additionalProperties) { + this.amountDue = amountDue; this.amountPaid = amountPaid; this.amountRemaining = amountRemaining; this.collectionState = collectionState; @@ -102,6 +112,7 @@ private BillingInvoiceResponseData( this.currency = currency; this.documentState = documentState; this.dueAt = dueAt; + this.endingBalance = endingBalance; this.externalId = externalId; this.finalizedAt = finalizedAt; this.id = id; @@ -109,6 +120,7 @@ private BillingInvoiceResponseData( this.periodEnd = periodEnd; this.periodStart = periodStart; this.providerType = providerType; + this.startingBalance = startingBalance; this.status = status; this.subscriptionExternalId = subscriptionExternalId; this.subtotal = subtotal; @@ -117,6 +129,14 @@ private BillingInvoiceResponseData( this.additionalProperties = additionalProperties; } + /** + * @return What the company is asked to pay: the total less any balance applied to it, never below zero. Zero on a draft. + */ + @JsonProperty("amount_due") + public long getAmountDue() { + return amountDue; + } + @JsonProperty("amount_paid") public long getAmountPaid() { return amountPaid; @@ -176,6 +196,14 @@ public Optional getDueAt() { return dueAt; } + /** + * @return The company's balance after this invoice, in minor units. Below zero is credit the next invoice takes off what is due. + */ + @JsonProperty("ending_balance") + public long getEndingBalance() { + return endingBalance; + } + /** * @return The billing provider's invoice ID. Null on an invoice Schematic issued. */ @@ -220,6 +248,14 @@ public BillingProviderType getProviderType() { return providerType; } + /** + * @return The company's balance before this invoice, in minor units. Below zero is credit applied to this invoice. + */ + @JsonProperty("starting_balance") + public long getStartingBalance() { + return startingBalance; + } + @JsonProperty("status") public InvoiceStatus getStatus() { return status; @@ -263,7 +299,8 @@ public Map getAdditionalProperties() { } private boolean equalTo(BillingInvoiceResponseData other) { - return amountPaid == other.amountPaid + return amountDue == other.amountDue + && amountPaid == other.amountPaid && amountRemaining == other.amountRemaining && collectionState.equals(other.collectionState) && collector.equals(other.collector) @@ -273,6 +310,7 @@ private boolean equalTo(BillingInvoiceResponseData other) { && currency.equals(other.currency) && documentState.equals(other.documentState) && dueAt.equals(other.dueAt) + && endingBalance == other.endingBalance && externalId.equals(other.externalId) && finalizedAt.equals(other.finalizedAt) && id.equals(other.id) @@ -280,6 +318,7 @@ private boolean equalTo(BillingInvoiceResponseData other) { && periodEnd.equals(other.periodEnd) && periodStart.equals(other.periodStart) && providerType.equals(other.providerType) + && startingBalance == other.startingBalance && status.equals(other.status) && subscriptionExternalId.equals(other.subscriptionExternalId) && subtotal == other.subtotal @@ -290,6 +329,7 @@ private boolean equalTo(BillingInvoiceResponseData other) { @java.lang.Override public int hashCode() { return Objects.hash( + this.amountDue, this.amountPaid, this.amountRemaining, this.collectionState, @@ -300,6 +340,7 @@ public int hashCode() { this.currency, this.documentState, this.dueAt, + this.endingBalance, this.externalId, this.finalizedAt, this.id, @@ -307,6 +348,7 @@ public int hashCode() { this.periodEnd, this.periodStart, this.providerType, + this.startingBalance, this.status, this.subscriptionExternalId, this.subtotal, @@ -319,16 +361,23 @@ public String toString() { return ObjectMappers.stringify(this); } - public static AmountPaidStage builder() { + public static AmountDueStage builder() { return new Builder(); } - public interface AmountPaidStage { - AmountRemainingStage amountPaid(long amountPaid); + public interface AmountDueStage { + /** + *

What the company is asked to pay: the total less any balance applied to it, never below zero. Zero on a draft.

+ */ + AmountPaidStage amountDue(long amountDue); Builder from(BillingInvoiceResponseData other); } + public interface AmountPaidStage { + AmountRemainingStage amountPaid(long amountPaid); + } + public interface AmountRemainingStage { CompanyIdStage amountRemaining(long amountRemaining); } @@ -342,7 +391,14 @@ public interface CreatedAtStage { } public interface CurrencyStage { - IdStage currency(@NotNull Currency currency); + EndingBalanceStage currency(@NotNull Currency currency); + } + + public interface EndingBalanceStage { + /** + *

The company's balance after this invoice, in minor units. Below zero is credit the next invoice takes off what is due.

+ */ + IdStage endingBalance(long endingBalance); } public interface IdStage { @@ -350,7 +406,14 @@ public interface IdStage { } public interface ProviderTypeStage { - StatusStage providerType(@NotNull BillingProviderType providerType); + StartingBalanceStage providerType(@NotNull BillingProviderType providerType); + } + + public interface StartingBalanceStage { + /** + *

The company's balance before this invoice, in minor units. Below zero is credit applied to this invoice.

+ */ + StatusStage startingBalance(long startingBalance); } public interface StatusStage { @@ -447,17 +510,22 @@ public interface _FinalStage { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder - implements AmountPaidStage, + implements AmountDueStage, + AmountPaidStage, AmountRemainingStage, CompanyIdStage, CreatedAtStage, CurrencyStage, + EndingBalanceStage, IdStage, ProviderTypeStage, + StartingBalanceStage, StatusStage, SubtotalStage, TotalStage, _FinalStage { + private long amountDue; + private long amountPaid; private long amountRemaining; @@ -468,10 +536,14 @@ public static final class Builder private Currency currency; + private long endingBalance; + private String id; private BillingProviderType providerType; + private long startingBalance; + private InvoiceStatus status; private long subtotal; @@ -508,6 +580,7 @@ private Builder() {} @java.lang.Override public Builder from(BillingInvoiceResponseData other) { + amountDue(other.getAmountDue()); amountPaid(other.getAmountPaid()); amountRemaining(other.getAmountRemaining()); collectionState(other.getCollectionState()); @@ -518,6 +591,7 @@ public Builder from(BillingInvoiceResponseData other) { currency(other.getCurrency()); documentState(other.getDocumentState()); dueAt(other.getDueAt()); + endingBalance(other.getEndingBalance()); externalId(other.getExternalId()); finalizedAt(other.getFinalizedAt()); id(other.getId()); @@ -525,6 +599,7 @@ public Builder from(BillingInvoiceResponseData other) { periodEnd(other.getPeriodEnd()); periodStart(other.getPeriodStart()); providerType(other.getProviderType()); + startingBalance(other.getStartingBalance()); status(other.getStatus()); subscriptionExternalId(other.getSubscriptionExternalId()); subtotal(other.getSubtotal()); @@ -533,6 +608,17 @@ public Builder from(BillingInvoiceResponseData other) { return this; } + /** + *

What the company is asked to pay: the total less any balance applied to it, never below zero. Zero on a draft.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("amount_due") + public AmountPaidStage amountDue(long amountDue) { + this.amountDue = amountDue; + return this; + } + @java.lang.Override @JsonSetter("amount_paid") public AmountRemainingStage amountPaid(long amountPaid) { @@ -563,11 +649,22 @@ public CurrencyStage createdAt(@NotNull OffsetDateTime createdAt) { @java.lang.Override @JsonSetter("currency") - public IdStage currency(@NotNull Currency currency) { + public EndingBalanceStage currency(@NotNull Currency currency) { this.currency = Objects.requireNonNull(currency, "currency must not be null"); return this; } + /** + *

The company's balance after this invoice, in minor units. Below zero is credit the next invoice takes off what is due.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("ending_balance") + public IdStage endingBalance(long endingBalance) { + this.endingBalance = endingBalance; + return this; + } + @java.lang.Override @JsonSetter("id") public ProviderTypeStage id(@NotNull String id) { @@ -577,11 +674,22 @@ public ProviderTypeStage id(@NotNull String id) { @java.lang.Override @JsonSetter("provider_type") - public StatusStage providerType(@NotNull BillingProviderType providerType) { + public StartingBalanceStage providerType(@NotNull BillingProviderType providerType) { this.providerType = Objects.requireNonNull(providerType, "providerType must not be null"); return this; } + /** + *

The company's balance before this invoice, in minor units. Below zero is credit applied to this invoice.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("starting_balance") + public StatusStage startingBalance(long startingBalance) { + this.startingBalance = startingBalance; + return this; + } + @java.lang.Override @JsonSetter("status") public SubtotalStage status(@NotNull InvoiceStatus status) { @@ -818,6 +926,7 @@ public _FinalStage collectionState(Optional collectionSt @java.lang.Override public BillingInvoiceResponseData build() { return new BillingInvoiceResponseData( + amountDue, amountPaid, amountRemaining, collectionState, @@ -828,6 +937,7 @@ public BillingInvoiceResponseData build() { currency, documentState, dueAt, + endingBalance, externalId, finalizedAt, id, @@ -835,6 +945,7 @@ public BillingInvoiceResponseData build() { periodEnd, periodStart, providerType, + startingBalance, status, subscriptionExternalId, subtotal, @@ -845,7 +956,8 @@ public BillingInvoiceResponseData build() { @JsonAnySetter private void putAdditionalPropertyFromJson(String key, Object value) { - if (key.equalsIgnoreCase("amount_paid") + if (key.equalsIgnoreCase("amount_due") + || key.equalsIgnoreCase("amount_paid") || key.equalsIgnoreCase("amount_remaining") || key.equalsIgnoreCase("collection_state") || key.equalsIgnoreCase("collector") @@ -855,6 +967,7 @@ private void putAdditionalPropertyFromJson(String key, Object value) { || key.equalsIgnoreCase("currency") || key.equalsIgnoreCase("document_state") || key.equalsIgnoreCase("due_at") + || key.equalsIgnoreCase("ending_balance") || key.equalsIgnoreCase("external_id") || key.equalsIgnoreCase("finalized_at") || key.equalsIgnoreCase("id") @@ -862,6 +975,7 @@ private void putAdditionalPropertyFromJson(String key, Object value) { || key.equalsIgnoreCase("period_end") || key.equalsIgnoreCase("period_start") || key.equalsIgnoreCase("provider_type") + || key.equalsIgnoreCase("starting_balance") || key.equalsIgnoreCase("status") || key.equalsIgnoreCase("subscription_external_id") || key.equalsIgnoreCase("subtotal") diff --git a/src/main/java/com/schematic/api/types/BillingInvoiceWebhook.java b/src/main/java/com/schematic/api/types/BillingInvoiceWebhook.java new file mode 100644 index 0000000..05a6777 --- /dev/null +++ b/src/main/java/com/schematic/api/types/BillingInvoiceWebhook.java @@ -0,0 +1,603 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import java.time.OffsetDateTime; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = BillingInvoiceWebhook.Builder.class) +public final class BillingInvoiceWebhook { + private final long amountDue; + + private final long amountPaid; + + private final long amountRemaining; + + private final String companyId; + + private final Optional contractId; + + private final Currency currency; + + private final Optional dueDate; + + private final String id; + + private final Optional number; + + private final Optional periodEnd; + + private final Optional periodStart; + + private final Optional status; + + private final long subtotal; + + private final long tax; + + private final long total; + + private final Optional url; + + private final Map additionalProperties; + + private BillingInvoiceWebhook( + long amountDue, + long amountPaid, + long amountRemaining, + String companyId, + Optional contractId, + Currency currency, + Optional dueDate, + String id, + Optional number, + Optional periodEnd, + Optional periodStart, + Optional status, + long subtotal, + long tax, + long total, + Optional url, + Map additionalProperties) { + this.amountDue = amountDue; + this.amountPaid = amountPaid; + this.amountRemaining = amountRemaining; + this.companyId = companyId; + this.contractId = contractId; + this.currency = currency; + this.dueDate = dueDate; + this.id = id; + this.number = number; + this.periodEnd = periodEnd; + this.periodStart = periodStart; + this.status = status; + this.subtotal = subtotal; + this.tax = tax; + this.total = total; + this.url = url; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("amount_due") + public long getAmountDue() { + return amountDue; + } + + @JsonProperty("amount_paid") + public long getAmountPaid() { + return amountPaid; + } + + @JsonProperty("amount_remaining") + public long getAmountRemaining() { + return amountRemaining; + } + + @JsonProperty("company_id") + public String getCompanyId() { + return companyId; + } + + @JsonProperty("contract_id") + public Optional getContractId() { + return contractId; + } + + @JsonProperty("currency") + public Currency getCurrency() { + return currency; + } + + @JsonProperty("due_date") + public Optional getDueDate() { + return dueDate; + } + + @JsonProperty("id") + public String getId() { + return id; + } + + @JsonProperty("number") + public Optional getNumber() { + return number; + } + + @JsonProperty("period_end") + public Optional getPeriodEnd() { + return periodEnd; + } + + @JsonProperty("period_start") + public Optional getPeriodStart() { + return periodStart; + } + + @JsonProperty("status") + public Optional getStatus() { + return status; + } + + @JsonProperty("subtotal") + public long getSubtotal() { + return subtotal; + } + + @JsonProperty("tax") + public long getTax() { + return tax; + } + + @JsonProperty("total") + public long getTotal() { + return total; + } + + /** + * @return The invoice's hosted page. Null until the invoice has one. + */ + @JsonProperty("url") + public Optional getUrl() { + return url; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof BillingInvoiceWebhook && equalTo((BillingInvoiceWebhook) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(BillingInvoiceWebhook other) { + return amountDue == other.amountDue + && amountPaid == other.amountPaid + && amountRemaining == other.amountRemaining + && companyId.equals(other.companyId) + && contractId.equals(other.contractId) + && currency.equals(other.currency) + && dueDate.equals(other.dueDate) + && id.equals(other.id) + && number.equals(other.number) + && periodEnd.equals(other.periodEnd) + && periodStart.equals(other.periodStart) + && status.equals(other.status) + && subtotal == other.subtotal + && tax == other.tax + && total == other.total + && url.equals(other.url); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.amountDue, + this.amountPaid, + this.amountRemaining, + this.companyId, + this.contractId, + this.currency, + this.dueDate, + this.id, + this.number, + this.periodEnd, + this.periodStart, + this.status, + this.subtotal, + this.tax, + this.total, + this.url); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static AmountDueStage builder() { + return new Builder(); + } + + public interface AmountDueStage { + AmountPaidStage amountDue(long amountDue); + + Builder from(BillingInvoiceWebhook other); + } + + public interface AmountPaidStage { + AmountRemainingStage amountPaid(long amountPaid); + } + + public interface AmountRemainingStage { + CompanyIdStage amountRemaining(long amountRemaining); + } + + public interface CompanyIdStage { + CurrencyStage companyId(@NotNull String companyId); + } + + public interface CurrencyStage { + IdStage currency(@NotNull Currency currency); + } + + public interface IdStage { + SubtotalStage id(@NotNull String id); + } + + public interface SubtotalStage { + TaxStage subtotal(long subtotal); + } + + public interface TaxStage { + TotalStage tax(long tax); + } + + public interface TotalStage { + _FinalStage total(long total); + } + + public interface _FinalStage { + BillingInvoiceWebhook build(); + + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); + + _FinalStage contractId(Optional contractId); + + _FinalStage contractId(String contractId); + + _FinalStage dueDate(Optional dueDate); + + _FinalStage dueDate(OffsetDateTime dueDate); + + _FinalStage number(Optional number); + + _FinalStage number(String number); + + _FinalStage periodEnd(Optional periodEnd); + + _FinalStage periodEnd(OffsetDateTime periodEnd); + + _FinalStage periodStart(Optional periodStart); + + _FinalStage periodStart(OffsetDateTime periodStart); + + _FinalStage status(Optional status); + + _FinalStage status(InvoiceStatus status); + + /** + *

The invoice's hosted page. Null until the invoice has one.

+ */ + _FinalStage url(Optional url); + + _FinalStage url(String url); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder + implements AmountDueStage, + AmountPaidStage, + AmountRemainingStage, + CompanyIdStage, + CurrencyStage, + IdStage, + SubtotalStage, + TaxStage, + TotalStage, + _FinalStage { + private long amountDue; + + private long amountPaid; + + private long amountRemaining; + + private String companyId; + + private Currency currency; + + private String id; + + private long subtotal; + + private long tax; + + private long total; + + private Optional url = Optional.empty(); + + private Optional status = Optional.empty(); + + private Optional periodStart = Optional.empty(); + + private Optional periodEnd = Optional.empty(); + + private Optional number = Optional.empty(); + + private Optional dueDate = Optional.empty(); + + private Optional contractId = Optional.empty(); + + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(BillingInvoiceWebhook other) { + amountDue(other.getAmountDue()); + amountPaid(other.getAmountPaid()); + amountRemaining(other.getAmountRemaining()); + companyId(other.getCompanyId()); + contractId(other.getContractId()); + currency(other.getCurrency()); + dueDate(other.getDueDate()); + id(other.getId()); + number(other.getNumber()); + periodEnd(other.getPeriodEnd()); + periodStart(other.getPeriodStart()); + status(other.getStatus()); + subtotal(other.getSubtotal()); + tax(other.getTax()); + total(other.getTotal()); + url(other.getUrl()); + return this; + } + + @java.lang.Override + @JsonSetter("amount_due") + public AmountPaidStage amountDue(long amountDue) { + this.amountDue = amountDue; + return this; + } + + @java.lang.Override + @JsonSetter("amount_paid") + public AmountRemainingStage amountPaid(long amountPaid) { + this.amountPaid = amountPaid; + return this; + } + + @java.lang.Override + @JsonSetter("amount_remaining") + public CompanyIdStage amountRemaining(long amountRemaining) { + this.amountRemaining = amountRemaining; + return this; + } + + @java.lang.Override + @JsonSetter("company_id") + public CurrencyStage companyId(@NotNull String companyId) { + this.companyId = Objects.requireNonNull(companyId, "companyId must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("currency") + public IdStage currency(@NotNull Currency currency) { + this.currency = Objects.requireNonNull(currency, "currency must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("id") + public SubtotalStage id(@NotNull String id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("subtotal") + public TaxStage subtotal(long subtotal) { + this.subtotal = subtotal; + return this; + } + + @java.lang.Override + @JsonSetter("tax") + public TotalStage tax(long tax) { + this.tax = tax; + return this; + } + + @java.lang.Override + @JsonSetter("total") + public _FinalStage total(long total) { + this.total = total; + return this; + } + + /** + *

The invoice's hosted page. Null until the invoice has one.

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

The invoice's hosted page. Null until the invoice has one.

+ */ + @java.lang.Override + @JsonSetter(value = "url", nulls = Nulls.SKIP) + public _FinalStage url(Optional url) { + this.url = url; + return this; + } + + @java.lang.Override + public _FinalStage status(InvoiceStatus status) { + this.status = Optional.ofNullable(status); + return this; + } + + @java.lang.Override + @JsonSetter(value = "status", nulls = Nulls.SKIP) + public _FinalStage status(Optional status) { + this.status = status; + return this; + } + + @java.lang.Override + public _FinalStage periodStart(OffsetDateTime periodStart) { + this.periodStart = Optional.ofNullable(periodStart); + return this; + } + + @java.lang.Override + @JsonSetter(value = "period_start", nulls = Nulls.SKIP) + public _FinalStage periodStart(Optional periodStart) { + this.periodStart = periodStart; + return this; + } + + @java.lang.Override + public _FinalStage periodEnd(OffsetDateTime periodEnd) { + this.periodEnd = Optional.ofNullable(periodEnd); + return this; + } + + @java.lang.Override + @JsonSetter(value = "period_end", nulls = Nulls.SKIP) + public _FinalStage periodEnd(Optional periodEnd) { + this.periodEnd = periodEnd; + return this; + } + + @java.lang.Override + public _FinalStage number(String number) { + this.number = Optional.ofNullable(number); + return this; + } + + @java.lang.Override + @JsonSetter(value = "number", nulls = Nulls.SKIP) + public _FinalStage number(Optional number) { + this.number = number; + return this; + } + + @java.lang.Override + public _FinalStage dueDate(OffsetDateTime dueDate) { + this.dueDate = Optional.ofNullable(dueDate); + return this; + } + + @java.lang.Override + @JsonSetter(value = "due_date", nulls = Nulls.SKIP) + public _FinalStage dueDate(Optional dueDate) { + this.dueDate = dueDate; + return this; + } + + @java.lang.Override + public _FinalStage contractId(String contractId) { + this.contractId = Optional.ofNullable(contractId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "contract_id", nulls = Nulls.SKIP) + public _FinalStage contractId(Optional contractId) { + this.contractId = contractId; + return this; + } + + @java.lang.Override + public BillingInvoiceWebhook build() { + return new BillingInvoiceWebhook( + amountDue, + amountPaid, + amountRemaining, + companyId, + contractId, + currency, + dueDate, + id, + number, + periodEnd, + periodStart, + status, + subtotal, + tax, + total, + url, + additionalProperties); + } + + @JsonAnySetter + private void putAdditionalPropertyFromJson(String key, Object value) { + if (key.equalsIgnoreCase("amount_due") + || key.equalsIgnoreCase("amount_paid") + || key.equalsIgnoreCase("amount_remaining") + || key.equalsIgnoreCase("company_id") + || key.equalsIgnoreCase("contract_id") + || key.equalsIgnoreCase("currency") + || key.equalsIgnoreCase("due_date") + || key.equalsIgnoreCase("id") + || key.equalsIgnoreCase("number") + || key.equalsIgnoreCase("period_end") + || key.equalsIgnoreCase("period_start") + || key.equalsIgnoreCase("status") + || key.equalsIgnoreCase("subtotal") + || key.equalsIgnoreCase("tax") + || key.equalsIgnoreCase("total") + || key.equalsIgnoreCase("url")) { + return; + } + this.additionalProperties.put(key, value); + } + + @java.lang.Override + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + @java.lang.Override + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + } +} diff --git a/src/main/java/com/schematic/api/types/BillingNativeSubscriptionLineResponseData.java b/src/main/java/com/schematic/api/types/BillingNativeSubscriptionLineResponseData.java index a9e343e..c4e8355 100644 --- a/src/main/java/com/schematic/api/types/BillingNativeSubscriptionLineResponseData.java +++ b/src/main/java/com/schematic/api/types/BillingNativeSubscriptionLineResponseData.java @@ -42,6 +42,8 @@ public final class BillingNativeSubscriptionLineResponseData { private final Optional effectiveTo; + private final Optional featureName; + private final String id; private final LineKind kind; @@ -75,6 +77,7 @@ private BillingNativeSubscriptionLineResponseData( Optional currentPeriodStart, OffsetDateTime effectiveFrom, Optional effectiveTo, + Optional featureName, String id, LineKind kind, long quantity, @@ -96,6 +99,7 @@ private BillingNativeSubscriptionLineResponseData( this.currentPeriodStart = currentPeriodStart; this.effectiveFrom = effectiveFrom; this.effectiveTo = effectiveTo; + this.featureName = featureName; this.id = id; this.kind = kind; this.quantity = quantity; @@ -171,6 +175,14 @@ public Optional getEffectiveTo() { return effectiveTo; } + /** + * @return The feature the line bills for when its price belongs to a plan entitlement, such as seats. Null on a plan's own price, an add-on's and a credit's. + */ + @JsonProperty("feature_name") + public Optional getFeatureName() { + return featureName; + } + @JsonProperty("id") public String getId() { return id; @@ -256,6 +268,7 @@ private boolean equalTo(BillingNativeSubscriptionLineResponseData other) { && currentPeriodStart.equals(other.currentPeriodStart) && effectiveFrom.equals(other.effectiveFrom) && effectiveTo.equals(other.effectiveTo) + && featureName.equals(other.featureName) && id.equals(other.id) && kind.equals(other.kind) && quantity == other.quantity @@ -281,6 +294,7 @@ public int hashCode() { this.currentPeriodStart, this.effectiveFrom, this.effectiveTo, + this.featureName, this.id, this.kind, this.quantity, @@ -390,6 +404,13 @@ public interface _FinalStage { _FinalStage effectiveTo(OffsetDateTime effectiveTo); + /** + *

The feature the line bills for when its price belongs to a plan entitlement, such as seats. Null on a plan's own price, an add-on's and a credit's.

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

The name of the plan, add-on or credit the line compiles from.

*/ @@ -466,6 +487,8 @@ public static final class Builder private Optional sourceName = Optional.empty(); + private Optional featureName = Optional.empty(); + private Optional effectiveTo = Optional.empty(); private Optional currentPeriodStart = Optional.empty(); @@ -488,6 +511,7 @@ public Builder from(BillingNativeSubscriptionLineResponseData other) { currentPeriodStart(other.getCurrentPeriodStart()); effectiveFrom(other.getEffectiveFrom()); effectiveTo(other.getEffectiveTo()); + featureName(other.getFeatureName()); id(other.getId()); kind(other.getKind()); quantity(other.getQuantity()); @@ -677,6 +701,26 @@ public _FinalStage sourceName(Optional sourceName) { return this; } + /** + *

The feature the line bills for when its price belongs to a plan entitlement, such as seats. Null on a plan's own price, an add-on's and a credit's.

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

The feature the line bills for when its price belongs to a plan entitlement, such as seats. Null on a plan's own price, an add-on's and a credit's.

+ */ + @java.lang.Override + @JsonSetter(value = "feature_name", nulls = Nulls.SKIP) + public _FinalStage featureName(Optional featureName) { + this.featureName = featureName; + return this; + } + @java.lang.Override public _FinalStage effectiveTo(OffsetDateTime effectiveTo) { this.effectiveTo = Optional.ofNullable(effectiveTo); @@ -743,6 +787,7 @@ public BillingNativeSubscriptionLineResponseData build() { currentPeriodStart, effectiveFrom, effectiveTo, + featureName, id, kind, quantity, @@ -768,6 +813,7 @@ private void putAdditionalPropertyFromJson(String key, Object value) { || key.equalsIgnoreCase("current_period_start") || key.equalsIgnoreCase("effective_from") || key.equalsIgnoreCase("effective_to") + || key.equalsIgnoreCase("feature_name") || key.equalsIgnoreCase("id") || key.equalsIgnoreCase("kind") || key.equalsIgnoreCase("quantity") diff --git a/src/main/java/com/schematic/api/types/BillingNativeSubscriptionResponseData.java b/src/main/java/com/schematic/api/types/BillingNativeSubscriptionResponseData.java index 105b15e..b8dfd52 100644 --- a/src/main/java/com/schematic/api/types/BillingNativeSubscriptionResponseData.java +++ b/src/main/java/com/schematic/api/types/BillingNativeSubscriptionResponseData.java @@ -24,6 +24,8 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = BillingNativeSubscriptionResponseData.Builder.class) public final class BillingNativeSubscriptionResponseData { + private final long balance; + private final Optional cancelAt; private final String companyId; @@ -51,6 +53,7 @@ public final class BillingNativeSubscriptionResponseData { private final Map additionalProperties; private BillingNativeSubscriptionResponseData( + long balance, Optional cancelAt, String companyId, Currency currency, @@ -64,6 +67,7 @@ private BillingNativeSubscriptionResponseData( SubscriptionStatus status, Optional terms, Map additionalProperties) { + this.balance = balance; this.cancelAt = cancelAt; this.companyId = companyId; this.currency = currency; @@ -79,6 +83,14 @@ private BillingNativeSubscriptionResponseData( this.additionalProperties = additionalProperties; } + /** + * @return The company's balance on its contract, in minor units of the currency. Below zero is credit the next invoice takes off what is due. Zero when the company has no billing profile. + */ + @JsonProperty("balance") + public long getBalance() { + return balance; + } + @JsonProperty("cancel_at") public Optional getCancelAt() { return cancelAt; @@ -164,7 +176,8 @@ public Map getAdditionalProperties() { } private boolean equalTo(BillingNativeSubscriptionResponseData other) { - return cancelAt.equals(other.cancelAt) + return balance == other.balance + && cancelAt.equals(other.cancelAt) && companyId.equals(other.companyId) && currency.equals(other.currency) && id.equals(other.id) @@ -181,6 +194,7 @@ private boolean equalTo(BillingNativeSubscriptionResponseData other) { @java.lang.Override public int hashCode() { return Objects.hash( + this.balance, this.cancelAt, this.companyId, this.currency, @@ -200,16 +214,23 @@ public String toString() { return ObjectMappers.stringify(this); } - public static CompanyIdStage builder() { + public static BalanceStage builder() { return new Builder(); } - public interface CompanyIdStage { - CurrencyStage companyId(@NotNull String companyId); + public interface BalanceStage { + /** + *

The company's balance on its contract, in minor units of the currency. Below zero is credit the next invoice takes off what is due. Zero when the company has no billing profile.

+ */ + CompanyIdStage balance(long balance); Builder from(BillingNativeSubscriptionResponseData other); } + public interface CompanyIdStage { + CurrencyStage companyId(@NotNull String companyId); + } + public interface CurrencyStage { IdStage currency(@NotNull Currency currency); } @@ -280,13 +301,16 @@ public interface _FinalStage { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder - implements CompanyIdStage, + implements BalanceStage, + CompanyIdStage, CurrencyStage, IdStage, PeriodEndStage, PeriodStartStage, StatusStage, _FinalStage { + private long balance; + private String companyId; private Currency currency; @@ -317,6 +341,7 @@ private Builder() {} @java.lang.Override public Builder from(BillingNativeSubscriptionResponseData other) { + balance(other.getBalance()); cancelAt(other.getCancelAt()); companyId(other.getCompanyId()); currency(other.getCurrency()); @@ -332,6 +357,17 @@ public Builder from(BillingNativeSubscriptionResponseData other) { return this; } + /** + *

The company's balance on its contract, in minor units of the currency. Below zero is credit the next invoice takes off what is due. Zero when the company has no billing profile.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("balance") + public CompanyIdStage balance(long balance) { + this.balance = balance; + return this; + } + @java.lang.Override @JsonSetter("company_id") public CurrencyStage companyId(@NotNull String companyId) { @@ -513,6 +549,7 @@ public _FinalStage cancelAt(Optional cancelAt) { @java.lang.Override public BillingNativeSubscriptionResponseData build() { return new BillingNativeSubscriptionResponseData( + balance, cancelAt, companyId, currency, @@ -530,7 +567,8 @@ public BillingNativeSubscriptionResponseData build() { @JsonAnySetter private void putAdditionalPropertyFromJson(String key, Object value) { - if (key.equalsIgnoreCase("cancel_at") + if (key.equalsIgnoreCase("balance") + || key.equalsIgnoreCase("cancel_at") || key.equalsIgnoreCase("company_id") || key.equalsIgnoreCase("currency") || key.equalsIgnoreCase("id") diff --git a/src/main/java/com/schematic/api/types/BillingStatementLineResponseData.java b/src/main/java/com/schematic/api/types/BillingStatementLineResponseData.java index 85e6720..8c88aab 100644 --- a/src/main/java/com/schematic/api/types/BillingStatementLineResponseData.java +++ b/src/main/java/com/schematic/api/types/BillingStatementLineResponseData.java @@ -24,12 +24,16 @@ public final class BillingStatementLineResponseData { private final long amount; + private final Optional description; + private final InvoiceLineKind kind; private final Optional periodEnd; private final Optional periodStart; + private final Optional prorationFraction; + private final Optional quantity; private final Optional subscriptionLineId; @@ -40,17 +44,21 @@ public final class BillingStatementLineResponseData { private BillingStatementLineResponseData( long amount, + Optional description, InvoiceLineKind kind, Optional periodEnd, Optional periodStart, + Optional prorationFraction, Optional quantity, Optional subscriptionLineId, Optional unitAmount, Map additionalProperties) { this.amount = amount; + this.description = description; this.kind = kind; this.periodEnd = periodEnd; this.periodStart = periodStart; + this.prorationFraction = prorationFraction; this.quantity = quantity; this.subscriptionLineId = subscriptionLineId; this.unitAmount = unitAmount; @@ -65,6 +73,14 @@ public long getAmount() { return amount; } + /** + * @return What the line bills for, and for part of a period, which part. Null when the line has no subscription line behind it. + */ + @JsonProperty("description") + public Optional getDescription() { + return description; + } + @JsonProperty("kind") public InvoiceLineKind getKind() { return kind; @@ -80,6 +96,14 @@ public Optional getPeriodStart() { return periodStart; } + /** + * @return The share of a full billing period the line bills, as a decimal from 0 to 1. Null when the line bills a whole period. + */ + @JsonProperty("proration_fraction") + public Optional getProrationFraction() { + return prorationFraction; + } + @JsonProperty("quantity") public Optional getQuantity() { return quantity; @@ -108,9 +132,11 @@ public Map getAdditionalProperties() { private boolean equalTo(BillingStatementLineResponseData other) { return amount == other.amount + && description.equals(other.description) && kind.equals(other.kind) && periodEnd.equals(other.periodEnd) && periodStart.equals(other.periodStart) + && prorationFraction.equals(other.prorationFraction) && quantity.equals(other.quantity) && subscriptionLineId.equals(other.subscriptionLineId) && unitAmount.equals(other.unitAmount); @@ -120,9 +146,11 @@ private boolean equalTo(BillingStatementLineResponseData other) { public int hashCode() { return Objects.hash( this.amount, + this.description, this.kind, this.periodEnd, this.periodStart, + this.prorationFraction, this.quantity, this.subscriptionLineId, this.unitAmount); @@ -157,6 +185,13 @@ public interface _FinalStage { _FinalStage additionalProperties(Map additionalProperties); + /** + *

What the line bills for, and for part of a period, which part. Null when the line has no subscription line behind it.

+ */ + _FinalStage description(Optional description); + + _FinalStage description(String description); + _FinalStage periodEnd(Optional periodEnd); _FinalStage periodEnd(OffsetDateTime periodEnd); @@ -165,6 +200,13 @@ public interface _FinalStage { _FinalStage periodStart(OffsetDateTime periodStart); + /** + *

The share of a full billing period the line bills, as a decimal from 0 to 1. Null when the line bills a whole period.

+ */ + _FinalStage prorationFraction(Optional prorationFraction); + + _FinalStage prorationFraction(String prorationFraction); + _FinalStage quantity(Optional quantity); _FinalStage quantity(Long quantity); @@ -190,10 +232,14 @@ public static final class Builder implements AmountStage, KindStage, _FinalStage private Optional quantity = Optional.empty(); + private Optional prorationFraction = Optional.empty(); + private Optional periodStart = Optional.empty(); private Optional periodEnd = Optional.empty(); + private Optional description = Optional.empty(); + private Map additionalProperties = new HashMap<>(); private Builder() {} @@ -201,9 +247,11 @@ private Builder() {} @java.lang.Override public Builder from(BillingStatementLineResponseData other) { amount(other.getAmount()); + description(other.getDescription()); kind(other.getKind()); periodEnd(other.getPeriodEnd()); periodStart(other.getPeriodStart()); + prorationFraction(other.getProrationFraction()); quantity(other.getQuantity()); subscriptionLineId(other.getSubscriptionLineId()); unitAmount(other.getUnitAmount()); @@ -267,6 +315,26 @@ public _FinalStage quantity(Optional quantity) { return this; } + /** + *

The share of a full billing period the line bills, as a decimal from 0 to 1. Null when the line bills a whole period.

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

The share of a full billing period the line bills, as a decimal from 0 to 1. Null when the line bills a whole period.

+ */ + @java.lang.Override + @JsonSetter(value = "proration_fraction", nulls = Nulls.SKIP) + public _FinalStage prorationFraction(Optional prorationFraction) { + this.prorationFraction = prorationFraction; + return this; + } + @java.lang.Override public _FinalStage periodStart(OffsetDateTime periodStart) { this.periodStart = Optional.ofNullable(periodStart); @@ -293,13 +361,35 @@ public _FinalStage periodEnd(Optional periodEnd) { return this; } + /** + *

What the line bills for, and for part of a period, which part. Null when the line has no subscription line behind it.

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

What the line bills for, and for part of a period, which part. Null when the line has no subscription line behind it.

+ */ + @java.lang.Override + @JsonSetter(value = "description", nulls = Nulls.SKIP) + public _FinalStage description(Optional description) { + this.description = description; + return this; + } + @java.lang.Override public BillingStatementLineResponseData build() { return new BillingStatementLineResponseData( amount, + description, kind, periodEnd, periodStart, + prorationFraction, quantity, subscriptionLineId, unitAmount, @@ -309,9 +399,11 @@ public BillingStatementLineResponseData build() { @JsonAnySetter private void putAdditionalPropertyFromJson(String key, Object value) { if (key.equalsIgnoreCase("amount") + || key.equalsIgnoreCase("description") || key.equalsIgnoreCase("kind") || key.equalsIgnoreCase("period_end") || key.equalsIgnoreCase("period_start") + || key.equalsIgnoreCase("proration_fraction") || key.equalsIgnoreCase("quantity") || key.equalsIgnoreCase("subscription_line_id") || key.equalsIgnoreCase("unit_amount")) { diff --git a/src/main/java/com/schematic/api/types/BillingSubscriptionPeriodLineWebhook.java b/src/main/java/com/schematic/api/types/BillingSubscriptionPeriodLineWebhook.java new file mode 100644 index 0000000..e85b87e --- /dev/null +++ b/src/main/java/com/schematic/api/types/BillingSubscriptionPeriodLineWebhook.java @@ -0,0 +1,344 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import java.time.OffsetDateTime; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = BillingSubscriptionPeriodLineWebhook.Builder.class) +public final class BillingSubscriptionPeriodLineWebhook { + private final long amount; + + private final Currency currency; + + private final String id; + + private final OffsetDateTime periodEnd; + + private final OffsetDateTime periodStart; + + private final Optional quantity; + + private final String sourceId; + + private final Optional unitAmount; + + private final Map additionalProperties; + + private BillingSubscriptionPeriodLineWebhook( + long amount, + Currency currency, + String id, + OffsetDateTime periodEnd, + OffsetDateTime periodStart, + Optional quantity, + String sourceId, + Optional unitAmount, + Map additionalProperties) { + this.amount = amount; + this.currency = currency; + this.id = id; + this.periodEnd = periodEnd; + this.periodStart = periodStart; + this.quantity = quantity; + this.sourceId = sourceId; + this.unitAmount = unitAmount; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("amount") + public long getAmount() { + return amount; + } + + @JsonProperty("currency") + public Currency getCurrency() { + return currency; + } + + @JsonProperty("id") + public String getId() { + return id; + } + + @JsonProperty("period_end") + public OffsetDateTime getPeriodEnd() { + return periodEnd; + } + + @JsonProperty("period_start") + public OffsetDateTime getPeriodStart() { + return periodStart; + } + + @JsonProperty("quantity") + public Optional getQuantity() { + return quantity; + } + + /** + * @return The plan or add-on the line bills for. + */ + @JsonProperty("source_id") + public String getSourceId() { + return sourceId; + } + + @JsonProperty("unit_amount") + public Optional getUnitAmount() { + return unitAmount; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof BillingSubscriptionPeriodLineWebhook + && equalTo((BillingSubscriptionPeriodLineWebhook) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(BillingSubscriptionPeriodLineWebhook other) { + return amount == other.amount + && currency.equals(other.currency) + && id.equals(other.id) + && periodEnd.equals(other.periodEnd) + && periodStart.equals(other.periodStart) + && quantity.equals(other.quantity) + && sourceId.equals(other.sourceId) + && unitAmount.equals(other.unitAmount); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.amount, + this.currency, + this.id, + this.periodEnd, + this.periodStart, + this.quantity, + this.sourceId, + this.unitAmount); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static AmountStage builder() { + return new Builder(); + } + + public interface AmountStage { + CurrencyStage amount(long amount); + + Builder from(BillingSubscriptionPeriodLineWebhook other); + } + + public interface CurrencyStage { + IdStage currency(@NotNull Currency currency); + } + + public interface IdStage { + PeriodEndStage id(@NotNull String id); + } + + public interface PeriodEndStage { + PeriodStartStage periodEnd(@NotNull OffsetDateTime periodEnd); + } + + public interface PeriodStartStage { + SourceIdStage periodStart(@NotNull OffsetDateTime periodStart); + } + + public interface SourceIdStage { + /** + *

The plan or add-on the line bills for.

+ */ + _FinalStage sourceId(@NotNull String sourceId); + } + + public interface _FinalStage { + BillingSubscriptionPeriodLineWebhook build(); + + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); + + _FinalStage quantity(Optional quantity); + + _FinalStage quantity(Long quantity); + + _FinalStage unitAmount(Optional unitAmount); + + _FinalStage unitAmount(Long unitAmount); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder + implements AmountStage, + CurrencyStage, + IdStage, + PeriodEndStage, + PeriodStartStage, + SourceIdStage, + _FinalStage { + private long amount; + + private Currency currency; + + private String id; + + private OffsetDateTime periodEnd; + + private OffsetDateTime periodStart; + + private String sourceId; + + private Optional unitAmount = Optional.empty(); + + private Optional quantity = Optional.empty(); + + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(BillingSubscriptionPeriodLineWebhook other) { + amount(other.getAmount()); + currency(other.getCurrency()); + id(other.getId()); + periodEnd(other.getPeriodEnd()); + periodStart(other.getPeriodStart()); + quantity(other.getQuantity()); + sourceId(other.getSourceId()); + unitAmount(other.getUnitAmount()); + return this; + } + + @java.lang.Override + @JsonSetter("amount") + public CurrencyStage amount(long amount) { + this.amount = amount; + return this; + } + + @java.lang.Override + @JsonSetter("currency") + public IdStage currency(@NotNull Currency currency) { + this.currency = Objects.requireNonNull(currency, "currency must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("id") + public PeriodEndStage id(@NotNull String id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("period_end") + public PeriodStartStage periodEnd(@NotNull OffsetDateTime periodEnd) { + this.periodEnd = Objects.requireNonNull(periodEnd, "periodEnd must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("period_start") + public SourceIdStage periodStart(@NotNull OffsetDateTime periodStart) { + this.periodStart = Objects.requireNonNull(periodStart, "periodStart must not be null"); + return this; + } + + /** + *

The plan or add-on the line bills for.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("source_id") + public _FinalStage sourceId(@NotNull String sourceId) { + this.sourceId = Objects.requireNonNull(sourceId, "sourceId must not be null"); + return this; + } + + @java.lang.Override + public _FinalStage unitAmount(Long unitAmount) { + this.unitAmount = Optional.ofNullable(unitAmount); + return this; + } + + @java.lang.Override + @JsonSetter(value = "unit_amount", nulls = Nulls.SKIP) + public _FinalStage unitAmount(Optional unitAmount) { + this.unitAmount = unitAmount; + return this; + } + + @java.lang.Override + public _FinalStage quantity(Long quantity) { + this.quantity = Optional.ofNullable(quantity); + return this; + } + + @java.lang.Override + @JsonSetter(value = "quantity", nulls = Nulls.SKIP) + public _FinalStage quantity(Optional quantity) { + this.quantity = quantity; + return this; + } + + @java.lang.Override + public BillingSubscriptionPeriodLineWebhook build() { + return new BillingSubscriptionPeriodLineWebhook( + amount, currency, id, periodEnd, periodStart, quantity, sourceId, unitAmount, additionalProperties); + } + + @JsonAnySetter + private void putAdditionalPropertyFromJson(String key, Object value) { + if (key.equalsIgnoreCase("amount") + || key.equalsIgnoreCase("currency") + || key.equalsIgnoreCase("id") + || key.equalsIgnoreCase("period_end") + || key.equalsIgnoreCase("period_start") + || key.equalsIgnoreCase("quantity") + || key.equalsIgnoreCase("source_id") + || key.equalsIgnoreCase("unit_amount")) { + return; + } + this.additionalProperties.put(key, value); + } + + @java.lang.Override + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + @java.lang.Override + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + } +} diff --git a/src/main/java/com/schematic/api/types/BillingSubscriptionPeriodWebhook.java b/src/main/java/com/schematic/api/types/BillingSubscriptionPeriodWebhook.java new file mode 100644 index 0000000..e97f307 --- /dev/null +++ b/src/main/java/com/schematic/api/types/BillingSubscriptionPeriodWebhook.java @@ -0,0 +1,300 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import java.time.OffsetDateTime; +import java.util.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 = BillingSubscriptionPeriodWebhook.Builder.class) +public final class BillingSubscriptionPeriodWebhook { + private final String companyId; + + private final String contractId; + + private final List lines; + + private final OffsetDateTime periodEnd; + + private final OffsetDateTime periodStart; + + private final String subscriptionId; + + private final Map additionalProperties; + + private BillingSubscriptionPeriodWebhook( + String companyId, + String contractId, + List lines, + OffsetDateTime periodEnd, + OffsetDateTime periodStart, + String subscriptionId, + Map additionalProperties) { + this.companyId = companyId; + this.contractId = contractId; + this.lines = lines; + this.periodEnd = periodEnd; + this.periodStart = periodStart; + this.subscriptionId = subscriptionId; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("company_id") + public String getCompanyId() { + return companyId; + } + + @JsonProperty("contract_id") + public String getContractId() { + return contractId; + } + + /** + * @return The lines charged in advance when the period started. + */ + @JsonProperty("lines") + public List getLines() { + return lines; + } + + @JsonProperty("period_end") + public OffsetDateTime getPeriodEnd() { + return periodEnd; + } + + @JsonProperty("period_start") + public OffsetDateTime getPeriodStart() { + return periodStart; + } + + @JsonProperty("subscription_id") + public String getSubscriptionId() { + return subscriptionId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof BillingSubscriptionPeriodWebhook && equalTo((BillingSubscriptionPeriodWebhook) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(BillingSubscriptionPeriodWebhook other) { + return companyId.equals(other.companyId) + && contractId.equals(other.contractId) + && lines.equals(other.lines) + && periodEnd.equals(other.periodEnd) + && periodStart.equals(other.periodStart) + && subscriptionId.equals(other.subscriptionId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.companyId, this.contractId, this.lines, this.periodEnd, this.periodStart, this.subscriptionId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static CompanyIdStage builder() { + return new Builder(); + } + + public interface CompanyIdStage { + ContractIdStage companyId(@NotNull String companyId); + + Builder from(BillingSubscriptionPeriodWebhook other); + } + + public interface ContractIdStage { + PeriodEndStage contractId(@NotNull String contractId); + } + + public interface PeriodEndStage { + PeriodStartStage periodEnd(@NotNull OffsetDateTime periodEnd); + } + + public interface PeriodStartStage { + SubscriptionIdStage periodStart(@NotNull OffsetDateTime periodStart); + } + + public interface SubscriptionIdStage { + _FinalStage subscriptionId(@NotNull String subscriptionId); + } + + public interface _FinalStage { + BillingSubscriptionPeriodWebhook build(); + + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); + + /** + *

The lines charged in advance when the period started.

+ */ + _FinalStage lines(List lines); + + _FinalStage addLines(BillingSubscriptionPeriodLineWebhook lines); + + _FinalStage addAllLines(List lines); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder + implements CompanyIdStage, + ContractIdStage, + PeriodEndStage, + PeriodStartStage, + SubscriptionIdStage, + _FinalStage { + private String companyId; + + private String contractId; + + private OffsetDateTime periodEnd; + + private OffsetDateTime periodStart; + + private String subscriptionId; + + private List lines = new ArrayList<>(); + + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(BillingSubscriptionPeriodWebhook other) { + companyId(other.getCompanyId()); + contractId(other.getContractId()); + lines(other.getLines()); + periodEnd(other.getPeriodEnd()); + periodStart(other.getPeriodStart()); + subscriptionId(other.getSubscriptionId()); + return this; + } + + @java.lang.Override + @JsonSetter("company_id") + public ContractIdStage companyId(@NotNull String companyId) { + this.companyId = Objects.requireNonNull(companyId, "companyId must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("contract_id") + public PeriodEndStage contractId(@NotNull String contractId) { + this.contractId = Objects.requireNonNull(contractId, "contractId must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("period_end") + public PeriodStartStage periodEnd(@NotNull OffsetDateTime periodEnd) { + this.periodEnd = Objects.requireNonNull(periodEnd, "periodEnd must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("period_start") + public SubscriptionIdStage periodStart(@NotNull OffsetDateTime periodStart) { + this.periodStart = Objects.requireNonNull(periodStart, "periodStart must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("subscription_id") + public _FinalStage subscriptionId(@NotNull String subscriptionId) { + this.subscriptionId = Objects.requireNonNull(subscriptionId, "subscriptionId must not be null"); + return this; + } + + /** + *

The lines charged in advance when the period started.

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

The lines charged in advance when the period started.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage addLines(BillingSubscriptionPeriodLineWebhook lines) { + this.lines.add(lines); + return this; + } + + /** + *

The lines charged in advance when the period started.

+ */ + @java.lang.Override + @JsonSetter(value = "lines", nulls = Nulls.SKIP) + public _FinalStage lines(List lines) { + this.lines.clear(); + if (lines != null) { + this.lines.addAll(lines); + } + return this; + } + + @java.lang.Override + public BillingSubscriptionPeriodWebhook build() { + return new BillingSubscriptionPeriodWebhook( + companyId, contractId, lines, periodEnd, periodStart, subscriptionId, additionalProperties); + } + + @JsonAnySetter + private void putAdditionalPropertyFromJson(String key, Object value) { + if (key.equalsIgnoreCase("company_id") + || key.equalsIgnoreCase("contract_id") + || key.equalsIgnoreCase("lines") + || key.equalsIgnoreCase("period_end") + || key.equalsIgnoreCase("period_start") + || key.equalsIgnoreCase("subscription_id")) { + return; + } + this.additionalProperties.put(key, value); + } + + @java.lang.Override + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + @java.lang.Override + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + } +} diff --git a/src/main/java/com/schematic/api/types/BillingSubscriptionResponseData.java b/src/main/java/com/schematic/api/types/BillingSubscriptionResponseData.java index 48c3936..5f412dc 100644 --- a/src/main/java/com/schematic/api/types/BillingSubscriptionResponseData.java +++ b/src/main/java/com/schematic/api/types/BillingSubscriptionResponseData.java @@ -23,6 +23,8 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = BillingSubscriptionResponseData.Builder.class) public final class BillingSubscriptionResponseData { + private final Optional accessRevokedAt; + private final Optional applicationId; private final Optional cancelAt; @@ -66,6 +68,7 @@ public final class BillingSubscriptionResponseData { private final Map additionalProperties; private BillingSubscriptionResponseData( + Optional accessRevokedAt, Optional applicationId, Optional cancelAt, boolean cancelAtPeriodEnd, @@ -87,6 +90,7 @@ private BillingSubscriptionResponseData( Optional trialEnd, Optional trialEndSetting, Map additionalProperties) { + this.accessRevokedAt = accessRevokedAt; this.applicationId = applicationId; this.cancelAt = cancelAt; this.cancelAtPeriodEnd = cancelAtPeriodEnd; @@ -110,6 +114,11 @@ private BillingSubscriptionResponseData( this.additionalProperties = additionalProperties; } + @JsonProperty("access_revoked_at") + public Optional getAccessRevokedAt() { + return accessRevokedAt; + } + @JsonProperty("application_id") public Optional getApplicationId() { return applicationId; @@ -222,7 +231,8 @@ public Map getAdditionalProperties() { } private boolean equalTo(BillingSubscriptionResponseData other) { - return applicationId.equals(other.applicationId) + return accessRevokedAt.equals(other.accessRevokedAt) + && applicationId.equals(other.applicationId) && cancelAt.equals(other.cancelAt) && cancelAtPeriodEnd == other.cancelAtPeriodEnd && companyId.equals(other.companyId) @@ -247,6 +257,7 @@ private boolean equalTo(BillingSubscriptionResponseData other) { @java.lang.Override public int hashCode() { return Objects.hash( + this.accessRevokedAt, this.applicationId, this.cancelAt, this.cancelAtPeriodEnd, @@ -335,6 +346,10 @@ public interface _FinalStage { _FinalStage additionalProperties(Map additionalProperties); + _FinalStage accessRevokedAt(Optional accessRevokedAt); + + _FinalStage accessRevokedAt(OffsetDateTime accessRevokedAt); + _FinalStage applicationId(Optional applicationId); _FinalStage applicationId(String applicationId); @@ -423,12 +438,15 @@ public static final class Builder private Optional applicationId = Optional.empty(); + private Optional accessRevokedAt = Optional.empty(); + private Map additionalProperties = new HashMap<>(); private Builder() {} @java.lang.Override public Builder from(BillingSubscriptionResponseData other) { + accessRevokedAt(other.getAccessRevokedAt()); applicationId(other.getApplicationId()); cancelAt(other.getCancelAt()); cancelAtPeriodEnd(other.getCancelAtPeriodEnd()); @@ -641,9 +659,23 @@ public _FinalStage applicationId(Optional applicationId) { return this; } + @java.lang.Override + public _FinalStage accessRevokedAt(OffsetDateTime accessRevokedAt) { + this.accessRevokedAt = Optional.ofNullable(accessRevokedAt); + return this; + } + + @java.lang.Override + @JsonSetter(value = "access_revoked_at", nulls = Nulls.SKIP) + public _FinalStage accessRevokedAt(Optional accessRevokedAt) { + this.accessRevokedAt = accessRevokedAt; + return this; + } + @java.lang.Override public BillingSubscriptionResponseData build() { return new BillingSubscriptionResponseData( + accessRevokedAt, applicationId, cancelAt, cancelAtPeriodEnd, @@ -669,7 +701,8 @@ public BillingSubscriptionResponseData build() { @JsonAnySetter private void putAdditionalPropertyFromJson(String key, Object value) { - if (key.equalsIgnoreCase("application_id") + if (key.equalsIgnoreCase("access_revoked_at") + || key.equalsIgnoreCase("application_id") || key.equalsIgnoreCase("cancel_at") || key.equalsIgnoreCase("cancel_at_period_end") || key.equalsIgnoreCase("company_id") diff --git a/src/main/java/com/schematic/api/types/BillingSubscriptionView.java b/src/main/java/com/schematic/api/types/BillingSubscriptionView.java index 9292ddb..77039b7 100644 --- a/src/main/java/com/schematic/api/types/BillingSubscriptionView.java +++ b/src/main/java/com/schematic/api/types/BillingSubscriptionView.java @@ -25,6 +25,8 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = BillingSubscriptionView.Builder.class) public final class BillingSubscriptionView { + private final Optional accessRevokedAt; + private final Optional applicationId; private final Optional cancelAt; @@ -76,6 +78,7 @@ public final class BillingSubscriptionView { private final Map additionalProperties; private BillingSubscriptionView( + Optional accessRevokedAt, Optional applicationId, Optional cancelAt, boolean cancelAtPeriodEnd, @@ -101,6 +104,7 @@ private BillingSubscriptionView( Optional trialEnd, Optional trialEndSetting, Map additionalProperties) { + this.accessRevokedAt = accessRevokedAt; this.applicationId = applicationId; this.cancelAt = cancelAt; this.cancelAtPeriodEnd = cancelAtPeriodEnd; @@ -128,6 +132,11 @@ private BillingSubscriptionView( this.additionalProperties = additionalProperties; } + @JsonProperty("access_revoked_at") + public Optional getAccessRevokedAt() { + return accessRevokedAt; + } + @JsonProperty("application_id") public Optional getApplicationId() { return applicationId; @@ -260,7 +269,8 @@ public Map getAdditionalProperties() { } private boolean equalTo(BillingSubscriptionView other) { - return applicationId.equals(other.applicationId) + return accessRevokedAt.equals(other.accessRevokedAt) + && applicationId.equals(other.applicationId) && cancelAt.equals(other.cancelAt) && cancelAtPeriodEnd == other.cancelAtPeriodEnd && companyId.equals(other.companyId) @@ -289,6 +299,7 @@ private boolean equalTo(BillingSubscriptionView other) { @java.lang.Override public int hashCode() { return Objects.hash( + this.accessRevokedAt, this.applicationId, this.cancelAt, this.cancelAtPeriodEnd, @@ -381,6 +392,10 @@ public interface _FinalStage { _FinalStage additionalProperties(Map additionalProperties); + _FinalStage accessRevokedAt(Optional accessRevokedAt); + + _FinalStage accessRevokedAt(OffsetDateTime accessRevokedAt); + _FinalStage applicationId(Optional applicationId); _FinalStage applicationId(String applicationId); @@ -497,12 +512,15 @@ public static final class Builder private Optional applicationId = Optional.empty(); + private Optional accessRevokedAt = Optional.empty(); + private Map additionalProperties = new HashMap<>(); private Builder() {} @java.lang.Override public Builder from(BillingSubscriptionView other) { + accessRevokedAt(other.getAccessRevokedAt()); applicationId(other.getApplicationId()); cancelAt(other.getCancelAt()); cancelAtPeriodEnd(other.getCancelAtPeriodEnd()); @@ -793,9 +811,23 @@ public _FinalStage applicationId(Optional applicationId) { return this; } + @java.lang.Override + public _FinalStage accessRevokedAt(OffsetDateTime accessRevokedAt) { + this.accessRevokedAt = Optional.ofNullable(accessRevokedAt); + return this; + } + + @java.lang.Override + @JsonSetter(value = "access_revoked_at", nulls = Nulls.SKIP) + public _FinalStage accessRevokedAt(Optional accessRevokedAt) { + this.accessRevokedAt = accessRevokedAt; + return this; + } + @java.lang.Override public BillingSubscriptionView build() { return new BillingSubscriptionView( + accessRevokedAt, applicationId, cancelAt, cancelAtPeriodEnd, @@ -825,7 +857,8 @@ public BillingSubscriptionView build() { @JsonAnySetter private void putAdditionalPropertyFromJson(String key, Object value) { - if (key.equalsIgnoreCase("application_id") + if (key.equalsIgnoreCase("access_revoked_at") + || key.equalsIgnoreCase("application_id") || key.equalsIgnoreCase("cancel_at") || key.equalsIgnoreCase("cancel_at_period_end") || key.equalsIgnoreCase("company_id") diff --git a/src/main/java/com/schematic/api/types/CatalogCreditGrantResponseData.java b/src/main/java/com/schematic/api/types/CatalogCreditGrantResponseData.java index 19dc831..0f69929 100644 --- a/src/main/java/com/schematic/api/types/CatalogCreditGrantResponseData.java +++ b/src/main/java/com/schematic/api/types/CatalogCreditGrantResponseData.java @@ -43,6 +43,8 @@ public final class CatalogCreditGrantResponseData { private final PlanCreditGrantScaling scaling; + private final boolean visible; + private final Map additionalProperties; private CatalogCreditGrantResponseData( @@ -57,6 +59,7 @@ private CatalogCreditGrantResponseData( Optional licenseId, Optional resetCadence, PlanCreditGrantScaling scaling, + boolean visible, Map additionalProperties) { this.companyCreditAmount = companyCreditAmount; this.creditAmount = creditAmount; @@ -69,6 +72,7 @@ private CatalogCreditGrantResponseData( this.licenseId = licenseId; this.resetCadence = resetCadence; this.scaling = scaling; + this.visible = visible; this.additionalProperties = additionalProperties; } @@ -133,6 +137,14 @@ public PlanCreditGrantScaling getScaling() { return scaling; } + /** + * @return Whether the catalog shows this credit on the plan. Display-only: a hidden grant is still granted and priced at checkout. + */ + @JsonProperty("visible") + public boolean getVisible() { + return visible; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -155,7 +167,8 @@ private boolean equalTo(CatalogCreditGrantResponseData other) { && id.equals(other.id) && licenseId.equals(other.licenseId) && resetCadence.equals(other.resetCadence) - && scaling.equals(other.scaling); + && scaling.equals(other.scaling) + && visible == other.visible; } @java.lang.Override @@ -171,7 +184,8 @@ public int hashCode() { this.id, this.licenseId, this.resetCadence, - this.scaling); + this.scaling, + this.visible); } @java.lang.Override @@ -212,7 +226,14 @@ public interface IdStage { } public interface ScalingStage { - _FinalStage scaling(@NotNull PlanCreditGrantScaling scaling); + VisibleStage scaling(@NotNull PlanCreditGrantScaling scaling); + } + + public interface VisibleStage { + /** + *

Whether the catalog shows this credit on the plan. Display-only: a hidden grant is still granted and priced at checkout.

+ */ + _FinalStage visible(boolean visible); } public interface _FinalStage { @@ -251,6 +272,7 @@ public static final class Builder CreditNameStage, IdStage, ScalingStage, + VisibleStage, _FinalStage { private long companyCreditAmount; @@ -264,6 +286,8 @@ public static final class Builder private PlanCreditGrantScaling scaling; + private boolean visible; + private Optional resetCadence = Optional.empty(); private Optional licenseId = Optional.empty(); @@ -291,6 +315,7 @@ public Builder from(CatalogCreditGrantResponseData other) { licenseId(other.getLicenseId()); resetCadence(other.getResetCadence()); scaling(other.getScaling()); + visible(other.getVisible()); return this; } @@ -339,11 +364,22 @@ public ScalingStage id(@NotNull String id) { @java.lang.Override @JsonSetter("scaling") - public _FinalStage scaling(@NotNull PlanCreditGrantScaling scaling) { + public VisibleStage scaling(@NotNull PlanCreditGrantScaling scaling) { this.scaling = Objects.requireNonNull(scaling, "scaling must not be null"); return this; } + /** + *

Whether the catalog shows this credit on the plan. Display-only: a hidden grant is still granted and priced at checkout.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("visible") + public _FinalStage visible(boolean visible) { + this.visible = visible; + return this; + } + @java.lang.Override public _FinalStage resetCadence(BillingPlanCreditGrantResetCadence resetCadence) { this.resetCadence = Optional.ofNullable(resetCadence); @@ -423,6 +459,7 @@ public CatalogCreditGrantResponseData build() { licenseId, resetCadence, scaling, + visible, additionalProperties); } @@ -438,7 +475,8 @@ private void putAdditionalPropertyFromJson(String key, Object value) { || key.equalsIgnoreCase("id") || key.equalsIgnoreCase("license_id") || key.equalsIgnoreCase("reset_cadence") - || key.equalsIgnoreCase("scaling")) { + || key.equalsIgnoreCase("scaling") + || key.equalsIgnoreCase("visible")) { return; } this.additionalProperties.put(key, value); diff --git a/src/main/java/com/schematic/api/types/CheckoutSubscription.java b/src/main/java/com/schematic/api/types/CheckoutSubscription.java index a1713ef..457621f 100644 --- a/src/main/java/com/schematic/api/types/CheckoutSubscription.java +++ b/src/main/java/com/schematic/api/types/CheckoutSubscription.java @@ -23,6 +23,8 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = CheckoutSubscription.Builder.class) public final class CheckoutSubscription { + private final Optional accessRevokedAt; + private final Optional applicationId; private final Optional cancelAt; @@ -74,6 +76,7 @@ public final class CheckoutSubscription { private final Map additionalProperties; private CheckoutSubscription( + Optional accessRevokedAt, Optional applicationId, Optional cancelAt, boolean cancelAtPeriodEnd, @@ -99,6 +102,7 @@ private CheckoutSubscription( Optional trialEnd, Optional trialEndSetting, Map additionalProperties) { + this.accessRevokedAt = accessRevokedAt; this.applicationId = applicationId; this.cancelAt = cancelAt; this.cancelAtPeriodEnd = cancelAtPeriodEnd; @@ -126,6 +130,11 @@ private CheckoutSubscription( this.additionalProperties = additionalProperties; } + @JsonProperty("access_revoked_at") + public Optional getAccessRevokedAt() { + return accessRevokedAt; + } + @JsonProperty("application_id") public Optional getApplicationId() { return applicationId; @@ -258,7 +267,8 @@ public Map getAdditionalProperties() { } private boolean equalTo(CheckoutSubscription other) { - return applicationId.equals(other.applicationId) + return accessRevokedAt.equals(other.accessRevokedAt) + && applicationId.equals(other.applicationId) && cancelAt.equals(other.cancelAt) && cancelAtPeriodEnd == other.cancelAtPeriodEnd && companyId.equals(other.companyId) @@ -287,6 +297,7 @@ private boolean equalTo(CheckoutSubscription other) { @java.lang.Override public int hashCode() { return Objects.hash( + this.accessRevokedAt, this.applicationId, this.cancelAt, this.cancelAtPeriodEnd, @@ -379,6 +390,10 @@ public interface _FinalStage { _FinalStage additionalProperties(Map additionalProperties); + _FinalStage accessRevokedAt(Optional accessRevokedAt); + + _FinalStage accessRevokedAt(OffsetDateTime accessRevokedAt); + _FinalStage applicationId(Optional applicationId); _FinalStage applicationId(String applicationId); @@ -491,12 +506,15 @@ public static final class Builder private Optional applicationId = Optional.empty(); + private Optional accessRevokedAt = Optional.empty(); + private Map additionalProperties = new HashMap<>(); private Builder() {} @java.lang.Override public Builder from(CheckoutSubscription other) { + accessRevokedAt(other.getAccessRevokedAt()); applicationId(other.getApplicationId()); cancelAt(other.getCancelAt()); cancelAtPeriodEnd(other.getCancelAtPeriodEnd()); @@ -765,9 +783,23 @@ public _FinalStage applicationId(Optional applicationId) { return this; } + @java.lang.Override + public _FinalStage accessRevokedAt(OffsetDateTime accessRevokedAt) { + this.accessRevokedAt = Optional.ofNullable(accessRevokedAt); + return this; + } + + @java.lang.Override + @JsonSetter(value = "access_revoked_at", nulls = Nulls.SKIP) + public _FinalStage accessRevokedAt(Optional accessRevokedAt) { + this.accessRevokedAt = accessRevokedAt; + return this; + } + @java.lang.Override public CheckoutSubscription build() { return new CheckoutSubscription( + accessRevokedAt, applicationId, cancelAt, cancelAtPeriodEnd, @@ -797,7 +829,8 @@ public CheckoutSubscription build() { @JsonAnySetter private void putAdditionalPropertyFromJson(String key, Object value) { - if (key.equalsIgnoreCase("application_id") + if (key.equalsIgnoreCase("access_revoked_at") + || key.equalsIgnoreCase("application_id") || key.equalsIgnoreCase("cancel_at") || key.equalsIgnoreCase("cancel_at_period_end") || key.equalsIgnoreCase("company_id") diff --git a/src/main/java/com/schematic/api/types/CompanyFeatureUsageExportMetadata.java b/src/main/java/com/schematic/api/types/CompanyFeatureUsageExportMetadata.java index 599f709..99645e5 100644 --- a/src/main/java/com/schematic/api/types/CompanyFeatureUsageExportMetadata.java +++ b/src/main/java/com/schematic/api/types/CompanyFeatureUsageExportMetadata.java @@ -21,6 +21,8 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = CompanyFeatureUsageExportMetadata.Builder.class) public final class CompanyFeatureUsageExportMetadata { + private final Optional cancelAtPeriodEnd; + private final Optional> companyIds; private final Optional> creditTypeIds; @@ -70,6 +72,7 @@ public final class CompanyFeatureUsageExportMetadata { private final Map additionalProperties; private CompanyFeatureUsageExportMetadata( + Optional cancelAtPeriodEnd, Optional> companyIds, Optional> creditTypeIds, Optional> entityKeyDefinitionIds, @@ -94,6 +97,7 @@ private CompanyFeatureUsageExportMetadata( Optional withoutPlan, Optional withoutSubscription, Map additionalProperties) { + this.cancelAtPeriodEnd = cancelAtPeriodEnd; this.companyIds = companyIds; this.creditTypeIds = creditTypeIds; this.entityKeyDefinitionIds = entityKeyDefinitionIds; @@ -120,6 +124,14 @@ private CompanyFeatureUsageExportMetadata( this.additionalProperties = additionalProperties; } + /** + * @return If true, restrict the export to companies with an active subscription that is set to cancel at the end of the current period; if false, restrict it to companies without one + */ + @JsonProperty("cancel_at_period_end") + public Optional getCancelAtPeriodEnd() { + return cancelAtPeriodEnd; + } + /** * @return Restrict the export to these Schematic company IDs (starting with 'comp_') */ @@ -316,7 +328,8 @@ public Map getAdditionalProperties() { } private boolean equalTo(CompanyFeatureUsageExportMetadata other) { - return companyIds.equals(other.companyIds) + return cancelAtPeriodEnd.equals(other.cancelAtPeriodEnd) + && companyIds.equals(other.companyIds) && creditTypeIds.equals(other.creditTypeIds) && entityKeyDefinitionIds.equals(other.entityKeyDefinitionIds) && entityTraitDefinitionIds.equals(other.entityTraitDefinitionIds) @@ -344,6 +357,7 @@ private boolean equalTo(CompanyFeatureUsageExportMetadata other) { @java.lang.Override public int hashCode() { return Objects.hash( + this.cancelAtPeriodEnd, this.companyIds, this.creditTypeIds, this.entityKeyDefinitionIds, @@ -380,6 +394,8 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { + private Optional cancelAtPeriodEnd = Optional.empty(); + private Optional> companyIds = Optional.empty(); private Optional> creditTypeIds = Optional.empty(); @@ -431,6 +447,7 @@ public static final class Builder { private Builder() {} public Builder from(CompanyFeatureUsageExportMetadata other) { + cancelAtPeriodEnd(other.getCancelAtPeriodEnd()); companyIds(other.getCompanyIds()); creditTypeIds(other.getCreditTypeIds()); entityKeyDefinitionIds(other.getEntityKeyDefinitionIds()); @@ -457,6 +474,20 @@ public Builder from(CompanyFeatureUsageExportMetadata other) { return this; } + /** + *

If true, restrict the export to companies with an active subscription that is set to cancel at the end of the current period; if false, restrict it to companies without one

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

Restrict the export to these Schematic company IDs (starting with 'comp_')

*/ @@ -785,6 +816,7 @@ public Builder withoutSubscription(Boolean withoutSubscription) { public CompanyFeatureUsageExportMetadata build() { return new CompanyFeatureUsageExportMetadata( + cancelAtPeriodEnd, companyIds, creditTypeIds, entityKeyDefinitionIds, @@ -813,7 +845,8 @@ public CompanyFeatureUsageExportMetadata build() { @JsonAnySetter private void putAdditionalPropertyFromJson(String key, Object value) { - if (key.equalsIgnoreCase("company_ids") + if (key.equalsIgnoreCase("cancel_at_period_end") + || key.equalsIgnoreCase("company_ids") || key.equalsIgnoreCase("credit_type_ids") || key.equalsIgnoreCase("entity_key_definition_ids") || key.equalsIgnoreCase("entity_trait_definition_ids") diff --git a/src/main/java/com/schematic/api/types/CompanyInferenceCostResponseData.java b/src/main/java/com/schematic/api/types/CompanyInferenceCostResponseData.java new file mode 100644 index 0000000..f70e3b2 --- /dev/null +++ b/src/main/java/com/schematic/api/types/CompanyInferenceCostResponseData.java @@ -0,0 +1,424 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import java.time.OffsetDateTime; +import java.util.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 = CompanyInferenceCostResponseData.Builder.class) +public final class CompanyInferenceCostResponseData { + private final List byModel; + + private final String companyId; + + private final List costs; + + private final OffsetDateTime endTime; + + private final long eventCount; + + private final OffsetDateTime startTime; + + private final long unpricedEventCount; + + private final Map additionalProperties; + + private CompanyInferenceCostResponseData( + List byModel, + String companyId, + List costs, + OffsetDateTime endTime, + long eventCount, + OffsetDateTime startTime, + long unpricedEventCount, + Map additionalProperties) { + this.byModel = byModel; + this.companyId = companyId; + this.costs = costs; + this.endTime = endTime; + this.eventCount = eventCount; + this.startTime = startTime; + this.unpricedEventCount = unpricedEventCount; + this.additionalProperties = additionalProperties; + } + + /** + * @return Cost and event counts per provider and response model, busiest model first + */ + @JsonProperty("by_model") + public List getByModel() { + return byModel; + } + + /** + * @return The company the cost belongs to + */ + @JsonProperty("company_id") + public String getCompanyId() { + return companyId; + } + + /** + * @return Summed cost of priced inference events, one entry per currency. Amounts in different currencies are not converted or combined. Empty when no event in the window was priced + */ + @JsonProperty("costs") + public List getCosts() { + return costs; + } + + /** + * @return End of the window (exclusive) + */ + @JsonProperty("end_time") + public OffsetDateTime getEndTime() { + return endTime; + } + + /** + * @return Number of inference events the company sent in the window, priced or not + */ + @JsonProperty("event_count") + public long getEventCount() { + return eventCount; + } + + /** + * @return Start of the window (inclusive) + */ + @JsonProperty("start_time") + public OffsetDateTime getStartTime() { + return startTime; + } + + /** + * @return Number of inference events in the window with no known cost: the event carried none and none could be derived from a price for its model. These add nothing to costs, so a non-zero count means the real cost is higher than reported + */ + @JsonProperty("unpriced_event_count") + public long getUnpricedEventCount() { + return unpricedEventCount; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CompanyInferenceCostResponseData && equalTo((CompanyInferenceCostResponseData) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CompanyInferenceCostResponseData other) { + return byModel.equals(other.byModel) + && companyId.equals(other.companyId) + && costs.equals(other.costs) + && endTime.equals(other.endTime) + && eventCount == other.eventCount + && startTime.equals(other.startTime) + && unpricedEventCount == other.unpricedEventCount; + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.byModel, + this.companyId, + this.costs, + this.endTime, + this.eventCount, + this.startTime, + this.unpricedEventCount); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static CompanyIdStage builder() { + return new Builder(); + } + + public interface CompanyIdStage { + /** + *

The company the cost belongs to

+ */ + EndTimeStage companyId(@NotNull String companyId); + + Builder from(CompanyInferenceCostResponseData other); + } + + public interface EndTimeStage { + /** + *

End of the window (exclusive)

+ */ + EventCountStage endTime(@NotNull OffsetDateTime endTime); + } + + public interface EventCountStage { + /** + *

Number of inference events the company sent in the window, priced or not

+ */ + StartTimeStage eventCount(long eventCount); + } + + public interface StartTimeStage { + /** + *

Start of the window (inclusive)

+ */ + UnpricedEventCountStage startTime(@NotNull OffsetDateTime startTime); + } + + public interface UnpricedEventCountStage { + /** + *

Number of inference events in the window with no known cost: the event carried none and none could be derived from a price for its model. These add nothing to costs, so a non-zero count means the real cost is higher than reported

+ */ + _FinalStage unpricedEventCount(long unpricedEventCount); + } + + public interface _FinalStage { + CompanyInferenceCostResponseData build(); + + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); + + /** + *

Cost and event counts per provider and response model, busiest model first

+ */ + _FinalStage byModel(List byModel); + + _FinalStage addByModel(InferenceModelCostResponseData byModel); + + _FinalStage addAllByModel(List byModel); + + /** + *

Summed cost of priced inference events, one entry per currency. Amounts in different currencies are not converted or combined. Empty when no event in the window was priced

+ */ + _FinalStage costs(List costs); + + _FinalStage addCosts(InferenceCostAmountResponseData costs); + + _FinalStage addAllCosts(List costs); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder + implements CompanyIdStage, + EndTimeStage, + EventCountStage, + StartTimeStage, + UnpricedEventCountStage, + _FinalStage { + private String companyId; + + private OffsetDateTime endTime; + + private long eventCount; + + private OffsetDateTime startTime; + + private long unpricedEventCount; + + private List costs = new ArrayList<>(); + + private List byModel = new ArrayList<>(); + + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(CompanyInferenceCostResponseData other) { + byModel(other.getByModel()); + companyId(other.getCompanyId()); + costs(other.getCosts()); + endTime(other.getEndTime()); + eventCount(other.getEventCount()); + startTime(other.getStartTime()); + unpricedEventCount(other.getUnpricedEventCount()); + return this; + } + + /** + *

The company the cost belongs to

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("company_id") + public EndTimeStage companyId(@NotNull String companyId) { + this.companyId = Objects.requireNonNull(companyId, "companyId must not be null"); + return this; + } + + /** + *

End of the window (exclusive)

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("end_time") + public EventCountStage endTime(@NotNull OffsetDateTime endTime) { + this.endTime = Objects.requireNonNull(endTime, "endTime must not be null"); + return this; + } + + /** + *

Number of inference events the company sent in the window, priced or not

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("event_count") + public StartTimeStage eventCount(long eventCount) { + this.eventCount = eventCount; + return this; + } + + /** + *

Start of the window (inclusive)

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("start_time") + public UnpricedEventCountStage startTime(@NotNull OffsetDateTime startTime) { + this.startTime = Objects.requireNonNull(startTime, "startTime must not be null"); + return this; + } + + /** + *

Number of inference events in the window with no known cost: the event carried none and none could be derived from a price for its model. These add nothing to costs, so a non-zero count means the real cost is higher than reported

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

Summed cost of priced inference events, one entry per currency. Amounts in different currencies are not converted or combined. Empty when no event in the window was priced

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

Summed cost of priced inference events, one entry per currency. Amounts in different currencies are not converted or combined. Empty when no event in the window was priced

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage addCosts(InferenceCostAmountResponseData costs) { + this.costs.add(costs); + return this; + } + + /** + *

Summed cost of priced inference events, one entry per currency. Amounts in different currencies are not converted or combined. Empty when no event in the window was priced

+ */ + @java.lang.Override + @JsonSetter(value = "costs", nulls = Nulls.SKIP) + public _FinalStage costs(List costs) { + this.costs.clear(); + if (costs != null) { + this.costs.addAll(costs); + } + return this; + } + + /** + *

Cost and event counts per provider and response model, busiest model first

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

Cost and event counts per provider and response model, busiest model first

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage addByModel(InferenceModelCostResponseData byModel) { + this.byModel.add(byModel); + return this; + } + + /** + *

Cost and event counts per provider and response model, busiest model first

+ */ + @java.lang.Override + @JsonSetter(value = "by_model", nulls = Nulls.SKIP) + public _FinalStage byModel(List byModel) { + this.byModel.clear(); + if (byModel != null) { + this.byModel.addAll(byModel); + } + return this; + } + + @java.lang.Override + public CompanyInferenceCostResponseData build() { + return new CompanyInferenceCostResponseData( + byModel, + companyId, + costs, + endTime, + eventCount, + startTime, + unpricedEventCount, + additionalProperties); + } + + @JsonAnySetter + private void putAdditionalPropertyFromJson(String key, Object value) { + if (key.equalsIgnoreCase("by_model") + || key.equalsIgnoreCase("company_id") + || key.equalsIgnoreCase("costs") + || key.equalsIgnoreCase("end_time") + || key.equalsIgnoreCase("event_count") + || key.equalsIgnoreCase("start_time") + || key.equalsIgnoreCase("unpriced_event_count")) { + return; + } + this.additionalProperties.put(key, value); + } + + @java.lang.Override + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + @java.lang.Override + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + } +} diff --git a/src/main/java/com/schematic/api/types/CreditEventLedgerResponseData.java b/src/main/java/com/schematic/api/types/CreditEventLedgerResponseData.java index 8d6887f..0386b2a 100644 --- a/src/main/java/com/schematic/api/types/CreditEventLedgerResponseData.java +++ b/src/main/java/com/schematic/api/types/CreditEventLedgerResponseData.java @@ -88,6 +88,10 @@ public final class CreditEventLedgerResponseData { private final long sourceId; + private final Optional sourceIdString; + + private final Optional sourceType; + private final Optional toGrantId; private final Optional transferReason; @@ -135,6 +139,8 @@ private CreditEventLedgerResponseData( Optional quantityConsumed, Optional quantityRemainingAtZeroOut, long sourceId, + Optional sourceIdString, + Optional sourceType, Optional toGrantId, Optional transferReason, Optional usageEventId, @@ -174,6 +180,8 @@ private CreditEventLedgerResponseData( this.quantityConsumed = quantityConsumed; this.quantityRemainingAtZeroOut = quantityRemainingAtZeroOut; this.sourceId = sourceId; + this.sourceIdString = sourceIdString; + this.sourceType = sourceType; this.toGrantId = toGrantId; this.transferReason = transferReason; this.usageEventId = usageEventId; @@ -341,11 +349,24 @@ public Optional getQuantityRemainingAtZeroOut() { return quantityRemainingAtZeroOut; } + /** + * @return Always 0. Use source_id_string. + */ @JsonProperty("source_id") public long getSourceId() { return sourceId; } + @JsonProperty("source_id_string") + public Optional getSourceIdString() { + return sourceIdString; + } + + @JsonProperty("source_type") + public Optional getSourceType() { + return sourceType; + } + @JsonProperty("to_grant_id") public Optional getToGrantId() { return toGrantId; @@ -420,6 +441,8 @@ private boolean equalTo(CreditEventLedgerResponseData other) { && quantityConsumed.equals(other.quantityConsumed) && quantityRemainingAtZeroOut.equals(other.quantityRemainingAtZeroOut) && sourceId == other.sourceId + && sourceIdString.equals(other.sourceIdString) + && sourceType.equals(other.sourceType) && toGrantId.equals(other.toGrantId) && transferReason.equals(other.transferReason) && usageEventId.equals(other.usageEventId) @@ -463,6 +486,8 @@ public int hashCode() { this.quantityConsumed, this.quantityRemainingAtZeroOut, this.sourceId, + this.sourceIdString, + this.sourceType, this.toGrantId, this.transferReason, this.usageEventId, @@ -515,6 +540,9 @@ public interface KindStage { } public interface SourceIdStage { + /** + *

Always 0. Use source_id_string.

+ */ _FinalStage sourceId(long sourceId); } @@ -622,6 +650,14 @@ public interface _FinalStage { _FinalStage quantityRemainingAtZeroOut(Double quantityRemainingAtZeroOut); + _FinalStage sourceIdString(Optional sourceIdString); + + _FinalStage sourceIdString(String sourceIdString); + + _FinalStage sourceType(Optional sourceType); + + _FinalStage sourceType(CreditLedgerSourceType sourceType); + _FinalStage toGrantId(Optional toGrantId); _FinalStage toGrantId(String toGrantId); @@ -689,6 +725,10 @@ public static final class Builder private Optional toGrantId = Optional.empty(); + private Optional sourceType = Optional.empty(); + + private Optional sourceIdString = Optional.empty(); + private Optional quantityRemainingAtZeroOut = Optional.empty(); private Optional quantityConsumed = Optional.empty(); @@ -773,6 +813,8 @@ public Builder from(CreditEventLedgerResponseData other) { quantityConsumed(other.getQuantityConsumed()); quantityRemainingAtZeroOut(other.getQuantityRemainingAtZeroOut()); sourceId(other.getSourceId()); + sourceIdString(other.getSourceIdString()); + sourceType(other.getSourceType()); toGrantId(other.getToGrantId()); transferReason(other.getTransferReason()); usageEventId(other.getUsageEventId()); @@ -838,6 +880,10 @@ public SourceIdStage kind(@NotNull CreditLedgerEntryKind kind) { return this; } + /** + *

Always 0. Use source_id_string.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ @java.lang.Override @JsonSetter("source_id") public _FinalStage sourceId(long sourceId) { @@ -923,6 +969,32 @@ public _FinalStage toGrantId(Optional toGrantId) { return this; } + @java.lang.Override + public _FinalStage sourceType(CreditLedgerSourceType sourceType) { + this.sourceType = Optional.ofNullable(sourceType); + return this; + } + + @java.lang.Override + @JsonSetter(value = "source_type", nulls = Nulls.SKIP) + public _FinalStage sourceType(Optional sourceType) { + this.sourceType = sourceType; + return this; + } + + @java.lang.Override + public _FinalStage sourceIdString(String sourceIdString) { + this.sourceIdString = Optional.ofNullable(sourceIdString); + return this; + } + + @java.lang.Override + @JsonSetter(value = "source_id_string", nulls = Nulls.SKIP) + public _FinalStage sourceIdString(Optional sourceIdString) { + this.sourceIdString = sourceIdString; + return this; + } + @java.lang.Override public _FinalStage quantityRemainingAtZeroOut(Double quantityRemainingAtZeroOut) { this.quantityRemainingAtZeroOut = Optional.ofNullable(quantityRemainingAtZeroOut); @@ -1275,6 +1347,8 @@ public CreditEventLedgerResponseData build() { quantityConsumed, quantityRemainingAtZeroOut, sourceId, + sourceIdString, + sourceType, toGrantId, transferReason, usageEventId, @@ -1318,6 +1392,8 @@ private void putAdditionalPropertyFromJson(String key, Object value) { || key.equalsIgnoreCase("quantity_consumed") || key.equalsIgnoreCase("quantity_remaining_at_zero_out") || key.equalsIgnoreCase("source_id") + || key.equalsIgnoreCase("source_id_string") + || key.equalsIgnoreCase("source_type") || key.equalsIgnoreCase("to_grant_id") || key.equalsIgnoreCase("transfer_reason") || key.equalsIgnoreCase("usage_event_id") diff --git a/src/main/java/com/schematic/api/types/CreditLedgerSourceType.java b/src/main/java/com/schematic/api/types/CreditLedgerSourceType.java new file mode 100644 index 0000000..f45d8a3 --- /dev/null +++ b/src/main/java/com/schematic/api/types/CreditLedgerSourceType.java @@ -0,0 +1,108 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +public final class CreditLedgerSourceType { + public static final CreditLedgerSourceType BILLING_CHARGE = + new CreditLedgerSourceType(Value.BILLING_CHARGE, "billing_charge"); + + public static final CreditLedgerSourceType BILLING_CREDIT_TRANSFER = + new CreditLedgerSourceType(Value.BILLING_CREDIT_TRANSFER, "billing_credit_transfer"); + + public static final CreditLedgerSourceType BILLING_CREDIT_GRANT = + new CreditLedgerSourceType(Value.BILLING_CREDIT_GRANT, "billing_credit_grant"); + + public static final CreditLedgerSourceType BILLING_SETTLEMENT = + new CreditLedgerSourceType(Value.BILLING_SETTLEMENT, "billing_settlement"); + + private final Value value; + + private final String string; + + CreditLedgerSourceType(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof CreditLedgerSourceType + && this.string.equals(((CreditLedgerSourceType) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case BILLING_CHARGE: + return visitor.visitBillingCharge(); + case BILLING_CREDIT_TRANSFER: + return visitor.visitBillingCreditTransfer(); + case BILLING_CREDIT_GRANT: + return visitor.visitBillingCreditGrant(); + case BILLING_SETTLEMENT: + return visitor.visitBillingSettlement(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static CreditLedgerSourceType valueOf(String value) { + switch (value) { + case "billing_charge": + return BILLING_CHARGE; + case "billing_credit_transfer": + return BILLING_CREDIT_TRANSFER; + case "billing_credit_grant": + return BILLING_CREDIT_GRANT; + case "billing_settlement": + return BILLING_SETTLEMENT; + default: + return new CreditLedgerSourceType(Value.UNKNOWN, value); + } + } + + public enum Value { + BILLING_CHARGE, + + BILLING_CREDIT_GRANT, + + BILLING_CREDIT_TRANSFER, + + BILLING_SETTLEMENT, + + UNKNOWN + } + + public interface Visitor { + T visitBillingCharge(); + + T visitBillingCreditGrant(); + + T visitBillingCreditTransfer(); + + T visitBillingSettlement(); + + T visitUnknown(String unknownType); + } +} diff --git a/src/main/java/com/schematic/api/types/DataExportMetadata.java b/src/main/java/com/schematic/api/types/DataExportMetadata.java index b573b31..bb01117 100644 --- a/src/main/java/com/schematic/api/types/DataExportMetadata.java +++ b/src/main/java/com/schematic/api/types/DataExportMetadata.java @@ -82,18 +82,18 @@ public Optional _getUnknown() { return Optional.empty(); } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof DataExportMetadata && value.equals(((DataExportMetadata) other).value); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash(value); } - @Override + @java.lang.Override public String toString() { return value.toString(); } diff --git a/src/main/java/com/schematic/api/types/EventDetailResponseData.java b/src/main/java/com/schematic/api/types/EventDetailResponseData.java index e6540c3..70c4380 100644 --- a/src/main/java/com/schematic/api/types/EventDetailResponseData.java +++ b/src/main/java/com/schematic/api/types/EventDetailResponseData.java @@ -40,6 +40,12 @@ public final class EventDetailResponseData { private final Optional companyId; + private final Optional cost; + + private final Optional costSource; + + private final Optional currency; + private final Optional enrichedAt; private final Optional environmentId; @@ -88,6 +94,9 @@ private EventDetailResponseData( OffsetDateTime capturedAt, Optional company, Optional companyId, + Optional cost, + Optional costSource, + Optional currency, Optional enrichedAt, Optional environmentId, Optional errorMessage, @@ -115,6 +124,9 @@ private EventDetailResponseData( this.capturedAt = capturedAt; this.company = company; this.companyId = companyId; + this.cost = cost; + this.costSource = costSource; + this.currency = currency; this.enrichedAt = enrichedAt; this.environmentId = environmentId; this.errorMessage = errorMessage; @@ -172,6 +184,30 @@ public Optional getCompanyId() { return companyId; } + /** + * @return What the inference call cost, as a decimal amount in currency (dollars, not cents, for usd). Absent when the call has no price, for other event types, and when listing events. + */ + @JsonProperty("cost") + public Optional getCost() { + return cost; + } + + /** + * @return Where the inference call's cost came from: provided when the request reported it, list_price when Schematic priced it from the model's list price, unpriced when neither applied. Absent for other event types and when listing events. + */ + @JsonProperty("cost_source") + public Optional getCostSource() { + return costSource; + } + + /** + * @return Lowercase ISO currency code for cost. Absent for other event types and when listing events. + */ + @JsonProperty("currency") + public Optional getCurrency() { + return currency; + } + @JsonProperty("enriched_at") public Optional getEnrichedAt() { return enrichedAt; @@ -286,6 +322,9 @@ private boolean equalTo(EventDetailResponseData other) { && capturedAt.equals(other.capturedAt) && company.equals(other.company) && companyId.equals(other.companyId) + && cost.equals(other.cost) + && costSource.equals(other.costSource) + && currency.equals(other.currency) && enrichedAt.equals(other.enrichedAt) && environmentId.equals(other.environmentId) && errorMessage.equals(other.errorMessage) @@ -317,6 +356,9 @@ public int hashCode() { this.capturedAt, this.company, this.companyId, + this.cost, + this.costSource, + this.currency, this.enrichedAt, this.environmentId, this.errorMessage, @@ -402,6 +444,27 @@ public interface _FinalStage { _FinalStage companyId(String companyId); + /** + *

What the inference call cost, as a decimal amount in currency (dollars, not cents, for usd). Absent when the call has no price, for other event types, and when listing events.

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

Where the inference call's cost came from: provided when the request reported it, list_price when Schematic priced it from the model's list price, unpriced when neither applied. Absent for other event types and when listing events.

+ */ + _FinalStage costSource(Optional costSource); + + _FinalStage costSource(InferenceCostSource costSource); + + /** + *

Lowercase ISO currency code for cost. Absent for other event types and when listing events.

+ */ + _FinalStage currency(Optional currency); + + _FinalStage currency(String currency); + _FinalStage enrichedAt(Optional enrichedAt); _FinalStage enrichedAt(OffsetDateTime enrichedAt); @@ -512,6 +575,12 @@ public static final class Builder private Optional enrichedAt = Optional.empty(); + private Optional currency = Optional.empty(); + + private Optional costSource = Optional.empty(); + + private Optional cost = Optional.empty(); + private Optional companyId = Optional.empty(); private Optional company = Optional.empty(); @@ -535,6 +604,9 @@ public Builder from(EventDetailResponseData other) { capturedAt(other.getCapturedAt()); company(other.getCompany()); companyId(other.getCompanyId()); + cost(other.getCost()); + costSource(other.getCostSource()); + currency(other.getCurrency()); enrichedAt(other.getEnrichedAt()); environmentId(other.getEnvironmentId()); errorMessage(other.getErrorMessage()); @@ -816,6 +888,66 @@ public _FinalStage enrichedAt(Optional enrichedAt) { return this; } + /** + *

Lowercase ISO currency code for cost. Absent for other event types and when listing events.

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

Lowercase ISO currency code for cost. Absent for other event types and when listing events.

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

Where the inference call's cost came from: provided when the request reported it, list_price when Schematic priced it from the model's list price, unpriced when neither applied. Absent for other event types and when listing events.

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

Where the inference call's cost came from: provided when the request reported it, list_price when Schematic priced it from the model's list price, unpriced when neither applied. Absent for other event types and when listing events.

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

What the inference call cost, as a decimal amount in currency (dollars, not cents, for usd). Absent when the call has no price, for other event types, and when listing events.

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

What the inference call cost, as a decimal amount in currency (dollars, not cents, for usd). Absent when the call has no price, for other event types, and when listing events.

+ */ + @java.lang.Override + @JsonSetter(value = "cost", nulls = Nulls.SKIP) + public _FinalStage cost(Optional cost) { + this.cost = cost; + return this; + } + @java.lang.Override public _FinalStage companyId(String companyId) { this.companyId = Optional.ofNullable(companyId); @@ -902,6 +1034,9 @@ public EventDetailResponseData build() { capturedAt, company, companyId, + cost, + costSource, + currency, enrichedAt, environmentId, errorMessage, @@ -933,6 +1068,9 @@ private void putAdditionalPropertyFromJson(String key, Object value) { || key.equalsIgnoreCase("captured_at") || key.equalsIgnoreCase("company") || key.equalsIgnoreCase("company_id") + || key.equalsIgnoreCase("cost") + || key.equalsIgnoreCase("cost_source") + || key.equalsIgnoreCase("currency") || key.equalsIgnoreCase("enriched_at") || key.equalsIgnoreCase("environment_id") || key.equalsIgnoreCase("error_message") diff --git a/src/main/java/com/schematic/api/types/InferenceCostAmountResponseData.java b/src/main/java/com/schematic/api/types/InferenceCostAmountResponseData.java new file mode 100644 index 0000000..d74a0a8 --- /dev/null +++ b/src/main/java/com/schematic/api/types/InferenceCostAmountResponseData.java @@ -0,0 +1,202 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = InferenceCostAmountResponseData.Builder.class) +public final class InferenceCostAmountResponseData { + private final String cost; + + private final String currency; + + private final long eventCount; + + private final Map additionalProperties; + + private InferenceCostAmountResponseData( + String cost, String currency, long eventCount, Map additionalProperties) { + this.cost = cost; + this.currency = currency; + this.eventCount = eventCount; + this.additionalProperties = additionalProperties; + } + + /** + * @return Summed cost as a decimal string in the currency's major unit (dollars, not cents), with up to 8 decimal places + */ + @JsonProperty("cost") + public String getCost() { + return cost; + } + + /** + * @return Lowercase ISO 4217 currency code of the cost + */ + @JsonProperty("currency") + public String getCurrency() { + return currency; + } + + /** + * @return Number of priced events summed into this cost + */ + @JsonProperty("event_count") + public long getEventCount() { + return eventCount; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof InferenceCostAmountResponseData && equalTo((InferenceCostAmountResponseData) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(InferenceCostAmountResponseData other) { + return cost.equals(other.cost) && currency.equals(other.currency) && eventCount == other.eventCount; + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.cost, this.currency, this.eventCount); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static CostStage builder() { + return new Builder(); + } + + public interface CostStage { + /** + *

Summed cost as a decimal string in the currency's major unit (dollars, not cents), with up to 8 decimal places

+ */ + CurrencyStage cost(@NotNull String cost); + + Builder from(InferenceCostAmountResponseData other); + } + + public interface CurrencyStage { + /** + *

Lowercase ISO 4217 currency code of the cost

+ */ + EventCountStage currency(@NotNull String currency); + } + + public interface EventCountStage { + /** + *

Number of priced events summed into this cost

+ */ + _FinalStage eventCount(long eventCount); + } + + public interface _FinalStage { + InferenceCostAmountResponseData build(); + + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements CostStage, CurrencyStage, EventCountStage, _FinalStage { + private String cost; + + private String currency; + + private long eventCount; + + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(InferenceCostAmountResponseData other) { + cost(other.getCost()); + currency(other.getCurrency()); + eventCount(other.getEventCount()); + return this; + } + + /** + *

Summed cost as a decimal string in the currency's major unit (dollars, not cents), with up to 8 decimal places

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("cost") + public CurrencyStage cost(@NotNull String cost) { + this.cost = Objects.requireNonNull(cost, "cost must not be null"); + return this; + } + + /** + *

Lowercase ISO 4217 currency code of the cost

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("currency") + public EventCountStage currency(@NotNull String currency) { + this.currency = Objects.requireNonNull(currency, "currency must not be null"); + return this; + } + + /** + *

Number of priced events summed into this cost

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("event_count") + public _FinalStage eventCount(long eventCount) { + this.eventCount = eventCount; + return this; + } + + @java.lang.Override + public InferenceCostAmountResponseData build() { + return new InferenceCostAmountResponseData(cost, currency, eventCount, additionalProperties); + } + + @JsonAnySetter + private void putAdditionalPropertyFromJson(String key, Object value) { + if (key.equalsIgnoreCase("cost") + || key.equalsIgnoreCase("currency") + || key.equalsIgnoreCase("event_count")) { + return; + } + this.additionalProperties.put(key, value); + } + + @java.lang.Override + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + @java.lang.Override + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + } +} diff --git a/src/main/java/com/schematic/api/types/InferenceCostSource.java b/src/main/java/com/schematic/api/types/InferenceCostSource.java new file mode 100644 index 0000000..3029bf4 --- /dev/null +++ b/src/main/java/com/schematic/api/types/InferenceCostSource.java @@ -0,0 +1,93 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +public final class InferenceCostSource { + public static final InferenceCostSource UNPRICED = new InferenceCostSource(Value.UNPRICED, "unpriced"); + + public static final InferenceCostSource PROVIDED = new InferenceCostSource(Value.PROVIDED, "provided"); + + public static final InferenceCostSource LIST_PRICE = new InferenceCostSource(Value.LIST_PRICE, "list_price"); + + private final Value value; + + private final String string; + + InferenceCostSource(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof InferenceCostSource && this.string.equals(((InferenceCostSource) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case UNPRICED: + return visitor.visitUnpriced(); + case PROVIDED: + return visitor.visitProvided(); + case LIST_PRICE: + return visitor.visitListPrice(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static InferenceCostSource valueOf(String value) { + switch (value) { + case "unpriced": + return UNPRICED; + case "provided": + return PROVIDED; + case "list_price": + return LIST_PRICE; + default: + return new InferenceCostSource(Value.UNKNOWN, value); + } + } + + public enum Value { + LIST_PRICE, + + PROVIDED, + + UNPRICED, + + UNKNOWN + } + + public interface Visitor { + T visitListPrice(); + + T visitProvided(); + + T visitUnpriced(); + + T visitUnknown(String unknownType); + } +} diff --git a/src/main/java/com/schematic/api/types/InferenceModelCostResponseData.java b/src/main/java/com/schematic/api/types/InferenceModelCostResponseData.java new file mode 100644 index 0000000..55d5748 --- /dev/null +++ b/src/main/java/com/schematic/api/types/InferenceModelCostResponseData.java @@ -0,0 +1,308 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = InferenceModelCostResponseData.Builder.class) +public final class InferenceModelCostResponseData { + private final List costs; + + private final long eventCount; + + private final String provider; + + private final String responseModel; + + private final long unpricedEventCount; + + private final Map additionalProperties; + + private InferenceModelCostResponseData( + List costs, + long eventCount, + String provider, + String responseModel, + long unpricedEventCount, + Map additionalProperties) { + this.costs = costs; + this.eventCount = eventCount; + this.provider = provider; + this.responseModel = responseModel; + this.unpricedEventCount = unpricedEventCount; + this.additionalProperties = additionalProperties; + } + + /** + * @return Summed cost of this model's priced events, one entry per currency + */ + @JsonProperty("costs") + public List getCosts() { + return costs; + } + + /** + * @return Number of inference events for this model, priced or not + */ + @JsonProperty("event_count") + public long getEventCount() { + return eventCount; + } + + /** + * @return The model provider the events reported, such as openai or anthropic + */ + @JsonProperty("provider") + public String getProvider() { + return provider; + } + + /** + * @return The model the provider reported answering the call + */ + @JsonProperty("response_model") + public String getResponseModel() { + return responseModel; + } + + /** + * @return Number of this model's events with no known cost + */ + @JsonProperty("unpriced_event_count") + public long getUnpricedEventCount() { + return unpricedEventCount; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof InferenceModelCostResponseData && equalTo((InferenceModelCostResponseData) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(InferenceModelCostResponseData other) { + return costs.equals(other.costs) + && eventCount == other.eventCount + && provider.equals(other.provider) + && responseModel.equals(other.responseModel) + && unpricedEventCount == other.unpricedEventCount; + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.costs, this.eventCount, this.provider, this.responseModel, this.unpricedEventCount); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static EventCountStage builder() { + return new Builder(); + } + + public interface EventCountStage { + /** + *

Number of inference events for this model, priced or not

+ */ + ProviderStage eventCount(long eventCount); + + Builder from(InferenceModelCostResponseData other); + } + + public interface ProviderStage { + /** + *

The model provider the events reported, such as openai or anthropic

+ */ + ResponseModelStage provider(@NotNull String provider); + } + + public interface ResponseModelStage { + /** + *

The model the provider reported answering the call

+ */ + UnpricedEventCountStage responseModel(@NotNull String responseModel); + } + + public interface UnpricedEventCountStage { + /** + *

Number of this model's events with no known cost

+ */ + _FinalStage unpricedEventCount(long unpricedEventCount); + } + + public interface _FinalStage { + InferenceModelCostResponseData build(); + + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); + + /** + *

Summed cost of this model's priced events, one entry per currency

+ */ + _FinalStage costs(List costs); + + _FinalStage addCosts(InferenceCostAmountResponseData costs); + + _FinalStage addAllCosts(List costs); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder + implements EventCountStage, ProviderStage, ResponseModelStage, UnpricedEventCountStage, _FinalStage { + private long eventCount; + + private String provider; + + private String responseModel; + + private long unpricedEventCount; + + private List costs = new ArrayList<>(); + + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(InferenceModelCostResponseData other) { + costs(other.getCosts()); + eventCount(other.getEventCount()); + provider(other.getProvider()); + responseModel(other.getResponseModel()); + unpricedEventCount(other.getUnpricedEventCount()); + return this; + } + + /** + *

Number of inference events for this model, priced or not

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("event_count") + public ProviderStage eventCount(long eventCount) { + this.eventCount = eventCount; + return this; + } + + /** + *

The model provider the events reported, such as openai or anthropic

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("provider") + public ResponseModelStage provider(@NotNull String provider) { + this.provider = Objects.requireNonNull(provider, "provider must not be null"); + return this; + } + + /** + *

The model the provider reported answering the call

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("response_model") + public UnpricedEventCountStage responseModel(@NotNull String responseModel) { + this.responseModel = Objects.requireNonNull(responseModel, "responseModel must not be null"); + return this; + } + + /** + *

Number of this model's events with no known cost

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

Summed cost of this model's priced events, one entry per currency

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

Summed cost of this model's priced events, one entry per currency

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage addCosts(InferenceCostAmountResponseData costs) { + this.costs.add(costs); + return this; + } + + /** + *

Summed cost of this model's priced events, one entry per currency

+ */ + @java.lang.Override + @JsonSetter(value = "costs", nulls = Nulls.SKIP) + public _FinalStage costs(List costs) { + this.costs.clear(); + if (costs != null) { + this.costs.addAll(costs); + } + return this; + } + + @java.lang.Override + public InferenceModelCostResponseData build() { + return new InferenceModelCostResponseData( + costs, eventCount, provider, responseModel, unpricedEventCount, additionalProperties); + } + + @JsonAnySetter + private void putAdditionalPropertyFromJson(String key, Object value) { + if (key.equalsIgnoreCase("costs") + || key.equalsIgnoreCase("event_count") + || key.equalsIgnoreCase("provider") + || key.equalsIgnoreCase("response_model") + || key.equalsIgnoreCase("unpriced_event_count")) { + return; + } + this.additionalProperties.put(key, value); + } + + @java.lang.Override + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + @java.lang.Override + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + } +} diff --git a/src/main/java/com/schematic/api/types/IntegrationConfig.java b/src/main/java/com/schematic/api/types/IntegrationConfig.java index 3d1455d..e184e62 100644 --- a/src/main/java/com/schematic/api/types/IntegrationConfig.java +++ b/src/main/java/com/schematic/api/types/IntegrationConfig.java @@ -112,18 +112,18 @@ public Optional _getUnknown() { return Optional.empty(); } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof IntegrationConfig && value.equals(((IntegrationConfig) other).value); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash(value); } - @Override + @java.lang.Override public String toString() { return value.toString(); } diff --git a/src/main/java/com/schematic/api/types/PlanChangeAction.java b/src/main/java/com/schematic/api/types/PlanChangeAction.java index ce1cdb1..2df4502 100644 --- a/src/main/java/com/schematic/api/types/PlanChangeAction.java +++ b/src/main/java/com/schematic/api/types/PlanChangeAction.java @@ -7,6 +7,15 @@ import com.fasterxml.jackson.annotation.JsonValue; public final class PlanChangeAction { + public static final PlanChangeAction QUICKSTART = new PlanChangeAction(Value.QUICKSTART, "quickstart"); + + public static final PlanChangeAction COMPANY_UPSERT = new PlanChangeAction(Value.COMPANY_UPSERT, "company_upsert"); + + public static final PlanChangeAction PLAN_BILLING_PRODUCT_CHANGED = + new PlanChangeAction(Value.PLAN_BILLING_PRODUCT_CHANGED, "plan_billing_product_changed"); + + public static final PlanChangeAction AMENDMENT = new PlanChangeAction(Value.AMENDMENT, "amendment"); + public static final PlanChangeAction CHECKOUT = new PlanChangeAction(Value.CHECKOUT, "checkout"); public static final PlanChangeAction MIGRATION = new PlanChangeAction(Value.MIGRATION, "migration"); @@ -14,21 +23,20 @@ public final class PlanChangeAction { public static final PlanChangeAction PLAN_VERSION_MIGRATION = new PlanChangeAction(Value.PLAN_VERSION_MIGRATION, "plan_version_migration"); + public static final PlanChangeAction ACCESS_REINSTATED = + new PlanChangeAction(Value.ACCESS_REINSTATED, "access_reinstated"); + public static final PlanChangeAction SUBSCRIPTION_CHANGE = new PlanChangeAction(Value.SUBSCRIPTION_CHANGE, "subscription_change"); public static final PlanChangeAction PLAN_DELETED = new PlanChangeAction(Value.PLAN_DELETED, "plan_deleted"); - public static final PlanChangeAction QUICKSTART = new PlanChangeAction(Value.QUICKSTART, "quickstart"); - - public static final PlanChangeAction COMPANY_UPSERT = new PlanChangeAction(Value.COMPANY_UPSERT, "company_upsert"); - - public static final PlanChangeAction PLAN_BILLING_PRODUCT_CHANGED = - new PlanChangeAction(Value.PLAN_BILLING_PRODUCT_CHANGED, "plan_billing_product_changed"); - public static final PlanChangeAction FALLBACK_PLAN = new PlanChangeAction(Value.FALLBACK_PLAN, "fallback_plan"); - public static final PlanChangeAction AMENDMENT = new PlanChangeAction(Value.AMENDMENT, "amendment"); + public static final PlanChangeAction INVOICE_PAST_DUE = + new PlanChangeAction(Value.INVOICE_PAST_DUE, "invoice_past_due"); + + public static final PlanChangeAction ACCESS_REVOKED = new PlanChangeAction(Value.ACCESS_REVOKED, "access_revoked"); public static final PlanChangeAction PLAN_TRAIT_CHANGE = new PlanChangeAction(Value.PLAN_TRAIT_CHANGE, "plan_trait_change"); @@ -67,26 +75,32 @@ public int hashCode() { public T visit(Visitor visitor) { switch (value) { + case QUICKSTART: + return visitor.visitQuickstart(); + case COMPANY_UPSERT: + return visitor.visitCompanyUpsert(); + case PLAN_BILLING_PRODUCT_CHANGED: + return visitor.visitPlanBillingProductChanged(); + case AMENDMENT: + return visitor.visitAmendment(); case CHECKOUT: return visitor.visitCheckout(); case MIGRATION: return visitor.visitMigration(); case PLAN_VERSION_MIGRATION: return visitor.visitPlanVersionMigration(); + case ACCESS_REINSTATED: + return visitor.visitAccessReinstated(); case SUBSCRIPTION_CHANGE: return visitor.visitSubscriptionChange(); case PLAN_DELETED: return visitor.visitPlanDeleted(); - case QUICKSTART: - return visitor.visitQuickstart(); - case COMPANY_UPSERT: - return visitor.visitCompanyUpsert(); - case PLAN_BILLING_PRODUCT_CHANGED: - return visitor.visitPlanBillingProductChanged(); case FALLBACK_PLAN: return visitor.visitFallbackPlan(); - case AMENDMENT: - return visitor.visitAmendment(); + case INVOICE_PAST_DUE: + return visitor.visitInvoicePastDue(); + case ACCESS_REVOKED: + return visitor.visitAccessRevoked(); case PLAN_TRAIT_CHANGE: return visitor.visitPlanTraitChange(); case MANAGE_PLAN: @@ -100,26 +114,32 @@ public T visit(Visitor visitor) { @JsonCreator(mode = JsonCreator.Mode.DELEGATING) public static PlanChangeAction valueOf(String value) { switch (value) { + case "quickstart": + return QUICKSTART; + case "company_upsert": + return COMPANY_UPSERT; + case "plan_billing_product_changed": + return PLAN_BILLING_PRODUCT_CHANGED; + case "amendment": + return AMENDMENT; case "checkout": return CHECKOUT; case "migration": return MIGRATION; case "plan_version_migration": return PLAN_VERSION_MIGRATION; + case "access_reinstated": + return ACCESS_REINSTATED; case "subscription_change": return SUBSCRIPTION_CHANGE; case "plan_deleted": return PLAN_DELETED; - case "quickstart": - return QUICKSTART; - case "company_upsert": - return COMPANY_UPSERT; - case "plan_billing_product_changed": - return PLAN_BILLING_PRODUCT_CHANGED; case "fallback_plan": return FALLBACK_PLAN; - case "amendment": - return AMENDMENT; + case "invoice_past_due": + return INVOICE_PAST_DUE; + case "access_revoked": + return ACCESS_REVOKED; case "plan_trait_change": return PLAN_TRAIT_CHANGE; case "manage_plan": @@ -130,6 +150,10 @@ public static PlanChangeAction valueOf(String value) { } public enum Value { + ACCESS_REINSTATED, + + ACCESS_REVOKED, + AMENDMENT, CHECKOUT, @@ -138,6 +162,8 @@ public enum Value { FALLBACK_PLAN, + INVOICE_PAST_DUE, + MANAGE_PLAN, MIGRATION, @@ -158,6 +184,10 @@ public enum Value { } public interface Visitor { + T visitAccessReinstated(); + + T visitAccessRevoked(); + T visitAmendment(); T visitCheckout(); @@ -166,6 +196,8 @@ public interface Visitor { T visitFallbackPlan(); + T visitInvoicePastDue(); + T visitManagePlan(); T visitMigration(); diff --git a/src/main/java/com/schematic/api/types/PublishPlanVersionRequestBody.java b/src/main/java/com/schematic/api/types/PublishPlanVersionRequestBody.java index 96c1685..c98432f 100644 --- a/src/main/java/com/schematic/api/types/PublishPlanVersionRequestBody.java +++ b/src/main/java/com/schematic/api/types/PublishPlanVersionRequestBody.java @@ -46,8 +46,12 @@ public final class PublishPlanVersionRequestBody { private final List excludedCompanyIds; + private final Optional gatingDays; + private final PlanVersionMigrationStrategy migrationStrategy; + private final Optional paymentGating; + private final Optional phone; private final Optional prorateFirstPeriod; @@ -76,7 +80,9 @@ private PublishPlanVersionRequestBody( Optional daysUntilDue, Optional endDate, List excludedCompanyIds, + Optional gatingDays, PlanVersionMigrationStrategy migrationStrategy, + Optional paymentGating, Optional phone, Optional prorateFirstPeriod, Optional prorationBehavior, @@ -96,7 +102,9 @@ private PublishPlanVersionRequestBody( this.daysUntilDue = daysUntilDue; this.endDate = endDate; this.excludedCompanyIds = excludedCompanyIds; + this.gatingDays = gatingDays; this.migrationStrategy = migrationStrategy; + this.paymentGating = paymentGating; this.phone = phone; this.prorateFirstPeriod = prorateFirstPeriod; this.prorationBehavior = prorationBehavior; @@ -183,11 +191,27 @@ public List getExcludedCompanyIds() { return excludedCompanyIds; } + /** + * @return With payment_gating revoke_after, how many days past due an invoice may go before the company loses the plan. 0 revokes at once. Only applies when Schematic bills the company. Applies to the company's contract and never creates a plan version. Omitted keeps the contract's setting. + */ + @JsonProperty("gating_days") + public Optional getGatingDays() { + return gatingDays; + } + @JsonProperty("migration_strategy") public PlanVersionMigrationStrategy getMigrationStrategy() { return migrationStrategy; } + /** + * @return What happens to the company's access when an invoice passes its due date: keep_serving keeps the plan and marks the subscription past due; revoke_after takes the plan away after gating_days. Only applies when Schematic bills the company, to every invoice on its contract, and never creates a plan version. Omitted keeps the contract's setting, which is keep_serving unless changed. + */ + @JsonProperty("payment_gating") + public Optional getPaymentGating() { + return paymentGating; + } + @JsonProperty("phone") public Optional getPhone() { return phone; @@ -261,7 +285,9 @@ private boolean equalTo(PublishPlanVersionRequestBody other) { && daysUntilDue.equals(other.daysUntilDue) && endDate.equals(other.endDate) && excludedCompanyIds.equals(other.excludedCompanyIds) + && gatingDays.equals(other.gatingDays) && migrationStrategy.equals(other.migrationStrategy) + && paymentGating.equals(other.paymentGating) && phone.equals(other.phone) && prorateFirstPeriod.equals(other.prorateFirstPeriod) && prorationBehavior.equals(other.prorationBehavior) @@ -285,7 +311,9 @@ public int hashCode() { this.daysUntilDue, this.endDate, this.excludedCompanyIds, + this.gatingDays, this.migrationStrategy, + this.paymentGating, this.phone, this.prorateFirstPeriod, this.prorationBehavior, @@ -384,6 +412,20 @@ public interface _FinalStage { _FinalStage addAllExcludedCompanyIds(List excludedCompanyIds); + /** + *

With payment_gating revoke_after, how many days past due an invoice may go before the company loses the plan. 0 revokes at once. Only applies when Schematic bills the company. Applies to the company's contract and never creates a plan version. Omitted keeps the contract's setting.

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

What happens to the company's access when an invoice passes its due date: keep_serving keeps the plan and marks the subscription past due; revoke_after takes the plan away after gating_days. Only applies when Schematic bills the company, to every invoice on its contract, and never creates a plan version. Omitted keeps the contract's setting, which is keep_serving unless changed.

+ */ + _FinalStage paymentGating(Optional paymentGating); + + _FinalStage paymentGating(PaymentGating paymentGating); + _FinalStage phone(Optional phone); _FinalStage phone(String phone); @@ -446,6 +488,10 @@ public static final class Builder implements MigrationStrategyStage, _FinalStage private Optional phone = Optional.empty(); + private Optional paymentGating = Optional.empty(); + + private Optional gatingDays = Optional.empty(); + private List excludedCompanyIds = new ArrayList<>(); private Optional endDate = Optional.empty(); @@ -485,7 +531,9 @@ public Builder from(PublishPlanVersionRequestBody other) { daysUntilDue(other.getDaysUntilDue()); endDate(other.getEndDate()); excludedCompanyIds(other.getExcludedCompanyIds()); + gatingDays(other.getGatingDays()); migrationStrategy(other.getMigrationStrategy()); + paymentGating(other.getPaymentGating()); phone(other.getPhone()); prorateFirstPeriod(other.getProrateFirstPeriod()); prorationBehavior(other.getProrationBehavior()); @@ -629,6 +677,46 @@ public _FinalStage phone(Optional phone) { return this; } + /** + *

What happens to the company's access when an invoice passes its due date: keep_serving keeps the plan and marks the subscription past due; revoke_after takes the plan away after gating_days. Only applies when Schematic bills the company, to every invoice on its contract, and never creates a plan version. Omitted keeps the contract's setting, which is keep_serving unless changed.

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

What happens to the company's access when an invoice passes its due date: keep_serving keeps the plan and marks the subscription past due; revoke_after takes the plan away after gating_days. Only applies when Schematic bills the company, to every invoice on its contract, and never creates a plan version. Omitted keeps the contract's setting, which is keep_serving unless changed.

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

With payment_gating revoke_after, how many days past due an invoice may go before the company loses the plan. 0 revokes at once. Only applies when Schematic bills the company. Applies to the company's contract and never creates a plan version. Omitted keeps the contract's setting.

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

With payment_gating revoke_after, how many days past due an invoice may go before the company loses the plan. 0 revokes at once. Only applies when Schematic bills the company. Applies to the company's contract and never creates a plan version. Omitted keeps the contract's setting.

+ */ + @java.lang.Override + @JsonSetter(value = "gating_days", nulls = Nulls.SKIP) + public _FinalStage gatingDays(Optional gatingDays) { + this.gatingDays = gatingDays; + return this; + } + @java.lang.Override public _FinalStage addAllExcludedCompanyIds(List excludedCompanyIds) { if (excludedCompanyIds != null) { @@ -846,7 +934,9 @@ public PublishPlanVersionRequestBody build() { daysUntilDue, endDate, excludedCompanyIds, + gatingDays, migrationStrategy, + paymentGating, phone, prorateFirstPeriod, prorationBehavior, @@ -870,7 +960,9 @@ private void putAdditionalPropertyFromJson(String key, Object value) { || key.equalsIgnoreCase("days_until_due") || key.equalsIgnoreCase("end_date") || key.equalsIgnoreCase("excluded_company_ids") + || key.equalsIgnoreCase("gating_days") || key.equalsIgnoreCase("migration_strategy") + || key.equalsIgnoreCase("payment_gating") || key.equalsIgnoreCase("phone") || key.equalsIgnoreCase("prorate_first_period") || key.equalsIgnoreCase("proration_behavior") diff --git a/src/main/java/com/schematic/api/types/WebhookRequestType.java b/src/main/java/com/schematic/api/types/WebhookRequestType.java index ade1245..877d4a5 100644 --- a/src/main/java/com/schematic/api/types/WebhookRequestType.java +++ b/src/main/java/com/schematic/api/types/WebhookRequestType.java @@ -86,6 +86,9 @@ public final class WebhookRequestType { public static final WebhookRequestType COMPANY_PLAN_CHANGED = new WebhookRequestType(Value.COMPANY_PLAN_CHANGED, "company.plan_changed"); + public static final WebhookRequestType INVOICE_FINALIZED = + new WebhookRequestType(Value.INVOICE_FINALIZED, "invoice.finalized"); + public static final WebhookRequestType ENTITLEMENT_TIER_LIMIT_REACHED = new WebhookRequestType(Value.ENTITLEMENT_TIER_LIMIT_REACHED, "entitlement.tier_limit.reached"); @@ -104,6 +107,12 @@ public final class WebhookRequestType { public static final WebhookRequestType COMPANY_CREATED = new WebhookRequestType(Value.COMPANY_CREATED, "company.created"); + public static final WebhookRequestType SUBSCRIPTION_PERIOD_STARTED = + new WebhookRequestType(Value.SUBSCRIPTION_PERIOD_STARTED, "subscription.period.started"); + + public static final WebhookRequestType INVOICE_PAST_DUE = + new WebhookRequestType(Value.INVOICE_PAST_DUE, "invoice.past_due"); + public static final WebhookRequestType AUTO_TOPUP_SUCCESS = new WebhookRequestType(Value.AUTO_TOPUP_SUCCESS, "auto.topup.success"); @@ -112,6 +121,8 @@ public final class WebhookRequestType { public static final WebhookRequestType FLAG_DELETED = new WebhookRequestType(Value.FLAG_DELETED, "flag.deleted"); + public static final WebhookRequestType INVOICE_PAID = new WebhookRequestType(Value.INVOICE_PAID, "invoice.paid"); + public static final WebhookRequestType PLAN_CREATED = new WebhookRequestType(Value.PLAN_CREATED, "plan.created"); public static final WebhookRequestType CREDIT_PURCHASE_SUCCESS = @@ -122,6 +133,9 @@ public final class WebhookRequestType { public static final WebhookRequestType FEATURE_UPDATED = new WebhookRequestType(Value.FEATURE_UPDATED, "feature.updated"); + public static final WebhookRequestType INVOICE_VOIDED = + new WebhookRequestType(Value.INVOICE_VOIDED, "invoice.voided"); + private final Value value; private final String string; @@ -212,6 +226,8 @@ public T visit(Visitor visitor) { return visitor.visitEntitlementSoftLimitWarning(); case COMPANY_PLAN_CHANGED: return visitor.visitCompanyPlanChanged(); + case INVOICE_FINALIZED: + return visitor.visitInvoiceFinalized(); case ENTITLEMENT_TIER_LIMIT_REACHED: return visitor.visitEntitlementTierLimitReached(); case PLAN_VERSION_DELETED: @@ -224,12 +240,18 @@ public T visit(Visitor visitor) { return visitor.visitCompanyUpdated(); case COMPANY_CREATED: return visitor.visitCompanyCreated(); + case SUBSCRIPTION_PERIOD_STARTED: + return visitor.visitSubscriptionPeriodStarted(); + case INVOICE_PAST_DUE: + return visitor.visitInvoicePastDue(); case AUTO_TOPUP_SUCCESS: return visitor.visitAutoTopupSuccess(); case ENTITLEMENT_TIER_LIMIT_WARNING: return visitor.visitEntitlementTierLimitWarning(); case FLAG_DELETED: return visitor.visitFlagDeleted(); + case INVOICE_PAID: + return visitor.visitInvoicePaid(); case PLAN_CREATED: return visitor.visitPlanCreated(); case CREDIT_PURCHASE_SUCCESS: @@ -238,6 +260,8 @@ public T visit(Visitor visitor) { return visitor.visitTestSend(); case FEATURE_UPDATED: return visitor.visitFeatureUpdated(); + case INVOICE_VOIDED: + return visitor.visitInvoiceVoided(); case UNKNOWN: default: return visitor.visitUnknown(string); @@ -305,6 +329,8 @@ public static WebhookRequestType valueOf(String value) { return ENTITLEMENT_SOFT_LIMIT_WARNING; case "company.plan_changed": return COMPANY_PLAN_CHANGED; + case "invoice.finalized": + return INVOICE_FINALIZED; case "entitlement.tier_limit.reached": return ENTITLEMENT_TIER_LIMIT_REACHED; case "plan_version.deleted": @@ -317,12 +343,18 @@ public static WebhookRequestType valueOf(String value) { return COMPANY_UPDATED; case "company.created": return COMPANY_CREATED; + case "subscription.period.started": + return SUBSCRIPTION_PERIOD_STARTED; + case "invoice.past_due": + return INVOICE_PAST_DUE; case "auto.topup.success": return AUTO_TOPUP_SUCCESS; case "entitlement.tier_limit.warning": return ENTITLEMENT_TIER_LIMIT_WARNING; case "flag.deleted": return FLAG_DELETED; + case "invoice.paid": + return INVOICE_PAID; case "plan.created": return PLAN_CREATED; case "credit.purchase.success": @@ -331,6 +363,8 @@ public static WebhookRequestType valueOf(String value) { return TEST_SEND; case "feature.updated": return FEATURE_UPDATED; + case "invoice.voided": + return INVOICE_VOIDED; default: return new WebhookRequestType(Value.UNKNOWN, value); } @@ -391,6 +425,14 @@ public enum Value { FLAG_UPDATED, + INVOICE_FINALIZED, + + INVOICE_PAID, + + INVOICE_PAST_DUE, + + INVOICE_VOIDED, + PLAN_CREATED, PLAN_DELETED, @@ -407,6 +449,8 @@ public enum Value { RULE_DELETED, + SUBSCRIPTION_PERIOD_STARTED, + TEST_SEND, USER_CREATED, @@ -479,6 +523,14 @@ public interface Visitor { T visitFlagUpdated(); + T visitInvoiceFinalized(); + + T visitInvoicePaid(); + + T visitInvoicePastDue(); + + T visitInvoiceVoided(); + T visitPlanCreated(); T visitPlanDeleted(); @@ -495,6 +547,8 @@ public interface Visitor { T visitRuleDeleted(); + T visitSubscriptionPeriodStarted(); + T visitTestSend(); T visitUserCreated();