From 5ab48ed451c7a2f12fc6d98aa736fb616701950b Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 14 Feb 2026 01:43:46 +0000 Subject: [PATCH 01/14] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 32808d2..56f5a81 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 17 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cas-parser%2Fcas-parser-56b0f699c5437d9e5326626d35dfc972c17d01f12cb416c7f4854c8ea6d0e95e.yml openapi_spec_hash: 158f405c1880706266d83e6ff16b9d2f -config_hash: ab495a165f0919b37cbf9efbd0f0e6ef +config_hash: 41c337f5cda03b13880617490f82bad0 From 1a29c9e8fc54fa3ebb2fde3192dfde1ecb579d52 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 14 Feb 2026 01:43:55 +0000 Subject: [PATCH 02/14] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 56f5a81..32808d2 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 17 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cas-parser%2Fcas-parser-56b0f699c5437d9e5326626d35dfc972c17d01f12cb416c7f4854c8ea6d0e95e.yml openapi_spec_hash: 158f405c1880706266d83e6ff16b9d2f -config_hash: 41c337f5cda03b13880617490f82bad0 +config_hash: ab495a165f0919b37cbf9efbd0f0e6ef From 2bc22e2b59ac2cfb61486480a3d652d6a910effc Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 14 Feb 2026 01:44:22 +0000 Subject: [PATCH 03/14] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 32808d2..56f5a81 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 17 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cas-parser%2Fcas-parser-56b0f699c5437d9e5326626d35dfc972c17d01f12cb416c7f4854c8ea6d0e95e.yml openapi_spec_hash: 158f405c1880706266d83e6ff16b9d2f -config_hash: ab495a165f0919b37cbf9efbd0f0e6ef +config_hash: 41c337f5cda03b13880617490f82bad0 From ff77ead512a0b13377c61c0e92cc478586e7a67e Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 18 Feb 2026 04:40:05 +0000 Subject: [PATCH 04/14] chore(internal): update `TestServerExtension` comment --- .../com/cas_parser/api/TestServerExtension.kt | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/TestServerExtension.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/TestServerExtension.kt index a567645..7b684c2 100644 --- a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/TestServerExtension.kt +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/TestServerExtension.kt @@ -15,25 +15,12 @@ class TestServerExtension : BeforeAllCallback, ExecutionCondition { } catch (e: Exception) { throw RuntimeException( """ - The test suite will not run without a mock Prism server running against your OpenAPI spec. + The test suite will not run without a mock server running against your OpenAPI spec. You can set the environment variable `SKIP_MOCK_TESTS` to `true` to skip running any tests that require the mock server. - To fix: - - 1. Install Prism (requires Node 16+): - - With npm: - $ npm install -g @stoplight/prism-cli - - With yarn: - $ yarn global add @stoplight/prism-cli - - 2. Run the mock server - - To run the server, pass in the path of your OpenAPI spec to the prism command: - $ prism mock path/to/your.openapi.yml + To fix run `./scripts/mock` in a separate terminal. """ .trimIndent(), e, From 1939ec1346feeb7a1ea45db385d6f8b7f8daacf6 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 19 Feb 2026 04:32:12 +0000 Subject: [PATCH 05/14] chore(internal): make `OkHttp` constructor internal --- .../kotlin/com/cas_parser/api/client/okhttp/OkHttpClient.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cas-parser-java-client-okhttp/src/main/kotlin/com/cas_parser/api/client/okhttp/OkHttpClient.kt b/cas-parser-java-client-okhttp/src/main/kotlin/com/cas_parser/api/client/okhttp/OkHttpClient.kt index 7079d3c..9cfdd63 100644 --- a/cas-parser-java-client-okhttp/src/main/kotlin/com/cas_parser/api/client/okhttp/OkHttpClient.kt +++ b/cas-parser-java-client-okhttp/src/main/kotlin/com/cas_parser/api/client/okhttp/OkHttpClient.kt @@ -33,7 +33,7 @@ import okhttp3.logging.HttpLoggingInterceptor import okio.BufferedSink class OkHttpClient -private constructor(@JvmSynthetic internal val okHttpClient: okhttp3.OkHttpClient) : HttpClient { +internal constructor(@JvmSynthetic internal val okHttpClient: okhttp3.OkHttpClient) : HttpClient { override fun execute(request: HttpRequest, requestOptions: RequestOptions): HttpResponse { val call = newCall(request, requestOptions) From 3ad0fbcafa782f6f7dfcead9d4c4646aedd4e681 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 19 Feb 2026 04:35:40 +0000 Subject: [PATCH 06/14] feat(client): add connection pooling option --- README.md | 19 ++++++++ .../client/okhttp/CasParserOkHttpClient.kt | 44 +++++++++++++++++++ .../okhttp/CasParserOkHttpClientAsync.kt | 44 +++++++++++++++++++ .../api/client/okhttp/OkHttpClient.kt | 42 ++++++++++++++++++ 4 files changed, 149 insertions(+) diff --git a/README.md b/README.md index c55a4ea..212151b 100644 --- a/README.md +++ b/README.md @@ -342,6 +342,25 @@ CasParserClient client = CasParserOkHttpClient.builder() .build(); ``` +### Connection pooling + +To customize the underlying OkHttp connection pool, configure the client using the `maxIdleConnections` and `keepAliveDuration` methods: + +```java +import com.cas_parser.api.client.CasParserClient; +import com.cas_parser.api.client.okhttp.CasParserOkHttpClient; +import java.time.Duration; + +CasParserClient client = CasParserOkHttpClient.builder() + .fromEnv() + // If `maxIdleConnections` is set, then `keepAliveDuration` must be set, and vice versa. + .maxIdleConnections(10) + .keepAliveDuration(Duration.ofMinutes(2)) + .build(); +``` + +If both options are unset, OkHttp's default connection pool settings are used. + ### HTTPS > [!NOTE] diff --git a/cas-parser-java-client-okhttp/src/main/kotlin/com/cas_parser/api/client/okhttp/CasParserOkHttpClient.kt b/cas-parser-java-client-okhttp/src/main/kotlin/com/cas_parser/api/client/okhttp/CasParserOkHttpClient.kt index dc713f6..417682f 100644 --- a/cas-parser-java-client-okhttp/src/main/kotlin/com/cas_parser/api/client/okhttp/CasParserOkHttpClient.kt +++ b/cas-parser-java-client-okhttp/src/main/kotlin/com/cas_parser/api/client/okhttp/CasParserOkHttpClient.kt @@ -47,6 +47,8 @@ class CasParserOkHttpClient private constructor() { private var clientOptions: ClientOptions.Builder = ClientOptions.builder() private var dispatcherExecutorService: ExecutorService? = null private var proxy: Proxy? = null + private var maxIdleConnections: Int? = null + private var keepAliveDuration: Duration? = null private var sslSocketFactory: SSLSocketFactory? = null private var trustManager: X509TrustManager? = null private var hostnameVerifier: HostnameVerifier? = null @@ -75,6 +77,46 @@ class CasParserOkHttpClient private constructor() { /** Alias for calling [Builder.proxy] with `proxy.orElse(null)`. */ fun proxy(proxy: Optional) = proxy(proxy.getOrNull()) + /** + * The maximum number of idle connections kept by the underlying OkHttp connection pool. + * + * If this is set, then [keepAliveDuration] must also be set. + * + * If unset, then OkHttp's default is used. + */ + fun maxIdleConnections(maxIdleConnections: Int?) = apply { + this.maxIdleConnections = maxIdleConnections + } + + /** + * Alias for [Builder.maxIdleConnections]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun maxIdleConnections(maxIdleConnections: Int) = + maxIdleConnections(maxIdleConnections as Int?) + + /** + * Alias for calling [Builder.maxIdleConnections] with `maxIdleConnections.orElse(null)`. + */ + fun maxIdleConnections(maxIdleConnections: Optional) = + maxIdleConnections(maxIdleConnections.getOrNull()) + + /** + * The keep-alive duration for idle connections in the underlying OkHttp connection pool. + * + * If this is set, then [maxIdleConnections] must also be set. + * + * If unset, then OkHttp's default is used. + */ + fun keepAliveDuration(keepAliveDuration: Duration?) = apply { + this.keepAliveDuration = keepAliveDuration + } + + /** Alias for calling [Builder.keepAliveDuration] with `keepAliveDuration.orElse(null)`. */ + fun keepAliveDuration(keepAliveDuration: Optional) = + keepAliveDuration(keepAliveDuration.getOrNull()) + /** * The socket factory used to secure HTTPS connections. * @@ -328,6 +370,8 @@ class CasParserOkHttpClient private constructor() { OkHttpClient.builder() .timeout(clientOptions.timeout()) .proxy(proxy) + .maxIdleConnections(maxIdleConnections) + .keepAliveDuration(keepAliveDuration) .dispatcherExecutorService(dispatcherExecutorService) .sslSocketFactory(sslSocketFactory) .trustManager(trustManager) diff --git a/cas-parser-java-client-okhttp/src/main/kotlin/com/cas_parser/api/client/okhttp/CasParserOkHttpClientAsync.kt b/cas-parser-java-client-okhttp/src/main/kotlin/com/cas_parser/api/client/okhttp/CasParserOkHttpClientAsync.kt index 5d4beab..e83fa10 100644 --- a/cas-parser-java-client-okhttp/src/main/kotlin/com/cas_parser/api/client/okhttp/CasParserOkHttpClientAsync.kt +++ b/cas-parser-java-client-okhttp/src/main/kotlin/com/cas_parser/api/client/okhttp/CasParserOkHttpClientAsync.kt @@ -47,6 +47,8 @@ class CasParserOkHttpClientAsync private constructor() { private var clientOptions: ClientOptions.Builder = ClientOptions.builder() private var dispatcherExecutorService: ExecutorService? = null private var proxy: Proxy? = null + private var maxIdleConnections: Int? = null + private var keepAliveDuration: Duration? = null private var sslSocketFactory: SSLSocketFactory? = null private var trustManager: X509TrustManager? = null private var hostnameVerifier: HostnameVerifier? = null @@ -75,6 +77,46 @@ class CasParserOkHttpClientAsync private constructor() { /** Alias for calling [Builder.proxy] with `proxy.orElse(null)`. */ fun proxy(proxy: Optional) = proxy(proxy.getOrNull()) + /** + * The maximum number of idle connections kept by the underlying OkHttp connection pool. + * + * If this is set, then [keepAliveDuration] must also be set. + * + * If unset, then OkHttp's default is used. + */ + fun maxIdleConnections(maxIdleConnections: Int?) = apply { + this.maxIdleConnections = maxIdleConnections + } + + /** + * Alias for [Builder.maxIdleConnections]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun maxIdleConnections(maxIdleConnections: Int) = + maxIdleConnections(maxIdleConnections as Int?) + + /** + * Alias for calling [Builder.maxIdleConnections] with `maxIdleConnections.orElse(null)`. + */ + fun maxIdleConnections(maxIdleConnections: Optional) = + maxIdleConnections(maxIdleConnections.getOrNull()) + + /** + * The keep-alive duration for idle connections in the underlying OkHttp connection pool. + * + * If this is set, then [maxIdleConnections] must also be set. + * + * If unset, then OkHttp's default is used. + */ + fun keepAliveDuration(keepAliveDuration: Duration?) = apply { + this.keepAliveDuration = keepAliveDuration + } + + /** Alias for calling [Builder.keepAliveDuration] with `keepAliveDuration.orElse(null)`. */ + fun keepAliveDuration(keepAliveDuration: Optional) = + keepAliveDuration(keepAliveDuration.getOrNull()) + /** * The socket factory used to secure HTTPS connections. * @@ -328,6 +370,8 @@ class CasParserOkHttpClientAsync private constructor() { OkHttpClient.builder() .timeout(clientOptions.timeout()) .proxy(proxy) + .maxIdleConnections(maxIdleConnections) + .keepAliveDuration(keepAliveDuration) .dispatcherExecutorService(dispatcherExecutorService) .sslSocketFactory(sslSocketFactory) .trustManager(trustManager) diff --git a/cas-parser-java-client-okhttp/src/main/kotlin/com/cas_parser/api/client/okhttp/OkHttpClient.kt b/cas-parser-java-client-okhttp/src/main/kotlin/com/cas_parser/api/client/okhttp/OkHttpClient.kt index 9cfdd63..7bc37ab 100644 --- a/cas-parser-java-client-okhttp/src/main/kotlin/com/cas_parser/api/client/okhttp/OkHttpClient.kt +++ b/cas-parser-java-client-okhttp/src/main/kotlin/com/cas_parser/api/client/okhttp/OkHttpClient.kt @@ -16,11 +16,13 @@ import java.time.Duration import java.util.concurrent.CancellationException import java.util.concurrent.CompletableFuture import java.util.concurrent.ExecutorService +import java.util.concurrent.TimeUnit import javax.net.ssl.HostnameVerifier import javax.net.ssl.SSLSocketFactory import javax.net.ssl.X509TrustManager import okhttp3.Call import okhttp3.Callback +import okhttp3.ConnectionPool import okhttp3.Dispatcher import okhttp3.HttpUrl.Companion.toHttpUrl import okhttp3.MediaType @@ -200,6 +202,8 @@ internal constructor(@JvmSynthetic internal val okHttpClient: okhttp3.OkHttpClie private var timeout: Timeout = Timeout.default() private var proxy: Proxy? = null + private var maxIdleConnections: Int? = null + private var keepAliveDuration: Duration? = null private var dispatcherExecutorService: ExecutorService? = null private var sslSocketFactory: SSLSocketFactory? = null private var trustManager: X509TrustManager? = null @@ -211,6 +215,28 @@ internal constructor(@JvmSynthetic internal val okHttpClient: okhttp3.OkHttpClie fun proxy(proxy: Proxy?) = apply { this.proxy = proxy } + /** + * Sets the maximum number of idle connections kept by the underlying [ConnectionPool]. + * + * If this is set, then [keepAliveDuration] must also be set. + * + * If unset, then OkHttp's default is used. + */ + fun maxIdleConnections(maxIdleConnections: Int?) = apply { + this.maxIdleConnections = maxIdleConnections + } + + /** + * Sets the keep-alive duration for idle connections in the underlying [ConnectionPool]. + * + * If this is set, then [maxIdleConnections] must also be set. + * + * If unset, then OkHttp's default is used. + */ + fun keepAliveDuration(keepAliveDuration: Duration?) = apply { + this.keepAliveDuration = keepAliveDuration + } + fun dispatcherExecutorService(dispatcherExecutorService: ExecutorService?) = apply { this.dispatcherExecutorService = dispatcherExecutorService } @@ -240,6 +266,22 @@ internal constructor(@JvmSynthetic internal val okHttpClient: okhttp3.OkHttpClie .apply { dispatcherExecutorService?.let { dispatcher(Dispatcher(it)) } + val maxIdleConnections = maxIdleConnections + val keepAliveDuration = keepAliveDuration + if (maxIdleConnections != null && keepAliveDuration != null) { + connectionPool( + ConnectionPool( + maxIdleConnections, + keepAliveDuration.toNanos(), + TimeUnit.NANOSECONDS, + ) + ) + } else { + check((maxIdleConnections != null) == (keepAliveDuration != null)) { + "Both or none of `maxIdleConnections` and `keepAliveDuration` must be set, but only one was set" + } + } + val sslSocketFactory = sslSocketFactory val trustManager = trustManager if (sslSocketFactory != null && trustManager != null) { From 0bdc28fc1a9ae2e735d2c40d9cf86c1dc00461ae Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 20 Feb 2026 05:23:00 +0000 Subject: [PATCH 07/14] chore(internal): remove mock server code --- .../com/cas_parser/api/TestServerExtension.kt | 49 ------------------- .../async/AccessTokenServiceAsyncTest.kt | 9 +--- .../async/CamsKfintechServiceAsyncTest.kt | 9 +--- .../services/async/CdslServiceAsyncTest.kt | 9 +--- .../async/ContractNoteServiceAsyncTest.kt | 9 +--- .../services/async/CreditServiceAsyncTest.kt | 9 +--- .../services/async/InboxServiceAsyncTest.kt | 27 ++-------- .../async/KfintechServiceAsyncTest.kt | 9 +--- .../api/services/async/LogServiceAsyncTest.kt | 15 +----- .../services/async/NsdlServiceAsyncTest.kt | 9 +--- .../services/async/SmartServiceAsyncTest.kt | 9 +--- .../async/VerifyTokenServiceAsyncTest.kt | 9 +--- .../async/cdsl/FetchServiceAsyncTest.kt | 15 +----- .../blocking/AccessTokenServiceTest.kt | 9 +--- .../blocking/CamsKfintechServiceTest.kt | 9 +--- .../api/services/blocking/CdslServiceTest.kt | 9 +--- .../blocking/ContractNoteServiceTest.kt | 9 +--- .../services/blocking/CreditServiceTest.kt | 9 +--- .../api/services/blocking/InboxServiceTest.kt | 27 ++-------- .../services/blocking/KfintechServiceTest.kt | 9 +--- .../api/services/blocking/LogServiceTest.kt | 15 +----- .../api/services/blocking/NsdlServiceTest.kt | 9 +--- .../api/services/blocking/SmartServiceTest.kt | 9 +--- .../blocking/VerifyTokenServiceTest.kt | 9 +--- .../blocking/cdsl/FetchServiceTest.kt | 15 +----- scripts/mock | 41 ---------------- scripts/test | 46 ----------------- 27 files changed, 34 insertions(+), 378 deletions(-) delete mode 100644 cas-parser-java-core/src/test/kotlin/com/cas_parser/api/TestServerExtension.kt delete mode 100755 scripts/mock diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/TestServerExtension.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/TestServerExtension.kt deleted file mode 100644 index 7b684c2..0000000 --- a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/TestServerExtension.kt +++ /dev/null @@ -1,49 +0,0 @@ -package com.cas_parser.api - -import java.lang.RuntimeException -import java.net.URL -import org.junit.jupiter.api.extension.BeforeAllCallback -import org.junit.jupiter.api.extension.ConditionEvaluationResult -import org.junit.jupiter.api.extension.ExecutionCondition -import org.junit.jupiter.api.extension.ExtensionContext - -class TestServerExtension : BeforeAllCallback, ExecutionCondition { - - override fun beforeAll(context: ExtensionContext?) { - try { - URL(BASE_URL).openConnection().connect() - } catch (e: Exception) { - throw RuntimeException( - """ - The test suite will not run without a mock server running against your OpenAPI spec. - - You can set the environment variable `SKIP_MOCK_TESTS` to `true` to skip running any tests - that require the mock server. - - To fix run `./scripts/mock` in a separate terminal. - """ - .trimIndent(), - e, - ) - } - } - - override fun evaluateExecutionCondition(context: ExtensionContext): ConditionEvaluationResult { - return if (System.getenv(SKIP_TESTS_ENV).toBoolean()) { - ConditionEvaluationResult.disabled( - "Environment variable $SKIP_TESTS_ENV is set to true" - ) - } else { - ConditionEvaluationResult.enabled( - "Environment variable $SKIP_TESTS_ENV is not set to true" - ) - } - } - - companion object { - - val BASE_URL = System.getenv("TEST_API_BASE_URL") ?: "http://localhost:4010" - - const val SKIP_TESTS_ENV: String = "SKIP_MOCK_TESTS" - } -} diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/AccessTokenServiceAsyncTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/AccessTokenServiceAsyncTest.kt index d1a2caa..bb9558e 100644 --- a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/AccessTokenServiceAsyncTest.kt +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/AccessTokenServiceAsyncTest.kt @@ -2,24 +2,17 @@ package com.cas_parser.api.services.async -import com.cas_parser.api.TestServerExtension import com.cas_parser.api.client.okhttp.CasParserOkHttpClientAsync import com.cas_parser.api.models.accesstoken.AccessTokenCreateParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith -@ExtendWith(TestServerExtension::class) internal class AccessTokenServiceAsyncTest { @Disabled("Prism tests are disabled") @Test fun create() { - val client = - CasParserOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() + val client = CasParserOkHttpClientAsync.builder().apiKey("My API Key").build() val accessTokenServiceAsync = client.accessToken() val accessTokenFuture = diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/CamsKfintechServiceAsyncTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/CamsKfintechServiceAsyncTest.kt index 2f14e4a..5597a2e 100644 --- a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/CamsKfintechServiceAsyncTest.kt +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/CamsKfintechServiceAsyncTest.kt @@ -2,24 +2,17 @@ package com.cas_parser.api.services.async -import com.cas_parser.api.TestServerExtension import com.cas_parser.api.client.okhttp.CasParserOkHttpClientAsync import com.cas_parser.api.models.camskfintech.CamsKfintechParseParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith -@ExtendWith(TestServerExtension::class) internal class CamsKfintechServiceAsyncTest { @Disabled("Prism tests are disabled") @Test fun parse() { - val client = - CasParserOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() + val client = CasParserOkHttpClientAsync.builder().apiKey("My API Key").build() val camsKfintechServiceAsync = client.camsKfintech() val unifiedResponseFuture = diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/CdslServiceAsyncTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/CdslServiceAsyncTest.kt index 36a9797..33d3092 100644 --- a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/CdslServiceAsyncTest.kt +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/CdslServiceAsyncTest.kt @@ -2,24 +2,17 @@ package com.cas_parser.api.services.async -import com.cas_parser.api.TestServerExtension import com.cas_parser.api.client.okhttp.CasParserOkHttpClientAsync import com.cas_parser.api.models.cdsl.CdslParsePdfParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith -@ExtendWith(TestServerExtension::class) internal class CdslServiceAsyncTest { @Disabled("Prism tests are disabled") @Test fun parsePdf() { - val client = - CasParserOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() + val client = CasParserOkHttpClientAsync.builder().apiKey("My API Key").build() val cdslServiceAsync = client.cdsl() val unifiedResponseFuture = diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/ContractNoteServiceAsyncTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/ContractNoteServiceAsyncTest.kt index 8e7907e..02dc255 100644 --- a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/ContractNoteServiceAsyncTest.kt +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/ContractNoteServiceAsyncTest.kt @@ -2,24 +2,17 @@ package com.cas_parser.api.services.async -import com.cas_parser.api.TestServerExtension import com.cas_parser.api.client.okhttp.CasParserOkHttpClientAsync import com.cas_parser.api.models.contractnote.ContractNoteParseParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith -@ExtendWith(TestServerExtension::class) internal class ContractNoteServiceAsyncTest { @Disabled("Prism tests are disabled") @Test fun parse() { - val client = - CasParserOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() + val client = CasParserOkHttpClientAsync.builder().apiKey("My API Key").build() val contractNoteServiceAsync = client.contractNote() val responseFuture = diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/CreditServiceAsyncTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/CreditServiceAsyncTest.kt index bedb74b..c831f4e 100644 --- a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/CreditServiceAsyncTest.kt +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/CreditServiceAsyncTest.kt @@ -2,23 +2,16 @@ package com.cas_parser.api.services.async -import com.cas_parser.api.TestServerExtension import com.cas_parser.api.client.okhttp.CasParserOkHttpClientAsync import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith -@ExtendWith(TestServerExtension::class) internal class CreditServiceAsyncTest { @Disabled("Prism tests are disabled") @Test fun check() { - val client = - CasParserOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() + val client = CasParserOkHttpClientAsync.builder().apiKey("My API Key").build() val creditServiceAsync = client.credits() val responseFuture = creditServiceAsync.check() diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/InboxServiceAsyncTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/InboxServiceAsyncTest.kt index 45759bf..f80c8f1 100644 --- a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/InboxServiceAsyncTest.kt +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/InboxServiceAsyncTest.kt @@ -2,7 +2,6 @@ package com.cas_parser.api.services.async -import com.cas_parser.api.TestServerExtension import com.cas_parser.api.client.okhttp.CasParserOkHttpClientAsync import com.cas_parser.api.models.inbox.InboxCheckConnectionStatusParams import com.cas_parser.api.models.inbox.InboxConnectEmailParams @@ -11,19 +10,13 @@ import com.cas_parser.api.models.inbox.InboxListCasFilesParams import java.time.LocalDate import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith -@ExtendWith(TestServerExtension::class) internal class InboxServiceAsyncTest { @Disabled("Prism tests are disabled") @Test fun checkConnectionStatus() { - val client = - CasParserOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() + val client = CasParserOkHttpClientAsync.builder().apiKey("My API Key").build() val inboxServiceAsync = client.inbox() val responseFuture = @@ -38,11 +31,7 @@ internal class InboxServiceAsyncTest { @Disabled("Prism tests are disabled") @Test fun connectEmail() { - val client = - CasParserOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() + val client = CasParserOkHttpClientAsync.builder().apiKey("My API Key").build() val inboxServiceAsync = client.inbox() val responseFuture = @@ -60,11 +49,7 @@ internal class InboxServiceAsyncTest { @Disabled("Prism tests are disabled") @Test fun disconnectEmail() { - val client = - CasParserOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() + val client = CasParserOkHttpClientAsync.builder().apiKey("My API Key").build() val inboxServiceAsync = client.inbox() val responseFuture = @@ -79,11 +64,7 @@ internal class InboxServiceAsyncTest { @Disabled("Prism tests are disabled") @Test fun listCasFiles() { - val client = - CasParserOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() + val client = CasParserOkHttpClientAsync.builder().apiKey("My API Key").build() val inboxServiceAsync = client.inbox() val responseFuture = diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/KfintechServiceAsyncTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/KfintechServiceAsyncTest.kt index 8409abc..3e8ebf1 100644 --- a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/KfintechServiceAsyncTest.kt +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/KfintechServiceAsyncTest.kt @@ -2,24 +2,17 @@ package com.cas_parser.api.services.async -import com.cas_parser.api.TestServerExtension import com.cas_parser.api.client.okhttp.CasParserOkHttpClientAsync import com.cas_parser.api.models.kfintech.KfintechGenerateCasParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith -@ExtendWith(TestServerExtension::class) internal class KfintechServiceAsyncTest { @Disabled("Prism tests are disabled") @Test fun generateCas() { - val client = - CasParserOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() + val client = CasParserOkHttpClientAsync.builder().apiKey("My API Key").build() val kfintechServiceAsync = client.kfintech() val responseFuture = diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/LogServiceAsyncTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/LogServiceAsyncTest.kt index bcb12c3..7779a3c 100644 --- a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/LogServiceAsyncTest.kt +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/LogServiceAsyncTest.kt @@ -2,26 +2,19 @@ package com.cas_parser.api.services.async -import com.cas_parser.api.TestServerExtension import com.cas_parser.api.client.okhttp.CasParserOkHttpClientAsync import com.cas_parser.api.models.logs.LogCreateParams import com.cas_parser.api.models.logs.LogGetSummaryParams import java.time.OffsetDateTime import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith -@ExtendWith(TestServerExtension::class) internal class LogServiceAsyncTest { @Disabled("Prism tests are disabled") @Test fun create() { - val client = - CasParserOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() + val client = CasParserOkHttpClientAsync.builder().apiKey("My API Key").build() val logServiceAsync = client.logs() val logFuture = @@ -40,11 +33,7 @@ internal class LogServiceAsyncTest { @Disabled("Prism tests are disabled") @Test fun getSummary() { - val client = - CasParserOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() + val client = CasParserOkHttpClientAsync.builder().apiKey("My API Key").build() val logServiceAsync = client.logs() val responseFuture = diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/NsdlServiceAsyncTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/NsdlServiceAsyncTest.kt index b8db02d..4b569bc 100644 --- a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/NsdlServiceAsyncTest.kt +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/NsdlServiceAsyncTest.kt @@ -2,24 +2,17 @@ package com.cas_parser.api.services.async -import com.cas_parser.api.TestServerExtension import com.cas_parser.api.client.okhttp.CasParserOkHttpClientAsync import com.cas_parser.api.models.nsdl.NsdlParseParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith -@ExtendWith(TestServerExtension::class) internal class NsdlServiceAsyncTest { @Disabled("Prism tests are disabled") @Test fun parse() { - val client = - CasParserOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() + val client = CasParserOkHttpClientAsync.builder().apiKey("My API Key").build() val nsdlServiceAsync = client.nsdl() val unifiedResponseFuture = diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/SmartServiceAsyncTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/SmartServiceAsyncTest.kt index 9cc398a..c574f20 100644 --- a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/SmartServiceAsyncTest.kt +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/SmartServiceAsyncTest.kt @@ -2,24 +2,17 @@ package com.cas_parser.api.services.async -import com.cas_parser.api.TestServerExtension import com.cas_parser.api.client.okhttp.CasParserOkHttpClientAsync import com.cas_parser.api.models.smart.SmartParseCasPdfParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith -@ExtendWith(TestServerExtension::class) internal class SmartServiceAsyncTest { @Disabled("Prism tests are disabled") @Test fun parseCasPdf() { - val client = - CasParserOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() + val client = CasParserOkHttpClientAsync.builder().apiKey("My API Key").build() val smartServiceAsync = client.smart() val unifiedResponseFuture = diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/VerifyTokenServiceAsyncTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/VerifyTokenServiceAsyncTest.kt index c521605..028abdd 100644 --- a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/VerifyTokenServiceAsyncTest.kt +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/VerifyTokenServiceAsyncTest.kt @@ -2,23 +2,16 @@ package com.cas_parser.api.services.async -import com.cas_parser.api.TestServerExtension import com.cas_parser.api.client.okhttp.CasParserOkHttpClientAsync import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith -@ExtendWith(TestServerExtension::class) internal class VerifyTokenServiceAsyncTest { @Disabled("Prism tests are disabled") @Test fun verify() { - val client = - CasParserOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() + val client = CasParserOkHttpClientAsync.builder().apiKey("My API Key").build() val verifyTokenServiceAsync = client.verifyToken() val responseFuture = verifyTokenServiceAsync.verify() diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/cdsl/FetchServiceAsyncTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/cdsl/FetchServiceAsyncTest.kt index 7cc38ca..aee0987 100644 --- a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/cdsl/FetchServiceAsyncTest.kt +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/cdsl/FetchServiceAsyncTest.kt @@ -2,25 +2,18 @@ package com.cas_parser.api.services.async.cdsl -import com.cas_parser.api.TestServerExtension import com.cas_parser.api.client.okhttp.CasParserOkHttpClientAsync import com.cas_parser.api.models.cdsl.fetch.FetchRequestOtpParams import com.cas_parser.api.models.cdsl.fetch.FetchVerifyOtpParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith -@ExtendWith(TestServerExtension::class) internal class FetchServiceAsyncTest { @Disabled("Prism tests are disabled") @Test fun requestOtp() { - val client = - CasParserOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() + val client = CasParserOkHttpClientAsync.builder().apiKey("My API Key").build() val fetchServiceAsync = client.cdsl().fetch() val responseFuture = @@ -39,11 +32,7 @@ internal class FetchServiceAsyncTest { @Disabled("Prism tests are disabled") @Test fun verifyOtp() { - val client = - CasParserOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() + val client = CasParserOkHttpClientAsync.builder().apiKey("My API Key").build() val fetchServiceAsync = client.cdsl().fetch() val responseFuture = diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/AccessTokenServiceTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/AccessTokenServiceTest.kt index 278e2a8..b236856 100644 --- a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/AccessTokenServiceTest.kt +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/AccessTokenServiceTest.kt @@ -2,24 +2,17 @@ package com.cas_parser.api.services.blocking -import com.cas_parser.api.TestServerExtension import com.cas_parser.api.client.okhttp.CasParserOkHttpClient import com.cas_parser.api.models.accesstoken.AccessTokenCreateParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith -@ExtendWith(TestServerExtension::class) internal class AccessTokenServiceTest { @Disabled("Prism tests are disabled") @Test fun create() { - val client = - CasParserOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() + val client = CasParserOkHttpClient.builder().apiKey("My API Key").build() val accessTokenService = client.accessToken() val accessToken = diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/CamsKfintechServiceTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/CamsKfintechServiceTest.kt index 86de188..fc27735 100644 --- a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/CamsKfintechServiceTest.kt +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/CamsKfintechServiceTest.kt @@ -2,24 +2,17 @@ package com.cas_parser.api.services.blocking -import com.cas_parser.api.TestServerExtension import com.cas_parser.api.client.okhttp.CasParserOkHttpClient import com.cas_parser.api.models.camskfintech.CamsKfintechParseParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith -@ExtendWith(TestServerExtension::class) internal class CamsKfintechServiceTest { @Disabled("Prism tests are disabled") @Test fun parse() { - val client = - CasParserOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() + val client = CasParserOkHttpClient.builder().apiKey("My API Key").build() val camsKfintechService = client.camsKfintech() val unifiedResponse = diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/CdslServiceTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/CdslServiceTest.kt index 492dd5c..7529333 100644 --- a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/CdslServiceTest.kt +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/CdslServiceTest.kt @@ -2,24 +2,17 @@ package com.cas_parser.api.services.blocking -import com.cas_parser.api.TestServerExtension import com.cas_parser.api.client.okhttp.CasParserOkHttpClient import com.cas_parser.api.models.cdsl.CdslParsePdfParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith -@ExtendWith(TestServerExtension::class) internal class CdslServiceTest { @Disabled("Prism tests are disabled") @Test fun parsePdf() { - val client = - CasParserOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() + val client = CasParserOkHttpClient.builder().apiKey("My API Key").build() val cdslService = client.cdsl() val unifiedResponse = diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/ContractNoteServiceTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/ContractNoteServiceTest.kt index 07164ca..93bf156 100644 --- a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/ContractNoteServiceTest.kt +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/ContractNoteServiceTest.kt @@ -2,24 +2,17 @@ package com.cas_parser.api.services.blocking -import com.cas_parser.api.TestServerExtension import com.cas_parser.api.client.okhttp.CasParserOkHttpClient import com.cas_parser.api.models.contractnote.ContractNoteParseParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith -@ExtendWith(TestServerExtension::class) internal class ContractNoteServiceTest { @Disabled("Prism tests are disabled") @Test fun parse() { - val client = - CasParserOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() + val client = CasParserOkHttpClient.builder().apiKey("My API Key").build() val contractNoteService = client.contractNote() val response = diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/CreditServiceTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/CreditServiceTest.kt index 750948f..faff248 100644 --- a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/CreditServiceTest.kt +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/CreditServiceTest.kt @@ -2,23 +2,16 @@ package com.cas_parser.api.services.blocking -import com.cas_parser.api.TestServerExtension import com.cas_parser.api.client.okhttp.CasParserOkHttpClient import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith -@ExtendWith(TestServerExtension::class) internal class CreditServiceTest { @Disabled("Prism tests are disabled") @Test fun check() { - val client = - CasParserOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() + val client = CasParserOkHttpClient.builder().apiKey("My API Key").build() val creditService = client.credits() val response = creditService.check() diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/InboxServiceTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/InboxServiceTest.kt index 8b62e2d..177e27d 100644 --- a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/InboxServiceTest.kt +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/InboxServiceTest.kt @@ -2,7 +2,6 @@ package com.cas_parser.api.services.blocking -import com.cas_parser.api.TestServerExtension import com.cas_parser.api.client.okhttp.CasParserOkHttpClient import com.cas_parser.api.models.inbox.InboxCheckConnectionStatusParams import com.cas_parser.api.models.inbox.InboxConnectEmailParams @@ -11,19 +10,13 @@ import com.cas_parser.api.models.inbox.InboxListCasFilesParams import java.time.LocalDate import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith -@ExtendWith(TestServerExtension::class) internal class InboxServiceTest { @Disabled("Prism tests are disabled") @Test fun checkConnectionStatus() { - val client = - CasParserOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() + val client = CasParserOkHttpClient.builder().apiKey("My API Key").build() val inboxService = client.inbox() val response = @@ -37,11 +30,7 @@ internal class InboxServiceTest { @Disabled("Prism tests are disabled") @Test fun connectEmail() { - val client = - CasParserOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() + val client = CasParserOkHttpClient.builder().apiKey("My API Key").build() val inboxService = client.inbox() val response = @@ -58,11 +47,7 @@ internal class InboxServiceTest { @Disabled("Prism tests are disabled") @Test fun disconnectEmail() { - val client = - CasParserOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() + val client = CasParserOkHttpClient.builder().apiKey("My API Key").build() val inboxService = client.inbox() val response = @@ -76,11 +61,7 @@ internal class InboxServiceTest { @Disabled("Prism tests are disabled") @Test fun listCasFiles() { - val client = - CasParserOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() + val client = CasParserOkHttpClient.builder().apiKey("My API Key").build() val inboxService = client.inbox() val response = diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/KfintechServiceTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/KfintechServiceTest.kt index 963c6f6..15b7879 100644 --- a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/KfintechServiceTest.kt +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/KfintechServiceTest.kt @@ -2,24 +2,17 @@ package com.cas_parser.api.services.blocking -import com.cas_parser.api.TestServerExtension import com.cas_parser.api.client.okhttp.CasParserOkHttpClient import com.cas_parser.api.models.kfintech.KfintechGenerateCasParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith -@ExtendWith(TestServerExtension::class) internal class KfintechServiceTest { @Disabled("Prism tests are disabled") @Test fun generateCas() { - val client = - CasParserOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() + val client = CasParserOkHttpClient.builder().apiKey("My API Key").build() val kfintechService = client.kfintech() val response = diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/LogServiceTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/LogServiceTest.kt index 20549fa..fe5349c 100644 --- a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/LogServiceTest.kt +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/LogServiceTest.kt @@ -2,26 +2,19 @@ package com.cas_parser.api.services.blocking -import com.cas_parser.api.TestServerExtension import com.cas_parser.api.client.okhttp.CasParserOkHttpClient import com.cas_parser.api.models.logs.LogCreateParams import com.cas_parser.api.models.logs.LogGetSummaryParams import java.time.OffsetDateTime import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith -@ExtendWith(TestServerExtension::class) internal class LogServiceTest { @Disabled("Prism tests are disabled") @Test fun create() { - val client = - CasParserOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() + val client = CasParserOkHttpClient.builder().apiKey("My API Key").build() val logService = client.logs() val log = @@ -39,11 +32,7 @@ internal class LogServiceTest { @Disabled("Prism tests are disabled") @Test fun getSummary() { - val client = - CasParserOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() + val client = CasParserOkHttpClient.builder().apiKey("My API Key").build() val logService = client.logs() val response = diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/NsdlServiceTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/NsdlServiceTest.kt index 44b520c..8ae0dc3 100644 --- a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/NsdlServiceTest.kt +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/NsdlServiceTest.kt @@ -2,24 +2,17 @@ package com.cas_parser.api.services.blocking -import com.cas_parser.api.TestServerExtension import com.cas_parser.api.client.okhttp.CasParserOkHttpClient import com.cas_parser.api.models.nsdl.NsdlParseParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith -@ExtendWith(TestServerExtension::class) internal class NsdlServiceTest { @Disabled("Prism tests are disabled") @Test fun parse() { - val client = - CasParserOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() + val client = CasParserOkHttpClient.builder().apiKey("My API Key").build() val nsdlService = client.nsdl() val unifiedResponse = diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/SmartServiceTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/SmartServiceTest.kt index 0f96eb7..d1f2d99 100644 --- a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/SmartServiceTest.kt +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/SmartServiceTest.kt @@ -2,24 +2,17 @@ package com.cas_parser.api.services.blocking -import com.cas_parser.api.TestServerExtension import com.cas_parser.api.client.okhttp.CasParserOkHttpClient import com.cas_parser.api.models.smart.SmartParseCasPdfParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith -@ExtendWith(TestServerExtension::class) internal class SmartServiceTest { @Disabled("Prism tests are disabled") @Test fun parseCasPdf() { - val client = - CasParserOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() + val client = CasParserOkHttpClient.builder().apiKey("My API Key").build() val smartService = client.smart() val unifiedResponse = diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/VerifyTokenServiceTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/VerifyTokenServiceTest.kt index 05a1f9f..485ae70 100644 --- a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/VerifyTokenServiceTest.kt +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/VerifyTokenServiceTest.kt @@ -2,23 +2,16 @@ package com.cas_parser.api.services.blocking -import com.cas_parser.api.TestServerExtension import com.cas_parser.api.client.okhttp.CasParserOkHttpClient import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith -@ExtendWith(TestServerExtension::class) internal class VerifyTokenServiceTest { @Disabled("Prism tests are disabled") @Test fun verify() { - val client = - CasParserOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() + val client = CasParserOkHttpClient.builder().apiKey("My API Key").build() val verifyTokenService = client.verifyToken() val response = verifyTokenService.verify() diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/cdsl/FetchServiceTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/cdsl/FetchServiceTest.kt index eedc3dd..1c83f66 100644 --- a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/cdsl/FetchServiceTest.kt +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/cdsl/FetchServiceTest.kt @@ -2,25 +2,18 @@ package com.cas_parser.api.services.blocking.cdsl -import com.cas_parser.api.TestServerExtension import com.cas_parser.api.client.okhttp.CasParserOkHttpClient import com.cas_parser.api.models.cdsl.fetch.FetchRequestOtpParams import com.cas_parser.api.models.cdsl.fetch.FetchVerifyOtpParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith -@ExtendWith(TestServerExtension::class) internal class FetchServiceTest { @Disabled("Prism tests are disabled") @Test fun requestOtp() { - val client = - CasParserOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() + val client = CasParserOkHttpClient.builder().apiKey("My API Key").build() val fetchService = client.cdsl().fetch() val response = @@ -38,11 +31,7 @@ internal class FetchServiceTest { @Disabled("Prism tests are disabled") @Test fun verifyOtp() { - val client = - CasParserOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() + val client = CasParserOkHttpClient.builder().apiKey("My API Key").build() val fetchService = client.cdsl().fetch() val response = diff --git a/scripts/mock b/scripts/mock deleted file mode 100755 index 0b28f6e..0000000 --- a/scripts/mock +++ /dev/null @@ -1,41 +0,0 @@ -#!/usr/bin/env bash - -set -e - -cd "$(dirname "$0")/.." - -if [[ -n "$1" && "$1" != '--'* ]]; then - URL="$1" - shift -else - URL="$(grep 'openapi_spec_url' .stats.yml | cut -d' ' -f2)" -fi - -# Check if the URL is empty -if [ -z "$URL" ]; then - echo "Error: No OpenAPI spec path/url provided or found in .stats.yml" - exit 1 -fi - -echo "==> Starting mock server with URL ${URL}" - -# Run prism mock on the given spec -if [ "$1" == "--daemon" ]; then - npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock "$URL" &> .prism.log & - - # Wait for server to come online - echo -n "Waiting for server" - while ! grep -q "✖ fatal\|Prism is listening" ".prism.log" ; do - echo -n "." - sleep 0.1 - done - - if grep -q "✖ fatal" ".prism.log"; then - cat .prism.log - exit 1 - fi - - echo -else - npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock "$URL" -fi diff --git a/scripts/test b/scripts/test index 047bc1d..904aea6 100755 --- a/scripts/test +++ b/scripts/test @@ -4,53 +4,7 @@ set -e cd "$(dirname "$0")/.." -RED='\033[0;31m' -GREEN='\033[0;32m' -YELLOW='\033[0;33m' -NC='\033[0m' # No Color -function prism_is_running() { - curl --silent "http://localhost:4010" >/dev/null 2>&1 -} - -kill_server_on_port() { - pids=$(lsof -t -i tcp:"$1" || echo "") - if [ "$pids" != "" ]; then - kill "$pids" - echo "Stopped $pids." - fi -} - -function is_overriding_api_base_url() { - [ -n "$TEST_API_BASE_URL" ] -} - -if ! is_overriding_api_base_url && ! prism_is_running ; then - # When we exit this script, make sure to kill the background mock server process - trap 'kill_server_on_port 4010' EXIT - - # Start the dev server - ./scripts/mock --daemon -fi - -if is_overriding_api_base_url ; then - echo -e "${GREEN}✔ Running tests against ${TEST_API_BASE_URL}${NC}" - echo -elif ! prism_is_running ; then - echo -e "${RED}ERROR:${NC} The test suite will not run without a mock Prism server" - echo -e "running against your OpenAPI spec." - echo - echo -e "To run the server, pass in the path or url of your OpenAPI" - echo -e "spec to the prism command:" - echo - echo -e " \$ ${YELLOW}npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock path/to/your.openapi.yml${NC}" - echo - - exit 1 -else - echo -e "${GREEN}✔ Mock prism server is running with your OpenAPI spec${NC}" - echo -fi echo "==> Running tests" ./gradlew test "$@" From e7286da78e71c2750514686fb39e2b1a0b5140af Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 20 Feb 2026 05:23:57 +0000 Subject: [PATCH 08/14] chore: update mock server docs --- .../com/cas_parser/api/services/ServiceParamsTest.kt | 2 +- .../api/services/async/AccessTokenServiceAsyncTest.kt | 2 +- .../api/services/async/CamsKfintechServiceAsyncTest.kt | 2 +- .../cas_parser/api/services/async/CdslServiceAsyncTest.kt | 2 +- .../api/services/async/ContractNoteServiceAsyncTest.kt | 2 +- .../api/services/async/CreditServiceAsyncTest.kt | 2 +- .../api/services/async/InboxServiceAsyncTest.kt | 8 ++++---- .../api/services/async/KfintechServiceAsyncTest.kt | 2 +- .../cas_parser/api/services/async/LogServiceAsyncTest.kt | 4 ++-- .../cas_parser/api/services/async/NsdlServiceAsyncTest.kt | 2 +- .../api/services/async/SmartServiceAsyncTest.kt | 2 +- .../api/services/async/VerifyTokenServiceAsyncTest.kt | 2 +- .../api/services/async/cdsl/FetchServiceAsyncTest.kt | 4 ++-- .../api/services/blocking/AccessTokenServiceTest.kt | 2 +- .../api/services/blocking/CamsKfintechServiceTest.kt | 2 +- .../cas_parser/api/services/blocking/CdslServiceTest.kt | 2 +- .../api/services/blocking/ContractNoteServiceTest.kt | 2 +- .../cas_parser/api/services/blocking/CreditServiceTest.kt | 2 +- .../cas_parser/api/services/blocking/InboxServiceTest.kt | 8 ++++---- .../api/services/blocking/KfintechServiceTest.kt | 2 +- .../cas_parser/api/services/blocking/LogServiceTest.kt | 4 ++-- .../cas_parser/api/services/blocking/NsdlServiceTest.kt | 2 +- .../cas_parser/api/services/blocking/SmartServiceTest.kt | 2 +- .../api/services/blocking/VerifyTokenServiceTest.kt | 2 +- .../api/services/blocking/cdsl/FetchServiceTest.kt | 4 ++-- 25 files changed, 35 insertions(+), 35 deletions(-) diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/ServiceParamsTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/ServiceParamsTest.kt index 2d2074d..4cdd376 100644 --- a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/ServiceParamsTest.kt +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/ServiceParamsTest.kt @@ -36,7 +36,7 @@ internal class ServiceParamsTest { .build() } - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun check() { val creditService = client.credits() diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/AccessTokenServiceAsyncTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/AccessTokenServiceAsyncTest.kt index bb9558e..c795a5c 100644 --- a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/AccessTokenServiceAsyncTest.kt +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/AccessTokenServiceAsyncTest.kt @@ -9,7 +9,7 @@ import org.junit.jupiter.api.Test internal class AccessTokenServiceAsyncTest { - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun create() { val client = CasParserOkHttpClientAsync.builder().apiKey("My API Key").build() diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/CamsKfintechServiceAsyncTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/CamsKfintechServiceAsyncTest.kt index 5597a2e..046850e 100644 --- a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/CamsKfintechServiceAsyncTest.kt +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/CamsKfintechServiceAsyncTest.kt @@ -9,7 +9,7 @@ import org.junit.jupiter.api.Test internal class CamsKfintechServiceAsyncTest { - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun parse() { val client = CasParserOkHttpClientAsync.builder().apiKey("My API Key").build() diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/CdslServiceAsyncTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/CdslServiceAsyncTest.kt index 33d3092..35d78b1 100644 --- a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/CdslServiceAsyncTest.kt +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/CdslServiceAsyncTest.kt @@ -9,7 +9,7 @@ import org.junit.jupiter.api.Test internal class CdslServiceAsyncTest { - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun parsePdf() { val client = CasParserOkHttpClientAsync.builder().apiKey("My API Key").build() diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/ContractNoteServiceAsyncTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/ContractNoteServiceAsyncTest.kt index 02dc255..1d51efe 100644 --- a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/ContractNoteServiceAsyncTest.kt +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/ContractNoteServiceAsyncTest.kt @@ -9,7 +9,7 @@ import org.junit.jupiter.api.Test internal class ContractNoteServiceAsyncTest { - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun parse() { val client = CasParserOkHttpClientAsync.builder().apiKey("My API Key").build() diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/CreditServiceAsyncTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/CreditServiceAsyncTest.kt index c831f4e..6c9e4d8 100644 --- a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/CreditServiceAsyncTest.kt +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/CreditServiceAsyncTest.kt @@ -8,7 +8,7 @@ import org.junit.jupiter.api.Test internal class CreditServiceAsyncTest { - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun check() { val client = CasParserOkHttpClientAsync.builder().apiKey("My API Key").build() diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/InboxServiceAsyncTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/InboxServiceAsyncTest.kt index f80c8f1..47362c1 100644 --- a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/InboxServiceAsyncTest.kt +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/InboxServiceAsyncTest.kt @@ -13,7 +13,7 @@ import org.junit.jupiter.api.Test internal class InboxServiceAsyncTest { - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun checkConnectionStatus() { val client = CasParserOkHttpClientAsync.builder().apiKey("My API Key").build() @@ -28,7 +28,7 @@ internal class InboxServiceAsyncTest { response.validate() } - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun connectEmail() { val client = CasParserOkHttpClientAsync.builder().apiKey("My API Key").build() @@ -46,7 +46,7 @@ internal class InboxServiceAsyncTest { response.validate() } - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun disconnectEmail() { val client = CasParserOkHttpClientAsync.builder().apiKey("My API Key").build() @@ -61,7 +61,7 @@ internal class InboxServiceAsyncTest { response.validate() } - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun listCasFiles() { val client = CasParserOkHttpClientAsync.builder().apiKey("My API Key").build() diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/KfintechServiceAsyncTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/KfintechServiceAsyncTest.kt index 3e8ebf1..0632267 100644 --- a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/KfintechServiceAsyncTest.kt +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/KfintechServiceAsyncTest.kt @@ -9,7 +9,7 @@ import org.junit.jupiter.api.Test internal class KfintechServiceAsyncTest { - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun generateCas() { val client = CasParserOkHttpClientAsync.builder().apiKey("My API Key").build() diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/LogServiceAsyncTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/LogServiceAsyncTest.kt index 7779a3c..532be8d 100644 --- a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/LogServiceAsyncTest.kt +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/LogServiceAsyncTest.kt @@ -11,7 +11,7 @@ import org.junit.jupiter.api.Test internal class LogServiceAsyncTest { - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun create() { val client = CasParserOkHttpClientAsync.builder().apiKey("My API Key").build() @@ -30,7 +30,7 @@ internal class LogServiceAsyncTest { log.validate() } - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun getSummary() { val client = CasParserOkHttpClientAsync.builder().apiKey("My API Key").build() diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/NsdlServiceAsyncTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/NsdlServiceAsyncTest.kt index 4b569bc..de5bda4 100644 --- a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/NsdlServiceAsyncTest.kt +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/NsdlServiceAsyncTest.kt @@ -9,7 +9,7 @@ import org.junit.jupiter.api.Test internal class NsdlServiceAsyncTest { - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun parse() { val client = CasParserOkHttpClientAsync.builder().apiKey("My API Key").build() diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/SmartServiceAsyncTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/SmartServiceAsyncTest.kt index c574f20..db32247 100644 --- a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/SmartServiceAsyncTest.kt +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/SmartServiceAsyncTest.kt @@ -9,7 +9,7 @@ import org.junit.jupiter.api.Test internal class SmartServiceAsyncTest { - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun parseCasPdf() { val client = CasParserOkHttpClientAsync.builder().apiKey("My API Key").build() diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/VerifyTokenServiceAsyncTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/VerifyTokenServiceAsyncTest.kt index 028abdd..3d7800c 100644 --- a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/VerifyTokenServiceAsyncTest.kt +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/VerifyTokenServiceAsyncTest.kt @@ -8,7 +8,7 @@ import org.junit.jupiter.api.Test internal class VerifyTokenServiceAsyncTest { - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun verify() { val client = CasParserOkHttpClientAsync.builder().apiKey("My API Key").build() diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/cdsl/FetchServiceAsyncTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/cdsl/FetchServiceAsyncTest.kt index aee0987..a7ac051 100644 --- a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/cdsl/FetchServiceAsyncTest.kt +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/cdsl/FetchServiceAsyncTest.kt @@ -10,7 +10,7 @@ import org.junit.jupiter.api.Test internal class FetchServiceAsyncTest { - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun requestOtp() { val client = CasParserOkHttpClientAsync.builder().apiKey("My API Key").build() @@ -29,7 +29,7 @@ internal class FetchServiceAsyncTest { response.validate() } - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun verifyOtp() { val client = CasParserOkHttpClientAsync.builder().apiKey("My API Key").build() diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/AccessTokenServiceTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/AccessTokenServiceTest.kt index b236856..f7c9696 100644 --- a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/AccessTokenServiceTest.kt +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/AccessTokenServiceTest.kt @@ -9,7 +9,7 @@ import org.junit.jupiter.api.Test internal class AccessTokenServiceTest { - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun create() { val client = CasParserOkHttpClient.builder().apiKey("My API Key").build() diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/CamsKfintechServiceTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/CamsKfintechServiceTest.kt index fc27735..f23fd75 100644 --- a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/CamsKfintechServiceTest.kt +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/CamsKfintechServiceTest.kt @@ -9,7 +9,7 @@ import org.junit.jupiter.api.Test internal class CamsKfintechServiceTest { - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun parse() { val client = CasParserOkHttpClient.builder().apiKey("My API Key").build() diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/CdslServiceTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/CdslServiceTest.kt index 7529333..87dffc2 100644 --- a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/CdslServiceTest.kt +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/CdslServiceTest.kt @@ -9,7 +9,7 @@ import org.junit.jupiter.api.Test internal class CdslServiceTest { - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun parsePdf() { val client = CasParserOkHttpClient.builder().apiKey("My API Key").build() diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/ContractNoteServiceTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/ContractNoteServiceTest.kt index 93bf156..effc5f4 100644 --- a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/ContractNoteServiceTest.kt +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/ContractNoteServiceTest.kt @@ -9,7 +9,7 @@ import org.junit.jupiter.api.Test internal class ContractNoteServiceTest { - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun parse() { val client = CasParserOkHttpClient.builder().apiKey("My API Key").build() diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/CreditServiceTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/CreditServiceTest.kt index faff248..94239a3 100644 --- a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/CreditServiceTest.kt +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/CreditServiceTest.kt @@ -8,7 +8,7 @@ import org.junit.jupiter.api.Test internal class CreditServiceTest { - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun check() { val client = CasParserOkHttpClient.builder().apiKey("My API Key").build() diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/InboxServiceTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/InboxServiceTest.kt index 177e27d..dc041fb 100644 --- a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/InboxServiceTest.kt +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/InboxServiceTest.kt @@ -13,7 +13,7 @@ import org.junit.jupiter.api.Test internal class InboxServiceTest { - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun checkConnectionStatus() { val client = CasParserOkHttpClient.builder().apiKey("My API Key").build() @@ -27,7 +27,7 @@ internal class InboxServiceTest { response.validate() } - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun connectEmail() { val client = CasParserOkHttpClient.builder().apiKey("My API Key").build() @@ -44,7 +44,7 @@ internal class InboxServiceTest { response.validate() } - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun disconnectEmail() { val client = CasParserOkHttpClient.builder().apiKey("My API Key").build() @@ -58,7 +58,7 @@ internal class InboxServiceTest { response.validate() } - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun listCasFiles() { val client = CasParserOkHttpClient.builder().apiKey("My API Key").build() diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/KfintechServiceTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/KfintechServiceTest.kt index 15b7879..ddc39f7 100644 --- a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/KfintechServiceTest.kt +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/KfintechServiceTest.kt @@ -9,7 +9,7 @@ import org.junit.jupiter.api.Test internal class KfintechServiceTest { - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun generateCas() { val client = CasParserOkHttpClient.builder().apiKey("My API Key").build() diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/LogServiceTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/LogServiceTest.kt index fe5349c..2ef5c48 100644 --- a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/LogServiceTest.kt +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/LogServiceTest.kt @@ -11,7 +11,7 @@ import org.junit.jupiter.api.Test internal class LogServiceTest { - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun create() { val client = CasParserOkHttpClient.builder().apiKey("My API Key").build() @@ -29,7 +29,7 @@ internal class LogServiceTest { log.validate() } - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun getSummary() { val client = CasParserOkHttpClient.builder().apiKey("My API Key").build() diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/NsdlServiceTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/NsdlServiceTest.kt index 8ae0dc3..9121446 100644 --- a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/NsdlServiceTest.kt +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/NsdlServiceTest.kt @@ -9,7 +9,7 @@ import org.junit.jupiter.api.Test internal class NsdlServiceTest { - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun parse() { val client = CasParserOkHttpClient.builder().apiKey("My API Key").build() diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/SmartServiceTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/SmartServiceTest.kt index d1f2d99..d28949d 100644 --- a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/SmartServiceTest.kt +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/SmartServiceTest.kt @@ -9,7 +9,7 @@ import org.junit.jupiter.api.Test internal class SmartServiceTest { - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun parseCasPdf() { val client = CasParserOkHttpClient.builder().apiKey("My API Key").build() diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/VerifyTokenServiceTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/VerifyTokenServiceTest.kt index 485ae70..19af27d 100644 --- a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/VerifyTokenServiceTest.kt +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/VerifyTokenServiceTest.kt @@ -8,7 +8,7 @@ import org.junit.jupiter.api.Test internal class VerifyTokenServiceTest { - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun verify() { val client = CasParserOkHttpClient.builder().apiKey("My API Key").build() diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/cdsl/FetchServiceTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/cdsl/FetchServiceTest.kt index 1c83f66..8c93c2a 100644 --- a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/cdsl/FetchServiceTest.kt +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/cdsl/FetchServiceTest.kt @@ -10,7 +10,7 @@ import org.junit.jupiter.api.Test internal class FetchServiceTest { - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun requestOtp() { val client = CasParserOkHttpClient.builder().apiKey("My API Key").build() @@ -28,7 +28,7 @@ internal class FetchServiceTest { response.validate() } - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun verifyOtp() { val client = CasParserOkHttpClient.builder().apiKey("My API Key").build() From 8d2cb43b11b1923624fdc32f7433115f5b20cf37 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 21 Feb 2026 21:17:40 +0000 Subject: [PATCH 09/14] feat(api): api update --- .stats.yml | 6 +- README.md | 70 +- .../accesstoken/AccessTokenCreateParams.kt | 410 ----------- .../accesstoken/AccessTokenCreateResponse.kt | 239 ------- .../api/models/credits/CreditCheckParams.kt | 219 ------ .../api/models/credits/CreditCheckResponse.kt | 387 ---------- .../api/models/logs/LogCreateParams.kt | 528 -------------- .../api/models/logs/LogCreateResponse.kt | 578 --------------- .../api/models/logs/LogGetSummaryParams.kt | 468 ------------- .../api/models/logs/LogGetSummaryResponse.kt | 663 ------------------ .../verifytoken/VerifyTokenVerifyParams.kt | 211 ------ .../verifytoken/VerifyTokenVerifyResponse.kt | 240 ------- .../services/async/AccessTokenServiceAsync.kt | 60 -- .../async/AccessTokenServiceAsyncImpl.kt | 56 -- .../api/services/async/CreditServiceAsync.kt | 57 -- .../services/async/CreditServiceAsyncImpl.kt | 56 -- .../api/services/async/LogServiceAsync.kt | 103 --- .../api/services/async/LogServiceAsyncImpl.kt | 96 --- .../services/async/VerifyTokenServiceAsync.kt | 49 -- .../async/VerifyTokenServiceAsyncImpl.kt | 56 -- .../services/blocking/AccessTokenService.kt | 60 -- .../blocking/AccessTokenServiceImpl.kt | 52 -- .../api/services/blocking/CreditService.kt | 56 -- .../services/blocking/CreditServiceImpl.kt | 52 -- .../api/services/blocking/LogService.kt | 102 --- .../api/services/blocking/LogServiceImpl.kt | 89 --- .../services/blocking/VerifyTokenService.kt | 49 -- .../blocking/VerifyTokenServiceImpl.kt | 52 -- .../AccessTokenCreateParamsTest.kt | 30 - .../AccessTokenCreateResponseTest.kt | 45 -- .../models/credits/CreditCheckParamsTest.kt | 13 - .../models/credits/CreditCheckResponseTest.kt | 61 -- .../api/models/logs/LogCreateParamsTest.kt | 42 -- .../api/models/logs/LogCreateResponseTest.kt | 74 -- .../models/logs/LogGetSummaryParamsTest.kt | 39 -- .../models/logs/LogGetSummaryResponseTest.kt | 78 --- .../VerifyTokenVerifyParamsTest.kt | 13 - .../VerifyTokenVerifyResponseTest.kt | 44 -- .../api/services/ErrorHandlingTest.kt | 256 +++++-- .../api/services/ServiceParamsTest.kt | 13 +- .../async/AccessTokenServiceAsyncTest.kt | 26 - .../services/async/CreditServiceAsyncTest.kt | 22 - .../api/services/async/LogServiceAsyncTest.kt | 50 -- .../async/VerifyTokenServiceAsyncTest.kt | 22 - .../blocking/AccessTokenServiceTest.kt | 23 - .../services/blocking/CreditServiceTest.kt | 21 - .../api/services/blocking/LogServiceTest.kt | 48 -- .../blocking/VerifyTokenServiceTest.kt | 21 - .../api/proguard/ProGuardCompatibilityTest.kt | 25 +- 49 files changed, 258 insertions(+), 5772 deletions(-) delete mode 100644 cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/accesstoken/AccessTokenCreateParams.kt delete mode 100644 cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/accesstoken/AccessTokenCreateResponse.kt delete mode 100644 cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/credits/CreditCheckParams.kt delete mode 100644 cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/credits/CreditCheckResponse.kt delete mode 100644 cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/logs/LogCreateParams.kt delete mode 100644 cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/logs/LogCreateResponse.kt delete mode 100644 cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/logs/LogGetSummaryParams.kt delete mode 100644 cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/logs/LogGetSummaryResponse.kt delete mode 100644 cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/verifytoken/VerifyTokenVerifyParams.kt delete mode 100644 cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/verifytoken/VerifyTokenVerifyResponse.kt delete mode 100644 cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/accesstoken/AccessTokenCreateParamsTest.kt delete mode 100644 cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/accesstoken/AccessTokenCreateResponseTest.kt delete mode 100644 cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/credits/CreditCheckParamsTest.kt delete mode 100644 cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/credits/CreditCheckResponseTest.kt delete mode 100644 cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/logs/LogCreateParamsTest.kt delete mode 100644 cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/logs/LogCreateResponseTest.kt delete mode 100644 cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/logs/LogGetSummaryParamsTest.kt delete mode 100644 cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/logs/LogGetSummaryResponseTest.kt delete mode 100644 cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/verifytoken/VerifyTokenVerifyParamsTest.kt delete mode 100644 cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/verifytoken/VerifyTokenVerifyResponseTest.kt delete mode 100644 cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/AccessTokenServiceAsyncTest.kt delete mode 100644 cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/CreditServiceAsyncTest.kt delete mode 100644 cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/LogServiceAsyncTest.kt delete mode 100644 cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/VerifyTokenServiceAsyncTest.kt delete mode 100644 cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/AccessTokenServiceTest.kt delete mode 100644 cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/CreditServiceTest.kt delete mode 100644 cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/LogServiceTest.kt delete mode 100644 cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/VerifyTokenServiceTest.kt diff --git a/.stats.yml b/.stats.yml index 56f5a81..80a6900 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ -configured_endpoints: 17 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cas-parser%2Fcas-parser-56b0f699c5437d9e5326626d35dfc972c17d01f12cb416c7f4854c8ea6d0e95e.yml -openapi_spec_hash: 158f405c1880706266d83e6ff16b9d2f +configured_endpoints: 12 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cas-parser%2Fcas-parser-6a9d3b677dcfb856dc571865c34b3fe401e4d7f0d799edfc743acb9a55800bd0.yml +openapi_spec_hash: 037703a6c741e4310fda3f57c22fa51e config_hash: 41c337f5cda03b13880617490f82bad0 diff --git a/README.md b/README.md index 212151b..50e5c0c 100644 --- a/README.md +++ b/README.md @@ -57,14 +57,14 @@ This library requires Java 8 or later. ```java import com.cas_parser.api.client.CasParserClient; import com.cas_parser.api.client.okhttp.CasParserOkHttpClient; -import com.cas_parser.api.models.credits.CreditCheckParams; -import com.cas_parser.api.models.credits.CreditCheckResponse; +import com.cas_parser.api.models.camskfintech.CamsKfintechParseParams; +import com.cas_parser.api.models.camskfintech.UnifiedResponse; // Configures using the `casparser.apiKey` and `casparser.baseUrl` system properties // Or configures using the `CAS_PARSER_API_KEY` and `CAS_PARSER_BASE_URL` environment variables CasParserClient client = CasParserOkHttpClient.fromEnv(); -CreditCheckResponse response = client.credits().check(); +UnifiedResponse unifiedResponse = client.camsKfintech().parse(); ``` ## Client configuration @@ -137,7 +137,7 @@ The `withOptions()` method does not affect the original client or service. To send a request to the Cas Parser API, build an instance of some `Params` class and pass it to the corresponding client method. When the response is received, it will be deserialized into an instance of a Java class. -For example, `client.credits().check(...)` should be called with an instance of `CreditCheckParams`, and it will return an instance of `CreditCheckResponse`. +For example, `client.camsKfintech().parse(...)` should be called with an instance of `CamsKfintechParseParams`, and it will return an instance of `UnifiedResponse`. ## Immutability @@ -154,15 +154,15 @@ The default client is synchronous. To switch to asynchronous execution, call the ```java import com.cas_parser.api.client.CasParserClient; import com.cas_parser.api.client.okhttp.CasParserOkHttpClient; -import com.cas_parser.api.models.credits.CreditCheckParams; -import com.cas_parser.api.models.credits.CreditCheckResponse; +import com.cas_parser.api.models.camskfintech.CamsKfintechParseParams; +import com.cas_parser.api.models.camskfintech.UnifiedResponse; import java.util.concurrent.CompletableFuture; // Configures using the `casparser.apiKey` and `casparser.baseUrl` system properties // Or configures using the `CAS_PARSER_API_KEY` and `CAS_PARSER_BASE_URL` environment variables CasParserClient client = CasParserOkHttpClient.fromEnv(); -CompletableFuture response = client.async().credits().check(); +CompletableFuture unifiedResponse = client.async().camsKfintech().parse(); ``` Or create an asynchronous client from the beginning: @@ -170,15 +170,15 @@ Or create an asynchronous client from the beginning: ```java import com.cas_parser.api.client.CasParserClientAsync; import com.cas_parser.api.client.okhttp.CasParserOkHttpClientAsync; -import com.cas_parser.api.models.credits.CreditCheckParams; -import com.cas_parser.api.models.credits.CreditCheckResponse; +import com.cas_parser.api.models.camskfintech.CamsKfintechParseParams; +import com.cas_parser.api.models.camskfintech.UnifiedResponse; import java.util.concurrent.CompletableFuture; // Configures using the `casparser.apiKey` and `casparser.baseUrl` system properties // Or configures using the `CAS_PARSER_API_KEY` and `CAS_PARSER_BASE_URL` environment variables CasParserClientAsync client = CasParserOkHttpClientAsync.fromEnv(); -CompletableFuture response = client.credits().check(); +CompletableFuture unifiedResponse = client.camsKfintech().parse(); ``` The asynchronous client supports the same options as the synchronous one, except most methods return `CompletableFuture`s. @@ -192,21 +192,21 @@ To access this data, prefix any HTTP method call on a client or service with `wi ```java import com.cas_parser.api.core.http.Headers; import com.cas_parser.api.core.http.HttpResponseFor; -import com.cas_parser.api.models.credits.CreditCheckParams; -import com.cas_parser.api.models.credits.CreditCheckResponse; +import com.cas_parser.api.models.camskfintech.CamsKfintechParseParams; +import com.cas_parser.api.models.camskfintech.UnifiedResponse; -HttpResponseFor response = client.credits().withRawResponse().check(); +HttpResponseFor unifiedResponse = client.camsKfintech().withRawResponse().parse(); -int statusCode = response.statusCode(); -Headers headers = response.headers(); +int statusCode = unifiedResponse.statusCode(); +Headers headers = unifiedResponse.headers(); ``` You can still deserialize the response into an instance of a Java class if needed: ```java -import com.cas_parser.api.models.credits.CreditCheckResponse; +import com.cas_parser.api.models.camskfintech.UnifiedResponse; -CreditCheckResponse parsedResponse = response.parse(); +UnifiedResponse parsedUnifiedResponse = unifiedResponse.parse(); ``` ## Error handling @@ -304,9 +304,9 @@ Requests time out after 1 minute by default. To set a custom timeout, configure the method call using the `timeout` method: ```java -import com.cas_parser.api.models.credits.CreditCheckResponse; +import com.cas_parser.api.models.camskfintech.UnifiedResponse; -CreditCheckResponse response = client.credits().check(RequestOptions.builder().timeout(Duration.ofSeconds(30)).build()); +UnifiedResponse unifiedResponse = client.camsKfintech().parse(RequestOptions.builder().timeout(Duration.ofSeconds(30)).build()); ``` Or configure the default for all method calls at the client level: @@ -443,9 +443,9 @@ To set undocumented parameters, call the `putAdditionalHeader`, `putAdditionalQu ```java import com.cas_parser.api.core.JsonValue; -import com.cas_parser.api.models.credits.CreditCheckParams; +import com.cas_parser.api.models.camskfintech.CamsKfintechParseParams; -CreditCheckParams params = CreditCheckParams.builder() +CamsKfintechParseParams params = CamsKfintechParseParams.builder() .putAdditionalHeader("Secret-Header", "42") .putAdditionalQueryParam("secret_query_param", "42") .putAdditionalBodyProperty("secretProperty", JsonValue.from("42")) @@ -457,9 +457,9 @@ These can be accessed on the built object later using the `_additionalHeaders()` To set a documented parameter or property to an undocumented or not yet supported _value_, pass a [`JsonValue`](cas-parser-java-core/src/main/kotlin/com/cas_parser/api/core/Values.kt) object to its setter: ```java -import com.cas_parser.api.models.credits.CreditCheckParams; +import com.cas_parser.api.models.camskfintech.CamsKfintechParseParams; -CreditCheckParams params = CreditCheckParams.builder().build(); +CamsKfintechParseParams params = CamsKfintechParseParams.builder().build(); ``` The most straightforward way to create a [`JsonValue`](cas-parser-java-core/src/main/kotlin/com/cas_parser/api/core/Values.kt) is using its `from(...)` method: @@ -507,10 +507,10 @@ To forcibly omit a required parameter or property, pass [`JsonMissing`](cas-pars ```java import com.cas_parser.api.core.JsonMissing; +import com.cas_parser.api.models.camskfintech.CamsKfintechParseParams; import com.cas_parser.api.models.cdsl.fetch.FetchRequestOtpParams; -import com.cas_parser.api.models.credits.CreditCheckParams; -CreditCheckParams params = FetchRequestOtpParams.builder() +CamsKfintechParseParams params = FetchRequestOtpParams.builder() .dob("1990-01-15") .pan("ABCDE1234F") .boId(JsonMissing.of()) @@ -525,7 +525,7 @@ To access undocumented response properties, call the `_additionalProperties()` m import com.cas_parser.api.core.JsonValue; import java.util.Map; -Map additionalProperties = client.credits().check(params)._additionalProperties(); +Map additionalProperties = client.camsKfintech().parse(params)._additionalProperties(); JsonValue secretPropertyValue = additionalProperties.get("secretProperty"); String result = secretPropertyValue.accept(new JsonValue.Visitor<>() { @@ -555,19 +555,19 @@ To access a property's raw JSON value, which may be undocumented, call its `_` p import com.cas_parser.api.core.JsonField; import java.util.Optional; -JsonField field = client.credits().check(params)._field(); +JsonField password = client.camsKfintech().parse(params)._password(); -if (field.isMissing()) { +if (password.isMissing()) { // The property is absent from the JSON response -} else if (field.isNull()) { +} else if (password.isNull()) { // The property was set to literal null } else { // Check if value was provided as a string // Other methods include `asNumber()`, `asBoolean()`, etc. - Optional jsonString = field.asString(); + Optional jsonString = password.asString(); // Try to deserialize into a custom type - MyClass myObject = field.asUnknown().orElseThrow().convert(MyClass.class); + MyClass myObject = password.asUnknown().orElseThrow().convert(MyClass.class); } ``` @@ -580,17 +580,17 @@ By default, the SDK will not throw an exception in this case. It will throw [`Ca If you would prefer to check that the response is completely well-typed upfront, then either call `validate()`: ```java -import com.cas_parser.api.models.credits.CreditCheckResponse; +import com.cas_parser.api.models.camskfintech.UnifiedResponse; -CreditCheckResponse response = client.credits().check(params).validate(); +UnifiedResponse unifiedResponse = client.camsKfintech().parse(params).validate(); ``` Or configure the method call to validate the response using the `responseValidation` method: ```java -import com.cas_parser.api.models.credits.CreditCheckResponse; +import com.cas_parser.api.models.camskfintech.UnifiedResponse; -CreditCheckResponse response = client.credits().check(RequestOptions.builder().responseValidation(true).build()); +UnifiedResponse unifiedResponse = client.camsKfintech().parse(RequestOptions.builder().responseValidation(true).build()); ``` Or configure the default for all method calls at the client level: diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/accesstoken/AccessTokenCreateParams.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/accesstoken/AccessTokenCreateParams.kt deleted file mode 100644 index 676dc4d..0000000 --- a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/accesstoken/AccessTokenCreateParams.kt +++ /dev/null @@ -1,410 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.cas_parser.api.models.accesstoken - -import com.cas_parser.api.core.ExcludeMissing -import com.cas_parser.api.core.JsonField -import com.cas_parser.api.core.JsonMissing -import com.cas_parser.api.core.JsonValue -import com.cas_parser.api.core.Params -import com.cas_parser.api.core.http.Headers -import com.cas_parser.api.core.http.QueryParams -import com.cas_parser.api.errors.CasParserInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects -import java.util.Optional - -/** - * Generate a short-lived access token from your API key. - * - * **Use this endpoint from your backend** to create tokens that can be safely passed to - * frontend/SDK. - * - * Access tokens: - * - Are prefixed with `at_` for easy identification - * - Valid for up to 60 minutes - * - Can be used in place of API keys on all v4 endpoints - * - Cannot be used to generate other access tokens - */ -class AccessTokenCreateParams -private constructor( - private val body: Body, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, -) : Params { - - /** - * Token validity in minutes (max 60) - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun expiryMinutes(): Optional = body.expiryMinutes() - - /** - * Returns the raw JSON value of [expiryMinutes]. - * - * Unlike [expiryMinutes], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _expiryMinutes(): JsonField = body._expiryMinutes() - - fun _additionalBodyProperties(): Map = body._additionalProperties() - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders - - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun none(): AccessTokenCreateParams = builder().build() - - /** Returns a mutable builder for constructing an instance of [AccessTokenCreateParams]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AccessTokenCreateParams]. */ - class Builder internal constructor() { - - private var body: Body.Builder = Body.builder() - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - - @JvmSynthetic - internal fun from(accessTokenCreateParams: AccessTokenCreateParams) = apply { - body = accessTokenCreateParams.body.toBuilder() - additionalHeaders = accessTokenCreateParams.additionalHeaders.toBuilder() - additionalQueryParams = accessTokenCreateParams.additionalQueryParams.toBuilder() - } - - /** - * Sets the entire request body. - * - * This is generally only useful if you are already constructing the body separately. - * Otherwise, it's more convenient to use the top-level setters instead: - * - [expiryMinutes] - */ - fun body(body: Body) = apply { this.body = body.toBuilder() } - - /** Token validity in minutes (max 60) */ - fun expiryMinutes(expiryMinutes: Long) = apply { body.expiryMinutes(expiryMinutes) } - - /** - * Sets [Builder.expiryMinutes] to an arbitrary JSON value. - * - * You should usually call [Builder.expiryMinutes] with a well-typed [Long] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun expiryMinutes(expiryMinutes: JsonField) = apply { - body.expiryMinutes(expiryMinutes) - } - - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - /** - * Returns an immutable instance of [AccessTokenCreateParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): AccessTokenCreateParams = - AccessTokenCreateParams( - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), - ) - } - - fun _body(): Body = body - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = additionalQueryParams - - class Body - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val expiryMinutes: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("expiry_minutes") - @ExcludeMissing - expiryMinutes: JsonField = JsonMissing.of() - ) : this(expiryMinutes, mutableMapOf()) - - /** - * Token validity in minutes (max 60) - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun expiryMinutes(): Optional = expiryMinutes.getOptional("expiry_minutes") - - /** - * Returns the raw JSON value of [expiryMinutes]. - * - * Unlike [expiryMinutes], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("expiry_minutes") - @ExcludeMissing - fun _expiryMinutes(): JsonField = expiryMinutes - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Body]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Body]. */ - class Builder internal constructor() { - - private var expiryMinutes: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(body: Body) = apply { - expiryMinutes = body.expiryMinutes - additionalProperties = body.additionalProperties.toMutableMap() - } - - /** Token validity in minutes (max 60) */ - fun expiryMinutes(expiryMinutes: Long) = expiryMinutes(JsonField.of(expiryMinutes)) - - /** - * Sets [Builder.expiryMinutes] to an arbitrary JSON value. - * - * You should usually call [Builder.expiryMinutes] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun expiryMinutes(expiryMinutes: JsonField) = apply { - this.expiryMinutes = expiryMinutes - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Body]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Body = Body(expiryMinutes, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): Body = apply { - if (validated) { - return@apply - } - - expiryMinutes() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CasParserInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = (if (expiryMinutes.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Body && - expiryMinutes == other.expiryMinutes && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(expiryMinutes, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Body{expiryMinutes=$expiryMinutes, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AccessTokenCreateParams && - body == other.body && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams - } - - override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) - - override fun toString() = - "AccessTokenCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" -} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/accesstoken/AccessTokenCreateResponse.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/accesstoken/AccessTokenCreateResponse.kt deleted file mode 100644 index a23d37b..0000000 --- a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/accesstoken/AccessTokenCreateResponse.kt +++ /dev/null @@ -1,239 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.cas_parser.api.models.accesstoken - -import com.cas_parser.api.core.ExcludeMissing -import com.cas_parser.api.core.JsonField -import com.cas_parser.api.core.JsonMissing -import com.cas_parser.api.core.JsonValue -import com.cas_parser.api.errors.CasParserInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects -import java.util.Optional - -class AccessTokenCreateResponse -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val accessToken: JsonField, - private val expiresIn: JsonField, - private val tokenType: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("access_token") - @ExcludeMissing - accessToken: JsonField = JsonMissing.of(), - @JsonProperty("expires_in") @ExcludeMissing expiresIn: JsonField = JsonMissing.of(), - @JsonProperty("token_type") @ExcludeMissing tokenType: JsonField = JsonMissing.of(), - ) : this(accessToken, expiresIn, tokenType, mutableMapOf()) - - /** - * The at_ prefixed access token - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun accessToken(): Optional = accessToken.getOptional("access_token") - - /** - * Token validity in seconds - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun expiresIn(): Optional = expiresIn.getOptional("expires_in") - - /** - * Always "api_key" - token is a drop-in replacement for x-api-key header - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun tokenType(): Optional = tokenType.getOptional("token_type") - - /** - * Returns the raw JSON value of [accessToken]. - * - * Unlike [accessToken], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("access_token") - @ExcludeMissing - fun _accessToken(): JsonField = accessToken - - /** - * Returns the raw JSON value of [expiresIn]. - * - * Unlike [expiresIn], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("expires_in") @ExcludeMissing fun _expiresIn(): JsonField = expiresIn - - /** - * Returns the raw JSON value of [tokenType]. - * - * Unlike [tokenType], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("token_type") @ExcludeMissing fun _tokenType(): JsonField = tokenType - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [AccessTokenCreateResponse]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AccessTokenCreateResponse]. */ - class Builder internal constructor() { - - private var accessToken: JsonField = JsonMissing.of() - private var expiresIn: JsonField = JsonMissing.of() - private var tokenType: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(accessTokenCreateResponse: AccessTokenCreateResponse) = apply { - accessToken = accessTokenCreateResponse.accessToken - expiresIn = accessTokenCreateResponse.expiresIn - tokenType = accessTokenCreateResponse.tokenType - additionalProperties = accessTokenCreateResponse.additionalProperties.toMutableMap() - } - - /** The at_ prefixed access token */ - fun accessToken(accessToken: String) = accessToken(JsonField.of(accessToken)) - - /** - * Sets [Builder.accessToken] to an arbitrary JSON value. - * - * You should usually call [Builder.accessToken] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun accessToken(accessToken: JsonField) = apply { this.accessToken = accessToken } - - /** Token validity in seconds */ - fun expiresIn(expiresIn: Long) = expiresIn(JsonField.of(expiresIn)) - - /** - * Sets [Builder.expiresIn] to an arbitrary JSON value. - * - * You should usually call [Builder.expiresIn] with a well-typed [Long] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun expiresIn(expiresIn: JsonField) = apply { this.expiresIn = expiresIn } - - /** Always "api_key" - token is a drop-in replacement for x-api-key header */ - fun tokenType(tokenType: String) = tokenType(JsonField.of(tokenType)) - - /** - * Sets [Builder.tokenType] to an arbitrary JSON value. - * - * You should usually call [Builder.tokenType] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun tokenType(tokenType: JsonField) = apply { this.tokenType = tokenType } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [AccessTokenCreateResponse]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): AccessTokenCreateResponse = - AccessTokenCreateResponse( - accessToken, - expiresIn, - tokenType, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): AccessTokenCreateResponse = apply { - if (validated) { - return@apply - } - - accessToken() - expiresIn() - tokenType() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CasParserInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (accessToken.asKnown().isPresent) 1 else 0) + - (if (expiresIn.asKnown().isPresent) 1 else 0) + - (if (tokenType.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AccessTokenCreateResponse && - accessToken == other.accessToken && - expiresIn == other.expiresIn && - tokenType == other.tokenType && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(accessToken, expiresIn, tokenType, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AccessTokenCreateResponse{accessToken=$accessToken, expiresIn=$expiresIn, tokenType=$tokenType, additionalProperties=$additionalProperties}" -} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/credits/CreditCheckParams.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/credits/CreditCheckParams.kt deleted file mode 100644 index aa45ce8..0000000 --- a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/credits/CreditCheckParams.kt +++ /dev/null @@ -1,219 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.cas_parser.api.models.credits - -import com.cas_parser.api.core.JsonValue -import com.cas_parser.api.core.Params -import com.cas_parser.api.core.http.Headers -import com.cas_parser.api.core.http.QueryParams -import com.cas_parser.api.core.toImmutable -import java.util.Objects -import java.util.Optional - -/** - * Check your remaining API credits and usage for the current billing period. - * - * Returns: - * - Number of API calls used and remaining credits - * - Credit limit and reset date - * - List of enabled features for your plan - * - * Credits reset at the start of each billing period. - */ -class CreditCheckParams -private constructor( - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, - private val additionalBodyProperties: Map, -) : Params { - - /** Additional body properties to send with the request. */ - fun _additionalBodyProperties(): Map = additionalBodyProperties - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders - - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun none(): CreditCheckParams = builder().build() - - /** Returns a mutable builder for constructing an instance of [CreditCheckParams]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [CreditCheckParams]. */ - class Builder internal constructor() { - - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - private var additionalBodyProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(creditCheckParams: CreditCheckParams) = apply { - additionalHeaders = creditCheckParams.additionalHeaders.toBuilder() - additionalQueryParams = creditCheckParams.additionalQueryParams.toBuilder() - additionalBodyProperties = creditCheckParams.additionalBodyProperties.toMutableMap() - } - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } - - /** - * Returns an immutable instance of [CreditCheckParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): CreditCheckParams = - CreditCheckParams( - additionalHeaders.build(), - additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), - ) - } - - fun _body(): Optional> = - Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is CreditCheckParams && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams && - additionalBodyProperties == other.additionalBodyProperties - } - - override fun hashCode(): Int = - Objects.hash(additionalHeaders, additionalQueryParams, additionalBodyProperties) - - override fun toString() = - "CreditCheckParams{additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" -} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/credits/CreditCheckResponse.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/credits/CreditCheckResponse.kt deleted file mode 100644 index 6a3f1a3..0000000 --- a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/credits/CreditCheckResponse.kt +++ /dev/null @@ -1,387 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.cas_parser.api.models.credits - -import com.cas_parser.api.core.ExcludeMissing -import com.cas_parser.api.core.JsonField -import com.cas_parser.api.core.JsonMissing -import com.cas_parser.api.core.JsonValue -import com.cas_parser.api.core.checkKnown -import com.cas_parser.api.core.toImmutable -import com.cas_parser.api.errors.CasParserInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.time.OffsetDateTime -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -class CreditCheckResponse -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val enabledFeatures: JsonField>, - private val isUnlimited: JsonField, - private val limit: JsonField, - private val remaining: JsonField, - private val resetsAt: JsonField, - private val used: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("enabled_features") - @ExcludeMissing - enabledFeatures: JsonField> = JsonMissing.of(), - @JsonProperty("is_unlimited") - @ExcludeMissing - isUnlimited: JsonField = JsonMissing.of(), - @JsonProperty("limit") @ExcludeMissing limit: JsonField = JsonMissing.of(), - @JsonProperty("remaining") @ExcludeMissing remaining: JsonField = JsonMissing.of(), - @JsonProperty("resets_at") - @ExcludeMissing - resetsAt: JsonField = JsonMissing.of(), - @JsonProperty("used") @ExcludeMissing used: JsonField = JsonMissing.of(), - ) : this(enabledFeatures, isUnlimited, limit, remaining, resetsAt, used, mutableMapOf()) - - /** - * List of API features enabled for your plan - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun enabledFeatures(): Optional> = enabledFeatures.getOptional("enabled_features") - - /** - * Whether the account has unlimited credits - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun isUnlimited(): Optional = isUnlimited.getOptional("is_unlimited") - - /** - * Total credit limit for billing period - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun limit(): Optional = limit.getOptional("limit") - - /** - * Remaining credits (null if unlimited) - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun remaining(): Optional = remaining.getOptional("remaining") - - /** - * When credits reset (ISO 8601) - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun resetsAt(): Optional = resetsAt.getOptional("resets_at") - - /** - * Number of credits used this billing period - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun used(): Optional = used.getOptional("used") - - /** - * Returns the raw JSON value of [enabledFeatures]. - * - * Unlike [enabledFeatures], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("enabled_features") - @ExcludeMissing - fun _enabledFeatures(): JsonField> = enabledFeatures - - /** - * Returns the raw JSON value of [isUnlimited]. - * - * Unlike [isUnlimited], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("is_unlimited") - @ExcludeMissing - fun _isUnlimited(): JsonField = isUnlimited - - /** - * Returns the raw JSON value of [limit]. - * - * Unlike [limit], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("limit") @ExcludeMissing fun _limit(): JsonField = limit - - /** - * Returns the raw JSON value of [remaining]. - * - * Unlike [remaining], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("remaining") @ExcludeMissing fun _remaining(): JsonField = remaining - - /** - * Returns the raw JSON value of [resetsAt]. - * - * Unlike [resetsAt], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("resets_at") @ExcludeMissing fun _resetsAt(): JsonField = resetsAt - - /** - * Returns the raw JSON value of [used]. - * - * Unlike [used], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("used") @ExcludeMissing fun _used(): JsonField = used - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [CreditCheckResponse]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [CreditCheckResponse]. */ - class Builder internal constructor() { - - private var enabledFeatures: JsonField>? = null - private var isUnlimited: JsonField = JsonMissing.of() - private var limit: JsonField = JsonMissing.of() - private var remaining: JsonField = JsonMissing.of() - private var resetsAt: JsonField = JsonMissing.of() - private var used: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(creditCheckResponse: CreditCheckResponse) = apply { - enabledFeatures = creditCheckResponse.enabledFeatures.map { it.toMutableList() } - isUnlimited = creditCheckResponse.isUnlimited - limit = creditCheckResponse.limit - remaining = creditCheckResponse.remaining - resetsAt = creditCheckResponse.resetsAt - used = creditCheckResponse.used - additionalProperties = creditCheckResponse.additionalProperties.toMutableMap() - } - - /** List of API features enabled for your plan */ - fun enabledFeatures(enabledFeatures: List) = - enabledFeatures(JsonField.of(enabledFeatures)) - - /** - * Sets [Builder.enabledFeatures] to an arbitrary JSON value. - * - * You should usually call [Builder.enabledFeatures] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun enabledFeatures(enabledFeatures: JsonField>) = apply { - this.enabledFeatures = enabledFeatures.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [enabledFeatures]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addEnabledFeature(enabledFeature: String) = apply { - enabledFeatures = - (enabledFeatures ?: JsonField.of(mutableListOf())).also { - checkKnown("enabledFeatures", it).add(enabledFeature) - } - } - - /** Whether the account has unlimited credits */ - fun isUnlimited(isUnlimited: Boolean) = isUnlimited(JsonField.of(isUnlimited)) - - /** - * Sets [Builder.isUnlimited] to an arbitrary JSON value. - * - * You should usually call [Builder.isUnlimited] with a well-typed [Boolean] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun isUnlimited(isUnlimited: JsonField) = apply { this.isUnlimited = isUnlimited } - - /** Total credit limit for billing period */ - fun limit(limit: Long) = limit(JsonField.of(limit)) - - /** - * Sets [Builder.limit] to an arbitrary JSON value. - * - * You should usually call [Builder.limit] with a well-typed [Long] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun limit(limit: JsonField) = apply { this.limit = limit } - - /** Remaining credits (null if unlimited) */ - fun remaining(remaining: Double?) = remaining(JsonField.ofNullable(remaining)) - - /** - * Alias for [Builder.remaining]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun remaining(remaining: Double) = remaining(remaining as Double?) - - /** Alias for calling [Builder.remaining] with `remaining.orElse(null)`. */ - fun remaining(remaining: Optional) = remaining(remaining.getOrNull()) - - /** - * Sets [Builder.remaining] to an arbitrary JSON value. - * - * You should usually call [Builder.remaining] with a well-typed [Double] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun remaining(remaining: JsonField) = apply { this.remaining = remaining } - - /** When credits reset (ISO 8601) */ - fun resetsAt(resetsAt: OffsetDateTime?) = resetsAt(JsonField.ofNullable(resetsAt)) - - /** Alias for calling [Builder.resetsAt] with `resetsAt.orElse(null)`. */ - fun resetsAt(resetsAt: Optional) = resetsAt(resetsAt.getOrNull()) - - /** - * Sets [Builder.resetsAt] to an arbitrary JSON value. - * - * You should usually call [Builder.resetsAt] with a well-typed [OffsetDateTime] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun resetsAt(resetsAt: JsonField) = apply { this.resetsAt = resetsAt } - - /** Number of credits used this billing period */ - fun used(used: Double) = used(JsonField.of(used)) - - /** - * Sets [Builder.used] to an arbitrary JSON value. - * - * You should usually call [Builder.used] with a well-typed [Double] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun used(used: JsonField) = apply { this.used = used } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [CreditCheckResponse]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): CreditCheckResponse = - CreditCheckResponse( - (enabledFeatures ?: JsonMissing.of()).map { it.toImmutable() }, - isUnlimited, - limit, - remaining, - resetsAt, - used, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): CreditCheckResponse = apply { - if (validated) { - return@apply - } - - enabledFeatures() - isUnlimited() - limit() - remaining() - resetsAt() - used() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CasParserInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (enabledFeatures.asKnown().getOrNull()?.size ?: 0) + - (if (isUnlimited.asKnown().isPresent) 1 else 0) + - (if (limit.asKnown().isPresent) 1 else 0) + - (if (remaining.asKnown().isPresent) 1 else 0) + - (if (resetsAt.asKnown().isPresent) 1 else 0) + - (if (used.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is CreditCheckResponse && - enabledFeatures == other.enabledFeatures && - isUnlimited == other.isUnlimited && - limit == other.limit && - remaining == other.remaining && - resetsAt == other.resetsAt && - used == other.used && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - enabledFeatures, - isUnlimited, - limit, - remaining, - resetsAt, - used, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "CreditCheckResponse{enabledFeatures=$enabledFeatures, isUnlimited=$isUnlimited, limit=$limit, remaining=$remaining, resetsAt=$resetsAt, used=$used, additionalProperties=$additionalProperties}" -} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/logs/LogCreateParams.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/logs/LogCreateParams.kt deleted file mode 100644 index c46a795..0000000 --- a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/logs/LogCreateParams.kt +++ /dev/null @@ -1,528 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.cas_parser.api.models.logs - -import com.cas_parser.api.core.ExcludeMissing -import com.cas_parser.api.core.JsonField -import com.cas_parser.api.core.JsonMissing -import com.cas_parser.api.core.JsonValue -import com.cas_parser.api.core.Params -import com.cas_parser.api.core.http.Headers -import com.cas_parser.api.core.http.QueryParams -import com.cas_parser.api.errors.CasParserInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.time.OffsetDateTime -import java.util.Collections -import java.util.Objects -import java.util.Optional - -/** - * Retrieve detailed API usage logs for your account. - * - * Returns a list of API calls with timestamps, features used, status codes, and credits consumed. - * Useful for monitoring usage patterns and debugging. - */ -class LogCreateParams -private constructor( - private val body: Body, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, -) : Params { - - /** - * End time filter (ISO 8601). Defaults to now. - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun endTime(): Optional = body.endTime() - - /** - * Maximum number of logs to return - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun limit(): Optional = body.limit() - - /** - * Start time filter (ISO 8601). Defaults to 30 days ago. - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun startTime(): Optional = body.startTime() - - /** - * Returns the raw JSON value of [endTime]. - * - * Unlike [endTime], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _endTime(): JsonField = body._endTime() - - /** - * Returns the raw JSON value of [limit]. - * - * Unlike [limit], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _limit(): JsonField = body._limit() - - /** - * Returns the raw JSON value of [startTime]. - * - * Unlike [startTime], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _startTime(): JsonField = body._startTime() - - fun _additionalBodyProperties(): Map = body._additionalProperties() - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders - - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun none(): LogCreateParams = builder().build() - - /** Returns a mutable builder for constructing an instance of [LogCreateParams]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [LogCreateParams]. */ - class Builder internal constructor() { - - private var body: Body.Builder = Body.builder() - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - - @JvmSynthetic - internal fun from(logCreateParams: LogCreateParams) = apply { - body = logCreateParams.body.toBuilder() - additionalHeaders = logCreateParams.additionalHeaders.toBuilder() - additionalQueryParams = logCreateParams.additionalQueryParams.toBuilder() - } - - /** - * Sets the entire request body. - * - * This is generally only useful if you are already constructing the body separately. - * Otherwise, it's more convenient to use the top-level setters instead: - * - [endTime] - * - [limit] - * - [startTime] - */ - fun body(body: Body) = apply { this.body = body.toBuilder() } - - /** End time filter (ISO 8601). Defaults to now. */ - fun endTime(endTime: OffsetDateTime) = apply { body.endTime(endTime) } - - /** - * Sets [Builder.endTime] to an arbitrary JSON value. - * - * You should usually call [Builder.endTime] with a well-typed [OffsetDateTime] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun endTime(endTime: JsonField) = apply { body.endTime(endTime) } - - /** Maximum number of logs to return */ - fun limit(limit: Long) = apply { body.limit(limit) } - - /** - * Sets [Builder.limit] to an arbitrary JSON value. - * - * You should usually call [Builder.limit] with a well-typed [Long] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun limit(limit: JsonField) = apply { body.limit(limit) } - - /** Start time filter (ISO 8601). Defaults to 30 days ago. */ - fun startTime(startTime: OffsetDateTime) = apply { body.startTime(startTime) } - - /** - * Sets [Builder.startTime] to an arbitrary JSON value. - * - * You should usually call [Builder.startTime] with a well-typed [OffsetDateTime] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun startTime(startTime: JsonField) = apply { body.startTime(startTime) } - - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - /** - * Returns an immutable instance of [LogCreateParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): LogCreateParams = - LogCreateParams(body.build(), additionalHeaders.build(), additionalQueryParams.build()) - } - - fun _body(): Body = body - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = additionalQueryParams - - class Body - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val endTime: JsonField, - private val limit: JsonField, - private val startTime: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("end_time") - @ExcludeMissing - endTime: JsonField = JsonMissing.of(), - @JsonProperty("limit") @ExcludeMissing limit: JsonField = JsonMissing.of(), - @JsonProperty("start_time") - @ExcludeMissing - startTime: JsonField = JsonMissing.of(), - ) : this(endTime, limit, startTime, mutableMapOf()) - - /** - * End time filter (ISO 8601). Defaults to now. - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun endTime(): Optional = endTime.getOptional("end_time") - - /** - * Maximum number of logs to return - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun limit(): Optional = limit.getOptional("limit") - - /** - * Start time filter (ISO 8601). Defaults to 30 days ago. - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun startTime(): Optional = startTime.getOptional("start_time") - - /** - * Returns the raw JSON value of [endTime]. - * - * Unlike [endTime], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("end_time") - @ExcludeMissing - fun _endTime(): JsonField = endTime - - /** - * Returns the raw JSON value of [limit]. - * - * Unlike [limit], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("limit") @ExcludeMissing fun _limit(): JsonField = limit - - /** - * Returns the raw JSON value of [startTime]. - * - * Unlike [startTime], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("start_time") - @ExcludeMissing - fun _startTime(): JsonField = startTime - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Body]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Body]. */ - class Builder internal constructor() { - - private var endTime: JsonField = JsonMissing.of() - private var limit: JsonField = JsonMissing.of() - private var startTime: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(body: Body) = apply { - endTime = body.endTime - limit = body.limit - startTime = body.startTime - additionalProperties = body.additionalProperties.toMutableMap() - } - - /** End time filter (ISO 8601). Defaults to now. */ - fun endTime(endTime: OffsetDateTime) = endTime(JsonField.of(endTime)) - - /** - * Sets [Builder.endTime] to an arbitrary JSON value. - * - * You should usually call [Builder.endTime] with a well-typed [OffsetDateTime] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun endTime(endTime: JsonField) = apply { this.endTime = endTime } - - /** Maximum number of logs to return */ - fun limit(limit: Long) = limit(JsonField.of(limit)) - - /** - * Sets [Builder.limit] to an arbitrary JSON value. - * - * You should usually call [Builder.limit] with a well-typed [Long] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun limit(limit: JsonField) = apply { this.limit = limit } - - /** Start time filter (ISO 8601). Defaults to 30 days ago. */ - fun startTime(startTime: OffsetDateTime) = startTime(JsonField.of(startTime)) - - /** - * Sets [Builder.startTime] to an arbitrary JSON value. - * - * You should usually call [Builder.startTime] with a well-typed [OffsetDateTime] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun startTime(startTime: JsonField) = apply { - this.startTime = startTime - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Body]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Body = Body(endTime, limit, startTime, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): Body = apply { - if (validated) { - return@apply - } - - endTime() - limit() - startTime() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CasParserInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (endTime.asKnown().isPresent) 1 else 0) + - (if (limit.asKnown().isPresent) 1 else 0) + - (if (startTime.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Body && - endTime == other.endTime && - limit == other.limit && - startTime == other.startTime && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(endTime, limit, startTime, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Body{endTime=$endTime, limit=$limit, startTime=$startTime, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is LogCreateParams && - body == other.body && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams - } - - override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) - - override fun toString() = - "LogCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" -} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/logs/LogCreateResponse.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/logs/LogCreateResponse.kt deleted file mode 100644 index b77a776..0000000 --- a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/logs/LogCreateResponse.kt +++ /dev/null @@ -1,578 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.cas_parser.api.models.logs - -import com.cas_parser.api.core.ExcludeMissing -import com.cas_parser.api.core.JsonField -import com.cas_parser.api.core.JsonMissing -import com.cas_parser.api.core.JsonValue -import com.cas_parser.api.core.checkKnown -import com.cas_parser.api.core.toImmutable -import com.cas_parser.api.errors.CasParserInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.time.OffsetDateTime -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -class LogCreateResponse -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val count: JsonField, - private val logs: JsonField>, - private val status: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("count") @ExcludeMissing count: JsonField = JsonMissing.of(), - @JsonProperty("logs") @ExcludeMissing logs: JsonField> = JsonMissing.of(), - @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), - ) : this(count, logs, status, mutableMapOf()) - - /** - * Number of logs returned - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun count(): Optional = count.getOptional("count") - - /** - * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun logs(): Optional> = logs.getOptional("logs") - - /** - * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun status(): Optional = status.getOptional("status") - - /** - * Returns the raw JSON value of [count]. - * - * Unlike [count], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("count") @ExcludeMissing fun _count(): JsonField = count - - /** - * Returns the raw JSON value of [logs]. - * - * Unlike [logs], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("logs") @ExcludeMissing fun _logs(): JsonField> = logs - - /** - * Returns the raw JSON value of [status]. - * - * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [LogCreateResponse]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [LogCreateResponse]. */ - class Builder internal constructor() { - - private var count: JsonField = JsonMissing.of() - private var logs: JsonField>? = null - private var status: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(logCreateResponse: LogCreateResponse) = apply { - count = logCreateResponse.count - logs = logCreateResponse.logs.map { it.toMutableList() } - status = logCreateResponse.status - additionalProperties = logCreateResponse.additionalProperties.toMutableMap() - } - - /** Number of logs returned */ - fun count(count: Long) = count(JsonField.of(count)) - - /** - * Sets [Builder.count] to an arbitrary JSON value. - * - * You should usually call [Builder.count] with a well-typed [Long] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun count(count: JsonField) = apply { this.count = count } - - fun logs(logs: List) = logs(JsonField.of(logs)) - - /** - * Sets [Builder.logs] to an arbitrary JSON value. - * - * You should usually call [Builder.logs] with a well-typed `List` value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun logs(logs: JsonField>) = apply { this.logs = logs.map { it.toMutableList() } } - - /** - * Adds a single [Log] to [logs]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addLog(log: Log) = apply { - logs = (logs ?: JsonField.of(mutableListOf())).also { checkKnown("logs", it).add(log) } - } - - fun status(status: String) = status(JsonField.of(status)) - - /** - * Sets [Builder.status] to an arbitrary JSON value. - * - * You should usually call [Builder.status] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun status(status: JsonField) = apply { this.status = status } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [LogCreateResponse]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): LogCreateResponse = - LogCreateResponse( - count, - (logs ?: JsonMissing.of()).map { it.toImmutable() }, - status, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): LogCreateResponse = apply { - if (validated) { - return@apply - } - - count() - logs().ifPresent { it.forEach { it.validate() } } - status() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CasParserInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (count.asKnown().isPresent) 1 else 0) + - (logs.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (if (status.asKnown().isPresent) 1 else 0) - - class Log - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val credits: JsonField, - private val feature: JsonField, - private val path: JsonField, - private val requestId: JsonField, - private val statusCode: JsonField, - private val timestamp: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("credits") @ExcludeMissing credits: JsonField = JsonMissing.of(), - @JsonProperty("feature") @ExcludeMissing feature: JsonField = JsonMissing.of(), - @JsonProperty("path") @ExcludeMissing path: JsonField = JsonMissing.of(), - @JsonProperty("request_id") - @ExcludeMissing - requestId: JsonField = JsonMissing.of(), - @JsonProperty("status_code") - @ExcludeMissing - statusCode: JsonField = JsonMissing.of(), - @JsonProperty("timestamp") - @ExcludeMissing - timestamp: JsonField = JsonMissing.of(), - ) : this(credits, feature, path, requestId, statusCode, timestamp, mutableMapOf()) - - /** - * Credits consumed for this request - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun credits(): Optional = credits.getOptional("credits") - - /** - * API feature used - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun feature(): Optional = feature.getOptional("feature") - - /** - * API endpoint path - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun path(): Optional = path.getOptional("path") - - /** - * Unique request identifier - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun requestId(): Optional = requestId.getOptional("request_id") - - /** - * HTTP response status code - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun statusCode(): Optional = statusCode.getOptional("status_code") - - /** - * When the request was made - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun timestamp(): Optional = timestamp.getOptional("timestamp") - - /** - * Returns the raw JSON value of [credits]. - * - * Unlike [credits], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("credits") @ExcludeMissing fun _credits(): JsonField = credits - - /** - * Returns the raw JSON value of [feature]. - * - * Unlike [feature], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("feature") @ExcludeMissing fun _feature(): JsonField = feature - - /** - * Returns the raw JSON value of [path]. - * - * Unlike [path], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("path") @ExcludeMissing fun _path(): JsonField = path - - /** - * Returns the raw JSON value of [requestId]. - * - * Unlike [requestId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("request_id") @ExcludeMissing fun _requestId(): JsonField = requestId - - /** - * Returns the raw JSON value of [statusCode]. - * - * Unlike [statusCode], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("status_code") @ExcludeMissing fun _statusCode(): JsonField = statusCode - - /** - * Returns the raw JSON value of [timestamp]. - * - * Unlike [timestamp], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("timestamp") - @ExcludeMissing - fun _timestamp(): JsonField = timestamp - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Log]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Log]. */ - class Builder internal constructor() { - - private var credits: JsonField = JsonMissing.of() - private var feature: JsonField = JsonMissing.of() - private var path: JsonField = JsonMissing.of() - private var requestId: JsonField = JsonMissing.of() - private var statusCode: JsonField = JsonMissing.of() - private var timestamp: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(log: Log) = apply { - credits = log.credits - feature = log.feature - path = log.path - requestId = log.requestId - statusCode = log.statusCode - timestamp = log.timestamp - additionalProperties = log.additionalProperties.toMutableMap() - } - - /** Credits consumed for this request */ - fun credits(credits: Double) = credits(JsonField.of(credits)) - - /** - * Sets [Builder.credits] to an arbitrary JSON value. - * - * You should usually call [Builder.credits] with a well-typed [Double] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun credits(credits: JsonField) = apply { this.credits = credits } - - /** API feature used */ - fun feature(feature: String) = feature(JsonField.of(feature)) - - /** - * Sets [Builder.feature] to an arbitrary JSON value. - * - * You should usually call [Builder.feature] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun feature(feature: JsonField) = apply { this.feature = feature } - - /** API endpoint path */ - fun path(path: String) = path(JsonField.of(path)) - - /** - * Sets [Builder.path] to an arbitrary JSON value. - * - * You should usually call [Builder.path] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun path(path: JsonField) = apply { this.path = path } - - /** Unique request identifier */ - fun requestId(requestId: String) = requestId(JsonField.of(requestId)) - - /** - * Sets [Builder.requestId] to an arbitrary JSON value. - * - * You should usually call [Builder.requestId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun requestId(requestId: JsonField) = apply { this.requestId = requestId } - - /** HTTP response status code */ - fun statusCode(statusCode: Long) = statusCode(JsonField.of(statusCode)) - - /** - * Sets [Builder.statusCode] to an arbitrary JSON value. - * - * You should usually call [Builder.statusCode] with a well-typed [Long] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun statusCode(statusCode: JsonField) = apply { this.statusCode = statusCode } - - /** When the request was made */ - fun timestamp(timestamp: OffsetDateTime) = timestamp(JsonField.of(timestamp)) - - /** - * Sets [Builder.timestamp] to an arbitrary JSON value. - * - * You should usually call [Builder.timestamp] with a well-typed [OffsetDateTime] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun timestamp(timestamp: JsonField) = apply { - this.timestamp = timestamp - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Log]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Log = - Log( - credits, - feature, - path, - requestId, - statusCode, - timestamp, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Log = apply { - if (validated) { - return@apply - } - - credits() - feature() - path() - requestId() - statusCode() - timestamp() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CasParserInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (credits.asKnown().isPresent) 1 else 0) + - (if (feature.asKnown().isPresent) 1 else 0) + - (if (path.asKnown().isPresent) 1 else 0) + - (if (requestId.asKnown().isPresent) 1 else 0) + - (if (statusCode.asKnown().isPresent) 1 else 0) + - (if (timestamp.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Log && - credits == other.credits && - feature == other.feature && - path == other.path && - requestId == other.requestId && - statusCode == other.statusCode && - timestamp == other.timestamp && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - credits, - feature, - path, - requestId, - statusCode, - timestamp, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Log{credits=$credits, feature=$feature, path=$path, requestId=$requestId, statusCode=$statusCode, timestamp=$timestamp, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is LogCreateResponse && - count == other.count && - logs == other.logs && - status == other.status && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(count, logs, status, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "LogCreateResponse{count=$count, logs=$logs, status=$status, additionalProperties=$additionalProperties}" -} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/logs/LogGetSummaryParams.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/logs/LogGetSummaryParams.kt deleted file mode 100644 index f14f253..0000000 --- a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/logs/LogGetSummaryParams.kt +++ /dev/null @@ -1,468 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.cas_parser.api.models.logs - -import com.cas_parser.api.core.ExcludeMissing -import com.cas_parser.api.core.JsonField -import com.cas_parser.api.core.JsonMissing -import com.cas_parser.api.core.JsonValue -import com.cas_parser.api.core.Params -import com.cas_parser.api.core.http.Headers -import com.cas_parser.api.core.http.QueryParams -import com.cas_parser.api.errors.CasParserInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.time.OffsetDateTime -import java.util.Collections -import java.util.Objects -import java.util.Optional - -/** - * Get aggregated usage statistics grouped by feature. - * - * Useful for understanding which API features are being used most and tracking usage trends. - */ -class LogGetSummaryParams -private constructor( - private val body: Body, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, -) : Params { - - /** - * End time filter (ISO 8601). Defaults to now. - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun endTime(): Optional = body.endTime() - - /** - * Start time filter (ISO 8601). Defaults to start of current month. - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun startTime(): Optional = body.startTime() - - /** - * Returns the raw JSON value of [endTime]. - * - * Unlike [endTime], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _endTime(): JsonField = body._endTime() - - /** - * Returns the raw JSON value of [startTime]. - * - * Unlike [startTime], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _startTime(): JsonField = body._startTime() - - fun _additionalBodyProperties(): Map = body._additionalProperties() - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders - - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun none(): LogGetSummaryParams = builder().build() - - /** Returns a mutable builder for constructing an instance of [LogGetSummaryParams]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [LogGetSummaryParams]. */ - class Builder internal constructor() { - - private var body: Body.Builder = Body.builder() - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - - @JvmSynthetic - internal fun from(logGetSummaryParams: LogGetSummaryParams) = apply { - body = logGetSummaryParams.body.toBuilder() - additionalHeaders = logGetSummaryParams.additionalHeaders.toBuilder() - additionalQueryParams = logGetSummaryParams.additionalQueryParams.toBuilder() - } - - /** - * Sets the entire request body. - * - * This is generally only useful if you are already constructing the body separately. - * Otherwise, it's more convenient to use the top-level setters instead: - * - [endTime] - * - [startTime] - */ - fun body(body: Body) = apply { this.body = body.toBuilder() } - - /** End time filter (ISO 8601). Defaults to now. */ - fun endTime(endTime: OffsetDateTime) = apply { body.endTime(endTime) } - - /** - * Sets [Builder.endTime] to an arbitrary JSON value. - * - * You should usually call [Builder.endTime] with a well-typed [OffsetDateTime] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun endTime(endTime: JsonField) = apply { body.endTime(endTime) } - - /** Start time filter (ISO 8601). Defaults to start of current month. */ - fun startTime(startTime: OffsetDateTime) = apply { body.startTime(startTime) } - - /** - * Sets [Builder.startTime] to an arbitrary JSON value. - * - * You should usually call [Builder.startTime] with a well-typed [OffsetDateTime] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun startTime(startTime: JsonField) = apply { body.startTime(startTime) } - - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - /** - * Returns an immutable instance of [LogGetSummaryParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): LogGetSummaryParams = - LogGetSummaryParams( - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), - ) - } - - fun _body(): Body = body - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = additionalQueryParams - - class Body - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val endTime: JsonField, - private val startTime: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("end_time") - @ExcludeMissing - endTime: JsonField = JsonMissing.of(), - @JsonProperty("start_time") - @ExcludeMissing - startTime: JsonField = JsonMissing.of(), - ) : this(endTime, startTime, mutableMapOf()) - - /** - * End time filter (ISO 8601). Defaults to now. - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun endTime(): Optional = endTime.getOptional("end_time") - - /** - * Start time filter (ISO 8601). Defaults to start of current month. - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun startTime(): Optional = startTime.getOptional("start_time") - - /** - * Returns the raw JSON value of [endTime]. - * - * Unlike [endTime], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("end_time") - @ExcludeMissing - fun _endTime(): JsonField = endTime - - /** - * Returns the raw JSON value of [startTime]. - * - * Unlike [startTime], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("start_time") - @ExcludeMissing - fun _startTime(): JsonField = startTime - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Body]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Body]. */ - class Builder internal constructor() { - - private var endTime: JsonField = JsonMissing.of() - private var startTime: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(body: Body) = apply { - endTime = body.endTime - startTime = body.startTime - additionalProperties = body.additionalProperties.toMutableMap() - } - - /** End time filter (ISO 8601). Defaults to now. */ - fun endTime(endTime: OffsetDateTime) = endTime(JsonField.of(endTime)) - - /** - * Sets [Builder.endTime] to an arbitrary JSON value. - * - * You should usually call [Builder.endTime] with a well-typed [OffsetDateTime] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun endTime(endTime: JsonField) = apply { this.endTime = endTime } - - /** Start time filter (ISO 8601). Defaults to start of current month. */ - fun startTime(startTime: OffsetDateTime) = startTime(JsonField.of(startTime)) - - /** - * Sets [Builder.startTime] to an arbitrary JSON value. - * - * You should usually call [Builder.startTime] with a well-typed [OffsetDateTime] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun startTime(startTime: JsonField) = apply { - this.startTime = startTime - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Body]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Body = Body(endTime, startTime, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): Body = apply { - if (validated) { - return@apply - } - - endTime() - startTime() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CasParserInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (endTime.asKnown().isPresent) 1 else 0) + - (if (startTime.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Body && - endTime == other.endTime && - startTime == other.startTime && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(endTime, startTime, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Body{endTime=$endTime, startTime=$startTime, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is LogGetSummaryParams && - body == other.body && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams - } - - override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) - - override fun toString() = - "LogGetSummaryParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" -} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/logs/LogGetSummaryResponse.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/logs/LogGetSummaryResponse.kt deleted file mode 100644 index a78d1ba..0000000 --- a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/logs/LogGetSummaryResponse.kt +++ /dev/null @@ -1,663 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.cas_parser.api.models.logs - -import com.cas_parser.api.core.ExcludeMissing -import com.cas_parser.api.core.JsonField -import com.cas_parser.api.core.JsonMissing -import com.cas_parser.api.core.JsonValue -import com.cas_parser.api.core.checkKnown -import com.cas_parser.api.core.toImmutable -import com.cas_parser.api.errors.CasParserInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -class LogGetSummaryResponse -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val status: JsonField, - private val summary: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), - @JsonProperty("summary") @ExcludeMissing summary: JsonField = JsonMissing.of(), - ) : this(status, summary, mutableMapOf()) - - /** - * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun status(): Optional = status.getOptional("status") - - /** - * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun summary(): Optional = summary.getOptional("summary") - - /** - * Returns the raw JSON value of [status]. - * - * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status - - /** - * Returns the raw JSON value of [summary]. - * - * Unlike [summary], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("summary") @ExcludeMissing fun _summary(): JsonField = summary - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [LogGetSummaryResponse]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [LogGetSummaryResponse]. */ - class Builder internal constructor() { - - private var status: JsonField = JsonMissing.of() - private var summary: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(logGetSummaryResponse: LogGetSummaryResponse) = apply { - status = logGetSummaryResponse.status - summary = logGetSummaryResponse.summary - additionalProperties = logGetSummaryResponse.additionalProperties.toMutableMap() - } - - fun status(status: String) = status(JsonField.of(status)) - - /** - * Sets [Builder.status] to an arbitrary JSON value. - * - * You should usually call [Builder.status] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun status(status: JsonField) = apply { this.status = status } - - fun summary(summary: Summary) = summary(JsonField.of(summary)) - - /** - * Sets [Builder.summary] to an arbitrary JSON value. - * - * You should usually call [Builder.summary] with a well-typed [Summary] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun summary(summary: JsonField) = apply { this.summary = summary } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [LogGetSummaryResponse]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): LogGetSummaryResponse = - LogGetSummaryResponse(status, summary, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): LogGetSummaryResponse = apply { - if (validated) { - return@apply - } - - status() - summary().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CasParserInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (status.asKnown().isPresent) 1 else 0) + - (summary.asKnown().getOrNull()?.validity() ?: 0) - - class Summary - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val byFeature: JsonField>, - private val totalCredits: JsonField, - private val totalRequests: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("by_feature") - @ExcludeMissing - byFeature: JsonField> = JsonMissing.of(), - @JsonProperty("total_credits") - @ExcludeMissing - totalCredits: JsonField = JsonMissing.of(), - @JsonProperty("total_requests") - @ExcludeMissing - totalRequests: JsonField = JsonMissing.of(), - ) : this(byFeature, totalCredits, totalRequests, mutableMapOf()) - - /** - * Usage breakdown by feature - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun byFeature(): Optional> = byFeature.getOptional("by_feature") - - /** - * Total credits consumed in the period - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun totalCredits(): Optional = totalCredits.getOptional("total_credits") - - /** - * Total API requests made in the period - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun totalRequests(): Optional = totalRequests.getOptional("total_requests") - - /** - * Returns the raw JSON value of [byFeature]. - * - * Unlike [byFeature], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("by_feature") - @ExcludeMissing - fun _byFeature(): JsonField> = byFeature - - /** - * Returns the raw JSON value of [totalCredits]. - * - * Unlike [totalCredits], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("total_credits") - @ExcludeMissing - fun _totalCredits(): JsonField = totalCredits - - /** - * Returns the raw JSON value of [totalRequests]. - * - * Unlike [totalRequests], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("total_requests") - @ExcludeMissing - fun _totalRequests(): JsonField = totalRequests - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Summary]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Summary]. */ - class Builder internal constructor() { - - private var byFeature: JsonField>? = null - private var totalCredits: JsonField = JsonMissing.of() - private var totalRequests: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(summary: Summary) = apply { - byFeature = summary.byFeature.map { it.toMutableList() } - totalCredits = summary.totalCredits - totalRequests = summary.totalRequests - additionalProperties = summary.additionalProperties.toMutableMap() - } - - /** Usage breakdown by feature */ - fun byFeature(byFeature: List) = byFeature(JsonField.of(byFeature)) - - /** - * Sets [Builder.byFeature] to an arbitrary JSON value. - * - * You should usually call [Builder.byFeature] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun byFeature(byFeature: JsonField>) = apply { - this.byFeature = byFeature.map { it.toMutableList() } - } - - /** - * Adds a single [ByFeature] to [Builder.byFeature]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addByFeature(byFeature: ByFeature) = apply { - this.byFeature = - (this.byFeature ?: JsonField.of(mutableListOf())).also { - checkKnown("byFeature", it).add(byFeature) - } - } - - /** Total credits consumed in the period */ - fun totalCredits(totalCredits: Double) = totalCredits(JsonField.of(totalCredits)) - - /** - * Sets [Builder.totalCredits] to an arbitrary JSON value. - * - * You should usually call [Builder.totalCredits] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun totalCredits(totalCredits: JsonField) = apply { - this.totalCredits = totalCredits - } - - /** Total API requests made in the period */ - fun totalRequests(totalRequests: Long) = totalRequests(JsonField.of(totalRequests)) - - /** - * Sets [Builder.totalRequests] to an arbitrary JSON value. - * - * You should usually call [Builder.totalRequests] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun totalRequests(totalRequests: JsonField) = apply { - this.totalRequests = totalRequests - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Summary]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Summary = - Summary( - (byFeature ?: JsonMissing.of()).map { it.toImmutable() }, - totalCredits, - totalRequests, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Summary = apply { - if (validated) { - return@apply - } - - byFeature().ifPresent { it.forEach { it.validate() } } - totalCredits() - totalRequests() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CasParserInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (byFeature.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (if (totalCredits.asKnown().isPresent) 1 else 0) + - (if (totalRequests.asKnown().isPresent) 1 else 0) - - class ByFeature - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val credits: JsonField, - private val feature: JsonField, - private val requests: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("credits") - @ExcludeMissing - credits: JsonField = JsonMissing.of(), - @JsonProperty("feature") - @ExcludeMissing - feature: JsonField = JsonMissing.of(), - @JsonProperty("requests") - @ExcludeMissing - requests: JsonField = JsonMissing.of(), - ) : this(credits, feature, requests, mutableMapOf()) - - /** - * Credits consumed by this feature - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun credits(): Optional = credits.getOptional("credits") - - /** - * API feature name - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun feature(): Optional = feature.getOptional("feature") - - /** - * Number of requests for this feature - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun requests(): Optional = requests.getOptional("requests") - - /** - * Returns the raw JSON value of [credits]. - * - * Unlike [credits], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("credits") @ExcludeMissing fun _credits(): JsonField = credits - - /** - * Returns the raw JSON value of [feature]. - * - * Unlike [feature], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("feature") @ExcludeMissing fun _feature(): JsonField = feature - - /** - * Returns the raw JSON value of [requests]. - * - * Unlike [requests], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("requests") @ExcludeMissing fun _requests(): JsonField = requests - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [ByFeature]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ByFeature]. */ - class Builder internal constructor() { - - private var credits: JsonField = JsonMissing.of() - private var feature: JsonField = JsonMissing.of() - private var requests: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(byFeature: ByFeature) = apply { - credits = byFeature.credits - feature = byFeature.feature - requests = byFeature.requests - additionalProperties = byFeature.additionalProperties.toMutableMap() - } - - /** Credits consumed by this feature */ - fun credits(credits: Double) = credits(JsonField.of(credits)) - - /** - * Sets [Builder.credits] to an arbitrary JSON value. - * - * You should usually call [Builder.credits] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun credits(credits: JsonField) = apply { this.credits = credits } - - /** API feature name */ - fun feature(feature: String) = feature(JsonField.of(feature)) - - /** - * Sets [Builder.feature] to an arbitrary JSON value. - * - * You should usually call [Builder.feature] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun feature(feature: JsonField) = apply { this.feature = feature } - - /** Number of requests for this feature */ - fun requests(requests: Long) = requests(JsonField.of(requests)) - - /** - * Sets [Builder.requests] to an arbitrary JSON value. - * - * You should usually call [Builder.requests] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun requests(requests: JsonField) = apply { this.requests = requests } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [ByFeature]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): ByFeature = - ByFeature(credits, feature, requests, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): ByFeature = apply { - if (validated) { - return@apply - } - - credits() - feature() - requests() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CasParserInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (credits.asKnown().isPresent) 1 else 0) + - (if (feature.asKnown().isPresent) 1 else 0) + - (if (requests.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ByFeature && - credits == other.credits && - feature == other.feature && - requests == other.requests && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(credits, feature, requests, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ByFeature{credits=$credits, feature=$feature, requests=$requests, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Summary && - byFeature == other.byFeature && - totalCredits == other.totalCredits && - totalRequests == other.totalRequests && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(byFeature, totalCredits, totalRequests, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Summary{byFeature=$byFeature, totalCredits=$totalCredits, totalRequests=$totalRequests, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is LogGetSummaryResponse && - status == other.status && - summary == other.summary && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(status, summary, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "LogGetSummaryResponse{status=$status, summary=$summary, additionalProperties=$additionalProperties}" -} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/verifytoken/VerifyTokenVerifyParams.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/verifytoken/VerifyTokenVerifyParams.kt deleted file mode 100644 index aac1a81..0000000 --- a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/verifytoken/VerifyTokenVerifyParams.kt +++ /dev/null @@ -1,211 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.cas_parser.api.models.verifytoken - -import com.cas_parser.api.core.JsonValue -import com.cas_parser.api.core.Params -import com.cas_parser.api.core.http.Headers -import com.cas_parser.api.core.http.QueryParams -import com.cas_parser.api.core.toImmutable -import java.util.Objects -import java.util.Optional - -/** Verify an access token and check if it's still valid. Useful for debugging token issues. */ -class VerifyTokenVerifyParams -private constructor( - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, - private val additionalBodyProperties: Map, -) : Params { - - /** Additional body properties to send with the request. */ - fun _additionalBodyProperties(): Map = additionalBodyProperties - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders - - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun none(): VerifyTokenVerifyParams = builder().build() - - /** Returns a mutable builder for constructing an instance of [VerifyTokenVerifyParams]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [VerifyTokenVerifyParams]. */ - class Builder internal constructor() { - - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - private var additionalBodyProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(verifyTokenVerifyParams: VerifyTokenVerifyParams) = apply { - additionalHeaders = verifyTokenVerifyParams.additionalHeaders.toBuilder() - additionalQueryParams = verifyTokenVerifyParams.additionalQueryParams.toBuilder() - additionalBodyProperties = - verifyTokenVerifyParams.additionalBodyProperties.toMutableMap() - } - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } - - /** - * Returns an immutable instance of [VerifyTokenVerifyParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): VerifyTokenVerifyParams = - VerifyTokenVerifyParams( - additionalHeaders.build(), - additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), - ) - } - - fun _body(): Optional> = - Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is VerifyTokenVerifyParams && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams && - additionalBodyProperties == other.additionalBodyProperties - } - - override fun hashCode(): Int = - Objects.hash(additionalHeaders, additionalQueryParams, additionalBodyProperties) - - override fun toString() = - "VerifyTokenVerifyParams{additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" -} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/verifytoken/VerifyTokenVerifyResponse.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/verifytoken/VerifyTokenVerifyResponse.kt deleted file mode 100644 index b8859a0..0000000 --- a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/verifytoken/VerifyTokenVerifyResponse.kt +++ /dev/null @@ -1,240 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.cas_parser.api.models.verifytoken - -import com.cas_parser.api.core.ExcludeMissing -import com.cas_parser.api.core.JsonField -import com.cas_parser.api.core.JsonMissing -import com.cas_parser.api.core.JsonValue -import com.cas_parser.api.errors.CasParserInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects -import java.util.Optional - -class VerifyTokenVerifyResponse -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val error: JsonField, - private val maskedApiKey: JsonField, - private val valid: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("error") @ExcludeMissing error: JsonField = JsonMissing.of(), - @JsonProperty("masked_api_key") - @ExcludeMissing - maskedApiKey: JsonField = JsonMissing.of(), - @JsonProperty("valid") @ExcludeMissing valid: JsonField = JsonMissing.of(), - ) : this(error, maskedApiKey, valid, mutableMapOf()) - - /** - * Error message (only shown if invalid) - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun error(): Optional = error.getOptional("error") - - /** - * Masked API key (only shown if valid) - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun maskedApiKey(): Optional = maskedApiKey.getOptional("masked_api_key") - - /** - * Whether the token is valid - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun valid(): Optional = valid.getOptional("valid") - - /** - * Returns the raw JSON value of [error]. - * - * Unlike [error], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("error") @ExcludeMissing fun _error(): JsonField = error - - /** - * Returns the raw JSON value of [maskedApiKey]. - * - * Unlike [maskedApiKey], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("masked_api_key") - @ExcludeMissing - fun _maskedApiKey(): JsonField = maskedApiKey - - /** - * Returns the raw JSON value of [valid]. - * - * Unlike [valid], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("valid") @ExcludeMissing fun _valid(): JsonField = valid - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [VerifyTokenVerifyResponse]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [VerifyTokenVerifyResponse]. */ - class Builder internal constructor() { - - private var error: JsonField = JsonMissing.of() - private var maskedApiKey: JsonField = JsonMissing.of() - private var valid: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(verifyTokenVerifyResponse: VerifyTokenVerifyResponse) = apply { - error = verifyTokenVerifyResponse.error - maskedApiKey = verifyTokenVerifyResponse.maskedApiKey - valid = verifyTokenVerifyResponse.valid - additionalProperties = verifyTokenVerifyResponse.additionalProperties.toMutableMap() - } - - /** Error message (only shown if invalid) */ - fun error(error: String) = error(JsonField.of(error)) - - /** - * Sets [Builder.error] to an arbitrary JSON value. - * - * You should usually call [Builder.error] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun error(error: JsonField) = apply { this.error = error } - - /** Masked API key (only shown if valid) */ - fun maskedApiKey(maskedApiKey: String) = maskedApiKey(JsonField.of(maskedApiKey)) - - /** - * Sets [Builder.maskedApiKey] to an arbitrary JSON value. - * - * You should usually call [Builder.maskedApiKey] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun maskedApiKey(maskedApiKey: JsonField) = apply { - this.maskedApiKey = maskedApiKey - } - - /** Whether the token is valid */ - fun valid(valid: Boolean) = valid(JsonField.of(valid)) - - /** - * Sets [Builder.valid] to an arbitrary JSON value. - * - * You should usually call [Builder.valid] with a well-typed [Boolean] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun valid(valid: JsonField) = apply { this.valid = valid } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [VerifyTokenVerifyResponse]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): VerifyTokenVerifyResponse = - VerifyTokenVerifyResponse( - error, - maskedApiKey, - valid, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): VerifyTokenVerifyResponse = apply { - if (validated) { - return@apply - } - - error() - maskedApiKey() - valid() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CasParserInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (error.asKnown().isPresent) 1 else 0) + - (if (maskedApiKey.asKnown().isPresent) 1 else 0) + - (if (valid.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is VerifyTokenVerifyResponse && - error == other.error && - maskedApiKey == other.maskedApiKey && - valid == other.valid && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(error, maskedApiKey, valid, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "VerifyTokenVerifyResponse{error=$error, maskedApiKey=$maskedApiKey, valid=$valid, additionalProperties=$additionalProperties}" -} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/AccessTokenServiceAsync.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/AccessTokenServiceAsync.kt index 0948924..3809ee6 100644 --- a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/AccessTokenServiceAsync.kt +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/AccessTokenServiceAsync.kt @@ -3,11 +3,6 @@ package com.cas_parser.api.services.async import com.cas_parser.api.core.ClientOptions -import com.cas_parser.api.core.RequestOptions -import com.cas_parser.api.core.http.HttpResponseFor -import com.cas_parser.api.models.accesstoken.AccessTokenCreateParams -import com.cas_parser.api.models.accesstoken.AccessTokenCreateResponse -import java.util.concurrent.CompletableFuture import java.util.function.Consumer interface AccessTokenServiceAsync { @@ -24,36 +19,6 @@ interface AccessTokenServiceAsync { */ fun withOptions(modifier: Consumer): AccessTokenServiceAsync - /** - * Generate a short-lived access token from your API key. - * - * **Use this endpoint from your backend** to create tokens that can be safely passed to - * frontend/SDK. - * - * Access tokens: - * - Are prefixed with `at_` for easy identification - * - Valid for up to 60 minutes - * - Can be used in place of API keys on all v4 endpoints - * - Cannot be used to generate other access tokens - */ - fun create(): CompletableFuture = - create(AccessTokenCreateParams.none()) - - /** @see create */ - fun create( - params: AccessTokenCreateParams = AccessTokenCreateParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** @see create */ - fun create( - params: AccessTokenCreateParams = AccessTokenCreateParams.none() - ): CompletableFuture = create(params, RequestOptions.none()) - - /** @see create */ - fun create(requestOptions: RequestOptions): CompletableFuture = - create(AccessTokenCreateParams.none(), requestOptions) - /** * A view of [AccessTokenServiceAsync] that provides access to raw HTTP responses for each * method. @@ -68,30 +33,5 @@ interface AccessTokenServiceAsync { fun withOptions( modifier: Consumer ): AccessTokenServiceAsync.WithRawResponse - - /** - * Returns a raw HTTP response for `post /v1/access-token`, but is otherwise the same as - * [AccessTokenServiceAsync.create]. - */ - fun create(): CompletableFuture> = - create(AccessTokenCreateParams.none()) - - /** @see create */ - fun create( - params: AccessTokenCreateParams = AccessTokenCreateParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - - /** @see create */ - fun create( - params: AccessTokenCreateParams = AccessTokenCreateParams.none() - ): CompletableFuture> = - create(params, RequestOptions.none()) - - /** @see create */ - fun create( - requestOptions: RequestOptions - ): CompletableFuture> = - create(AccessTokenCreateParams.none(), requestOptions) } } diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/AccessTokenServiceAsyncImpl.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/AccessTokenServiceAsyncImpl.kt index e71b99c..a947c34 100644 --- a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/AccessTokenServiceAsyncImpl.kt +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/AccessTokenServiceAsyncImpl.kt @@ -3,21 +3,6 @@ package com.cas_parser.api.services.async import com.cas_parser.api.core.ClientOptions -import com.cas_parser.api.core.RequestOptions -import com.cas_parser.api.core.handlers.errorBodyHandler -import com.cas_parser.api.core.handlers.errorHandler -import com.cas_parser.api.core.handlers.jsonHandler -import com.cas_parser.api.core.http.HttpMethod -import com.cas_parser.api.core.http.HttpRequest -import com.cas_parser.api.core.http.HttpResponse -import com.cas_parser.api.core.http.HttpResponse.Handler -import com.cas_parser.api.core.http.HttpResponseFor -import com.cas_parser.api.core.http.json -import com.cas_parser.api.core.http.parseable -import com.cas_parser.api.core.prepareAsync -import com.cas_parser.api.models.accesstoken.AccessTokenCreateParams -import com.cas_parser.api.models.accesstoken.AccessTokenCreateResponse -import java.util.concurrent.CompletableFuture import java.util.function.Consumer class AccessTokenServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : @@ -32,55 +17,14 @@ class AccessTokenServiceAsyncImpl internal constructor(private val clientOptions override fun withOptions(modifier: Consumer): AccessTokenServiceAsync = AccessTokenServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - override fun create( - params: AccessTokenCreateParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // post /v1/access-token - withRawResponse().create(params, requestOptions).thenApply { it.parse() } - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : AccessTokenServiceAsync.WithRawResponse { - private val errorHandler: Handler = - errorHandler(errorBodyHandler(clientOptions.jsonMapper)) - override fun withOptions( modifier: Consumer ): AccessTokenServiceAsync.WithRawResponse = AccessTokenServiceAsyncImpl.WithRawResponseImpl( clientOptions.toBuilder().apply(modifier::accept).build() ) - - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun create( - params: AccessTokenCreateParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("v1", "access-token") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } } } diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/CreditServiceAsync.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/CreditServiceAsync.kt index 05290f8..70f75cb 100644 --- a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/CreditServiceAsync.kt +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/CreditServiceAsync.kt @@ -3,11 +3,6 @@ package com.cas_parser.api.services.async import com.cas_parser.api.core.ClientOptions -import com.cas_parser.api.core.RequestOptions -import com.cas_parser.api.core.http.HttpResponseFor -import com.cas_parser.api.models.credits.CreditCheckParams -import com.cas_parser.api.models.credits.CreditCheckResponse -import java.util.concurrent.CompletableFuture import java.util.function.Consumer interface CreditServiceAsync { @@ -24,33 +19,6 @@ interface CreditServiceAsync { */ fun withOptions(modifier: Consumer): CreditServiceAsync - /** - * Check your remaining API credits and usage for the current billing period. - * - * Returns: - * - Number of API calls used and remaining credits - * - Credit limit and reset date - * - List of enabled features for your plan - * - * Credits reset at the start of each billing period. - */ - fun check(): CompletableFuture = check(CreditCheckParams.none()) - - /** @see check */ - fun check( - params: CreditCheckParams = CreditCheckParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** @see check */ - fun check( - params: CreditCheckParams = CreditCheckParams.none() - ): CompletableFuture = check(params, RequestOptions.none()) - - /** @see check */ - fun check(requestOptions: RequestOptions): CompletableFuture = - check(CreditCheckParams.none(), requestOptions) - /** * A view of [CreditServiceAsync] that provides access to raw HTTP responses for each method. */ @@ -64,30 +32,5 @@ interface CreditServiceAsync { fun withOptions( modifier: Consumer ): CreditServiceAsync.WithRawResponse - - /** - * Returns a raw HTTP response for `post /credits`, but is otherwise the same as - * [CreditServiceAsync.check]. - */ - fun check(): CompletableFuture> = - check(CreditCheckParams.none()) - - /** @see check */ - fun check( - params: CreditCheckParams = CreditCheckParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - - /** @see check */ - fun check( - params: CreditCheckParams = CreditCheckParams.none() - ): CompletableFuture> = - check(params, RequestOptions.none()) - - /** @see check */ - fun check( - requestOptions: RequestOptions - ): CompletableFuture> = - check(CreditCheckParams.none(), requestOptions) } } diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/CreditServiceAsyncImpl.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/CreditServiceAsyncImpl.kt index 6f2806c..9995851 100644 --- a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/CreditServiceAsyncImpl.kt +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/CreditServiceAsyncImpl.kt @@ -3,21 +3,6 @@ package com.cas_parser.api.services.async import com.cas_parser.api.core.ClientOptions -import com.cas_parser.api.core.RequestOptions -import com.cas_parser.api.core.handlers.errorBodyHandler -import com.cas_parser.api.core.handlers.errorHandler -import com.cas_parser.api.core.handlers.jsonHandler -import com.cas_parser.api.core.http.HttpMethod -import com.cas_parser.api.core.http.HttpRequest -import com.cas_parser.api.core.http.HttpResponse -import com.cas_parser.api.core.http.HttpResponse.Handler -import com.cas_parser.api.core.http.HttpResponseFor -import com.cas_parser.api.core.http.json -import com.cas_parser.api.core.http.parseable -import com.cas_parser.api.core.prepareAsync -import com.cas_parser.api.models.credits.CreditCheckParams -import com.cas_parser.api.models.credits.CreditCheckResponse -import java.util.concurrent.CompletableFuture import java.util.function.Consumer class CreditServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : @@ -32,55 +17,14 @@ class CreditServiceAsyncImpl internal constructor(private val clientOptions: Cli override fun withOptions(modifier: Consumer): CreditServiceAsync = CreditServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - override fun check( - params: CreditCheckParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // post /credits - withRawResponse().check(params, requestOptions).thenApply { it.parse() } - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : CreditServiceAsync.WithRawResponse { - private val errorHandler: Handler = - errorHandler(errorBodyHandler(clientOptions.jsonMapper)) - override fun withOptions( modifier: Consumer ): CreditServiceAsync.WithRawResponse = CreditServiceAsyncImpl.WithRawResponseImpl( clientOptions.toBuilder().apply(modifier::accept).build() ) - - private val checkHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun check( - params: CreditCheckParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("credits") - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response - .use { checkHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } } } diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/LogServiceAsync.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/LogServiceAsync.kt index 641ee6a..4dc2b00 100644 --- a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/LogServiceAsync.kt +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/LogServiceAsync.kt @@ -3,13 +3,6 @@ package com.cas_parser.api.services.async import com.cas_parser.api.core.ClientOptions -import com.cas_parser.api.core.RequestOptions -import com.cas_parser.api.core.http.HttpResponseFor -import com.cas_parser.api.models.logs.LogCreateParams -import com.cas_parser.api.models.logs.LogCreateResponse -import com.cas_parser.api.models.logs.LogGetSummaryParams -import com.cas_parser.api.models.logs.LogGetSummaryResponse -import java.util.concurrent.CompletableFuture import java.util.function.Consumer interface LogServiceAsync { @@ -26,52 +19,6 @@ interface LogServiceAsync { */ fun withOptions(modifier: Consumer): LogServiceAsync - /** - * Retrieve detailed API usage logs for your account. - * - * Returns a list of API calls with timestamps, features used, status codes, and credits - * consumed. Useful for monitoring usage patterns and debugging. - */ - fun create(): CompletableFuture = create(LogCreateParams.none()) - - /** @see create */ - fun create( - params: LogCreateParams = LogCreateParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** @see create */ - fun create( - params: LogCreateParams = LogCreateParams.none() - ): CompletableFuture = create(params, RequestOptions.none()) - - /** @see create */ - fun create(requestOptions: RequestOptions): CompletableFuture = - create(LogCreateParams.none(), requestOptions) - - /** - * Get aggregated usage statistics grouped by feature. - * - * Useful for understanding which API features are being used most and tracking usage trends. - */ - fun getSummary(): CompletableFuture = - getSummary(LogGetSummaryParams.none()) - - /** @see getSummary */ - fun getSummary( - params: LogGetSummaryParams = LogGetSummaryParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** @see getSummary */ - fun getSummary( - params: LogGetSummaryParams = LogGetSummaryParams.none() - ): CompletableFuture = getSummary(params, RequestOptions.none()) - - /** @see getSummary */ - fun getSummary(requestOptions: RequestOptions): CompletableFuture = - getSummary(LogGetSummaryParams.none(), requestOptions) - /** A view of [LogServiceAsync] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -81,55 +28,5 @@ interface LogServiceAsync { * The original service is not modified. */ fun withOptions(modifier: Consumer): LogServiceAsync.WithRawResponse - - /** - * Returns a raw HTTP response for `post /logs`, but is otherwise the same as - * [LogServiceAsync.create]. - */ - fun create(): CompletableFuture> = - create(LogCreateParams.none()) - - /** @see create */ - fun create( - params: LogCreateParams = LogCreateParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - - /** @see create */ - fun create( - params: LogCreateParams = LogCreateParams.none() - ): CompletableFuture> = - create(params, RequestOptions.none()) - - /** @see create */ - fun create( - requestOptions: RequestOptions - ): CompletableFuture> = - create(LogCreateParams.none(), requestOptions) - - /** - * Returns a raw HTTP response for `post /logs/summary`, but is otherwise the same as - * [LogServiceAsync.getSummary]. - */ - fun getSummary(): CompletableFuture> = - getSummary(LogGetSummaryParams.none()) - - /** @see getSummary */ - fun getSummary( - params: LogGetSummaryParams = LogGetSummaryParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - - /** @see getSummary */ - fun getSummary( - params: LogGetSummaryParams = LogGetSummaryParams.none() - ): CompletableFuture> = - getSummary(params, RequestOptions.none()) - - /** @see getSummary */ - fun getSummary( - requestOptions: RequestOptions - ): CompletableFuture> = - getSummary(LogGetSummaryParams.none(), requestOptions) } } diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/LogServiceAsyncImpl.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/LogServiceAsyncImpl.kt index 1dd0192..6797075 100644 --- a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/LogServiceAsyncImpl.kt +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/LogServiceAsyncImpl.kt @@ -3,23 +3,6 @@ package com.cas_parser.api.services.async import com.cas_parser.api.core.ClientOptions -import com.cas_parser.api.core.RequestOptions -import com.cas_parser.api.core.handlers.errorBodyHandler -import com.cas_parser.api.core.handlers.errorHandler -import com.cas_parser.api.core.handlers.jsonHandler -import com.cas_parser.api.core.http.HttpMethod -import com.cas_parser.api.core.http.HttpRequest -import com.cas_parser.api.core.http.HttpResponse -import com.cas_parser.api.core.http.HttpResponse.Handler -import com.cas_parser.api.core.http.HttpResponseFor -import com.cas_parser.api.core.http.json -import com.cas_parser.api.core.http.parseable -import com.cas_parser.api.core.prepareAsync -import com.cas_parser.api.models.logs.LogCreateParams -import com.cas_parser.api.models.logs.LogCreateResponse -import com.cas_parser.api.models.logs.LogGetSummaryParams -import com.cas_parser.api.models.logs.LogGetSummaryResponse -import java.util.concurrent.CompletableFuture import java.util.function.Consumer class LogServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : @@ -34,93 +17,14 @@ class LogServiceAsyncImpl internal constructor(private val clientOptions: Client override fun withOptions(modifier: Consumer): LogServiceAsync = LogServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - override fun create( - params: LogCreateParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // post /logs - withRawResponse().create(params, requestOptions).thenApply { it.parse() } - - override fun getSummary( - params: LogGetSummaryParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // post /logs/summary - withRawResponse().getSummary(params, requestOptions).thenApply { it.parse() } - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : LogServiceAsync.WithRawResponse { - private val errorHandler: Handler = - errorHandler(errorBodyHandler(clientOptions.jsonMapper)) - override fun withOptions( modifier: Consumer ): LogServiceAsync.WithRawResponse = LogServiceAsyncImpl.WithRawResponseImpl( clientOptions.toBuilder().apply(modifier::accept).build() ) - - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun create( - params: LogCreateParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("logs") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } - - private val getSummaryHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun getSummary( - params: LogGetSummaryParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("logs", "summary") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response - .use { getSummaryHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } } } diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/VerifyTokenServiceAsync.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/VerifyTokenServiceAsync.kt index 2a7125e..4ff8c23 100644 --- a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/VerifyTokenServiceAsync.kt +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/VerifyTokenServiceAsync.kt @@ -3,11 +3,6 @@ package com.cas_parser.api.services.async import com.cas_parser.api.core.ClientOptions -import com.cas_parser.api.core.RequestOptions -import com.cas_parser.api.core.http.HttpResponseFor -import com.cas_parser.api.models.verifytoken.VerifyTokenVerifyParams -import com.cas_parser.api.models.verifytoken.VerifyTokenVerifyResponse -import java.util.concurrent.CompletableFuture import java.util.function.Consumer interface VerifyTokenServiceAsync { @@ -24,25 +19,6 @@ interface VerifyTokenServiceAsync { */ fun withOptions(modifier: Consumer): VerifyTokenServiceAsync - /** Verify an access token and check if it's still valid. Useful for debugging token issues. */ - fun verify(): CompletableFuture = - verify(VerifyTokenVerifyParams.none()) - - /** @see verify */ - fun verify( - params: VerifyTokenVerifyParams = VerifyTokenVerifyParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** @see verify */ - fun verify( - params: VerifyTokenVerifyParams = VerifyTokenVerifyParams.none() - ): CompletableFuture = verify(params, RequestOptions.none()) - - /** @see verify */ - fun verify(requestOptions: RequestOptions): CompletableFuture = - verify(VerifyTokenVerifyParams.none(), requestOptions) - /** * A view of [VerifyTokenServiceAsync] that provides access to raw HTTP responses for each * method. @@ -57,30 +33,5 @@ interface VerifyTokenServiceAsync { fun withOptions( modifier: Consumer ): VerifyTokenServiceAsync.WithRawResponse - - /** - * Returns a raw HTTP response for `post /v1/verify-token`, but is otherwise the same as - * [VerifyTokenServiceAsync.verify]. - */ - fun verify(): CompletableFuture> = - verify(VerifyTokenVerifyParams.none()) - - /** @see verify */ - fun verify( - params: VerifyTokenVerifyParams = VerifyTokenVerifyParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - - /** @see verify */ - fun verify( - params: VerifyTokenVerifyParams = VerifyTokenVerifyParams.none() - ): CompletableFuture> = - verify(params, RequestOptions.none()) - - /** @see verify */ - fun verify( - requestOptions: RequestOptions - ): CompletableFuture> = - verify(VerifyTokenVerifyParams.none(), requestOptions) } } diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/VerifyTokenServiceAsyncImpl.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/VerifyTokenServiceAsyncImpl.kt index ba12f1b..c617351 100644 --- a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/VerifyTokenServiceAsyncImpl.kt +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/VerifyTokenServiceAsyncImpl.kt @@ -3,21 +3,6 @@ package com.cas_parser.api.services.async import com.cas_parser.api.core.ClientOptions -import com.cas_parser.api.core.RequestOptions -import com.cas_parser.api.core.handlers.errorBodyHandler -import com.cas_parser.api.core.handlers.errorHandler -import com.cas_parser.api.core.handlers.jsonHandler -import com.cas_parser.api.core.http.HttpMethod -import com.cas_parser.api.core.http.HttpRequest -import com.cas_parser.api.core.http.HttpResponse -import com.cas_parser.api.core.http.HttpResponse.Handler -import com.cas_parser.api.core.http.HttpResponseFor -import com.cas_parser.api.core.http.json -import com.cas_parser.api.core.http.parseable -import com.cas_parser.api.core.prepareAsync -import com.cas_parser.api.models.verifytoken.VerifyTokenVerifyParams -import com.cas_parser.api.models.verifytoken.VerifyTokenVerifyResponse -import java.util.concurrent.CompletableFuture import java.util.function.Consumer class VerifyTokenServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : @@ -32,55 +17,14 @@ class VerifyTokenServiceAsyncImpl internal constructor(private val clientOptions override fun withOptions(modifier: Consumer): VerifyTokenServiceAsync = VerifyTokenServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - override fun verify( - params: VerifyTokenVerifyParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // post /v1/verify-token - withRawResponse().verify(params, requestOptions).thenApply { it.parse() } - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : VerifyTokenServiceAsync.WithRawResponse { - private val errorHandler: Handler = - errorHandler(errorBodyHandler(clientOptions.jsonMapper)) - override fun withOptions( modifier: Consumer ): VerifyTokenServiceAsync.WithRawResponse = VerifyTokenServiceAsyncImpl.WithRawResponseImpl( clientOptions.toBuilder().apply(modifier::accept).build() ) - - private val verifyHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun verify( - params: VerifyTokenVerifyParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("v1", "verify-token") - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response - .use { verifyHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } } } diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/AccessTokenService.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/AccessTokenService.kt index 3414d2a..2779802 100644 --- a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/AccessTokenService.kt +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/AccessTokenService.kt @@ -3,11 +3,6 @@ package com.cas_parser.api.services.blocking import com.cas_parser.api.core.ClientOptions -import com.cas_parser.api.core.RequestOptions -import com.cas_parser.api.core.http.HttpResponseFor -import com.cas_parser.api.models.accesstoken.AccessTokenCreateParams -import com.cas_parser.api.models.accesstoken.AccessTokenCreateResponse -import com.google.errorprone.annotations.MustBeClosed import java.util.function.Consumer interface AccessTokenService { @@ -24,35 +19,6 @@ interface AccessTokenService { */ fun withOptions(modifier: Consumer): AccessTokenService - /** - * Generate a short-lived access token from your API key. - * - * **Use this endpoint from your backend** to create tokens that can be safely passed to - * frontend/SDK. - * - * Access tokens: - * - Are prefixed with `at_` for easy identification - * - Valid for up to 60 minutes - * - Can be used in place of API keys on all v4 endpoints - * - Cannot be used to generate other access tokens - */ - fun create(): AccessTokenCreateResponse = create(AccessTokenCreateParams.none()) - - /** @see create */ - fun create( - params: AccessTokenCreateParams = AccessTokenCreateParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): AccessTokenCreateResponse - - /** @see create */ - fun create( - params: AccessTokenCreateParams = AccessTokenCreateParams.none() - ): AccessTokenCreateResponse = create(params, RequestOptions.none()) - - /** @see create */ - fun create(requestOptions: RequestOptions): AccessTokenCreateResponse = - create(AccessTokenCreateParams.none(), requestOptions) - /** * A view of [AccessTokenService] that provides access to raw HTTP responses for each method. */ @@ -66,31 +32,5 @@ interface AccessTokenService { fun withOptions( modifier: Consumer ): AccessTokenService.WithRawResponse - - /** - * Returns a raw HTTP response for `post /v1/access-token`, but is otherwise the same as - * [AccessTokenService.create]. - */ - @MustBeClosed - fun create(): HttpResponseFor = - create(AccessTokenCreateParams.none()) - - /** @see create */ - @MustBeClosed - fun create( - params: AccessTokenCreateParams = AccessTokenCreateParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor - - /** @see create */ - @MustBeClosed - fun create( - params: AccessTokenCreateParams = AccessTokenCreateParams.none() - ): HttpResponseFor = create(params, RequestOptions.none()) - - /** @see create */ - @MustBeClosed - fun create(requestOptions: RequestOptions): HttpResponseFor = - create(AccessTokenCreateParams.none(), requestOptions) } } diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/AccessTokenServiceImpl.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/AccessTokenServiceImpl.kt index 9906e2d..a8c27c2 100644 --- a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/AccessTokenServiceImpl.kt +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/AccessTokenServiceImpl.kt @@ -3,20 +3,6 @@ package com.cas_parser.api.services.blocking import com.cas_parser.api.core.ClientOptions -import com.cas_parser.api.core.RequestOptions -import com.cas_parser.api.core.handlers.errorBodyHandler -import com.cas_parser.api.core.handlers.errorHandler -import com.cas_parser.api.core.handlers.jsonHandler -import com.cas_parser.api.core.http.HttpMethod -import com.cas_parser.api.core.http.HttpRequest -import com.cas_parser.api.core.http.HttpResponse -import com.cas_parser.api.core.http.HttpResponse.Handler -import com.cas_parser.api.core.http.HttpResponseFor -import com.cas_parser.api.core.http.json -import com.cas_parser.api.core.http.parseable -import com.cas_parser.api.core.prepare -import com.cas_parser.api.models.accesstoken.AccessTokenCreateParams -import com.cas_parser.api.models.accesstoken.AccessTokenCreateResponse import java.util.function.Consumer class AccessTokenServiceImpl internal constructor(private val clientOptions: ClientOptions) : @@ -31,52 +17,14 @@ class AccessTokenServiceImpl internal constructor(private val clientOptions: Cli override fun withOptions(modifier: Consumer): AccessTokenService = AccessTokenServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - override fun create( - params: AccessTokenCreateParams, - requestOptions: RequestOptions, - ): AccessTokenCreateResponse = - // post /v1/access-token - withRawResponse().create(params, requestOptions).parse() - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : AccessTokenService.WithRawResponse { - private val errorHandler: Handler = - errorHandler(errorBodyHandler(clientOptions.jsonMapper)) - override fun withOptions( modifier: Consumer ): AccessTokenService.WithRawResponse = AccessTokenServiceImpl.WithRawResponseImpl( clientOptions.toBuilder().apply(modifier::accept).build() ) - - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun create( - params: AccessTokenCreateParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("v1", "access-token") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } } } diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/CreditService.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/CreditService.kt index 5d22d46..60ebf10 100644 --- a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/CreditService.kt +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/CreditService.kt @@ -3,11 +3,6 @@ package com.cas_parser.api.services.blocking import com.cas_parser.api.core.ClientOptions -import com.cas_parser.api.core.RequestOptions -import com.cas_parser.api.core.http.HttpResponseFor -import com.cas_parser.api.models.credits.CreditCheckParams -import com.cas_parser.api.models.credits.CreditCheckResponse -import com.google.errorprone.annotations.MustBeClosed import java.util.function.Consumer interface CreditService { @@ -24,32 +19,6 @@ interface CreditService { */ fun withOptions(modifier: Consumer): CreditService - /** - * Check your remaining API credits and usage for the current billing period. - * - * Returns: - * - Number of API calls used and remaining credits - * - Credit limit and reset date - * - List of enabled features for your plan - * - * Credits reset at the start of each billing period. - */ - fun check(): CreditCheckResponse = check(CreditCheckParams.none()) - - /** @see check */ - fun check( - params: CreditCheckParams = CreditCheckParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CreditCheckResponse - - /** @see check */ - fun check(params: CreditCheckParams = CreditCheckParams.none()): CreditCheckResponse = - check(params, RequestOptions.none()) - - /** @see check */ - fun check(requestOptions: RequestOptions): CreditCheckResponse = - check(CreditCheckParams.none(), requestOptions) - /** A view of [CreditService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -59,30 +28,5 @@ interface CreditService { * The original service is not modified. */ fun withOptions(modifier: Consumer): CreditService.WithRawResponse - - /** - * Returns a raw HTTP response for `post /credits`, but is otherwise the same as - * [CreditService.check]. - */ - @MustBeClosed - fun check(): HttpResponseFor = check(CreditCheckParams.none()) - - /** @see check */ - @MustBeClosed - fun check( - params: CreditCheckParams = CreditCheckParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor - - /** @see check */ - @MustBeClosed - fun check( - params: CreditCheckParams = CreditCheckParams.none() - ): HttpResponseFor = check(params, RequestOptions.none()) - - /** @see check */ - @MustBeClosed - fun check(requestOptions: RequestOptions): HttpResponseFor = - check(CreditCheckParams.none(), requestOptions) } } diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/CreditServiceImpl.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/CreditServiceImpl.kt index 549e113..a33b3c5 100644 --- a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/CreditServiceImpl.kt +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/CreditServiceImpl.kt @@ -3,20 +3,6 @@ package com.cas_parser.api.services.blocking import com.cas_parser.api.core.ClientOptions -import com.cas_parser.api.core.RequestOptions -import com.cas_parser.api.core.handlers.errorBodyHandler -import com.cas_parser.api.core.handlers.errorHandler -import com.cas_parser.api.core.handlers.jsonHandler -import com.cas_parser.api.core.http.HttpMethod -import com.cas_parser.api.core.http.HttpRequest -import com.cas_parser.api.core.http.HttpResponse -import com.cas_parser.api.core.http.HttpResponse.Handler -import com.cas_parser.api.core.http.HttpResponseFor -import com.cas_parser.api.core.http.json -import com.cas_parser.api.core.http.parseable -import com.cas_parser.api.core.prepare -import com.cas_parser.api.models.credits.CreditCheckParams -import com.cas_parser.api.models.credits.CreditCheckResponse import java.util.function.Consumer class CreditServiceImpl internal constructor(private val clientOptions: ClientOptions) : @@ -31,52 +17,14 @@ class CreditServiceImpl internal constructor(private val clientOptions: ClientOp override fun withOptions(modifier: Consumer): CreditService = CreditServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - override fun check( - params: CreditCheckParams, - requestOptions: RequestOptions, - ): CreditCheckResponse = - // post /credits - withRawResponse().check(params, requestOptions).parse() - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : CreditService.WithRawResponse { - private val errorHandler: Handler = - errorHandler(errorBodyHandler(clientOptions.jsonMapper)) - override fun withOptions( modifier: Consumer ): CreditService.WithRawResponse = CreditServiceImpl.WithRawResponseImpl( clientOptions.toBuilder().apply(modifier::accept).build() ) - - private val checkHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun check( - params: CreditCheckParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("credits") - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response - .use { checkHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } } } diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/LogService.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/LogService.kt index ce35cba..f95703a 100644 --- a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/LogService.kt +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/LogService.kt @@ -3,13 +3,6 @@ package com.cas_parser.api.services.blocking import com.cas_parser.api.core.ClientOptions -import com.cas_parser.api.core.RequestOptions -import com.cas_parser.api.core.http.HttpResponseFor -import com.cas_parser.api.models.logs.LogCreateParams -import com.cas_parser.api.models.logs.LogCreateResponse -import com.cas_parser.api.models.logs.LogGetSummaryParams -import com.cas_parser.api.models.logs.LogGetSummaryResponse -import com.google.errorprone.annotations.MustBeClosed import java.util.function.Consumer interface LogService { @@ -26,50 +19,6 @@ interface LogService { */ fun withOptions(modifier: Consumer): LogService - /** - * Retrieve detailed API usage logs for your account. - * - * Returns a list of API calls with timestamps, features used, status codes, and credits - * consumed. Useful for monitoring usage patterns and debugging. - */ - fun create(): LogCreateResponse = create(LogCreateParams.none()) - - /** @see create */ - fun create( - params: LogCreateParams = LogCreateParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): LogCreateResponse - - /** @see create */ - fun create(params: LogCreateParams = LogCreateParams.none()): LogCreateResponse = - create(params, RequestOptions.none()) - - /** @see create */ - fun create(requestOptions: RequestOptions): LogCreateResponse = - create(LogCreateParams.none(), requestOptions) - - /** - * Get aggregated usage statistics grouped by feature. - * - * Useful for understanding which API features are being used most and tracking usage trends. - */ - fun getSummary(): LogGetSummaryResponse = getSummary(LogGetSummaryParams.none()) - - /** @see getSummary */ - fun getSummary( - params: LogGetSummaryParams = LogGetSummaryParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): LogGetSummaryResponse - - /** @see getSummary */ - fun getSummary( - params: LogGetSummaryParams = LogGetSummaryParams.none() - ): LogGetSummaryResponse = getSummary(params, RequestOptions.none()) - - /** @see getSummary */ - fun getSummary(requestOptions: RequestOptions): LogGetSummaryResponse = - getSummary(LogGetSummaryParams.none(), requestOptions) - /** A view of [LogService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -79,56 +28,5 @@ interface LogService { * The original service is not modified. */ fun withOptions(modifier: Consumer): LogService.WithRawResponse - - /** - * Returns a raw HTTP response for `post /logs`, but is otherwise the same as - * [LogService.create]. - */ - @MustBeClosed - fun create(): HttpResponseFor = create(LogCreateParams.none()) - - /** @see create */ - @MustBeClosed - fun create( - params: LogCreateParams = LogCreateParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor - - /** @see create */ - @MustBeClosed - fun create( - params: LogCreateParams = LogCreateParams.none() - ): HttpResponseFor = create(params, RequestOptions.none()) - - /** @see create */ - @MustBeClosed - fun create(requestOptions: RequestOptions): HttpResponseFor = - create(LogCreateParams.none(), requestOptions) - - /** - * Returns a raw HTTP response for `post /logs/summary`, but is otherwise the same as - * [LogService.getSummary]. - */ - @MustBeClosed - fun getSummary(): HttpResponseFor = - getSummary(LogGetSummaryParams.none()) - - /** @see getSummary */ - @MustBeClosed - fun getSummary( - params: LogGetSummaryParams = LogGetSummaryParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor - - /** @see getSummary */ - @MustBeClosed - fun getSummary( - params: LogGetSummaryParams = LogGetSummaryParams.none() - ): HttpResponseFor = getSummary(params, RequestOptions.none()) - - /** @see getSummary */ - @MustBeClosed - fun getSummary(requestOptions: RequestOptions): HttpResponseFor = - getSummary(LogGetSummaryParams.none(), requestOptions) } } diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/LogServiceImpl.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/LogServiceImpl.kt index fb303d1..0a82263 100644 --- a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/LogServiceImpl.kt +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/LogServiceImpl.kt @@ -3,22 +3,6 @@ package com.cas_parser.api.services.blocking import com.cas_parser.api.core.ClientOptions -import com.cas_parser.api.core.RequestOptions -import com.cas_parser.api.core.handlers.errorBodyHandler -import com.cas_parser.api.core.handlers.errorHandler -import com.cas_parser.api.core.handlers.jsonHandler -import com.cas_parser.api.core.http.HttpMethod -import com.cas_parser.api.core.http.HttpRequest -import com.cas_parser.api.core.http.HttpResponse -import com.cas_parser.api.core.http.HttpResponse.Handler -import com.cas_parser.api.core.http.HttpResponseFor -import com.cas_parser.api.core.http.json -import com.cas_parser.api.core.http.parseable -import com.cas_parser.api.core.prepare -import com.cas_parser.api.models.logs.LogCreateParams -import com.cas_parser.api.models.logs.LogCreateResponse -import com.cas_parser.api.models.logs.LogGetSummaryParams -import com.cas_parser.api.models.logs.LogGetSummaryResponse import java.util.function.Consumer class LogServiceImpl internal constructor(private val clientOptions: ClientOptions) : LogService { @@ -32,87 +16,14 @@ class LogServiceImpl internal constructor(private val clientOptions: ClientOptio override fun withOptions(modifier: Consumer): LogService = LogServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - override fun create( - params: LogCreateParams, - requestOptions: RequestOptions, - ): LogCreateResponse = - // post /logs - withRawResponse().create(params, requestOptions).parse() - - override fun getSummary( - params: LogGetSummaryParams, - requestOptions: RequestOptions, - ): LogGetSummaryResponse = - // post /logs/summary - withRawResponse().getSummary(params, requestOptions).parse() - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : LogService.WithRawResponse { - private val errorHandler: Handler = - errorHandler(errorBodyHandler(clientOptions.jsonMapper)) - override fun withOptions( modifier: Consumer ): LogService.WithRawResponse = LogServiceImpl.WithRawResponseImpl( clientOptions.toBuilder().apply(modifier::accept).build() ) - - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun create( - params: LogCreateParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("logs") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - - private val getSummaryHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun getSummary( - params: LogGetSummaryParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("logs", "summary") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response - .use { getSummaryHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } } } diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/VerifyTokenService.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/VerifyTokenService.kt index 6596370..a44e1df 100644 --- a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/VerifyTokenService.kt +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/VerifyTokenService.kt @@ -3,11 +3,6 @@ package com.cas_parser.api.services.blocking import com.cas_parser.api.core.ClientOptions -import com.cas_parser.api.core.RequestOptions -import com.cas_parser.api.core.http.HttpResponseFor -import com.cas_parser.api.models.verifytoken.VerifyTokenVerifyParams -import com.cas_parser.api.models.verifytoken.VerifyTokenVerifyResponse -import com.google.errorprone.annotations.MustBeClosed import java.util.function.Consumer interface VerifyTokenService { @@ -24,24 +19,6 @@ interface VerifyTokenService { */ fun withOptions(modifier: Consumer): VerifyTokenService - /** Verify an access token and check if it's still valid. Useful for debugging token issues. */ - fun verify(): VerifyTokenVerifyResponse = verify(VerifyTokenVerifyParams.none()) - - /** @see verify */ - fun verify( - params: VerifyTokenVerifyParams = VerifyTokenVerifyParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): VerifyTokenVerifyResponse - - /** @see verify */ - fun verify( - params: VerifyTokenVerifyParams = VerifyTokenVerifyParams.none() - ): VerifyTokenVerifyResponse = verify(params, RequestOptions.none()) - - /** @see verify */ - fun verify(requestOptions: RequestOptions): VerifyTokenVerifyResponse = - verify(VerifyTokenVerifyParams.none(), requestOptions) - /** * A view of [VerifyTokenService] that provides access to raw HTTP responses for each method. */ @@ -55,31 +32,5 @@ interface VerifyTokenService { fun withOptions( modifier: Consumer ): VerifyTokenService.WithRawResponse - - /** - * Returns a raw HTTP response for `post /v1/verify-token`, but is otherwise the same as - * [VerifyTokenService.verify]. - */ - @MustBeClosed - fun verify(): HttpResponseFor = - verify(VerifyTokenVerifyParams.none()) - - /** @see verify */ - @MustBeClosed - fun verify( - params: VerifyTokenVerifyParams = VerifyTokenVerifyParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor - - /** @see verify */ - @MustBeClosed - fun verify( - params: VerifyTokenVerifyParams = VerifyTokenVerifyParams.none() - ): HttpResponseFor = verify(params, RequestOptions.none()) - - /** @see verify */ - @MustBeClosed - fun verify(requestOptions: RequestOptions): HttpResponseFor = - verify(VerifyTokenVerifyParams.none(), requestOptions) } } diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/VerifyTokenServiceImpl.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/VerifyTokenServiceImpl.kt index 6780bb3..e202bbc 100644 --- a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/VerifyTokenServiceImpl.kt +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/VerifyTokenServiceImpl.kt @@ -3,20 +3,6 @@ package com.cas_parser.api.services.blocking import com.cas_parser.api.core.ClientOptions -import com.cas_parser.api.core.RequestOptions -import com.cas_parser.api.core.handlers.errorBodyHandler -import com.cas_parser.api.core.handlers.errorHandler -import com.cas_parser.api.core.handlers.jsonHandler -import com.cas_parser.api.core.http.HttpMethod -import com.cas_parser.api.core.http.HttpRequest -import com.cas_parser.api.core.http.HttpResponse -import com.cas_parser.api.core.http.HttpResponse.Handler -import com.cas_parser.api.core.http.HttpResponseFor -import com.cas_parser.api.core.http.json -import com.cas_parser.api.core.http.parseable -import com.cas_parser.api.core.prepare -import com.cas_parser.api.models.verifytoken.VerifyTokenVerifyParams -import com.cas_parser.api.models.verifytoken.VerifyTokenVerifyResponse import java.util.function.Consumer class VerifyTokenServiceImpl internal constructor(private val clientOptions: ClientOptions) : @@ -31,52 +17,14 @@ class VerifyTokenServiceImpl internal constructor(private val clientOptions: Cli override fun withOptions(modifier: Consumer): VerifyTokenService = VerifyTokenServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - override fun verify( - params: VerifyTokenVerifyParams, - requestOptions: RequestOptions, - ): VerifyTokenVerifyResponse = - // post /v1/verify-token - withRawResponse().verify(params, requestOptions).parse() - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : VerifyTokenService.WithRawResponse { - private val errorHandler: Handler = - errorHandler(errorBodyHandler(clientOptions.jsonMapper)) - override fun withOptions( modifier: Consumer ): VerifyTokenService.WithRawResponse = VerifyTokenServiceImpl.WithRawResponseImpl( clientOptions.toBuilder().apply(modifier::accept).build() ) - - private val verifyHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun verify( - params: VerifyTokenVerifyParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("v1", "verify-token") - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response - .use { verifyHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } } } diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/accesstoken/AccessTokenCreateParamsTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/accesstoken/AccessTokenCreateParamsTest.kt deleted file mode 100644 index a6a696b..0000000 --- a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/accesstoken/AccessTokenCreateParamsTest.kt +++ /dev/null @@ -1,30 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.cas_parser.api.models.accesstoken - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class AccessTokenCreateParamsTest { - - @Test - fun create() { - AccessTokenCreateParams.builder().expiryMinutes(60L).build() - } - - @Test - fun body() { - val params = AccessTokenCreateParams.builder().expiryMinutes(60L).build() - - val body = params._body() - - assertThat(body.expiryMinutes()).contains(60L) - } - - @Test - fun bodyWithoutOptionalFields() { - val params = AccessTokenCreateParams.builder().build() - - val body = params._body() - } -} diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/accesstoken/AccessTokenCreateResponseTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/accesstoken/AccessTokenCreateResponseTest.kt deleted file mode 100644 index 09382b7..0000000 --- a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/accesstoken/AccessTokenCreateResponseTest.kt +++ /dev/null @@ -1,45 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.cas_parser.api.models.accesstoken - -import com.cas_parser.api.core.jsonMapper -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class AccessTokenCreateResponseTest { - - @Test - fun create() { - val accessTokenCreateResponse = - AccessTokenCreateResponse.builder() - .accessToken("at_eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...") - .expiresIn(3600L) - .tokenType("api_key") - .build() - - assertThat(accessTokenCreateResponse.accessToken()) - .contains("at_eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...") - assertThat(accessTokenCreateResponse.expiresIn()).contains(3600L) - assertThat(accessTokenCreateResponse.tokenType()).contains("api_key") - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val accessTokenCreateResponse = - AccessTokenCreateResponse.builder() - .accessToken("at_eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...") - .expiresIn(3600L) - .tokenType("api_key") - .build() - - val roundtrippedAccessTokenCreateResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(accessTokenCreateResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedAccessTokenCreateResponse).isEqualTo(accessTokenCreateResponse) - } -} diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/credits/CreditCheckParamsTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/credits/CreditCheckParamsTest.kt deleted file mode 100644 index b26664b..0000000 --- a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/credits/CreditCheckParamsTest.kt +++ /dev/null @@ -1,13 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.cas_parser.api.models.credits - -import org.junit.jupiter.api.Test - -internal class CreditCheckParamsTest { - - @Test - fun create() { - CreditCheckParams.builder().build() - } -} diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/credits/CreditCheckResponseTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/credits/CreditCheckResponseTest.kt deleted file mode 100644 index 17d52f9..0000000 --- a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/credits/CreditCheckResponseTest.kt +++ /dev/null @@ -1,61 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.cas_parser.api.models.credits - -import com.cas_parser.api.core.jsonMapper -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import java.time.OffsetDateTime -import kotlin.jvm.optionals.getOrNull -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class CreditCheckResponseTest { - - @Test - fun create() { - val creditCheckResponse = - CreditCheckResponse.builder() - .enabledFeatures( - listOf("cams_kfintech_cas_parser", "cdsl_cas_parser", "nsdl_cas_parser") - ) - .isUnlimited(false) - .limit(50L) - .remaining(35.0) - .resetsAt(OffsetDateTime.parse("2026-02-15T00:00:00Z")) - .used(15.0) - .build() - - assertThat(creditCheckResponse.enabledFeatures().getOrNull()) - .containsExactly("cams_kfintech_cas_parser", "cdsl_cas_parser", "nsdl_cas_parser") - assertThat(creditCheckResponse.isUnlimited()).contains(false) - assertThat(creditCheckResponse.limit()).contains(50L) - assertThat(creditCheckResponse.remaining()).contains(35.0) - assertThat(creditCheckResponse.resetsAt()) - .contains(OffsetDateTime.parse("2026-02-15T00:00:00Z")) - assertThat(creditCheckResponse.used()).contains(15.0) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val creditCheckResponse = - CreditCheckResponse.builder() - .enabledFeatures( - listOf("cams_kfintech_cas_parser", "cdsl_cas_parser", "nsdl_cas_parser") - ) - .isUnlimited(false) - .limit(50L) - .remaining(35.0) - .resetsAt(OffsetDateTime.parse("2026-02-15T00:00:00Z")) - .used(15.0) - .build() - - val roundtrippedCreditCheckResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(creditCheckResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedCreditCheckResponse).isEqualTo(creditCheckResponse) - } -} diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/logs/LogCreateParamsTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/logs/LogCreateParamsTest.kt deleted file mode 100644 index e7212ba..0000000 --- a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/logs/LogCreateParamsTest.kt +++ /dev/null @@ -1,42 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.cas_parser.api.models.logs - -import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class LogCreateParamsTest { - - @Test - fun create() { - LogCreateParams.builder() - .endTime(OffsetDateTime.parse("2026-01-31T23:59:59Z")) - .limit(1L) - .startTime(OffsetDateTime.parse("2026-01-01T00:00:00Z")) - .build() - } - - @Test - fun body() { - val params = - LogCreateParams.builder() - .endTime(OffsetDateTime.parse("2026-01-31T23:59:59Z")) - .limit(1L) - .startTime(OffsetDateTime.parse("2026-01-01T00:00:00Z")) - .build() - - val body = params._body() - - assertThat(body.endTime()).contains(OffsetDateTime.parse("2026-01-31T23:59:59Z")) - assertThat(body.limit()).contains(1L) - assertThat(body.startTime()).contains(OffsetDateTime.parse("2026-01-01T00:00:00Z")) - } - - @Test - fun bodyWithoutOptionalFields() { - val params = LogCreateParams.builder().build() - - val body = params._body() - } -} diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/logs/LogCreateResponseTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/logs/LogCreateResponseTest.kt deleted file mode 100644 index 0f24a21..0000000 --- a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/logs/LogCreateResponseTest.kt +++ /dev/null @@ -1,74 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.cas_parser.api.models.logs - -import com.cas_parser.api.core.jsonMapper -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import java.time.OffsetDateTime -import kotlin.jvm.optionals.getOrNull -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class LogCreateResponseTest { - - @Test - fun create() { - val logCreateResponse = - LogCreateResponse.builder() - .count(25L) - .addLog( - LogCreateResponse.Log.builder() - .credits(1.0) - .feature("cdsl_cas_parser") - .path("/v4/cdsl/parse") - .requestId("req_2xYz7KpL8mN3Ab") - .statusCode(200L) - .timestamp(OffsetDateTime.parse("2026-01-15T14:30:00Z")) - .build() - ) - .status("success") - .build() - - assertThat(logCreateResponse.count()).contains(25L) - assertThat(logCreateResponse.logs().getOrNull()) - .containsExactly( - LogCreateResponse.Log.builder() - .credits(1.0) - .feature("cdsl_cas_parser") - .path("/v4/cdsl/parse") - .requestId("req_2xYz7KpL8mN3Ab") - .statusCode(200L) - .timestamp(OffsetDateTime.parse("2026-01-15T14:30:00Z")) - .build() - ) - assertThat(logCreateResponse.status()).contains("success") - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val logCreateResponse = - LogCreateResponse.builder() - .count(25L) - .addLog( - LogCreateResponse.Log.builder() - .credits(1.0) - .feature("cdsl_cas_parser") - .path("/v4/cdsl/parse") - .requestId("req_2xYz7KpL8mN3Ab") - .statusCode(200L) - .timestamp(OffsetDateTime.parse("2026-01-15T14:30:00Z")) - .build() - ) - .status("success") - .build() - - val roundtrippedLogCreateResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(logCreateResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedLogCreateResponse).isEqualTo(logCreateResponse) - } -} diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/logs/LogGetSummaryParamsTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/logs/LogGetSummaryParamsTest.kt deleted file mode 100644 index a2cfd4a..0000000 --- a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/logs/LogGetSummaryParamsTest.kt +++ /dev/null @@ -1,39 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.cas_parser.api.models.logs - -import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class LogGetSummaryParamsTest { - - @Test - fun create() { - LogGetSummaryParams.builder() - .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - } - - @Test - fun body() { - val params = - LogGetSummaryParams.builder() - .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - - val body = params._body() - - assertThat(body.endTime()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(body.startTime()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - } - - @Test - fun bodyWithoutOptionalFields() { - val params = LogGetSummaryParams.builder().build() - - val body = params._body() - } -} diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/logs/LogGetSummaryResponseTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/logs/LogGetSummaryResponseTest.kt deleted file mode 100644 index 94e8bc7..0000000 --- a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/logs/LogGetSummaryResponseTest.kt +++ /dev/null @@ -1,78 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.cas_parser.api.models.logs - -import com.cas_parser.api.core.jsonMapper -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class LogGetSummaryResponseTest { - - @Test - fun create() { - val logGetSummaryResponse = - LogGetSummaryResponse.builder() - .status("success") - .summary( - LogGetSummaryResponse.Summary.builder() - .addByFeature( - LogGetSummaryResponse.Summary.ByFeature.builder() - .credits(15.0) - .feature("cdsl_cas_parser") - .requests(15L) - .build() - ) - .totalCredits(45.5) - .totalRequests(42L) - .build() - ) - .build() - - assertThat(logGetSummaryResponse.status()).contains("success") - assertThat(logGetSummaryResponse.summary()) - .contains( - LogGetSummaryResponse.Summary.builder() - .addByFeature( - LogGetSummaryResponse.Summary.ByFeature.builder() - .credits(15.0) - .feature("cdsl_cas_parser") - .requests(15L) - .build() - ) - .totalCredits(45.5) - .totalRequests(42L) - .build() - ) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val logGetSummaryResponse = - LogGetSummaryResponse.builder() - .status("success") - .summary( - LogGetSummaryResponse.Summary.builder() - .addByFeature( - LogGetSummaryResponse.Summary.ByFeature.builder() - .credits(15.0) - .feature("cdsl_cas_parser") - .requests(15L) - .build() - ) - .totalCredits(45.5) - .totalRequests(42L) - .build() - ) - .build() - - val roundtrippedLogGetSummaryResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(logGetSummaryResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedLogGetSummaryResponse).isEqualTo(logGetSummaryResponse) - } -} diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/verifytoken/VerifyTokenVerifyParamsTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/verifytoken/VerifyTokenVerifyParamsTest.kt deleted file mode 100644 index 6e75d40..0000000 --- a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/verifytoken/VerifyTokenVerifyParamsTest.kt +++ /dev/null @@ -1,13 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.cas_parser.api.models.verifytoken - -import org.junit.jupiter.api.Test - -internal class VerifyTokenVerifyParamsTest { - - @Test - fun create() { - VerifyTokenVerifyParams.builder().build() - } -} diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/verifytoken/VerifyTokenVerifyResponseTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/verifytoken/VerifyTokenVerifyResponseTest.kt deleted file mode 100644 index 813bc45..0000000 --- a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/verifytoken/VerifyTokenVerifyResponseTest.kt +++ /dev/null @@ -1,44 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.cas_parser.api.models.verifytoken - -import com.cas_parser.api.core.jsonMapper -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class VerifyTokenVerifyResponseTest { - - @Test - fun create() { - val verifyTokenVerifyResponse = - VerifyTokenVerifyResponse.builder() - .error("Token has expired") - .maskedApiKey("abc1****ef23") - .valid(true) - .build() - - assertThat(verifyTokenVerifyResponse.error()).contains("Token has expired") - assertThat(verifyTokenVerifyResponse.maskedApiKey()).contains("abc1****ef23") - assertThat(verifyTokenVerifyResponse.valid()).contains(true) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val verifyTokenVerifyResponse = - VerifyTokenVerifyResponse.builder() - .error("Token has expired") - .maskedApiKey("abc1****ef23") - .valid(true) - .build() - - val roundtrippedVerifyTokenVerifyResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(verifyTokenVerifyResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedVerifyTokenVerifyResponse).isEqualTo(verifyTokenVerifyResponse) - } -} diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/ErrorHandlingTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/ErrorHandlingTest.kt index f58190a..0cce742 100644 --- a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/ErrorHandlingTest.kt +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/ErrorHandlingTest.kt @@ -16,6 +16,7 @@ import com.cas_parser.api.errors.RateLimitException import com.cas_parser.api.errors.UnauthorizedException import com.cas_parser.api.errors.UnexpectedStatusCodeException import com.cas_parser.api.errors.UnprocessableEntityException +import com.cas_parser.api.models.camskfintech.CamsKfintechParseParams import com.github.tomakehurst.wiremock.client.WireMock.anyUrl import com.github.tomakehurst.wiremock.client.WireMock.post import com.github.tomakehurst.wiremock.client.WireMock.status @@ -58,8 +59,8 @@ internal class ErrorHandlingTest { } @Test - fun creditsCheck400() { - val creditService = client.credits() + fun camsKfintechParse400() { + val camsKfintechService = client.camsKfintech() stubFor( post(anyUrl()) .willReturn( @@ -67,7 +68,16 @@ internal class ErrorHandlingTest { ) ) - val e = assertThrows { creditService.check() } + val e = + assertThrows { + camsKfintechService.parse( + CamsKfintechParseParams.builder() + .password("password") + .pdfFile("pdf_file") + .pdfUrl("https://example.com") + .build() + ) + } assertThat(e.statusCode()).isEqualTo(400) assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) @@ -75,8 +85,8 @@ internal class ErrorHandlingTest { } @Test - fun creditsCheck400WithRawResponse() { - val creditService = client.credits().withRawResponse() + fun camsKfintechParse400WithRawResponse() { + val camsKfintechService = client.camsKfintech().withRawResponse() stubFor( post(anyUrl()) .willReturn( @@ -84,7 +94,16 @@ internal class ErrorHandlingTest { ) ) - val e = assertThrows { creditService.check() } + val e = + assertThrows { + camsKfintechService.parse( + CamsKfintechParseParams.builder() + .password("password") + .pdfFile("pdf_file") + .pdfUrl("https://example.com") + .build() + ) + } assertThat(e.statusCode()).isEqualTo(400) assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) @@ -92,8 +111,8 @@ internal class ErrorHandlingTest { } @Test - fun creditsCheck401() { - val creditService = client.credits() + fun camsKfintechParse401() { + val camsKfintechService = client.camsKfintech() stubFor( post(anyUrl()) .willReturn( @@ -101,7 +120,16 @@ internal class ErrorHandlingTest { ) ) - val e = assertThrows { creditService.check() } + val e = + assertThrows { + camsKfintechService.parse( + CamsKfintechParseParams.builder() + .password("password") + .pdfFile("pdf_file") + .pdfUrl("https://example.com") + .build() + ) + } assertThat(e.statusCode()).isEqualTo(401) assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) @@ -109,8 +137,8 @@ internal class ErrorHandlingTest { } @Test - fun creditsCheck401WithRawResponse() { - val creditService = client.credits().withRawResponse() + fun camsKfintechParse401WithRawResponse() { + val camsKfintechService = client.camsKfintech().withRawResponse() stubFor( post(anyUrl()) .willReturn( @@ -118,7 +146,16 @@ internal class ErrorHandlingTest { ) ) - val e = assertThrows { creditService.check() } + val e = + assertThrows { + camsKfintechService.parse( + CamsKfintechParseParams.builder() + .password("password") + .pdfFile("pdf_file") + .pdfUrl("https://example.com") + .build() + ) + } assertThat(e.statusCode()).isEqualTo(401) assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) @@ -126,8 +163,8 @@ internal class ErrorHandlingTest { } @Test - fun creditsCheck403() { - val creditService = client.credits() + fun camsKfintechParse403() { + val camsKfintechService = client.camsKfintech() stubFor( post(anyUrl()) .willReturn( @@ -135,7 +172,16 @@ internal class ErrorHandlingTest { ) ) - val e = assertThrows { creditService.check() } + val e = + assertThrows { + camsKfintechService.parse( + CamsKfintechParseParams.builder() + .password("password") + .pdfFile("pdf_file") + .pdfUrl("https://example.com") + .build() + ) + } assertThat(e.statusCode()).isEqualTo(403) assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) @@ -143,8 +189,8 @@ internal class ErrorHandlingTest { } @Test - fun creditsCheck403WithRawResponse() { - val creditService = client.credits().withRawResponse() + fun camsKfintechParse403WithRawResponse() { + val camsKfintechService = client.camsKfintech().withRawResponse() stubFor( post(anyUrl()) .willReturn( @@ -152,7 +198,16 @@ internal class ErrorHandlingTest { ) ) - val e = assertThrows { creditService.check() } + val e = + assertThrows { + camsKfintechService.parse( + CamsKfintechParseParams.builder() + .password("password") + .pdfFile("pdf_file") + .pdfUrl("https://example.com") + .build() + ) + } assertThat(e.statusCode()).isEqualTo(403) assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) @@ -160,8 +215,8 @@ internal class ErrorHandlingTest { } @Test - fun creditsCheck404() { - val creditService = client.credits() + fun camsKfintechParse404() { + val camsKfintechService = client.camsKfintech() stubFor( post(anyUrl()) .willReturn( @@ -169,7 +224,16 @@ internal class ErrorHandlingTest { ) ) - val e = assertThrows { creditService.check() } + val e = + assertThrows { + camsKfintechService.parse( + CamsKfintechParseParams.builder() + .password("password") + .pdfFile("pdf_file") + .pdfUrl("https://example.com") + .build() + ) + } assertThat(e.statusCode()).isEqualTo(404) assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) @@ -177,8 +241,8 @@ internal class ErrorHandlingTest { } @Test - fun creditsCheck404WithRawResponse() { - val creditService = client.credits().withRawResponse() + fun camsKfintechParse404WithRawResponse() { + val camsKfintechService = client.camsKfintech().withRawResponse() stubFor( post(anyUrl()) .willReturn( @@ -186,7 +250,16 @@ internal class ErrorHandlingTest { ) ) - val e = assertThrows { creditService.check() } + val e = + assertThrows { + camsKfintechService.parse( + CamsKfintechParseParams.builder() + .password("password") + .pdfFile("pdf_file") + .pdfUrl("https://example.com") + .build() + ) + } assertThat(e.statusCode()).isEqualTo(404) assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) @@ -194,8 +267,8 @@ internal class ErrorHandlingTest { } @Test - fun creditsCheck422() { - val creditService = client.credits() + fun camsKfintechParse422() { + val camsKfintechService = client.camsKfintech() stubFor( post(anyUrl()) .willReturn( @@ -203,7 +276,16 @@ internal class ErrorHandlingTest { ) ) - val e = assertThrows { creditService.check() } + val e = + assertThrows { + camsKfintechService.parse( + CamsKfintechParseParams.builder() + .password("password") + .pdfFile("pdf_file") + .pdfUrl("https://example.com") + .build() + ) + } assertThat(e.statusCode()).isEqualTo(422) assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) @@ -211,8 +293,8 @@ internal class ErrorHandlingTest { } @Test - fun creditsCheck422WithRawResponse() { - val creditService = client.credits().withRawResponse() + fun camsKfintechParse422WithRawResponse() { + val camsKfintechService = client.camsKfintech().withRawResponse() stubFor( post(anyUrl()) .willReturn( @@ -220,7 +302,16 @@ internal class ErrorHandlingTest { ) ) - val e = assertThrows { creditService.check() } + val e = + assertThrows { + camsKfintechService.parse( + CamsKfintechParseParams.builder() + .password("password") + .pdfFile("pdf_file") + .pdfUrl("https://example.com") + .build() + ) + } assertThat(e.statusCode()).isEqualTo(422) assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) @@ -228,8 +319,8 @@ internal class ErrorHandlingTest { } @Test - fun creditsCheck429() { - val creditService = client.credits() + fun camsKfintechParse429() { + val camsKfintechService = client.camsKfintech() stubFor( post(anyUrl()) .willReturn( @@ -237,7 +328,16 @@ internal class ErrorHandlingTest { ) ) - val e = assertThrows { creditService.check() } + val e = + assertThrows { + camsKfintechService.parse( + CamsKfintechParseParams.builder() + .password("password") + .pdfFile("pdf_file") + .pdfUrl("https://example.com") + .build() + ) + } assertThat(e.statusCode()).isEqualTo(429) assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) @@ -245,8 +345,8 @@ internal class ErrorHandlingTest { } @Test - fun creditsCheck429WithRawResponse() { - val creditService = client.credits().withRawResponse() + fun camsKfintechParse429WithRawResponse() { + val camsKfintechService = client.camsKfintech().withRawResponse() stubFor( post(anyUrl()) .willReturn( @@ -254,7 +354,16 @@ internal class ErrorHandlingTest { ) ) - val e = assertThrows { creditService.check() } + val e = + assertThrows { + camsKfintechService.parse( + CamsKfintechParseParams.builder() + .password("password") + .pdfFile("pdf_file") + .pdfUrl("https://example.com") + .build() + ) + } assertThat(e.statusCode()).isEqualTo(429) assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) @@ -262,8 +371,8 @@ internal class ErrorHandlingTest { } @Test - fun creditsCheck500() { - val creditService = client.credits() + fun camsKfintechParse500() { + val camsKfintechService = client.camsKfintech() stubFor( post(anyUrl()) .willReturn( @@ -271,7 +380,16 @@ internal class ErrorHandlingTest { ) ) - val e = assertThrows { creditService.check() } + val e = + assertThrows { + camsKfintechService.parse( + CamsKfintechParseParams.builder() + .password("password") + .pdfFile("pdf_file") + .pdfUrl("https://example.com") + .build() + ) + } assertThat(e.statusCode()).isEqualTo(500) assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) @@ -279,8 +397,8 @@ internal class ErrorHandlingTest { } @Test - fun creditsCheck500WithRawResponse() { - val creditService = client.credits().withRawResponse() + fun camsKfintechParse500WithRawResponse() { + val camsKfintechService = client.camsKfintech().withRawResponse() stubFor( post(anyUrl()) .willReturn( @@ -288,7 +406,16 @@ internal class ErrorHandlingTest { ) ) - val e = assertThrows { creditService.check() } + val e = + assertThrows { + camsKfintechService.parse( + CamsKfintechParseParams.builder() + .password("password") + .pdfFile("pdf_file") + .pdfUrl("https://example.com") + .build() + ) + } assertThat(e.statusCode()).isEqualTo(500) assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) @@ -296,8 +423,8 @@ internal class ErrorHandlingTest { } @Test - fun creditsCheck999() { - val creditService = client.credits() + fun camsKfintechParse999() { + val camsKfintechService = client.camsKfintech() stubFor( post(anyUrl()) .willReturn( @@ -305,7 +432,16 @@ internal class ErrorHandlingTest { ) ) - val e = assertThrows { creditService.check() } + val e = + assertThrows { + camsKfintechService.parse( + CamsKfintechParseParams.builder() + .password("password") + .pdfFile("pdf_file") + .pdfUrl("https://example.com") + .build() + ) + } assertThat(e.statusCode()).isEqualTo(999) assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) @@ -313,8 +449,8 @@ internal class ErrorHandlingTest { } @Test - fun creditsCheck999WithRawResponse() { - val creditService = client.credits().withRawResponse() + fun camsKfintechParse999WithRawResponse() { + val camsKfintechService = client.camsKfintech().withRawResponse() stubFor( post(anyUrl()) .willReturn( @@ -322,7 +458,16 @@ internal class ErrorHandlingTest { ) ) - val e = assertThrows { creditService.check() } + val e = + assertThrows { + camsKfintechService.parse( + CamsKfintechParseParams.builder() + .password("password") + .pdfFile("pdf_file") + .pdfUrl("https://example.com") + .build() + ) + } assertThat(e.statusCode()).isEqualTo(999) assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) @@ -330,14 +475,23 @@ internal class ErrorHandlingTest { } @Test - fun creditsCheckInvalidJsonBody() { - val creditService = client.credits() + fun camsKfintechParseInvalidJsonBody() { + val camsKfintechService = client.camsKfintech() stubFor( post(anyUrl()) .willReturn(status(200).withHeader(HEADER_NAME, HEADER_VALUE).withBody(NOT_JSON)) ) - val e = assertThrows { creditService.check() } + val e = + assertThrows { + camsKfintechService.parse( + CamsKfintechParseParams.builder() + .password("password") + .pdfFile("pdf_file") + .pdfUrl("https://example.com") + .build() + ) + } assertThat(e).hasMessage("Error reading response") } diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/ServiceParamsTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/ServiceParamsTest.kt index 4cdd376..be4ed15 100644 --- a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/ServiceParamsTest.kt +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/ServiceParamsTest.kt @@ -5,7 +5,7 @@ package com.cas_parser.api.services import com.cas_parser.api.client.CasParserClient import com.cas_parser.api.client.okhttp.CasParserOkHttpClient import com.cas_parser.api.core.JsonValue -import com.cas_parser.api.models.credits.CreditCheckParams +import com.cas_parser.api.models.camskfintech.CamsKfintechParseParams import com.github.tomakehurst.wiremock.client.WireMock.anyUrl import com.github.tomakehurst.wiremock.client.WireMock.equalTo import com.github.tomakehurst.wiremock.client.WireMock.matchingJsonPath @@ -38,12 +38,15 @@ internal class ServiceParamsTest { @Disabled("Mock server tests are disabled") @Test - fun check() { - val creditService = client.credits() + fun parse() { + val camsKfintechService = client.camsKfintech() stubFor(post(anyUrl()).willReturn(ok("{}"))) - creditService.check( - CreditCheckParams.builder() + camsKfintechService.parse( + CamsKfintechParseParams.builder() + .password("password") + .pdfFile("pdf_file") + .pdfUrl("https://example.com") .putAdditionalHeader("Secret-Header", "42") .putAdditionalQueryParam("secret_query_param", "42") .putAdditionalBodyProperty("secretProperty", JsonValue.from("42")) diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/AccessTokenServiceAsyncTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/AccessTokenServiceAsyncTest.kt deleted file mode 100644 index c795a5c..0000000 --- a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/AccessTokenServiceAsyncTest.kt +++ /dev/null @@ -1,26 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.cas_parser.api.services.async - -import com.cas_parser.api.client.okhttp.CasParserOkHttpClientAsync -import com.cas_parser.api.models.accesstoken.AccessTokenCreateParams -import org.junit.jupiter.api.Disabled -import org.junit.jupiter.api.Test - -internal class AccessTokenServiceAsyncTest { - - @Disabled("Mock server tests are disabled") - @Test - fun create() { - val client = CasParserOkHttpClientAsync.builder().apiKey("My API Key").build() - val accessTokenServiceAsync = client.accessToken() - - val accessTokenFuture = - accessTokenServiceAsync.create( - AccessTokenCreateParams.builder().expiryMinutes(60L).build() - ) - - val accessToken = accessTokenFuture.get() - accessToken.validate() - } -} diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/CreditServiceAsyncTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/CreditServiceAsyncTest.kt deleted file mode 100644 index 6c9e4d8..0000000 --- a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/CreditServiceAsyncTest.kt +++ /dev/null @@ -1,22 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.cas_parser.api.services.async - -import com.cas_parser.api.client.okhttp.CasParserOkHttpClientAsync -import org.junit.jupiter.api.Disabled -import org.junit.jupiter.api.Test - -internal class CreditServiceAsyncTest { - - @Disabled("Mock server tests are disabled") - @Test - fun check() { - val client = CasParserOkHttpClientAsync.builder().apiKey("My API Key").build() - val creditServiceAsync = client.credits() - - val responseFuture = creditServiceAsync.check() - - val response = responseFuture.get() - response.validate() - } -} diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/LogServiceAsyncTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/LogServiceAsyncTest.kt deleted file mode 100644 index 532be8d..0000000 --- a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/LogServiceAsyncTest.kt +++ /dev/null @@ -1,50 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.cas_parser.api.services.async - -import com.cas_parser.api.client.okhttp.CasParserOkHttpClientAsync -import com.cas_parser.api.models.logs.LogCreateParams -import com.cas_parser.api.models.logs.LogGetSummaryParams -import java.time.OffsetDateTime -import org.junit.jupiter.api.Disabled -import org.junit.jupiter.api.Test - -internal class LogServiceAsyncTest { - - @Disabled("Mock server tests are disabled") - @Test - fun create() { - val client = CasParserOkHttpClientAsync.builder().apiKey("My API Key").build() - val logServiceAsync = client.logs() - - val logFuture = - logServiceAsync.create( - LogCreateParams.builder() - .endTime(OffsetDateTime.parse("2026-01-31T23:59:59Z")) - .limit(1L) - .startTime(OffsetDateTime.parse("2026-01-01T00:00:00Z")) - .build() - ) - - val log = logFuture.get() - log.validate() - } - - @Disabled("Mock server tests are disabled") - @Test - fun getSummary() { - val client = CasParserOkHttpClientAsync.builder().apiKey("My API Key").build() - val logServiceAsync = client.logs() - - val responseFuture = - logServiceAsync.getSummary( - LogGetSummaryParams.builder() - .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - - val response = responseFuture.get() - response.validate() - } -} diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/VerifyTokenServiceAsyncTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/VerifyTokenServiceAsyncTest.kt deleted file mode 100644 index 3d7800c..0000000 --- a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/VerifyTokenServiceAsyncTest.kt +++ /dev/null @@ -1,22 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.cas_parser.api.services.async - -import com.cas_parser.api.client.okhttp.CasParserOkHttpClientAsync -import org.junit.jupiter.api.Disabled -import org.junit.jupiter.api.Test - -internal class VerifyTokenServiceAsyncTest { - - @Disabled("Mock server tests are disabled") - @Test - fun verify() { - val client = CasParserOkHttpClientAsync.builder().apiKey("My API Key").build() - val verifyTokenServiceAsync = client.verifyToken() - - val responseFuture = verifyTokenServiceAsync.verify() - - val response = responseFuture.get() - response.validate() - } -} diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/AccessTokenServiceTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/AccessTokenServiceTest.kt deleted file mode 100644 index f7c9696..0000000 --- a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/AccessTokenServiceTest.kt +++ /dev/null @@ -1,23 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.cas_parser.api.services.blocking - -import com.cas_parser.api.client.okhttp.CasParserOkHttpClient -import com.cas_parser.api.models.accesstoken.AccessTokenCreateParams -import org.junit.jupiter.api.Disabled -import org.junit.jupiter.api.Test - -internal class AccessTokenServiceTest { - - @Disabled("Mock server tests are disabled") - @Test - fun create() { - val client = CasParserOkHttpClient.builder().apiKey("My API Key").build() - val accessTokenService = client.accessToken() - - val accessToken = - accessTokenService.create(AccessTokenCreateParams.builder().expiryMinutes(60L).build()) - - accessToken.validate() - } -} diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/CreditServiceTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/CreditServiceTest.kt deleted file mode 100644 index 94239a3..0000000 --- a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/CreditServiceTest.kt +++ /dev/null @@ -1,21 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.cas_parser.api.services.blocking - -import com.cas_parser.api.client.okhttp.CasParserOkHttpClient -import org.junit.jupiter.api.Disabled -import org.junit.jupiter.api.Test - -internal class CreditServiceTest { - - @Disabled("Mock server tests are disabled") - @Test - fun check() { - val client = CasParserOkHttpClient.builder().apiKey("My API Key").build() - val creditService = client.credits() - - val response = creditService.check() - - response.validate() - } -} diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/LogServiceTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/LogServiceTest.kt deleted file mode 100644 index 2ef5c48..0000000 --- a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/LogServiceTest.kt +++ /dev/null @@ -1,48 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.cas_parser.api.services.blocking - -import com.cas_parser.api.client.okhttp.CasParserOkHttpClient -import com.cas_parser.api.models.logs.LogCreateParams -import com.cas_parser.api.models.logs.LogGetSummaryParams -import java.time.OffsetDateTime -import org.junit.jupiter.api.Disabled -import org.junit.jupiter.api.Test - -internal class LogServiceTest { - - @Disabled("Mock server tests are disabled") - @Test - fun create() { - val client = CasParserOkHttpClient.builder().apiKey("My API Key").build() - val logService = client.logs() - - val log = - logService.create( - LogCreateParams.builder() - .endTime(OffsetDateTime.parse("2026-01-31T23:59:59Z")) - .limit(1L) - .startTime(OffsetDateTime.parse("2026-01-01T00:00:00Z")) - .build() - ) - - log.validate() - } - - @Disabled("Mock server tests are disabled") - @Test - fun getSummary() { - val client = CasParserOkHttpClient.builder().apiKey("My API Key").build() - val logService = client.logs() - - val response = - logService.getSummary( - LogGetSummaryParams.builder() - .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - - response.validate() - } -} diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/VerifyTokenServiceTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/VerifyTokenServiceTest.kt deleted file mode 100644 index 19af27d..0000000 --- a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/VerifyTokenServiceTest.kt +++ /dev/null @@ -1,21 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.cas_parser.api.services.blocking - -import com.cas_parser.api.client.okhttp.CasParserOkHttpClient -import org.junit.jupiter.api.Disabled -import org.junit.jupiter.api.Test - -internal class VerifyTokenServiceTest { - - @Disabled("Mock server tests are disabled") - @Test - fun verify() { - val client = CasParserOkHttpClient.builder().apiKey("My API Key").build() - val verifyTokenService = client.verifyToken() - - val response = verifyTokenService.verify() - - response.validate() - } -} diff --git a/cas-parser-java-proguard-test/src/test/kotlin/com/cas_parser/api/proguard/ProGuardCompatibilityTest.kt b/cas-parser-java-proguard-test/src/test/kotlin/com/cas_parser/api/proguard/ProGuardCompatibilityTest.kt index bdbc9b7..8592efc 100644 --- a/cas-parser-java-proguard-test/src/test/kotlin/com/cas_parser/api/proguard/ProGuardCompatibilityTest.kt +++ b/cas-parser-java-proguard-test/src/test/kotlin/com/cas_parser/api/proguard/ProGuardCompatibilityTest.kt @@ -4,9 +4,8 @@ package com.cas_parser.api.proguard import com.cas_parser.api.client.okhttp.CasParserOkHttpClient import com.cas_parser.api.core.jsonMapper -import com.cas_parser.api.models.credits.CreditCheckResponse +import com.cas_parser.api.models.camskfintech.LinkedHolder import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import java.time.OffsetDateTime import kotlin.reflect.full.memberFunctions import kotlin.reflect.jvm.javaMethod import org.assertj.core.api.Assertions.assertThat @@ -62,26 +61,16 @@ internal class ProGuardCompatibilityTest { } @Test - fun creditCheckResponseRoundtrip() { + fun linkedHolderRoundtrip() { val jsonMapper = jsonMapper() - val creditCheckResponse = - CreditCheckResponse.builder() - .enabledFeatures( - listOf("cams_kfintech_cas_parser", "cdsl_cas_parser", "nsdl_cas_parser") - ) - .isUnlimited(false) - .limit(50L) - .remaining(35.0) - .resetsAt(OffsetDateTime.parse("2026-02-15T00:00:00Z")) - .used(15.0) - .build() + val linkedHolder = LinkedHolder.builder().name("name").pan("pan").build() - val roundtrippedCreditCheckResponse = + val roundtrippedLinkedHolder = jsonMapper.readValue( - jsonMapper.writeValueAsString(creditCheckResponse), - jacksonTypeRef(), + jsonMapper.writeValueAsString(linkedHolder), + jacksonTypeRef(), ) - assertThat(roundtrippedCreditCheckResponse).isEqualTo(creditCheckResponse) + assertThat(roundtrippedLinkedHolder).isEqualTo(linkedHolder) } } From cfdb276b8126bf167b489ded6fc13d84ad876dad Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sun, 22 Feb 2026 23:17:51 +0000 Subject: [PATCH 10/14] feat(api): api update --- .stats.yml | 4 +- .../models/inbox/InboxListCasFilesResponse.kt | 45 ++++++++++++++++++- .../inbox/InboxListCasFilesResponseTest.kt | 3 ++ 3 files changed, 49 insertions(+), 3 deletions(-) diff --git a/.stats.yml b/.stats.yml index 80a6900..1e5b8d1 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 12 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cas-parser%2Fcas-parser-6a9d3b677dcfb856dc571865c34b3fe401e4d7f0d799edfc743acb9a55800bd0.yml -openapi_spec_hash: 037703a6c741e4310fda3f57c22fa51e +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cas-parser%2Fcas-parser-e6762e83ef7cdff129d03d0ab8c130db2fb5d1d820142847c27d72b40a0e9f53.yml +openapi_spec_hash: f38fb40a2b28bae4b0c9c4228c1c0e0d config_hash: 41c337f5cda03b13880617490f82bad0 diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/inbox/InboxListCasFilesResponse.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/inbox/InboxListCasFilesResponse.kt index 84d490e..e2c0cc3 100644 --- a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/inbox/InboxListCasFilesResponse.kt +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/inbox/InboxListCasFilesResponse.kt @@ -232,6 +232,7 @@ private constructor( private val messageDate: JsonField, private val messageId: JsonField, private val originalFilename: JsonField, + private val senderEmail: JsonField, private val size: JsonField, private val url: JsonField, private val additionalProperties: MutableMap, @@ -257,6 +258,9 @@ private constructor( @JsonProperty("original_filename") @ExcludeMissing originalFilename: JsonField = JsonMissing.of(), + @JsonProperty("sender_email") + @ExcludeMissing + senderEmail: JsonField = JsonMissing.of(), @JsonProperty("size") @ExcludeMissing size: JsonField = JsonMissing.of(), @JsonProperty("url") @ExcludeMissing url: JsonField = JsonMissing.of(), ) : this( @@ -266,6 +270,7 @@ private constructor( messageDate, messageId, originalFilename, + senderEmail, size, url, mutableMapOf(), @@ -319,6 +324,14 @@ private constructor( */ fun originalFilename(): Optional = originalFilename.getOptional("original_filename") + /** + * Email address of the CAS authority who sent this + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun senderEmail(): Optional = senderEmail.getOptional("sender_email") + /** * File size in bytes * @@ -382,6 +395,15 @@ private constructor( @ExcludeMissing fun _originalFilename(): JsonField = originalFilename + /** + * Returns the raw JSON value of [senderEmail]. + * + * Unlike [senderEmail], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("sender_email") + @ExcludeMissing + fun _senderEmail(): JsonField = senderEmail + /** * Returns the raw JSON value of [size]. * @@ -423,6 +445,7 @@ private constructor( private var messageDate: JsonField = JsonMissing.of() private var messageId: JsonField = JsonMissing.of() private var originalFilename: JsonField = JsonMissing.of() + private var senderEmail: JsonField = JsonMissing.of() private var size: JsonField = JsonMissing.of() private var url: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -435,6 +458,7 @@ private constructor( messageDate = file.messageDate messageId = file.messageId originalFilename = file.originalFilename + senderEmail = file.senderEmail size = file.size url = file.url additionalProperties = file.additionalProperties.toMutableMap() @@ -517,6 +541,20 @@ private constructor( this.originalFilename = originalFilename } + /** Email address of the CAS authority who sent this */ + fun senderEmail(senderEmail: String) = senderEmail(JsonField.of(senderEmail)) + + /** + * Sets [Builder.senderEmail] to an arbitrary JSON value. + * + * You should usually call [Builder.senderEmail] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun senderEmail(senderEmail: JsonField) = apply { + this.senderEmail = senderEmail + } + /** File size in bytes */ fun size(size: Long) = size(JsonField.of(size)) @@ -573,6 +611,7 @@ private constructor( messageDate, messageId, originalFilename, + senderEmail, size, url, additionalProperties.toMutableMap(), @@ -592,6 +631,7 @@ private constructor( messageDate() messageId() originalFilename() + senderEmail() size() url() validated = true @@ -619,6 +659,7 @@ private constructor( (if (messageDate.asKnown().isPresent) 1 else 0) + (if (messageId.asKnown().isPresent) 1 else 0) + (if (originalFilename.asKnown().isPresent) 1 else 0) + + (if (senderEmail.asKnown().isPresent) 1 else 0) + (if (size.asKnown().isPresent) 1 else 0) + (if (url.asKnown().isPresent) 1 else 0) @@ -777,6 +818,7 @@ private constructor( messageDate == other.messageDate && messageId == other.messageId && originalFilename == other.originalFilename && + senderEmail == other.senderEmail && size == other.size && url == other.url && additionalProperties == other.additionalProperties @@ -790,6 +832,7 @@ private constructor( messageDate, messageId, originalFilename, + senderEmail, size, url, additionalProperties, @@ -799,7 +842,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "File{casType=$casType, expiresIn=$expiresIn, filename=$filename, messageDate=$messageDate, messageId=$messageId, originalFilename=$originalFilename, size=$size, url=$url, additionalProperties=$additionalProperties}" + "File{casType=$casType, expiresIn=$expiresIn, filename=$filename, messageDate=$messageDate, messageId=$messageId, originalFilename=$originalFilename, senderEmail=$senderEmail, size=$size, url=$url, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/inbox/InboxListCasFilesResponseTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/inbox/InboxListCasFilesResponseTest.kt index 1f710cb..a491c06 100644 --- a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/inbox/InboxListCasFilesResponseTest.kt +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/inbox/InboxListCasFilesResponseTest.kt @@ -24,6 +24,7 @@ internal class InboxListCasFilesResponseTest { .messageDate(LocalDate.parse("2025-01-15")) .messageId("18d4a2b3c4d5e6f7") .originalFilename("CDSL_CAS_Statement.pdf") + .senderEmail("eCAS@cdslstatement.com") .size(245000L) .url( "https://cdn.casparser.in/email-cas/user123/cdsl_20250115_a1b2c3d4.pdf" @@ -43,6 +44,7 @@ internal class InboxListCasFilesResponseTest { .messageDate(LocalDate.parse("2025-01-15")) .messageId("18d4a2b3c4d5e6f7") .originalFilename("CDSL_CAS_Statement.pdf") + .senderEmail("eCAS@cdslstatement.com") .size(245000L) .url("https://cdn.casparser.in/email-cas/user123/cdsl_20250115_a1b2c3d4.pdf") .build() @@ -64,6 +66,7 @@ internal class InboxListCasFilesResponseTest { .messageDate(LocalDate.parse("2025-01-15")) .messageId("18d4a2b3c4d5e6f7") .originalFilename("CDSL_CAS_Statement.pdf") + .senderEmail("eCAS@cdslstatement.com") .size(245000L) .url( "https://cdn.casparser.in/email-cas/user123/cdsl_20250115_a1b2c3d4.pdf" From b23e22466dac01c31d286182542dc8146d5fac7d Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 23 Feb 2026 00:17:41 +0000 Subject: [PATCH 11/14] feat(api): api update --- .stats.yml | 4 ++-- .../api/models/inbox/InboxListCasFilesResponse.kt | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.stats.yml b/.stats.yml index 1e5b8d1..b880d0c 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 12 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cas-parser%2Fcas-parser-e6762e83ef7cdff129d03d0ab8c130db2fb5d1d820142847c27d72b40a0e9f53.yml -openapi_spec_hash: f38fb40a2b28bae4b0c9c4228c1c0e0d +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cas-parser%2Fcas-parser-d9763d006969b49a1473851069fdfa429eb13133b64103a62963bb70ddb22305.yml +openapi_spec_hash: 6aee689b7a759b12c85c088c15e29bc0 config_hash: 41c337f5cda03b13880617490f82bad0 diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/inbox/InboxListCasFilesResponse.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/inbox/InboxListCasFilesResponse.kt index e2c0cc3..1373c71 100644 --- a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/inbox/InboxListCasFilesResponse.kt +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/inbox/InboxListCasFilesResponse.kt @@ -325,7 +325,8 @@ private constructor( fun originalFilename(): Optional = originalFilename.getOptional("original_filename") /** - * Email address of the CAS authority who sent this + * Email address of the CAS authority (CDSL, NSDL, CAMS, or KFintech) who originally sent + * this statement * * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). @@ -541,7 +542,10 @@ private constructor( this.originalFilename = originalFilename } - /** Email address of the CAS authority who sent this */ + /** + * Email address of the CAS authority (CDSL, NSDL, CAMS, or KFintech) who originally + * sent this statement + */ fun senderEmail(senderEmail: String) = senderEmail(JsonField.of(senderEmail)) /** From 2bb349ef8822aeda2d8d47d5f0c27994f9624446 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 23 Feb 2026 02:53:14 +0000 Subject: [PATCH 12/14] feat(api): manual updates --- .stats.yml | 4 +- README.md | 70 +- .../cas_parser/api/client/CasParserClient.kt | 5 + .../api/client/CasParserClientAsync.kt | 5 + .../api/client/CasParserClientAsyncImpl.kt | 14 + .../api/client/CasParserClientImpl.kt | 14 + .../accesstoken/AccessTokenCreateParams.kt | 412 ++++++ .../accesstoken/AccessTokenCreateResponse.kt | 239 ++++ .../api/models/credits/CreditCheckParams.kt | 219 +++ .../api/models/credits/CreditCheckResponse.kt | 387 ++++++ .../inboundemail/InboundEmailCreateParams.kt | 1061 +++++++++++++++ .../InboundEmailCreateResponse.kt | 884 ++++++++++++ .../inboundemail/InboundEmailDeleteParams.kt | 241 ++++ .../InboundEmailDeleteResponse.kt | 186 +++ .../inboundemail/InboundEmailListParams.kt | 381 ++++++ .../inboundemail/InboundEmailListResponse.kt | 1194 +++++++++++++++++ .../InboundEmailRetrieveParams.kt | 197 +++ .../InboundEmailRetrieveResponse.kt | 884 ++++++++++++ .../api/models/logs/LogCreateParams.kt | 530 ++++++++ .../api/models/logs/LogCreateResponse.kt | 578 ++++++++ .../api/models/logs/LogGetSummaryParams.kt | 470 +++++++ .../api/models/logs/LogGetSummaryResponse.kt | 663 +++++++++ .../verifytoken/VerifyTokenVerifyParams.kt | 211 +++ .../verifytoken/VerifyTokenVerifyResponse.kt | 240 ++++ .../services/async/AccessTokenServiceAsync.kt | 62 + .../async/AccessTokenServiceAsyncImpl.kt | 56 + .../api/services/async/CreditServiceAsync.kt | 57 + .../services/async/CreditServiceAsyncImpl.kt | 56 + .../async/InboundEmailServiceAsync.kt | 300 +++++ .../async/InboundEmailServiceAsyncImpl.kt | 212 +++ .../api/services/async/LogServiceAsync.kt | 107 ++ .../api/services/async/LogServiceAsyncImpl.kt | 96 ++ .../services/async/VerifyTokenServiceAsync.kt | 49 + .../async/VerifyTokenServiceAsyncImpl.kt | 56 + .../services/blocking/AccessTokenService.kt | 62 + .../blocking/AccessTokenServiceImpl.kt | 52 + .../api/services/blocking/CreditService.kt | 56 + .../services/blocking/CreditServiceImpl.kt | 52 + .../services/blocking/InboundEmailService.kt | 298 ++++ .../blocking/InboundEmailServiceImpl.kt | 199 +++ .../api/services/blocking/LogService.kt | 106 ++ .../api/services/blocking/LogServiceImpl.kt | 89 ++ .../services/blocking/VerifyTokenService.kt | 49 + .../blocking/VerifyTokenServiceImpl.kt | 52 + .../AccessTokenCreateParamsTest.kt | 30 + .../AccessTokenCreateResponseTest.kt | 45 + .../models/credits/CreditCheckParamsTest.kt | 13 + .../models/credits/CreditCheckResponseTest.kt | 61 + .../InboundEmailCreateParamsTest.kt | 76 ++ .../InboundEmailCreateResponseTest.kt | 89 ++ .../InboundEmailDeleteParamsTest.kt | 23 + .../InboundEmailDeleteResponseTest.kt | 41 + .../InboundEmailListParamsTest.kt | 49 + .../InboundEmailListResponseTest.kt | 105 ++ .../InboundEmailRetrieveParamsTest.kt | 23 + .../InboundEmailRetrieveResponseTest.kt | 89 ++ .../api/models/logs/LogCreateParamsTest.kt | 42 + .../api/models/logs/LogCreateResponseTest.kt | 74 + .../models/logs/LogGetSummaryParamsTest.kt | 39 + .../models/logs/LogGetSummaryResponseTest.kt | 78 ++ .../VerifyTokenVerifyParamsTest.kt | 13 + .../VerifyTokenVerifyResponseTest.kt | 44 + .../api/services/ErrorHandlingTest.kt | 256 +--- .../api/services/ServiceParamsTest.kt | 13 +- .../async/AccessTokenServiceAsyncTest.kt | 26 + .../services/async/CreditServiceAsyncTest.kt | 22 + .../async/InboundEmailServiceAsyncTest.kt | 83 ++ .../api/services/async/LogServiceAsyncTest.kt | 50 + .../async/VerifyTokenServiceAsyncTest.kt | 22 + .../blocking/AccessTokenServiceTest.kt | 23 + .../services/blocking/CreditServiceTest.kt | 21 + .../blocking/InboundEmailServiceTest.kt | 79 ++ .../api/services/blocking/LogServiceTest.kt | 48 + .../blocking/VerifyTokenServiceTest.kt | 21 + .../api/proguard/ProGuardCompatibilityTest.kt | 26 +- 75 files changed, 12522 insertions(+), 257 deletions(-) create mode 100644 cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/accesstoken/AccessTokenCreateParams.kt create mode 100644 cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/accesstoken/AccessTokenCreateResponse.kt create mode 100644 cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/credits/CreditCheckParams.kt create mode 100644 cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/credits/CreditCheckResponse.kt create mode 100644 cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/inboundemail/InboundEmailCreateParams.kt create mode 100644 cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/inboundemail/InboundEmailCreateResponse.kt create mode 100644 cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/inboundemail/InboundEmailDeleteParams.kt create mode 100644 cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/inboundemail/InboundEmailDeleteResponse.kt create mode 100644 cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/inboundemail/InboundEmailListParams.kt create mode 100644 cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/inboundemail/InboundEmailListResponse.kt create mode 100644 cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/inboundemail/InboundEmailRetrieveParams.kt create mode 100644 cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/inboundemail/InboundEmailRetrieveResponse.kt create mode 100644 cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/logs/LogCreateParams.kt create mode 100644 cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/logs/LogCreateResponse.kt create mode 100644 cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/logs/LogGetSummaryParams.kt create mode 100644 cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/logs/LogGetSummaryResponse.kt create mode 100644 cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/verifytoken/VerifyTokenVerifyParams.kt create mode 100644 cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/verifytoken/VerifyTokenVerifyResponse.kt create mode 100644 cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/InboundEmailServiceAsync.kt create mode 100644 cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/InboundEmailServiceAsyncImpl.kt create mode 100644 cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/InboundEmailService.kt create mode 100644 cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/InboundEmailServiceImpl.kt create mode 100644 cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/accesstoken/AccessTokenCreateParamsTest.kt create mode 100644 cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/accesstoken/AccessTokenCreateResponseTest.kt create mode 100644 cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/credits/CreditCheckParamsTest.kt create mode 100644 cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/credits/CreditCheckResponseTest.kt create mode 100644 cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/inboundemail/InboundEmailCreateParamsTest.kt create mode 100644 cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/inboundemail/InboundEmailCreateResponseTest.kt create mode 100644 cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/inboundemail/InboundEmailDeleteParamsTest.kt create mode 100644 cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/inboundemail/InboundEmailDeleteResponseTest.kt create mode 100644 cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/inboundemail/InboundEmailListParamsTest.kt create mode 100644 cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/inboundemail/InboundEmailListResponseTest.kt create mode 100644 cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/inboundemail/InboundEmailRetrieveParamsTest.kt create mode 100644 cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/inboundemail/InboundEmailRetrieveResponseTest.kt create mode 100644 cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/logs/LogCreateParamsTest.kt create mode 100644 cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/logs/LogCreateResponseTest.kt create mode 100644 cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/logs/LogGetSummaryParamsTest.kt create mode 100644 cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/logs/LogGetSummaryResponseTest.kt create mode 100644 cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/verifytoken/VerifyTokenVerifyParamsTest.kt create mode 100644 cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/verifytoken/VerifyTokenVerifyResponseTest.kt create mode 100644 cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/AccessTokenServiceAsyncTest.kt create mode 100644 cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/CreditServiceAsyncTest.kt create mode 100644 cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/InboundEmailServiceAsyncTest.kt create mode 100644 cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/LogServiceAsyncTest.kt create mode 100644 cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/VerifyTokenServiceAsyncTest.kt create mode 100644 cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/AccessTokenServiceTest.kt create mode 100644 cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/CreditServiceTest.kt create mode 100644 cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/InboundEmailServiceTest.kt create mode 100644 cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/LogServiceTest.kt create mode 100644 cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/VerifyTokenServiceTest.kt diff --git a/.stats.yml b/.stats.yml index b880d0c..cdf3c0a 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ -configured_endpoints: 12 +configured_endpoints: 21 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cas-parser%2Fcas-parser-d9763d006969b49a1473851069fdfa429eb13133b64103a62963bb70ddb22305.yml openapi_spec_hash: 6aee689b7a759b12c85c088c15e29bc0 -config_hash: 41c337f5cda03b13880617490f82bad0 +config_hash: d54f39abb185904495bef7c5f8702746 diff --git a/README.md b/README.md index 50e5c0c..212151b 100644 --- a/README.md +++ b/README.md @@ -57,14 +57,14 @@ This library requires Java 8 or later. ```java import com.cas_parser.api.client.CasParserClient; import com.cas_parser.api.client.okhttp.CasParserOkHttpClient; -import com.cas_parser.api.models.camskfintech.CamsKfintechParseParams; -import com.cas_parser.api.models.camskfintech.UnifiedResponse; +import com.cas_parser.api.models.credits.CreditCheckParams; +import com.cas_parser.api.models.credits.CreditCheckResponse; // Configures using the `casparser.apiKey` and `casparser.baseUrl` system properties // Or configures using the `CAS_PARSER_API_KEY` and `CAS_PARSER_BASE_URL` environment variables CasParserClient client = CasParserOkHttpClient.fromEnv(); -UnifiedResponse unifiedResponse = client.camsKfintech().parse(); +CreditCheckResponse response = client.credits().check(); ``` ## Client configuration @@ -137,7 +137,7 @@ The `withOptions()` method does not affect the original client or service. To send a request to the Cas Parser API, build an instance of some `Params` class and pass it to the corresponding client method. When the response is received, it will be deserialized into an instance of a Java class. -For example, `client.camsKfintech().parse(...)` should be called with an instance of `CamsKfintechParseParams`, and it will return an instance of `UnifiedResponse`. +For example, `client.credits().check(...)` should be called with an instance of `CreditCheckParams`, and it will return an instance of `CreditCheckResponse`. ## Immutability @@ -154,15 +154,15 @@ The default client is synchronous. To switch to asynchronous execution, call the ```java import com.cas_parser.api.client.CasParserClient; import com.cas_parser.api.client.okhttp.CasParserOkHttpClient; -import com.cas_parser.api.models.camskfintech.CamsKfintechParseParams; -import com.cas_parser.api.models.camskfintech.UnifiedResponse; +import com.cas_parser.api.models.credits.CreditCheckParams; +import com.cas_parser.api.models.credits.CreditCheckResponse; import java.util.concurrent.CompletableFuture; // Configures using the `casparser.apiKey` and `casparser.baseUrl` system properties // Or configures using the `CAS_PARSER_API_KEY` and `CAS_PARSER_BASE_URL` environment variables CasParserClient client = CasParserOkHttpClient.fromEnv(); -CompletableFuture unifiedResponse = client.async().camsKfintech().parse(); +CompletableFuture response = client.async().credits().check(); ``` Or create an asynchronous client from the beginning: @@ -170,15 +170,15 @@ Or create an asynchronous client from the beginning: ```java import com.cas_parser.api.client.CasParserClientAsync; import com.cas_parser.api.client.okhttp.CasParserOkHttpClientAsync; -import com.cas_parser.api.models.camskfintech.CamsKfintechParseParams; -import com.cas_parser.api.models.camskfintech.UnifiedResponse; +import com.cas_parser.api.models.credits.CreditCheckParams; +import com.cas_parser.api.models.credits.CreditCheckResponse; import java.util.concurrent.CompletableFuture; // Configures using the `casparser.apiKey` and `casparser.baseUrl` system properties // Or configures using the `CAS_PARSER_API_KEY` and `CAS_PARSER_BASE_URL` environment variables CasParserClientAsync client = CasParserOkHttpClientAsync.fromEnv(); -CompletableFuture unifiedResponse = client.camsKfintech().parse(); +CompletableFuture response = client.credits().check(); ``` The asynchronous client supports the same options as the synchronous one, except most methods return `CompletableFuture`s. @@ -192,21 +192,21 @@ To access this data, prefix any HTTP method call on a client or service with `wi ```java import com.cas_parser.api.core.http.Headers; import com.cas_parser.api.core.http.HttpResponseFor; -import com.cas_parser.api.models.camskfintech.CamsKfintechParseParams; -import com.cas_parser.api.models.camskfintech.UnifiedResponse; +import com.cas_parser.api.models.credits.CreditCheckParams; +import com.cas_parser.api.models.credits.CreditCheckResponse; -HttpResponseFor unifiedResponse = client.camsKfintech().withRawResponse().parse(); +HttpResponseFor response = client.credits().withRawResponse().check(); -int statusCode = unifiedResponse.statusCode(); -Headers headers = unifiedResponse.headers(); +int statusCode = response.statusCode(); +Headers headers = response.headers(); ``` You can still deserialize the response into an instance of a Java class if needed: ```java -import com.cas_parser.api.models.camskfintech.UnifiedResponse; +import com.cas_parser.api.models.credits.CreditCheckResponse; -UnifiedResponse parsedUnifiedResponse = unifiedResponse.parse(); +CreditCheckResponse parsedResponse = response.parse(); ``` ## Error handling @@ -304,9 +304,9 @@ Requests time out after 1 minute by default. To set a custom timeout, configure the method call using the `timeout` method: ```java -import com.cas_parser.api.models.camskfintech.UnifiedResponse; +import com.cas_parser.api.models.credits.CreditCheckResponse; -UnifiedResponse unifiedResponse = client.camsKfintech().parse(RequestOptions.builder().timeout(Duration.ofSeconds(30)).build()); +CreditCheckResponse response = client.credits().check(RequestOptions.builder().timeout(Duration.ofSeconds(30)).build()); ``` Or configure the default for all method calls at the client level: @@ -443,9 +443,9 @@ To set undocumented parameters, call the `putAdditionalHeader`, `putAdditionalQu ```java import com.cas_parser.api.core.JsonValue; -import com.cas_parser.api.models.camskfintech.CamsKfintechParseParams; +import com.cas_parser.api.models.credits.CreditCheckParams; -CamsKfintechParseParams params = CamsKfintechParseParams.builder() +CreditCheckParams params = CreditCheckParams.builder() .putAdditionalHeader("Secret-Header", "42") .putAdditionalQueryParam("secret_query_param", "42") .putAdditionalBodyProperty("secretProperty", JsonValue.from("42")) @@ -457,9 +457,9 @@ These can be accessed on the built object later using the `_additionalHeaders()` To set a documented parameter or property to an undocumented or not yet supported _value_, pass a [`JsonValue`](cas-parser-java-core/src/main/kotlin/com/cas_parser/api/core/Values.kt) object to its setter: ```java -import com.cas_parser.api.models.camskfintech.CamsKfintechParseParams; +import com.cas_parser.api.models.credits.CreditCheckParams; -CamsKfintechParseParams params = CamsKfintechParseParams.builder().build(); +CreditCheckParams params = CreditCheckParams.builder().build(); ``` The most straightforward way to create a [`JsonValue`](cas-parser-java-core/src/main/kotlin/com/cas_parser/api/core/Values.kt) is using its `from(...)` method: @@ -507,10 +507,10 @@ To forcibly omit a required parameter or property, pass [`JsonMissing`](cas-pars ```java import com.cas_parser.api.core.JsonMissing; -import com.cas_parser.api.models.camskfintech.CamsKfintechParseParams; import com.cas_parser.api.models.cdsl.fetch.FetchRequestOtpParams; +import com.cas_parser.api.models.credits.CreditCheckParams; -CamsKfintechParseParams params = FetchRequestOtpParams.builder() +CreditCheckParams params = FetchRequestOtpParams.builder() .dob("1990-01-15") .pan("ABCDE1234F") .boId(JsonMissing.of()) @@ -525,7 +525,7 @@ To access undocumented response properties, call the `_additionalProperties()` m import com.cas_parser.api.core.JsonValue; import java.util.Map; -Map additionalProperties = client.camsKfintech().parse(params)._additionalProperties(); +Map additionalProperties = client.credits().check(params)._additionalProperties(); JsonValue secretPropertyValue = additionalProperties.get("secretProperty"); String result = secretPropertyValue.accept(new JsonValue.Visitor<>() { @@ -555,19 +555,19 @@ To access a property's raw JSON value, which may be undocumented, call its `_` p import com.cas_parser.api.core.JsonField; import java.util.Optional; -JsonField password = client.camsKfintech().parse(params)._password(); +JsonField field = client.credits().check(params)._field(); -if (password.isMissing()) { +if (field.isMissing()) { // The property is absent from the JSON response -} else if (password.isNull()) { +} else if (field.isNull()) { // The property was set to literal null } else { // Check if value was provided as a string // Other methods include `asNumber()`, `asBoolean()`, etc. - Optional jsonString = password.asString(); + Optional jsonString = field.asString(); // Try to deserialize into a custom type - MyClass myObject = password.asUnknown().orElseThrow().convert(MyClass.class); + MyClass myObject = field.asUnknown().orElseThrow().convert(MyClass.class); } ``` @@ -580,17 +580,17 @@ By default, the SDK will not throw an exception in this case. It will throw [`Ca If you would prefer to check that the response is completely well-typed upfront, then either call `validate()`: ```java -import com.cas_parser.api.models.camskfintech.UnifiedResponse; +import com.cas_parser.api.models.credits.CreditCheckResponse; -UnifiedResponse unifiedResponse = client.camsKfintech().parse(params).validate(); +CreditCheckResponse response = client.credits().check(params).validate(); ``` Or configure the method call to validate the response using the `responseValidation` method: ```java -import com.cas_parser.api.models.camskfintech.UnifiedResponse; +import com.cas_parser.api.models.credits.CreditCheckResponse; -UnifiedResponse unifiedResponse = client.camsKfintech().parse(RequestOptions.builder().responseValidation(true).build()); +CreditCheckResponse response = client.credits().check(RequestOptions.builder().responseValidation(true).build()); ``` Or configure the default for all method calls at the client level: diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/client/CasParserClient.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/client/CasParserClient.kt index 87a671b..df928cf 100644 --- a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/client/CasParserClient.kt +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/client/CasParserClient.kt @@ -8,6 +8,7 @@ import com.cas_parser.api.services.blocking.CamsKfintechService import com.cas_parser.api.services.blocking.CdslService import com.cas_parser.api.services.blocking.ContractNoteService import com.cas_parser.api.services.blocking.CreditService +import com.cas_parser.api.services.blocking.InboundEmailService import com.cas_parser.api.services.blocking.InboxService import com.cas_parser.api.services.blocking.KfintechService import com.cas_parser.api.services.blocking.LogService @@ -74,6 +75,8 @@ interface CasParserClient { fun smart(): SmartService + fun inboundEmail(): InboundEmailService + /** * Closes this client, relinquishing any underlying resources. * @@ -118,5 +121,7 @@ interface CasParserClient { fun nsdl(): NsdlService.WithRawResponse fun smart(): SmartService.WithRawResponse + + fun inboundEmail(): InboundEmailService.WithRawResponse } } diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/client/CasParserClientAsync.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/client/CasParserClientAsync.kt index 22f6ad3..4d828d5 100644 --- a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/client/CasParserClientAsync.kt +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/client/CasParserClientAsync.kt @@ -8,6 +8,7 @@ import com.cas_parser.api.services.async.CamsKfintechServiceAsync import com.cas_parser.api.services.async.CdslServiceAsync import com.cas_parser.api.services.async.ContractNoteServiceAsync import com.cas_parser.api.services.async.CreditServiceAsync +import com.cas_parser.api.services.async.InboundEmailServiceAsync import com.cas_parser.api.services.async.InboxServiceAsync import com.cas_parser.api.services.async.KfintechServiceAsync import com.cas_parser.api.services.async.LogServiceAsync @@ -74,6 +75,8 @@ interface CasParserClientAsync { fun smart(): SmartServiceAsync + fun inboundEmail(): InboundEmailServiceAsync + /** * Closes this client, relinquishing any underlying resources. * @@ -122,5 +125,7 @@ interface CasParserClientAsync { fun nsdl(): NsdlServiceAsync.WithRawResponse fun smart(): SmartServiceAsync.WithRawResponse + + fun inboundEmail(): InboundEmailServiceAsync.WithRawResponse } } diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/client/CasParserClientAsyncImpl.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/client/CasParserClientAsyncImpl.kt index 5f28136..b10af0a 100644 --- a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/client/CasParserClientAsyncImpl.kt +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/client/CasParserClientAsyncImpl.kt @@ -14,6 +14,8 @@ import com.cas_parser.api.services.async.ContractNoteServiceAsync import com.cas_parser.api.services.async.ContractNoteServiceAsyncImpl import com.cas_parser.api.services.async.CreditServiceAsync import com.cas_parser.api.services.async.CreditServiceAsyncImpl +import com.cas_parser.api.services.async.InboundEmailServiceAsync +import com.cas_parser.api.services.async.InboundEmailServiceAsyncImpl import com.cas_parser.api.services.async.InboxServiceAsync import com.cas_parser.api.services.async.InboxServiceAsyncImpl import com.cas_parser.api.services.async.KfintechServiceAsync @@ -83,6 +85,10 @@ class CasParserClientAsyncImpl(private val clientOptions: ClientOptions) : CasPa SmartServiceAsyncImpl(clientOptionsWithUserAgent) } + private val inboundEmail: InboundEmailServiceAsync by lazy { + InboundEmailServiceAsyncImpl(clientOptionsWithUserAgent) + } + override fun sync(): CasParserClient = sync override fun withRawResponse(): CasParserClientAsync.WithRawResponse = withRawResponse @@ -112,6 +118,8 @@ class CasParserClientAsyncImpl(private val clientOptions: ClientOptions) : CasPa override fun smart(): SmartServiceAsync = smart + override fun inboundEmail(): InboundEmailServiceAsync = inboundEmail + override fun close() = clientOptions.close() class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : @@ -161,6 +169,10 @@ class CasParserClientAsyncImpl(private val clientOptions: ClientOptions) : CasPa SmartServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + private val inboundEmail: InboundEmailServiceAsync.WithRawResponse by lazy { + InboundEmailServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + override fun withOptions( modifier: Consumer ): CasParserClientAsync.WithRawResponse = @@ -189,5 +201,7 @@ class CasParserClientAsyncImpl(private val clientOptions: ClientOptions) : CasPa override fun nsdl(): NsdlServiceAsync.WithRawResponse = nsdl override fun smart(): SmartServiceAsync.WithRawResponse = smart + + override fun inboundEmail(): InboundEmailServiceAsync.WithRawResponse = inboundEmail } } diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/client/CasParserClientImpl.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/client/CasParserClientImpl.kt index f4b18e8..db32253 100644 --- a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/client/CasParserClientImpl.kt +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/client/CasParserClientImpl.kt @@ -14,6 +14,8 @@ import com.cas_parser.api.services.blocking.ContractNoteService import com.cas_parser.api.services.blocking.ContractNoteServiceImpl import com.cas_parser.api.services.blocking.CreditService import com.cas_parser.api.services.blocking.CreditServiceImpl +import com.cas_parser.api.services.blocking.InboundEmailService +import com.cas_parser.api.services.blocking.InboundEmailServiceImpl import com.cas_parser.api.services.blocking.InboxService import com.cas_parser.api.services.blocking.InboxServiceImpl import com.cas_parser.api.services.blocking.KfintechService @@ -77,6 +79,10 @@ class CasParserClientImpl(private val clientOptions: ClientOptions) : CasParserC private val smart: SmartService by lazy { SmartServiceImpl(clientOptionsWithUserAgent) } + private val inboundEmail: InboundEmailService by lazy { + InboundEmailServiceImpl(clientOptionsWithUserAgent) + } + override fun async(): CasParserClientAsync = async override fun withRawResponse(): CasParserClient.WithRawResponse = withRawResponse @@ -106,6 +112,8 @@ class CasParserClientImpl(private val clientOptions: ClientOptions) : CasParserC override fun smart(): SmartService = smart + override fun inboundEmail(): InboundEmailService = inboundEmail + override fun close() = clientOptions.close() class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : @@ -155,6 +163,10 @@ class CasParserClientImpl(private val clientOptions: ClientOptions) : CasParserC SmartServiceImpl.WithRawResponseImpl(clientOptions) } + private val inboundEmail: InboundEmailService.WithRawResponse by lazy { + InboundEmailServiceImpl.WithRawResponseImpl(clientOptions) + } + override fun withOptions( modifier: Consumer ): CasParserClient.WithRawResponse = @@ -183,5 +195,7 @@ class CasParserClientImpl(private val clientOptions: ClientOptions) : CasParserC override fun nsdl(): NsdlService.WithRawResponse = nsdl override fun smart(): SmartService.WithRawResponse = smart + + override fun inboundEmail(): InboundEmailService.WithRawResponse = inboundEmail } } diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/accesstoken/AccessTokenCreateParams.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/accesstoken/AccessTokenCreateParams.kt new file mode 100644 index 0000000..93daf86 --- /dev/null +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/accesstoken/AccessTokenCreateParams.kt @@ -0,0 +1,412 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.models.accesstoken + +import com.cas_parser.api.core.ExcludeMissing +import com.cas_parser.api.core.JsonField +import com.cas_parser.api.core.JsonMissing +import com.cas_parser.api.core.JsonValue +import com.cas_parser.api.core.Params +import com.cas_parser.api.core.http.Headers +import com.cas_parser.api.core.http.QueryParams +import com.cas_parser.api.errors.CasParserInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional + +/** + * Generate a short-lived access token from your API key. + * + * **Use this endpoint from your backend** to create tokens that can be safely passed to + * frontend/SDK. + * + * **Legacy path:** `/v1/access-token` (still supported) + * + * Access tokens: + * - Are prefixed with `at_` for easy identification + * - Valid for up to 60 minutes + * - Can be used in place of API keys on all v4 endpoints + * - Cannot be used to generate other access tokens + */ +class AccessTokenCreateParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * Token validity in minutes (max 60) + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun expiryMinutes(): Optional = body.expiryMinutes() + + /** + * Returns the raw JSON value of [expiryMinutes]. + * + * Unlike [expiryMinutes], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _expiryMinutes(): JsonField = body._expiryMinutes() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): AccessTokenCreateParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [AccessTokenCreateParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AccessTokenCreateParams]. */ + class Builder internal constructor() { + + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(accessTokenCreateParams: AccessTokenCreateParams) = apply { + body = accessTokenCreateParams.body.toBuilder() + additionalHeaders = accessTokenCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = accessTokenCreateParams.additionalQueryParams.toBuilder() + } + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [expiryMinutes] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** Token validity in minutes (max 60) */ + fun expiryMinutes(expiryMinutes: Long) = apply { body.expiryMinutes(expiryMinutes) } + + /** + * Sets [Builder.expiryMinutes] to an arbitrary JSON value. + * + * You should usually call [Builder.expiryMinutes] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun expiryMinutes(expiryMinutes: JsonField) = apply { + body.expiryMinutes(expiryMinutes) + } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [AccessTokenCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): AccessTokenCreateParams = + AccessTokenCreateParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val expiryMinutes: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("expiry_minutes") + @ExcludeMissing + expiryMinutes: JsonField = JsonMissing.of() + ) : this(expiryMinutes, mutableMapOf()) + + /** + * Token validity in minutes (max 60) + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun expiryMinutes(): Optional = expiryMinutes.getOptional("expiry_minutes") + + /** + * Returns the raw JSON value of [expiryMinutes]. + * + * Unlike [expiryMinutes], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("expiry_minutes") + @ExcludeMissing + fun _expiryMinutes(): JsonField = expiryMinutes + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Body]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var expiryMinutes: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + expiryMinutes = body.expiryMinutes + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** Token validity in minutes (max 60) */ + fun expiryMinutes(expiryMinutes: Long) = expiryMinutes(JsonField.of(expiryMinutes)) + + /** + * Sets [Builder.expiryMinutes] to an arbitrary JSON value. + * + * You should usually call [Builder.expiryMinutes] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun expiryMinutes(expiryMinutes: JsonField) = apply { + this.expiryMinutes = expiryMinutes + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Body = Body(expiryMinutes, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + expiryMinutes() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CasParserInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (if (expiryMinutes.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + expiryMinutes == other.expiryMinutes && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(expiryMinutes, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{expiryMinutes=$expiryMinutes, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AccessTokenCreateParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "AccessTokenCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/accesstoken/AccessTokenCreateResponse.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/accesstoken/AccessTokenCreateResponse.kt new file mode 100644 index 0000000..a23d37b --- /dev/null +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/accesstoken/AccessTokenCreateResponse.kt @@ -0,0 +1,239 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.models.accesstoken + +import com.cas_parser.api.core.ExcludeMissing +import com.cas_parser.api.core.JsonField +import com.cas_parser.api.core.JsonMissing +import com.cas_parser.api.core.JsonValue +import com.cas_parser.api.errors.CasParserInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional + +class AccessTokenCreateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val accessToken: JsonField, + private val expiresIn: JsonField, + private val tokenType: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("access_token") + @ExcludeMissing + accessToken: JsonField = JsonMissing.of(), + @JsonProperty("expires_in") @ExcludeMissing expiresIn: JsonField = JsonMissing.of(), + @JsonProperty("token_type") @ExcludeMissing tokenType: JsonField = JsonMissing.of(), + ) : this(accessToken, expiresIn, tokenType, mutableMapOf()) + + /** + * The at_ prefixed access token + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun accessToken(): Optional = accessToken.getOptional("access_token") + + /** + * Token validity in seconds + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun expiresIn(): Optional = expiresIn.getOptional("expires_in") + + /** + * Always "api_key" - token is a drop-in replacement for x-api-key header + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tokenType(): Optional = tokenType.getOptional("token_type") + + /** + * Returns the raw JSON value of [accessToken]. + * + * Unlike [accessToken], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("access_token") + @ExcludeMissing + fun _accessToken(): JsonField = accessToken + + /** + * Returns the raw JSON value of [expiresIn]. + * + * Unlike [expiresIn], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("expires_in") @ExcludeMissing fun _expiresIn(): JsonField = expiresIn + + /** + * Returns the raw JSON value of [tokenType]. + * + * Unlike [tokenType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("token_type") @ExcludeMissing fun _tokenType(): JsonField = tokenType + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [AccessTokenCreateResponse]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AccessTokenCreateResponse]. */ + class Builder internal constructor() { + + private var accessToken: JsonField = JsonMissing.of() + private var expiresIn: JsonField = JsonMissing.of() + private var tokenType: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(accessTokenCreateResponse: AccessTokenCreateResponse) = apply { + accessToken = accessTokenCreateResponse.accessToken + expiresIn = accessTokenCreateResponse.expiresIn + tokenType = accessTokenCreateResponse.tokenType + additionalProperties = accessTokenCreateResponse.additionalProperties.toMutableMap() + } + + /** The at_ prefixed access token */ + fun accessToken(accessToken: String) = accessToken(JsonField.of(accessToken)) + + /** + * Sets [Builder.accessToken] to an arbitrary JSON value. + * + * You should usually call [Builder.accessToken] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun accessToken(accessToken: JsonField) = apply { this.accessToken = accessToken } + + /** Token validity in seconds */ + fun expiresIn(expiresIn: Long) = expiresIn(JsonField.of(expiresIn)) + + /** + * Sets [Builder.expiresIn] to an arbitrary JSON value. + * + * You should usually call [Builder.expiresIn] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun expiresIn(expiresIn: JsonField) = apply { this.expiresIn = expiresIn } + + /** Always "api_key" - token is a drop-in replacement for x-api-key header */ + fun tokenType(tokenType: String) = tokenType(JsonField.of(tokenType)) + + /** + * Sets [Builder.tokenType] to an arbitrary JSON value. + * + * You should usually call [Builder.tokenType] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun tokenType(tokenType: JsonField) = apply { this.tokenType = tokenType } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AccessTokenCreateResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): AccessTokenCreateResponse = + AccessTokenCreateResponse( + accessToken, + expiresIn, + tokenType, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AccessTokenCreateResponse = apply { + if (validated) { + return@apply + } + + accessToken() + expiresIn() + tokenType() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CasParserInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (accessToken.asKnown().isPresent) 1 else 0) + + (if (expiresIn.asKnown().isPresent) 1 else 0) + + (if (tokenType.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AccessTokenCreateResponse && + accessToken == other.accessToken && + expiresIn == other.expiresIn && + tokenType == other.tokenType && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(accessToken, expiresIn, tokenType, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AccessTokenCreateResponse{accessToken=$accessToken, expiresIn=$expiresIn, tokenType=$tokenType, additionalProperties=$additionalProperties}" +} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/credits/CreditCheckParams.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/credits/CreditCheckParams.kt new file mode 100644 index 0000000..aa45ce8 --- /dev/null +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/credits/CreditCheckParams.kt @@ -0,0 +1,219 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.models.credits + +import com.cas_parser.api.core.JsonValue +import com.cas_parser.api.core.Params +import com.cas_parser.api.core.http.Headers +import com.cas_parser.api.core.http.QueryParams +import com.cas_parser.api.core.toImmutable +import java.util.Objects +import java.util.Optional + +/** + * Check your remaining API credits and usage for the current billing period. + * + * Returns: + * - Number of API calls used and remaining credits + * - Credit limit and reset date + * - List of enabled features for your plan + * + * Credits reset at the start of each billing period. + */ +class CreditCheckParams +private constructor( + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map, +) : Params { + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): CreditCheckParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [CreditCheckParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CreditCheckParams]. */ + class Builder internal constructor() { + + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(creditCheckParams: CreditCheckParams) = apply { + additionalHeaders = creditCheckParams.additionalHeaders.toBuilder() + additionalQueryParams = creditCheckParams.additionalQueryParams.toBuilder() + additionalBodyProperties = creditCheckParams.additionalBodyProperties.toMutableMap() + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [CreditCheckParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CreditCheckParams = + CreditCheckParams( + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CreditCheckParams && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash(additionalHeaders, additionalQueryParams, additionalBodyProperties) + + override fun toString() = + "CreditCheckParams{additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/credits/CreditCheckResponse.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/credits/CreditCheckResponse.kt new file mode 100644 index 0000000..6a3f1a3 --- /dev/null +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/credits/CreditCheckResponse.kt @@ -0,0 +1,387 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.models.credits + +import com.cas_parser.api.core.ExcludeMissing +import com.cas_parser.api.core.JsonField +import com.cas_parser.api.core.JsonMissing +import com.cas_parser.api.core.JsonValue +import com.cas_parser.api.core.checkKnown +import com.cas_parser.api.core.toImmutable +import com.cas_parser.api.errors.CasParserInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class CreditCheckResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val enabledFeatures: JsonField>, + private val isUnlimited: JsonField, + private val limit: JsonField, + private val remaining: JsonField, + private val resetsAt: JsonField, + private val used: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("enabled_features") + @ExcludeMissing + enabledFeatures: JsonField> = JsonMissing.of(), + @JsonProperty("is_unlimited") + @ExcludeMissing + isUnlimited: JsonField = JsonMissing.of(), + @JsonProperty("limit") @ExcludeMissing limit: JsonField = JsonMissing.of(), + @JsonProperty("remaining") @ExcludeMissing remaining: JsonField = JsonMissing.of(), + @JsonProperty("resets_at") + @ExcludeMissing + resetsAt: JsonField = JsonMissing.of(), + @JsonProperty("used") @ExcludeMissing used: JsonField = JsonMissing.of(), + ) : this(enabledFeatures, isUnlimited, limit, remaining, resetsAt, used, mutableMapOf()) + + /** + * List of API features enabled for your plan + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun enabledFeatures(): Optional> = enabledFeatures.getOptional("enabled_features") + + /** + * Whether the account has unlimited credits + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun isUnlimited(): Optional = isUnlimited.getOptional("is_unlimited") + + /** + * Total credit limit for billing period + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun limit(): Optional = limit.getOptional("limit") + + /** + * Remaining credits (null if unlimited) + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun remaining(): Optional = remaining.getOptional("remaining") + + /** + * When credits reset (ISO 8601) + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun resetsAt(): Optional = resetsAt.getOptional("resets_at") + + /** + * Number of credits used this billing period + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun used(): Optional = used.getOptional("used") + + /** + * Returns the raw JSON value of [enabledFeatures]. + * + * Unlike [enabledFeatures], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("enabled_features") + @ExcludeMissing + fun _enabledFeatures(): JsonField> = enabledFeatures + + /** + * Returns the raw JSON value of [isUnlimited]. + * + * Unlike [isUnlimited], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("is_unlimited") + @ExcludeMissing + fun _isUnlimited(): JsonField = isUnlimited + + /** + * Returns the raw JSON value of [limit]. + * + * Unlike [limit], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("limit") @ExcludeMissing fun _limit(): JsonField = limit + + /** + * Returns the raw JSON value of [remaining]. + * + * Unlike [remaining], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("remaining") @ExcludeMissing fun _remaining(): JsonField = remaining + + /** + * Returns the raw JSON value of [resetsAt]. + * + * Unlike [resetsAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("resets_at") @ExcludeMissing fun _resetsAt(): JsonField = resetsAt + + /** + * Returns the raw JSON value of [used]. + * + * Unlike [used], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("used") @ExcludeMissing fun _used(): JsonField = used + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [CreditCheckResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CreditCheckResponse]. */ + class Builder internal constructor() { + + private var enabledFeatures: JsonField>? = null + private var isUnlimited: JsonField = JsonMissing.of() + private var limit: JsonField = JsonMissing.of() + private var remaining: JsonField = JsonMissing.of() + private var resetsAt: JsonField = JsonMissing.of() + private var used: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(creditCheckResponse: CreditCheckResponse) = apply { + enabledFeatures = creditCheckResponse.enabledFeatures.map { it.toMutableList() } + isUnlimited = creditCheckResponse.isUnlimited + limit = creditCheckResponse.limit + remaining = creditCheckResponse.remaining + resetsAt = creditCheckResponse.resetsAt + used = creditCheckResponse.used + additionalProperties = creditCheckResponse.additionalProperties.toMutableMap() + } + + /** List of API features enabled for your plan */ + fun enabledFeatures(enabledFeatures: List) = + enabledFeatures(JsonField.of(enabledFeatures)) + + /** + * Sets [Builder.enabledFeatures] to an arbitrary JSON value. + * + * You should usually call [Builder.enabledFeatures] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun enabledFeatures(enabledFeatures: JsonField>) = apply { + this.enabledFeatures = enabledFeatures.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [enabledFeatures]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addEnabledFeature(enabledFeature: String) = apply { + enabledFeatures = + (enabledFeatures ?: JsonField.of(mutableListOf())).also { + checkKnown("enabledFeatures", it).add(enabledFeature) + } + } + + /** Whether the account has unlimited credits */ + fun isUnlimited(isUnlimited: Boolean) = isUnlimited(JsonField.of(isUnlimited)) + + /** + * Sets [Builder.isUnlimited] to an arbitrary JSON value. + * + * You should usually call [Builder.isUnlimited] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun isUnlimited(isUnlimited: JsonField) = apply { this.isUnlimited = isUnlimited } + + /** Total credit limit for billing period */ + fun limit(limit: Long) = limit(JsonField.of(limit)) + + /** + * Sets [Builder.limit] to an arbitrary JSON value. + * + * You should usually call [Builder.limit] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun limit(limit: JsonField) = apply { this.limit = limit } + + /** Remaining credits (null if unlimited) */ + fun remaining(remaining: Double?) = remaining(JsonField.ofNullable(remaining)) + + /** + * Alias for [Builder.remaining]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun remaining(remaining: Double) = remaining(remaining as Double?) + + /** Alias for calling [Builder.remaining] with `remaining.orElse(null)`. */ + fun remaining(remaining: Optional) = remaining(remaining.getOrNull()) + + /** + * Sets [Builder.remaining] to an arbitrary JSON value. + * + * You should usually call [Builder.remaining] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun remaining(remaining: JsonField) = apply { this.remaining = remaining } + + /** When credits reset (ISO 8601) */ + fun resetsAt(resetsAt: OffsetDateTime?) = resetsAt(JsonField.ofNullable(resetsAt)) + + /** Alias for calling [Builder.resetsAt] with `resetsAt.orElse(null)`. */ + fun resetsAt(resetsAt: Optional) = resetsAt(resetsAt.getOrNull()) + + /** + * Sets [Builder.resetsAt] to an arbitrary JSON value. + * + * You should usually call [Builder.resetsAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun resetsAt(resetsAt: JsonField) = apply { this.resetsAt = resetsAt } + + /** Number of credits used this billing period */ + fun used(used: Double) = used(JsonField.of(used)) + + /** + * Sets [Builder.used] to an arbitrary JSON value. + * + * You should usually call [Builder.used] with a well-typed [Double] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun used(used: JsonField) = apply { this.used = used } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CreditCheckResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CreditCheckResponse = + CreditCheckResponse( + (enabledFeatures ?: JsonMissing.of()).map { it.toImmutable() }, + isUnlimited, + limit, + remaining, + resetsAt, + used, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CreditCheckResponse = apply { + if (validated) { + return@apply + } + + enabledFeatures() + isUnlimited() + limit() + remaining() + resetsAt() + used() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CasParserInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (enabledFeatures.asKnown().getOrNull()?.size ?: 0) + + (if (isUnlimited.asKnown().isPresent) 1 else 0) + + (if (limit.asKnown().isPresent) 1 else 0) + + (if (remaining.asKnown().isPresent) 1 else 0) + + (if (resetsAt.asKnown().isPresent) 1 else 0) + + (if (used.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CreditCheckResponse && + enabledFeatures == other.enabledFeatures && + isUnlimited == other.isUnlimited && + limit == other.limit && + remaining == other.remaining && + resetsAt == other.resetsAt && + used == other.used && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + enabledFeatures, + isUnlimited, + limit, + remaining, + resetsAt, + used, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CreditCheckResponse{enabledFeatures=$enabledFeatures, isUnlimited=$isUnlimited, limit=$limit, remaining=$remaining, resetsAt=$resetsAt, used=$used, additionalProperties=$additionalProperties}" +} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/inboundemail/InboundEmailCreateParams.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/inboundemail/InboundEmailCreateParams.kt new file mode 100644 index 0000000..a20d52b --- /dev/null +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/inboundemail/InboundEmailCreateParams.kt @@ -0,0 +1,1061 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.models.inboundemail + +import com.cas_parser.api.core.Enum +import com.cas_parser.api.core.ExcludeMissing +import com.cas_parser.api.core.JsonField +import com.cas_parser.api.core.JsonMissing +import com.cas_parser.api.core.JsonValue +import com.cas_parser.api.core.Params +import com.cas_parser.api.core.checkKnown +import com.cas_parser.api.core.checkRequired +import com.cas_parser.api.core.http.Headers +import com.cas_parser.api.core.http.QueryParams +import com.cas_parser.api.core.toImmutable +import com.cas_parser.api.errors.CasParserInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Create a dedicated inbound email address for collecting CAS statements via email forwarding. + * + * **How it works:** + * 1. Create an inbound email with your webhook URL + * 2. Display the email address to your user (e.g., "Forward your CAS to + * ie_xxx@import.casparser.in") + * 3. When an investor forwards a CAS email, we verify the sender and deliver to your webhook + * + * **Webhook Delivery:** + * - We POST to your `callback_url` with JSON body containing files (matching EmailCASFile schema) + * - Failed deliveries are retried automatically with exponential backoff + * + * **Inactivity:** + * - Inbound emails with no activity in 30 days are marked inactive + * - Active inbound emails remain operational indefinitely + */ +class InboundEmailCreateParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * Webhook URL where we POST email notifications. Must be HTTPS in production (HTTP allowed for + * localhost during development). + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun callbackUrl(): String = body.callbackUrl() + + /** + * Optional custom email prefix for user-friendly addresses. + * - Must be 3-32 characters + * - Alphanumeric + hyphens only + * - Must start and end with letter/number + * - Example: `john-portfolio@import.casparser.in` + * - If omitted, generates random ID like `ie_abc123xyz@import.casparser.in` + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun alias(): Optional = body.alias() + + /** + * Filter emails by CAS provider. If omitted, accepts all providers. + * - `cdsl` → eCAS@cdslstatement.com + * - `nsdl` → NSDL-CAS@nsdl.co.in + * - `cams` → donotreply@camsonline.com + * - `kfintech` → samfS@kfintech.com + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun allowedSources(): Optional> = body.allowedSources() + + /** + * Optional key-value pairs (max 10) to include in webhook payload. Useful for passing context + * like plan_type, campaign_id, etc. + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun metadata(): Optional = body.metadata() + + /** + * Your internal identifier (e.g., user_id, account_id). Returned in webhook payload for + * correlation. + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun reference(): Optional = body.reference() + + /** + * Returns the raw JSON value of [callbackUrl]. + * + * Unlike [callbackUrl], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _callbackUrl(): JsonField = body._callbackUrl() + + /** + * Returns the raw JSON value of [alias]. + * + * Unlike [alias], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _alias(): JsonField = body._alias() + + /** + * Returns the raw JSON value of [allowedSources]. + * + * Unlike [allowedSources], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _allowedSources(): JsonField> = body._allowedSources() + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _metadata(): JsonField = body._metadata() + + /** + * Returns the raw JSON value of [reference]. + * + * Unlike [reference], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _reference(): JsonField = body._reference() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [InboundEmailCreateParams]. + * + * The following fields are required: + * ```java + * .callbackUrl() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InboundEmailCreateParams]. */ + class Builder internal constructor() { + + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(inboundEmailCreateParams: InboundEmailCreateParams) = apply { + body = inboundEmailCreateParams.body.toBuilder() + additionalHeaders = inboundEmailCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = inboundEmailCreateParams.additionalQueryParams.toBuilder() + } + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [callbackUrl] + * - [alias] + * - [allowedSources] + * - [metadata] + * - [reference] + * - etc. + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** + * Webhook URL where we POST email notifications. Must be HTTPS in production (HTTP allowed + * for localhost during development). + */ + fun callbackUrl(callbackUrl: String) = apply { body.callbackUrl(callbackUrl) } + + /** + * Sets [Builder.callbackUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.callbackUrl] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun callbackUrl(callbackUrl: JsonField) = apply { body.callbackUrl(callbackUrl) } + + /** + * Optional custom email prefix for user-friendly addresses. + * - Must be 3-32 characters + * - Alphanumeric + hyphens only + * - Must start and end with letter/number + * - Example: `john-portfolio@import.casparser.in` + * - If omitted, generates random ID like `ie_abc123xyz@import.casparser.in` + */ + fun alias(alias: String) = apply { body.alias(alias) } + + /** + * Sets [Builder.alias] to an arbitrary JSON value. + * + * You should usually call [Builder.alias] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun alias(alias: JsonField) = apply { body.alias(alias) } + + /** + * Filter emails by CAS provider. If omitted, accepts all providers. + * - `cdsl` → eCAS@cdslstatement.com + * - `nsdl` → NSDL-CAS@nsdl.co.in + * - `cams` → donotreply@camsonline.com + * - `kfintech` → samfS@kfintech.com + */ + fun allowedSources(allowedSources: List) = apply { + body.allowedSources(allowedSources) + } + + /** + * Sets [Builder.allowedSources] to an arbitrary JSON value. + * + * You should usually call [Builder.allowedSources] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun allowedSources(allowedSources: JsonField>) = apply { + body.allowedSources(allowedSources) + } + + /** + * Adds a single [AllowedSource] to [allowedSources]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAllowedSource(allowedSource: AllowedSource) = apply { + body.addAllowedSource(allowedSource) + } + + /** + * Optional key-value pairs (max 10) to include in webhook payload. Useful for passing + * context like plan_type, campaign_id, etc. + */ + fun metadata(metadata: Metadata) = apply { body.metadata(metadata) } + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun metadata(metadata: JsonField) = apply { body.metadata(metadata) } + + /** + * Your internal identifier (e.g., user_id, account_id). Returned in webhook payload for + * correlation. + */ + fun reference(reference: String) = apply { body.reference(reference) } + + /** + * Sets [Builder.reference] to an arbitrary JSON value. + * + * You should usually call [Builder.reference] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun reference(reference: JsonField) = apply { body.reference(reference) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [InboundEmailCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .callbackUrl() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): InboundEmailCreateParams = + InboundEmailCreateParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val callbackUrl: JsonField, + private val alias: JsonField, + private val allowedSources: JsonField>, + private val metadata: JsonField, + private val reference: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("callback_url") + @ExcludeMissing + callbackUrl: JsonField = JsonMissing.of(), + @JsonProperty("alias") @ExcludeMissing alias: JsonField = JsonMissing.of(), + @JsonProperty("allowed_sources") + @ExcludeMissing + allowedSources: JsonField> = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference") + @ExcludeMissing + reference: JsonField = JsonMissing.of(), + ) : this(callbackUrl, alias, allowedSources, metadata, reference, mutableMapOf()) + + /** + * Webhook URL where we POST email notifications. Must be HTTPS in production (HTTP allowed + * for localhost during development). + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun callbackUrl(): String = callbackUrl.getRequired("callback_url") + + /** + * Optional custom email prefix for user-friendly addresses. + * - Must be 3-32 characters + * - Alphanumeric + hyphens only + * - Must start and end with letter/number + * - Example: `john-portfolio@import.casparser.in` + * - If omitted, generates random ID like `ie_abc123xyz@import.casparser.in` + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun alias(): Optional = alias.getOptional("alias") + + /** + * Filter emails by CAS provider. If omitted, accepts all providers. + * - `cdsl` → eCAS@cdslstatement.com + * - `nsdl` → NSDL-CAS@nsdl.co.in + * - `cams` → donotreply@camsonline.com + * - `kfintech` → samfS@kfintech.com + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun allowedSources(): Optional> = + allowedSources.getOptional("allowed_sources") + + /** + * Optional key-value pairs (max 10) to include in webhook payload. Useful for passing + * context like plan_type, campaign_id, etc. + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * Your internal identifier (e.g., user_id, account_id). Returned in webhook payload for + * correlation. + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun reference(): Optional = reference.getOptional("reference") + + /** + * Returns the raw JSON value of [callbackUrl]. + * + * Unlike [callbackUrl], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("callback_url") + @ExcludeMissing + fun _callbackUrl(): JsonField = callbackUrl + + /** + * Returns the raw JSON value of [alias]. + * + * Unlike [alias], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("alias") @ExcludeMissing fun _alias(): JsonField = alias + + /** + * Returns the raw JSON value of [allowedSources]. + * + * Unlike [allowedSources], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("allowed_sources") + @ExcludeMissing + fun _allowedSources(): JsonField> = allowedSources + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [reference]. + * + * Unlike [reference], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("reference") @ExcludeMissing fun _reference(): JsonField = reference + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .callbackUrl() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var callbackUrl: JsonField? = null + private var alias: JsonField = JsonMissing.of() + private var allowedSources: JsonField>? = null + private var metadata: JsonField = JsonMissing.of() + private var reference: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + callbackUrl = body.callbackUrl + alias = body.alias + allowedSources = body.allowedSources.map { it.toMutableList() } + metadata = body.metadata + reference = body.reference + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** + * Webhook URL where we POST email notifications. Must be HTTPS in production (HTTP + * allowed for localhost during development). + */ + fun callbackUrl(callbackUrl: String) = callbackUrl(JsonField.of(callbackUrl)) + + /** + * Sets [Builder.callbackUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.callbackUrl] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun callbackUrl(callbackUrl: JsonField) = apply { + this.callbackUrl = callbackUrl + } + + /** + * Optional custom email prefix for user-friendly addresses. + * - Must be 3-32 characters + * - Alphanumeric + hyphens only + * - Must start and end with letter/number + * - Example: `john-portfolio@import.casparser.in` + * - If omitted, generates random ID like `ie_abc123xyz@import.casparser.in` + */ + fun alias(alias: String) = alias(JsonField.of(alias)) + + /** + * Sets [Builder.alias] to an arbitrary JSON value. + * + * You should usually call [Builder.alias] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun alias(alias: JsonField) = apply { this.alias = alias } + + /** + * Filter emails by CAS provider. If omitted, accepts all providers. + * - `cdsl` → eCAS@cdslstatement.com + * - `nsdl` → NSDL-CAS@nsdl.co.in + * - `cams` → donotreply@camsonline.com + * - `kfintech` → samfS@kfintech.com + */ + fun allowedSources(allowedSources: List) = + allowedSources(JsonField.of(allowedSources)) + + /** + * Sets [Builder.allowedSources] to an arbitrary JSON value. + * + * You should usually call [Builder.allowedSources] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun allowedSources(allowedSources: JsonField>) = apply { + this.allowedSources = allowedSources.map { it.toMutableList() } + } + + /** + * Adds a single [AllowedSource] to [allowedSources]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAllowedSource(allowedSource: AllowedSource) = apply { + allowedSources = + (allowedSources ?: JsonField.of(mutableListOf())).also { + checkKnown("allowedSources", it).add(allowedSource) + } + } + + /** + * Optional key-value pairs (max 10) to include in webhook payload. Useful for passing + * context like plan_type, campaign_id, etc. + */ + fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * Your internal identifier (e.g., user_id, account_id). Returned in webhook payload for + * correlation. + */ + fun reference(reference: String) = reference(JsonField.of(reference)) + + /** + * Sets [Builder.reference] to an arbitrary JSON value. + * + * You should usually call [Builder.reference] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun reference(reference: JsonField) = apply { this.reference = reference } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .callbackUrl() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("callbackUrl", callbackUrl), + alias, + (allowedSources ?: JsonMissing.of()).map { it.toImmutable() }, + metadata, + reference, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + callbackUrl() + alias() + allowedSources().ifPresent { it.forEach { it.validate() } } + metadata().ifPresent { it.validate() } + reference() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CasParserInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (callbackUrl.asKnown().isPresent) 1 else 0) + + (if (alias.asKnown().isPresent) 1 else 0) + + (allowedSources.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (reference.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + callbackUrl == other.callbackUrl && + alias == other.alias && + allowedSources == other.allowedSources && + metadata == other.metadata && + reference == other.reference && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + callbackUrl, + alias, + allowedSources, + metadata, + reference, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{callbackUrl=$callbackUrl, alias=$alias, allowedSources=$allowedSources, metadata=$metadata, reference=$reference, additionalProperties=$additionalProperties}" + } + + class AllowedSource @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val CDSL = of("cdsl") + + @JvmField val NSDL = of("nsdl") + + @JvmField val CAMS = of("cams") + + @JvmField val KFINTECH = of("kfintech") + + @JvmStatic fun of(value: String) = AllowedSource(JsonField.of(value)) + } + + /** An enum containing [AllowedSource]'s known values. */ + enum class Known { + CDSL, + NSDL, + CAMS, + KFINTECH, + } + + /** + * An enum containing [AllowedSource]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [AllowedSource] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + CDSL, + NSDL, + CAMS, + KFINTECH, + /** + * An enum member indicating that [AllowedSource] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + CDSL -> Value.CDSL + NSDL -> Value.NSDL + CAMS -> Value.CAMS + KFINTECH -> Value.KFINTECH + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws CasParserInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + CDSL -> Known.CDSL + NSDL -> Known.NSDL + CAMS -> Known.CAMS + KFINTECH -> Known.KFINTECH + else -> throw CasParserInvalidDataException("Unknown AllowedSource: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws CasParserInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + CasParserInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): AllowedSource = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CasParserInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AllowedSource && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * Optional key-value pairs (max 10) to include in webhook payload. Useful for passing context + * like plan_type, campaign_id, etc. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CasParserInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InboundEmailCreateParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "InboundEmailCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/inboundemail/InboundEmailCreateResponse.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/inboundemail/InboundEmailCreateResponse.kt new file mode 100644 index 0000000..fb3d9d5 --- /dev/null +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/inboundemail/InboundEmailCreateResponse.kt @@ -0,0 +1,884 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.models.inboundemail + +import com.cas_parser.api.core.Enum +import com.cas_parser.api.core.ExcludeMissing +import com.cas_parser.api.core.JsonField +import com.cas_parser.api.core.JsonMissing +import com.cas_parser.api.core.JsonValue +import com.cas_parser.api.core.checkKnown +import com.cas_parser.api.core.toImmutable +import com.cas_parser.api.errors.CasParserInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** An inbound email address for receiving forwarded CAS emails */ +class InboundEmailCreateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val allowedSources: JsonField>, + private val callbackUrl: JsonField, + private val createdAt: JsonField, + private val email: JsonField, + private val inboundEmailId: JsonField, + private val metadata: JsonField, + private val reference: JsonField, + private val status: JsonField, + private val updatedAt: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("allowed_sources") + @ExcludeMissing + allowedSources: JsonField> = JsonMissing.of(), + @JsonProperty("callback_url") + @ExcludeMissing + callbackUrl: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField = JsonMissing.of(), + @JsonProperty("email") @ExcludeMissing email: JsonField = JsonMissing.of(), + @JsonProperty("inbound_email_id") + @ExcludeMissing + inboundEmailId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference") @ExcludeMissing reference: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + @JsonProperty("updated_at") + @ExcludeMissing + updatedAt: JsonField = JsonMissing.of(), + ) : this( + allowedSources, + callbackUrl, + createdAt, + email, + inboundEmailId, + metadata, + reference, + status, + updatedAt, + mutableMapOf(), + ) + + /** + * Accepted CAS providers (empty = all) + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun allowedSources(): Optional> = + allowedSources.getOptional("allowed_sources") + + /** + * Webhook URL for email notifications + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun callbackUrl(): Optional = callbackUrl.getOptional("callback_url") + + /** + * When the mailbox was created + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun createdAt(): Optional = createdAt.getOptional("created_at") + + /** + * The inbound email address to forward CAS statements to + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun email(): Optional = email.getOptional("email") + + /** + * Unique inbound email identifier + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun inboundEmailId(): Optional = inboundEmailId.getOptional("inbound_email_id") + + /** + * Custom key-value metadata + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * Your internal reference identifier + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun reference(): Optional = reference.getOptional("reference") + + /** + * Current mailbox status + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun status(): Optional = status.getOptional("status") + + /** + * When the mailbox was last updated + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun updatedAt(): Optional = updatedAt.getOptional("updated_at") + + /** + * Returns the raw JSON value of [allowedSources]. + * + * Unlike [allowedSources], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("allowed_sources") + @ExcludeMissing + fun _allowedSources(): JsonField> = allowedSources + + /** + * Returns the raw JSON value of [callbackUrl]. + * + * Unlike [callbackUrl], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("callback_url") + @ExcludeMissing + fun _callbackUrl(): JsonField = callbackUrl + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt + + /** + * Returns the raw JSON value of [email]. + * + * Unlike [email], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("email") @ExcludeMissing fun _email(): JsonField = email + + /** + * Returns the raw JSON value of [inboundEmailId]. + * + * Unlike [inboundEmailId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("inbound_email_id") + @ExcludeMissing + fun _inboundEmailId(): JsonField = inboundEmailId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [reference]. + * + * Unlike [reference], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("reference") @ExcludeMissing fun _reference(): JsonField = reference + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [updatedAt]. + * + * Unlike [updatedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("updated_at") + @ExcludeMissing + fun _updatedAt(): JsonField = updatedAt + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [InboundEmailCreateResponse]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InboundEmailCreateResponse]. */ + class Builder internal constructor() { + + private var allowedSources: JsonField>? = null + private var callbackUrl: JsonField = JsonMissing.of() + private var createdAt: JsonField = JsonMissing.of() + private var email: JsonField = JsonMissing.of() + private var inboundEmailId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var reference: JsonField = JsonMissing.of() + private var status: JsonField = JsonMissing.of() + private var updatedAt: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(inboundEmailCreateResponse: InboundEmailCreateResponse) = apply { + allowedSources = inboundEmailCreateResponse.allowedSources.map { it.toMutableList() } + callbackUrl = inboundEmailCreateResponse.callbackUrl + createdAt = inboundEmailCreateResponse.createdAt + email = inboundEmailCreateResponse.email + inboundEmailId = inboundEmailCreateResponse.inboundEmailId + metadata = inboundEmailCreateResponse.metadata + reference = inboundEmailCreateResponse.reference + status = inboundEmailCreateResponse.status + updatedAt = inboundEmailCreateResponse.updatedAt + additionalProperties = inboundEmailCreateResponse.additionalProperties.toMutableMap() + } + + /** Accepted CAS providers (empty = all) */ + fun allowedSources(allowedSources: List) = + allowedSources(JsonField.of(allowedSources)) + + /** + * Sets [Builder.allowedSources] to an arbitrary JSON value. + * + * You should usually call [Builder.allowedSources] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun allowedSources(allowedSources: JsonField>) = apply { + this.allowedSources = allowedSources.map { it.toMutableList() } + } + + /** + * Adds a single [AllowedSource] to [allowedSources]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAllowedSource(allowedSource: AllowedSource) = apply { + allowedSources = + (allowedSources ?: JsonField.of(mutableListOf())).also { + checkKnown("allowedSources", it).add(allowedSource) + } + } + + /** Webhook URL for email notifications */ + fun callbackUrl(callbackUrl: String) = callbackUrl(JsonField.of(callbackUrl)) + + /** + * Sets [Builder.callbackUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.callbackUrl] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun callbackUrl(callbackUrl: JsonField) = apply { this.callbackUrl = callbackUrl } + + /** When the mailbox was created */ + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } + + /** The inbound email address to forward CAS statements to */ + fun email(email: String) = email(JsonField.of(email)) + + /** + * Sets [Builder.email] to an arbitrary JSON value. + * + * You should usually call [Builder.email] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun email(email: JsonField) = apply { this.email = email } + + /** Unique inbound email identifier */ + fun inboundEmailId(inboundEmailId: String) = inboundEmailId(JsonField.of(inboundEmailId)) + + /** + * Sets [Builder.inboundEmailId] to an arbitrary JSON value. + * + * You should usually call [Builder.inboundEmailId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun inboundEmailId(inboundEmailId: JsonField) = apply { + this.inboundEmailId = inboundEmailId + } + + /** Custom key-value metadata */ + fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** Your internal reference identifier */ + fun reference(reference: String?) = reference(JsonField.ofNullable(reference)) + + /** Alias for calling [Builder.reference] with `reference.orElse(null)`. */ + fun reference(reference: Optional) = reference(reference.getOrNull()) + + /** + * Sets [Builder.reference] to an arbitrary JSON value. + * + * You should usually call [Builder.reference] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun reference(reference: JsonField) = apply { this.reference = reference } + + /** Current mailbox status */ + fun status(status: Status) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Status] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + /** When the mailbox was last updated */ + fun updatedAt(updatedAt: OffsetDateTime) = updatedAt(JsonField.of(updatedAt)) + + /** + * Sets [Builder.updatedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.updatedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun updatedAt(updatedAt: JsonField) = apply { this.updatedAt = updatedAt } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [InboundEmailCreateResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): InboundEmailCreateResponse = + InboundEmailCreateResponse( + (allowedSources ?: JsonMissing.of()).map { it.toImmutable() }, + callbackUrl, + createdAt, + email, + inboundEmailId, + metadata, + reference, + status, + updatedAt, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): InboundEmailCreateResponse = apply { + if (validated) { + return@apply + } + + allowedSources().ifPresent { it.forEach { it.validate() } } + callbackUrl() + createdAt() + email() + inboundEmailId() + metadata().ifPresent { it.validate() } + reference() + status().ifPresent { it.validate() } + updatedAt() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CasParserInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (allowedSources.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (callbackUrl.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (email.asKnown().isPresent) 1 else 0) + + (if (inboundEmailId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (reference.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (if (updatedAt.asKnown().isPresent) 1 else 0) + + class AllowedSource @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val CDSL = of("cdsl") + + @JvmField val NSDL = of("nsdl") + + @JvmField val CAMS = of("cams") + + @JvmField val KFINTECH = of("kfintech") + + @JvmStatic fun of(value: String) = AllowedSource(JsonField.of(value)) + } + + /** An enum containing [AllowedSource]'s known values. */ + enum class Known { + CDSL, + NSDL, + CAMS, + KFINTECH, + } + + /** + * An enum containing [AllowedSource]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [AllowedSource] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + CDSL, + NSDL, + CAMS, + KFINTECH, + /** + * An enum member indicating that [AllowedSource] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + CDSL -> Value.CDSL + NSDL -> Value.NSDL + CAMS -> Value.CAMS + KFINTECH -> Value.KFINTECH + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws CasParserInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + CDSL -> Known.CDSL + NSDL -> Known.NSDL + CAMS -> Known.CAMS + KFINTECH -> Known.KFINTECH + else -> throw CasParserInvalidDataException("Unknown AllowedSource: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws CasParserInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + CasParserInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): AllowedSource = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CasParserInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AllowedSource && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Custom key-value metadata */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CasParserInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + /** Current mailbox status */ + class Status @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val ACTIVE = of("active") + + @JvmField val PAUSED = of("paused") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + ACTIVE, + PAUSED, + } + + /** + * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Status] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ACTIVE, + PAUSED, + /** An enum member indicating that [Status] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ACTIVE -> Value.ACTIVE + PAUSED -> Value.PAUSED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws CasParserInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ACTIVE -> Known.ACTIVE + PAUSED -> Known.PAUSED + else -> throw CasParserInvalidDataException("Unknown Status: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws CasParserInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + CasParserInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CasParserInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Status && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InboundEmailCreateResponse && + allowedSources == other.allowedSources && + callbackUrl == other.callbackUrl && + createdAt == other.createdAt && + email == other.email && + inboundEmailId == other.inboundEmailId && + metadata == other.metadata && + reference == other.reference && + status == other.status && + updatedAt == other.updatedAt && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + allowedSources, + callbackUrl, + createdAt, + email, + inboundEmailId, + metadata, + reference, + status, + updatedAt, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "InboundEmailCreateResponse{allowedSources=$allowedSources, callbackUrl=$callbackUrl, createdAt=$createdAt, email=$email, inboundEmailId=$inboundEmailId, metadata=$metadata, reference=$reference, status=$status, updatedAt=$updatedAt, additionalProperties=$additionalProperties}" +} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/inboundemail/InboundEmailDeleteParams.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/inboundemail/InboundEmailDeleteParams.kt new file mode 100644 index 0000000..1546fbf --- /dev/null +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/inboundemail/InboundEmailDeleteParams.kt @@ -0,0 +1,241 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.models.inboundemail + +import com.cas_parser.api.core.JsonValue +import com.cas_parser.api.core.Params +import com.cas_parser.api.core.http.Headers +import com.cas_parser.api.core.http.QueryParams +import com.cas_parser.api.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Permanently delete an inbound email address. It will stop accepting emails. + * + * **Note:** Deletion is immediate and cannot be undone. Any emails received after deletion will be + * rejected. + */ +class InboundEmailDeleteParams +private constructor( + private val inboundEmailId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map, +) : Params { + + fun inboundEmailId(): Optional = Optional.ofNullable(inboundEmailId) + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): InboundEmailDeleteParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [InboundEmailDeleteParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InboundEmailDeleteParams]. */ + class Builder internal constructor() { + + private var inboundEmailId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(inboundEmailDeleteParams: InboundEmailDeleteParams) = apply { + inboundEmailId = inboundEmailDeleteParams.inboundEmailId + additionalHeaders = inboundEmailDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = inboundEmailDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = + inboundEmailDeleteParams.additionalBodyProperties.toMutableMap() + } + + fun inboundEmailId(inboundEmailId: String?) = apply { this.inboundEmailId = inboundEmailId } + + /** Alias for calling [Builder.inboundEmailId] with `inboundEmailId.orElse(null)`. */ + fun inboundEmailId(inboundEmailId: Optional) = + inboundEmailId(inboundEmailId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [InboundEmailDeleteParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): InboundEmailDeleteParams = + InboundEmailDeleteParams( + inboundEmailId, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> inboundEmailId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InboundEmailDeleteParams && + inboundEmailId == other.inboundEmailId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash( + inboundEmailId, + additionalHeaders, + additionalQueryParams, + additionalBodyProperties, + ) + + override fun toString() = + "InboundEmailDeleteParams{inboundEmailId=$inboundEmailId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/inboundemail/InboundEmailDeleteResponse.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/inboundemail/InboundEmailDeleteResponse.kt new file mode 100644 index 0000000..332967a --- /dev/null +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/inboundemail/InboundEmailDeleteResponse.kt @@ -0,0 +1,186 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.models.inboundemail + +import com.cas_parser.api.core.ExcludeMissing +import com.cas_parser.api.core.JsonField +import com.cas_parser.api.core.JsonMissing +import com.cas_parser.api.core.JsonValue +import com.cas_parser.api.errors.CasParserInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional + +class InboundEmailDeleteResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val msg: JsonField, + private val status: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("msg") @ExcludeMissing msg: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + ) : this(msg, status, mutableMapOf()) + + /** + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun msg(): Optional = msg.getOptional("msg") + + /** + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun status(): Optional = status.getOptional("status") + + /** + * Returns the raw JSON value of [msg]. + * + * Unlike [msg], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("msg") @ExcludeMissing fun _msg(): JsonField = msg + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [InboundEmailDeleteResponse]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InboundEmailDeleteResponse]. */ + class Builder internal constructor() { + + private var msg: JsonField = JsonMissing.of() + private var status: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(inboundEmailDeleteResponse: InboundEmailDeleteResponse) = apply { + msg = inboundEmailDeleteResponse.msg + status = inboundEmailDeleteResponse.status + additionalProperties = inboundEmailDeleteResponse.additionalProperties.toMutableMap() + } + + fun msg(msg: String) = msg(JsonField.of(msg)) + + /** + * Sets [Builder.msg] to an arbitrary JSON value. + * + * You should usually call [Builder.msg] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun msg(msg: JsonField) = apply { this.msg = msg } + + fun status(status: String) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [InboundEmailDeleteResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): InboundEmailDeleteResponse = + InboundEmailDeleteResponse(msg, status, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): InboundEmailDeleteResponse = apply { + if (validated) { + return@apply + } + + msg() + status() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CasParserInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (msg.asKnown().isPresent) 1 else 0) + (if (status.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InboundEmailDeleteResponse && + msg == other.msg && + status == other.status && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(msg, status, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "InboundEmailDeleteResponse{msg=$msg, status=$status, additionalProperties=$additionalProperties}" +} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/inboundemail/InboundEmailListParams.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/inboundemail/InboundEmailListParams.kt new file mode 100644 index 0000000..aea16e2 --- /dev/null +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/inboundemail/InboundEmailListParams.kt @@ -0,0 +1,381 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.models.inboundemail + +import com.cas_parser.api.core.Enum +import com.cas_parser.api.core.JsonField +import com.cas_parser.api.core.Params +import com.cas_parser.api.core.http.Headers +import com.cas_parser.api.core.http.QueryParams +import com.cas_parser.api.errors.CasParserInvalidDataException +import com.fasterxml.jackson.annotation.JsonCreator +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * List all mailboxes associated with your API key. Returns active and inactive mailboxes (deleted + * mailboxes are excluded). + */ +class InboundEmailListParams +private constructor( + private val limit: Long?, + private val offset: Long?, + private val status: Status?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** Maximum number of inbound emails to return */ + fun limit(): Optional = Optional.ofNullable(limit) + + /** Pagination offset */ + fun offset(): Optional = Optional.ofNullable(offset) + + /** Filter by status */ + fun status(): Optional = Optional.ofNullable(status) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): InboundEmailListParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [InboundEmailListParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InboundEmailListParams]. */ + class Builder internal constructor() { + + private var limit: Long? = null + private var offset: Long? = null + private var status: Status? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(inboundEmailListParams: InboundEmailListParams) = apply { + limit = inboundEmailListParams.limit + offset = inboundEmailListParams.offset + status = inboundEmailListParams.status + additionalHeaders = inboundEmailListParams.additionalHeaders.toBuilder() + additionalQueryParams = inboundEmailListParams.additionalQueryParams.toBuilder() + } + + /** Maximum number of inbound emails to return */ + fun limit(limit: Long?) = apply { this.limit = limit } + + /** + * Alias for [Builder.limit]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun limit(limit: Long) = limit(limit as Long?) + + /** Alias for calling [Builder.limit] with `limit.orElse(null)`. */ + fun limit(limit: Optional) = limit(limit.getOrNull()) + + /** Pagination offset */ + fun offset(offset: Long?) = apply { this.offset = offset } + + /** + * Alias for [Builder.offset]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun offset(offset: Long) = offset(offset as Long?) + + /** Alias for calling [Builder.offset] with `offset.orElse(null)`. */ + fun offset(offset: Optional) = offset(offset.getOrNull()) + + /** Filter by status */ + fun status(status: Status?) = apply { this.status = status } + + /** Alias for calling [Builder.status] with `status.orElse(null)`. */ + fun status(status: Optional) = status(status.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [InboundEmailListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): InboundEmailListParams = + InboundEmailListParams( + limit, + offset, + status, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + limit?.let { put("limit", it.toString()) } + offset?.let { put("offset", it.toString()) } + status?.let { put("status", it.toString()) } + putAll(additionalQueryParams) + } + .build() + + /** Filter by status */ + class Status @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val ACTIVE = of("active") + + @JvmField val PAUSED = of("paused") + + @JvmField val ALL = of("all") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + ACTIVE, + PAUSED, + ALL, + } + + /** + * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Status] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ACTIVE, + PAUSED, + ALL, + /** An enum member indicating that [Status] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ACTIVE -> Value.ACTIVE + PAUSED -> Value.PAUSED + ALL -> Value.ALL + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws CasParserInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ACTIVE -> Known.ACTIVE + PAUSED -> Known.PAUSED + ALL -> Known.ALL + else -> throw CasParserInvalidDataException("Unknown Status: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws CasParserInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + CasParserInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CasParserInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Status && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InboundEmailListParams && + limit == other.limit && + offset == other.offset && + status == other.status && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(limit, offset, status, additionalHeaders, additionalQueryParams) + + override fun toString() = + "InboundEmailListParams{limit=$limit, offset=$offset, status=$status, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/inboundemail/InboundEmailListResponse.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/inboundemail/InboundEmailListResponse.kt new file mode 100644 index 0000000..12c0e54 --- /dev/null +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/inboundemail/InboundEmailListResponse.kt @@ -0,0 +1,1194 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.models.inboundemail + +import com.cas_parser.api.core.Enum +import com.cas_parser.api.core.ExcludeMissing +import com.cas_parser.api.core.JsonField +import com.cas_parser.api.core.JsonMissing +import com.cas_parser.api.core.JsonValue +import com.cas_parser.api.core.checkKnown +import com.cas_parser.api.core.toImmutable +import com.cas_parser.api.errors.CasParserInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class InboundEmailListResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val inboundEmails: JsonField>, + private val limit: JsonField, + private val offset: JsonField, + private val status: JsonField, + private val total: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("inbound_emails") + @ExcludeMissing + inboundEmails: JsonField> = JsonMissing.of(), + @JsonProperty("limit") @ExcludeMissing limit: JsonField = JsonMissing.of(), + @JsonProperty("offset") @ExcludeMissing offset: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + @JsonProperty("total") @ExcludeMissing total: JsonField = JsonMissing.of(), + ) : this(inboundEmails, limit, offset, status, total, mutableMapOf()) + + /** + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun inboundEmails(): Optional> = inboundEmails.getOptional("inbound_emails") + + /** + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun limit(): Optional = limit.getOptional("limit") + + /** + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun offset(): Optional = offset.getOptional("offset") + + /** + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun status(): Optional = status.getOptional("status") + + /** + * Total number of inbound emails (for pagination) + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun total(): Optional = total.getOptional("total") + + /** + * Returns the raw JSON value of [inboundEmails]. + * + * Unlike [inboundEmails], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("inbound_emails") + @ExcludeMissing + fun _inboundEmails(): JsonField> = inboundEmails + + /** + * Returns the raw JSON value of [limit]. + * + * Unlike [limit], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("limit") @ExcludeMissing fun _limit(): JsonField = limit + + /** + * Returns the raw JSON value of [offset]. + * + * Unlike [offset], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("offset") @ExcludeMissing fun _offset(): JsonField = offset + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [total]. + * + * Unlike [total], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("total") @ExcludeMissing fun _total(): JsonField = total + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [InboundEmailListResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InboundEmailListResponse]. */ + class Builder internal constructor() { + + private var inboundEmails: JsonField>? = null + private var limit: JsonField = JsonMissing.of() + private var offset: JsonField = JsonMissing.of() + private var status: JsonField = JsonMissing.of() + private var total: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(inboundEmailListResponse: InboundEmailListResponse) = apply { + inboundEmails = inboundEmailListResponse.inboundEmails.map { it.toMutableList() } + limit = inboundEmailListResponse.limit + offset = inboundEmailListResponse.offset + status = inboundEmailListResponse.status + total = inboundEmailListResponse.total + additionalProperties = inboundEmailListResponse.additionalProperties.toMutableMap() + } + + fun inboundEmails(inboundEmails: List) = + inboundEmails(JsonField.of(inboundEmails)) + + /** + * Sets [Builder.inboundEmails] to an arbitrary JSON value. + * + * You should usually call [Builder.inboundEmails] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun inboundEmails(inboundEmails: JsonField>) = apply { + this.inboundEmails = inboundEmails.map { it.toMutableList() } + } + + /** + * Adds a single [InboundEmail] to [inboundEmails]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addInboundEmail(inboundEmail: InboundEmail) = apply { + inboundEmails = + (inboundEmails ?: JsonField.of(mutableListOf())).also { + checkKnown("inboundEmails", it).add(inboundEmail) + } + } + + fun limit(limit: Long) = limit(JsonField.of(limit)) + + /** + * Sets [Builder.limit] to an arbitrary JSON value. + * + * You should usually call [Builder.limit] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun limit(limit: JsonField) = apply { this.limit = limit } + + fun offset(offset: Long) = offset(JsonField.of(offset)) + + /** + * Sets [Builder.offset] to an arbitrary JSON value. + * + * You should usually call [Builder.offset] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun offset(offset: JsonField) = apply { this.offset = offset } + + fun status(status: String) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + /** Total number of inbound emails (for pagination) */ + fun total(total: Long) = total(JsonField.of(total)) + + /** + * Sets [Builder.total] to an arbitrary JSON value. + * + * You should usually call [Builder.total] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun total(total: JsonField) = apply { this.total = total } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [InboundEmailListResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): InboundEmailListResponse = + InboundEmailListResponse( + (inboundEmails ?: JsonMissing.of()).map { it.toImmutable() }, + limit, + offset, + status, + total, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): InboundEmailListResponse = apply { + if (validated) { + return@apply + } + + inboundEmails().ifPresent { it.forEach { it.validate() } } + limit() + offset() + status() + total() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CasParserInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (inboundEmails.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (limit.asKnown().isPresent) 1 else 0) + + (if (offset.asKnown().isPresent) 1 else 0) + + (if (status.asKnown().isPresent) 1 else 0) + + (if (total.asKnown().isPresent) 1 else 0) + + /** An inbound email address for receiving forwarded CAS emails */ + class InboundEmail + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val allowedSources: JsonField>, + private val callbackUrl: JsonField, + private val createdAt: JsonField, + private val email: JsonField, + private val inboundEmailId: JsonField, + private val metadata: JsonField, + private val reference: JsonField, + private val status: JsonField, + private val updatedAt: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("allowed_sources") + @ExcludeMissing + allowedSources: JsonField> = JsonMissing.of(), + @JsonProperty("callback_url") + @ExcludeMissing + callbackUrl: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField = JsonMissing.of(), + @JsonProperty("email") @ExcludeMissing email: JsonField = JsonMissing.of(), + @JsonProperty("inbound_email_id") + @ExcludeMissing + inboundEmailId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference") + @ExcludeMissing + reference: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + @JsonProperty("updated_at") + @ExcludeMissing + updatedAt: JsonField = JsonMissing.of(), + ) : this( + allowedSources, + callbackUrl, + createdAt, + email, + inboundEmailId, + metadata, + reference, + status, + updatedAt, + mutableMapOf(), + ) + + /** + * Accepted CAS providers (empty = all) + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun allowedSources(): Optional> = + allowedSources.getOptional("allowed_sources") + + /** + * Webhook URL for email notifications + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun callbackUrl(): Optional = callbackUrl.getOptional("callback_url") + + /** + * When the mailbox was created + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun createdAt(): Optional = createdAt.getOptional("created_at") + + /** + * The inbound email address to forward CAS statements to + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun email(): Optional = email.getOptional("email") + + /** + * Unique inbound email identifier + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun inboundEmailId(): Optional = inboundEmailId.getOptional("inbound_email_id") + + /** + * Custom key-value metadata + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * Your internal reference identifier + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun reference(): Optional = reference.getOptional("reference") + + /** + * Current mailbox status + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun status(): Optional = status.getOptional("status") + + /** + * When the mailbox was last updated + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun updatedAt(): Optional = updatedAt.getOptional("updated_at") + + /** + * Returns the raw JSON value of [allowedSources]. + * + * Unlike [allowedSources], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("allowed_sources") + @ExcludeMissing + fun _allowedSources(): JsonField> = allowedSources + + /** + * Returns the raw JSON value of [callbackUrl]. + * + * Unlike [callbackUrl], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("callback_url") + @ExcludeMissing + fun _callbackUrl(): JsonField = callbackUrl + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt + + /** + * Returns the raw JSON value of [email]. + * + * Unlike [email], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("email") @ExcludeMissing fun _email(): JsonField = email + + /** + * Returns the raw JSON value of [inboundEmailId]. + * + * Unlike [inboundEmailId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("inbound_email_id") + @ExcludeMissing + fun _inboundEmailId(): JsonField = inboundEmailId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [reference]. + * + * Unlike [reference], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("reference") @ExcludeMissing fun _reference(): JsonField = reference + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [updatedAt]. + * + * Unlike [updatedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("updated_at") + @ExcludeMissing + fun _updatedAt(): JsonField = updatedAt + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [InboundEmail]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InboundEmail]. */ + class Builder internal constructor() { + + private var allowedSources: JsonField>? = null + private var callbackUrl: JsonField = JsonMissing.of() + private var createdAt: JsonField = JsonMissing.of() + private var email: JsonField = JsonMissing.of() + private var inboundEmailId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var reference: JsonField = JsonMissing.of() + private var status: JsonField = JsonMissing.of() + private var updatedAt: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(inboundEmail: InboundEmail) = apply { + allowedSources = inboundEmail.allowedSources.map { it.toMutableList() } + callbackUrl = inboundEmail.callbackUrl + createdAt = inboundEmail.createdAt + email = inboundEmail.email + inboundEmailId = inboundEmail.inboundEmailId + metadata = inboundEmail.metadata + reference = inboundEmail.reference + status = inboundEmail.status + updatedAt = inboundEmail.updatedAt + additionalProperties = inboundEmail.additionalProperties.toMutableMap() + } + + /** Accepted CAS providers (empty = all) */ + fun allowedSources(allowedSources: List) = + allowedSources(JsonField.of(allowedSources)) + + /** + * Sets [Builder.allowedSources] to an arbitrary JSON value. + * + * You should usually call [Builder.allowedSources] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun allowedSources(allowedSources: JsonField>) = apply { + this.allowedSources = allowedSources.map { it.toMutableList() } + } + + /** + * Adds a single [AllowedSource] to [allowedSources]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAllowedSource(allowedSource: AllowedSource) = apply { + allowedSources = + (allowedSources ?: JsonField.of(mutableListOf())).also { + checkKnown("allowedSources", it).add(allowedSource) + } + } + + /** Webhook URL for email notifications */ + fun callbackUrl(callbackUrl: String) = callbackUrl(JsonField.of(callbackUrl)) + + /** + * Sets [Builder.callbackUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.callbackUrl] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun callbackUrl(callbackUrl: JsonField) = apply { + this.callbackUrl = callbackUrl + } + + /** When the mailbox was created */ + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField) = apply { + this.createdAt = createdAt + } + + /** The inbound email address to forward CAS statements to */ + fun email(email: String) = email(JsonField.of(email)) + + /** + * Sets [Builder.email] to an arbitrary JSON value. + * + * You should usually call [Builder.email] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun email(email: JsonField) = apply { this.email = email } + + /** Unique inbound email identifier */ + fun inboundEmailId(inboundEmailId: String) = + inboundEmailId(JsonField.of(inboundEmailId)) + + /** + * Sets [Builder.inboundEmailId] to an arbitrary JSON value. + * + * You should usually call [Builder.inboundEmailId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun inboundEmailId(inboundEmailId: JsonField) = apply { + this.inboundEmailId = inboundEmailId + } + + /** Custom key-value metadata */ + fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** Your internal reference identifier */ + fun reference(reference: String?) = reference(JsonField.ofNullable(reference)) + + /** Alias for calling [Builder.reference] with `reference.orElse(null)`. */ + fun reference(reference: Optional) = reference(reference.getOrNull()) + + /** + * Sets [Builder.reference] to an arbitrary JSON value. + * + * You should usually call [Builder.reference] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun reference(reference: JsonField) = apply { this.reference = reference } + + /** Current mailbox status */ + fun status(status: Status) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Status] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + /** When the mailbox was last updated */ + fun updatedAt(updatedAt: OffsetDateTime) = updatedAt(JsonField.of(updatedAt)) + + /** + * Sets [Builder.updatedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.updatedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun updatedAt(updatedAt: JsonField) = apply { + this.updatedAt = updatedAt + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [InboundEmail]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): InboundEmail = + InboundEmail( + (allowedSources ?: JsonMissing.of()).map { it.toImmutable() }, + callbackUrl, + createdAt, + email, + inboundEmailId, + metadata, + reference, + status, + updatedAt, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): InboundEmail = apply { + if (validated) { + return@apply + } + + allowedSources().ifPresent { it.forEach { it.validate() } } + callbackUrl() + createdAt() + email() + inboundEmailId() + metadata().ifPresent { it.validate() } + reference() + status().ifPresent { it.validate() } + updatedAt() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CasParserInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (allowedSources.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (callbackUrl.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (email.asKnown().isPresent) 1 else 0) + + (if (inboundEmailId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (reference.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (if (updatedAt.asKnown().isPresent) 1 else 0) + + class AllowedSource @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val CDSL = of("cdsl") + + @JvmField val NSDL = of("nsdl") + + @JvmField val CAMS = of("cams") + + @JvmField val KFINTECH = of("kfintech") + + @JvmStatic fun of(value: String) = AllowedSource(JsonField.of(value)) + } + + /** An enum containing [AllowedSource]'s known values. */ + enum class Known { + CDSL, + NSDL, + CAMS, + KFINTECH, + } + + /** + * An enum containing [AllowedSource]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [AllowedSource] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + CDSL, + NSDL, + CAMS, + KFINTECH, + /** + * An enum member indicating that [AllowedSource] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + CDSL -> Value.CDSL + NSDL -> Value.NSDL + CAMS -> Value.CAMS + KFINTECH -> Value.KFINTECH + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws CasParserInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + CDSL -> Known.CDSL + NSDL -> Known.NSDL + CAMS -> Known.CAMS + KFINTECH -> Known.KFINTECH + else -> throw CasParserInvalidDataException("Unknown AllowedSource: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws CasParserInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + CasParserInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): AllowedSource = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CasParserInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AllowedSource && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Custom key-value metadata */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CasParserInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + /** Current mailbox status */ + class Status @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val ACTIVE = of("active") + + @JvmField val PAUSED = of("paused") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + ACTIVE, + PAUSED, + } + + /** + * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Status] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ACTIVE, + PAUSED, + /** + * An enum member indicating that [Status] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ACTIVE -> Value.ACTIVE + PAUSED -> Value.PAUSED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws CasParserInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ACTIVE -> Known.ACTIVE + PAUSED -> Known.PAUSED + else -> throw CasParserInvalidDataException("Unknown Status: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws CasParserInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + CasParserInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CasParserInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Status && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InboundEmail && + allowedSources == other.allowedSources && + callbackUrl == other.callbackUrl && + createdAt == other.createdAt && + email == other.email && + inboundEmailId == other.inboundEmailId && + metadata == other.metadata && + reference == other.reference && + status == other.status && + updatedAt == other.updatedAt && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + allowedSources, + callbackUrl, + createdAt, + email, + inboundEmailId, + metadata, + reference, + status, + updatedAt, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "InboundEmail{allowedSources=$allowedSources, callbackUrl=$callbackUrl, createdAt=$createdAt, email=$email, inboundEmailId=$inboundEmailId, metadata=$metadata, reference=$reference, status=$status, updatedAt=$updatedAt, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InboundEmailListResponse && + inboundEmails == other.inboundEmails && + limit == other.limit && + offset == other.offset && + status == other.status && + total == other.total && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(inboundEmails, limit, offset, status, total, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "InboundEmailListResponse{inboundEmails=$inboundEmails, limit=$limit, offset=$offset, status=$status, total=$total, additionalProperties=$additionalProperties}" +} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/inboundemail/InboundEmailRetrieveParams.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/inboundemail/InboundEmailRetrieveParams.kt new file mode 100644 index 0000000..1c0676b --- /dev/null +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/inboundemail/InboundEmailRetrieveParams.kt @@ -0,0 +1,197 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.models.inboundemail + +import com.cas_parser.api.core.Params +import com.cas_parser.api.core.http.Headers +import com.cas_parser.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Retrieve details of a specific mailbox including statistics. */ +class InboundEmailRetrieveParams +private constructor( + private val inboundEmailId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun inboundEmailId(): Optional = Optional.ofNullable(inboundEmailId) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): InboundEmailRetrieveParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of [InboundEmailRetrieveParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InboundEmailRetrieveParams]. */ + class Builder internal constructor() { + + private var inboundEmailId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(inboundEmailRetrieveParams: InboundEmailRetrieveParams) = apply { + inboundEmailId = inboundEmailRetrieveParams.inboundEmailId + additionalHeaders = inboundEmailRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = inboundEmailRetrieveParams.additionalQueryParams.toBuilder() + } + + fun inboundEmailId(inboundEmailId: String?) = apply { this.inboundEmailId = inboundEmailId } + + /** Alias for calling [Builder.inboundEmailId] with `inboundEmailId.orElse(null)`. */ + fun inboundEmailId(inboundEmailId: Optional) = + inboundEmailId(inboundEmailId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [InboundEmailRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): InboundEmailRetrieveParams = + InboundEmailRetrieveParams( + inboundEmailId, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> inboundEmailId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InboundEmailRetrieveParams && + inboundEmailId == other.inboundEmailId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(inboundEmailId, additionalHeaders, additionalQueryParams) + + override fun toString() = + "InboundEmailRetrieveParams{inboundEmailId=$inboundEmailId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/inboundemail/InboundEmailRetrieveResponse.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/inboundemail/InboundEmailRetrieveResponse.kt new file mode 100644 index 0000000..c997bf9 --- /dev/null +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/inboundemail/InboundEmailRetrieveResponse.kt @@ -0,0 +1,884 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.models.inboundemail + +import com.cas_parser.api.core.Enum +import com.cas_parser.api.core.ExcludeMissing +import com.cas_parser.api.core.JsonField +import com.cas_parser.api.core.JsonMissing +import com.cas_parser.api.core.JsonValue +import com.cas_parser.api.core.checkKnown +import com.cas_parser.api.core.toImmutable +import com.cas_parser.api.errors.CasParserInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** An inbound email address for receiving forwarded CAS emails */ +class InboundEmailRetrieveResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val allowedSources: JsonField>, + private val callbackUrl: JsonField, + private val createdAt: JsonField, + private val email: JsonField, + private val inboundEmailId: JsonField, + private val metadata: JsonField, + private val reference: JsonField, + private val status: JsonField, + private val updatedAt: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("allowed_sources") + @ExcludeMissing + allowedSources: JsonField> = JsonMissing.of(), + @JsonProperty("callback_url") + @ExcludeMissing + callbackUrl: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField = JsonMissing.of(), + @JsonProperty("email") @ExcludeMissing email: JsonField = JsonMissing.of(), + @JsonProperty("inbound_email_id") + @ExcludeMissing + inboundEmailId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference") @ExcludeMissing reference: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + @JsonProperty("updated_at") + @ExcludeMissing + updatedAt: JsonField = JsonMissing.of(), + ) : this( + allowedSources, + callbackUrl, + createdAt, + email, + inboundEmailId, + metadata, + reference, + status, + updatedAt, + mutableMapOf(), + ) + + /** + * Accepted CAS providers (empty = all) + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun allowedSources(): Optional> = + allowedSources.getOptional("allowed_sources") + + /** + * Webhook URL for email notifications + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun callbackUrl(): Optional = callbackUrl.getOptional("callback_url") + + /** + * When the mailbox was created + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun createdAt(): Optional = createdAt.getOptional("created_at") + + /** + * The inbound email address to forward CAS statements to + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun email(): Optional = email.getOptional("email") + + /** + * Unique inbound email identifier + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun inboundEmailId(): Optional = inboundEmailId.getOptional("inbound_email_id") + + /** + * Custom key-value metadata + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * Your internal reference identifier + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun reference(): Optional = reference.getOptional("reference") + + /** + * Current mailbox status + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun status(): Optional = status.getOptional("status") + + /** + * When the mailbox was last updated + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun updatedAt(): Optional = updatedAt.getOptional("updated_at") + + /** + * Returns the raw JSON value of [allowedSources]. + * + * Unlike [allowedSources], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("allowed_sources") + @ExcludeMissing + fun _allowedSources(): JsonField> = allowedSources + + /** + * Returns the raw JSON value of [callbackUrl]. + * + * Unlike [callbackUrl], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("callback_url") + @ExcludeMissing + fun _callbackUrl(): JsonField = callbackUrl + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt + + /** + * Returns the raw JSON value of [email]. + * + * Unlike [email], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("email") @ExcludeMissing fun _email(): JsonField = email + + /** + * Returns the raw JSON value of [inboundEmailId]. + * + * Unlike [inboundEmailId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("inbound_email_id") + @ExcludeMissing + fun _inboundEmailId(): JsonField = inboundEmailId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [reference]. + * + * Unlike [reference], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("reference") @ExcludeMissing fun _reference(): JsonField = reference + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [updatedAt]. + * + * Unlike [updatedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("updated_at") + @ExcludeMissing + fun _updatedAt(): JsonField = updatedAt + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [InboundEmailRetrieveResponse]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InboundEmailRetrieveResponse]. */ + class Builder internal constructor() { + + private var allowedSources: JsonField>? = null + private var callbackUrl: JsonField = JsonMissing.of() + private var createdAt: JsonField = JsonMissing.of() + private var email: JsonField = JsonMissing.of() + private var inboundEmailId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var reference: JsonField = JsonMissing.of() + private var status: JsonField = JsonMissing.of() + private var updatedAt: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(inboundEmailRetrieveResponse: InboundEmailRetrieveResponse) = apply { + allowedSources = inboundEmailRetrieveResponse.allowedSources.map { it.toMutableList() } + callbackUrl = inboundEmailRetrieveResponse.callbackUrl + createdAt = inboundEmailRetrieveResponse.createdAt + email = inboundEmailRetrieveResponse.email + inboundEmailId = inboundEmailRetrieveResponse.inboundEmailId + metadata = inboundEmailRetrieveResponse.metadata + reference = inboundEmailRetrieveResponse.reference + status = inboundEmailRetrieveResponse.status + updatedAt = inboundEmailRetrieveResponse.updatedAt + additionalProperties = inboundEmailRetrieveResponse.additionalProperties.toMutableMap() + } + + /** Accepted CAS providers (empty = all) */ + fun allowedSources(allowedSources: List) = + allowedSources(JsonField.of(allowedSources)) + + /** + * Sets [Builder.allowedSources] to an arbitrary JSON value. + * + * You should usually call [Builder.allowedSources] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun allowedSources(allowedSources: JsonField>) = apply { + this.allowedSources = allowedSources.map { it.toMutableList() } + } + + /** + * Adds a single [AllowedSource] to [allowedSources]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAllowedSource(allowedSource: AllowedSource) = apply { + allowedSources = + (allowedSources ?: JsonField.of(mutableListOf())).also { + checkKnown("allowedSources", it).add(allowedSource) + } + } + + /** Webhook URL for email notifications */ + fun callbackUrl(callbackUrl: String) = callbackUrl(JsonField.of(callbackUrl)) + + /** + * Sets [Builder.callbackUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.callbackUrl] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun callbackUrl(callbackUrl: JsonField) = apply { this.callbackUrl = callbackUrl } + + /** When the mailbox was created */ + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } + + /** The inbound email address to forward CAS statements to */ + fun email(email: String) = email(JsonField.of(email)) + + /** + * Sets [Builder.email] to an arbitrary JSON value. + * + * You should usually call [Builder.email] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun email(email: JsonField) = apply { this.email = email } + + /** Unique inbound email identifier */ + fun inboundEmailId(inboundEmailId: String) = inboundEmailId(JsonField.of(inboundEmailId)) + + /** + * Sets [Builder.inboundEmailId] to an arbitrary JSON value. + * + * You should usually call [Builder.inboundEmailId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun inboundEmailId(inboundEmailId: JsonField) = apply { + this.inboundEmailId = inboundEmailId + } + + /** Custom key-value metadata */ + fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** Your internal reference identifier */ + fun reference(reference: String?) = reference(JsonField.ofNullable(reference)) + + /** Alias for calling [Builder.reference] with `reference.orElse(null)`. */ + fun reference(reference: Optional) = reference(reference.getOrNull()) + + /** + * Sets [Builder.reference] to an arbitrary JSON value. + * + * You should usually call [Builder.reference] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun reference(reference: JsonField) = apply { this.reference = reference } + + /** Current mailbox status */ + fun status(status: Status) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Status] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + /** When the mailbox was last updated */ + fun updatedAt(updatedAt: OffsetDateTime) = updatedAt(JsonField.of(updatedAt)) + + /** + * Sets [Builder.updatedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.updatedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun updatedAt(updatedAt: JsonField) = apply { this.updatedAt = updatedAt } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [InboundEmailRetrieveResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): InboundEmailRetrieveResponse = + InboundEmailRetrieveResponse( + (allowedSources ?: JsonMissing.of()).map { it.toImmutable() }, + callbackUrl, + createdAt, + email, + inboundEmailId, + metadata, + reference, + status, + updatedAt, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): InboundEmailRetrieveResponse = apply { + if (validated) { + return@apply + } + + allowedSources().ifPresent { it.forEach { it.validate() } } + callbackUrl() + createdAt() + email() + inboundEmailId() + metadata().ifPresent { it.validate() } + reference() + status().ifPresent { it.validate() } + updatedAt() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CasParserInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (allowedSources.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (callbackUrl.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (email.asKnown().isPresent) 1 else 0) + + (if (inboundEmailId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (reference.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (if (updatedAt.asKnown().isPresent) 1 else 0) + + class AllowedSource @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val CDSL = of("cdsl") + + @JvmField val NSDL = of("nsdl") + + @JvmField val CAMS = of("cams") + + @JvmField val KFINTECH = of("kfintech") + + @JvmStatic fun of(value: String) = AllowedSource(JsonField.of(value)) + } + + /** An enum containing [AllowedSource]'s known values. */ + enum class Known { + CDSL, + NSDL, + CAMS, + KFINTECH, + } + + /** + * An enum containing [AllowedSource]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [AllowedSource] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + CDSL, + NSDL, + CAMS, + KFINTECH, + /** + * An enum member indicating that [AllowedSource] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + CDSL -> Value.CDSL + NSDL -> Value.NSDL + CAMS -> Value.CAMS + KFINTECH -> Value.KFINTECH + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws CasParserInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + CDSL -> Known.CDSL + NSDL -> Known.NSDL + CAMS -> Known.CAMS + KFINTECH -> Known.KFINTECH + else -> throw CasParserInvalidDataException("Unknown AllowedSource: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws CasParserInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + CasParserInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): AllowedSource = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CasParserInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AllowedSource && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Custom key-value metadata */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CasParserInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + /** Current mailbox status */ + class Status @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val ACTIVE = of("active") + + @JvmField val PAUSED = of("paused") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + ACTIVE, + PAUSED, + } + + /** + * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Status] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ACTIVE, + PAUSED, + /** An enum member indicating that [Status] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ACTIVE -> Value.ACTIVE + PAUSED -> Value.PAUSED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws CasParserInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ACTIVE -> Known.ACTIVE + PAUSED -> Known.PAUSED + else -> throw CasParserInvalidDataException("Unknown Status: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws CasParserInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + CasParserInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CasParserInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Status && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InboundEmailRetrieveResponse && + allowedSources == other.allowedSources && + callbackUrl == other.callbackUrl && + createdAt == other.createdAt && + email == other.email && + inboundEmailId == other.inboundEmailId && + metadata == other.metadata && + reference == other.reference && + status == other.status && + updatedAt == other.updatedAt && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + allowedSources, + callbackUrl, + createdAt, + email, + inboundEmailId, + metadata, + reference, + status, + updatedAt, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "InboundEmailRetrieveResponse{allowedSources=$allowedSources, callbackUrl=$callbackUrl, createdAt=$createdAt, email=$email, inboundEmailId=$inboundEmailId, metadata=$metadata, reference=$reference, status=$status, updatedAt=$updatedAt, additionalProperties=$additionalProperties}" +} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/logs/LogCreateParams.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/logs/LogCreateParams.kt new file mode 100644 index 0000000..b5db085 --- /dev/null +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/logs/LogCreateParams.kt @@ -0,0 +1,530 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.models.logs + +import com.cas_parser.api.core.ExcludeMissing +import com.cas_parser.api.core.JsonField +import com.cas_parser.api.core.JsonMissing +import com.cas_parser.api.core.JsonValue +import com.cas_parser.api.core.Params +import com.cas_parser.api.core.http.Headers +import com.cas_parser.api.core.http.QueryParams +import com.cas_parser.api.errors.CasParserInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional + +/** + * Retrieve detailed API usage logs for your account. + * + * Returns a list of API calls with timestamps, features used, status codes, and credits consumed. + * Useful for monitoring usage patterns and debugging. + * + * **Legacy path:** `/logs` (still supported) + */ +class LogCreateParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * End time filter (ISO 8601). Defaults to now. + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun endTime(): Optional = body.endTime() + + /** + * Maximum number of logs to return + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun limit(): Optional = body.limit() + + /** + * Start time filter (ISO 8601). Defaults to 30 days ago. + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun startTime(): Optional = body.startTime() + + /** + * Returns the raw JSON value of [endTime]. + * + * Unlike [endTime], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _endTime(): JsonField = body._endTime() + + /** + * Returns the raw JSON value of [limit]. + * + * Unlike [limit], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _limit(): JsonField = body._limit() + + /** + * Returns the raw JSON value of [startTime]. + * + * Unlike [startTime], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _startTime(): JsonField = body._startTime() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): LogCreateParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [LogCreateParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LogCreateParams]. */ + class Builder internal constructor() { + + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(logCreateParams: LogCreateParams) = apply { + body = logCreateParams.body.toBuilder() + additionalHeaders = logCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = logCreateParams.additionalQueryParams.toBuilder() + } + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [endTime] + * - [limit] + * - [startTime] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** End time filter (ISO 8601). Defaults to now. */ + fun endTime(endTime: OffsetDateTime) = apply { body.endTime(endTime) } + + /** + * Sets [Builder.endTime] to an arbitrary JSON value. + * + * You should usually call [Builder.endTime] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun endTime(endTime: JsonField) = apply { body.endTime(endTime) } + + /** Maximum number of logs to return */ + fun limit(limit: Long) = apply { body.limit(limit) } + + /** + * Sets [Builder.limit] to an arbitrary JSON value. + * + * You should usually call [Builder.limit] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun limit(limit: JsonField) = apply { body.limit(limit) } + + /** Start time filter (ISO 8601). Defaults to 30 days ago. */ + fun startTime(startTime: OffsetDateTime) = apply { body.startTime(startTime) } + + /** + * Sets [Builder.startTime] to an arbitrary JSON value. + * + * You should usually call [Builder.startTime] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun startTime(startTime: JsonField) = apply { body.startTime(startTime) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [LogCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): LogCreateParams = + LogCreateParams(body.build(), additionalHeaders.build(), additionalQueryParams.build()) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val endTime: JsonField, + private val limit: JsonField, + private val startTime: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("end_time") + @ExcludeMissing + endTime: JsonField = JsonMissing.of(), + @JsonProperty("limit") @ExcludeMissing limit: JsonField = JsonMissing.of(), + @JsonProperty("start_time") + @ExcludeMissing + startTime: JsonField = JsonMissing.of(), + ) : this(endTime, limit, startTime, mutableMapOf()) + + /** + * End time filter (ISO 8601). Defaults to now. + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun endTime(): Optional = endTime.getOptional("end_time") + + /** + * Maximum number of logs to return + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun limit(): Optional = limit.getOptional("limit") + + /** + * Start time filter (ISO 8601). Defaults to 30 days ago. + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun startTime(): Optional = startTime.getOptional("start_time") + + /** + * Returns the raw JSON value of [endTime]. + * + * Unlike [endTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("end_time") + @ExcludeMissing + fun _endTime(): JsonField = endTime + + /** + * Returns the raw JSON value of [limit]. + * + * Unlike [limit], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("limit") @ExcludeMissing fun _limit(): JsonField = limit + + /** + * Returns the raw JSON value of [startTime]. + * + * Unlike [startTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("start_time") + @ExcludeMissing + fun _startTime(): JsonField = startTime + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Body]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var endTime: JsonField = JsonMissing.of() + private var limit: JsonField = JsonMissing.of() + private var startTime: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + endTime = body.endTime + limit = body.limit + startTime = body.startTime + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** End time filter (ISO 8601). Defaults to now. */ + fun endTime(endTime: OffsetDateTime) = endTime(JsonField.of(endTime)) + + /** + * Sets [Builder.endTime] to an arbitrary JSON value. + * + * You should usually call [Builder.endTime] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun endTime(endTime: JsonField) = apply { this.endTime = endTime } + + /** Maximum number of logs to return */ + fun limit(limit: Long) = limit(JsonField.of(limit)) + + /** + * Sets [Builder.limit] to an arbitrary JSON value. + * + * You should usually call [Builder.limit] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun limit(limit: JsonField) = apply { this.limit = limit } + + /** Start time filter (ISO 8601). Defaults to 30 days ago. */ + fun startTime(startTime: OffsetDateTime) = startTime(JsonField.of(startTime)) + + /** + * Sets [Builder.startTime] to an arbitrary JSON value. + * + * You should usually call [Builder.startTime] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun startTime(startTime: JsonField) = apply { + this.startTime = startTime + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Body = Body(endTime, limit, startTime, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + endTime() + limit() + startTime() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CasParserInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (endTime.asKnown().isPresent) 1 else 0) + + (if (limit.asKnown().isPresent) 1 else 0) + + (if (startTime.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + endTime == other.endTime && + limit == other.limit && + startTime == other.startTime && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(endTime, limit, startTime, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{endTime=$endTime, limit=$limit, startTime=$startTime, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LogCreateParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "LogCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/logs/LogCreateResponse.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/logs/LogCreateResponse.kt new file mode 100644 index 0000000..b77a776 --- /dev/null +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/logs/LogCreateResponse.kt @@ -0,0 +1,578 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.models.logs + +import com.cas_parser.api.core.ExcludeMissing +import com.cas_parser.api.core.JsonField +import com.cas_parser.api.core.JsonMissing +import com.cas_parser.api.core.JsonValue +import com.cas_parser.api.core.checkKnown +import com.cas_parser.api.core.toImmutable +import com.cas_parser.api.errors.CasParserInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class LogCreateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val count: JsonField, + private val logs: JsonField>, + private val status: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("count") @ExcludeMissing count: JsonField = JsonMissing.of(), + @JsonProperty("logs") @ExcludeMissing logs: JsonField> = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + ) : this(count, logs, status, mutableMapOf()) + + /** + * Number of logs returned + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun count(): Optional = count.getOptional("count") + + /** + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun logs(): Optional> = logs.getOptional("logs") + + /** + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun status(): Optional = status.getOptional("status") + + /** + * Returns the raw JSON value of [count]. + * + * Unlike [count], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("count") @ExcludeMissing fun _count(): JsonField = count + + /** + * Returns the raw JSON value of [logs]. + * + * Unlike [logs], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("logs") @ExcludeMissing fun _logs(): JsonField> = logs + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [LogCreateResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LogCreateResponse]. */ + class Builder internal constructor() { + + private var count: JsonField = JsonMissing.of() + private var logs: JsonField>? = null + private var status: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(logCreateResponse: LogCreateResponse) = apply { + count = logCreateResponse.count + logs = logCreateResponse.logs.map { it.toMutableList() } + status = logCreateResponse.status + additionalProperties = logCreateResponse.additionalProperties.toMutableMap() + } + + /** Number of logs returned */ + fun count(count: Long) = count(JsonField.of(count)) + + /** + * Sets [Builder.count] to an arbitrary JSON value. + * + * You should usually call [Builder.count] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun count(count: JsonField) = apply { this.count = count } + + fun logs(logs: List) = logs(JsonField.of(logs)) + + /** + * Sets [Builder.logs] to an arbitrary JSON value. + * + * You should usually call [Builder.logs] with a well-typed `List` value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun logs(logs: JsonField>) = apply { this.logs = logs.map { it.toMutableList() } } + + /** + * Adds a single [Log] to [logs]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLog(log: Log) = apply { + logs = (logs ?: JsonField.of(mutableListOf())).also { checkKnown("logs", it).add(log) } + } + + fun status(status: String) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LogCreateResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): LogCreateResponse = + LogCreateResponse( + count, + (logs ?: JsonMissing.of()).map { it.toImmutable() }, + status, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LogCreateResponse = apply { + if (validated) { + return@apply + } + + count() + logs().ifPresent { it.forEach { it.validate() } } + status() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CasParserInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (count.asKnown().isPresent) 1 else 0) + + (logs.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (status.asKnown().isPresent) 1 else 0) + + class Log + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val credits: JsonField, + private val feature: JsonField, + private val path: JsonField, + private val requestId: JsonField, + private val statusCode: JsonField, + private val timestamp: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("credits") @ExcludeMissing credits: JsonField = JsonMissing.of(), + @JsonProperty("feature") @ExcludeMissing feature: JsonField = JsonMissing.of(), + @JsonProperty("path") @ExcludeMissing path: JsonField = JsonMissing.of(), + @JsonProperty("request_id") + @ExcludeMissing + requestId: JsonField = JsonMissing.of(), + @JsonProperty("status_code") + @ExcludeMissing + statusCode: JsonField = JsonMissing.of(), + @JsonProperty("timestamp") + @ExcludeMissing + timestamp: JsonField = JsonMissing.of(), + ) : this(credits, feature, path, requestId, statusCode, timestamp, mutableMapOf()) + + /** + * Credits consumed for this request + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun credits(): Optional = credits.getOptional("credits") + + /** + * API feature used + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun feature(): Optional = feature.getOptional("feature") + + /** + * API endpoint path + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun path(): Optional = path.getOptional("path") + + /** + * Unique request identifier + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun requestId(): Optional = requestId.getOptional("request_id") + + /** + * HTTP response status code + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun statusCode(): Optional = statusCode.getOptional("status_code") + + /** + * When the request was made + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun timestamp(): Optional = timestamp.getOptional("timestamp") + + /** + * Returns the raw JSON value of [credits]. + * + * Unlike [credits], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("credits") @ExcludeMissing fun _credits(): JsonField = credits + + /** + * Returns the raw JSON value of [feature]. + * + * Unlike [feature], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("feature") @ExcludeMissing fun _feature(): JsonField = feature + + /** + * Returns the raw JSON value of [path]. + * + * Unlike [path], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("path") @ExcludeMissing fun _path(): JsonField = path + + /** + * Returns the raw JSON value of [requestId]. + * + * Unlike [requestId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("request_id") @ExcludeMissing fun _requestId(): JsonField = requestId + + /** + * Returns the raw JSON value of [statusCode]. + * + * Unlike [statusCode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status_code") @ExcludeMissing fun _statusCode(): JsonField = statusCode + + /** + * Returns the raw JSON value of [timestamp]. + * + * Unlike [timestamp], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("timestamp") + @ExcludeMissing + fun _timestamp(): JsonField = timestamp + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Log]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Log]. */ + class Builder internal constructor() { + + private var credits: JsonField = JsonMissing.of() + private var feature: JsonField = JsonMissing.of() + private var path: JsonField = JsonMissing.of() + private var requestId: JsonField = JsonMissing.of() + private var statusCode: JsonField = JsonMissing.of() + private var timestamp: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(log: Log) = apply { + credits = log.credits + feature = log.feature + path = log.path + requestId = log.requestId + statusCode = log.statusCode + timestamp = log.timestamp + additionalProperties = log.additionalProperties.toMutableMap() + } + + /** Credits consumed for this request */ + fun credits(credits: Double) = credits(JsonField.of(credits)) + + /** + * Sets [Builder.credits] to an arbitrary JSON value. + * + * You should usually call [Builder.credits] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun credits(credits: JsonField) = apply { this.credits = credits } + + /** API feature used */ + fun feature(feature: String) = feature(JsonField.of(feature)) + + /** + * Sets [Builder.feature] to an arbitrary JSON value. + * + * You should usually call [Builder.feature] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun feature(feature: JsonField) = apply { this.feature = feature } + + /** API endpoint path */ + fun path(path: String) = path(JsonField.of(path)) + + /** + * Sets [Builder.path] to an arbitrary JSON value. + * + * You should usually call [Builder.path] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun path(path: JsonField) = apply { this.path = path } + + /** Unique request identifier */ + fun requestId(requestId: String) = requestId(JsonField.of(requestId)) + + /** + * Sets [Builder.requestId] to an arbitrary JSON value. + * + * You should usually call [Builder.requestId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun requestId(requestId: JsonField) = apply { this.requestId = requestId } + + /** HTTP response status code */ + fun statusCode(statusCode: Long) = statusCode(JsonField.of(statusCode)) + + /** + * Sets [Builder.statusCode] to an arbitrary JSON value. + * + * You should usually call [Builder.statusCode] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun statusCode(statusCode: JsonField) = apply { this.statusCode = statusCode } + + /** When the request was made */ + fun timestamp(timestamp: OffsetDateTime) = timestamp(JsonField.of(timestamp)) + + /** + * Sets [Builder.timestamp] to an arbitrary JSON value. + * + * You should usually call [Builder.timestamp] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun timestamp(timestamp: JsonField) = apply { + this.timestamp = timestamp + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Log]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Log = + Log( + credits, + feature, + path, + requestId, + statusCode, + timestamp, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Log = apply { + if (validated) { + return@apply + } + + credits() + feature() + path() + requestId() + statusCode() + timestamp() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CasParserInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (credits.asKnown().isPresent) 1 else 0) + + (if (feature.asKnown().isPresent) 1 else 0) + + (if (path.asKnown().isPresent) 1 else 0) + + (if (requestId.asKnown().isPresent) 1 else 0) + + (if (statusCode.asKnown().isPresent) 1 else 0) + + (if (timestamp.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Log && + credits == other.credits && + feature == other.feature && + path == other.path && + requestId == other.requestId && + statusCode == other.statusCode && + timestamp == other.timestamp && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + credits, + feature, + path, + requestId, + statusCode, + timestamp, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Log{credits=$credits, feature=$feature, path=$path, requestId=$requestId, statusCode=$statusCode, timestamp=$timestamp, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LogCreateResponse && + count == other.count && + logs == other.logs && + status == other.status && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(count, logs, status, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LogCreateResponse{count=$count, logs=$logs, status=$status, additionalProperties=$additionalProperties}" +} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/logs/LogGetSummaryParams.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/logs/LogGetSummaryParams.kt new file mode 100644 index 0000000..28648da --- /dev/null +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/logs/LogGetSummaryParams.kt @@ -0,0 +1,470 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.models.logs + +import com.cas_parser.api.core.ExcludeMissing +import com.cas_parser.api.core.JsonField +import com.cas_parser.api.core.JsonMissing +import com.cas_parser.api.core.JsonValue +import com.cas_parser.api.core.Params +import com.cas_parser.api.core.http.Headers +import com.cas_parser.api.core.http.QueryParams +import com.cas_parser.api.errors.CasParserInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional + +/** + * Get aggregated usage statistics grouped by feature. + * + * Useful for understanding which API features are being used most and tracking usage trends. + * + * **Legacy path:** `/logs/summary` (still supported) + */ +class LogGetSummaryParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * End time filter (ISO 8601). Defaults to now. + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun endTime(): Optional = body.endTime() + + /** + * Start time filter (ISO 8601). Defaults to start of current month. + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun startTime(): Optional = body.startTime() + + /** + * Returns the raw JSON value of [endTime]. + * + * Unlike [endTime], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _endTime(): JsonField = body._endTime() + + /** + * Returns the raw JSON value of [startTime]. + * + * Unlike [startTime], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _startTime(): JsonField = body._startTime() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): LogGetSummaryParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [LogGetSummaryParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LogGetSummaryParams]. */ + class Builder internal constructor() { + + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(logGetSummaryParams: LogGetSummaryParams) = apply { + body = logGetSummaryParams.body.toBuilder() + additionalHeaders = logGetSummaryParams.additionalHeaders.toBuilder() + additionalQueryParams = logGetSummaryParams.additionalQueryParams.toBuilder() + } + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [endTime] + * - [startTime] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** End time filter (ISO 8601). Defaults to now. */ + fun endTime(endTime: OffsetDateTime) = apply { body.endTime(endTime) } + + /** + * Sets [Builder.endTime] to an arbitrary JSON value. + * + * You should usually call [Builder.endTime] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun endTime(endTime: JsonField) = apply { body.endTime(endTime) } + + /** Start time filter (ISO 8601). Defaults to start of current month. */ + fun startTime(startTime: OffsetDateTime) = apply { body.startTime(startTime) } + + /** + * Sets [Builder.startTime] to an arbitrary JSON value. + * + * You should usually call [Builder.startTime] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun startTime(startTime: JsonField) = apply { body.startTime(startTime) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [LogGetSummaryParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): LogGetSummaryParams = + LogGetSummaryParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val endTime: JsonField, + private val startTime: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("end_time") + @ExcludeMissing + endTime: JsonField = JsonMissing.of(), + @JsonProperty("start_time") + @ExcludeMissing + startTime: JsonField = JsonMissing.of(), + ) : this(endTime, startTime, mutableMapOf()) + + /** + * End time filter (ISO 8601). Defaults to now. + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun endTime(): Optional = endTime.getOptional("end_time") + + /** + * Start time filter (ISO 8601). Defaults to start of current month. + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun startTime(): Optional = startTime.getOptional("start_time") + + /** + * Returns the raw JSON value of [endTime]. + * + * Unlike [endTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("end_time") + @ExcludeMissing + fun _endTime(): JsonField = endTime + + /** + * Returns the raw JSON value of [startTime]. + * + * Unlike [startTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("start_time") + @ExcludeMissing + fun _startTime(): JsonField = startTime + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Body]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var endTime: JsonField = JsonMissing.of() + private var startTime: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + endTime = body.endTime + startTime = body.startTime + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** End time filter (ISO 8601). Defaults to now. */ + fun endTime(endTime: OffsetDateTime) = endTime(JsonField.of(endTime)) + + /** + * Sets [Builder.endTime] to an arbitrary JSON value. + * + * You should usually call [Builder.endTime] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun endTime(endTime: JsonField) = apply { this.endTime = endTime } + + /** Start time filter (ISO 8601). Defaults to start of current month. */ + fun startTime(startTime: OffsetDateTime) = startTime(JsonField.of(startTime)) + + /** + * Sets [Builder.startTime] to an arbitrary JSON value. + * + * You should usually call [Builder.startTime] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun startTime(startTime: JsonField) = apply { + this.startTime = startTime + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Body = Body(endTime, startTime, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + endTime() + startTime() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CasParserInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (endTime.asKnown().isPresent) 1 else 0) + + (if (startTime.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + endTime == other.endTime && + startTime == other.startTime && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(endTime, startTime, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{endTime=$endTime, startTime=$startTime, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LogGetSummaryParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "LogGetSummaryParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/logs/LogGetSummaryResponse.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/logs/LogGetSummaryResponse.kt new file mode 100644 index 0000000..a78d1ba --- /dev/null +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/logs/LogGetSummaryResponse.kt @@ -0,0 +1,663 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.models.logs + +import com.cas_parser.api.core.ExcludeMissing +import com.cas_parser.api.core.JsonField +import com.cas_parser.api.core.JsonMissing +import com.cas_parser.api.core.JsonValue +import com.cas_parser.api.core.checkKnown +import com.cas_parser.api.core.toImmutable +import com.cas_parser.api.errors.CasParserInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class LogGetSummaryResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val status: JsonField, + private val summary: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + @JsonProperty("summary") @ExcludeMissing summary: JsonField = JsonMissing.of(), + ) : this(status, summary, mutableMapOf()) + + /** + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun status(): Optional = status.getOptional("status") + + /** + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun summary(): Optional = summary.getOptional("summary") + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [summary]. + * + * Unlike [summary], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("summary") @ExcludeMissing fun _summary(): JsonField = summary + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [LogGetSummaryResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LogGetSummaryResponse]. */ + class Builder internal constructor() { + + private var status: JsonField = JsonMissing.of() + private var summary: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(logGetSummaryResponse: LogGetSummaryResponse) = apply { + status = logGetSummaryResponse.status + summary = logGetSummaryResponse.summary + additionalProperties = logGetSummaryResponse.additionalProperties.toMutableMap() + } + + fun status(status: String) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + fun summary(summary: Summary) = summary(JsonField.of(summary)) + + /** + * Sets [Builder.summary] to an arbitrary JSON value. + * + * You should usually call [Builder.summary] with a well-typed [Summary] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun summary(summary: JsonField) = apply { this.summary = summary } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LogGetSummaryResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): LogGetSummaryResponse = + LogGetSummaryResponse(status, summary, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): LogGetSummaryResponse = apply { + if (validated) { + return@apply + } + + status() + summary().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CasParserInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (status.asKnown().isPresent) 1 else 0) + + (summary.asKnown().getOrNull()?.validity() ?: 0) + + class Summary + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val byFeature: JsonField>, + private val totalCredits: JsonField, + private val totalRequests: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("by_feature") + @ExcludeMissing + byFeature: JsonField> = JsonMissing.of(), + @JsonProperty("total_credits") + @ExcludeMissing + totalCredits: JsonField = JsonMissing.of(), + @JsonProperty("total_requests") + @ExcludeMissing + totalRequests: JsonField = JsonMissing.of(), + ) : this(byFeature, totalCredits, totalRequests, mutableMapOf()) + + /** + * Usage breakdown by feature + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun byFeature(): Optional> = byFeature.getOptional("by_feature") + + /** + * Total credits consumed in the period + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun totalCredits(): Optional = totalCredits.getOptional("total_credits") + + /** + * Total API requests made in the period + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun totalRequests(): Optional = totalRequests.getOptional("total_requests") + + /** + * Returns the raw JSON value of [byFeature]. + * + * Unlike [byFeature], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("by_feature") + @ExcludeMissing + fun _byFeature(): JsonField> = byFeature + + /** + * Returns the raw JSON value of [totalCredits]. + * + * Unlike [totalCredits], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("total_credits") + @ExcludeMissing + fun _totalCredits(): JsonField = totalCredits + + /** + * Returns the raw JSON value of [totalRequests]. + * + * Unlike [totalRequests], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("total_requests") + @ExcludeMissing + fun _totalRequests(): JsonField = totalRequests + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Summary]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Summary]. */ + class Builder internal constructor() { + + private var byFeature: JsonField>? = null + private var totalCredits: JsonField = JsonMissing.of() + private var totalRequests: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(summary: Summary) = apply { + byFeature = summary.byFeature.map { it.toMutableList() } + totalCredits = summary.totalCredits + totalRequests = summary.totalRequests + additionalProperties = summary.additionalProperties.toMutableMap() + } + + /** Usage breakdown by feature */ + fun byFeature(byFeature: List) = byFeature(JsonField.of(byFeature)) + + /** + * Sets [Builder.byFeature] to an arbitrary JSON value. + * + * You should usually call [Builder.byFeature] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun byFeature(byFeature: JsonField>) = apply { + this.byFeature = byFeature.map { it.toMutableList() } + } + + /** + * Adds a single [ByFeature] to [Builder.byFeature]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addByFeature(byFeature: ByFeature) = apply { + this.byFeature = + (this.byFeature ?: JsonField.of(mutableListOf())).also { + checkKnown("byFeature", it).add(byFeature) + } + } + + /** Total credits consumed in the period */ + fun totalCredits(totalCredits: Double) = totalCredits(JsonField.of(totalCredits)) + + /** + * Sets [Builder.totalCredits] to an arbitrary JSON value. + * + * You should usually call [Builder.totalCredits] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun totalCredits(totalCredits: JsonField) = apply { + this.totalCredits = totalCredits + } + + /** Total API requests made in the period */ + fun totalRequests(totalRequests: Long) = totalRequests(JsonField.of(totalRequests)) + + /** + * Sets [Builder.totalRequests] to an arbitrary JSON value. + * + * You should usually call [Builder.totalRequests] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun totalRequests(totalRequests: JsonField) = apply { + this.totalRequests = totalRequests + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Summary]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Summary = + Summary( + (byFeature ?: JsonMissing.of()).map { it.toImmutable() }, + totalCredits, + totalRequests, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Summary = apply { + if (validated) { + return@apply + } + + byFeature().ifPresent { it.forEach { it.validate() } } + totalCredits() + totalRequests() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CasParserInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (byFeature.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (totalCredits.asKnown().isPresent) 1 else 0) + + (if (totalRequests.asKnown().isPresent) 1 else 0) + + class ByFeature + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val credits: JsonField, + private val feature: JsonField, + private val requests: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("credits") + @ExcludeMissing + credits: JsonField = JsonMissing.of(), + @JsonProperty("feature") + @ExcludeMissing + feature: JsonField = JsonMissing.of(), + @JsonProperty("requests") + @ExcludeMissing + requests: JsonField = JsonMissing.of(), + ) : this(credits, feature, requests, mutableMapOf()) + + /** + * Credits consumed by this feature + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun credits(): Optional = credits.getOptional("credits") + + /** + * API feature name + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun feature(): Optional = feature.getOptional("feature") + + /** + * Number of requests for this feature + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun requests(): Optional = requests.getOptional("requests") + + /** + * Returns the raw JSON value of [credits]. + * + * Unlike [credits], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("credits") @ExcludeMissing fun _credits(): JsonField = credits + + /** + * Returns the raw JSON value of [feature]. + * + * Unlike [feature], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("feature") @ExcludeMissing fun _feature(): JsonField = feature + + /** + * Returns the raw JSON value of [requests]. + * + * Unlike [requests], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("requests") @ExcludeMissing fun _requests(): JsonField = requests + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [ByFeature]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ByFeature]. */ + class Builder internal constructor() { + + private var credits: JsonField = JsonMissing.of() + private var feature: JsonField = JsonMissing.of() + private var requests: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(byFeature: ByFeature) = apply { + credits = byFeature.credits + feature = byFeature.feature + requests = byFeature.requests + additionalProperties = byFeature.additionalProperties.toMutableMap() + } + + /** Credits consumed by this feature */ + fun credits(credits: Double) = credits(JsonField.of(credits)) + + /** + * Sets [Builder.credits] to an arbitrary JSON value. + * + * You should usually call [Builder.credits] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun credits(credits: JsonField) = apply { this.credits = credits } + + /** API feature name */ + fun feature(feature: String) = feature(JsonField.of(feature)) + + /** + * Sets [Builder.feature] to an arbitrary JSON value. + * + * You should usually call [Builder.feature] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun feature(feature: JsonField) = apply { this.feature = feature } + + /** Number of requests for this feature */ + fun requests(requests: Long) = requests(JsonField.of(requests)) + + /** + * Sets [Builder.requests] to an arbitrary JSON value. + * + * You should usually call [Builder.requests] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun requests(requests: JsonField) = apply { this.requests = requests } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ByFeature]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ByFeature = + ByFeature(credits, feature, requests, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): ByFeature = apply { + if (validated) { + return@apply + } + + credits() + feature() + requests() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CasParserInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (credits.asKnown().isPresent) 1 else 0) + + (if (feature.asKnown().isPresent) 1 else 0) + + (if (requests.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ByFeature && + credits == other.credits && + feature == other.feature && + requests == other.requests && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(credits, feature, requests, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ByFeature{credits=$credits, feature=$feature, requests=$requests, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Summary && + byFeature == other.byFeature && + totalCredits == other.totalCredits && + totalRequests == other.totalRequests && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(byFeature, totalCredits, totalRequests, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Summary{byFeature=$byFeature, totalCredits=$totalCredits, totalRequests=$totalRequests, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LogGetSummaryResponse && + status == other.status && + summary == other.summary && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(status, summary, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LogGetSummaryResponse{status=$status, summary=$summary, additionalProperties=$additionalProperties}" +} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/verifytoken/VerifyTokenVerifyParams.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/verifytoken/VerifyTokenVerifyParams.kt new file mode 100644 index 0000000..aac1a81 --- /dev/null +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/verifytoken/VerifyTokenVerifyParams.kt @@ -0,0 +1,211 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.models.verifytoken + +import com.cas_parser.api.core.JsonValue +import com.cas_parser.api.core.Params +import com.cas_parser.api.core.http.Headers +import com.cas_parser.api.core.http.QueryParams +import com.cas_parser.api.core.toImmutable +import java.util.Objects +import java.util.Optional + +/** Verify an access token and check if it's still valid. Useful for debugging token issues. */ +class VerifyTokenVerifyParams +private constructor( + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map, +) : Params { + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): VerifyTokenVerifyParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [VerifyTokenVerifyParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [VerifyTokenVerifyParams]. */ + class Builder internal constructor() { + + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(verifyTokenVerifyParams: VerifyTokenVerifyParams) = apply { + additionalHeaders = verifyTokenVerifyParams.additionalHeaders.toBuilder() + additionalQueryParams = verifyTokenVerifyParams.additionalQueryParams.toBuilder() + additionalBodyProperties = + verifyTokenVerifyParams.additionalBodyProperties.toMutableMap() + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [VerifyTokenVerifyParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): VerifyTokenVerifyParams = + VerifyTokenVerifyParams( + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is VerifyTokenVerifyParams && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash(additionalHeaders, additionalQueryParams, additionalBodyProperties) + + override fun toString() = + "VerifyTokenVerifyParams{additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/verifytoken/VerifyTokenVerifyResponse.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/verifytoken/VerifyTokenVerifyResponse.kt new file mode 100644 index 0000000..b8859a0 --- /dev/null +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/verifytoken/VerifyTokenVerifyResponse.kt @@ -0,0 +1,240 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.models.verifytoken + +import com.cas_parser.api.core.ExcludeMissing +import com.cas_parser.api.core.JsonField +import com.cas_parser.api.core.JsonMissing +import com.cas_parser.api.core.JsonValue +import com.cas_parser.api.errors.CasParserInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional + +class VerifyTokenVerifyResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val error: JsonField, + private val maskedApiKey: JsonField, + private val valid: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("error") @ExcludeMissing error: JsonField = JsonMissing.of(), + @JsonProperty("masked_api_key") + @ExcludeMissing + maskedApiKey: JsonField = JsonMissing.of(), + @JsonProperty("valid") @ExcludeMissing valid: JsonField = JsonMissing.of(), + ) : this(error, maskedApiKey, valid, mutableMapOf()) + + /** + * Error message (only shown if invalid) + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun error(): Optional = error.getOptional("error") + + /** + * Masked API key (only shown if valid) + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun maskedApiKey(): Optional = maskedApiKey.getOptional("masked_api_key") + + /** + * Whether the token is valid + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun valid(): Optional = valid.getOptional("valid") + + /** + * Returns the raw JSON value of [error]. + * + * Unlike [error], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("error") @ExcludeMissing fun _error(): JsonField = error + + /** + * Returns the raw JSON value of [maskedApiKey]. + * + * Unlike [maskedApiKey], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("masked_api_key") + @ExcludeMissing + fun _maskedApiKey(): JsonField = maskedApiKey + + /** + * Returns the raw JSON value of [valid]. + * + * Unlike [valid], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("valid") @ExcludeMissing fun _valid(): JsonField = valid + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [VerifyTokenVerifyResponse]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [VerifyTokenVerifyResponse]. */ + class Builder internal constructor() { + + private var error: JsonField = JsonMissing.of() + private var maskedApiKey: JsonField = JsonMissing.of() + private var valid: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(verifyTokenVerifyResponse: VerifyTokenVerifyResponse) = apply { + error = verifyTokenVerifyResponse.error + maskedApiKey = verifyTokenVerifyResponse.maskedApiKey + valid = verifyTokenVerifyResponse.valid + additionalProperties = verifyTokenVerifyResponse.additionalProperties.toMutableMap() + } + + /** Error message (only shown if invalid) */ + fun error(error: String) = error(JsonField.of(error)) + + /** + * Sets [Builder.error] to an arbitrary JSON value. + * + * You should usually call [Builder.error] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun error(error: JsonField) = apply { this.error = error } + + /** Masked API key (only shown if valid) */ + fun maskedApiKey(maskedApiKey: String) = maskedApiKey(JsonField.of(maskedApiKey)) + + /** + * Sets [Builder.maskedApiKey] to an arbitrary JSON value. + * + * You should usually call [Builder.maskedApiKey] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun maskedApiKey(maskedApiKey: JsonField) = apply { + this.maskedApiKey = maskedApiKey + } + + /** Whether the token is valid */ + fun valid(valid: Boolean) = valid(JsonField.of(valid)) + + /** + * Sets [Builder.valid] to an arbitrary JSON value. + * + * You should usually call [Builder.valid] with a well-typed [Boolean] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun valid(valid: JsonField) = apply { this.valid = valid } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [VerifyTokenVerifyResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): VerifyTokenVerifyResponse = + VerifyTokenVerifyResponse( + error, + maskedApiKey, + valid, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): VerifyTokenVerifyResponse = apply { + if (validated) { + return@apply + } + + error() + maskedApiKey() + valid() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CasParserInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (error.asKnown().isPresent) 1 else 0) + + (if (maskedApiKey.asKnown().isPresent) 1 else 0) + + (if (valid.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is VerifyTokenVerifyResponse && + error == other.error && + maskedApiKey == other.maskedApiKey && + valid == other.valid && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(error, maskedApiKey, valid, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "VerifyTokenVerifyResponse{error=$error, maskedApiKey=$maskedApiKey, valid=$valid, additionalProperties=$additionalProperties}" +} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/AccessTokenServiceAsync.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/AccessTokenServiceAsync.kt index 3809ee6..acfdef1 100644 --- a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/AccessTokenServiceAsync.kt +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/AccessTokenServiceAsync.kt @@ -3,6 +3,11 @@ package com.cas_parser.api.services.async import com.cas_parser.api.core.ClientOptions +import com.cas_parser.api.core.RequestOptions +import com.cas_parser.api.core.http.HttpResponseFor +import com.cas_parser.api.models.accesstoken.AccessTokenCreateParams +import com.cas_parser.api.models.accesstoken.AccessTokenCreateResponse +import java.util.concurrent.CompletableFuture import java.util.function.Consumer interface AccessTokenServiceAsync { @@ -19,6 +24,38 @@ interface AccessTokenServiceAsync { */ fun withOptions(modifier: Consumer): AccessTokenServiceAsync + /** + * Generate a short-lived access token from your API key. + * + * **Use this endpoint from your backend** to create tokens that can be safely passed to + * frontend/SDK. + * + * **Legacy path:** `/v1/access-token` (still supported) + * + * Access tokens: + * - Are prefixed with `at_` for easy identification + * - Valid for up to 60 minutes + * - Can be used in place of API keys on all v4 endpoints + * - Cannot be used to generate other access tokens + */ + fun create(): CompletableFuture = + create(AccessTokenCreateParams.none()) + + /** @see create */ + fun create( + params: AccessTokenCreateParams = AccessTokenCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see create */ + fun create( + params: AccessTokenCreateParams = AccessTokenCreateParams.none() + ): CompletableFuture = create(params, RequestOptions.none()) + + /** @see create */ + fun create(requestOptions: RequestOptions): CompletableFuture = + create(AccessTokenCreateParams.none(), requestOptions) + /** * A view of [AccessTokenServiceAsync] that provides access to raw HTTP responses for each * method. @@ -33,5 +70,30 @@ interface AccessTokenServiceAsync { fun withOptions( modifier: Consumer ): AccessTokenServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /v1/token`, but is otherwise the same as + * [AccessTokenServiceAsync.create]. + */ + fun create(): CompletableFuture> = + create(AccessTokenCreateParams.none()) + + /** @see create */ + fun create( + params: AccessTokenCreateParams = AccessTokenCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see create */ + fun create( + params: AccessTokenCreateParams = AccessTokenCreateParams.none() + ): CompletableFuture> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + requestOptions: RequestOptions + ): CompletableFuture> = + create(AccessTokenCreateParams.none(), requestOptions) } } diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/AccessTokenServiceAsyncImpl.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/AccessTokenServiceAsyncImpl.kt index a947c34..ec51534 100644 --- a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/AccessTokenServiceAsyncImpl.kt +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/AccessTokenServiceAsyncImpl.kt @@ -3,6 +3,21 @@ package com.cas_parser.api.services.async import com.cas_parser.api.core.ClientOptions +import com.cas_parser.api.core.RequestOptions +import com.cas_parser.api.core.handlers.errorBodyHandler +import com.cas_parser.api.core.handlers.errorHandler +import com.cas_parser.api.core.handlers.jsonHandler +import com.cas_parser.api.core.http.HttpMethod +import com.cas_parser.api.core.http.HttpRequest +import com.cas_parser.api.core.http.HttpResponse +import com.cas_parser.api.core.http.HttpResponse.Handler +import com.cas_parser.api.core.http.HttpResponseFor +import com.cas_parser.api.core.http.json +import com.cas_parser.api.core.http.parseable +import com.cas_parser.api.core.prepareAsync +import com.cas_parser.api.models.accesstoken.AccessTokenCreateParams +import com.cas_parser.api.models.accesstoken.AccessTokenCreateResponse +import java.util.concurrent.CompletableFuture import java.util.function.Consumer class AccessTokenServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : @@ -17,14 +32,55 @@ class AccessTokenServiceAsyncImpl internal constructor(private val clientOptions override fun withOptions(modifier: Consumer): AccessTokenServiceAsync = AccessTokenServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create( + params: AccessTokenCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /v1/token + withRawResponse().create(params, requestOptions).thenApply { it.parse() } + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : AccessTokenServiceAsync.WithRawResponse { + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + override fun withOptions( modifier: Consumer ): AccessTokenServiceAsync.WithRawResponse = AccessTokenServiceAsyncImpl.WithRawResponseImpl( clientOptions.toBuilder().apply(modifier::accept).build() ) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun create( + params: AccessTokenCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "token") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } } } diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/CreditServiceAsync.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/CreditServiceAsync.kt index 70f75cb..dd5a54f 100644 --- a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/CreditServiceAsync.kt +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/CreditServiceAsync.kt @@ -3,6 +3,11 @@ package com.cas_parser.api.services.async import com.cas_parser.api.core.ClientOptions +import com.cas_parser.api.core.RequestOptions +import com.cas_parser.api.core.http.HttpResponseFor +import com.cas_parser.api.models.credits.CreditCheckParams +import com.cas_parser.api.models.credits.CreditCheckResponse +import java.util.concurrent.CompletableFuture import java.util.function.Consumer interface CreditServiceAsync { @@ -19,6 +24,33 @@ interface CreditServiceAsync { */ fun withOptions(modifier: Consumer): CreditServiceAsync + /** + * Check your remaining API credits and usage for the current billing period. + * + * Returns: + * - Number of API calls used and remaining credits + * - Credit limit and reset date + * - List of enabled features for your plan + * + * Credits reset at the start of each billing period. + */ + fun check(): CompletableFuture = check(CreditCheckParams.none()) + + /** @see check */ + fun check( + params: CreditCheckParams = CreditCheckParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see check */ + fun check( + params: CreditCheckParams = CreditCheckParams.none() + ): CompletableFuture = check(params, RequestOptions.none()) + + /** @see check */ + fun check(requestOptions: RequestOptions): CompletableFuture = + check(CreditCheckParams.none(), requestOptions) + /** * A view of [CreditServiceAsync] that provides access to raw HTTP responses for each method. */ @@ -32,5 +64,30 @@ interface CreditServiceAsync { fun withOptions( modifier: Consumer ): CreditServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /v1/credits`, but is otherwise the same as + * [CreditServiceAsync.check]. + */ + fun check(): CompletableFuture> = + check(CreditCheckParams.none()) + + /** @see check */ + fun check( + params: CreditCheckParams = CreditCheckParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see check */ + fun check( + params: CreditCheckParams = CreditCheckParams.none() + ): CompletableFuture> = + check(params, RequestOptions.none()) + + /** @see check */ + fun check( + requestOptions: RequestOptions + ): CompletableFuture> = + check(CreditCheckParams.none(), requestOptions) } } diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/CreditServiceAsyncImpl.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/CreditServiceAsyncImpl.kt index 9995851..02b806c 100644 --- a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/CreditServiceAsyncImpl.kt +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/CreditServiceAsyncImpl.kt @@ -3,6 +3,21 @@ package com.cas_parser.api.services.async import com.cas_parser.api.core.ClientOptions +import com.cas_parser.api.core.RequestOptions +import com.cas_parser.api.core.handlers.errorBodyHandler +import com.cas_parser.api.core.handlers.errorHandler +import com.cas_parser.api.core.handlers.jsonHandler +import com.cas_parser.api.core.http.HttpMethod +import com.cas_parser.api.core.http.HttpRequest +import com.cas_parser.api.core.http.HttpResponse +import com.cas_parser.api.core.http.HttpResponse.Handler +import com.cas_parser.api.core.http.HttpResponseFor +import com.cas_parser.api.core.http.json +import com.cas_parser.api.core.http.parseable +import com.cas_parser.api.core.prepareAsync +import com.cas_parser.api.models.credits.CreditCheckParams +import com.cas_parser.api.models.credits.CreditCheckResponse +import java.util.concurrent.CompletableFuture import java.util.function.Consumer class CreditServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : @@ -17,14 +32,55 @@ class CreditServiceAsyncImpl internal constructor(private val clientOptions: Cli override fun withOptions(modifier: Consumer): CreditServiceAsync = CreditServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun check( + params: CreditCheckParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /v1/credits + withRawResponse().check(params, requestOptions).thenApply { it.parse() } + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : CreditServiceAsync.WithRawResponse { + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + override fun withOptions( modifier: Consumer ): CreditServiceAsync.WithRawResponse = CreditServiceAsyncImpl.WithRawResponseImpl( clientOptions.toBuilder().apply(modifier::accept).build() ) + + private val checkHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun check( + params: CreditCheckParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "credits") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { checkHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } } } diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/InboundEmailServiceAsync.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/InboundEmailServiceAsync.kt new file mode 100644 index 0000000..8ff0edb --- /dev/null +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/InboundEmailServiceAsync.kt @@ -0,0 +1,300 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.services.async + +import com.cas_parser.api.core.ClientOptions +import com.cas_parser.api.core.RequestOptions +import com.cas_parser.api.core.http.HttpResponseFor +import com.cas_parser.api.models.inboundemail.InboundEmailCreateParams +import com.cas_parser.api.models.inboundemail.InboundEmailCreateResponse +import com.cas_parser.api.models.inboundemail.InboundEmailDeleteParams +import com.cas_parser.api.models.inboundemail.InboundEmailDeleteResponse +import com.cas_parser.api.models.inboundemail.InboundEmailListParams +import com.cas_parser.api.models.inboundemail.InboundEmailListResponse +import com.cas_parser.api.models.inboundemail.InboundEmailRetrieveParams +import com.cas_parser.api.models.inboundemail.InboundEmailRetrieveResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface InboundEmailServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): InboundEmailServiceAsync + + /** + * Create a dedicated inbound email address for collecting CAS statements via email forwarding. + * + * **How it works:** + * 1. Create an inbound email with your webhook URL + * 2. Display the email address to your user (e.g., "Forward your CAS to + * ie_xxx@import.casparser.in") + * 3. When an investor forwards a CAS email, we verify the sender and deliver to your webhook + * + * **Webhook Delivery:** + * - We POST to your `callback_url` with JSON body containing files (matching EmailCASFile + * schema) + * - Failed deliveries are retried automatically with exponential backoff + * + * **Inactivity:** + * - Inbound emails with no activity in 30 days are marked inactive + * - Active inbound emails remain operational indefinitely + */ + fun create(params: InboundEmailCreateParams): CompletableFuture = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: InboundEmailCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** Retrieve details of a specific mailbox including statistics. */ + fun retrieve(inboundEmailId: String): CompletableFuture = + retrieve(inboundEmailId, InboundEmailRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + inboundEmailId: String, + params: InboundEmailRetrieveParams = InboundEmailRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + retrieve(params.toBuilder().inboundEmailId(inboundEmailId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + inboundEmailId: String, + params: InboundEmailRetrieveParams = InboundEmailRetrieveParams.none(), + ): CompletableFuture = + retrieve(inboundEmailId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: InboundEmailRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see retrieve */ + fun retrieve( + params: InboundEmailRetrieveParams + ): CompletableFuture = retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + inboundEmailId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + retrieve(inboundEmailId, InboundEmailRetrieveParams.none(), requestOptions) + + /** + * List all mailboxes associated with your API key. Returns active and inactive mailboxes + * (deleted mailboxes are excluded). + */ + fun list(): CompletableFuture = list(InboundEmailListParams.none()) + + /** @see list */ + fun list( + params: InboundEmailListParams = InboundEmailListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see list */ + fun list( + params: InboundEmailListParams = InboundEmailListParams.none() + ): CompletableFuture = list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): CompletableFuture = + list(InboundEmailListParams.none(), requestOptions) + + /** + * Permanently delete an inbound email address. It will stop accepting emails. + * + * **Note:** Deletion is immediate and cannot be undone. Any emails received after deletion will + * be rejected. + */ + fun delete(inboundEmailId: String): CompletableFuture = + delete(inboundEmailId, InboundEmailDeleteParams.none()) + + /** @see delete */ + fun delete( + inboundEmailId: String, + params: InboundEmailDeleteParams = InboundEmailDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + delete(params.toBuilder().inboundEmailId(inboundEmailId).build(), requestOptions) + + /** @see delete */ + fun delete( + inboundEmailId: String, + params: InboundEmailDeleteParams = InboundEmailDeleteParams.none(), + ): CompletableFuture = + delete(inboundEmailId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: InboundEmailDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see delete */ + fun delete(params: InboundEmailDeleteParams): CompletableFuture = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + inboundEmailId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + delete(inboundEmailId, InboundEmailDeleteParams.none(), requestOptions) + + /** + * A view of [InboundEmailServiceAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): InboundEmailServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /v4/inbound-email`, but is otherwise the same as + * [InboundEmailServiceAsync.create]. + */ + fun create( + params: InboundEmailCreateParams + ): CompletableFuture> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: InboundEmailCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /v4/inbound-email/{inbound_email_id}`, but is + * otherwise the same as [InboundEmailServiceAsync.retrieve]. + */ + fun retrieve( + inboundEmailId: String + ): CompletableFuture> = + retrieve(inboundEmailId, InboundEmailRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + inboundEmailId: String, + params: InboundEmailRetrieveParams = InboundEmailRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + retrieve(params.toBuilder().inboundEmailId(inboundEmailId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + inboundEmailId: String, + params: InboundEmailRetrieveParams = InboundEmailRetrieveParams.none(), + ): CompletableFuture> = + retrieve(inboundEmailId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: InboundEmailRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see retrieve */ + fun retrieve( + params: InboundEmailRetrieveParams + ): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + inboundEmailId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + retrieve(inboundEmailId, InboundEmailRetrieveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /v4/inbound-email`, but is otherwise the same as + * [InboundEmailServiceAsync.list]. + */ + fun list(): CompletableFuture> = + list(InboundEmailListParams.none()) + + /** @see list */ + fun list( + params: InboundEmailListParams = InboundEmailListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see list */ + fun list( + params: InboundEmailListParams = InboundEmailListParams.none() + ): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + requestOptions: RequestOptions + ): CompletableFuture> = + list(InboundEmailListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /v4/inbound-email/{inbound_email_id}`, but is + * otherwise the same as [InboundEmailServiceAsync.delete]. + */ + fun delete( + inboundEmailId: String + ): CompletableFuture> = + delete(inboundEmailId, InboundEmailDeleteParams.none()) + + /** @see delete */ + fun delete( + inboundEmailId: String, + params: InboundEmailDeleteParams = InboundEmailDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + delete(params.toBuilder().inboundEmailId(inboundEmailId).build(), requestOptions) + + /** @see delete */ + fun delete( + inboundEmailId: String, + params: InboundEmailDeleteParams = InboundEmailDeleteParams.none(), + ): CompletableFuture> = + delete(inboundEmailId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: InboundEmailDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see delete */ + fun delete( + params: InboundEmailDeleteParams + ): CompletableFuture> = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + inboundEmailId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + delete(inboundEmailId, InboundEmailDeleteParams.none(), requestOptions) + } +} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/InboundEmailServiceAsyncImpl.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/InboundEmailServiceAsyncImpl.kt new file mode 100644 index 0000000..a199b5f --- /dev/null +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/InboundEmailServiceAsyncImpl.kt @@ -0,0 +1,212 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.services.async + +import com.cas_parser.api.core.ClientOptions +import com.cas_parser.api.core.RequestOptions +import com.cas_parser.api.core.checkRequired +import com.cas_parser.api.core.handlers.errorBodyHandler +import com.cas_parser.api.core.handlers.errorHandler +import com.cas_parser.api.core.handlers.jsonHandler +import com.cas_parser.api.core.http.HttpMethod +import com.cas_parser.api.core.http.HttpRequest +import com.cas_parser.api.core.http.HttpResponse +import com.cas_parser.api.core.http.HttpResponse.Handler +import com.cas_parser.api.core.http.HttpResponseFor +import com.cas_parser.api.core.http.json +import com.cas_parser.api.core.http.parseable +import com.cas_parser.api.core.prepareAsync +import com.cas_parser.api.models.inboundemail.InboundEmailCreateParams +import com.cas_parser.api.models.inboundemail.InboundEmailCreateResponse +import com.cas_parser.api.models.inboundemail.InboundEmailDeleteParams +import com.cas_parser.api.models.inboundemail.InboundEmailDeleteResponse +import com.cas_parser.api.models.inboundemail.InboundEmailListParams +import com.cas_parser.api.models.inboundemail.InboundEmailListResponse +import com.cas_parser.api.models.inboundemail.InboundEmailRetrieveParams +import com.cas_parser.api.models.inboundemail.InboundEmailRetrieveResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class InboundEmailServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + InboundEmailServiceAsync { + + private val withRawResponse: InboundEmailServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): InboundEmailServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): InboundEmailServiceAsync = + InboundEmailServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: InboundEmailCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /v4/inbound-email + withRawResponse().create(params, requestOptions).thenApply { it.parse() } + + override fun retrieve( + params: InboundEmailRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /v4/inbound-email/{inbound_email_id} + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + + override fun list( + params: InboundEmailListParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /v4/inbound-email + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + override fun delete( + params: InboundEmailDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // delete /v4/inbound-email/{inbound_email_id} + withRawResponse().delete(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + InboundEmailServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): InboundEmailServiceAsync.WithRawResponse = + InboundEmailServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun create( + params: InboundEmailCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v4", "inbound-email") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieve( + params: InboundEmailRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("inboundEmailId", params.inboundEmailId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v4", "inbound-email", params._pathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun list( + params: InboundEmailListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v4", "inbound-email") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val deleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun delete( + params: InboundEmailDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("inboundEmailId", params.inboundEmailId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v4", "inbound-email", params._pathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/LogServiceAsync.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/LogServiceAsync.kt index 4dc2b00..3f2546a 100644 --- a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/LogServiceAsync.kt +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/LogServiceAsync.kt @@ -3,6 +3,13 @@ package com.cas_parser.api.services.async import com.cas_parser.api.core.ClientOptions +import com.cas_parser.api.core.RequestOptions +import com.cas_parser.api.core.http.HttpResponseFor +import com.cas_parser.api.models.logs.LogCreateParams +import com.cas_parser.api.models.logs.LogCreateResponse +import com.cas_parser.api.models.logs.LogGetSummaryParams +import com.cas_parser.api.models.logs.LogGetSummaryResponse +import java.util.concurrent.CompletableFuture import java.util.function.Consumer interface LogServiceAsync { @@ -19,6 +26,56 @@ interface LogServiceAsync { */ fun withOptions(modifier: Consumer): LogServiceAsync + /** + * Retrieve detailed API usage logs for your account. + * + * Returns a list of API calls with timestamps, features used, status codes, and credits + * consumed. Useful for monitoring usage patterns and debugging. + * + * **Legacy path:** `/logs` (still supported) + */ + fun create(): CompletableFuture = create(LogCreateParams.none()) + + /** @see create */ + fun create( + params: LogCreateParams = LogCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see create */ + fun create( + params: LogCreateParams = LogCreateParams.none() + ): CompletableFuture = create(params, RequestOptions.none()) + + /** @see create */ + fun create(requestOptions: RequestOptions): CompletableFuture = + create(LogCreateParams.none(), requestOptions) + + /** + * Get aggregated usage statistics grouped by feature. + * + * Useful for understanding which API features are being used most and tracking usage trends. + * + * **Legacy path:** `/logs/summary` (still supported) + */ + fun getSummary(): CompletableFuture = + getSummary(LogGetSummaryParams.none()) + + /** @see getSummary */ + fun getSummary( + params: LogGetSummaryParams = LogGetSummaryParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see getSummary */ + fun getSummary( + params: LogGetSummaryParams = LogGetSummaryParams.none() + ): CompletableFuture = getSummary(params, RequestOptions.none()) + + /** @see getSummary */ + fun getSummary(requestOptions: RequestOptions): CompletableFuture = + getSummary(LogGetSummaryParams.none(), requestOptions) + /** A view of [LogServiceAsync] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -28,5 +85,55 @@ interface LogServiceAsync { * The original service is not modified. */ fun withOptions(modifier: Consumer): LogServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /v1/usage`, but is otherwise the same as + * [LogServiceAsync.create]. + */ + fun create(): CompletableFuture> = + create(LogCreateParams.none()) + + /** @see create */ + fun create( + params: LogCreateParams = LogCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see create */ + fun create( + params: LogCreateParams = LogCreateParams.none() + ): CompletableFuture> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + requestOptions: RequestOptions + ): CompletableFuture> = + create(LogCreateParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /v1/usage/summary`, but is otherwise the same as + * [LogServiceAsync.getSummary]. + */ + fun getSummary(): CompletableFuture> = + getSummary(LogGetSummaryParams.none()) + + /** @see getSummary */ + fun getSummary( + params: LogGetSummaryParams = LogGetSummaryParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see getSummary */ + fun getSummary( + params: LogGetSummaryParams = LogGetSummaryParams.none() + ): CompletableFuture> = + getSummary(params, RequestOptions.none()) + + /** @see getSummary */ + fun getSummary( + requestOptions: RequestOptions + ): CompletableFuture> = + getSummary(LogGetSummaryParams.none(), requestOptions) } } diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/LogServiceAsyncImpl.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/LogServiceAsyncImpl.kt index 6797075..a4bf0f2 100644 --- a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/LogServiceAsyncImpl.kt +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/LogServiceAsyncImpl.kt @@ -3,6 +3,23 @@ package com.cas_parser.api.services.async import com.cas_parser.api.core.ClientOptions +import com.cas_parser.api.core.RequestOptions +import com.cas_parser.api.core.handlers.errorBodyHandler +import com.cas_parser.api.core.handlers.errorHandler +import com.cas_parser.api.core.handlers.jsonHandler +import com.cas_parser.api.core.http.HttpMethod +import com.cas_parser.api.core.http.HttpRequest +import com.cas_parser.api.core.http.HttpResponse +import com.cas_parser.api.core.http.HttpResponse.Handler +import com.cas_parser.api.core.http.HttpResponseFor +import com.cas_parser.api.core.http.json +import com.cas_parser.api.core.http.parseable +import com.cas_parser.api.core.prepareAsync +import com.cas_parser.api.models.logs.LogCreateParams +import com.cas_parser.api.models.logs.LogCreateResponse +import com.cas_parser.api.models.logs.LogGetSummaryParams +import com.cas_parser.api.models.logs.LogGetSummaryResponse +import java.util.concurrent.CompletableFuture import java.util.function.Consumer class LogServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : @@ -17,14 +34,93 @@ class LogServiceAsyncImpl internal constructor(private val clientOptions: Client override fun withOptions(modifier: Consumer): LogServiceAsync = LogServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create( + params: LogCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /v1/usage + withRawResponse().create(params, requestOptions).thenApply { it.parse() } + + override fun getSummary( + params: LogGetSummaryParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /v1/usage/summary + withRawResponse().getSummary(params, requestOptions).thenApply { it.parse() } + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : LogServiceAsync.WithRawResponse { + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + override fun withOptions( modifier: Consumer ): LogServiceAsync.WithRawResponse = LogServiceAsyncImpl.WithRawResponseImpl( clientOptions.toBuilder().apply(modifier::accept).build() ) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun create( + params: LogCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "usage") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val getSummaryHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun getSummary( + params: LogGetSummaryParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "usage", "summary") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { getSummaryHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } } } diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/VerifyTokenServiceAsync.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/VerifyTokenServiceAsync.kt index 4ff8c23..3d8b41e 100644 --- a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/VerifyTokenServiceAsync.kt +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/VerifyTokenServiceAsync.kt @@ -3,6 +3,11 @@ package com.cas_parser.api.services.async import com.cas_parser.api.core.ClientOptions +import com.cas_parser.api.core.RequestOptions +import com.cas_parser.api.core.http.HttpResponseFor +import com.cas_parser.api.models.verifytoken.VerifyTokenVerifyParams +import com.cas_parser.api.models.verifytoken.VerifyTokenVerifyResponse +import java.util.concurrent.CompletableFuture import java.util.function.Consumer interface VerifyTokenServiceAsync { @@ -19,6 +24,25 @@ interface VerifyTokenServiceAsync { */ fun withOptions(modifier: Consumer): VerifyTokenServiceAsync + /** Verify an access token and check if it's still valid. Useful for debugging token issues. */ + fun verify(): CompletableFuture = + verify(VerifyTokenVerifyParams.none()) + + /** @see verify */ + fun verify( + params: VerifyTokenVerifyParams = VerifyTokenVerifyParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see verify */ + fun verify( + params: VerifyTokenVerifyParams = VerifyTokenVerifyParams.none() + ): CompletableFuture = verify(params, RequestOptions.none()) + + /** @see verify */ + fun verify(requestOptions: RequestOptions): CompletableFuture = + verify(VerifyTokenVerifyParams.none(), requestOptions) + /** * A view of [VerifyTokenServiceAsync] that provides access to raw HTTP responses for each * method. @@ -33,5 +57,30 @@ interface VerifyTokenServiceAsync { fun withOptions( modifier: Consumer ): VerifyTokenServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /v1/token/verify`, but is otherwise the same as + * [VerifyTokenServiceAsync.verify]. + */ + fun verify(): CompletableFuture> = + verify(VerifyTokenVerifyParams.none()) + + /** @see verify */ + fun verify( + params: VerifyTokenVerifyParams = VerifyTokenVerifyParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see verify */ + fun verify( + params: VerifyTokenVerifyParams = VerifyTokenVerifyParams.none() + ): CompletableFuture> = + verify(params, RequestOptions.none()) + + /** @see verify */ + fun verify( + requestOptions: RequestOptions + ): CompletableFuture> = + verify(VerifyTokenVerifyParams.none(), requestOptions) } } diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/VerifyTokenServiceAsyncImpl.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/VerifyTokenServiceAsyncImpl.kt index c617351..9a42c63 100644 --- a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/VerifyTokenServiceAsyncImpl.kt +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/VerifyTokenServiceAsyncImpl.kt @@ -3,6 +3,21 @@ package com.cas_parser.api.services.async import com.cas_parser.api.core.ClientOptions +import com.cas_parser.api.core.RequestOptions +import com.cas_parser.api.core.handlers.errorBodyHandler +import com.cas_parser.api.core.handlers.errorHandler +import com.cas_parser.api.core.handlers.jsonHandler +import com.cas_parser.api.core.http.HttpMethod +import com.cas_parser.api.core.http.HttpRequest +import com.cas_parser.api.core.http.HttpResponse +import com.cas_parser.api.core.http.HttpResponse.Handler +import com.cas_parser.api.core.http.HttpResponseFor +import com.cas_parser.api.core.http.json +import com.cas_parser.api.core.http.parseable +import com.cas_parser.api.core.prepareAsync +import com.cas_parser.api.models.verifytoken.VerifyTokenVerifyParams +import com.cas_parser.api.models.verifytoken.VerifyTokenVerifyResponse +import java.util.concurrent.CompletableFuture import java.util.function.Consumer class VerifyTokenServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : @@ -17,14 +32,55 @@ class VerifyTokenServiceAsyncImpl internal constructor(private val clientOptions override fun withOptions(modifier: Consumer): VerifyTokenServiceAsync = VerifyTokenServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun verify( + params: VerifyTokenVerifyParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /v1/token/verify + withRawResponse().verify(params, requestOptions).thenApply { it.parse() } + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : VerifyTokenServiceAsync.WithRawResponse { + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + override fun withOptions( modifier: Consumer ): VerifyTokenServiceAsync.WithRawResponse = VerifyTokenServiceAsyncImpl.WithRawResponseImpl( clientOptions.toBuilder().apply(modifier::accept).build() ) + + private val verifyHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun verify( + params: VerifyTokenVerifyParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "token", "verify") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { verifyHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } } } diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/AccessTokenService.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/AccessTokenService.kt index 2779802..784798e 100644 --- a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/AccessTokenService.kt +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/AccessTokenService.kt @@ -3,6 +3,11 @@ package com.cas_parser.api.services.blocking import com.cas_parser.api.core.ClientOptions +import com.cas_parser.api.core.RequestOptions +import com.cas_parser.api.core.http.HttpResponseFor +import com.cas_parser.api.models.accesstoken.AccessTokenCreateParams +import com.cas_parser.api.models.accesstoken.AccessTokenCreateResponse +import com.google.errorprone.annotations.MustBeClosed import java.util.function.Consumer interface AccessTokenService { @@ -19,6 +24,37 @@ interface AccessTokenService { */ fun withOptions(modifier: Consumer): AccessTokenService + /** + * Generate a short-lived access token from your API key. + * + * **Use this endpoint from your backend** to create tokens that can be safely passed to + * frontend/SDK. + * + * **Legacy path:** `/v1/access-token` (still supported) + * + * Access tokens: + * - Are prefixed with `at_` for easy identification + * - Valid for up to 60 minutes + * - Can be used in place of API keys on all v4 endpoints + * - Cannot be used to generate other access tokens + */ + fun create(): AccessTokenCreateResponse = create(AccessTokenCreateParams.none()) + + /** @see create */ + fun create( + params: AccessTokenCreateParams = AccessTokenCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): AccessTokenCreateResponse + + /** @see create */ + fun create( + params: AccessTokenCreateParams = AccessTokenCreateParams.none() + ): AccessTokenCreateResponse = create(params, RequestOptions.none()) + + /** @see create */ + fun create(requestOptions: RequestOptions): AccessTokenCreateResponse = + create(AccessTokenCreateParams.none(), requestOptions) + /** * A view of [AccessTokenService] that provides access to raw HTTP responses for each method. */ @@ -32,5 +68,31 @@ interface AccessTokenService { fun withOptions( modifier: Consumer ): AccessTokenService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /v1/token`, but is otherwise the same as + * [AccessTokenService.create]. + */ + @MustBeClosed + fun create(): HttpResponseFor = + create(AccessTokenCreateParams.none()) + + /** @see create */ + @MustBeClosed + fun create( + params: AccessTokenCreateParams = AccessTokenCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see create */ + @MustBeClosed + fun create( + params: AccessTokenCreateParams = AccessTokenCreateParams.none() + ): HttpResponseFor = create(params, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create(requestOptions: RequestOptions): HttpResponseFor = + create(AccessTokenCreateParams.none(), requestOptions) } } diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/AccessTokenServiceImpl.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/AccessTokenServiceImpl.kt index a8c27c2..9fe0782 100644 --- a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/AccessTokenServiceImpl.kt +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/AccessTokenServiceImpl.kt @@ -3,6 +3,20 @@ package com.cas_parser.api.services.blocking import com.cas_parser.api.core.ClientOptions +import com.cas_parser.api.core.RequestOptions +import com.cas_parser.api.core.handlers.errorBodyHandler +import com.cas_parser.api.core.handlers.errorHandler +import com.cas_parser.api.core.handlers.jsonHandler +import com.cas_parser.api.core.http.HttpMethod +import com.cas_parser.api.core.http.HttpRequest +import com.cas_parser.api.core.http.HttpResponse +import com.cas_parser.api.core.http.HttpResponse.Handler +import com.cas_parser.api.core.http.HttpResponseFor +import com.cas_parser.api.core.http.json +import com.cas_parser.api.core.http.parseable +import com.cas_parser.api.core.prepare +import com.cas_parser.api.models.accesstoken.AccessTokenCreateParams +import com.cas_parser.api.models.accesstoken.AccessTokenCreateResponse import java.util.function.Consumer class AccessTokenServiceImpl internal constructor(private val clientOptions: ClientOptions) : @@ -17,14 +31,52 @@ class AccessTokenServiceImpl internal constructor(private val clientOptions: Cli override fun withOptions(modifier: Consumer): AccessTokenService = AccessTokenServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create( + params: AccessTokenCreateParams, + requestOptions: RequestOptions, + ): AccessTokenCreateResponse = + // post /v1/token + withRawResponse().create(params, requestOptions).parse() + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : AccessTokenService.WithRawResponse { + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + override fun withOptions( modifier: Consumer ): AccessTokenService.WithRawResponse = AccessTokenServiceImpl.WithRawResponseImpl( clientOptions.toBuilder().apply(modifier::accept).build() ) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun create( + params: AccessTokenCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "token") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } } diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/CreditService.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/CreditService.kt index 60ebf10..0c7a9da 100644 --- a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/CreditService.kt +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/CreditService.kt @@ -3,6 +3,11 @@ package com.cas_parser.api.services.blocking import com.cas_parser.api.core.ClientOptions +import com.cas_parser.api.core.RequestOptions +import com.cas_parser.api.core.http.HttpResponseFor +import com.cas_parser.api.models.credits.CreditCheckParams +import com.cas_parser.api.models.credits.CreditCheckResponse +import com.google.errorprone.annotations.MustBeClosed import java.util.function.Consumer interface CreditService { @@ -19,6 +24,32 @@ interface CreditService { */ fun withOptions(modifier: Consumer): CreditService + /** + * Check your remaining API credits and usage for the current billing period. + * + * Returns: + * - Number of API calls used and remaining credits + * - Credit limit and reset date + * - List of enabled features for your plan + * + * Credits reset at the start of each billing period. + */ + fun check(): CreditCheckResponse = check(CreditCheckParams.none()) + + /** @see check */ + fun check( + params: CreditCheckParams = CreditCheckParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CreditCheckResponse + + /** @see check */ + fun check(params: CreditCheckParams = CreditCheckParams.none()): CreditCheckResponse = + check(params, RequestOptions.none()) + + /** @see check */ + fun check(requestOptions: RequestOptions): CreditCheckResponse = + check(CreditCheckParams.none(), requestOptions) + /** A view of [CreditService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -28,5 +59,30 @@ interface CreditService { * The original service is not modified. */ fun withOptions(modifier: Consumer): CreditService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /v1/credits`, but is otherwise the same as + * [CreditService.check]. + */ + @MustBeClosed + fun check(): HttpResponseFor = check(CreditCheckParams.none()) + + /** @see check */ + @MustBeClosed + fun check( + params: CreditCheckParams = CreditCheckParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see check */ + @MustBeClosed + fun check( + params: CreditCheckParams = CreditCheckParams.none() + ): HttpResponseFor = check(params, RequestOptions.none()) + + /** @see check */ + @MustBeClosed + fun check(requestOptions: RequestOptions): HttpResponseFor = + check(CreditCheckParams.none(), requestOptions) } } diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/CreditServiceImpl.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/CreditServiceImpl.kt index a33b3c5..c611592 100644 --- a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/CreditServiceImpl.kt +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/CreditServiceImpl.kt @@ -3,6 +3,20 @@ package com.cas_parser.api.services.blocking import com.cas_parser.api.core.ClientOptions +import com.cas_parser.api.core.RequestOptions +import com.cas_parser.api.core.handlers.errorBodyHandler +import com.cas_parser.api.core.handlers.errorHandler +import com.cas_parser.api.core.handlers.jsonHandler +import com.cas_parser.api.core.http.HttpMethod +import com.cas_parser.api.core.http.HttpRequest +import com.cas_parser.api.core.http.HttpResponse +import com.cas_parser.api.core.http.HttpResponse.Handler +import com.cas_parser.api.core.http.HttpResponseFor +import com.cas_parser.api.core.http.json +import com.cas_parser.api.core.http.parseable +import com.cas_parser.api.core.prepare +import com.cas_parser.api.models.credits.CreditCheckParams +import com.cas_parser.api.models.credits.CreditCheckResponse import java.util.function.Consumer class CreditServiceImpl internal constructor(private val clientOptions: ClientOptions) : @@ -17,14 +31,52 @@ class CreditServiceImpl internal constructor(private val clientOptions: ClientOp override fun withOptions(modifier: Consumer): CreditService = CreditServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun check( + params: CreditCheckParams, + requestOptions: RequestOptions, + ): CreditCheckResponse = + // post /v1/credits + withRawResponse().check(params, requestOptions).parse() + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : CreditService.WithRawResponse { + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + override fun withOptions( modifier: Consumer ): CreditService.WithRawResponse = CreditServiceImpl.WithRawResponseImpl( clientOptions.toBuilder().apply(modifier::accept).build() ) + + private val checkHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun check( + params: CreditCheckParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "credits") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { checkHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } } diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/InboundEmailService.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/InboundEmailService.kt new file mode 100644 index 0000000..c46275e --- /dev/null +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/InboundEmailService.kt @@ -0,0 +1,298 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.services.blocking + +import com.cas_parser.api.core.ClientOptions +import com.cas_parser.api.core.RequestOptions +import com.cas_parser.api.core.http.HttpResponseFor +import com.cas_parser.api.models.inboundemail.InboundEmailCreateParams +import com.cas_parser.api.models.inboundemail.InboundEmailCreateResponse +import com.cas_parser.api.models.inboundemail.InboundEmailDeleteParams +import com.cas_parser.api.models.inboundemail.InboundEmailDeleteResponse +import com.cas_parser.api.models.inboundemail.InboundEmailListParams +import com.cas_parser.api.models.inboundemail.InboundEmailListResponse +import com.cas_parser.api.models.inboundemail.InboundEmailRetrieveParams +import com.cas_parser.api.models.inboundemail.InboundEmailRetrieveResponse +import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer + +interface InboundEmailService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): InboundEmailService + + /** + * Create a dedicated inbound email address for collecting CAS statements via email forwarding. + * + * **How it works:** + * 1. Create an inbound email with your webhook URL + * 2. Display the email address to your user (e.g., "Forward your CAS to + * ie_xxx@import.casparser.in") + * 3. When an investor forwards a CAS email, we verify the sender and deliver to your webhook + * + * **Webhook Delivery:** + * - We POST to your `callback_url` with JSON body containing files (matching EmailCASFile + * schema) + * - Failed deliveries are retried automatically with exponential backoff + * + * **Inactivity:** + * - Inbound emails with no activity in 30 days are marked inactive + * - Active inbound emails remain operational indefinitely + */ + fun create(params: InboundEmailCreateParams): InboundEmailCreateResponse = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: InboundEmailCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): InboundEmailCreateResponse + + /** Retrieve details of a specific mailbox including statistics. */ + fun retrieve(inboundEmailId: String): InboundEmailRetrieveResponse = + retrieve(inboundEmailId, InboundEmailRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + inboundEmailId: String, + params: InboundEmailRetrieveParams = InboundEmailRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): InboundEmailRetrieveResponse = + retrieve(params.toBuilder().inboundEmailId(inboundEmailId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + inboundEmailId: String, + params: InboundEmailRetrieveParams = InboundEmailRetrieveParams.none(), + ): InboundEmailRetrieveResponse = retrieve(inboundEmailId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: InboundEmailRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): InboundEmailRetrieveResponse + + /** @see retrieve */ + fun retrieve(params: InboundEmailRetrieveParams): InboundEmailRetrieveResponse = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + inboundEmailId: String, + requestOptions: RequestOptions, + ): InboundEmailRetrieveResponse = + retrieve(inboundEmailId, InboundEmailRetrieveParams.none(), requestOptions) + + /** + * List all mailboxes associated with your API key. Returns active and inactive mailboxes + * (deleted mailboxes are excluded). + */ + fun list(): InboundEmailListResponse = list(InboundEmailListParams.none()) + + /** @see list */ + fun list( + params: InboundEmailListParams = InboundEmailListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): InboundEmailListResponse + + /** @see list */ + fun list( + params: InboundEmailListParams = InboundEmailListParams.none() + ): InboundEmailListResponse = list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): InboundEmailListResponse = + list(InboundEmailListParams.none(), requestOptions) + + /** + * Permanently delete an inbound email address. It will stop accepting emails. + * + * **Note:** Deletion is immediate and cannot be undone. Any emails received after deletion will + * be rejected. + */ + fun delete(inboundEmailId: String): InboundEmailDeleteResponse = + delete(inboundEmailId, InboundEmailDeleteParams.none()) + + /** @see delete */ + fun delete( + inboundEmailId: String, + params: InboundEmailDeleteParams = InboundEmailDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): InboundEmailDeleteResponse = + delete(params.toBuilder().inboundEmailId(inboundEmailId).build(), requestOptions) + + /** @see delete */ + fun delete( + inboundEmailId: String, + params: InboundEmailDeleteParams = InboundEmailDeleteParams.none(), + ): InboundEmailDeleteResponse = delete(inboundEmailId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: InboundEmailDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): InboundEmailDeleteResponse + + /** @see delete */ + fun delete(params: InboundEmailDeleteParams): InboundEmailDeleteResponse = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete(inboundEmailId: String, requestOptions: RequestOptions): InboundEmailDeleteResponse = + delete(inboundEmailId, InboundEmailDeleteParams.none(), requestOptions) + + /** + * A view of [InboundEmailService] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): InboundEmailService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /v4/inbound-email`, but is otherwise the same as + * [InboundEmailService.create]. + */ + @MustBeClosed + fun create(params: InboundEmailCreateParams): HttpResponseFor = + create(params, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + params: InboundEmailCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /v4/inbound-email/{inbound_email_id}`, but is + * otherwise the same as [InboundEmailService.retrieve]. + */ + @MustBeClosed + fun retrieve(inboundEmailId: String): HttpResponseFor = + retrieve(inboundEmailId, InboundEmailRetrieveParams.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + inboundEmailId: String, + params: InboundEmailRetrieveParams = InboundEmailRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieve(params.toBuilder().inboundEmailId(inboundEmailId).build(), requestOptions) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + inboundEmailId: String, + params: InboundEmailRetrieveParams = InboundEmailRetrieveParams.none(), + ): HttpResponseFor = + retrieve(inboundEmailId, params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + params: InboundEmailRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + params: InboundEmailRetrieveParams + ): HttpResponseFor = retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + inboundEmailId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + retrieve(inboundEmailId, InboundEmailRetrieveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /v4/inbound-email`, but is otherwise the same as + * [InboundEmailService.list]. + */ + @MustBeClosed + fun list(): HttpResponseFor = list(InboundEmailListParams.none()) + + /** @see list */ + @MustBeClosed + fun list( + params: InboundEmailListParams = InboundEmailListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see list */ + @MustBeClosed + fun list( + params: InboundEmailListParams = InboundEmailListParams.none() + ): HttpResponseFor = list(params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list(requestOptions: RequestOptions): HttpResponseFor = + list(InboundEmailListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /v4/inbound-email/{inbound_email_id}`, but is + * otherwise the same as [InboundEmailService.delete]. + */ + @MustBeClosed + fun delete(inboundEmailId: String): HttpResponseFor = + delete(inboundEmailId, InboundEmailDeleteParams.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + inboundEmailId: String, + params: InboundEmailDeleteParams = InboundEmailDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + delete(params.toBuilder().inboundEmailId(inboundEmailId).build(), requestOptions) + + /** @see delete */ + @MustBeClosed + fun delete( + inboundEmailId: String, + params: InboundEmailDeleteParams = InboundEmailDeleteParams.none(), + ): HttpResponseFor = + delete(inboundEmailId, params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + params: InboundEmailDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see delete */ + @MustBeClosed + fun delete(params: InboundEmailDeleteParams): HttpResponseFor = + delete(params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + inboundEmailId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + delete(inboundEmailId, InboundEmailDeleteParams.none(), requestOptions) + } +} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/InboundEmailServiceImpl.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/InboundEmailServiceImpl.kt new file mode 100644 index 0000000..b0aefb3 --- /dev/null +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/InboundEmailServiceImpl.kt @@ -0,0 +1,199 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.services.blocking + +import com.cas_parser.api.core.ClientOptions +import com.cas_parser.api.core.RequestOptions +import com.cas_parser.api.core.checkRequired +import com.cas_parser.api.core.handlers.errorBodyHandler +import com.cas_parser.api.core.handlers.errorHandler +import com.cas_parser.api.core.handlers.jsonHandler +import com.cas_parser.api.core.http.HttpMethod +import com.cas_parser.api.core.http.HttpRequest +import com.cas_parser.api.core.http.HttpResponse +import com.cas_parser.api.core.http.HttpResponse.Handler +import com.cas_parser.api.core.http.HttpResponseFor +import com.cas_parser.api.core.http.json +import com.cas_parser.api.core.http.parseable +import com.cas_parser.api.core.prepare +import com.cas_parser.api.models.inboundemail.InboundEmailCreateParams +import com.cas_parser.api.models.inboundemail.InboundEmailCreateResponse +import com.cas_parser.api.models.inboundemail.InboundEmailDeleteParams +import com.cas_parser.api.models.inboundemail.InboundEmailDeleteResponse +import com.cas_parser.api.models.inboundemail.InboundEmailListParams +import com.cas_parser.api.models.inboundemail.InboundEmailListResponse +import com.cas_parser.api.models.inboundemail.InboundEmailRetrieveParams +import com.cas_parser.api.models.inboundemail.InboundEmailRetrieveResponse +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class InboundEmailServiceImpl internal constructor(private val clientOptions: ClientOptions) : + InboundEmailService { + + private val withRawResponse: InboundEmailService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): InboundEmailService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): InboundEmailService = + InboundEmailServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: InboundEmailCreateParams, + requestOptions: RequestOptions, + ): InboundEmailCreateResponse = + // post /v4/inbound-email + withRawResponse().create(params, requestOptions).parse() + + override fun retrieve( + params: InboundEmailRetrieveParams, + requestOptions: RequestOptions, + ): InboundEmailRetrieveResponse = + // get /v4/inbound-email/{inbound_email_id} + withRawResponse().retrieve(params, requestOptions).parse() + + override fun list( + params: InboundEmailListParams, + requestOptions: RequestOptions, + ): InboundEmailListResponse = + // get /v4/inbound-email + withRawResponse().list(params, requestOptions).parse() + + override fun delete( + params: InboundEmailDeleteParams, + requestOptions: RequestOptions, + ): InboundEmailDeleteResponse = + // delete /v4/inbound-email/{inbound_email_id} + withRawResponse().delete(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + InboundEmailService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): InboundEmailService.WithRawResponse = + InboundEmailServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun create( + params: InboundEmailCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v4", "inbound-email") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieve( + params: InboundEmailRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("inboundEmailId", params.inboundEmailId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v4", "inbound-email", params._pathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun list( + params: InboundEmailListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v4", "inbound-email") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val deleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun delete( + params: InboundEmailDeleteParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("inboundEmailId", params.inboundEmailId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v4", "inbound-email", params._pathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/LogService.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/LogService.kt index f95703a..7361743 100644 --- a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/LogService.kt +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/LogService.kt @@ -3,6 +3,13 @@ package com.cas_parser.api.services.blocking import com.cas_parser.api.core.ClientOptions +import com.cas_parser.api.core.RequestOptions +import com.cas_parser.api.core.http.HttpResponseFor +import com.cas_parser.api.models.logs.LogCreateParams +import com.cas_parser.api.models.logs.LogCreateResponse +import com.cas_parser.api.models.logs.LogGetSummaryParams +import com.cas_parser.api.models.logs.LogGetSummaryResponse +import com.google.errorprone.annotations.MustBeClosed import java.util.function.Consumer interface LogService { @@ -19,6 +26,54 @@ interface LogService { */ fun withOptions(modifier: Consumer): LogService + /** + * Retrieve detailed API usage logs for your account. + * + * Returns a list of API calls with timestamps, features used, status codes, and credits + * consumed. Useful for monitoring usage patterns and debugging. + * + * **Legacy path:** `/logs` (still supported) + */ + fun create(): LogCreateResponse = create(LogCreateParams.none()) + + /** @see create */ + fun create( + params: LogCreateParams = LogCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): LogCreateResponse + + /** @see create */ + fun create(params: LogCreateParams = LogCreateParams.none()): LogCreateResponse = + create(params, RequestOptions.none()) + + /** @see create */ + fun create(requestOptions: RequestOptions): LogCreateResponse = + create(LogCreateParams.none(), requestOptions) + + /** + * Get aggregated usage statistics grouped by feature. + * + * Useful for understanding which API features are being used most and tracking usage trends. + * + * **Legacy path:** `/logs/summary` (still supported) + */ + fun getSummary(): LogGetSummaryResponse = getSummary(LogGetSummaryParams.none()) + + /** @see getSummary */ + fun getSummary( + params: LogGetSummaryParams = LogGetSummaryParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): LogGetSummaryResponse + + /** @see getSummary */ + fun getSummary( + params: LogGetSummaryParams = LogGetSummaryParams.none() + ): LogGetSummaryResponse = getSummary(params, RequestOptions.none()) + + /** @see getSummary */ + fun getSummary(requestOptions: RequestOptions): LogGetSummaryResponse = + getSummary(LogGetSummaryParams.none(), requestOptions) + /** A view of [LogService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -28,5 +83,56 @@ interface LogService { * The original service is not modified. */ fun withOptions(modifier: Consumer): LogService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /v1/usage`, but is otherwise the same as + * [LogService.create]. + */ + @MustBeClosed + fun create(): HttpResponseFor = create(LogCreateParams.none()) + + /** @see create */ + @MustBeClosed + fun create( + params: LogCreateParams = LogCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see create */ + @MustBeClosed + fun create( + params: LogCreateParams = LogCreateParams.none() + ): HttpResponseFor = create(params, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create(requestOptions: RequestOptions): HttpResponseFor = + create(LogCreateParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /v1/usage/summary`, but is otherwise the same as + * [LogService.getSummary]. + */ + @MustBeClosed + fun getSummary(): HttpResponseFor = + getSummary(LogGetSummaryParams.none()) + + /** @see getSummary */ + @MustBeClosed + fun getSummary( + params: LogGetSummaryParams = LogGetSummaryParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see getSummary */ + @MustBeClosed + fun getSummary( + params: LogGetSummaryParams = LogGetSummaryParams.none() + ): HttpResponseFor = getSummary(params, RequestOptions.none()) + + /** @see getSummary */ + @MustBeClosed + fun getSummary(requestOptions: RequestOptions): HttpResponseFor = + getSummary(LogGetSummaryParams.none(), requestOptions) } } diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/LogServiceImpl.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/LogServiceImpl.kt index 0a82263..4dce634 100644 --- a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/LogServiceImpl.kt +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/LogServiceImpl.kt @@ -3,6 +3,22 @@ package com.cas_parser.api.services.blocking import com.cas_parser.api.core.ClientOptions +import com.cas_parser.api.core.RequestOptions +import com.cas_parser.api.core.handlers.errorBodyHandler +import com.cas_parser.api.core.handlers.errorHandler +import com.cas_parser.api.core.handlers.jsonHandler +import com.cas_parser.api.core.http.HttpMethod +import com.cas_parser.api.core.http.HttpRequest +import com.cas_parser.api.core.http.HttpResponse +import com.cas_parser.api.core.http.HttpResponse.Handler +import com.cas_parser.api.core.http.HttpResponseFor +import com.cas_parser.api.core.http.json +import com.cas_parser.api.core.http.parseable +import com.cas_parser.api.core.prepare +import com.cas_parser.api.models.logs.LogCreateParams +import com.cas_parser.api.models.logs.LogCreateResponse +import com.cas_parser.api.models.logs.LogGetSummaryParams +import com.cas_parser.api.models.logs.LogGetSummaryResponse import java.util.function.Consumer class LogServiceImpl internal constructor(private val clientOptions: ClientOptions) : LogService { @@ -16,14 +32,87 @@ class LogServiceImpl internal constructor(private val clientOptions: ClientOptio override fun withOptions(modifier: Consumer): LogService = LogServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create( + params: LogCreateParams, + requestOptions: RequestOptions, + ): LogCreateResponse = + // post /v1/usage + withRawResponse().create(params, requestOptions).parse() + + override fun getSummary( + params: LogGetSummaryParams, + requestOptions: RequestOptions, + ): LogGetSummaryResponse = + // post /v1/usage/summary + withRawResponse().getSummary(params, requestOptions).parse() + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : LogService.WithRawResponse { + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + override fun withOptions( modifier: Consumer ): LogService.WithRawResponse = LogServiceImpl.WithRawResponseImpl( clientOptions.toBuilder().apply(modifier::accept).build() ) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun create( + params: LogCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "usage") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val getSummaryHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun getSummary( + params: LogGetSummaryParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "usage", "summary") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { getSummaryHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } } diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/VerifyTokenService.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/VerifyTokenService.kt index a44e1df..e8135cd 100644 --- a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/VerifyTokenService.kt +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/VerifyTokenService.kt @@ -3,6 +3,11 @@ package com.cas_parser.api.services.blocking import com.cas_parser.api.core.ClientOptions +import com.cas_parser.api.core.RequestOptions +import com.cas_parser.api.core.http.HttpResponseFor +import com.cas_parser.api.models.verifytoken.VerifyTokenVerifyParams +import com.cas_parser.api.models.verifytoken.VerifyTokenVerifyResponse +import com.google.errorprone.annotations.MustBeClosed import java.util.function.Consumer interface VerifyTokenService { @@ -19,6 +24,24 @@ interface VerifyTokenService { */ fun withOptions(modifier: Consumer): VerifyTokenService + /** Verify an access token and check if it's still valid. Useful for debugging token issues. */ + fun verify(): VerifyTokenVerifyResponse = verify(VerifyTokenVerifyParams.none()) + + /** @see verify */ + fun verify( + params: VerifyTokenVerifyParams = VerifyTokenVerifyParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): VerifyTokenVerifyResponse + + /** @see verify */ + fun verify( + params: VerifyTokenVerifyParams = VerifyTokenVerifyParams.none() + ): VerifyTokenVerifyResponse = verify(params, RequestOptions.none()) + + /** @see verify */ + fun verify(requestOptions: RequestOptions): VerifyTokenVerifyResponse = + verify(VerifyTokenVerifyParams.none(), requestOptions) + /** * A view of [VerifyTokenService] that provides access to raw HTTP responses for each method. */ @@ -32,5 +55,31 @@ interface VerifyTokenService { fun withOptions( modifier: Consumer ): VerifyTokenService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /v1/token/verify`, but is otherwise the same as + * [VerifyTokenService.verify]. + */ + @MustBeClosed + fun verify(): HttpResponseFor = + verify(VerifyTokenVerifyParams.none()) + + /** @see verify */ + @MustBeClosed + fun verify( + params: VerifyTokenVerifyParams = VerifyTokenVerifyParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see verify */ + @MustBeClosed + fun verify( + params: VerifyTokenVerifyParams = VerifyTokenVerifyParams.none() + ): HttpResponseFor = verify(params, RequestOptions.none()) + + /** @see verify */ + @MustBeClosed + fun verify(requestOptions: RequestOptions): HttpResponseFor = + verify(VerifyTokenVerifyParams.none(), requestOptions) } } diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/VerifyTokenServiceImpl.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/VerifyTokenServiceImpl.kt index e202bbc..bf3fce7 100644 --- a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/VerifyTokenServiceImpl.kt +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/VerifyTokenServiceImpl.kt @@ -3,6 +3,20 @@ package com.cas_parser.api.services.blocking import com.cas_parser.api.core.ClientOptions +import com.cas_parser.api.core.RequestOptions +import com.cas_parser.api.core.handlers.errorBodyHandler +import com.cas_parser.api.core.handlers.errorHandler +import com.cas_parser.api.core.handlers.jsonHandler +import com.cas_parser.api.core.http.HttpMethod +import com.cas_parser.api.core.http.HttpRequest +import com.cas_parser.api.core.http.HttpResponse +import com.cas_parser.api.core.http.HttpResponse.Handler +import com.cas_parser.api.core.http.HttpResponseFor +import com.cas_parser.api.core.http.json +import com.cas_parser.api.core.http.parseable +import com.cas_parser.api.core.prepare +import com.cas_parser.api.models.verifytoken.VerifyTokenVerifyParams +import com.cas_parser.api.models.verifytoken.VerifyTokenVerifyResponse import java.util.function.Consumer class VerifyTokenServiceImpl internal constructor(private val clientOptions: ClientOptions) : @@ -17,14 +31,52 @@ class VerifyTokenServiceImpl internal constructor(private val clientOptions: Cli override fun withOptions(modifier: Consumer): VerifyTokenService = VerifyTokenServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun verify( + params: VerifyTokenVerifyParams, + requestOptions: RequestOptions, + ): VerifyTokenVerifyResponse = + // post /v1/token/verify + withRawResponse().verify(params, requestOptions).parse() + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : VerifyTokenService.WithRawResponse { + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + override fun withOptions( modifier: Consumer ): VerifyTokenService.WithRawResponse = VerifyTokenServiceImpl.WithRawResponseImpl( clientOptions.toBuilder().apply(modifier::accept).build() ) + + private val verifyHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun verify( + params: VerifyTokenVerifyParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "token", "verify") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { verifyHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } } diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/accesstoken/AccessTokenCreateParamsTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/accesstoken/AccessTokenCreateParamsTest.kt new file mode 100644 index 0000000..a6a696b --- /dev/null +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/accesstoken/AccessTokenCreateParamsTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.models.accesstoken + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class AccessTokenCreateParamsTest { + + @Test + fun create() { + AccessTokenCreateParams.builder().expiryMinutes(60L).build() + } + + @Test + fun body() { + val params = AccessTokenCreateParams.builder().expiryMinutes(60L).build() + + val body = params._body() + + assertThat(body.expiryMinutes()).contains(60L) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = AccessTokenCreateParams.builder().build() + + val body = params._body() + } +} diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/accesstoken/AccessTokenCreateResponseTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/accesstoken/AccessTokenCreateResponseTest.kt new file mode 100644 index 0000000..09382b7 --- /dev/null +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/accesstoken/AccessTokenCreateResponseTest.kt @@ -0,0 +1,45 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.models.accesstoken + +import com.cas_parser.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class AccessTokenCreateResponseTest { + + @Test + fun create() { + val accessTokenCreateResponse = + AccessTokenCreateResponse.builder() + .accessToken("at_eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...") + .expiresIn(3600L) + .tokenType("api_key") + .build() + + assertThat(accessTokenCreateResponse.accessToken()) + .contains("at_eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...") + assertThat(accessTokenCreateResponse.expiresIn()).contains(3600L) + assertThat(accessTokenCreateResponse.tokenType()).contains("api_key") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val accessTokenCreateResponse = + AccessTokenCreateResponse.builder() + .accessToken("at_eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...") + .expiresIn(3600L) + .tokenType("api_key") + .build() + + val roundtrippedAccessTokenCreateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(accessTokenCreateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedAccessTokenCreateResponse).isEqualTo(accessTokenCreateResponse) + } +} diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/credits/CreditCheckParamsTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/credits/CreditCheckParamsTest.kt new file mode 100644 index 0000000..b26664b --- /dev/null +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/credits/CreditCheckParamsTest.kt @@ -0,0 +1,13 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.models.credits + +import org.junit.jupiter.api.Test + +internal class CreditCheckParamsTest { + + @Test + fun create() { + CreditCheckParams.builder().build() + } +} diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/credits/CreditCheckResponseTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/credits/CreditCheckResponseTest.kt new file mode 100644 index 0000000..17d52f9 --- /dev/null +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/credits/CreditCheckResponseTest.kt @@ -0,0 +1,61 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.models.credits + +import com.cas_parser.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.time.OffsetDateTime +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CreditCheckResponseTest { + + @Test + fun create() { + val creditCheckResponse = + CreditCheckResponse.builder() + .enabledFeatures( + listOf("cams_kfintech_cas_parser", "cdsl_cas_parser", "nsdl_cas_parser") + ) + .isUnlimited(false) + .limit(50L) + .remaining(35.0) + .resetsAt(OffsetDateTime.parse("2026-02-15T00:00:00Z")) + .used(15.0) + .build() + + assertThat(creditCheckResponse.enabledFeatures().getOrNull()) + .containsExactly("cams_kfintech_cas_parser", "cdsl_cas_parser", "nsdl_cas_parser") + assertThat(creditCheckResponse.isUnlimited()).contains(false) + assertThat(creditCheckResponse.limit()).contains(50L) + assertThat(creditCheckResponse.remaining()).contains(35.0) + assertThat(creditCheckResponse.resetsAt()) + .contains(OffsetDateTime.parse("2026-02-15T00:00:00Z")) + assertThat(creditCheckResponse.used()).contains(15.0) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val creditCheckResponse = + CreditCheckResponse.builder() + .enabledFeatures( + listOf("cams_kfintech_cas_parser", "cdsl_cas_parser", "nsdl_cas_parser") + ) + .isUnlimited(false) + .limit(50L) + .remaining(35.0) + .resetsAt(OffsetDateTime.parse("2026-02-15T00:00:00Z")) + .used(15.0) + .build() + + val roundtrippedCreditCheckResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(creditCheckResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCreditCheckResponse).isEqualTo(creditCheckResponse) + } +} diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/inboundemail/InboundEmailCreateParamsTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/inboundemail/InboundEmailCreateParamsTest.kt new file mode 100644 index 0000000..900b778 --- /dev/null +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/inboundemail/InboundEmailCreateParamsTest.kt @@ -0,0 +1,76 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.models.inboundemail + +import com.cas_parser.api.core.JsonValue +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class InboundEmailCreateParamsTest { + + @Test + fun create() { + InboundEmailCreateParams.builder() + .callbackUrl("https://api.yourapp.com/webhooks/cas-email") + .alias("john-portfolio") + .addAllowedSource(InboundEmailCreateParams.AllowedSource.CDSL) + .addAllowedSource(InboundEmailCreateParams.AllowedSource.NSDL) + .metadata( + InboundEmailCreateParams.Metadata.builder() + .putAdditionalProperty("plan", JsonValue.from("premium")) + .putAdditionalProperty("source", JsonValue.from("onboarding")) + .build() + ) + .reference("user_12345") + .build() + } + + @Test + fun body() { + val params = + InboundEmailCreateParams.builder() + .callbackUrl("https://api.yourapp.com/webhooks/cas-email") + .alias("john-portfolio") + .addAllowedSource(InboundEmailCreateParams.AllowedSource.CDSL) + .addAllowedSource(InboundEmailCreateParams.AllowedSource.NSDL) + .metadata( + InboundEmailCreateParams.Metadata.builder() + .putAdditionalProperty("plan", JsonValue.from("premium")) + .putAdditionalProperty("source", JsonValue.from("onboarding")) + .build() + ) + .reference("user_12345") + .build() + + val body = params._body() + + assertThat(body.callbackUrl()).isEqualTo("https://api.yourapp.com/webhooks/cas-email") + assertThat(body.alias()).contains("john-portfolio") + assertThat(body.allowedSources().getOrNull()) + .containsExactly( + InboundEmailCreateParams.AllowedSource.CDSL, + InboundEmailCreateParams.AllowedSource.NSDL, + ) + assertThat(body.metadata()) + .contains( + InboundEmailCreateParams.Metadata.builder() + .putAdditionalProperty("plan", JsonValue.from("premium")) + .putAdditionalProperty("source", JsonValue.from("onboarding")) + .build() + ) + assertThat(body.reference()).contains("user_12345") + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + InboundEmailCreateParams.builder() + .callbackUrl("https://api.yourapp.com/webhooks/cas-email") + .build() + + val body = params._body() + + assertThat(body.callbackUrl()).isEqualTo("https://api.yourapp.com/webhooks/cas-email") + } +} diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/inboundemail/InboundEmailCreateResponseTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/inboundemail/InboundEmailCreateResponseTest.kt new file mode 100644 index 0000000..1fbdbd1 --- /dev/null +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/inboundemail/InboundEmailCreateResponseTest.kt @@ -0,0 +1,89 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.models.inboundemail + +import com.cas_parser.api.core.JsonValue +import com.cas_parser.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.time.OffsetDateTime +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class InboundEmailCreateResponseTest { + + @Test + fun create() { + val inboundEmailCreateResponse = + InboundEmailCreateResponse.builder() + .addAllowedSource(InboundEmailCreateResponse.AllowedSource.CDSL) + .addAllowedSource(InboundEmailCreateResponse.AllowedSource.NSDL) + .callbackUrl("https://api.yourapp.com/webhooks/cas-email") + .createdAt(OffsetDateTime.parse("2025-02-21T10:30:00Z")) + .email("ie_a1b2c3d4e5f6@import.casparser.in") + .inboundEmailId("ie_a1b2c3d4e5f6") + .metadata( + InboundEmailCreateResponse.Metadata.builder() + .putAdditionalProperty("plan", JsonValue.from("premium")) + .build() + ) + .reference("user_12345") + .status(InboundEmailCreateResponse.Status.ACTIVE) + .updatedAt(OffsetDateTime.parse("2025-02-21T10:30:00Z")) + .build() + + assertThat(inboundEmailCreateResponse.allowedSources().getOrNull()) + .containsExactly( + InboundEmailCreateResponse.AllowedSource.CDSL, + InboundEmailCreateResponse.AllowedSource.NSDL, + ) + assertThat(inboundEmailCreateResponse.callbackUrl()) + .contains("https://api.yourapp.com/webhooks/cas-email") + assertThat(inboundEmailCreateResponse.createdAt()) + .contains(OffsetDateTime.parse("2025-02-21T10:30:00Z")) + assertThat(inboundEmailCreateResponse.email()) + .contains("ie_a1b2c3d4e5f6@import.casparser.in") + assertThat(inboundEmailCreateResponse.inboundEmailId()).contains("ie_a1b2c3d4e5f6") + assertThat(inboundEmailCreateResponse.metadata()) + .contains( + InboundEmailCreateResponse.Metadata.builder() + .putAdditionalProperty("plan", JsonValue.from("premium")) + .build() + ) + assertThat(inboundEmailCreateResponse.reference()).contains("user_12345") + assertThat(inboundEmailCreateResponse.status()) + .contains(InboundEmailCreateResponse.Status.ACTIVE) + assertThat(inboundEmailCreateResponse.updatedAt()) + .contains(OffsetDateTime.parse("2025-02-21T10:30:00Z")) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val inboundEmailCreateResponse = + InboundEmailCreateResponse.builder() + .addAllowedSource(InboundEmailCreateResponse.AllowedSource.CDSL) + .addAllowedSource(InboundEmailCreateResponse.AllowedSource.NSDL) + .callbackUrl("https://api.yourapp.com/webhooks/cas-email") + .createdAt(OffsetDateTime.parse("2025-02-21T10:30:00Z")) + .email("ie_a1b2c3d4e5f6@import.casparser.in") + .inboundEmailId("ie_a1b2c3d4e5f6") + .metadata( + InboundEmailCreateResponse.Metadata.builder() + .putAdditionalProperty("plan", JsonValue.from("premium")) + .build() + ) + .reference("user_12345") + .status(InboundEmailCreateResponse.Status.ACTIVE) + .updatedAt(OffsetDateTime.parse("2025-02-21T10:30:00Z")) + .build() + + val roundtrippedInboundEmailCreateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(inboundEmailCreateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedInboundEmailCreateResponse).isEqualTo(inboundEmailCreateResponse) + } +} diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/inboundemail/InboundEmailDeleteParamsTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/inboundemail/InboundEmailDeleteParamsTest.kt new file mode 100644 index 0000000..917b4ee --- /dev/null +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/inboundemail/InboundEmailDeleteParamsTest.kt @@ -0,0 +1,23 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.models.inboundemail + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class InboundEmailDeleteParamsTest { + + @Test + fun create() { + InboundEmailDeleteParams.builder().inboundEmailId("inbound_email_id").build() + } + + @Test + fun pathParams() { + val params = InboundEmailDeleteParams.builder().inboundEmailId("inbound_email_id").build() + + assertThat(params._pathParam(0)).isEqualTo("inbound_email_id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/inboundemail/InboundEmailDeleteResponseTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/inboundemail/InboundEmailDeleteResponseTest.kt new file mode 100644 index 0000000..0c8f6fe --- /dev/null +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/inboundemail/InboundEmailDeleteResponseTest.kt @@ -0,0 +1,41 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.models.inboundemail + +import com.cas_parser.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class InboundEmailDeleteResponseTest { + + @Test + fun create() { + val inboundEmailDeleteResponse = + InboundEmailDeleteResponse.builder() + .msg("Mailbox deleted successfully") + .status("success") + .build() + + assertThat(inboundEmailDeleteResponse.msg()).contains("Mailbox deleted successfully") + assertThat(inboundEmailDeleteResponse.status()).contains("success") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val inboundEmailDeleteResponse = + InboundEmailDeleteResponse.builder() + .msg("Mailbox deleted successfully") + .status("success") + .build() + + val roundtrippedInboundEmailDeleteResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(inboundEmailDeleteResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedInboundEmailDeleteResponse).isEqualTo(inboundEmailDeleteResponse) + } +} diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/inboundemail/InboundEmailListParamsTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/inboundemail/InboundEmailListParamsTest.kt new file mode 100644 index 0000000..b0dfb9d --- /dev/null +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/inboundemail/InboundEmailListParamsTest.kt @@ -0,0 +1,49 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.models.inboundemail + +import com.cas_parser.api.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class InboundEmailListParamsTest { + + @Test + fun create() { + InboundEmailListParams.builder() + .limit(1L) + .offset(0L) + .status(InboundEmailListParams.Status.ACTIVE) + .build() + } + + @Test + fun queryParams() { + val params = + InboundEmailListParams.builder() + .limit(1L) + .offset(0L) + .status(InboundEmailListParams.Status.ACTIVE) + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("limit", "1") + .put("offset", "0") + .put("status", "active") + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = InboundEmailListParams.builder().build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/inboundemail/InboundEmailListResponseTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/inboundemail/InboundEmailListResponseTest.kt new file mode 100644 index 0000000..ff243b8 --- /dev/null +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/inboundemail/InboundEmailListResponseTest.kt @@ -0,0 +1,105 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.models.inboundemail + +import com.cas_parser.api.core.JsonValue +import com.cas_parser.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.time.OffsetDateTime +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class InboundEmailListResponseTest { + + @Test + fun create() { + val inboundEmailListResponse = + InboundEmailListResponse.builder() + .addInboundEmail( + InboundEmailListResponse.InboundEmail.builder() + .addAllowedSource(InboundEmailListResponse.InboundEmail.AllowedSource.CDSL) + .addAllowedSource(InboundEmailListResponse.InboundEmail.AllowedSource.NSDL) + .callbackUrl("https://api.yourapp.com/webhooks/cas-email") + .createdAt(OffsetDateTime.parse("2025-02-21T10:30:00Z")) + .email("ie_a1b2c3d4e5f6@import.casparser.in") + .inboundEmailId("ie_a1b2c3d4e5f6") + .metadata( + InboundEmailListResponse.InboundEmail.Metadata.builder() + .putAdditionalProperty("plan", JsonValue.from("premium")) + .build() + ) + .reference("user_12345") + .status(InboundEmailListResponse.InboundEmail.Status.ACTIVE) + .updatedAt(OffsetDateTime.parse("2025-02-21T10:30:00Z")) + .build() + ) + .limit(50L) + .offset(0L) + .status("success") + .total(15L) + .build() + + assertThat(inboundEmailListResponse.inboundEmails().getOrNull()) + .containsExactly( + InboundEmailListResponse.InboundEmail.builder() + .addAllowedSource(InboundEmailListResponse.InboundEmail.AllowedSource.CDSL) + .addAllowedSource(InboundEmailListResponse.InboundEmail.AllowedSource.NSDL) + .callbackUrl("https://api.yourapp.com/webhooks/cas-email") + .createdAt(OffsetDateTime.parse("2025-02-21T10:30:00Z")) + .email("ie_a1b2c3d4e5f6@import.casparser.in") + .inboundEmailId("ie_a1b2c3d4e5f6") + .metadata( + InboundEmailListResponse.InboundEmail.Metadata.builder() + .putAdditionalProperty("plan", JsonValue.from("premium")) + .build() + ) + .reference("user_12345") + .status(InboundEmailListResponse.InboundEmail.Status.ACTIVE) + .updatedAt(OffsetDateTime.parse("2025-02-21T10:30:00Z")) + .build() + ) + assertThat(inboundEmailListResponse.limit()).contains(50L) + assertThat(inboundEmailListResponse.offset()).contains(0L) + assertThat(inboundEmailListResponse.status()).contains("success") + assertThat(inboundEmailListResponse.total()).contains(15L) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val inboundEmailListResponse = + InboundEmailListResponse.builder() + .addInboundEmail( + InboundEmailListResponse.InboundEmail.builder() + .addAllowedSource(InboundEmailListResponse.InboundEmail.AllowedSource.CDSL) + .addAllowedSource(InboundEmailListResponse.InboundEmail.AllowedSource.NSDL) + .callbackUrl("https://api.yourapp.com/webhooks/cas-email") + .createdAt(OffsetDateTime.parse("2025-02-21T10:30:00Z")) + .email("ie_a1b2c3d4e5f6@import.casparser.in") + .inboundEmailId("ie_a1b2c3d4e5f6") + .metadata( + InboundEmailListResponse.InboundEmail.Metadata.builder() + .putAdditionalProperty("plan", JsonValue.from("premium")) + .build() + ) + .reference("user_12345") + .status(InboundEmailListResponse.InboundEmail.Status.ACTIVE) + .updatedAt(OffsetDateTime.parse("2025-02-21T10:30:00Z")) + .build() + ) + .limit(50L) + .offset(0L) + .status("success") + .total(15L) + .build() + + val roundtrippedInboundEmailListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(inboundEmailListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedInboundEmailListResponse).isEqualTo(inboundEmailListResponse) + } +} diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/inboundemail/InboundEmailRetrieveParamsTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/inboundemail/InboundEmailRetrieveParamsTest.kt new file mode 100644 index 0000000..2b76fc3 --- /dev/null +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/inboundemail/InboundEmailRetrieveParamsTest.kt @@ -0,0 +1,23 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.models.inboundemail + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class InboundEmailRetrieveParamsTest { + + @Test + fun create() { + InboundEmailRetrieveParams.builder().inboundEmailId("ie_a1b2c3d4e5f6").build() + } + + @Test + fun pathParams() { + val params = InboundEmailRetrieveParams.builder().inboundEmailId("ie_a1b2c3d4e5f6").build() + + assertThat(params._pathParam(0)).isEqualTo("ie_a1b2c3d4e5f6") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/inboundemail/InboundEmailRetrieveResponseTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/inboundemail/InboundEmailRetrieveResponseTest.kt new file mode 100644 index 0000000..c6e9872 --- /dev/null +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/inboundemail/InboundEmailRetrieveResponseTest.kt @@ -0,0 +1,89 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.models.inboundemail + +import com.cas_parser.api.core.JsonValue +import com.cas_parser.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.time.OffsetDateTime +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class InboundEmailRetrieveResponseTest { + + @Test + fun create() { + val inboundEmailRetrieveResponse = + InboundEmailRetrieveResponse.builder() + .addAllowedSource(InboundEmailRetrieveResponse.AllowedSource.CDSL) + .addAllowedSource(InboundEmailRetrieveResponse.AllowedSource.NSDL) + .callbackUrl("https://api.yourapp.com/webhooks/cas-email") + .createdAt(OffsetDateTime.parse("2025-02-21T10:30:00Z")) + .email("ie_a1b2c3d4e5f6@import.casparser.in") + .inboundEmailId("ie_a1b2c3d4e5f6") + .metadata( + InboundEmailRetrieveResponse.Metadata.builder() + .putAdditionalProperty("plan", JsonValue.from("premium")) + .build() + ) + .reference("user_12345") + .status(InboundEmailRetrieveResponse.Status.ACTIVE) + .updatedAt(OffsetDateTime.parse("2025-02-21T10:30:00Z")) + .build() + + assertThat(inboundEmailRetrieveResponse.allowedSources().getOrNull()) + .containsExactly( + InboundEmailRetrieveResponse.AllowedSource.CDSL, + InboundEmailRetrieveResponse.AllowedSource.NSDL, + ) + assertThat(inboundEmailRetrieveResponse.callbackUrl()) + .contains("https://api.yourapp.com/webhooks/cas-email") + assertThat(inboundEmailRetrieveResponse.createdAt()) + .contains(OffsetDateTime.parse("2025-02-21T10:30:00Z")) + assertThat(inboundEmailRetrieveResponse.email()) + .contains("ie_a1b2c3d4e5f6@import.casparser.in") + assertThat(inboundEmailRetrieveResponse.inboundEmailId()).contains("ie_a1b2c3d4e5f6") + assertThat(inboundEmailRetrieveResponse.metadata()) + .contains( + InboundEmailRetrieveResponse.Metadata.builder() + .putAdditionalProperty("plan", JsonValue.from("premium")) + .build() + ) + assertThat(inboundEmailRetrieveResponse.reference()).contains("user_12345") + assertThat(inboundEmailRetrieveResponse.status()) + .contains(InboundEmailRetrieveResponse.Status.ACTIVE) + assertThat(inboundEmailRetrieveResponse.updatedAt()) + .contains(OffsetDateTime.parse("2025-02-21T10:30:00Z")) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val inboundEmailRetrieveResponse = + InboundEmailRetrieveResponse.builder() + .addAllowedSource(InboundEmailRetrieveResponse.AllowedSource.CDSL) + .addAllowedSource(InboundEmailRetrieveResponse.AllowedSource.NSDL) + .callbackUrl("https://api.yourapp.com/webhooks/cas-email") + .createdAt(OffsetDateTime.parse("2025-02-21T10:30:00Z")) + .email("ie_a1b2c3d4e5f6@import.casparser.in") + .inboundEmailId("ie_a1b2c3d4e5f6") + .metadata( + InboundEmailRetrieveResponse.Metadata.builder() + .putAdditionalProperty("plan", JsonValue.from("premium")) + .build() + ) + .reference("user_12345") + .status(InboundEmailRetrieveResponse.Status.ACTIVE) + .updatedAt(OffsetDateTime.parse("2025-02-21T10:30:00Z")) + .build() + + val roundtrippedInboundEmailRetrieveResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(inboundEmailRetrieveResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedInboundEmailRetrieveResponse).isEqualTo(inboundEmailRetrieveResponse) + } +} diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/logs/LogCreateParamsTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/logs/LogCreateParamsTest.kt new file mode 100644 index 0000000..e7212ba --- /dev/null +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/logs/LogCreateParamsTest.kt @@ -0,0 +1,42 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.models.logs + +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class LogCreateParamsTest { + + @Test + fun create() { + LogCreateParams.builder() + .endTime(OffsetDateTime.parse("2026-01-31T23:59:59Z")) + .limit(1L) + .startTime(OffsetDateTime.parse("2026-01-01T00:00:00Z")) + .build() + } + + @Test + fun body() { + val params = + LogCreateParams.builder() + .endTime(OffsetDateTime.parse("2026-01-31T23:59:59Z")) + .limit(1L) + .startTime(OffsetDateTime.parse("2026-01-01T00:00:00Z")) + .build() + + val body = params._body() + + assertThat(body.endTime()).contains(OffsetDateTime.parse("2026-01-31T23:59:59Z")) + assertThat(body.limit()).contains(1L) + assertThat(body.startTime()).contains(OffsetDateTime.parse("2026-01-01T00:00:00Z")) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = LogCreateParams.builder().build() + + val body = params._body() + } +} diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/logs/LogCreateResponseTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/logs/LogCreateResponseTest.kt new file mode 100644 index 0000000..0f24a21 --- /dev/null +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/logs/LogCreateResponseTest.kt @@ -0,0 +1,74 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.models.logs + +import com.cas_parser.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.time.OffsetDateTime +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class LogCreateResponseTest { + + @Test + fun create() { + val logCreateResponse = + LogCreateResponse.builder() + .count(25L) + .addLog( + LogCreateResponse.Log.builder() + .credits(1.0) + .feature("cdsl_cas_parser") + .path("/v4/cdsl/parse") + .requestId("req_2xYz7KpL8mN3Ab") + .statusCode(200L) + .timestamp(OffsetDateTime.parse("2026-01-15T14:30:00Z")) + .build() + ) + .status("success") + .build() + + assertThat(logCreateResponse.count()).contains(25L) + assertThat(logCreateResponse.logs().getOrNull()) + .containsExactly( + LogCreateResponse.Log.builder() + .credits(1.0) + .feature("cdsl_cas_parser") + .path("/v4/cdsl/parse") + .requestId("req_2xYz7KpL8mN3Ab") + .statusCode(200L) + .timestamp(OffsetDateTime.parse("2026-01-15T14:30:00Z")) + .build() + ) + assertThat(logCreateResponse.status()).contains("success") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val logCreateResponse = + LogCreateResponse.builder() + .count(25L) + .addLog( + LogCreateResponse.Log.builder() + .credits(1.0) + .feature("cdsl_cas_parser") + .path("/v4/cdsl/parse") + .requestId("req_2xYz7KpL8mN3Ab") + .statusCode(200L) + .timestamp(OffsetDateTime.parse("2026-01-15T14:30:00Z")) + .build() + ) + .status("success") + .build() + + val roundtrippedLogCreateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(logCreateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedLogCreateResponse).isEqualTo(logCreateResponse) + } +} diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/logs/LogGetSummaryParamsTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/logs/LogGetSummaryParamsTest.kt new file mode 100644 index 0000000..a2cfd4a --- /dev/null +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/logs/LogGetSummaryParamsTest.kt @@ -0,0 +1,39 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.models.logs + +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class LogGetSummaryParamsTest { + + @Test + fun create() { + LogGetSummaryParams.builder() + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + } + + @Test + fun body() { + val params = + LogGetSummaryParams.builder() + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + val body = params._body() + + assertThat(body.endTime()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(body.startTime()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = LogGetSummaryParams.builder().build() + + val body = params._body() + } +} diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/logs/LogGetSummaryResponseTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/logs/LogGetSummaryResponseTest.kt new file mode 100644 index 0000000..94e8bc7 --- /dev/null +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/logs/LogGetSummaryResponseTest.kt @@ -0,0 +1,78 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.models.logs + +import com.cas_parser.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class LogGetSummaryResponseTest { + + @Test + fun create() { + val logGetSummaryResponse = + LogGetSummaryResponse.builder() + .status("success") + .summary( + LogGetSummaryResponse.Summary.builder() + .addByFeature( + LogGetSummaryResponse.Summary.ByFeature.builder() + .credits(15.0) + .feature("cdsl_cas_parser") + .requests(15L) + .build() + ) + .totalCredits(45.5) + .totalRequests(42L) + .build() + ) + .build() + + assertThat(logGetSummaryResponse.status()).contains("success") + assertThat(logGetSummaryResponse.summary()) + .contains( + LogGetSummaryResponse.Summary.builder() + .addByFeature( + LogGetSummaryResponse.Summary.ByFeature.builder() + .credits(15.0) + .feature("cdsl_cas_parser") + .requests(15L) + .build() + ) + .totalCredits(45.5) + .totalRequests(42L) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val logGetSummaryResponse = + LogGetSummaryResponse.builder() + .status("success") + .summary( + LogGetSummaryResponse.Summary.builder() + .addByFeature( + LogGetSummaryResponse.Summary.ByFeature.builder() + .credits(15.0) + .feature("cdsl_cas_parser") + .requests(15L) + .build() + ) + .totalCredits(45.5) + .totalRequests(42L) + .build() + ) + .build() + + val roundtrippedLogGetSummaryResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(logGetSummaryResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedLogGetSummaryResponse).isEqualTo(logGetSummaryResponse) + } +} diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/verifytoken/VerifyTokenVerifyParamsTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/verifytoken/VerifyTokenVerifyParamsTest.kt new file mode 100644 index 0000000..6e75d40 --- /dev/null +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/verifytoken/VerifyTokenVerifyParamsTest.kt @@ -0,0 +1,13 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.models.verifytoken + +import org.junit.jupiter.api.Test + +internal class VerifyTokenVerifyParamsTest { + + @Test + fun create() { + VerifyTokenVerifyParams.builder().build() + } +} diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/verifytoken/VerifyTokenVerifyResponseTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/verifytoken/VerifyTokenVerifyResponseTest.kt new file mode 100644 index 0000000..813bc45 --- /dev/null +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/verifytoken/VerifyTokenVerifyResponseTest.kt @@ -0,0 +1,44 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.models.verifytoken + +import com.cas_parser.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class VerifyTokenVerifyResponseTest { + + @Test + fun create() { + val verifyTokenVerifyResponse = + VerifyTokenVerifyResponse.builder() + .error("Token has expired") + .maskedApiKey("abc1****ef23") + .valid(true) + .build() + + assertThat(verifyTokenVerifyResponse.error()).contains("Token has expired") + assertThat(verifyTokenVerifyResponse.maskedApiKey()).contains("abc1****ef23") + assertThat(verifyTokenVerifyResponse.valid()).contains(true) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val verifyTokenVerifyResponse = + VerifyTokenVerifyResponse.builder() + .error("Token has expired") + .maskedApiKey("abc1****ef23") + .valid(true) + .build() + + val roundtrippedVerifyTokenVerifyResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(verifyTokenVerifyResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedVerifyTokenVerifyResponse).isEqualTo(verifyTokenVerifyResponse) + } +} diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/ErrorHandlingTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/ErrorHandlingTest.kt index 0cce742..f58190a 100644 --- a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/ErrorHandlingTest.kt +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/ErrorHandlingTest.kt @@ -16,7 +16,6 @@ import com.cas_parser.api.errors.RateLimitException import com.cas_parser.api.errors.UnauthorizedException import com.cas_parser.api.errors.UnexpectedStatusCodeException import com.cas_parser.api.errors.UnprocessableEntityException -import com.cas_parser.api.models.camskfintech.CamsKfintechParseParams import com.github.tomakehurst.wiremock.client.WireMock.anyUrl import com.github.tomakehurst.wiremock.client.WireMock.post import com.github.tomakehurst.wiremock.client.WireMock.status @@ -59,8 +58,8 @@ internal class ErrorHandlingTest { } @Test - fun camsKfintechParse400() { - val camsKfintechService = client.camsKfintech() + fun creditsCheck400() { + val creditService = client.credits() stubFor( post(anyUrl()) .willReturn( @@ -68,16 +67,7 @@ internal class ErrorHandlingTest { ) ) - val e = - assertThrows { - camsKfintechService.parse( - CamsKfintechParseParams.builder() - .password("password") - .pdfFile("pdf_file") - .pdfUrl("https://example.com") - .build() - ) - } + val e = assertThrows { creditService.check() } assertThat(e.statusCode()).isEqualTo(400) assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) @@ -85,8 +75,8 @@ internal class ErrorHandlingTest { } @Test - fun camsKfintechParse400WithRawResponse() { - val camsKfintechService = client.camsKfintech().withRawResponse() + fun creditsCheck400WithRawResponse() { + val creditService = client.credits().withRawResponse() stubFor( post(anyUrl()) .willReturn( @@ -94,16 +84,7 @@ internal class ErrorHandlingTest { ) ) - val e = - assertThrows { - camsKfintechService.parse( - CamsKfintechParseParams.builder() - .password("password") - .pdfFile("pdf_file") - .pdfUrl("https://example.com") - .build() - ) - } + val e = assertThrows { creditService.check() } assertThat(e.statusCode()).isEqualTo(400) assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) @@ -111,8 +92,8 @@ internal class ErrorHandlingTest { } @Test - fun camsKfintechParse401() { - val camsKfintechService = client.camsKfintech() + fun creditsCheck401() { + val creditService = client.credits() stubFor( post(anyUrl()) .willReturn( @@ -120,16 +101,7 @@ internal class ErrorHandlingTest { ) ) - val e = - assertThrows { - camsKfintechService.parse( - CamsKfintechParseParams.builder() - .password("password") - .pdfFile("pdf_file") - .pdfUrl("https://example.com") - .build() - ) - } + val e = assertThrows { creditService.check() } assertThat(e.statusCode()).isEqualTo(401) assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) @@ -137,8 +109,8 @@ internal class ErrorHandlingTest { } @Test - fun camsKfintechParse401WithRawResponse() { - val camsKfintechService = client.camsKfintech().withRawResponse() + fun creditsCheck401WithRawResponse() { + val creditService = client.credits().withRawResponse() stubFor( post(anyUrl()) .willReturn( @@ -146,16 +118,7 @@ internal class ErrorHandlingTest { ) ) - val e = - assertThrows { - camsKfintechService.parse( - CamsKfintechParseParams.builder() - .password("password") - .pdfFile("pdf_file") - .pdfUrl("https://example.com") - .build() - ) - } + val e = assertThrows { creditService.check() } assertThat(e.statusCode()).isEqualTo(401) assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) @@ -163,8 +126,8 @@ internal class ErrorHandlingTest { } @Test - fun camsKfintechParse403() { - val camsKfintechService = client.camsKfintech() + fun creditsCheck403() { + val creditService = client.credits() stubFor( post(anyUrl()) .willReturn( @@ -172,16 +135,7 @@ internal class ErrorHandlingTest { ) ) - val e = - assertThrows { - camsKfintechService.parse( - CamsKfintechParseParams.builder() - .password("password") - .pdfFile("pdf_file") - .pdfUrl("https://example.com") - .build() - ) - } + val e = assertThrows { creditService.check() } assertThat(e.statusCode()).isEqualTo(403) assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) @@ -189,8 +143,8 @@ internal class ErrorHandlingTest { } @Test - fun camsKfintechParse403WithRawResponse() { - val camsKfintechService = client.camsKfintech().withRawResponse() + fun creditsCheck403WithRawResponse() { + val creditService = client.credits().withRawResponse() stubFor( post(anyUrl()) .willReturn( @@ -198,16 +152,7 @@ internal class ErrorHandlingTest { ) ) - val e = - assertThrows { - camsKfintechService.parse( - CamsKfintechParseParams.builder() - .password("password") - .pdfFile("pdf_file") - .pdfUrl("https://example.com") - .build() - ) - } + val e = assertThrows { creditService.check() } assertThat(e.statusCode()).isEqualTo(403) assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) @@ -215,8 +160,8 @@ internal class ErrorHandlingTest { } @Test - fun camsKfintechParse404() { - val camsKfintechService = client.camsKfintech() + fun creditsCheck404() { + val creditService = client.credits() stubFor( post(anyUrl()) .willReturn( @@ -224,16 +169,7 @@ internal class ErrorHandlingTest { ) ) - val e = - assertThrows { - camsKfintechService.parse( - CamsKfintechParseParams.builder() - .password("password") - .pdfFile("pdf_file") - .pdfUrl("https://example.com") - .build() - ) - } + val e = assertThrows { creditService.check() } assertThat(e.statusCode()).isEqualTo(404) assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) @@ -241,8 +177,8 @@ internal class ErrorHandlingTest { } @Test - fun camsKfintechParse404WithRawResponse() { - val camsKfintechService = client.camsKfintech().withRawResponse() + fun creditsCheck404WithRawResponse() { + val creditService = client.credits().withRawResponse() stubFor( post(anyUrl()) .willReturn( @@ -250,16 +186,7 @@ internal class ErrorHandlingTest { ) ) - val e = - assertThrows { - camsKfintechService.parse( - CamsKfintechParseParams.builder() - .password("password") - .pdfFile("pdf_file") - .pdfUrl("https://example.com") - .build() - ) - } + val e = assertThrows { creditService.check() } assertThat(e.statusCode()).isEqualTo(404) assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) @@ -267,8 +194,8 @@ internal class ErrorHandlingTest { } @Test - fun camsKfintechParse422() { - val camsKfintechService = client.camsKfintech() + fun creditsCheck422() { + val creditService = client.credits() stubFor( post(anyUrl()) .willReturn( @@ -276,16 +203,7 @@ internal class ErrorHandlingTest { ) ) - val e = - assertThrows { - camsKfintechService.parse( - CamsKfintechParseParams.builder() - .password("password") - .pdfFile("pdf_file") - .pdfUrl("https://example.com") - .build() - ) - } + val e = assertThrows { creditService.check() } assertThat(e.statusCode()).isEqualTo(422) assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) @@ -293,8 +211,8 @@ internal class ErrorHandlingTest { } @Test - fun camsKfintechParse422WithRawResponse() { - val camsKfintechService = client.camsKfintech().withRawResponse() + fun creditsCheck422WithRawResponse() { + val creditService = client.credits().withRawResponse() stubFor( post(anyUrl()) .willReturn( @@ -302,16 +220,7 @@ internal class ErrorHandlingTest { ) ) - val e = - assertThrows { - camsKfintechService.parse( - CamsKfintechParseParams.builder() - .password("password") - .pdfFile("pdf_file") - .pdfUrl("https://example.com") - .build() - ) - } + val e = assertThrows { creditService.check() } assertThat(e.statusCode()).isEqualTo(422) assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) @@ -319,8 +228,8 @@ internal class ErrorHandlingTest { } @Test - fun camsKfintechParse429() { - val camsKfintechService = client.camsKfintech() + fun creditsCheck429() { + val creditService = client.credits() stubFor( post(anyUrl()) .willReturn( @@ -328,16 +237,7 @@ internal class ErrorHandlingTest { ) ) - val e = - assertThrows { - camsKfintechService.parse( - CamsKfintechParseParams.builder() - .password("password") - .pdfFile("pdf_file") - .pdfUrl("https://example.com") - .build() - ) - } + val e = assertThrows { creditService.check() } assertThat(e.statusCode()).isEqualTo(429) assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) @@ -345,8 +245,8 @@ internal class ErrorHandlingTest { } @Test - fun camsKfintechParse429WithRawResponse() { - val camsKfintechService = client.camsKfintech().withRawResponse() + fun creditsCheck429WithRawResponse() { + val creditService = client.credits().withRawResponse() stubFor( post(anyUrl()) .willReturn( @@ -354,16 +254,7 @@ internal class ErrorHandlingTest { ) ) - val e = - assertThrows { - camsKfintechService.parse( - CamsKfintechParseParams.builder() - .password("password") - .pdfFile("pdf_file") - .pdfUrl("https://example.com") - .build() - ) - } + val e = assertThrows { creditService.check() } assertThat(e.statusCode()).isEqualTo(429) assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) @@ -371,8 +262,8 @@ internal class ErrorHandlingTest { } @Test - fun camsKfintechParse500() { - val camsKfintechService = client.camsKfintech() + fun creditsCheck500() { + val creditService = client.credits() stubFor( post(anyUrl()) .willReturn( @@ -380,16 +271,7 @@ internal class ErrorHandlingTest { ) ) - val e = - assertThrows { - camsKfintechService.parse( - CamsKfintechParseParams.builder() - .password("password") - .pdfFile("pdf_file") - .pdfUrl("https://example.com") - .build() - ) - } + val e = assertThrows { creditService.check() } assertThat(e.statusCode()).isEqualTo(500) assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) @@ -397,8 +279,8 @@ internal class ErrorHandlingTest { } @Test - fun camsKfintechParse500WithRawResponse() { - val camsKfintechService = client.camsKfintech().withRawResponse() + fun creditsCheck500WithRawResponse() { + val creditService = client.credits().withRawResponse() stubFor( post(anyUrl()) .willReturn( @@ -406,16 +288,7 @@ internal class ErrorHandlingTest { ) ) - val e = - assertThrows { - camsKfintechService.parse( - CamsKfintechParseParams.builder() - .password("password") - .pdfFile("pdf_file") - .pdfUrl("https://example.com") - .build() - ) - } + val e = assertThrows { creditService.check() } assertThat(e.statusCode()).isEqualTo(500) assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) @@ -423,8 +296,8 @@ internal class ErrorHandlingTest { } @Test - fun camsKfintechParse999() { - val camsKfintechService = client.camsKfintech() + fun creditsCheck999() { + val creditService = client.credits() stubFor( post(anyUrl()) .willReturn( @@ -432,16 +305,7 @@ internal class ErrorHandlingTest { ) ) - val e = - assertThrows { - camsKfintechService.parse( - CamsKfintechParseParams.builder() - .password("password") - .pdfFile("pdf_file") - .pdfUrl("https://example.com") - .build() - ) - } + val e = assertThrows { creditService.check() } assertThat(e.statusCode()).isEqualTo(999) assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) @@ -449,8 +313,8 @@ internal class ErrorHandlingTest { } @Test - fun camsKfintechParse999WithRawResponse() { - val camsKfintechService = client.camsKfintech().withRawResponse() + fun creditsCheck999WithRawResponse() { + val creditService = client.credits().withRawResponse() stubFor( post(anyUrl()) .willReturn( @@ -458,16 +322,7 @@ internal class ErrorHandlingTest { ) ) - val e = - assertThrows { - camsKfintechService.parse( - CamsKfintechParseParams.builder() - .password("password") - .pdfFile("pdf_file") - .pdfUrl("https://example.com") - .build() - ) - } + val e = assertThrows { creditService.check() } assertThat(e.statusCode()).isEqualTo(999) assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) @@ -475,23 +330,14 @@ internal class ErrorHandlingTest { } @Test - fun camsKfintechParseInvalidJsonBody() { - val camsKfintechService = client.camsKfintech() + fun creditsCheckInvalidJsonBody() { + val creditService = client.credits() stubFor( post(anyUrl()) .willReturn(status(200).withHeader(HEADER_NAME, HEADER_VALUE).withBody(NOT_JSON)) ) - val e = - assertThrows { - camsKfintechService.parse( - CamsKfintechParseParams.builder() - .password("password") - .pdfFile("pdf_file") - .pdfUrl("https://example.com") - .build() - ) - } + val e = assertThrows { creditService.check() } assertThat(e).hasMessage("Error reading response") } diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/ServiceParamsTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/ServiceParamsTest.kt index be4ed15..4cdd376 100644 --- a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/ServiceParamsTest.kt +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/ServiceParamsTest.kt @@ -5,7 +5,7 @@ package com.cas_parser.api.services import com.cas_parser.api.client.CasParserClient import com.cas_parser.api.client.okhttp.CasParserOkHttpClient import com.cas_parser.api.core.JsonValue -import com.cas_parser.api.models.camskfintech.CamsKfintechParseParams +import com.cas_parser.api.models.credits.CreditCheckParams import com.github.tomakehurst.wiremock.client.WireMock.anyUrl import com.github.tomakehurst.wiremock.client.WireMock.equalTo import com.github.tomakehurst.wiremock.client.WireMock.matchingJsonPath @@ -38,15 +38,12 @@ internal class ServiceParamsTest { @Disabled("Mock server tests are disabled") @Test - fun parse() { - val camsKfintechService = client.camsKfintech() + fun check() { + val creditService = client.credits() stubFor(post(anyUrl()).willReturn(ok("{}"))) - camsKfintechService.parse( - CamsKfintechParseParams.builder() - .password("password") - .pdfFile("pdf_file") - .pdfUrl("https://example.com") + creditService.check( + CreditCheckParams.builder() .putAdditionalHeader("Secret-Header", "42") .putAdditionalQueryParam("secret_query_param", "42") .putAdditionalBodyProperty("secretProperty", JsonValue.from("42")) diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/AccessTokenServiceAsyncTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/AccessTokenServiceAsyncTest.kt new file mode 100644 index 0000000..c795a5c --- /dev/null +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/AccessTokenServiceAsyncTest.kt @@ -0,0 +1,26 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.services.async + +import com.cas_parser.api.client.okhttp.CasParserOkHttpClientAsync +import com.cas_parser.api.models.accesstoken.AccessTokenCreateParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test + +internal class AccessTokenServiceAsyncTest { + + @Disabled("Mock server tests are disabled") + @Test + fun create() { + val client = CasParserOkHttpClientAsync.builder().apiKey("My API Key").build() + val accessTokenServiceAsync = client.accessToken() + + val accessTokenFuture = + accessTokenServiceAsync.create( + AccessTokenCreateParams.builder().expiryMinutes(60L).build() + ) + + val accessToken = accessTokenFuture.get() + accessToken.validate() + } +} diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/CreditServiceAsyncTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/CreditServiceAsyncTest.kt new file mode 100644 index 0000000..6c9e4d8 --- /dev/null +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/CreditServiceAsyncTest.kt @@ -0,0 +1,22 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.services.async + +import com.cas_parser.api.client.okhttp.CasParserOkHttpClientAsync +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test + +internal class CreditServiceAsyncTest { + + @Disabled("Mock server tests are disabled") + @Test + fun check() { + val client = CasParserOkHttpClientAsync.builder().apiKey("My API Key").build() + val creditServiceAsync = client.credits() + + val responseFuture = creditServiceAsync.check() + + val response = responseFuture.get() + response.validate() + } +} diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/InboundEmailServiceAsyncTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/InboundEmailServiceAsyncTest.kt new file mode 100644 index 0000000..0993dac --- /dev/null +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/InboundEmailServiceAsyncTest.kt @@ -0,0 +1,83 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.services.async + +import com.cas_parser.api.client.okhttp.CasParserOkHttpClientAsync +import com.cas_parser.api.core.JsonValue +import com.cas_parser.api.models.inboundemail.InboundEmailCreateParams +import com.cas_parser.api.models.inboundemail.InboundEmailListParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test + +internal class InboundEmailServiceAsyncTest { + + @Disabled("Mock server tests are disabled") + @Test + fun create() { + val client = CasParserOkHttpClientAsync.builder().apiKey("My API Key").build() + val inboundEmailServiceAsync = client.inboundEmail() + + val inboundEmailFuture = + inboundEmailServiceAsync.create( + InboundEmailCreateParams.builder() + .callbackUrl("https://api.yourapp.com/webhooks/cas-email") + .alias("john-portfolio") + .addAllowedSource(InboundEmailCreateParams.AllowedSource.CDSL) + .addAllowedSource(InboundEmailCreateParams.AllowedSource.NSDL) + .metadata( + InboundEmailCreateParams.Metadata.builder() + .putAdditionalProperty("plan", JsonValue.from("premium")) + .putAdditionalProperty("source", JsonValue.from("onboarding")) + .build() + ) + .reference("user_12345") + .build() + ) + + val inboundEmail = inboundEmailFuture.get() + inboundEmail.validate() + } + + @Disabled("Mock server tests are disabled") + @Test + fun retrieve() { + val client = CasParserOkHttpClientAsync.builder().apiKey("My API Key").build() + val inboundEmailServiceAsync = client.inboundEmail() + + val inboundEmailFuture = inboundEmailServiceAsync.retrieve("ie_a1b2c3d4e5f6") + + val inboundEmail = inboundEmailFuture.get() + inboundEmail.validate() + } + + @Disabled("Mock server tests are disabled") + @Test + fun list() { + val client = CasParserOkHttpClientAsync.builder().apiKey("My API Key").build() + val inboundEmailServiceAsync = client.inboundEmail() + + val inboundEmailsFuture = + inboundEmailServiceAsync.list( + InboundEmailListParams.builder() + .limit(1L) + .offset(0L) + .status(InboundEmailListParams.Status.ACTIVE) + .build() + ) + + val inboundEmails = inboundEmailsFuture.get() + inboundEmails.validate() + } + + @Disabled("Mock server tests are disabled") + @Test + fun delete() { + val client = CasParserOkHttpClientAsync.builder().apiKey("My API Key").build() + val inboundEmailServiceAsync = client.inboundEmail() + + val inboundEmailFuture = inboundEmailServiceAsync.delete("inbound_email_id") + + val inboundEmail = inboundEmailFuture.get() + inboundEmail.validate() + } +} diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/LogServiceAsyncTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/LogServiceAsyncTest.kt new file mode 100644 index 0000000..532be8d --- /dev/null +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/LogServiceAsyncTest.kt @@ -0,0 +1,50 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.services.async + +import com.cas_parser.api.client.okhttp.CasParserOkHttpClientAsync +import com.cas_parser.api.models.logs.LogCreateParams +import com.cas_parser.api.models.logs.LogGetSummaryParams +import java.time.OffsetDateTime +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test + +internal class LogServiceAsyncTest { + + @Disabled("Mock server tests are disabled") + @Test + fun create() { + val client = CasParserOkHttpClientAsync.builder().apiKey("My API Key").build() + val logServiceAsync = client.logs() + + val logFuture = + logServiceAsync.create( + LogCreateParams.builder() + .endTime(OffsetDateTime.parse("2026-01-31T23:59:59Z")) + .limit(1L) + .startTime(OffsetDateTime.parse("2026-01-01T00:00:00Z")) + .build() + ) + + val log = logFuture.get() + log.validate() + } + + @Disabled("Mock server tests are disabled") + @Test + fun getSummary() { + val client = CasParserOkHttpClientAsync.builder().apiKey("My API Key").build() + val logServiceAsync = client.logs() + + val responseFuture = + logServiceAsync.getSummary( + LogGetSummaryParams.builder() + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + + val response = responseFuture.get() + response.validate() + } +} diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/VerifyTokenServiceAsyncTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/VerifyTokenServiceAsyncTest.kt new file mode 100644 index 0000000..3d7800c --- /dev/null +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/VerifyTokenServiceAsyncTest.kt @@ -0,0 +1,22 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.services.async + +import com.cas_parser.api.client.okhttp.CasParserOkHttpClientAsync +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test + +internal class VerifyTokenServiceAsyncTest { + + @Disabled("Mock server tests are disabled") + @Test + fun verify() { + val client = CasParserOkHttpClientAsync.builder().apiKey("My API Key").build() + val verifyTokenServiceAsync = client.verifyToken() + + val responseFuture = verifyTokenServiceAsync.verify() + + val response = responseFuture.get() + response.validate() + } +} diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/AccessTokenServiceTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/AccessTokenServiceTest.kt new file mode 100644 index 0000000..f7c9696 --- /dev/null +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/AccessTokenServiceTest.kt @@ -0,0 +1,23 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.services.blocking + +import com.cas_parser.api.client.okhttp.CasParserOkHttpClient +import com.cas_parser.api.models.accesstoken.AccessTokenCreateParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test + +internal class AccessTokenServiceTest { + + @Disabled("Mock server tests are disabled") + @Test + fun create() { + val client = CasParserOkHttpClient.builder().apiKey("My API Key").build() + val accessTokenService = client.accessToken() + + val accessToken = + accessTokenService.create(AccessTokenCreateParams.builder().expiryMinutes(60L).build()) + + accessToken.validate() + } +} diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/CreditServiceTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/CreditServiceTest.kt new file mode 100644 index 0000000..94239a3 --- /dev/null +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/CreditServiceTest.kt @@ -0,0 +1,21 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.services.blocking + +import com.cas_parser.api.client.okhttp.CasParserOkHttpClient +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test + +internal class CreditServiceTest { + + @Disabled("Mock server tests are disabled") + @Test + fun check() { + val client = CasParserOkHttpClient.builder().apiKey("My API Key").build() + val creditService = client.credits() + + val response = creditService.check() + + response.validate() + } +} diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/InboundEmailServiceTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/InboundEmailServiceTest.kt new file mode 100644 index 0000000..66d6b0c --- /dev/null +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/InboundEmailServiceTest.kt @@ -0,0 +1,79 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.services.blocking + +import com.cas_parser.api.client.okhttp.CasParserOkHttpClient +import com.cas_parser.api.core.JsonValue +import com.cas_parser.api.models.inboundemail.InboundEmailCreateParams +import com.cas_parser.api.models.inboundemail.InboundEmailListParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test + +internal class InboundEmailServiceTest { + + @Disabled("Mock server tests are disabled") + @Test + fun create() { + val client = CasParserOkHttpClient.builder().apiKey("My API Key").build() + val inboundEmailService = client.inboundEmail() + + val inboundEmail = + inboundEmailService.create( + InboundEmailCreateParams.builder() + .callbackUrl("https://api.yourapp.com/webhooks/cas-email") + .alias("john-portfolio") + .addAllowedSource(InboundEmailCreateParams.AllowedSource.CDSL) + .addAllowedSource(InboundEmailCreateParams.AllowedSource.NSDL) + .metadata( + InboundEmailCreateParams.Metadata.builder() + .putAdditionalProperty("plan", JsonValue.from("premium")) + .putAdditionalProperty("source", JsonValue.from("onboarding")) + .build() + ) + .reference("user_12345") + .build() + ) + + inboundEmail.validate() + } + + @Disabled("Mock server tests are disabled") + @Test + fun retrieve() { + val client = CasParserOkHttpClient.builder().apiKey("My API Key").build() + val inboundEmailService = client.inboundEmail() + + val inboundEmail = inboundEmailService.retrieve("ie_a1b2c3d4e5f6") + + inboundEmail.validate() + } + + @Disabled("Mock server tests are disabled") + @Test + fun list() { + val client = CasParserOkHttpClient.builder().apiKey("My API Key").build() + val inboundEmailService = client.inboundEmail() + + val inboundEmails = + inboundEmailService.list( + InboundEmailListParams.builder() + .limit(1L) + .offset(0L) + .status(InboundEmailListParams.Status.ACTIVE) + .build() + ) + + inboundEmails.validate() + } + + @Disabled("Mock server tests are disabled") + @Test + fun delete() { + val client = CasParserOkHttpClient.builder().apiKey("My API Key").build() + val inboundEmailService = client.inboundEmail() + + val inboundEmail = inboundEmailService.delete("inbound_email_id") + + inboundEmail.validate() + } +} diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/LogServiceTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/LogServiceTest.kt new file mode 100644 index 0000000..2ef5c48 --- /dev/null +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/LogServiceTest.kt @@ -0,0 +1,48 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.services.blocking + +import com.cas_parser.api.client.okhttp.CasParserOkHttpClient +import com.cas_parser.api.models.logs.LogCreateParams +import com.cas_parser.api.models.logs.LogGetSummaryParams +import java.time.OffsetDateTime +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test + +internal class LogServiceTest { + + @Disabled("Mock server tests are disabled") + @Test + fun create() { + val client = CasParserOkHttpClient.builder().apiKey("My API Key").build() + val logService = client.logs() + + val log = + logService.create( + LogCreateParams.builder() + .endTime(OffsetDateTime.parse("2026-01-31T23:59:59Z")) + .limit(1L) + .startTime(OffsetDateTime.parse("2026-01-01T00:00:00Z")) + .build() + ) + + log.validate() + } + + @Disabled("Mock server tests are disabled") + @Test + fun getSummary() { + val client = CasParserOkHttpClient.builder().apiKey("My API Key").build() + val logService = client.logs() + + val response = + logService.getSummary( + LogGetSummaryParams.builder() + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + + response.validate() + } +} diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/VerifyTokenServiceTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/VerifyTokenServiceTest.kt new file mode 100644 index 0000000..19af27d --- /dev/null +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/VerifyTokenServiceTest.kt @@ -0,0 +1,21 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.services.blocking + +import com.cas_parser.api.client.okhttp.CasParserOkHttpClient +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test + +internal class VerifyTokenServiceTest { + + @Disabled("Mock server tests are disabled") + @Test + fun verify() { + val client = CasParserOkHttpClient.builder().apiKey("My API Key").build() + val verifyTokenService = client.verifyToken() + + val response = verifyTokenService.verify() + + response.validate() + } +} diff --git a/cas-parser-java-proguard-test/src/test/kotlin/com/cas_parser/api/proguard/ProGuardCompatibilityTest.kt b/cas-parser-java-proguard-test/src/test/kotlin/com/cas_parser/api/proguard/ProGuardCompatibilityTest.kt index 8592efc..bc06f0e 100644 --- a/cas-parser-java-proguard-test/src/test/kotlin/com/cas_parser/api/proguard/ProGuardCompatibilityTest.kt +++ b/cas-parser-java-proguard-test/src/test/kotlin/com/cas_parser/api/proguard/ProGuardCompatibilityTest.kt @@ -4,8 +4,9 @@ package com.cas_parser.api.proguard import com.cas_parser.api.client.okhttp.CasParserOkHttpClient import com.cas_parser.api.core.jsonMapper -import com.cas_parser.api.models.camskfintech.LinkedHolder +import com.cas_parser.api.models.credits.CreditCheckResponse import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.time.OffsetDateTime import kotlin.reflect.full.memberFunctions import kotlin.reflect.jvm.javaMethod import org.assertj.core.api.Assertions.assertThat @@ -58,19 +59,30 @@ internal class ProGuardCompatibilityTest { assertThat(client.kfintech()).isNotNull() assertThat(client.nsdl()).isNotNull() assertThat(client.smart()).isNotNull() + assertThat(client.inboundEmail()).isNotNull() } @Test - fun linkedHolderRoundtrip() { + fun creditCheckResponseRoundtrip() { val jsonMapper = jsonMapper() - val linkedHolder = LinkedHolder.builder().name("name").pan("pan").build() + val creditCheckResponse = + CreditCheckResponse.builder() + .enabledFeatures( + listOf("cams_kfintech_cas_parser", "cdsl_cas_parser", "nsdl_cas_parser") + ) + .isUnlimited(false) + .limit(50L) + .remaining(35.0) + .resetsAt(OffsetDateTime.parse("2026-02-15T00:00:00Z")) + .used(15.0) + .build() - val roundtrippedLinkedHolder = + val roundtrippedCreditCheckResponse = jsonMapper.readValue( - jsonMapper.writeValueAsString(linkedHolder), - jacksonTypeRef(), + jsonMapper.writeValueAsString(creditCheckResponse), + jacksonTypeRef(), ) - assertThat(roundtrippedLinkedHolder).isEqualTo(linkedHolder) + assertThat(roundtrippedCreditCheckResponse).isEqualTo(creditCheckResponse) } } From e5677af2ac300d200926245d86b6896d7d15697d Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 23 Feb 2026 03:00:43 +0000 Subject: [PATCH 13/14] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index cdf3c0a..49508b3 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 21 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cas-parser%2Fcas-parser-d9763d006969b49a1473851069fdfa429eb13133b64103a62963bb70ddb22305.yml openapi_spec_hash: 6aee689b7a759b12c85c088c15e29bc0 -config_hash: d54f39abb185904495bef7c5f8702746 +config_hash: 4ab3e1ee76a463e0ed214541260ee12e From 0f834e7a7e72bd8778286f0e404665e365637179 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 23 Feb 2026 03:00:57 +0000 Subject: [PATCH 14/14] release: 0.4.0 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 20 ++++++++++++++++++++ README.md | 10 +++++----- build.gradle.kts | 2 +- 4 files changed, 27 insertions(+), 7 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 6b7b74c..da59f99 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.3.0" + ".": "0.4.0" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 19f5970..76db8cf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,25 @@ # Changelog +## 0.4.0 (2026-02-23) + +Full Changelog: [v0.3.0...v0.4.0](https://github.com/CASParser/cas-parser-java/compare/v0.3.0...v0.4.0) + +### Features + +* **api:** api update ([b23e224](https://github.com/CASParser/cas-parser-java/commit/b23e22466dac01c31d286182542dc8146d5fac7d)) +* **api:** api update ([cfdb276](https://github.com/CASParser/cas-parser-java/commit/cfdb276b8126bf167b489ded6fc13d84ad876dad)) +* **api:** api update ([8d2cb43](https://github.com/CASParser/cas-parser-java/commit/8d2cb43b11b1923624fdc32f7433115f5b20cf37)) +* **api:** manual updates ([2bb349e](https://github.com/CASParser/cas-parser-java/commit/2bb349ef8822aeda2d8d47d5f0c27994f9624446)) +* **client:** add connection pooling option ([3ad0fbc](https://github.com/CASParser/cas-parser-java/commit/3ad0fbcafa782f6f7dfcead9d4c4646aedd4e681)) + + +### Chores + +* **internal:** make `OkHttp` constructor internal ([1939ec1](https://github.com/CASParser/cas-parser-java/commit/1939ec1346feeb7a1ea45db385d6f8b7f8daacf6)) +* **internal:** remove mock server code ([0bdc28f](https://github.com/CASParser/cas-parser-java/commit/0bdc28fc1a9ae2e735d2c40d9cf86c1dc00461ae)) +* **internal:** update `TestServerExtension` comment ([ff77ead](https://github.com/CASParser/cas-parser-java/commit/ff77ead512a0b13377c61c0e92cc478586e7a67e)) +* update mock server docs ([e7286da](https://github.com/CASParser/cas-parser-java/commit/e7286da78e71c2750514686fb39e2b1a0b5140af)) + ## 0.3.0 (2026-02-14) Full Changelog: [v0.2.1...v0.3.0](https://github.com/CASParser/cas-parser-java/compare/v0.2.1...v0.3.0) diff --git a/README.md b/README.md index 212151b..bb3747b 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ -[![Maven Central](https://img.shields.io/maven-central/v/com.cas_parser.api/cas-parser-java)](https://central.sonatype.com/artifact/com.cas_parser.api/cas-parser-java/0.3.0) -[![javadoc](https://javadoc.io/badge2/com.cas_parser.api/cas-parser-java/0.3.0/javadoc.svg)](https://javadoc.io/doc/com.cas_parser.api/cas-parser-java/0.3.0) +[![Maven Central](https://img.shields.io/maven-central/v/com.cas_parser.api/cas-parser-java)](https://central.sonatype.com/artifact/com.cas_parser.api/cas-parser-java/0.4.0) +[![javadoc](https://javadoc.io/badge2/com.cas_parser.api/cas-parser-java/0.4.0/javadoc.svg)](https://javadoc.io/doc/com.cas_parser.api/cas-parser-java/0.4.0) @@ -22,7 +22,7 @@ Use the Cas Parser MCP Server to enable AI assistants to interact with this API, -The REST API documentation can be found on [docs.casparser.in](https://docs.casparser.in). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.cas_parser.api/cas-parser-java/0.3.0). +The REST API documentation can be found on [docs.casparser.in](https://docs.casparser.in). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.cas_parser.api/cas-parser-java/0.4.0). @@ -33,7 +33,7 @@ The REST API documentation can be found on [docs.casparser.in](https://docs.casp ### Gradle ```kotlin -implementation("com.cas_parser.api:cas-parser-java:0.3.0") +implementation("com.cas_parser.api:cas-parser-java:0.4.0") ``` ### Maven @@ -42,7 +42,7 @@ implementation("com.cas_parser.api:cas-parser-java:0.3.0") com.cas_parser.api cas-parser-java - 0.3.0 + 0.4.0 ``` diff --git a/build.gradle.kts b/build.gradle.kts index 90d29ec..40e9f7a 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -9,7 +9,7 @@ repositories { allprojects { group = "com.cas_parser.api" - version = "0.3.0" // x-release-please-version + version = "0.4.0" // x-release-please-version } subprojects {