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/.stats.yml b/.stats.yml index 32808d2..49508b3 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 +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: 4ab3e1ee76a463e0ed214541260ee12e 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 c55a4ea..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 ``` @@ -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/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 { 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 7079d3c..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 @@ -33,7 +35,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) @@ -200,6 +202,8 @@ private constructor(@JvmSynthetic internal val okHttpClient: okhttp3.OkHttpClien 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 @@ private constructor(@JvmSynthetic internal val okHttpClient: okhttp3.OkHttpClien 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 @@ private constructor(@JvmSynthetic internal val okHttpClient: okhttp3.OkHttpClien .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) { 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 index 676dc4d..93daf86 100644 --- 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 @@ -24,6 +24,8 @@ import java.util.Optional * **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 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/inbox/InboxListCasFilesResponse.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/inbox/InboxListCasFilesResponse.kt index 84d490e..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 @@ -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,15 @@ private constructor( */ fun originalFilename(): Optional = originalFilename.getOptional("original_filename") + /** + * 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). + */ + fun senderEmail(): Optional = senderEmail.getOptional("sender_email") + /** * File size in bytes * @@ -382,6 +396,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 +446,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 +459,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 +542,23 @@ private constructor( this.originalFilename = originalFilename } + /** + * Email address of the CAS authority (CDSL, NSDL, CAMS, or KFintech) who originally + * sent this statement + */ + 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 +615,7 @@ private constructor( messageDate, messageId, originalFilename, + senderEmail, size, url, additionalProperties.toMutableMap(), @@ -592,6 +635,7 @@ private constructor( messageDate() messageId() originalFilename() + senderEmail() size() url() validated = true @@ -619,6 +663,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 +822,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 +836,7 @@ private constructor( messageDate, messageId, originalFilename, + senderEmail, size, url, additionalProperties, @@ -799,7 +846,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/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 index c46a795..b5db085 100644 --- 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 @@ -24,6 +24,8 @@ import java.util.Optional * * 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( 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 index f14f253..28648da 100644 --- 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 @@ -23,6 +23,8 @@ 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( 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..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 @@ -30,6 +30,8 @@ interface AccessTokenServiceAsync { * **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 @@ -70,7 +72,7 @@ interface AccessTokenServiceAsync { ): AccessTokenServiceAsync.WithRawResponse /** - * Returns a raw HTTP response for `post /v1/access-token`, but is otherwise the same as + * Returns a raw HTTP response for `post /v1/token`, but is otherwise the same as * [AccessTokenServiceAsync.create]. */ fun create(): CompletableFuture> = 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..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 @@ -36,7 +36,7 @@ class AccessTokenServiceAsyncImpl internal constructor(private val clientOptions params: AccessTokenCreateParams, requestOptions: RequestOptions, ): CompletableFuture = - // post /v1/access-token + // post /v1/token withRawResponse().create(params, requestOptions).thenApply { it.parse() } class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : @@ -63,7 +63,7 @@ class AccessTokenServiceAsyncImpl internal constructor(private val clientOptions HttpRequest.builder() .method(HttpMethod.POST) .baseUrl(clientOptions.baseUrl()) - .addPathSegments("v1", "access-token") + .addPathSegments("v1", "token") .body(json(clientOptions.jsonMapper, params._body())) .build() .prepareAsync(clientOptions, params) 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..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 @@ -66,7 +66,7 @@ interface CreditServiceAsync { ): CreditServiceAsync.WithRawResponse /** - * Returns a raw HTTP response for `post /credits`, but is otherwise the same as + * Returns a raw HTTP response for `post /v1/credits`, but is otherwise the same as * [CreditServiceAsync.check]. */ fun check(): CompletableFuture> = 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..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 @@ -36,7 +36,7 @@ class CreditServiceAsyncImpl internal constructor(private val clientOptions: Cli params: CreditCheckParams, requestOptions: RequestOptions, ): CompletableFuture = - // post /credits + // post /v1/credits withRawResponse().check(params, requestOptions).thenApply { it.parse() } class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : @@ -63,7 +63,7 @@ class CreditServiceAsyncImpl internal constructor(private val clientOptions: Cli HttpRequest.builder() .method(HttpMethod.POST) .baseUrl(clientOptions.baseUrl()) - .addPathSegments("credits") + .addPathSegments("v1", "credits") .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() .prepareAsync(clientOptions, params) 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 641ee6a..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 @@ -31,6 +31,8 @@ interface LogServiceAsync { * * 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()) @@ -53,6 +55,8 @@ interface LogServiceAsync { * 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()) @@ -83,7 +87,7 @@ interface LogServiceAsync { fun withOptions(modifier: Consumer): LogServiceAsync.WithRawResponse /** - * Returns a raw HTTP response for `post /logs`, but is otherwise the same as + * Returns a raw HTTP response for `post /v1/usage`, but is otherwise the same as * [LogServiceAsync.create]. */ fun create(): CompletableFuture> = @@ -108,7 +112,7 @@ interface LogServiceAsync { create(LogCreateParams.none(), requestOptions) /** - * Returns a raw HTTP response for `post /logs/summary`, but is otherwise the same as + * Returns a raw HTTP response for `post /v1/usage/summary`, but is otherwise the same as * [LogServiceAsync.getSummary]. */ fun getSummary(): CompletableFuture> = 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..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 @@ -38,14 +38,14 @@ class LogServiceAsyncImpl internal constructor(private val clientOptions: Client params: LogCreateParams, requestOptions: RequestOptions, ): CompletableFuture = - // post /logs + // post /v1/usage withRawResponse().create(params, requestOptions).thenApply { it.parse() } override fun getSummary( params: LogGetSummaryParams, requestOptions: RequestOptions, ): CompletableFuture = - // post /logs/summary + // post /v1/usage/summary withRawResponse().getSummary(params, requestOptions).thenApply { it.parse() } class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : @@ -72,7 +72,7 @@ class LogServiceAsyncImpl internal constructor(private val clientOptions: Client HttpRequest.builder() .method(HttpMethod.POST) .baseUrl(clientOptions.baseUrl()) - .addPathSegments("logs") + .addPathSegments("v1", "usage") .body(json(clientOptions.jsonMapper, params._body())) .build() .prepareAsync(clientOptions, params) @@ -103,7 +103,7 @@ class LogServiceAsyncImpl internal constructor(private val clientOptions: Client HttpRequest.builder() .method(HttpMethod.POST) .baseUrl(clientOptions.baseUrl()) - .addPathSegments("logs", "summary") + .addPathSegments("v1", "usage", "summary") .body(json(clientOptions.jsonMapper, params._body())) .build() .prepareAsync(clientOptions, params) 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..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 @@ -59,7 +59,7 @@ interface VerifyTokenServiceAsync { ): VerifyTokenServiceAsync.WithRawResponse /** - * Returns a raw HTTP response for `post /v1/verify-token`, but is otherwise the same as + * Returns a raw HTTP response for `post /v1/token/verify`, but is otherwise the same as * [VerifyTokenServiceAsync.verify]. */ fun verify(): CompletableFuture> = 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..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 @@ -36,7 +36,7 @@ class VerifyTokenServiceAsyncImpl internal constructor(private val clientOptions params: VerifyTokenVerifyParams, requestOptions: RequestOptions, ): CompletableFuture = - // post /v1/verify-token + // post /v1/token/verify withRawResponse().verify(params, requestOptions).thenApply { it.parse() } class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : @@ -63,7 +63,7 @@ class VerifyTokenServiceAsyncImpl internal constructor(private val clientOptions HttpRequest.builder() .method(HttpMethod.POST) .baseUrl(clientOptions.baseUrl()) - .addPathSegments("v1", "verify-token") + .addPathSegments("v1", "token", "verify") .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() .prepareAsync(clientOptions, params) 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..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 @@ -30,6 +30,8 @@ interface AccessTokenService { * **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 @@ -68,7 +70,7 @@ interface AccessTokenService { ): AccessTokenService.WithRawResponse /** - * Returns a raw HTTP response for `post /v1/access-token`, but is otherwise the same as + * Returns a raw HTTP response for `post /v1/token`, but is otherwise the same as * [AccessTokenService.create]. */ @MustBeClosed 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..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 @@ -35,7 +35,7 @@ class AccessTokenServiceImpl internal constructor(private val clientOptions: Cli params: AccessTokenCreateParams, requestOptions: RequestOptions, ): AccessTokenCreateResponse = - // post /v1/access-token + // post /v1/token withRawResponse().create(params, requestOptions).parse() class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : @@ -62,7 +62,7 @@ class AccessTokenServiceImpl internal constructor(private val clientOptions: Cli HttpRequest.builder() .method(HttpMethod.POST) .baseUrl(clientOptions.baseUrl()) - .addPathSegments("v1", "access-token") + .addPathSegments("v1", "token") .body(json(clientOptions.jsonMapper, params._body())) .build() .prepare(clientOptions, params) 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..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 @@ -61,7 +61,7 @@ interface CreditService { fun withOptions(modifier: Consumer): CreditService.WithRawResponse /** - * Returns a raw HTTP response for `post /credits`, but is otherwise the same as + * Returns a raw HTTP response for `post /v1/credits`, but is otherwise the same as * [CreditService.check]. */ @MustBeClosed 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..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 @@ -35,7 +35,7 @@ class CreditServiceImpl internal constructor(private val clientOptions: ClientOp params: CreditCheckParams, requestOptions: RequestOptions, ): CreditCheckResponse = - // post /credits + // post /v1/credits withRawResponse().check(params, requestOptions).parse() class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : @@ -62,7 +62,7 @@ class CreditServiceImpl internal constructor(private val clientOptions: ClientOp HttpRequest.builder() .method(HttpMethod.POST) .baseUrl(clientOptions.baseUrl()) - .addPathSegments("credits") + .addPathSegments("v1", "credits") .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() .prepare(clientOptions, params) 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 ce35cba..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 @@ -31,6 +31,8 @@ interface LogService { * * 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()) @@ -52,6 +54,8 @@ interface LogService { * 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()) @@ -81,7 +85,7 @@ interface LogService { fun withOptions(modifier: Consumer): LogService.WithRawResponse /** - * Returns a raw HTTP response for `post /logs`, but is otherwise the same as + * Returns a raw HTTP response for `post /v1/usage`, but is otherwise the same as * [LogService.create]. */ @MustBeClosed @@ -106,7 +110,7 @@ interface LogService { create(LogCreateParams.none(), requestOptions) /** - * Returns a raw HTTP response for `post /logs/summary`, but is otherwise the same as + * Returns a raw HTTP response for `post /v1/usage/summary`, but is otherwise the same as * [LogService.getSummary]. */ @MustBeClosed 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..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 @@ -36,14 +36,14 @@ class LogServiceImpl internal constructor(private val clientOptions: ClientOptio params: LogCreateParams, requestOptions: RequestOptions, ): LogCreateResponse = - // post /logs + // post /v1/usage withRawResponse().create(params, requestOptions).parse() override fun getSummary( params: LogGetSummaryParams, requestOptions: RequestOptions, ): LogGetSummaryResponse = - // post /logs/summary + // post /v1/usage/summary withRawResponse().getSummary(params, requestOptions).parse() class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : @@ -70,7 +70,7 @@ class LogServiceImpl internal constructor(private val clientOptions: ClientOptio HttpRequest.builder() .method(HttpMethod.POST) .baseUrl(clientOptions.baseUrl()) - .addPathSegments("logs") + .addPathSegments("v1", "usage") .body(json(clientOptions.jsonMapper, params._body())) .build() .prepare(clientOptions, params) @@ -98,7 +98,7 @@ class LogServiceImpl internal constructor(private val clientOptions: ClientOptio HttpRequest.builder() .method(HttpMethod.POST) .baseUrl(clientOptions.baseUrl()) - .addPathSegments("logs", "summary") + .addPathSegments("v1", "usage", "summary") .body(json(clientOptions.jsonMapper, params._body())) .build() .prepare(clientOptions, params) 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..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 @@ -57,7 +57,7 @@ interface VerifyTokenService { ): VerifyTokenService.WithRawResponse /** - * Returns a raw HTTP response for `post /v1/verify-token`, but is otherwise the same as + * Returns a raw HTTP response for `post /v1/token/verify`, but is otherwise the same as * [VerifyTokenService.verify]. */ @MustBeClosed 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..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 @@ -35,7 +35,7 @@ class VerifyTokenServiceImpl internal constructor(private val clientOptions: Cli params: VerifyTokenVerifyParams, requestOptions: RequestOptions, ): VerifyTokenVerifyResponse = - // post /v1/verify-token + // post /v1/token/verify withRawResponse().verify(params, requestOptions).parse() class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : @@ -62,7 +62,7 @@ class VerifyTokenServiceImpl internal constructor(private val clientOptions: Cli HttpRequest.builder() .method(HttpMethod.POST) .baseUrl(clientOptions.baseUrl()) - .addPathSegments("v1", "verify-token") + .addPathSegments("v1", "token", "verify") .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() .prepare(clientOptions, params) 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 a567645..0000000 --- a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/TestServerExtension.kt +++ /dev/null @@ -1,62 +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 Prism 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 - """ - .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/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/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" 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 d1a2caa..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 @@ -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") + @Disabled("Mock server 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..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 @@ -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") + @Disabled("Mock server 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..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 @@ -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") + @Disabled("Mock server 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..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 @@ -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") + @Disabled("Mock server 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..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 @@ -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") + @Disabled("Mock server 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/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/InboxServiceAsyncTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/InboxServiceAsyncTest.kt index 45759bf..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 @@ -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") + @Disabled("Mock server 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 = @@ -35,14 +28,10 @@ internal class InboxServiceAsyncTest { response.validate() } - @Disabled("Prism tests are disabled") + @Disabled("Mock server 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 = @@ -57,14 +46,10 @@ internal class InboxServiceAsyncTest { response.validate() } - @Disabled("Prism tests are disabled") + @Disabled("Mock server 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 = @@ -76,14 +61,10 @@ internal class InboxServiceAsyncTest { response.validate() } - @Disabled("Prism tests are disabled") + @Disabled("Mock server 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..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 @@ -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") + @Disabled("Mock server 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..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 @@ -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") + @Disabled("Mock server 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 = @@ -37,14 +30,10 @@ internal class LogServiceAsyncTest { log.validate() } - @Disabled("Prism tests are disabled") + @Disabled("Mock server 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..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 @@ -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") + @Disabled("Mock server 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..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 @@ -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") + @Disabled("Mock server 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..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 @@ -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") + @Disabled("Mock server 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..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 @@ -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") + @Disabled("Mock server 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 = @@ -36,14 +29,10 @@ internal class FetchServiceAsyncTest { response.validate() } - @Disabled("Prism tests are disabled") + @Disabled("Mock server 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..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 @@ -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") + @Disabled("Mock server 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..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 @@ -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") + @Disabled("Mock server 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..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 @@ -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") + @Disabled("Mock server 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..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 @@ -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") + @Disabled("Mock server 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..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 @@ -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") + @Disabled("Mock server 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/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/InboxServiceTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/InboxServiceTest.kt index 8b62e2d..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 @@ -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") + @Disabled("Mock server 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 = @@ -34,14 +27,10 @@ internal class InboxServiceTest { response.validate() } - @Disabled("Prism tests are disabled") + @Disabled("Mock server 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 = @@ -55,14 +44,10 @@ internal class InboxServiceTest { response.validate() } - @Disabled("Prism tests are disabled") + @Disabled("Mock server 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 = @@ -73,14 +58,10 @@ internal class InboxServiceTest { response.validate() } - @Disabled("Prism tests are disabled") + @Disabled("Mock server 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..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 @@ -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") + @Disabled("Mock server 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..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 @@ -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") + @Disabled("Mock server 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 = @@ -36,14 +29,10 @@ internal class LogServiceTest { log.validate() } - @Disabled("Prism tests are disabled") + @Disabled("Mock server 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..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 @@ -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") + @Disabled("Mock server 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..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 @@ -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") + @Disabled("Mock server 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..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 @@ -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") + @Disabled("Mock server 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..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 @@ -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") + @Disabled("Mock server 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 = @@ -35,14 +28,10 @@ internal class FetchServiceTest { response.validate() } - @Disabled("Prism tests are disabled") + @Disabled("Mock server 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/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..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 @@ -59,6 +59,7 @@ internal class ProGuardCompatibilityTest { assertThat(client.kfintech()).isNotNull() assertThat(client.nsdl()).isNotNull() assertThat(client.smart()).isNotNull() + assertThat(client.inboundEmail()).isNotNull() } @Test 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 "$@"