diff --git a/.release-please-manifest.json b/.release-please-manifest.json index a26ebfc1..8f3e0a49 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.14.0" + ".": "0.15.0" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index b57e87a9..cce5f555 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ -configured_endpoints: 19 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/prelude/prelude-86fc45f417e6468f6a6087f9e35b264b0a350e31385bc078a2027a1f1abd1d15.yml +configured_endpoints: 27 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/prelude/prelude-33b70f86404b99046db5c61d3142b149dd7dec7eefe5e62ff3b397c7274aa5dc.yml openapi_spec_hash: fb72aba38ec55a3b6b5162c9f5b4228d -config_hash: 3dbe79c14ecd9a153418249f9155d159 +config_hash: 707d65d2f456a2b5ba5b2c565b60128a diff --git a/CHANGELOG.md b/CHANGELOG.md index 2d26bd82..8317f99e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## 0.15.0 (2026-09-18) + +Full Changelog: [v0.14.0...v0.15.0](https://github.com/prelude-so/java-sdk/compare/v0.14.0...v0.15.0) + +### Features + +* **api:** manual updates ([9121aca](https://github.com/prelude-so/java-sdk/commit/9121acadfe49924dbf383d9ba7a363a4282afdb4)) + ## 0.14.0 (2026-09-15) Full Changelog: [v0.13.0...v0.14.0](https://github.com/prelude-so/java-sdk/compare/v0.13.0...v0.14.0) diff --git a/README.md b/README.md index efdba809..b560586c 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ -[![Maven Central](https://img.shields.io/maven-central/v/so.prelude.sdk/prelude-java)](https://central.sonatype.com/artifact/so.prelude.sdk/prelude-java/0.14.0) -[![javadoc](https://javadoc.io/badge2/so.prelude.sdk/prelude-java/javadoc.svg)](https://javadoc.io/doc/so.prelude.sdk/prelude-java/0.14.0) +[![Maven Central](https://img.shields.io/maven-central/v/so.prelude.sdk/prelude-java)](https://central.sonatype.com/artifact/so.prelude.sdk/prelude-java/0.15.0) +[![javadoc](https://javadoc.io/badge2/so.prelude.sdk/prelude-java/javadoc.svg)](https://javadoc.io/doc/so.prelude.sdk/prelude-java/0.15.0) @@ -13,7 +13,7 @@ It is generated with [Stainless](https://www.stainless.com/). -The REST API documentation can be found on [docs.prelude.so](https://docs.prelude.so). Javadocs are available on [javadoc.io](https://javadoc.io/doc/so.prelude.sdk/prelude-java/0.14.0). +The REST API documentation can be found on [docs.prelude.so](https://docs.prelude.so). Javadocs are available on [javadoc.io](https://javadoc.io/doc/so.prelude.sdk/prelude-java/0.15.0). @@ -24,7 +24,7 @@ The REST API documentation can be found on [docs.prelude.so](https://docs.prelud ### Gradle ```kotlin -implementation("so.prelude.sdk:prelude-java:0.14.0") +implementation("so.prelude.sdk:prelude-java:0.15.0") ``` ### Maven @@ -33,7 +33,7 @@ implementation("so.prelude.sdk:prelude-java:0.14.0") so.prelude.sdk prelude-java - 0.14.0 + 0.15.0 ``` @@ -48,6 +48,7 @@ This library requires Java 8 or later. ```java import so.prelude.sdk.client.PreludeClient; import so.prelude.sdk.client.okhttp.PreludeOkHttpClient; +import so.prelude.sdk.models.Target; import so.prelude.sdk.models.VerificationCreateParams; import so.prelude.sdk.models.VerificationCreateResponse; @@ -56,8 +57,8 @@ import so.prelude.sdk.models.VerificationCreateResponse; PreludeClient client = PreludeOkHttpClient.fromEnv(); VerificationCreateParams params = VerificationCreateParams.builder() - .target(VerificationCreateParams.Target.builder() - .type(VerificationCreateParams.Target.Type.PHONE_NUMBER) + .target(Target.builder() + .type(Target.Type.PHONE_NUMBER) .value("+30123456789") .build()) .build(); @@ -152,6 +153,7 @@ The default client is synchronous. To switch to asynchronous execution, call the import java.util.concurrent.CompletableFuture; import so.prelude.sdk.client.PreludeClient; import so.prelude.sdk.client.okhttp.PreludeOkHttpClient; +import so.prelude.sdk.models.Target; import so.prelude.sdk.models.VerificationCreateParams; import so.prelude.sdk.models.VerificationCreateResponse; @@ -160,8 +162,8 @@ import so.prelude.sdk.models.VerificationCreateResponse; PreludeClient client = PreludeOkHttpClient.fromEnv(); VerificationCreateParams params = VerificationCreateParams.builder() - .target(VerificationCreateParams.Target.builder() - .type(VerificationCreateParams.Target.Type.PHONE_NUMBER) + .target(Target.builder() + .type(Target.Type.PHONE_NUMBER) .value("+30123456789") .build()) .build(); @@ -174,6 +176,7 @@ Or create an asynchronous client from the beginning: import java.util.concurrent.CompletableFuture; import so.prelude.sdk.client.PreludeClientAsync; import so.prelude.sdk.client.okhttp.PreludeOkHttpClientAsync; +import so.prelude.sdk.models.Target; import so.prelude.sdk.models.VerificationCreateParams; import so.prelude.sdk.models.VerificationCreateResponse; @@ -182,8 +185,8 @@ import so.prelude.sdk.models.VerificationCreateResponse; PreludeClientAsync client = PreludeOkHttpClientAsync.fromEnv(); VerificationCreateParams params = VerificationCreateParams.builder() - .target(VerificationCreateParams.Target.builder() - .type(VerificationCreateParams.Target.Type.PHONE_NUMBER) + .target(Target.builder() + .type(Target.Type.PHONE_NUMBER) .value("+30123456789") .build()) .build(); @@ -201,12 +204,13 @@ To access this data, prefix any HTTP method call on a client or service with `wi ```java import so.prelude.sdk.core.http.Headers; import so.prelude.sdk.core.http.HttpResponseFor; +import so.prelude.sdk.models.Target; import so.prelude.sdk.models.VerificationCreateParams; import so.prelude.sdk.models.VerificationCreateResponse; VerificationCreateParams params = VerificationCreateParams.builder() - .target(VerificationCreateParams.Target.builder() - .type(VerificationCreateParams.Target.Type.PHONE_NUMBER) + .target(Target.builder() + .type(Target.Type.PHONE_NUMBER) .value("+30123456789") .build()) .build(); @@ -486,10 +490,11 @@ To set undocumented parameters on _nested_ headers, query params, or body classe ```java import so.prelude.sdk.core.JsonValue; +import so.prelude.sdk.models.Target; import so.prelude.sdk.models.VerificationCreateParams; VerificationCreateParams params = VerificationCreateParams.builder() - .target(VerificationCreateParams.Target.builder() + .target(Target.builder() .putAdditionalProperty("secretProperty", JsonValue.from("42")) .build()) .build(); @@ -597,9 +602,9 @@ To access a property's raw JSON value, which may be undocumented, call its `_` p ```java import java.util.Optional; import so.prelude.sdk.core.JsonField; -import so.prelude.sdk.models.VerificationCreateParams; +import so.prelude.sdk.models.Target; -JsonField target = client.verification().create(params)._target(); +JsonField target = client.verification().create(params)._target(); if (target.isMissing()) { // The property is absent from the JSON response diff --git a/build.gradle.kts b/build.gradle.kts index 9913f290..f2d0c2e9 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,7 +8,7 @@ repositories { allprojects { group = "so.prelude.sdk" - version = "0.14.0" // x-release-please-version + version = "0.15.0" // x-release-please-version } subprojects { diff --git a/prelude-java-core/src/main/kotlin/so/prelude/sdk/client/PreludeClient.kt b/prelude-java-core/src/main/kotlin/so/prelude/sdk/client/PreludeClient.kt index 278c33cf..b8026f85 100644 --- a/prelude-java-core/src/main/kotlin/so/prelude/sdk/client/PreludeClient.kt +++ b/prelude-java-core/src/main/kotlin/so/prelude/sdk/client/PreludeClient.kt @@ -4,6 +4,7 @@ package so.prelude.sdk.client import java.util.function.Consumer import so.prelude.sdk.core.ClientOptions +import so.prelude.sdk.services.blocking.IntelService import so.prelude.sdk.services.blocking.LookupService import so.prelude.sdk.services.blocking.NotifyService import so.prelude.sdk.services.blocking.TransactionalService @@ -68,6 +69,8 @@ interface PreludeClient { /** Evaluate email addresses and phone numbers for trustworthiness. */ fun watch(): WatchService + fun intel(): IntelService + /** * Closes this client, relinquishing any underlying resources. * @@ -111,5 +114,7 @@ interface PreludeClient { /** Evaluate email addresses and phone numbers for trustworthiness. */ fun watch(): WatchService.WithRawResponse + + fun intel(): IntelService.WithRawResponse } } diff --git a/prelude-java-core/src/main/kotlin/so/prelude/sdk/client/PreludeClientAsync.kt b/prelude-java-core/src/main/kotlin/so/prelude/sdk/client/PreludeClientAsync.kt index 2fd36276..25002405 100644 --- a/prelude-java-core/src/main/kotlin/so/prelude/sdk/client/PreludeClientAsync.kt +++ b/prelude-java-core/src/main/kotlin/so/prelude/sdk/client/PreludeClientAsync.kt @@ -4,6 +4,7 @@ package so.prelude.sdk.client import java.util.function.Consumer import so.prelude.sdk.core.ClientOptions +import so.prelude.sdk.services.async.IntelServiceAsync import so.prelude.sdk.services.async.LookupServiceAsync import so.prelude.sdk.services.async.NotifyServiceAsync import so.prelude.sdk.services.async.TransactionalServiceAsync @@ -68,6 +69,8 @@ interface PreludeClientAsync { /** Evaluate email addresses and phone numbers for trustworthiness. */ fun watch(): WatchServiceAsync + fun intel(): IntelServiceAsync + /** * Closes this client, relinquishing any underlying resources. * @@ -115,5 +118,7 @@ interface PreludeClientAsync { /** Evaluate email addresses and phone numbers for trustworthiness. */ fun watch(): WatchServiceAsync.WithRawResponse + + fun intel(): IntelServiceAsync.WithRawResponse } } diff --git a/prelude-java-core/src/main/kotlin/so/prelude/sdk/client/PreludeClientAsyncImpl.kt b/prelude-java-core/src/main/kotlin/so/prelude/sdk/client/PreludeClientAsyncImpl.kt index 2fab033f..9a1a1c18 100644 --- a/prelude-java-core/src/main/kotlin/so/prelude/sdk/client/PreludeClientAsyncImpl.kt +++ b/prelude-java-core/src/main/kotlin/so/prelude/sdk/client/PreludeClientAsyncImpl.kt @@ -5,6 +5,8 @@ package so.prelude.sdk.client import java.util.function.Consumer import so.prelude.sdk.core.ClientOptions import so.prelude.sdk.core.getPackageVersion +import so.prelude.sdk.services.async.IntelServiceAsync +import so.prelude.sdk.services.async.IntelServiceAsyncImpl import so.prelude.sdk.services.async.LookupServiceAsync import so.prelude.sdk.services.async.LookupServiceAsyncImpl import so.prelude.sdk.services.async.NotifyServiceAsync @@ -59,6 +61,10 @@ class PreludeClientAsyncImpl(private val clientOptions: ClientOptions) : Prelude WatchServiceAsyncImpl(clientOptionsWithUserAgent) } + private val intel: IntelServiceAsync by lazy { + IntelServiceAsyncImpl(clientOptionsWithUserAgent) + } + override fun sync(): PreludeClient = sync override fun withRawResponse(): PreludeClientAsync.WithRawResponse = withRawResponse @@ -88,6 +94,8 @@ class PreludeClientAsyncImpl(private val clientOptions: ClientOptions) : Prelude /** Evaluate email addresses and phone numbers for trustworthiness. */ override fun watch(): WatchServiceAsync = watch + override fun intel(): IntelServiceAsync = intel + override fun close() = clientOptions.close() class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : @@ -118,6 +126,10 @@ class PreludeClientAsyncImpl(private val clientOptions: ClientOptions) : Prelude WatchServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + private val intel: IntelServiceAsync.WithRawResponse by lazy { + IntelServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + override fun withOptions( modifier: Consumer ): PreludeClientAsync.WithRawResponse = @@ -146,5 +158,7 @@ class PreludeClientAsyncImpl(private val clientOptions: ClientOptions) : Prelude /** Evaluate email addresses and phone numbers for trustworthiness. */ override fun watch(): WatchServiceAsync.WithRawResponse = watch + + override fun intel(): IntelServiceAsync.WithRawResponse = intel } } diff --git a/prelude-java-core/src/main/kotlin/so/prelude/sdk/client/PreludeClientImpl.kt b/prelude-java-core/src/main/kotlin/so/prelude/sdk/client/PreludeClientImpl.kt index f3848303..9d0e26ea 100644 --- a/prelude-java-core/src/main/kotlin/so/prelude/sdk/client/PreludeClientImpl.kt +++ b/prelude-java-core/src/main/kotlin/so/prelude/sdk/client/PreludeClientImpl.kt @@ -5,6 +5,8 @@ package so.prelude.sdk.client import java.util.function.Consumer import so.prelude.sdk.core.ClientOptions import so.prelude.sdk.core.getPackageVersion +import so.prelude.sdk.services.blocking.IntelService +import so.prelude.sdk.services.blocking.IntelServiceImpl import so.prelude.sdk.services.blocking.LookupService import so.prelude.sdk.services.blocking.LookupServiceImpl import so.prelude.sdk.services.blocking.NotifyService @@ -53,6 +55,8 @@ class PreludeClientImpl(private val clientOptions: ClientOptions) : PreludeClien private val watch: WatchService by lazy { WatchServiceImpl(clientOptionsWithUserAgent) } + private val intel: IntelService by lazy { IntelServiceImpl(clientOptionsWithUserAgent) } + override fun async(): PreludeClientAsync = async override fun withRawResponse(): PreludeClient.WithRawResponse = withRawResponse @@ -81,6 +85,8 @@ class PreludeClientImpl(private val clientOptions: ClientOptions) : PreludeClien /** Evaluate email addresses and phone numbers for trustworthiness. */ override fun watch(): WatchService = watch + override fun intel(): IntelService = intel + override fun close() = clientOptions.close() class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : @@ -110,6 +116,10 @@ class PreludeClientImpl(private val clientOptions: ClientOptions) : PreludeClien WatchServiceImpl.WithRawResponseImpl(clientOptions) } + private val intel: IntelService.WithRawResponse by lazy { + IntelServiceImpl.WithRawResponseImpl(clientOptions) + } + override fun withOptions( modifier: Consumer ): PreludeClient.WithRawResponse = @@ -138,5 +148,7 @@ class PreludeClientImpl(private val clientOptions: ClientOptions) : PreludeClien /** Evaluate email addresses and phone numbers for trustworthiness. */ override fun watch(): WatchService.WithRawResponse = watch + + override fun intel(): IntelService.WithRawResponse = intel } } diff --git a/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/IntelKycMatchParams.kt b/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/IntelKycMatchParams.kt new file mode 100644 index 00000000..ea08364f --- /dev/null +++ b/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/IntelKycMatchParams.kt @@ -0,0 +1,973 @@ +// File generated from our OpenAPI spec by Stainless. + +package so.prelude.sdk.models + +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.LocalDate +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull +import so.prelude.sdk.core.ExcludeMissing +import so.prelude.sdk.core.JsonField +import so.prelude.sdk.core.JsonMissing +import so.prelude.sdk.core.JsonValue +import so.prelude.sdk.core.Params +import so.prelude.sdk.core.http.Headers +import so.prelude.sdk.core.http.QueryParams +import so.prelude.sdk.errors.PreludeInvalidDataException + +/** + * Verify identity attributes against the subscriber record held by the end-user's mobile operator. + * Send a phone number along with the attributes to check; Prelude resolves the operator internally + * and returns a per-attribute match. Currently available for France only (Orange, SFR, Bouygues) + * and must be enabled for your account. + */ +class IntelKycMatchParams +private constructor( + private val phone: String?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** An E.164 formatted phone number whose subscriber identity to match against. */ + fun phone(): Optional = Optional.ofNullable(phone) + + /** + * The street address. + * + * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun address(): Optional = body.address() + + /** + * The date of birth in ISO 8601 (`YYYY-MM-DD`) format. Compared exactly. + * + * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun birthdate(): Optional = body.birthdate() + + /** + * The ISO 3166-1 alpha-2 country code. Compared exactly. + * + * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun country(): Optional = body.country() + + /** + * The email address. + * + * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun email(): Optional = body.email() + + /** + * The end-user's family (last) name. + * + * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun familyName(): Optional = body.familyName() + + /** + * The end-user's given (first) name. + * + * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun givenName(): Optional = body.givenName() + + /** + * The locality (city). + * + * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun locality(): Optional = body.locality() + + /** + * The postal code. Compared exactly. + * + * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun postalCode(): Optional = body.postalCode() + + /** + * The region, state, or province. + * + * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun region(): Optional = body.region() + + /** + * Returns the raw JSON value of [address]. + * + * Unlike [address], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _address(): JsonField = body._address() + + /** + * Returns the raw JSON value of [birthdate]. + * + * Unlike [birthdate], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _birthdate(): JsonField = body._birthdate() + + /** + * Returns the raw JSON value of [country]. + * + * Unlike [country], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _country(): JsonField = body._country() + + /** + * Returns the raw JSON value of [email]. + * + * Unlike [email], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _email(): JsonField = body._email() + + /** + * Returns the raw JSON value of [familyName]. + * + * Unlike [familyName], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _familyName(): JsonField = body._familyName() + + /** + * Returns the raw JSON value of [givenName]. + * + * Unlike [givenName], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _givenName(): JsonField = body._givenName() + + /** + * Returns the raw JSON value of [locality]. + * + * Unlike [locality], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _locality(): JsonField = body._locality() + + /** + * Returns the raw JSON value of [postalCode]. + * + * Unlike [postalCode], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _postalCode(): JsonField = body._postalCode() + + /** + * Returns the raw JSON value of [region]. + * + * Unlike [region], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _region(): JsonField = body._region() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): IntelKycMatchParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [IntelKycMatchParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [IntelKycMatchParams]. */ + class Builder internal constructor() { + + private var phone: String? = null + 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(intelKycMatchParams: IntelKycMatchParams) = apply { + phone = intelKycMatchParams.phone + body = intelKycMatchParams.body.toBuilder() + additionalHeaders = intelKycMatchParams.additionalHeaders.toBuilder() + additionalQueryParams = intelKycMatchParams.additionalQueryParams.toBuilder() + } + + /** An E.164 formatted phone number whose subscriber identity to match against. */ + fun phone(phone: String?) = apply { this.phone = phone } + + /** Alias for calling [Builder.phone] with `phone.orElse(null)`. */ + fun phone(phone: Optional) = phone(phone.getOrNull()) + + /** + * 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: + * - [address] + * - [birthdate] + * - [country] + * - [email] + * - [familyName] + * - etc. + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** The street address. */ + fun address(address: String) = apply { body.address(address) } + + /** + * Sets [Builder.address] to an arbitrary JSON value. + * + * You should usually call [Builder.address] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun address(address: JsonField) = apply { body.address(address) } + + /** The date of birth in ISO 8601 (`YYYY-MM-DD`) format. Compared exactly. */ + fun birthdate(birthdate: LocalDate) = apply { body.birthdate(birthdate) } + + /** + * Sets [Builder.birthdate] to an arbitrary JSON value. + * + * You should usually call [Builder.birthdate] with a well-typed [LocalDate] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun birthdate(birthdate: JsonField) = apply { body.birthdate(birthdate) } + + /** The ISO 3166-1 alpha-2 country code. Compared exactly. */ + fun country(country: String) = apply { body.country(country) } + + /** + * Sets [Builder.country] to an arbitrary JSON value. + * + * You should usually call [Builder.country] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun country(country: JsonField) = apply { body.country(country) } + + /** The email address. */ + fun email(email: String) = apply { body.email(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 { body.email(email) } + + /** The end-user's family (last) name. */ + fun familyName(familyName: String) = apply { body.familyName(familyName) } + + /** + * Sets [Builder.familyName] to an arbitrary JSON value. + * + * You should usually call [Builder.familyName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun familyName(familyName: JsonField) = apply { body.familyName(familyName) } + + /** The end-user's given (first) name. */ + fun givenName(givenName: String) = apply { body.givenName(givenName) } + + /** + * Sets [Builder.givenName] to an arbitrary JSON value. + * + * You should usually call [Builder.givenName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun givenName(givenName: JsonField) = apply { body.givenName(givenName) } + + /** The locality (city). */ + fun locality(locality: String) = apply { body.locality(locality) } + + /** + * Sets [Builder.locality] to an arbitrary JSON value. + * + * You should usually call [Builder.locality] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun locality(locality: JsonField) = apply { body.locality(locality) } + + /** The postal code. Compared exactly. */ + fun postalCode(postalCode: String) = apply { body.postalCode(postalCode) } + + /** + * Sets [Builder.postalCode] to an arbitrary JSON value. + * + * You should usually call [Builder.postalCode] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun postalCode(postalCode: JsonField) = apply { body.postalCode(postalCode) } + + /** The region, state, or province. */ + fun region(region: String) = apply { body.region(region) } + + /** + * Sets [Builder.region] to an arbitrary JSON value. + * + * You should usually call [Builder.region] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun region(region: JsonField) = apply { body.region(region) } + + 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 [IntelKycMatchParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): IntelKycMatchParams = + IntelKycMatchParams( + phone, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> phone ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + /** + * The identity attributes to verify. Only the fields you want checked need to be sent; at least + * one attribute is required. Each operator can answer a subset of these attributes - any + * attribute the operator does not support resolves to `not_available` rather than `false`. + */ + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val address: JsonField, + private val birthdate: JsonField, + private val country: JsonField, + private val email: JsonField, + private val familyName: JsonField, + private val givenName: JsonField, + private val locality: JsonField, + private val postalCode: JsonField, + private val region: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("address") @ExcludeMissing address: JsonField = JsonMissing.of(), + @JsonProperty("birthdate") + @ExcludeMissing + birthdate: JsonField = JsonMissing.of(), + @JsonProperty("country") @ExcludeMissing country: JsonField = JsonMissing.of(), + @JsonProperty("email") @ExcludeMissing email: JsonField = JsonMissing.of(), + @JsonProperty("family_name") + @ExcludeMissing + familyName: JsonField = JsonMissing.of(), + @JsonProperty("given_name") + @ExcludeMissing + givenName: JsonField = JsonMissing.of(), + @JsonProperty("locality") + @ExcludeMissing + locality: JsonField = JsonMissing.of(), + @JsonProperty("postal_code") + @ExcludeMissing + postalCode: JsonField = JsonMissing.of(), + @JsonProperty("region") @ExcludeMissing region: JsonField = JsonMissing.of(), + ) : this( + address, + birthdate, + country, + email, + familyName, + givenName, + locality, + postalCode, + region, + mutableMapOf(), + ) + + /** + * The street address. + * + * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun address(): Optional = address.getOptional("address") + + /** + * The date of birth in ISO 8601 (`YYYY-MM-DD`) format. Compared exactly. + * + * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun birthdate(): Optional = birthdate.getOptional("birthdate") + + /** + * The ISO 3166-1 alpha-2 country code. Compared exactly. + * + * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun country(): Optional = country.getOptional("country") + + /** + * The email address. + * + * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun email(): Optional = email.getOptional("email") + + /** + * The end-user's family (last) name. + * + * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun familyName(): Optional = familyName.getOptional("family_name") + + /** + * The end-user's given (first) name. + * + * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun givenName(): Optional = givenName.getOptional("given_name") + + /** + * The locality (city). + * + * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun locality(): Optional = locality.getOptional("locality") + + /** + * The postal code. Compared exactly. + * + * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun postalCode(): Optional = postalCode.getOptional("postal_code") + + /** + * The region, state, or province. + * + * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun region(): Optional = region.getOptional("region") + + /** + * Returns the raw JSON value of [address]. + * + * Unlike [address], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("address") @ExcludeMissing fun _address(): JsonField = address + + /** + * Returns the raw JSON value of [birthdate]. + * + * Unlike [birthdate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("birthdate") + @ExcludeMissing + fun _birthdate(): JsonField = birthdate + + /** + * Returns the raw JSON value of [country]. + * + * Unlike [country], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("country") @ExcludeMissing fun _country(): JsonField = country + + /** + * 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 [familyName]. + * + * Unlike [familyName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("family_name") + @ExcludeMissing + fun _familyName(): JsonField = familyName + + /** + * Returns the raw JSON value of [givenName]. + * + * Unlike [givenName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("given_name") @ExcludeMissing fun _givenName(): JsonField = givenName + + /** + * Returns the raw JSON value of [locality]. + * + * Unlike [locality], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("locality") @ExcludeMissing fun _locality(): JsonField = locality + + /** + * Returns the raw JSON value of [postalCode]. + * + * Unlike [postalCode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("postal_code") + @ExcludeMissing + fun _postalCode(): JsonField = postalCode + + /** + * Returns the raw JSON value of [region]. + * + * Unlike [region], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("region") @ExcludeMissing fun _region(): JsonField = region + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Body]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var address: JsonField = JsonMissing.of() + private var birthdate: JsonField = JsonMissing.of() + private var country: JsonField = JsonMissing.of() + private var email: JsonField = JsonMissing.of() + private var familyName: JsonField = JsonMissing.of() + private var givenName: JsonField = JsonMissing.of() + private var locality: JsonField = JsonMissing.of() + private var postalCode: JsonField = JsonMissing.of() + private var region: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + address = body.address + birthdate = body.birthdate + country = body.country + email = body.email + familyName = body.familyName + givenName = body.givenName + locality = body.locality + postalCode = body.postalCode + region = body.region + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** The street address. */ + fun address(address: String) = address(JsonField.of(address)) + + /** + * Sets [Builder.address] to an arbitrary JSON value. + * + * You should usually call [Builder.address] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun address(address: JsonField) = apply { this.address = address } + + /** The date of birth in ISO 8601 (`YYYY-MM-DD`) format. Compared exactly. */ + fun birthdate(birthdate: LocalDate) = birthdate(JsonField.of(birthdate)) + + /** + * Sets [Builder.birthdate] to an arbitrary JSON value. + * + * You should usually call [Builder.birthdate] with a well-typed [LocalDate] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun birthdate(birthdate: JsonField) = apply { this.birthdate = birthdate } + + /** The ISO 3166-1 alpha-2 country code. Compared exactly. */ + fun country(country: String) = country(JsonField.of(country)) + + /** + * Sets [Builder.country] to an arbitrary JSON value. + * + * You should usually call [Builder.country] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun country(country: JsonField) = apply { this.country = country } + + /** The email address. */ + 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 } + + /** The end-user's family (last) name. */ + fun familyName(familyName: String) = familyName(JsonField.of(familyName)) + + /** + * Sets [Builder.familyName] to an arbitrary JSON value. + * + * You should usually call [Builder.familyName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun familyName(familyName: JsonField) = apply { this.familyName = familyName } + + /** The end-user's given (first) name. */ + fun givenName(givenName: String) = givenName(JsonField.of(givenName)) + + /** + * Sets [Builder.givenName] to an arbitrary JSON value. + * + * You should usually call [Builder.givenName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun givenName(givenName: JsonField) = apply { this.givenName = givenName } + + /** The locality (city). */ + fun locality(locality: String) = locality(JsonField.of(locality)) + + /** + * Sets [Builder.locality] to an arbitrary JSON value. + * + * You should usually call [Builder.locality] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun locality(locality: JsonField) = apply { this.locality = locality } + + /** The postal code. Compared exactly. */ + fun postalCode(postalCode: String) = postalCode(JsonField.of(postalCode)) + + /** + * Sets [Builder.postalCode] to an arbitrary JSON value. + * + * You should usually call [Builder.postalCode] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun postalCode(postalCode: JsonField) = apply { this.postalCode = postalCode } + + /** The region, state, or province. */ + fun region(region: String) = region(JsonField.of(region)) + + /** + * Sets [Builder.region] to an arbitrary JSON value. + * + * You should usually call [Builder.region] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun region(region: JsonField) = apply { this.region = region } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Body = + Body( + address, + birthdate, + country, + email, + familyName, + givenName, + locality, + postalCode, + region, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws PreludeInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Body = apply { + if (validated) { + return@apply + } + + address() + birthdate() + country() + email() + familyName() + givenName() + locality() + postalCode() + region() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: PreludeInvalidDataException) { + 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 (address.asKnown().isPresent) 1 else 0) + + (if (birthdate.asKnown().isPresent) 1 else 0) + + (if (country.asKnown().isPresent) 1 else 0) + + (if (email.asKnown().isPresent) 1 else 0) + + (if (familyName.asKnown().isPresent) 1 else 0) + + (if (givenName.asKnown().isPresent) 1 else 0) + + (if (locality.asKnown().isPresent) 1 else 0) + + (if (postalCode.asKnown().isPresent) 1 else 0) + + (if (region.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + address == other.address && + birthdate == other.birthdate && + country == other.country && + email == other.email && + familyName == other.familyName && + givenName == other.givenName && + locality == other.locality && + postalCode == other.postalCode && + region == other.region && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + address, + birthdate, + country, + email, + familyName, + givenName, + locality, + postalCode, + region, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{address=$address, birthdate=$birthdate, country=$country, email=$email, familyName=$familyName, givenName=$givenName, locality=$locality, postalCode=$postalCode, region=$region, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is IntelKycMatchParams && + phone == other.phone && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(phone, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "IntelKycMatchParams{phone=$phone, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/IntelKycMatchResponse.kt b/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/IntelKycMatchResponse.kt new file mode 100644 index 00000000..07c5a856 --- /dev/null +++ b/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/IntelKycMatchResponse.kt @@ -0,0 +1,2274 @@ +// File generated from our OpenAPI spec by Stainless. + +package so.prelude.sdk.models + +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 +import so.prelude.sdk.core.Enum +import so.prelude.sdk.core.ExcludeMissing +import so.prelude.sdk.core.JsonField +import so.prelude.sdk.core.JsonMissing +import so.prelude.sdk.core.JsonValue +import so.prelude.sdk.errors.PreludeInvalidDataException + +/** + * The per-attribute match result. Each `_match` field is one of `true`, `false`, or + * `not_available` (the operator could not answer for that attribute). Fuzzy attributes additionally + * return a `_match_score` (0-99 similarity) when they do not match exactly; the score is + * omitted on a match or when `not_available`. + */ +class IntelKycMatchResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val addressMatch: JsonField, + private val addressMatchScore: JsonField, + private val birthdateMatch: JsonField, + private val countryCode: JsonField, + private val countryMatch: JsonField, + private val emailMatch: JsonField, + private val emailMatchScore: JsonField, + private val familyNameMatch: JsonField, + private val familyNameMatchScore: JsonField, + private val givenNameMatch: JsonField, + private val givenNameMatchScore: JsonField, + private val localityMatch: JsonField, + private val localityMatchScore: JsonField, + private val operator: JsonField, + private val phoneNumber: JsonField, + private val postalCodeMatch: JsonField, + private val regionMatch: JsonField, + private val regionMatchScore: JsonField, + private val requestId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("address_match") + @ExcludeMissing + addressMatch: JsonField = JsonMissing.of(), + @JsonProperty("address_match_score") + @ExcludeMissing + addressMatchScore: JsonField = JsonMissing.of(), + @JsonProperty("birthdate_match") + @ExcludeMissing + birthdateMatch: JsonField = JsonMissing.of(), + @JsonProperty("country_code") + @ExcludeMissing + countryCode: JsonField = JsonMissing.of(), + @JsonProperty("country_match") + @ExcludeMissing + countryMatch: JsonField = JsonMissing.of(), + @JsonProperty("email_match") + @ExcludeMissing + emailMatch: JsonField = JsonMissing.of(), + @JsonProperty("email_match_score") + @ExcludeMissing + emailMatchScore: JsonField = JsonMissing.of(), + @JsonProperty("family_name_match") + @ExcludeMissing + familyNameMatch: JsonField = JsonMissing.of(), + @JsonProperty("family_name_match_score") + @ExcludeMissing + familyNameMatchScore: JsonField = JsonMissing.of(), + @JsonProperty("given_name_match") + @ExcludeMissing + givenNameMatch: JsonField = JsonMissing.of(), + @JsonProperty("given_name_match_score") + @ExcludeMissing + givenNameMatchScore: JsonField = JsonMissing.of(), + @JsonProperty("locality_match") + @ExcludeMissing + localityMatch: JsonField = JsonMissing.of(), + @JsonProperty("locality_match_score") + @ExcludeMissing + localityMatchScore: JsonField = JsonMissing.of(), + @JsonProperty("operator") @ExcludeMissing operator: JsonField = JsonMissing.of(), + @JsonProperty("phone_number") + @ExcludeMissing + phoneNumber: JsonField = JsonMissing.of(), + @JsonProperty("postal_code_match") + @ExcludeMissing + postalCodeMatch: JsonField = JsonMissing.of(), + @JsonProperty("region_match") + @ExcludeMissing + regionMatch: JsonField = JsonMissing.of(), + @JsonProperty("region_match_score") + @ExcludeMissing + regionMatchScore: JsonField = JsonMissing.of(), + @JsonProperty("request_id") @ExcludeMissing requestId: JsonField = JsonMissing.of(), + ) : this( + addressMatch, + addressMatchScore, + birthdateMatch, + countryCode, + countryMatch, + emailMatch, + emailMatchScore, + familyNameMatch, + familyNameMatchScore, + givenNameMatch, + givenNameMatchScore, + localityMatch, + localityMatchScore, + operator, + phoneNumber, + postalCodeMatch, + regionMatch, + regionMatchScore, + requestId, + mutableMapOf(), + ) + + /** + * Whether the street address matched the operator's record. + * + * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun addressMatch(): Optional = addressMatch.getOptional("address_match") + + /** + * Similarity score (0-99) for the address. Returned only on a non-match. + * + * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun addressMatchScore(): Optional = addressMatchScore.getOptional("address_match_score") + + /** + * Whether the date of birth matched the operator's record. Compared exactly; never scored. + * + * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun birthdateMatch(): Optional = birthdateMatch.getOptional("birthdate_match") + + /** + * The country code of the phone number. + * + * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun countryCode(): Optional = countryCode.getOptional("country_code") + + /** + * Whether the country matched the operator's record. Compared exactly; never scored. + * + * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun countryMatch(): Optional = countryMatch.getOptional("country_match") + + /** + * Whether the email address matched the operator's record. + * + * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun emailMatch(): Optional = emailMatch.getOptional("email_match") + + /** + * Similarity score (0-99) for the email. Returned only on a non-match. + * + * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun emailMatchScore(): Optional = emailMatchScore.getOptional("email_match_score") + + /** + * Whether the family name matched the operator's record. + * + * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun familyNameMatch(): Optional = + familyNameMatch.getOptional("family_name_match") + + /** + * Similarity score (0-99) for the family name. Returned only on a non-match. + * + * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun familyNameMatchScore(): Optional = + familyNameMatchScore.getOptional("family_name_match_score") + + /** + * Whether the given name matched the operator's record. + * + * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun givenNameMatch(): Optional = givenNameMatch.getOptional("given_name_match") + + /** + * Similarity score (0-99) for the given name. Returned only on a non-match. + * + * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun givenNameMatchScore(): Optional = + givenNameMatchScore.getOptional("given_name_match_score") + + /** + * Whether the locality matched the operator's record. + * + * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun localityMatch(): Optional = localityMatch.getOptional("locality_match") + + /** + * Similarity score (0-99) for the locality. Returned only on a non-match. + * + * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun localityMatchScore(): Optional = + localityMatchScore.getOptional("locality_match_score") + + /** + * The mobile operator that answered the match. + * + * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun operator(): Optional = operator.getOptional("operator") + + /** + * The phone number that was matched, in E.164 format. + * + * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun phoneNumber(): Optional = phoneNumber.getOptional("phone_number") + + /** + * Whether the postal code matched the operator's record. Compared exactly; never scored. + * + * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun postalCodeMatch(): Optional = + postalCodeMatch.getOptional("postal_code_match") + + /** + * Whether the region matched the operator's record. + * + * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun regionMatch(): Optional = regionMatch.getOptional("region_match") + + /** + * Similarity score (0-99) for the region. Returned only on a non-match. + * + * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun regionMatchScore(): Optional = regionMatchScore.getOptional("region_match_score") + + /** + * A string that identifies this specific request. Report it back to us to help us diagnose your + * issues. + * + * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun requestId(): Optional = requestId.getOptional("request_id") + + /** + * Returns the raw JSON value of [addressMatch]. + * + * Unlike [addressMatch], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("address_match") + @ExcludeMissing + fun _addressMatch(): JsonField = addressMatch + + /** + * Returns the raw JSON value of [addressMatchScore]. + * + * Unlike [addressMatchScore], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("address_match_score") + @ExcludeMissing + fun _addressMatchScore(): JsonField = addressMatchScore + + /** + * Returns the raw JSON value of [birthdateMatch]. + * + * Unlike [birthdateMatch], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("birthdate_match") + @ExcludeMissing + fun _birthdateMatch(): JsonField = birthdateMatch + + /** + * Returns the raw JSON value of [countryCode]. + * + * Unlike [countryCode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("country_code") + @ExcludeMissing + fun _countryCode(): JsonField = countryCode + + /** + * Returns the raw JSON value of [countryMatch]. + * + * Unlike [countryMatch], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("country_match") + @ExcludeMissing + fun _countryMatch(): JsonField = countryMatch + + /** + * Returns the raw JSON value of [emailMatch]. + * + * Unlike [emailMatch], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("email_match") + @ExcludeMissing + fun _emailMatch(): JsonField = emailMatch + + /** + * Returns the raw JSON value of [emailMatchScore]. + * + * Unlike [emailMatchScore], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("email_match_score") + @ExcludeMissing + fun _emailMatchScore(): JsonField = emailMatchScore + + /** + * Returns the raw JSON value of [familyNameMatch]. + * + * Unlike [familyNameMatch], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("family_name_match") + @ExcludeMissing + fun _familyNameMatch(): JsonField = familyNameMatch + + /** + * Returns the raw JSON value of [familyNameMatchScore]. + * + * Unlike [familyNameMatchScore], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("family_name_match_score") + @ExcludeMissing + fun _familyNameMatchScore(): JsonField = familyNameMatchScore + + /** + * Returns the raw JSON value of [givenNameMatch]. + * + * Unlike [givenNameMatch], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("given_name_match") + @ExcludeMissing + fun _givenNameMatch(): JsonField = givenNameMatch + + /** + * Returns the raw JSON value of [givenNameMatchScore]. + * + * Unlike [givenNameMatchScore], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("given_name_match_score") + @ExcludeMissing + fun _givenNameMatchScore(): JsonField = givenNameMatchScore + + /** + * Returns the raw JSON value of [localityMatch]. + * + * Unlike [localityMatch], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("locality_match") + @ExcludeMissing + fun _localityMatch(): JsonField = localityMatch + + /** + * Returns the raw JSON value of [localityMatchScore]. + * + * Unlike [localityMatchScore], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("locality_match_score") + @ExcludeMissing + fun _localityMatchScore(): JsonField = localityMatchScore + + /** + * Returns the raw JSON value of [operator]. + * + * Unlike [operator], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("operator") @ExcludeMissing fun _operator(): JsonField = operator + + /** + * Returns the raw JSON value of [phoneNumber]. + * + * Unlike [phoneNumber], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("phone_number") + @ExcludeMissing + fun _phoneNumber(): JsonField = phoneNumber + + /** + * Returns the raw JSON value of [postalCodeMatch]. + * + * Unlike [postalCodeMatch], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("postal_code_match") + @ExcludeMissing + fun _postalCodeMatch(): JsonField = postalCodeMatch + + /** + * Returns the raw JSON value of [regionMatch]. + * + * Unlike [regionMatch], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("region_match") + @ExcludeMissing + fun _regionMatch(): JsonField = regionMatch + + /** + * Returns the raw JSON value of [regionMatchScore]. + * + * Unlike [regionMatchScore], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("region_match_score") + @ExcludeMissing + fun _regionMatchScore(): JsonField = regionMatchScore + + /** + * Returns the raw JSON value of [requestId]. + * + * Unlike [requestId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("request_id") @ExcludeMissing fun _requestId(): JsonField = requestId + + @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 [IntelKycMatchResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [IntelKycMatchResponse]. */ + class Builder internal constructor() { + + private var addressMatch: JsonField = JsonMissing.of() + private var addressMatchScore: JsonField = JsonMissing.of() + private var birthdateMatch: JsonField = JsonMissing.of() + private var countryCode: JsonField = JsonMissing.of() + private var countryMatch: JsonField = JsonMissing.of() + private var emailMatch: JsonField = JsonMissing.of() + private var emailMatchScore: JsonField = JsonMissing.of() + private var familyNameMatch: JsonField = JsonMissing.of() + private var familyNameMatchScore: JsonField = JsonMissing.of() + private var givenNameMatch: JsonField = JsonMissing.of() + private var givenNameMatchScore: JsonField = JsonMissing.of() + private var localityMatch: JsonField = JsonMissing.of() + private var localityMatchScore: JsonField = JsonMissing.of() + private var operator: JsonField = JsonMissing.of() + private var phoneNumber: JsonField = JsonMissing.of() + private var postalCodeMatch: JsonField = JsonMissing.of() + private var regionMatch: JsonField = JsonMissing.of() + private var regionMatchScore: JsonField = JsonMissing.of() + private var requestId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(intelKycMatchResponse: IntelKycMatchResponse) = apply { + addressMatch = intelKycMatchResponse.addressMatch + addressMatchScore = intelKycMatchResponse.addressMatchScore + birthdateMatch = intelKycMatchResponse.birthdateMatch + countryCode = intelKycMatchResponse.countryCode + countryMatch = intelKycMatchResponse.countryMatch + emailMatch = intelKycMatchResponse.emailMatch + emailMatchScore = intelKycMatchResponse.emailMatchScore + familyNameMatch = intelKycMatchResponse.familyNameMatch + familyNameMatchScore = intelKycMatchResponse.familyNameMatchScore + givenNameMatch = intelKycMatchResponse.givenNameMatch + givenNameMatchScore = intelKycMatchResponse.givenNameMatchScore + localityMatch = intelKycMatchResponse.localityMatch + localityMatchScore = intelKycMatchResponse.localityMatchScore + operator = intelKycMatchResponse.operator + phoneNumber = intelKycMatchResponse.phoneNumber + postalCodeMatch = intelKycMatchResponse.postalCodeMatch + regionMatch = intelKycMatchResponse.regionMatch + regionMatchScore = intelKycMatchResponse.regionMatchScore + requestId = intelKycMatchResponse.requestId + additionalProperties = intelKycMatchResponse.additionalProperties.toMutableMap() + } + + /** Whether the street address matched the operator's record. */ + fun addressMatch(addressMatch: AddressMatch) = addressMatch(JsonField.of(addressMatch)) + + /** + * Sets [Builder.addressMatch] to an arbitrary JSON value. + * + * You should usually call [Builder.addressMatch] with a well-typed [AddressMatch] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun addressMatch(addressMatch: JsonField) = apply { + this.addressMatch = addressMatch + } + + /** Similarity score (0-99) for the address. Returned only on a non-match. */ + fun addressMatchScore(addressMatchScore: Long) = + addressMatchScore(JsonField.of(addressMatchScore)) + + /** + * Sets [Builder.addressMatchScore] to an arbitrary JSON value. + * + * You should usually call [Builder.addressMatchScore] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun addressMatchScore(addressMatchScore: JsonField) = apply { + this.addressMatchScore = addressMatchScore + } + + /** + * Whether the date of birth matched the operator's record. Compared exactly; never scored. + */ + fun birthdateMatch(birthdateMatch: BirthdateMatch) = + birthdateMatch(JsonField.of(birthdateMatch)) + + /** + * Sets [Builder.birthdateMatch] to an arbitrary JSON value. + * + * You should usually call [Builder.birthdateMatch] with a well-typed [BirthdateMatch] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun birthdateMatch(birthdateMatch: JsonField) = apply { + this.birthdateMatch = birthdateMatch + } + + /** The country code of the phone number. */ + fun countryCode(countryCode: String) = countryCode(JsonField.of(countryCode)) + + /** + * Sets [Builder.countryCode] to an arbitrary JSON value. + * + * You should usually call [Builder.countryCode] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun countryCode(countryCode: JsonField) = apply { this.countryCode = countryCode } + + /** Whether the country matched the operator's record. Compared exactly; never scored. */ + fun countryMatch(countryMatch: CountryMatch) = countryMatch(JsonField.of(countryMatch)) + + /** + * Sets [Builder.countryMatch] to an arbitrary JSON value. + * + * You should usually call [Builder.countryMatch] with a well-typed [CountryMatch] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun countryMatch(countryMatch: JsonField) = apply { + this.countryMatch = countryMatch + } + + /** Whether the email address matched the operator's record. */ + fun emailMatch(emailMatch: EmailMatch) = emailMatch(JsonField.of(emailMatch)) + + /** + * Sets [Builder.emailMatch] to an arbitrary JSON value. + * + * You should usually call [Builder.emailMatch] with a well-typed [EmailMatch] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun emailMatch(emailMatch: JsonField) = apply { this.emailMatch = emailMatch } + + /** Similarity score (0-99) for the email. Returned only on a non-match. */ + fun emailMatchScore(emailMatchScore: Long) = emailMatchScore(JsonField.of(emailMatchScore)) + + /** + * Sets [Builder.emailMatchScore] to an arbitrary JSON value. + * + * You should usually call [Builder.emailMatchScore] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun emailMatchScore(emailMatchScore: JsonField) = apply { + this.emailMatchScore = emailMatchScore + } + + /** Whether the family name matched the operator's record. */ + fun familyNameMatch(familyNameMatch: FamilyNameMatch) = + familyNameMatch(JsonField.of(familyNameMatch)) + + /** + * Sets [Builder.familyNameMatch] to an arbitrary JSON value. + * + * You should usually call [Builder.familyNameMatch] with a well-typed [FamilyNameMatch] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun familyNameMatch(familyNameMatch: JsonField) = apply { + this.familyNameMatch = familyNameMatch + } + + /** Similarity score (0-99) for the family name. Returned only on a non-match. */ + fun familyNameMatchScore(familyNameMatchScore: Long) = + familyNameMatchScore(JsonField.of(familyNameMatchScore)) + + /** + * Sets [Builder.familyNameMatchScore] to an arbitrary JSON value. + * + * You should usually call [Builder.familyNameMatchScore] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun familyNameMatchScore(familyNameMatchScore: JsonField) = apply { + this.familyNameMatchScore = familyNameMatchScore + } + + /** Whether the given name matched the operator's record. */ + fun givenNameMatch(givenNameMatch: GivenNameMatch) = + givenNameMatch(JsonField.of(givenNameMatch)) + + /** + * Sets [Builder.givenNameMatch] to an arbitrary JSON value. + * + * You should usually call [Builder.givenNameMatch] with a well-typed [GivenNameMatch] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun givenNameMatch(givenNameMatch: JsonField) = apply { + this.givenNameMatch = givenNameMatch + } + + /** Similarity score (0-99) for the given name. Returned only on a non-match. */ + fun givenNameMatchScore(givenNameMatchScore: Long) = + givenNameMatchScore(JsonField.of(givenNameMatchScore)) + + /** + * Sets [Builder.givenNameMatchScore] to an arbitrary JSON value. + * + * You should usually call [Builder.givenNameMatchScore] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun givenNameMatchScore(givenNameMatchScore: JsonField) = apply { + this.givenNameMatchScore = givenNameMatchScore + } + + /** Whether the locality matched the operator's record. */ + fun localityMatch(localityMatch: LocalityMatch) = localityMatch(JsonField.of(localityMatch)) + + /** + * Sets [Builder.localityMatch] to an arbitrary JSON value. + * + * You should usually call [Builder.localityMatch] with a well-typed [LocalityMatch] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun localityMatch(localityMatch: JsonField) = apply { + this.localityMatch = localityMatch + } + + /** Similarity score (0-99) for the locality. Returned only on a non-match. */ + fun localityMatchScore(localityMatchScore: Long) = + localityMatchScore(JsonField.of(localityMatchScore)) + + /** + * Sets [Builder.localityMatchScore] to an arbitrary JSON value. + * + * You should usually call [Builder.localityMatchScore] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun localityMatchScore(localityMatchScore: JsonField) = apply { + this.localityMatchScore = localityMatchScore + } + + /** The mobile operator that answered the match. */ + fun operator(operator: String) = operator(JsonField.of(operator)) + + /** + * Sets [Builder.operator] to an arbitrary JSON value. + * + * You should usually call [Builder.operator] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun operator(operator: JsonField) = apply { this.operator = operator } + + /** The phone number that was matched, in E.164 format. */ + fun phoneNumber(phoneNumber: String) = phoneNumber(JsonField.of(phoneNumber)) + + /** + * Sets [Builder.phoneNumber] to an arbitrary JSON value. + * + * You should usually call [Builder.phoneNumber] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun phoneNumber(phoneNumber: JsonField) = apply { this.phoneNumber = phoneNumber } + + /** + * Whether the postal code matched the operator's record. Compared exactly; never scored. + */ + fun postalCodeMatch(postalCodeMatch: PostalCodeMatch) = + postalCodeMatch(JsonField.of(postalCodeMatch)) + + /** + * Sets [Builder.postalCodeMatch] to an arbitrary JSON value. + * + * You should usually call [Builder.postalCodeMatch] with a well-typed [PostalCodeMatch] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun postalCodeMatch(postalCodeMatch: JsonField) = apply { + this.postalCodeMatch = postalCodeMatch + } + + /** Whether the region matched the operator's record. */ + fun regionMatch(regionMatch: RegionMatch) = regionMatch(JsonField.of(regionMatch)) + + /** + * Sets [Builder.regionMatch] to an arbitrary JSON value. + * + * You should usually call [Builder.regionMatch] with a well-typed [RegionMatch] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun regionMatch(regionMatch: JsonField) = apply { + this.regionMatch = regionMatch + } + + /** Similarity score (0-99) for the region. Returned only on a non-match. */ + fun regionMatchScore(regionMatchScore: Long) = + regionMatchScore(JsonField.of(regionMatchScore)) + + /** + * Sets [Builder.regionMatchScore] to an arbitrary JSON value. + * + * You should usually call [Builder.regionMatchScore] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun regionMatchScore(regionMatchScore: JsonField) = apply { + this.regionMatchScore = regionMatchScore + } + + /** + * A string that identifies this specific request. Report it back to us to help us diagnose + * your issues. + */ + fun requestId(requestId: String) = requestId(JsonField.of(requestId)) + + /** + * Sets [Builder.requestId] to an arbitrary JSON value. + * + * You should usually call [Builder.requestId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun requestId(requestId: JsonField) = apply { this.requestId = requestId } + + 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 [IntelKycMatchResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): IntelKycMatchResponse = + IntelKycMatchResponse( + addressMatch, + addressMatchScore, + birthdateMatch, + countryCode, + countryMatch, + emailMatch, + emailMatchScore, + familyNameMatch, + familyNameMatchScore, + givenNameMatch, + givenNameMatchScore, + localityMatch, + localityMatchScore, + operator, + phoneNumber, + postalCodeMatch, + regionMatch, + regionMatchScore, + requestId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws PreludeInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): IntelKycMatchResponse = apply { + if (validated) { + return@apply + } + + addressMatch().ifPresent { it.validate() } + addressMatchScore() + birthdateMatch().ifPresent { it.validate() } + countryCode() + countryMatch().ifPresent { it.validate() } + emailMatch().ifPresent { it.validate() } + emailMatchScore() + familyNameMatch().ifPresent { it.validate() } + familyNameMatchScore() + givenNameMatch().ifPresent { it.validate() } + givenNameMatchScore() + localityMatch().ifPresent { it.validate() } + localityMatchScore() + operator() + phoneNumber() + postalCodeMatch().ifPresent { it.validate() } + regionMatch().ifPresent { it.validate() } + regionMatchScore() + requestId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: PreludeInvalidDataException) { + 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 = + (addressMatch.asKnown().getOrNull()?.validity() ?: 0) + + (if (addressMatchScore.asKnown().isPresent) 1 else 0) + + (birthdateMatch.asKnown().getOrNull()?.validity() ?: 0) + + (if (countryCode.asKnown().isPresent) 1 else 0) + + (countryMatch.asKnown().getOrNull()?.validity() ?: 0) + + (emailMatch.asKnown().getOrNull()?.validity() ?: 0) + + (if (emailMatchScore.asKnown().isPresent) 1 else 0) + + (familyNameMatch.asKnown().getOrNull()?.validity() ?: 0) + + (if (familyNameMatchScore.asKnown().isPresent) 1 else 0) + + (givenNameMatch.asKnown().getOrNull()?.validity() ?: 0) + + (if (givenNameMatchScore.asKnown().isPresent) 1 else 0) + + (localityMatch.asKnown().getOrNull()?.validity() ?: 0) + + (if (localityMatchScore.asKnown().isPresent) 1 else 0) + + (if (operator.asKnown().isPresent) 1 else 0) + + (if (phoneNumber.asKnown().isPresent) 1 else 0) + + (postalCodeMatch.asKnown().getOrNull()?.validity() ?: 0) + + (regionMatch.asKnown().getOrNull()?.validity() ?: 0) + + (if (regionMatchScore.asKnown().isPresent) 1 else 0) + + (if (requestId.asKnown().isPresent) 1 else 0) + + /** Whether the street address matched the operator's record. */ + class AddressMatch @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 TRUE = of("true") + + @JvmField val FALSE = of("false") + + @JvmField val NOT_AVAILABLE = of("not_available") + + @JvmStatic fun of(value: String) = AddressMatch(JsonField.of(value)) + } + + /** An enum containing [AddressMatch]'s known values. */ + enum class Known { + TRUE, + FALSE, + NOT_AVAILABLE, + } + + /** + * An enum containing [AddressMatch]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [AddressMatch] 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 { + TRUE, + FALSE, + NOT_AVAILABLE, + /** + * An enum member indicating that [AddressMatch] 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) { + TRUE -> Value.TRUE + FALSE -> Value.FALSE + NOT_AVAILABLE -> Value.NOT_AVAILABLE + 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 PreludeInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + TRUE -> Known.TRUE + FALSE -> Known.FALSE + NOT_AVAILABLE -> Known.NOT_AVAILABLE + else -> throw PreludeInvalidDataException("Unknown AddressMatch: $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 PreludeInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { PreludeInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws PreludeInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): AddressMatch = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: PreludeInvalidDataException) { + 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 AddressMatch && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Whether the date of birth matched the operator's record. Compared exactly; never scored. */ + class BirthdateMatch @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 TRUE = of("true") + + @JvmField val FALSE = of("false") + + @JvmField val NOT_AVAILABLE = of("not_available") + + @JvmStatic fun of(value: String) = BirthdateMatch(JsonField.of(value)) + } + + /** An enum containing [BirthdateMatch]'s known values. */ + enum class Known { + TRUE, + FALSE, + NOT_AVAILABLE, + } + + /** + * An enum containing [BirthdateMatch]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [BirthdateMatch] 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 { + TRUE, + FALSE, + NOT_AVAILABLE, + /** + * An enum member indicating that [BirthdateMatch] 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) { + TRUE -> Value.TRUE + FALSE -> Value.FALSE + NOT_AVAILABLE -> Value.NOT_AVAILABLE + 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 PreludeInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + TRUE -> Known.TRUE + FALSE -> Known.FALSE + NOT_AVAILABLE -> Known.NOT_AVAILABLE + else -> throw PreludeInvalidDataException("Unknown BirthdateMatch: $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 PreludeInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { PreludeInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws PreludeInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): BirthdateMatch = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: PreludeInvalidDataException) { + 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 BirthdateMatch && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Whether the country matched the operator's record. Compared exactly; never scored. */ + class CountryMatch @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 TRUE = of("true") + + @JvmField val FALSE = of("false") + + @JvmField val NOT_AVAILABLE = of("not_available") + + @JvmStatic fun of(value: String) = CountryMatch(JsonField.of(value)) + } + + /** An enum containing [CountryMatch]'s known values. */ + enum class Known { + TRUE, + FALSE, + NOT_AVAILABLE, + } + + /** + * An enum containing [CountryMatch]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [CountryMatch] 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 { + TRUE, + FALSE, + NOT_AVAILABLE, + /** + * An enum member indicating that [CountryMatch] 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) { + TRUE -> Value.TRUE + FALSE -> Value.FALSE + NOT_AVAILABLE -> Value.NOT_AVAILABLE + 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 PreludeInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + TRUE -> Known.TRUE + FALSE -> Known.FALSE + NOT_AVAILABLE -> Known.NOT_AVAILABLE + else -> throw PreludeInvalidDataException("Unknown CountryMatch: $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 PreludeInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { PreludeInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws PreludeInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): CountryMatch = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: PreludeInvalidDataException) { + 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 CountryMatch && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Whether the email address matched the operator's record. */ + class EmailMatch @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 TRUE = of("true") + + @JvmField val FALSE = of("false") + + @JvmField val NOT_AVAILABLE = of("not_available") + + @JvmStatic fun of(value: String) = EmailMatch(JsonField.of(value)) + } + + /** An enum containing [EmailMatch]'s known values. */ + enum class Known { + TRUE, + FALSE, + NOT_AVAILABLE, + } + + /** + * An enum containing [EmailMatch]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [EmailMatch] 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 { + TRUE, + FALSE, + NOT_AVAILABLE, + /** + * An enum member indicating that [EmailMatch] 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) { + TRUE -> Value.TRUE + FALSE -> Value.FALSE + NOT_AVAILABLE -> Value.NOT_AVAILABLE + 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 PreludeInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + TRUE -> Known.TRUE + FALSE -> Known.FALSE + NOT_AVAILABLE -> Known.NOT_AVAILABLE + else -> throw PreludeInvalidDataException("Unknown EmailMatch: $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 PreludeInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { PreludeInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws PreludeInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): EmailMatch = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: PreludeInvalidDataException) { + 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 EmailMatch && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Whether the family name matched the operator's record. */ + class FamilyNameMatch @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 TRUE = of("true") + + @JvmField val FALSE = of("false") + + @JvmField val NOT_AVAILABLE = of("not_available") + + @JvmStatic fun of(value: String) = FamilyNameMatch(JsonField.of(value)) + } + + /** An enum containing [FamilyNameMatch]'s known values. */ + enum class Known { + TRUE, + FALSE, + NOT_AVAILABLE, + } + + /** + * An enum containing [FamilyNameMatch]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [FamilyNameMatch] 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 { + TRUE, + FALSE, + NOT_AVAILABLE, + /** + * An enum member indicating that [FamilyNameMatch] 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) { + TRUE -> Value.TRUE + FALSE -> Value.FALSE + NOT_AVAILABLE -> Value.NOT_AVAILABLE + 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 PreludeInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + TRUE -> Known.TRUE + FALSE -> Known.FALSE + NOT_AVAILABLE -> Known.NOT_AVAILABLE + else -> throw PreludeInvalidDataException("Unknown FamilyNameMatch: $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 PreludeInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { PreludeInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws PreludeInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): FamilyNameMatch = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: PreludeInvalidDataException) { + 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 FamilyNameMatch && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Whether the given name matched the operator's record. */ + class GivenNameMatch @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 TRUE = of("true") + + @JvmField val FALSE = of("false") + + @JvmField val NOT_AVAILABLE = of("not_available") + + @JvmStatic fun of(value: String) = GivenNameMatch(JsonField.of(value)) + } + + /** An enum containing [GivenNameMatch]'s known values. */ + enum class Known { + TRUE, + FALSE, + NOT_AVAILABLE, + } + + /** + * An enum containing [GivenNameMatch]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [GivenNameMatch] 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 { + TRUE, + FALSE, + NOT_AVAILABLE, + /** + * An enum member indicating that [GivenNameMatch] 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) { + TRUE -> Value.TRUE + FALSE -> Value.FALSE + NOT_AVAILABLE -> Value.NOT_AVAILABLE + 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 PreludeInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + TRUE -> Known.TRUE + FALSE -> Known.FALSE + NOT_AVAILABLE -> Known.NOT_AVAILABLE + else -> throw PreludeInvalidDataException("Unknown GivenNameMatch: $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 PreludeInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { PreludeInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws PreludeInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): GivenNameMatch = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: PreludeInvalidDataException) { + 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 GivenNameMatch && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Whether the locality matched the operator's record. */ + class LocalityMatch @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 TRUE = of("true") + + @JvmField val FALSE = of("false") + + @JvmField val NOT_AVAILABLE = of("not_available") + + @JvmStatic fun of(value: String) = LocalityMatch(JsonField.of(value)) + } + + /** An enum containing [LocalityMatch]'s known values. */ + enum class Known { + TRUE, + FALSE, + NOT_AVAILABLE, + } + + /** + * An enum containing [LocalityMatch]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [LocalityMatch] 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 { + TRUE, + FALSE, + NOT_AVAILABLE, + /** + * An enum member indicating that [LocalityMatch] 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) { + TRUE -> Value.TRUE + FALSE -> Value.FALSE + NOT_AVAILABLE -> Value.NOT_AVAILABLE + 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 PreludeInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + TRUE -> Known.TRUE + FALSE -> Known.FALSE + NOT_AVAILABLE -> Known.NOT_AVAILABLE + else -> throw PreludeInvalidDataException("Unknown LocalityMatch: $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 PreludeInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { PreludeInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws PreludeInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): LocalityMatch = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: PreludeInvalidDataException) { + 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 LocalityMatch && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Whether the postal code matched the operator's record. Compared exactly; never scored. */ + class PostalCodeMatch @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 TRUE = of("true") + + @JvmField val FALSE = of("false") + + @JvmField val NOT_AVAILABLE = of("not_available") + + @JvmStatic fun of(value: String) = PostalCodeMatch(JsonField.of(value)) + } + + /** An enum containing [PostalCodeMatch]'s known values. */ + enum class Known { + TRUE, + FALSE, + NOT_AVAILABLE, + } + + /** + * An enum containing [PostalCodeMatch]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [PostalCodeMatch] 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 { + TRUE, + FALSE, + NOT_AVAILABLE, + /** + * An enum member indicating that [PostalCodeMatch] 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) { + TRUE -> Value.TRUE + FALSE -> Value.FALSE + NOT_AVAILABLE -> Value.NOT_AVAILABLE + 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 PreludeInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + TRUE -> Known.TRUE + FALSE -> Known.FALSE + NOT_AVAILABLE -> Known.NOT_AVAILABLE + else -> throw PreludeInvalidDataException("Unknown PostalCodeMatch: $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 PreludeInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { PreludeInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws PreludeInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): PostalCodeMatch = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: PreludeInvalidDataException) { + 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 PostalCodeMatch && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Whether the region matched the operator's record. */ + class RegionMatch @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 TRUE = of("true") + + @JvmField val FALSE = of("false") + + @JvmField val NOT_AVAILABLE = of("not_available") + + @JvmStatic fun of(value: String) = RegionMatch(JsonField.of(value)) + } + + /** An enum containing [RegionMatch]'s known values. */ + enum class Known { + TRUE, + FALSE, + NOT_AVAILABLE, + } + + /** + * An enum containing [RegionMatch]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [RegionMatch] 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 { + TRUE, + FALSE, + NOT_AVAILABLE, + /** + * An enum member indicating that [RegionMatch] 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) { + TRUE -> Value.TRUE + FALSE -> Value.FALSE + NOT_AVAILABLE -> Value.NOT_AVAILABLE + 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 PreludeInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + TRUE -> Known.TRUE + FALSE -> Known.FALSE + NOT_AVAILABLE -> Known.NOT_AVAILABLE + else -> throw PreludeInvalidDataException("Unknown RegionMatch: $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 PreludeInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { PreludeInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws PreludeInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): RegionMatch = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: PreludeInvalidDataException) { + 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 RegionMatch && 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 IntelKycMatchResponse && + addressMatch == other.addressMatch && + addressMatchScore == other.addressMatchScore && + birthdateMatch == other.birthdateMatch && + countryCode == other.countryCode && + countryMatch == other.countryMatch && + emailMatch == other.emailMatch && + emailMatchScore == other.emailMatchScore && + familyNameMatch == other.familyNameMatch && + familyNameMatchScore == other.familyNameMatchScore && + givenNameMatch == other.givenNameMatch && + givenNameMatchScore == other.givenNameMatchScore && + localityMatch == other.localityMatch && + localityMatchScore == other.localityMatchScore && + operator == other.operator && + phoneNumber == other.phoneNumber && + postalCodeMatch == other.postalCodeMatch && + regionMatch == other.regionMatch && + regionMatchScore == other.regionMatchScore && + requestId == other.requestId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + addressMatch, + addressMatchScore, + birthdateMatch, + countryCode, + countryMatch, + emailMatch, + emailMatchScore, + familyNameMatch, + familyNameMatchScore, + givenNameMatch, + givenNameMatchScore, + localityMatch, + localityMatchScore, + operator, + phoneNumber, + postalCodeMatch, + regionMatch, + regionMatchScore, + requestId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "IntelKycMatchResponse{addressMatch=$addressMatch, addressMatchScore=$addressMatchScore, birthdateMatch=$birthdateMatch, countryCode=$countryCode, countryMatch=$countryMatch, emailMatch=$emailMatch, emailMatchScore=$emailMatchScore, familyNameMatch=$familyNameMatch, familyNameMatchScore=$familyNameMatchScore, givenNameMatch=$givenNameMatch, givenNameMatchScore=$givenNameMatchScore, localityMatch=$localityMatch, localityMatchScore=$localityMatchScore, operator=$operator, phoneNumber=$phoneNumber, postalCodeMatch=$postalCodeMatch, regionMatch=$regionMatch, regionMatchScore=$regionMatchScore, requestId=$requestId, additionalProperties=$additionalProperties}" +} diff --git a/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/NotifyReplyParams.kt b/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/NotifyReplyParams.kt new file mode 100644 index 00000000..400d07b1 --- /dev/null +++ b/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/NotifyReplyParams.kt @@ -0,0 +1,733 @@ +// File generated from our OpenAPI spec by Stainless. + +package so.prelude.sdk.models + +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 so.prelude.sdk.core.ExcludeMissing +import so.prelude.sdk.core.JsonField +import so.prelude.sdk.core.JsonMissing +import so.prelude.sdk.core.JsonValue +import so.prelude.sdk.core.Params +import so.prelude.sdk.core.checkRequired +import so.prelude.sdk.core.http.Headers +import so.prelude.sdk.core.http.QueryParams +import so.prelude.sdk.errors.PreludeInvalidDataException + +/** + * Send a free-form text reply to an inbound WhatsApp message within the 24-hour conversation + * window. See [WhatsApp 2-Way Messaging](/notify/v2/documentation/whatsapp) for details. + */ +class NotifyReplyParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * The inbound message ID (prefixed with `im_`) to reply to. This ID is provided in the + * `inbound.message.received` webhook event. + * + * @throws PreludeInvalidDataException 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 replyTo(): String = body.replyTo() + + /** + * The reply message body sent as a free-form WhatsApp text. + * + * @throws PreludeInvalidDataException 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 text(): String = body.text() + + /** + * The recipient's phone number in E.164 format. Must match the phone number that sent the + * original inbound message. + * + * @throws PreludeInvalidDataException 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 to(): String = body.to() + + /** + * The URL where webhooks will be sent for delivery events of this reply. + * + * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun callbackUrl(): Optional = body.callbackUrl() + + /** + * A user-defined identifier to correlate this reply with your internal systems. It is returned + * in the response and any webhook events that refer to this message. + * + * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun correlationId(): Optional = body.correlationId() + + /** + * Returns the raw JSON value of [replyTo]. + * + * Unlike [replyTo], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _replyTo(): JsonField = body._replyTo() + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _text(): JsonField = body._text() + + /** + * Returns the raw JSON value of [to]. + * + * Unlike [to], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _to(): JsonField = body._to() + + /** + * 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 [correlationId]. + * + * Unlike [correlationId], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _correlationId(): JsonField = body._correlationId() + + 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 [NotifyReplyParams]. + * + * The following fields are required: + * ```java + * .replyTo() + * .text() + * .to() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NotifyReplyParams]. */ + 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(notifyReplyParams: NotifyReplyParams) = apply { + body = notifyReplyParams.body.toBuilder() + additionalHeaders = notifyReplyParams.additionalHeaders.toBuilder() + additionalQueryParams = notifyReplyParams.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: + * - [replyTo] + * - [text] + * - [to] + * - [callbackUrl] + * - [correlationId] + * - etc. + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** + * The inbound message ID (prefixed with `im_`) to reply to. This ID is provided in the + * `inbound.message.received` webhook event. + */ + fun replyTo(replyTo: String) = apply { body.replyTo(replyTo) } + + /** + * Sets [Builder.replyTo] to an arbitrary JSON value. + * + * You should usually call [Builder.replyTo] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun replyTo(replyTo: JsonField) = apply { body.replyTo(replyTo) } + + /** The reply message body sent as a free-form WhatsApp text. */ + fun text(text: String) = apply { body.text(text) } + + /** + * Sets [Builder.text] to an arbitrary JSON value. + * + * You should usually call [Builder.text] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun text(text: JsonField) = apply { body.text(text) } + + /** + * The recipient's phone number in E.164 format. Must match the phone number that sent the + * original inbound message. + */ + fun to(to: String) = apply { body.to(to) } + + /** + * Sets [Builder.to] to an arbitrary JSON value. + * + * You should usually call [Builder.to] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun to(to: JsonField) = apply { body.to(to) } + + /** The URL where webhooks will be sent for delivery events of this reply. */ + 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) } + + /** + * A user-defined identifier to correlate this reply with your internal systems. It is + * returned in the response and any webhook events that refer to this message. + */ + fun correlationId(correlationId: String) = apply { body.correlationId(correlationId) } + + /** + * Sets [Builder.correlationId] to an arbitrary JSON value. + * + * You should usually call [Builder.correlationId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun correlationId(correlationId: JsonField) = apply { + body.correlationId(correlationId) + } + + 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 [NotifyReplyParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .replyTo() + * .text() + * .to() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): NotifyReplyParams = + NotifyReplyParams( + 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 replyTo: JsonField, + private val text: JsonField, + private val to: JsonField, + private val callbackUrl: JsonField, + private val correlationId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("reply_to") @ExcludeMissing replyTo: JsonField = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), + @JsonProperty("to") @ExcludeMissing to: JsonField = JsonMissing.of(), + @JsonProperty("callback_url") + @ExcludeMissing + callbackUrl: JsonField = JsonMissing.of(), + @JsonProperty("correlation_id") + @ExcludeMissing + correlationId: JsonField = JsonMissing.of(), + ) : this(replyTo, text, to, callbackUrl, correlationId, mutableMapOf()) + + /** + * The inbound message ID (prefixed with `im_`) to reply to. This ID is provided in the + * `inbound.message.received` webhook event. + * + * @throws PreludeInvalidDataException 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 replyTo(): String = replyTo.getRequired("reply_to") + + /** + * The reply message body sent as a free-form WhatsApp text. + * + * @throws PreludeInvalidDataException 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 text(): String = text.getRequired("text") + + /** + * The recipient's phone number in E.164 format. Must match the phone number that sent the + * original inbound message. + * + * @throws PreludeInvalidDataException 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 to(): String = to.getRequired("to") + + /** + * The URL where webhooks will be sent for delivery events of this reply. + * + * @throws PreludeInvalidDataException 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") + + /** + * A user-defined identifier to correlate this reply with your internal systems. It is + * returned in the response and any webhook events that refer to this message. + * + * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun correlationId(): Optional = correlationId.getOptional("correlation_id") + + /** + * Returns the raw JSON value of [replyTo]. + * + * Unlike [replyTo], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("reply_to") @ExcludeMissing fun _replyTo(): JsonField = replyTo + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text + + /** + * Returns the raw JSON value of [to]. + * + * Unlike [to], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("to") @ExcludeMissing fun _to(): JsonField = to + + /** + * 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 [correlationId]. + * + * Unlike [correlationId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("correlation_id") + @ExcludeMissing + fun _correlationId(): JsonField = correlationId + + @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 + * .replyTo() + * .text() + * .to() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var replyTo: JsonField? = null + private var text: JsonField? = null + private var to: JsonField? = null + private var callbackUrl: JsonField = JsonMissing.of() + private var correlationId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + replyTo = body.replyTo + text = body.text + to = body.to + callbackUrl = body.callbackUrl + correlationId = body.correlationId + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** + * The inbound message ID (prefixed with `im_`) to reply to. This ID is provided in the + * `inbound.message.received` webhook event. + */ + fun replyTo(replyTo: String) = replyTo(JsonField.of(replyTo)) + + /** + * Sets [Builder.replyTo] to an arbitrary JSON value. + * + * You should usually call [Builder.replyTo] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun replyTo(replyTo: JsonField) = apply { this.replyTo = replyTo } + + /** The reply message body sent as a free-form WhatsApp text. */ + fun text(text: String) = text(JsonField.of(text)) + + /** + * Sets [Builder.text] to an arbitrary JSON value. + * + * You should usually call [Builder.text] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun text(text: JsonField) = apply { this.text = text } + + /** + * The recipient's phone number in E.164 format. Must match the phone number that sent + * the original inbound message. + */ + fun to(to: String) = to(JsonField.of(to)) + + /** + * Sets [Builder.to] to an arbitrary JSON value. + * + * You should usually call [Builder.to] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun to(to: JsonField) = apply { this.to = to } + + /** The URL where webhooks will be sent for delivery events of this reply. */ + 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 + } + + /** + * A user-defined identifier to correlate this reply with your internal systems. It is + * returned in the response and any webhook events that refer to this message. + */ + fun correlationId(correlationId: String) = correlationId(JsonField.of(correlationId)) + + /** + * Sets [Builder.correlationId] to an arbitrary JSON value. + * + * You should usually call [Builder.correlationId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun correlationId(correlationId: JsonField) = apply { + this.correlationId = correlationId + } + + 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 + * .replyTo() + * .text() + * .to() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("replyTo", replyTo), + checkRequired("text", text), + checkRequired("to", to), + callbackUrl, + correlationId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws PreludeInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Body = apply { + if (validated) { + return@apply + } + + replyTo() + text() + to() + callbackUrl() + correlationId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: PreludeInvalidDataException) { + 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 (replyTo.asKnown().isPresent) 1 else 0) + + (if (text.asKnown().isPresent) 1 else 0) + + (if (to.asKnown().isPresent) 1 else 0) + + (if (callbackUrl.asKnown().isPresent) 1 else 0) + + (if (correlationId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + replyTo == other.replyTo && + text == other.text && + to == other.to && + callbackUrl == other.callbackUrl && + correlationId == other.correlationId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(replyTo, text, to, callbackUrl, correlationId, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{replyTo=$replyTo, text=$text, to=$to, callbackUrl=$callbackUrl, correlationId=$correlationId, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is NotifyReplyParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "NotifyReplyParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/NotifyReplyResponse.kt b/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/NotifyReplyResponse.kt new file mode 100644 index 00000000..d2c7c3b9 --- /dev/null +++ b/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/NotifyReplyResponse.kt @@ -0,0 +1,425 @@ +// File generated from our OpenAPI spec by Stainless. + +package so.prelude.sdk.models + +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 so.prelude.sdk.core.ExcludeMissing +import so.prelude.sdk.core.JsonField +import so.prelude.sdk.core.JsonMissing +import so.prelude.sdk.core.JsonValue +import so.prelude.sdk.core.checkRequired +import so.prelude.sdk.errors.PreludeInvalidDataException + +class NotifyReplyResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val createdAt: JsonField, + private val replyTo: JsonField, + private val text: JsonField, + private val to: JsonField, + private val callbackUrl: JsonField, + private val correlationId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField = JsonMissing.of(), + @JsonProperty("reply_to") @ExcludeMissing replyTo: JsonField = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), + @JsonProperty("to") @ExcludeMissing to: JsonField = JsonMissing.of(), + @JsonProperty("callback_url") + @ExcludeMissing + callbackUrl: JsonField = JsonMissing.of(), + @JsonProperty("correlation_id") + @ExcludeMissing + correlationId: JsonField = JsonMissing.of(), + ) : this(id, createdAt, replyTo, text, to, callbackUrl, correlationId, mutableMapOf()) + + /** + * The reply message identifier. + * + * @throws PreludeInvalidDataException 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 id(): String = id.getRequired("id") + + /** + * The reply creation date in RFC3339 format. + * + * @throws PreludeInvalidDataException 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 createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * The inbound message ID this reply was sent in response to. + * + * @throws PreludeInvalidDataException 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 replyTo(): String = replyTo.getRequired("reply_to") + + /** + * The reply message body that was sent. + * + * @throws PreludeInvalidDataException 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 text(): String = text.getRequired("text") + + /** + * The recipient's phone number in E.164 format. + * + * @throws PreludeInvalidDataException 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 to(): String = to.getRequired("to") + + /** + * The callback URL where webhooks will be sent. + * + * @throws PreludeInvalidDataException 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") + + /** + * The user-defined correlation identifier echoed back from the request. + * + * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun correlationId(): Optional = correlationId.getOptional("correlation_id") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * 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 [replyTo]. + * + * Unlike [replyTo], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("reply_to") @ExcludeMissing fun _replyTo(): JsonField = replyTo + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text + + /** + * Returns the raw JSON value of [to]. + * + * Unlike [to], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("to") @ExcludeMissing fun _to(): JsonField = to + + /** + * 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 [correlationId]. + * + * Unlike [correlationId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("correlation_id") + @ExcludeMissing + fun _correlationId(): JsonField = correlationId + + @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 [NotifyReplyResponse]. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .replyTo() + * .text() + * .to() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NotifyReplyResponse]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var createdAt: JsonField? = null + private var replyTo: JsonField? = null + private var text: JsonField? = null + private var to: JsonField? = null + private var callbackUrl: JsonField = JsonMissing.of() + private var correlationId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(notifyReplyResponse: NotifyReplyResponse) = apply { + id = notifyReplyResponse.id + createdAt = notifyReplyResponse.createdAt + replyTo = notifyReplyResponse.replyTo + text = notifyReplyResponse.text + to = notifyReplyResponse.to + callbackUrl = notifyReplyResponse.callbackUrl + correlationId = notifyReplyResponse.correlationId + additionalProperties = notifyReplyResponse.additionalProperties.toMutableMap() + } + + /** The reply message identifier. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** The reply creation date in RFC3339 format. */ + 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 message ID this reply was sent in response to. */ + fun replyTo(replyTo: String) = replyTo(JsonField.of(replyTo)) + + /** + * Sets [Builder.replyTo] to an arbitrary JSON value. + * + * You should usually call [Builder.replyTo] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun replyTo(replyTo: JsonField) = apply { this.replyTo = replyTo } + + /** The reply message body that was sent. */ + fun text(text: String) = text(JsonField.of(text)) + + /** + * Sets [Builder.text] to an arbitrary JSON value. + * + * You should usually call [Builder.text] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun text(text: JsonField) = apply { this.text = text } + + /** The recipient's phone number in E.164 format. */ + fun to(to: String) = to(JsonField.of(to)) + + /** + * Sets [Builder.to] to an arbitrary JSON value. + * + * You should usually call [Builder.to] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun to(to: JsonField) = apply { this.to = to } + + /** The callback URL where webhooks will be sent. */ + 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 } + + /** The user-defined correlation identifier echoed back from the request. */ + fun correlationId(correlationId: String) = correlationId(JsonField.of(correlationId)) + + /** + * Sets [Builder.correlationId] to an arbitrary JSON value. + * + * You should usually call [Builder.correlationId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun correlationId(correlationId: JsonField) = apply { + this.correlationId = correlationId + } + + 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 [NotifyReplyResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .replyTo() + * .text() + * .to() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): NotifyReplyResponse = + NotifyReplyResponse( + checkRequired("id", id), + checkRequired("createdAt", createdAt), + checkRequired("replyTo", replyTo), + checkRequired("text", text), + checkRequired("to", to), + callbackUrl, + correlationId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws PreludeInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): NotifyReplyResponse = apply { + if (validated) { + return@apply + } + + id() + createdAt() + replyTo() + text() + to() + callbackUrl() + correlationId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: PreludeInvalidDataException) { + 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 (id.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (replyTo.asKnown().isPresent) 1 else 0) + + (if (text.asKnown().isPresent) 1 else 0) + + (if (to.asKnown().isPresent) 1 else 0) + + (if (callbackUrl.asKnown().isPresent) 1 else 0) + + (if (correlationId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is NotifyReplyResponse && + id == other.id && + createdAt == other.createdAt && + replyTo == other.replyTo && + text == other.text && + to == other.to && + callbackUrl == other.callbackUrl && + correlationId == other.correlationId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + createdAt, + replyTo, + text, + to, + callbackUrl, + correlationId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NotifyReplyResponse{id=$id, createdAt=$createdAt, replyTo=$replyTo, text=$text, to=$to, callbackUrl=$callbackUrl, correlationId=$correlationId, additionalProperties=$additionalProperties}" +} diff --git a/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/PhoneVerificationCarrier.kt b/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/PhoneVerificationCarrier.kt new file mode 100644 index 00000000..f2d03400 --- /dev/null +++ b/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/PhoneVerificationCarrier.kt @@ -0,0 +1,212 @@ +// File generated from our OpenAPI spec by Stainless. + +package so.prelude.sdk.models + +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 so.prelude.sdk.core.ExcludeMissing +import so.prelude.sdk.core.JsonField +import so.prelude.sdk.core.JsonMissing +import so.prelude.sdk.core.JsonValue +import so.prelude.sdk.core.checkRequired +import so.prelude.sdk.errors.PreludeInvalidDataException + +/** The end user's mobile network. */ +class PhoneVerificationCarrier +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val mccmnc: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("mccmnc") @ExcludeMissing mccmnc: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(mccmnc, name, mutableMapOf()) + + /** + * @throws PreludeInvalidDataException 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 mccmnc(): String = mccmnc.getRequired("mccmnc") + + /** + * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun name(): Optional = name.getOptional("name") + + /** + * Returns the raw JSON value of [mccmnc]. + * + * Unlike [mccmnc], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("mccmnc") @ExcludeMissing fun _mccmnc(): JsonField = mccmnc + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @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 [PhoneVerificationCarrier]. + * + * The following fields are required: + * ```java + * .mccmnc() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PhoneVerificationCarrier]. */ + class Builder internal constructor() { + + private var mccmnc: JsonField? = null + private var name: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(phoneVerificationCarrier: PhoneVerificationCarrier) = apply { + mccmnc = phoneVerificationCarrier.mccmnc + name = phoneVerificationCarrier.name + additionalProperties = phoneVerificationCarrier.additionalProperties.toMutableMap() + } + + fun mccmnc(mccmnc: String) = mccmnc(JsonField.of(mccmnc)) + + /** + * Sets [Builder.mccmnc] to an arbitrary JSON value. + * + * You should usually call [Builder.mccmnc] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun mccmnc(mccmnc: JsonField) = apply { this.mccmnc = mccmnc } + + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + 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 [PhoneVerificationCarrier]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .mccmnc() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PhoneVerificationCarrier = + PhoneVerificationCarrier( + checkRequired("mccmnc", mccmnc), + name, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws PreludeInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): PhoneVerificationCarrier = apply { + if (validated) { + return@apply + } + + mccmnc() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: PreludeInvalidDataException) { + 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 (mccmnc.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PhoneVerificationCarrier && + mccmnc == other.mccmnc && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(mccmnc, name, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PhoneVerificationCarrier{mccmnc=$mccmnc, name=$name, additionalProperties=$additionalProperties}" +} diff --git a/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/PhoneVerificationMoney.kt b/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/PhoneVerificationMoney.kt new file mode 100644 index 00000000..2eef41e7 --- /dev/null +++ b/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/PhoneVerificationMoney.kt @@ -0,0 +1,222 @@ +// File generated from our OpenAPI spec by Stainless. + +package so.prelude.sdk.models + +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 so.prelude.sdk.core.ExcludeMissing +import so.prelude.sdk.core.JsonField +import so.prelude.sdk.core.JsonMissing +import so.prelude.sdk.core.JsonValue +import so.prelude.sdk.core.checkRequired +import so.prelude.sdk.errors.PreludeInvalidDataException + +class PhoneVerificationMoney +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") @ExcludeMissing currency: JsonField = JsonMissing.of(), + ) : this(amount, currency, mutableMapOf()) + + /** + * Exact decimal amount. It is never rounded to the currency's minor units, so a sub-cent cost + * reads as `0.0004` rather than as `0.00`. + * + * @throws PreludeInvalidDataException 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 amount(): String = amount.getRequired("amount") + + /** + * ISO 4217 currency code. + * + * @throws PreludeInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + @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 [PhoneVerificationMoney]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PhoneVerificationMoney]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(phoneVerificationMoney: PhoneVerificationMoney) = apply { + amount = phoneVerificationMoney.amount + currency = phoneVerificationMoney.currency + additionalProperties = phoneVerificationMoney.additionalProperties.toMutableMap() + } + + /** + * Exact decimal amount. It is never rounded to the currency's minor units, so a sub-cent + * cost reads as `0.0004` rather than as `0.00`. + */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** ISO 4217 currency code. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + 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 [PhoneVerificationMoney]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PhoneVerificationMoney = + PhoneVerificationMoney( + checkRequired("amount", amount), + checkRequired("currency", currency), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws PreludeInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): PhoneVerificationMoney = apply { + if (validated) { + return@apply + } + + amount() + currency() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: PreludeInvalidDataException) { + 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 (amount.asKnown().isPresent) 1 else 0) + (if (currency.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PhoneVerificationMoney && + amount == other.amount && + currency == other.currency && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(amount, currency, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PhoneVerificationMoney{amount=$amount, currency=$currency, additionalProperties=$additionalProperties}" +} diff --git a/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/PhoneVerificationPsd2Transaction.kt b/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/PhoneVerificationPsd2Transaction.kt new file mode 100644 index 00000000..8c71b21d --- /dev/null +++ b/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/PhoneVerificationPsd2Transaction.kt @@ -0,0 +1,208 @@ +// File generated from our OpenAPI spec by Stainless. + +package so.prelude.sdk.models + +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 +import so.prelude.sdk.core.ExcludeMissing +import so.prelude.sdk.core.JsonField +import so.prelude.sdk.core.JsonMissing +import so.prelude.sdk.core.JsonValue +import so.prelude.sdk.errors.PreludeInvalidDataException + +class PhoneVerificationPsd2Transaction +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val amount: JsonField, + private val recipient: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("recipient") @ExcludeMissing recipient: JsonField = JsonMissing.of(), + ) : this(amount, recipient, mutableMapOf()) + + /** + * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun amount(): Optional = amount.getOptional("amount") + + /** + * Payee name displayed to the payer. + * + * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun recipient(): Optional = recipient.getOptional("recipient") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [recipient]. + * + * Unlike [recipient], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("recipient") @ExcludeMissing fun _recipient(): JsonField = recipient + + @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 + * [PhoneVerificationPsd2Transaction]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PhoneVerificationPsd2Transaction]. */ + class Builder internal constructor() { + + private var amount: JsonField = JsonMissing.of() + private var recipient: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(phoneVerificationPsd2Transaction: PhoneVerificationPsd2Transaction) = + apply { + amount = phoneVerificationPsd2Transaction.amount + recipient = phoneVerificationPsd2Transaction.recipient + additionalProperties = + phoneVerificationPsd2Transaction.additionalProperties.toMutableMap() + } + + fun amount(amount: PhoneVerificationMoney) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [PhoneVerificationMoney] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** Payee name displayed to the payer. */ + fun recipient(recipient: String) = recipient(JsonField.of(recipient)) + + /** + * Sets [Builder.recipient] to an arbitrary JSON value. + * + * You should usually call [Builder.recipient] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun recipient(recipient: JsonField) = apply { this.recipient = recipient } + + 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 [PhoneVerificationPsd2Transaction]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): PhoneVerificationPsd2Transaction = + PhoneVerificationPsd2Transaction(amount, recipient, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws PreludeInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): PhoneVerificationPsd2Transaction = apply { + if (validated) { + return@apply + } + + amount().ifPresent { it.validate() } + recipient() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: PreludeInvalidDataException) { + 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 = + (amount.asKnown().getOrNull()?.validity() ?: 0) + + (if (recipient.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PhoneVerificationPsd2Transaction && + amount == other.amount && + recipient == other.recipient && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(amount, recipient, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PhoneVerificationPsd2Transaction{amount=$amount, recipient=$recipient, additionalProperties=$additionalProperties}" +} diff --git a/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/Signals.kt b/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/Signals.kt new file mode 100644 index 00000000..be6077c8 --- /dev/null +++ b/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/Signals.kt @@ -0,0 +1,744 @@ +// File generated from our OpenAPI spec by Stainless. + +package so.prelude.sdk.models + +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 +import so.prelude.sdk.core.Enum +import so.prelude.sdk.core.ExcludeMissing +import so.prelude.sdk.core.JsonField +import so.prelude.sdk.core.JsonMissing +import so.prelude.sdk.core.JsonValue +import so.prelude.sdk.errors.PreludeInvalidDataException + +/** + * The signals used for anti-fraud. For more details, refer to + * [Signals](/verify/v2/documentation/prevent-fraud#signals). + */ +class Signals +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val appVersion: JsonField, + private val deviceId: JsonField, + private val deviceModel: JsonField, + private val devicePlatform: JsonField, + private val existingUser: JsonField, + private val ip: JsonField, + private val isTrustedUser: JsonField, + private val ja4Fingerprint: JsonField, + private val osVersion: JsonField, + private val userAgent: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("app_version") + @ExcludeMissing + appVersion: JsonField = JsonMissing.of(), + @JsonProperty("device_id") @ExcludeMissing deviceId: JsonField = JsonMissing.of(), + @JsonProperty("device_model") + @ExcludeMissing + deviceModel: JsonField = JsonMissing.of(), + @JsonProperty("device_platform") + @ExcludeMissing + devicePlatform: JsonField = JsonMissing.of(), + @JsonProperty("existing_user") + @ExcludeMissing + existingUser: JsonField = JsonMissing.of(), + @JsonProperty("ip") @ExcludeMissing ip: JsonField = JsonMissing.of(), + @JsonProperty("is_trusted_user") + @ExcludeMissing + isTrustedUser: JsonField = JsonMissing.of(), + @JsonProperty("ja4_fingerprint") + @ExcludeMissing + ja4Fingerprint: JsonField = JsonMissing.of(), + @JsonProperty("os_version") @ExcludeMissing osVersion: JsonField = JsonMissing.of(), + @JsonProperty("user_agent") @ExcludeMissing userAgent: JsonField = JsonMissing.of(), + ) : this( + appVersion, + deviceId, + deviceModel, + devicePlatform, + existingUser, + ip, + isTrustedUser, + ja4Fingerprint, + osVersion, + userAgent, + mutableMapOf(), + ) + + /** + * The version of your application. + * + * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun appVersion(): Optional = appVersion.getOptional("app_version") + + /** + * A unique ID for the user's device. You should ensure that each user device has a unique + * `device_id` value. Ideally, for Android, this corresponds to the `ANDROID_ID` and for iOS, + * this corresponds to the `identifierForVendor`. + * + * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun deviceId(): Optional = deviceId.getOptional("device_id") + + /** + * The model of the user's device. + * + * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun deviceModel(): Optional = deviceModel.getOptional("device_model") + + /** + * The type of the user's device. + * + * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun devicePlatform(): Optional = devicePlatform.getOptional("device_platform") + + /** + * Whether the end-user already exists in your system, for example an existing account signing + * in again rather than a first-time signup. Unlike `is_trusted_user`, this signal does not + * bypass fraud checks; it is taken into account as one additional anti-fraud signal. For more + * details, refer to [Signals](/verify/v2/documentation/prevent-fraud#signals). + * + * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun existingUser(): Optional = existingUser.getOptional("existing_user") + + /** + * The public IP v4 or v6 address of the end-user's device. You should collect this from your + * backend. If your backend is behind a proxy, use the `X-Forwarded-For`, `Forwarded`, + * `True-Client-IP`, `CF-Connecting-IP` or an equivalent header to get the actual public IP of + * the end-user's device. + * + * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun ip(): Optional = ip.getOptional("ip") + + /** + * This signal should indicate a higher level of trust, explicitly stating that the user is + * genuine. Contact us to discuss your use case. For more details, refer to + * [Signals](/verify/v2/documentation/prevent-fraud#signals). + * + * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun isTrustedUser(): Optional = isTrustedUser.getOptional("is_trusted_user") + + /** + * The JA4 fingerprint observed for the end-user's connection. Prelude will infer it + * automatically when you use our Frontend SDKs (which use Prelude's edge network), but you can + * also forward the value if you terminate TLS yourself. + * + * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun ja4Fingerprint(): Optional = ja4Fingerprint.getOptional("ja4_fingerprint") + + /** + * The version of the user's device operating system. + * + * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun osVersion(): Optional = osVersion.getOptional("os_version") + + /** + * The user agent of the user's device. If the individual fields (os_version, device_platform, + * device_model) are provided, we will prioritize those values instead of parsing them from the + * user agent string. + * + * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun userAgent(): Optional = userAgent.getOptional("user_agent") + + /** + * Returns the raw JSON value of [appVersion]. + * + * Unlike [appVersion], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("app_version") @ExcludeMissing fun _appVersion(): JsonField = appVersion + + /** + * Returns the raw JSON value of [deviceId]. + * + * Unlike [deviceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("device_id") @ExcludeMissing fun _deviceId(): JsonField = deviceId + + /** + * Returns the raw JSON value of [deviceModel]. + * + * Unlike [deviceModel], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("device_model") + @ExcludeMissing + fun _deviceModel(): JsonField = deviceModel + + /** + * Returns the raw JSON value of [devicePlatform]. + * + * Unlike [devicePlatform], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("device_platform") + @ExcludeMissing + fun _devicePlatform(): JsonField = devicePlatform + + /** + * Returns the raw JSON value of [existingUser]. + * + * Unlike [existingUser], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("existing_user") + @ExcludeMissing + fun _existingUser(): JsonField = existingUser + + /** + * Returns the raw JSON value of [ip]. + * + * Unlike [ip], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ip") @ExcludeMissing fun _ip(): JsonField = ip + + /** + * Returns the raw JSON value of [isTrustedUser]. + * + * Unlike [isTrustedUser], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("is_trusted_user") + @ExcludeMissing + fun _isTrustedUser(): JsonField = isTrustedUser + + /** + * Returns the raw JSON value of [ja4Fingerprint]. + * + * Unlike [ja4Fingerprint], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ja4_fingerprint") + @ExcludeMissing + fun _ja4Fingerprint(): JsonField = ja4Fingerprint + + /** + * Returns the raw JSON value of [osVersion]. + * + * Unlike [osVersion], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("os_version") @ExcludeMissing fun _osVersion(): JsonField = osVersion + + /** + * Returns the raw JSON value of [userAgent]. + * + * Unlike [userAgent], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("user_agent") @ExcludeMissing fun _userAgent(): JsonField = userAgent + + @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 [Signals]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Signals]. */ + class Builder internal constructor() { + + private var appVersion: JsonField = JsonMissing.of() + private var deviceId: JsonField = JsonMissing.of() + private var deviceModel: JsonField = JsonMissing.of() + private var devicePlatform: JsonField = JsonMissing.of() + private var existingUser: JsonField = JsonMissing.of() + private var ip: JsonField = JsonMissing.of() + private var isTrustedUser: JsonField = JsonMissing.of() + private var ja4Fingerprint: JsonField = JsonMissing.of() + private var osVersion: JsonField = JsonMissing.of() + private var userAgent: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(signals: Signals) = apply { + appVersion = signals.appVersion + deviceId = signals.deviceId + deviceModel = signals.deviceModel + devicePlatform = signals.devicePlatform + existingUser = signals.existingUser + ip = signals.ip + isTrustedUser = signals.isTrustedUser + ja4Fingerprint = signals.ja4Fingerprint + osVersion = signals.osVersion + userAgent = signals.userAgent + additionalProperties = signals.additionalProperties.toMutableMap() + } + + /** The version of your application. */ + fun appVersion(appVersion: String) = appVersion(JsonField.of(appVersion)) + + /** + * Sets [Builder.appVersion] to an arbitrary JSON value. + * + * You should usually call [Builder.appVersion] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun appVersion(appVersion: JsonField) = apply { this.appVersion = appVersion } + + /** + * A unique ID for the user's device. You should ensure that each user device has a unique + * `device_id` value. Ideally, for Android, this corresponds to the `ANDROID_ID` and for + * iOS, this corresponds to the `identifierForVendor`. + */ + fun deviceId(deviceId: String) = deviceId(JsonField.of(deviceId)) + + /** + * Sets [Builder.deviceId] to an arbitrary JSON value. + * + * You should usually call [Builder.deviceId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun deviceId(deviceId: JsonField) = apply { this.deviceId = deviceId } + + /** The model of the user's device. */ + fun deviceModel(deviceModel: String) = deviceModel(JsonField.of(deviceModel)) + + /** + * Sets [Builder.deviceModel] to an arbitrary JSON value. + * + * You should usually call [Builder.deviceModel] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun deviceModel(deviceModel: JsonField) = apply { this.deviceModel = deviceModel } + + /** The type of the user's device. */ + fun devicePlatform(devicePlatform: DevicePlatform) = + devicePlatform(JsonField.of(devicePlatform)) + + /** + * Sets [Builder.devicePlatform] to an arbitrary JSON value. + * + * You should usually call [Builder.devicePlatform] with a well-typed [DevicePlatform] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun devicePlatform(devicePlatform: JsonField) = apply { + this.devicePlatform = devicePlatform + } + + /** + * Whether the end-user already exists in your system, for example an existing account + * signing in again rather than a first-time signup. Unlike `is_trusted_user`, this signal + * does not bypass fraud checks; it is taken into account as one additional anti-fraud + * signal. For more details, refer to + * [Signals](/verify/v2/documentation/prevent-fraud#signals). + */ + fun existingUser(existingUser: Boolean) = existingUser(JsonField.of(existingUser)) + + /** + * Sets [Builder.existingUser] to an arbitrary JSON value. + * + * You should usually call [Builder.existingUser] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun existingUser(existingUser: JsonField) = apply { + this.existingUser = existingUser + } + + /** + * The public IP v4 or v6 address of the end-user's device. You should collect this from + * your backend. If your backend is behind a proxy, use the `X-Forwarded-For`, `Forwarded`, + * `True-Client-IP`, `CF-Connecting-IP` or an equivalent header to get the actual public IP + * of the end-user's device. + */ + fun ip(ip: String) = ip(JsonField.of(ip)) + + /** + * Sets [Builder.ip] to an arbitrary JSON value. + * + * You should usually call [Builder.ip] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun ip(ip: JsonField) = apply { this.ip = ip } + + /** + * This signal should indicate a higher level of trust, explicitly stating that the user is + * genuine. Contact us to discuss your use case. For more details, refer to + * [Signals](/verify/v2/documentation/prevent-fraud#signals). + */ + fun isTrustedUser(isTrustedUser: Boolean) = isTrustedUser(JsonField.of(isTrustedUser)) + + /** + * Sets [Builder.isTrustedUser] to an arbitrary JSON value. + * + * You should usually call [Builder.isTrustedUser] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun isTrustedUser(isTrustedUser: JsonField) = apply { + this.isTrustedUser = isTrustedUser + } + + /** + * The JA4 fingerprint observed for the end-user's connection. Prelude will infer it + * automatically when you use our Frontend SDKs (which use Prelude's edge network), but you + * can also forward the value if you terminate TLS yourself. + */ + fun ja4Fingerprint(ja4Fingerprint: String) = ja4Fingerprint(JsonField.of(ja4Fingerprint)) + + /** + * Sets [Builder.ja4Fingerprint] to an arbitrary JSON value. + * + * You should usually call [Builder.ja4Fingerprint] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun ja4Fingerprint(ja4Fingerprint: JsonField) = apply { + this.ja4Fingerprint = ja4Fingerprint + } + + /** The version of the user's device operating system. */ + fun osVersion(osVersion: String) = osVersion(JsonField.of(osVersion)) + + /** + * Sets [Builder.osVersion] to an arbitrary JSON value. + * + * You should usually call [Builder.osVersion] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun osVersion(osVersion: JsonField) = apply { this.osVersion = osVersion } + + /** + * The user agent of the user's device. If the individual fields (os_version, + * device_platform, device_model) are provided, we will prioritize those values instead of + * parsing them from the user agent string. + */ + fun userAgent(userAgent: String) = userAgent(JsonField.of(userAgent)) + + /** + * Sets [Builder.userAgent] to an arbitrary JSON value. + * + * You should usually call [Builder.userAgent] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun userAgent(userAgent: JsonField) = apply { this.userAgent = userAgent } + + 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 [Signals]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Signals = + Signals( + appVersion, + deviceId, + deviceModel, + devicePlatform, + existingUser, + ip, + isTrustedUser, + ja4Fingerprint, + osVersion, + userAgent, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws PreludeInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Signals = apply { + if (validated) { + return@apply + } + + appVersion() + deviceId() + deviceModel() + devicePlatform().ifPresent { it.validate() } + existingUser() + ip() + isTrustedUser() + ja4Fingerprint() + osVersion() + userAgent() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: PreludeInvalidDataException) { + 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 (appVersion.asKnown().isPresent) 1 else 0) + + (if (deviceId.asKnown().isPresent) 1 else 0) + + (if (deviceModel.asKnown().isPresent) 1 else 0) + + (devicePlatform.asKnown().getOrNull()?.validity() ?: 0) + + (if (existingUser.asKnown().isPresent) 1 else 0) + + (if (ip.asKnown().isPresent) 1 else 0) + + (if (isTrustedUser.asKnown().isPresent) 1 else 0) + + (if (ja4Fingerprint.asKnown().isPresent) 1 else 0) + + (if (osVersion.asKnown().isPresent) 1 else 0) + + (if (userAgent.asKnown().isPresent) 1 else 0) + + /** The type of the user's device. */ + class DevicePlatform @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 ANDROID = of("android") + + @JvmField val IOS = of("ios") + + @JvmField val IPADOS = of("ipados") + + @JvmField val TVOS = of("tvos") + + @JvmField val WEB = of("web") + + @JvmStatic fun of(value: String) = DevicePlatform(JsonField.of(value)) + } + + /** An enum containing [DevicePlatform]'s known values. */ + enum class Known { + ANDROID, + IOS, + IPADOS, + TVOS, + WEB, + } + + /** + * An enum containing [DevicePlatform]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [DevicePlatform] 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 { + ANDROID, + IOS, + IPADOS, + TVOS, + WEB, + /** + * An enum member indicating that [DevicePlatform] 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) { + ANDROID -> Value.ANDROID + IOS -> Value.IOS + IPADOS -> Value.IPADOS + TVOS -> Value.TVOS + WEB -> Value.WEB + 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 PreludeInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ANDROID -> Known.ANDROID + IOS -> Known.IOS + IPADOS -> Known.IPADOS + TVOS -> Known.TVOS + WEB -> Known.WEB + else -> throw PreludeInvalidDataException("Unknown DevicePlatform: $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 PreludeInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { PreludeInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws PreludeInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): DevicePlatform = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: PreludeInvalidDataException) { + 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 DevicePlatform && 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 Signals && + appVersion == other.appVersion && + deviceId == other.deviceId && + deviceModel == other.deviceModel && + devicePlatform == other.devicePlatform && + existingUser == other.existingUser && + ip == other.ip && + isTrustedUser == other.isTrustedUser && + ja4Fingerprint == other.ja4Fingerprint && + osVersion == other.osVersion && + userAgent == other.userAgent && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + appVersion, + deviceId, + deviceModel, + devicePlatform, + existingUser, + ip, + isTrustedUser, + ja4Fingerprint, + osVersion, + userAgent, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Signals{appVersion=$appVersion, deviceId=$deviceId, deviceModel=$deviceModel, devicePlatform=$devicePlatform, existingUser=$existingUser, ip=$ip, isTrustedUser=$isTrustedUser, ja4Fingerprint=$ja4Fingerprint, osVersion=$osVersion, userAgent=$userAgent, additionalProperties=$additionalProperties}" +} diff --git a/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/Target.kt b/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/Target.kt new file mode 100644 index 00000000..38cc1b2c --- /dev/null +++ b/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/Target.kt @@ -0,0 +1,356 @@ +// File generated from our OpenAPI spec by Stainless. + +package so.prelude.sdk.models + +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 kotlin.jvm.optionals.getOrNull +import so.prelude.sdk.core.Enum +import so.prelude.sdk.core.ExcludeMissing +import so.prelude.sdk.core.JsonField +import so.prelude.sdk.core.JsonMissing +import so.prelude.sdk.core.JsonValue +import so.prelude.sdk.core.checkRequired +import so.prelude.sdk.errors.PreludeInvalidDataException + +/** The operation target. Either a phone number or an email address. */ +class Target +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val type: JsonField, + private val value: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("value") @ExcludeMissing value: JsonField = JsonMissing.of(), + ) : this(type, value, mutableMapOf()) + + /** + * The type of the target. Either "phone_number" or "email_address". + * + * @throws PreludeInvalidDataException 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 type(): Type = type.getRequired("type") + + /** + * An E.164 formatted phone number or an email address. + * + * @throws PreludeInvalidDataException 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 value(): String = value.getRequired("value") + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + /** + * Returns the raw JSON value of [value]. + * + * Unlike [value], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value + + @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 [Target]. + * + * The following fields are required: + * ```java + * .type() + * .value() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Target]. */ + class Builder internal constructor() { + + private var type: JsonField? = null + private var value: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(target: Target) = apply { + type = target.type + value = target.value + additionalProperties = target.additionalProperties.toMutableMap() + } + + /** The type of the target. Either "phone_number" or "email_address". */ + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + /** An E.164 formatted phone number or an email address. */ + fun value(value: String) = value(JsonField.of(value)) + + /** + * Sets [Builder.value] to an arbitrary JSON value. + * + * You should usually call [Builder.value] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun value(value: JsonField) = apply { this.value = value } + + 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 [Target]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .type() + * .value() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Target = + Target( + checkRequired("type", type), + checkRequired("value", value), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws PreludeInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Target = apply { + if (validated) { + return@apply + } + + type().validate() + value() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: PreludeInvalidDataException) { + 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 = + (type.asKnown().getOrNull()?.validity() ?: 0) + (if (value.asKnown().isPresent) 1 else 0) + + /** The type of the target. Either "phone_number" or "email_address". */ + class Type @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 PHONE_NUMBER = of("phone_number") + + @JvmField val EMAIL_ADDRESS = of("email_address") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + PHONE_NUMBER, + EMAIL_ADDRESS, + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] 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 { + PHONE_NUMBER, + EMAIL_ADDRESS, + /** An enum member indicating that [Type] 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) { + PHONE_NUMBER -> Value.PHONE_NUMBER + EMAIL_ADDRESS -> Value.EMAIL_ADDRESS + 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 PreludeInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PHONE_NUMBER -> Known.PHONE_NUMBER + EMAIL_ADDRESS -> Known.EMAIL_ADDRESS + else -> throw PreludeInvalidDataException("Unknown Type: $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 PreludeInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { PreludeInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws PreludeInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: PreludeInvalidDataException) { + 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 Type && 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 Target && + type == other.type && + value == other.value && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(type, value, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Target{type=$type, value=$value, additionalProperties=$additionalProperties}" +} diff --git a/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/VerificationCheckParams.kt b/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/VerificationCheckParams.kt index a55b1bcc..3a5e2607 100644 --- a/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/VerificationCheckParams.kt +++ b/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/VerificationCheckParams.kt @@ -10,7 +10,6 @@ import java.util.Collections import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull -import so.prelude.sdk.core.Enum import so.prelude.sdk.core.ExcludeMissing import so.prelude.sdk.core.JsonField import so.prelude.sdk.core.JsonMissing @@ -562,355 +561,6 @@ private constructor( "Body{code=$code, target=$target, psd2=$psd2, additionalProperties=$additionalProperties}" } - /** - * The verification target. Either a phone number or an email address. To use the email - * verification feature contact us to discuss your use case. - */ - class Target - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val type: JsonField, - private val value: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - @JsonProperty("value") @ExcludeMissing value: JsonField = JsonMissing.of(), - ) : this(type, value, mutableMapOf()) - - /** - * The type of the target. Either "phone_number" or "email_address". - * - * @throws PreludeInvalidDataException 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 type(): Type = type.getRequired("type") - - /** - * An E.164 formatted phone number or an email address. - * - * @throws PreludeInvalidDataException 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 value(): String = value.getRequired("value") - - /** - * Returns the raw JSON value of [type]. - * - * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - /** - * Returns the raw JSON value of [value]. - * - * Unlike [value], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value - - @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 [Target]. - * - * The following fields are required: - * ```java - * .type() - * .value() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Target]. */ - class Builder internal constructor() { - - private var type: JsonField? = null - private var value: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(target: Target) = apply { - type = target.type - value = target.value - additionalProperties = target.additionalProperties.toMutableMap() - } - - /** The type of the target. Either "phone_number" or "email_address". */ - fun type(type: Type) = type(JsonField.of(type)) - - /** - * Sets [Builder.type] to an arbitrary JSON value. - * - * You should usually call [Builder.type] with a well-typed [Type] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun type(type: JsonField) = apply { this.type = type } - - /** An E.164 formatted phone number or an email address. */ - fun value(value: String) = value(JsonField.of(value)) - - /** - * Sets [Builder.value] to an arbitrary JSON value. - * - * You should usually call [Builder.value] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun value(value: JsonField) = apply { this.value = value } - - 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 [Target]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .type() - * .value() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Target = - Target( - checkRequired("type", type), - checkRequired("value", value), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing fields. - * - * @throws PreludeInvalidDataException if any value type in this object doesn't match its - * expected type. - */ - fun validate(): Target = apply { - if (validated) { - return@apply - } - - type().validate() - value() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: PreludeInvalidDataException) { - 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 = - (type.asKnown().getOrNull()?.validity() ?: 0) + - (if (value.asKnown().isPresent) 1 else 0) - - /** The type of the target. Either "phone_number" or "email_address". */ - class Type @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 PHONE_NUMBER = of("phone_number") - - @JvmField val EMAIL_ADDRESS = of("email_address") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - PHONE_NUMBER, - EMAIL_ADDRESS, - } - - /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Type] 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 { - PHONE_NUMBER, - EMAIL_ADDRESS, - /** An enum member indicating that [Type] 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) { - PHONE_NUMBER -> Value.PHONE_NUMBER - EMAIL_ADDRESS -> Value.EMAIL_ADDRESS - 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 PreludeInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - PHONE_NUMBER -> Known.PHONE_NUMBER - EMAIL_ADDRESS -> Known.EMAIL_ADDRESS - else -> throw PreludeInvalidDataException("Unknown Type: $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 PreludeInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - PreludeInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws PreludeInvalidDataException if any value type in this object doesn't match - * its expected type. - */ - fun validate(): Type = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: PreludeInvalidDataException) { - 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 Type && 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 Target && - type == other.type && - value == other.value && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(type, value, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Target{type=$type, value=$value, additionalProperties=$additionalProperties}" - } - /** * Required when checking a code issued under the `prelude:psd2` template. The submitted * variables must match those provided at issuance; any mismatch invalidates the code (PSD2 SCA diff --git a/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/VerificationCreateParams.kt b/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/VerificationCreateParams.kt index 8bd0ed53..b6f6a63e 100644 --- a/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/VerificationCreateParams.kt +++ b/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/VerificationCreateParams.kt @@ -704,52 +704,41 @@ private constructor( } /** - * The verification target. Either a phone number or an email address. To use the email - * verification feature contact us to discuss your use case. + * The metadata for this verification. This object will be returned with every response or + * webhook sent that refers to this verification. */ - class Target + class Metadata @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val type: JsonField, - private val value: JsonField, + private val correlationId: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - @JsonProperty("value") @ExcludeMissing value: JsonField = JsonMissing.of(), - ) : this(type, value, mutableMapOf()) - - /** - * The type of the target. Either "phone_number" or "email_address". - * - * @throws PreludeInvalidDataException 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 type(): Type = type.getRequired("type") - - /** - * An E.164 formatted phone number or an email address. - * - * @throws PreludeInvalidDataException 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 value(): String = value.getRequired("value") + @JsonProperty("correlation_id") + @ExcludeMissing + correlationId: JsonField = JsonMissing.of() + ) : this(correlationId, mutableMapOf()) /** - * Returns the raw JSON value of [type]. + * A user-defined identifier to correlate this verification with. It is returned in the + * response and any webhook events that refer to this verification. * - * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + fun correlationId(): Optional = correlationId.getOptional("correlation_id") /** - * Returns the raw JSON value of [value]. + * Returns the raw JSON value of [correlationId]. * - * Unlike [value], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [correlationId], this method doesn't throw if the JSON field has an unexpected + * type. */ - @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value + @JsonProperty("correlation_id") + @ExcludeMissing + fun _correlationId(): JsonField = correlationId @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -765,55 +754,38 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [Target]. - * - * The following fields are required: - * ```java - * .type() - * .value() - * ``` - */ + /** Returns a mutable builder for constructing an instance of [Metadata]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [Target]. */ + /** A builder for [Metadata]. */ class Builder internal constructor() { - private var type: JsonField? = null - private var value: JsonField? = null + private var correlationId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(target: Target) = apply { - type = target.type - value = target.value - additionalProperties = target.additionalProperties.toMutableMap() + internal fun from(metadata: Metadata) = apply { + correlationId = metadata.correlationId + additionalProperties = metadata.additionalProperties.toMutableMap() } - /** The type of the target. Either "phone_number" or "email_address". */ - fun type(type: Type) = type(JsonField.of(type)) - /** - * Sets [Builder.type] to an arbitrary JSON value. - * - * You should usually call [Builder.type] with a well-typed [Type] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. + * A user-defined identifier to correlate this verification with. It is returned in the + * response and any webhook events that refer to this verification. */ - fun type(type: JsonField) = apply { this.type = type } - - /** An E.164 formatted phone number or an email address. */ - fun value(value: String) = value(JsonField.of(value)) + fun correlationId(correlationId: String) = correlationId(JsonField.of(correlationId)) /** - * Sets [Builder.value] to an arbitrary JSON value. + * Sets [Builder.correlationId] to an arbitrary JSON value. * - * You should usually call [Builder.value] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet + * You should usually call [Builder.correlationId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun value(value: JsonField) = apply { this.value = value } + fun correlationId(correlationId: JsonField) = apply { + this.correlationId = correlationId + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -835,24 +807,11 @@ private constructor( } /** - * Returns an immutable instance of [Target]. + * Returns an immutable instance of [Metadata]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .type() - * .value() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ - fun build(): Target = - Target( - checkRequired("type", type), - checkRequired("value", value), - additionalProperties.toMutableMap(), - ) + fun build(): Metadata = Metadata(correlationId, additionalProperties.toMutableMap()) } private var validated: Boolean = false @@ -866,13 +825,12 @@ private constructor( * @throws PreludeInvalidDataException if any value type in this object doesn't match its * expected type. */ - fun validate(): Target = apply { + fun validate(): Metadata = apply { if (validated) { return@apply } - type().validate() - value() + correlationId() validated = true } @@ -891,356 +849,49 @@ private constructor( * Used for best match union deserialization. */ @JvmSynthetic - internal fun validity(): Int = - (type.asKnown().getOrNull()?.validity() ?: 0) + - (if (value.asKnown().isPresent) 1 else 0) - - /** The type of the target. Either "phone_number" or "email_address". */ - class Type @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 PHONE_NUMBER = of("phone_number") - - @JvmField val EMAIL_ADDRESS = of("email_address") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - PHONE_NUMBER, - EMAIL_ADDRESS, - } - - /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Type] 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 { - PHONE_NUMBER, - EMAIL_ADDRESS, - /** An enum member indicating that [Type] 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) { - PHONE_NUMBER -> Value.PHONE_NUMBER - EMAIL_ADDRESS -> Value.EMAIL_ADDRESS - 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 PreludeInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - PHONE_NUMBER -> Known.PHONE_NUMBER - EMAIL_ADDRESS -> Known.EMAIL_ADDRESS - else -> throw PreludeInvalidDataException("Unknown Type: $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 PreludeInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - PreludeInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws PreludeInvalidDataException if any value type in this object doesn't match - * its expected type. - */ - fun validate(): Type = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: PreludeInvalidDataException) { - 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 Type && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } + internal fun validity(): Int = (if (correlationId.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is Target && - type == other.type && - value == other.value && + return other is Metadata && + correlationId == other.correlationId && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(type, value, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(correlationId, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "Target{type=$type, value=$value, additionalProperties=$additionalProperties}" + "Metadata{correlationId=$correlationId, additionalProperties=$additionalProperties}" } - /** - * The metadata for this verification. This object will be returned with every response or - * webhook sent that refers to this verification. - */ - class Metadata + /** Verification options */ + class Options @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val correlationId: JsonField, + private val appRealm: JsonField, + private val callbackUrl: JsonField, + private val channels: JsonField>, + private val codeSize: JsonField, + private val customCode: JsonField, + private val forceChallenge: JsonField, + private val locale: JsonField, + private val maxAutoFallbacks: JsonField, + private val method: JsonField, + private val preferredChannel: JsonField, + private val senderId: JsonField, + private val templateId: JsonField, + private val variables: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("correlation_id") - @ExcludeMissing - correlationId: JsonField = JsonMissing.of() - ) : this(correlationId, mutableMapOf()) - - /** - * A user-defined identifier to correlate this verification with. It is returned in the - * response and any webhook events that refer to this verification. - * - * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun correlationId(): Optional = correlationId.getOptional("correlation_id") - - /** - * Returns the raw JSON value of [correlationId]. - * - * Unlike [correlationId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("correlation_id") - @ExcludeMissing - fun _correlationId(): JsonField = correlationId - - @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 [Metadata]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Metadata]. */ - class Builder internal constructor() { - - private var correlationId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - correlationId = metadata.correlationId - additionalProperties = metadata.additionalProperties.toMutableMap() - } - - /** - * A user-defined identifier to correlate this verification with. It is returned in the - * response and any webhook events that refer to this verification. - */ - fun correlationId(correlationId: String) = correlationId(JsonField.of(correlationId)) - - /** - * Sets [Builder.correlationId] to an arbitrary JSON value. - * - * You should usually call [Builder.correlationId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun correlationId(correlationId: JsonField) = apply { - this.correlationId = correlationId - } - - 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(correlationId, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing fields. - * - * @throws PreludeInvalidDataException if any value type in this object doesn't match its - * expected type. - */ - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - correlationId() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: PreludeInvalidDataException) { - 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 (correlationId.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metadata && - correlationId == other.correlationId && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(correlationId, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Metadata{correlationId=$correlationId, additionalProperties=$additionalProperties}" - } - - /** Verification options */ - class Options - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val appRealm: JsonField, - private val callbackUrl: JsonField, - private val channels: JsonField>, - private val codeSize: JsonField, - private val customCode: JsonField, - private val forceChallenge: JsonField, - private val locale: JsonField, - private val maxAutoFallbacks: JsonField, - private val method: JsonField, - private val preferredChannel: JsonField, - private val senderId: JsonField, - private val templateId: JsonField, - private val variables: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("app_realm") + @JsonProperty("app_realm") @ExcludeMissing appRealm: JsonField = JsonMissing.of(), @JsonProperty("callback_url") @@ -2617,934 +2268,57 @@ private constructor( * * This method is _not_ forwards compatible with new types from the API for existing * fields. - * - * @throws PreludeInvalidDataException if any value type in this object doesn't match - * its expected type. - */ - fun validate(): Method = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: PreludeInvalidDataException) { - 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 Method && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * The channel to prioritize when delivering the verification. Prelude prioritizes this - * channel on the first attempt and continues to prefer it on retries while an untried route - * on that channel remains; once those are exhausted, retries fall back to the next best - * available route. If the channel is unavailable (for example, when a verification is - * challenged), Prelude uses the best available route instead. Cannot be combined with - * `channels`. - */ - class PreferredChannel - @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 SMS = of("sms") - - @JvmField val RCS = of("rcs") - - @JvmField val WHATSAPP = of("whatsapp") - - @JvmField val VIBER = of("viber") - - @JvmField val ZALO = of("zalo") - - @JvmField val TELEGRAM = of("telegram") - - @JvmStatic fun of(value: String) = PreferredChannel(JsonField.of(value)) - } - - /** An enum containing [PreferredChannel]'s known values. */ - enum class Known { - SMS, - RCS, - WHATSAPP, - VIBER, - ZALO, - TELEGRAM, - } - - /** - * An enum containing [PreferredChannel]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [PreferredChannel] 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 { - SMS, - RCS, - WHATSAPP, - VIBER, - ZALO, - TELEGRAM, - /** - * An enum member indicating that [PreferredChannel] 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) { - SMS -> Value.SMS - RCS -> Value.RCS - WHATSAPP -> Value.WHATSAPP - VIBER -> Value.VIBER - ZALO -> Value.ZALO - TELEGRAM -> Value.TELEGRAM - 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 PreludeInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - SMS -> Known.SMS - RCS -> Known.RCS - WHATSAPP -> Known.WHATSAPP - VIBER -> Known.VIBER - ZALO -> Known.ZALO - TELEGRAM -> Known.TELEGRAM - else -> throw PreludeInvalidDataException("Unknown PreferredChannel: $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 PreludeInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - PreludeInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws PreludeInvalidDataException if any value type in this object doesn't match - * its expected type. - */ - fun validate(): PreferredChannel = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: PreludeInvalidDataException) { - 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 PreferredChannel && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** The variables to be replaced in the template. */ - class Variables - @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 [Variables]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Variables]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(variables: Variables) = apply { - additionalProperties = variables.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 [Variables]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Variables = Variables(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws PreludeInvalidDataException if any value type in this object doesn't match - * its expected type. - */ - fun validate(): Variables = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: PreludeInvalidDataException) { - 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 Variables && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Variables{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Options && - appRealm == other.appRealm && - callbackUrl == other.callbackUrl && - channels == other.channels && - codeSize == other.codeSize && - customCode == other.customCode && - forceChallenge == other.forceChallenge && - locale == other.locale && - maxAutoFallbacks == other.maxAutoFallbacks && - method == other.method && - preferredChannel == other.preferredChannel && - senderId == other.senderId && - templateId == other.templateId && - variables == other.variables && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - appRealm, - callbackUrl, - channels, - codeSize, - customCode, - forceChallenge, - locale, - maxAutoFallbacks, - method, - preferredChannel, - senderId, - templateId, - variables, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Options{appRealm=$appRealm, callbackUrl=$callbackUrl, channels=$channels, codeSize=$codeSize, customCode=$customCode, forceChallenge=$forceChallenge, locale=$locale, maxAutoFallbacks=$maxAutoFallbacks, method=$method, preferredChannel=$preferredChannel, senderId=$senderId, templateId=$templateId, variables=$variables, additionalProperties=$additionalProperties}" - } - - /** - * The signals used for anti-fraud. For more details, refer to - * [Signals](/verify/v2/documentation/prevent-fraud#signals). - */ - class Signals - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val appVersion: JsonField, - private val deviceId: JsonField, - private val deviceModel: JsonField, - private val devicePlatform: JsonField, - private val existingUser: JsonField, - private val ip: JsonField, - private val isTrustedUser: JsonField, - private val ja4Fingerprint: JsonField, - private val osVersion: JsonField, - private val userAgent: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("app_version") - @ExcludeMissing - appVersion: JsonField = JsonMissing.of(), - @JsonProperty("device_id") - @ExcludeMissing - deviceId: JsonField = JsonMissing.of(), - @JsonProperty("device_model") - @ExcludeMissing - deviceModel: JsonField = JsonMissing.of(), - @JsonProperty("device_platform") - @ExcludeMissing - devicePlatform: JsonField = JsonMissing.of(), - @JsonProperty("existing_user") - @ExcludeMissing - existingUser: JsonField = JsonMissing.of(), - @JsonProperty("ip") @ExcludeMissing ip: JsonField = JsonMissing.of(), - @JsonProperty("is_trusted_user") - @ExcludeMissing - isTrustedUser: JsonField = JsonMissing.of(), - @JsonProperty("ja4_fingerprint") - @ExcludeMissing - ja4Fingerprint: JsonField = JsonMissing.of(), - @JsonProperty("os_version") - @ExcludeMissing - osVersion: JsonField = JsonMissing.of(), - @JsonProperty("user_agent") - @ExcludeMissing - userAgent: JsonField = JsonMissing.of(), - ) : this( - appVersion, - deviceId, - deviceModel, - devicePlatform, - existingUser, - ip, - isTrustedUser, - ja4Fingerprint, - osVersion, - userAgent, - mutableMapOf(), - ) - - /** - * The version of your application. - * - * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun appVersion(): Optional = appVersion.getOptional("app_version") - - /** - * A unique ID for the user's device. You should ensure that each user device has a unique - * `device_id` value. Ideally, for Android, this corresponds to the `ANDROID_ID` and for - * iOS, this corresponds to the `identifierForVendor`. - * - * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun deviceId(): Optional = deviceId.getOptional("device_id") - - /** - * The model of the user's device. - * - * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun deviceModel(): Optional = deviceModel.getOptional("device_model") - - /** - * The type of the user's device. - * - * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun devicePlatform(): Optional = - devicePlatform.getOptional("device_platform") - - /** - * Whether the end-user already exists in your system, for example an existing account - * signing in again rather than a first-time signup. Unlike `is_trusted_user`, this signal - * does not bypass fraud checks; it is taken into account as one additional anti-fraud - * signal. For more details, refer to - * [Signals](/verify/v2/documentation/prevent-fraud#signals). - * - * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun existingUser(): Optional = existingUser.getOptional("existing_user") - - /** - * The public IP v4 or v6 address of the end-user's device. You should collect this from - * your backend. If your backend is behind a proxy, use the `X-Forwarded-For`, `Forwarded`, - * `True-Client-IP`, `CF-Connecting-IP` or an equivalent header to get the actual public IP - * of the end-user's device. - * - * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun ip(): Optional = ip.getOptional("ip") - - /** - * This signal should indicate a higher level of trust, explicitly stating that the user is - * genuine. Contact us to discuss your use case. For more details, refer to - * [Signals](/verify/v2/documentation/prevent-fraud#signals). - * - * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun isTrustedUser(): Optional = isTrustedUser.getOptional("is_trusted_user") - - /** - * The JA4 fingerprint observed for the end-user's connection. Prelude will infer it - * automatically when you use our Frontend SDKs (which use Prelude's edge network), but you - * can also forward the value if you terminate TLS yourself. - * - * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun ja4Fingerprint(): Optional = ja4Fingerprint.getOptional("ja4_fingerprint") - - /** - * The version of the user's device operating system. - * - * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun osVersion(): Optional = osVersion.getOptional("os_version") - - /** - * The user agent of the user's device. If the individual fields (os_version, - * device_platform, device_model) are provided, we will prioritize those values instead of - * parsing them from the user agent string. - * - * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun userAgent(): Optional = userAgent.getOptional("user_agent") - - /** - * Returns the raw JSON value of [appVersion]. - * - * Unlike [appVersion], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("app_version") - @ExcludeMissing - fun _appVersion(): JsonField = appVersion - - /** - * Returns the raw JSON value of [deviceId]. - * - * Unlike [deviceId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("device_id") @ExcludeMissing fun _deviceId(): JsonField = deviceId - - /** - * Returns the raw JSON value of [deviceModel]. - * - * Unlike [deviceModel], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("device_model") - @ExcludeMissing - fun _deviceModel(): JsonField = deviceModel - - /** - * Returns the raw JSON value of [devicePlatform]. - * - * Unlike [devicePlatform], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("device_platform") - @ExcludeMissing - fun _devicePlatform(): JsonField = devicePlatform - - /** - * Returns the raw JSON value of [existingUser]. - * - * Unlike [existingUser], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("existing_user") - @ExcludeMissing - fun _existingUser(): JsonField = existingUser - - /** - * Returns the raw JSON value of [ip]. - * - * Unlike [ip], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("ip") @ExcludeMissing fun _ip(): JsonField = ip - - /** - * Returns the raw JSON value of [isTrustedUser]. - * - * Unlike [isTrustedUser], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("is_trusted_user") - @ExcludeMissing - fun _isTrustedUser(): JsonField = isTrustedUser - - /** - * Returns the raw JSON value of [ja4Fingerprint]. - * - * Unlike [ja4Fingerprint], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("ja4_fingerprint") - @ExcludeMissing - fun _ja4Fingerprint(): JsonField = ja4Fingerprint - - /** - * Returns the raw JSON value of [osVersion]. - * - * Unlike [osVersion], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("os_version") @ExcludeMissing fun _osVersion(): JsonField = osVersion - - /** - * Returns the raw JSON value of [userAgent]. - * - * Unlike [userAgent], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("user_agent") @ExcludeMissing fun _userAgent(): JsonField = userAgent - - @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 [Signals]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Signals]. */ - class Builder internal constructor() { - - private var appVersion: JsonField = JsonMissing.of() - private var deviceId: JsonField = JsonMissing.of() - private var deviceModel: JsonField = JsonMissing.of() - private var devicePlatform: JsonField = JsonMissing.of() - private var existingUser: JsonField = JsonMissing.of() - private var ip: JsonField = JsonMissing.of() - private var isTrustedUser: JsonField = JsonMissing.of() - private var ja4Fingerprint: JsonField = JsonMissing.of() - private var osVersion: JsonField = JsonMissing.of() - private var userAgent: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(signals: Signals) = apply { - appVersion = signals.appVersion - deviceId = signals.deviceId - deviceModel = signals.deviceModel - devicePlatform = signals.devicePlatform - existingUser = signals.existingUser - ip = signals.ip - isTrustedUser = signals.isTrustedUser - ja4Fingerprint = signals.ja4Fingerprint - osVersion = signals.osVersion - userAgent = signals.userAgent - additionalProperties = signals.additionalProperties.toMutableMap() - } - - /** The version of your application. */ - fun appVersion(appVersion: String) = appVersion(JsonField.of(appVersion)) - - /** - * Sets [Builder.appVersion] to an arbitrary JSON value. - * - * You should usually call [Builder.appVersion] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun appVersion(appVersion: JsonField) = apply { this.appVersion = appVersion } - - /** - * A unique ID for the user's device. You should ensure that each user device has a - * unique `device_id` value. Ideally, for Android, this corresponds to the `ANDROID_ID` - * and for iOS, this corresponds to the `identifierForVendor`. - */ - fun deviceId(deviceId: String) = deviceId(JsonField.of(deviceId)) - - /** - * Sets [Builder.deviceId] to an arbitrary JSON value. - * - * You should usually call [Builder.deviceId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun deviceId(deviceId: JsonField) = apply { this.deviceId = deviceId } - - /** The model of the user's device. */ - fun deviceModel(deviceModel: String) = deviceModel(JsonField.of(deviceModel)) - - /** - * Sets [Builder.deviceModel] to an arbitrary JSON value. - * - * You should usually call [Builder.deviceModel] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun deviceModel(deviceModel: JsonField) = apply { - this.deviceModel = deviceModel - } - - /** The type of the user's device. */ - fun devicePlatform(devicePlatform: DevicePlatform) = - devicePlatform(JsonField.of(devicePlatform)) - - /** - * Sets [Builder.devicePlatform] to an arbitrary JSON value. - * - * You should usually call [Builder.devicePlatform] with a well-typed [DevicePlatform] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun devicePlatform(devicePlatform: JsonField) = apply { - this.devicePlatform = devicePlatform - } - - /** - * Whether the end-user already exists in your system, for example an existing account - * signing in again rather than a first-time signup. Unlike `is_trusted_user`, this - * signal does not bypass fraud checks; it is taken into account as one additional - * anti-fraud signal. For more details, refer to - * [Signals](/verify/v2/documentation/prevent-fraud#signals). - */ - fun existingUser(existingUser: Boolean) = existingUser(JsonField.of(existingUser)) - - /** - * Sets [Builder.existingUser] to an arbitrary JSON value. - * - * You should usually call [Builder.existingUser] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun existingUser(existingUser: JsonField) = apply { - this.existingUser = existingUser - } - - /** - * The public IP v4 or v6 address of the end-user's device. You should collect this from - * your backend. If your backend is behind a proxy, use the `X-Forwarded-For`, - * `Forwarded`, `True-Client-IP`, `CF-Connecting-IP` or an equivalent header to get the - * actual public IP of the end-user's device. - */ - fun ip(ip: String) = ip(JsonField.of(ip)) - - /** - * Sets [Builder.ip] to an arbitrary JSON value. - * - * You should usually call [Builder.ip] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun ip(ip: JsonField) = apply { this.ip = ip } - - /** - * This signal should indicate a higher level of trust, explicitly stating that the user - * is genuine. Contact us to discuss your use case. For more details, refer to - * [Signals](/verify/v2/documentation/prevent-fraud#signals). - */ - fun isTrustedUser(isTrustedUser: Boolean) = isTrustedUser(JsonField.of(isTrustedUser)) - - /** - * Sets [Builder.isTrustedUser] to an arbitrary JSON value. - * - * You should usually call [Builder.isTrustedUser] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun isTrustedUser(isTrustedUser: JsonField) = apply { - this.isTrustedUser = isTrustedUser - } - - /** - * The JA4 fingerprint observed for the end-user's connection. Prelude will infer it - * automatically when you use our Frontend SDKs (which use Prelude's edge network), but - * you can also forward the value if you terminate TLS yourself. - */ - fun ja4Fingerprint(ja4Fingerprint: String) = - ja4Fingerprint(JsonField.of(ja4Fingerprint)) - - /** - * Sets [Builder.ja4Fingerprint] to an arbitrary JSON value. - * - * You should usually call [Builder.ja4Fingerprint] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun ja4Fingerprint(ja4Fingerprint: JsonField) = apply { - this.ja4Fingerprint = ja4Fingerprint - } - - /** The version of the user's device operating system. */ - fun osVersion(osVersion: String) = osVersion(JsonField.of(osVersion)) - - /** - * Sets [Builder.osVersion] to an arbitrary JSON value. - * - * You should usually call [Builder.osVersion] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun osVersion(osVersion: JsonField) = apply { this.osVersion = osVersion } - - /** - * The user agent of the user's device. If the individual fields (os_version, - * device_platform, device_model) are provided, we will prioritize those values instead - * of parsing them from the user agent string. - */ - fun userAgent(userAgent: String) = userAgent(JsonField.of(userAgent)) - - /** - * Sets [Builder.userAgent] to an arbitrary JSON value. - * - * You should usually call [Builder.userAgent] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun userAgent(userAgent: JsonField) = apply { this.userAgent = userAgent } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + * + * @throws PreludeInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): Method = apply { + if (validated) { + return@apply + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) + known() + validated = true } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: PreludeInvalidDataException) { + false + } /** - * Returns an immutable instance of [Signals]. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * Further updates to this [Builder] will not mutate the returned instance. + * Used for best match union deserialization. */ - fun build(): Signals = - Signals( - appVersion, - deviceId, - deviceModel, - devicePlatform, - existingUser, - ip, - isTrustedUser, - ja4Fingerprint, - osVersion, - userAgent, - additionalProperties.toMutableMap(), - ) - } + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - private var validated: Boolean = false + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing fields. - * - * @throws PreludeInvalidDataException if any value type in this object doesn't match its - * expected type. - */ - fun validate(): Signals = apply { - if (validated) { - return@apply + return other is Method && value == other.value } - appVersion() - deviceId() - deviceModel() - devicePlatform().ifPresent { it.validate() } - existingUser() - ip() - isTrustedUser() - ja4Fingerprint() - osVersion() - userAgent() - validated = true - } + override fun hashCode() = value.hashCode() - fun isValid(): Boolean = - try { - validate() - true - } catch (e: PreludeInvalidDataException) { - false - } + override fun toString() = value.toString() + } /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. + * The channel to prioritize when delivering the verification. Prelude prioritizes this + * channel on the first attempt and continues to prefer it on retries while an untried route + * on that channel remains; once those are exhausted, retries fall back to the next best + * available route. If the channel is unavailable (for example, when a verification is + * challenged), Prelude uses the best available route instead. Cannot be combined with + * `channels`. */ - @JvmSynthetic - internal fun validity(): Int = - (if (appVersion.asKnown().isPresent) 1 else 0) + - (if (deviceId.asKnown().isPresent) 1 else 0) + - (if (deviceModel.asKnown().isPresent) 1 else 0) + - (devicePlatform.asKnown().getOrNull()?.validity() ?: 0) + - (if (existingUser.asKnown().isPresent) 1 else 0) + - (if (ip.asKnown().isPresent) 1 else 0) + - (if (isTrustedUser.asKnown().isPresent) 1 else 0) + - (if (ja4Fingerprint.asKnown().isPresent) 1 else 0) + - (if (osVersion.asKnown().isPresent) 1 else 0) + - (if (userAgent.asKnown().isPresent) 1 else 0) - - /** The type of the user's device. */ - class DevicePlatform + class PreferredChannel @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -3560,46 +2334,51 @@ private constructor( companion object { - @JvmField val ANDROID = of("android") + @JvmField val SMS = of("sms") + + @JvmField val RCS = of("rcs") - @JvmField val IOS = of("ios") + @JvmField val WHATSAPP = of("whatsapp") - @JvmField val IPADOS = of("ipados") + @JvmField val VIBER = of("viber") - @JvmField val TVOS = of("tvos") + @JvmField val ZALO = of("zalo") - @JvmField val WEB = of("web") + @JvmField val TELEGRAM = of("telegram") - @JvmStatic fun of(value: String) = DevicePlatform(JsonField.of(value)) + @JvmStatic fun of(value: String) = PreferredChannel(JsonField.of(value)) } - /** An enum containing [DevicePlatform]'s known values. */ + /** An enum containing [PreferredChannel]'s known values. */ enum class Known { - ANDROID, - IOS, - IPADOS, - TVOS, - WEB, + SMS, + RCS, + WHATSAPP, + VIBER, + ZALO, + TELEGRAM, } /** - * An enum containing [DevicePlatform]'s known values, as well as an [_UNKNOWN] member. + * An enum containing [PreferredChannel]'s known values, as well as an [_UNKNOWN] + * member. * - * An instance of [DevicePlatform] can contain an unknown value in a couple of cases: + * An instance of [PreferredChannel] 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 { - ANDROID, - IOS, - IPADOS, - TVOS, - WEB, + SMS, + RCS, + WHATSAPP, + VIBER, + ZALO, + TELEGRAM, /** - * An enum member indicating that [DevicePlatform] was instantiated with an unknown - * value. + * An enum member indicating that [PreferredChannel] was instantiated with an + * unknown value. */ _UNKNOWN, } @@ -3613,11 +2392,12 @@ private constructor( */ fun value(): Value = when (this) { - ANDROID -> Value.ANDROID - IOS -> Value.IOS - IPADOS -> Value.IPADOS - TVOS -> Value.TVOS - WEB -> Value.WEB + SMS -> Value.SMS + RCS -> Value.RCS + WHATSAPP -> Value.WHATSAPP + VIBER -> Value.VIBER + ZALO -> Value.ZALO + TELEGRAM -> Value.TELEGRAM else -> Value._UNKNOWN } @@ -3632,12 +2412,13 @@ private constructor( */ fun known(): Known = when (this) { - ANDROID -> Known.ANDROID - IOS -> Known.IOS - IPADOS -> Known.IPADOS - TVOS -> Known.TVOS - WEB -> Known.WEB - else -> throw PreludeInvalidDataException("Unknown DevicePlatform: $value") + SMS -> Known.SMS + RCS -> Known.RCS + WHATSAPP -> Known.WHATSAPP + VIBER -> Known.VIBER + ZALO -> Known.ZALO + TELEGRAM -> Known.TELEGRAM + else -> throw PreludeInvalidDataException("Unknown PreferredChannel: $value") } /** @@ -3666,7 +2447,7 @@ private constructor( * @throws PreludeInvalidDataException if any value type in this object doesn't match * its expected type. */ - fun validate(): DevicePlatform = apply { + fun validate(): PreferredChannel = apply { if (validated) { return@apply } @@ -3696,7 +2477,7 @@ private constructor( return true } - return other is DevicePlatform && value == other.value + return other is PreferredChannel && value == other.value } override fun hashCode() = value.hashCode() @@ -3704,37 +2485,156 @@ private constructor( override fun toString() = value.toString() } + /** The variables to be replaced in the template. */ + class Variables + @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 [Variables]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Variables]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(variables: Variables) = apply { + additionalProperties = variables.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 [Variables]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Variables = Variables(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws PreludeInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): Variables = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: PreludeInvalidDataException) { + 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 Variables && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Variables{additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is Signals && - appVersion == other.appVersion && - deviceId == other.deviceId && - deviceModel == other.deviceModel && - devicePlatform == other.devicePlatform && - existingUser == other.existingUser && - ip == other.ip && - isTrustedUser == other.isTrustedUser && - ja4Fingerprint == other.ja4Fingerprint && - osVersion == other.osVersion && - userAgent == other.userAgent && + return other is Options && + appRealm == other.appRealm && + callbackUrl == other.callbackUrl && + channels == other.channels && + codeSize == other.codeSize && + customCode == other.customCode && + forceChallenge == other.forceChallenge && + locale == other.locale && + maxAutoFallbacks == other.maxAutoFallbacks && + method == other.method && + preferredChannel == other.preferredChannel && + senderId == other.senderId && + templateId == other.templateId && + variables == other.variables && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( - appVersion, - deviceId, - deviceModel, - devicePlatform, - existingUser, - ip, - isTrustedUser, - ja4Fingerprint, - osVersion, - userAgent, + appRealm, + callbackUrl, + channels, + codeSize, + customCode, + forceChallenge, + locale, + maxAutoFallbacks, + method, + preferredChannel, + senderId, + templateId, + variables, additionalProperties, ) } @@ -3742,7 +2642,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Signals{appVersion=$appVersion, deviceId=$deviceId, deviceModel=$deviceModel, devicePlatform=$devicePlatform, existingUser=$existingUser, ip=$ip, isTrustedUser=$isTrustedUser, ja4Fingerprint=$ja4Fingerprint, osVersion=$osVersion, userAgent=$userAgent, additionalProperties=$additionalProperties}" + "Options{appRealm=$appRealm, callbackUrl=$callbackUrl, channels=$channels, codeSize=$codeSize, customCode=$customCode, forceChallenge=$forceChallenge, locale=$locale, maxAutoFallbacks=$maxAutoFallbacks, method=$method, preferredChannel=$preferredChannel, senderId=$senderId, templateId=$templateId, variables=$variables, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/VerificationManagementSandboxAddPhoneNumberParams.kt b/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/VerificationManagementSandboxAddPhoneNumberParams.kt new file mode 100644 index 00000000..ac06bf7a --- /dev/null +++ b/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/VerificationManagementSandboxAddPhoneNumberParams.kt @@ -0,0 +1,531 @@ +// File generated from our OpenAPI spec by Stainless. + +package so.prelude.sdk.models + +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 so.prelude.sdk.core.ExcludeMissing +import so.prelude.sdk.core.JsonField +import so.prelude.sdk.core.JsonMissing +import so.prelude.sdk.core.JsonValue +import so.prelude.sdk.core.Params +import so.prelude.sdk.core.checkRequired +import so.prelude.sdk.core.http.Headers +import so.prelude.sdk.core.http.QueryParams +import so.prelude.sdk.errors.PreludeInvalidDataException + +/** + * Register a phone number as a sandbox number and associate it with a fixed attempt code. + * Subsequent verification attempts against this number will not trigger a real SMS/call and will + * validate against the configured attempt code. + * + * This operation is idempotent - re-adding the same phone number will overwrite the existing + * attempt code. + * + * In order to get access to this endpoint, contact our support team. + */ +class VerificationManagementSandboxAddPhoneNumberParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * The fixed attempt code that will validate verification attempts for this phone number. + * + * @throws PreludeInvalidDataException 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 attemptCode(): String = body.attemptCode() + + /** + * An E.164 formatted phone number to add to the sandbox list. + * + * @throws PreludeInvalidDataException 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 phoneNumber(): String = body.phoneNumber() + + /** + * Returns the raw JSON value of [attemptCode]. + * + * Unlike [attemptCode], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _attemptCode(): JsonField = body._attemptCode() + + /** + * Returns the raw JSON value of [phoneNumber]. + * + * Unlike [phoneNumber], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _phoneNumber(): JsonField = body._phoneNumber() + + 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 + * [VerificationManagementSandboxAddPhoneNumberParams]. + * + * The following fields are required: + * ```java + * .attemptCode() + * .phoneNumber() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [VerificationManagementSandboxAddPhoneNumberParams]. */ + 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( + verificationManagementSandboxAddPhoneNumberParams: + VerificationManagementSandboxAddPhoneNumberParams + ) = apply { + body = verificationManagementSandboxAddPhoneNumberParams.body.toBuilder() + additionalHeaders = + verificationManagementSandboxAddPhoneNumberParams.additionalHeaders.toBuilder() + additionalQueryParams = + verificationManagementSandboxAddPhoneNumberParams.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: + * - [attemptCode] + * - [phoneNumber] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** + * The fixed attempt code that will validate verification attempts for this phone number. + */ + fun attemptCode(attemptCode: String) = apply { body.attemptCode(attemptCode) } + + /** + * Sets [Builder.attemptCode] to an arbitrary JSON value. + * + * You should usually call [Builder.attemptCode] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun attemptCode(attemptCode: JsonField) = apply { body.attemptCode(attemptCode) } + + /** An E.164 formatted phone number to add to the sandbox list. */ + fun phoneNumber(phoneNumber: String) = apply { body.phoneNumber(phoneNumber) } + + /** + * Sets [Builder.phoneNumber] to an arbitrary JSON value. + * + * You should usually call [Builder.phoneNumber] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun phoneNumber(phoneNumber: JsonField) = apply { body.phoneNumber(phoneNumber) } + + 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 [VerificationManagementSandboxAddPhoneNumberParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .attemptCode() + * .phoneNumber() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): VerificationManagementSandboxAddPhoneNumberParams = + VerificationManagementSandboxAddPhoneNumberParams( + 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 attemptCode: JsonField, + private val phoneNumber: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("attempt_code") + @ExcludeMissing + attemptCode: JsonField = JsonMissing.of(), + @JsonProperty("phone_number") + @ExcludeMissing + phoneNumber: JsonField = JsonMissing.of(), + ) : this(attemptCode, phoneNumber, mutableMapOf()) + + /** + * The fixed attempt code that will validate verification attempts for this phone number. + * + * @throws PreludeInvalidDataException 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 attemptCode(): String = attemptCode.getRequired("attempt_code") + + /** + * An E.164 formatted phone number to add to the sandbox list. + * + * @throws PreludeInvalidDataException 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 phoneNumber(): String = phoneNumber.getRequired("phone_number") + + /** + * Returns the raw JSON value of [attemptCode]. + * + * Unlike [attemptCode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("attempt_code") + @ExcludeMissing + fun _attemptCode(): JsonField = attemptCode + + /** + * Returns the raw JSON value of [phoneNumber]. + * + * Unlike [phoneNumber], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("phone_number") + @ExcludeMissing + fun _phoneNumber(): JsonField = phoneNumber + + @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 + * .attemptCode() + * .phoneNumber() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var attemptCode: JsonField? = null + private var phoneNumber: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + attemptCode = body.attemptCode + phoneNumber = body.phoneNumber + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** + * The fixed attempt code that will validate verification attempts for this phone + * number. + */ + fun attemptCode(attemptCode: String) = attemptCode(JsonField.of(attemptCode)) + + /** + * Sets [Builder.attemptCode] to an arbitrary JSON value. + * + * You should usually call [Builder.attemptCode] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun attemptCode(attemptCode: JsonField) = apply { + this.attemptCode = attemptCode + } + + /** An E.164 formatted phone number to add to the sandbox list. */ + fun phoneNumber(phoneNumber: String) = phoneNumber(JsonField.of(phoneNumber)) + + /** + * Sets [Builder.phoneNumber] to an arbitrary JSON value. + * + * You should usually call [Builder.phoneNumber] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun phoneNumber(phoneNumber: JsonField) = apply { + this.phoneNumber = phoneNumber + } + + 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 + * .attemptCode() + * .phoneNumber() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("attemptCode", attemptCode), + checkRequired("phoneNumber", phoneNumber), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws PreludeInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Body = apply { + if (validated) { + return@apply + } + + attemptCode() + phoneNumber() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: PreludeInvalidDataException) { + 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 (attemptCode.asKnown().isPresent) 1 else 0) + + (if (phoneNumber.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + attemptCode == other.attemptCode && + phoneNumber == other.phoneNumber && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(attemptCode, phoneNumber, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{attemptCode=$attemptCode, phoneNumber=$phoneNumber, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is VerificationManagementSandboxAddPhoneNumberParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "VerificationManagementSandboxAddPhoneNumberParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/VerificationManagementSandboxAddPhoneNumberResponse.kt b/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/VerificationManagementSandboxAddPhoneNumberResponse.kt new file mode 100644 index 00000000..b4afefb5 --- /dev/null +++ b/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/VerificationManagementSandboxAddPhoneNumberResponse.kt @@ -0,0 +1,237 @@ +// File generated from our OpenAPI spec by Stainless. + +package so.prelude.sdk.models + +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 so.prelude.sdk.core.ExcludeMissing +import so.prelude.sdk.core.JsonField +import so.prelude.sdk.core.JsonMissing +import so.prelude.sdk.core.JsonValue +import so.prelude.sdk.core.checkRequired +import so.prelude.sdk.errors.PreludeInvalidDataException + +class VerificationManagementSandboxAddPhoneNumberResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val attemptCode: JsonField, + private val phoneNumber: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("attempt_code") + @ExcludeMissing + attemptCode: JsonField = JsonMissing.of(), + @JsonProperty("phone_number") + @ExcludeMissing + phoneNumber: JsonField = JsonMissing.of(), + ) : this(attemptCode, phoneNumber, mutableMapOf()) + + /** + * The fixed attempt code associated with the sandbox phone number. + * + * @throws PreludeInvalidDataException 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 attemptCode(): String = attemptCode.getRequired("attempt_code") + + /** + * The E.164 formatted phone number that was added to the sandbox list. + * + * @throws PreludeInvalidDataException 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 phoneNumber(): String = phoneNumber.getRequired("phone_number") + + /** + * Returns the raw JSON value of [attemptCode]. + * + * Unlike [attemptCode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("attempt_code") + @ExcludeMissing + fun _attemptCode(): JsonField = attemptCode + + /** + * Returns the raw JSON value of [phoneNumber]. + * + * Unlike [phoneNumber], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("phone_number") + @ExcludeMissing + fun _phoneNumber(): JsonField = phoneNumber + + @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 + * [VerificationManagementSandboxAddPhoneNumberResponse]. + * + * The following fields are required: + * ```java + * .attemptCode() + * .phoneNumber() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [VerificationManagementSandboxAddPhoneNumberResponse]. */ + class Builder internal constructor() { + + private var attemptCode: JsonField? = null + private var phoneNumber: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + verificationManagementSandboxAddPhoneNumberResponse: + VerificationManagementSandboxAddPhoneNumberResponse + ) = apply { + attemptCode = verificationManagementSandboxAddPhoneNumberResponse.attemptCode + phoneNumber = verificationManagementSandboxAddPhoneNumberResponse.phoneNumber + additionalProperties = + verificationManagementSandboxAddPhoneNumberResponse.additionalProperties + .toMutableMap() + } + + /** The fixed attempt code associated with the sandbox phone number. */ + fun attemptCode(attemptCode: String) = attemptCode(JsonField.of(attemptCode)) + + /** + * Sets [Builder.attemptCode] to an arbitrary JSON value. + * + * You should usually call [Builder.attemptCode] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun attemptCode(attemptCode: JsonField) = apply { this.attemptCode = attemptCode } + + /** The E.164 formatted phone number that was added to the sandbox list. */ + fun phoneNumber(phoneNumber: String) = phoneNumber(JsonField.of(phoneNumber)) + + /** + * Sets [Builder.phoneNumber] to an arbitrary JSON value. + * + * You should usually call [Builder.phoneNumber] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun phoneNumber(phoneNumber: JsonField) = apply { this.phoneNumber = phoneNumber } + + 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 [VerificationManagementSandboxAddPhoneNumberResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .attemptCode() + * .phoneNumber() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): VerificationManagementSandboxAddPhoneNumberResponse = + VerificationManagementSandboxAddPhoneNumberResponse( + checkRequired("attemptCode", attemptCode), + checkRequired("phoneNumber", phoneNumber), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws PreludeInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): VerificationManagementSandboxAddPhoneNumberResponse = apply { + if (validated) { + return@apply + } + + attemptCode() + phoneNumber() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: PreludeInvalidDataException) { + 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 (attemptCode.asKnown().isPresent) 1 else 0) + + (if (phoneNumber.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is VerificationManagementSandboxAddPhoneNumberResponse && + attemptCode == other.attemptCode && + phoneNumber == other.phoneNumber && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(attemptCode, phoneNumber, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "VerificationManagementSandboxAddPhoneNumberResponse{attemptCode=$attemptCode, phoneNumber=$phoneNumber, additionalProperties=$additionalProperties}" +} diff --git a/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/VerificationManagementSandboxDeletePhoneNumberParams.kt b/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/VerificationManagementSandboxDeletePhoneNumberParams.kt new file mode 100644 index 00000000..c31713f5 --- /dev/null +++ b/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/VerificationManagementSandboxDeletePhoneNumberParams.kt @@ -0,0 +1,253 @@ +// File generated from our OpenAPI spec by Stainless. + +package so.prelude.sdk.models + +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull +import so.prelude.sdk.core.JsonValue +import so.prelude.sdk.core.Params +import so.prelude.sdk.core.http.Headers +import so.prelude.sdk.core.http.QueryParams +import so.prelude.sdk.core.toImmutable + +/** + * Remove a phone number from the sandbox list. + * + * This operation is idempotent - deleting a phone number that is not in the sandbox list will + * succeed without making any changes. + * + * In order to get access to this endpoint, contact our support team. + */ +class VerificationManagementSandboxDeletePhoneNumberParams +private constructor( + private val phoneNumber: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map, +) : Params { + + fun phoneNumber(): Optional = Optional.ofNullable(phoneNumber) + + /** 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(): VerificationManagementSandboxDeletePhoneNumberParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of + * [VerificationManagementSandboxDeletePhoneNumberParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [VerificationManagementSandboxDeletePhoneNumberParams]. */ + class Builder internal constructor() { + + private var phoneNumber: 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( + verificationManagementSandboxDeletePhoneNumberParams: + VerificationManagementSandboxDeletePhoneNumberParams + ) = apply { + phoneNumber = verificationManagementSandboxDeletePhoneNumberParams.phoneNumber + additionalHeaders = + verificationManagementSandboxDeletePhoneNumberParams.additionalHeaders.toBuilder() + additionalQueryParams = + verificationManagementSandboxDeletePhoneNumberParams.additionalQueryParams + .toBuilder() + additionalBodyProperties = + verificationManagementSandboxDeletePhoneNumberParams.additionalBodyProperties + .toMutableMap() + } + + fun phoneNumber(phoneNumber: String?) = apply { this.phoneNumber = phoneNumber } + + /** Alias for calling [Builder.phoneNumber] with `phoneNumber.orElse(null)`. */ + fun phoneNumber(phoneNumber: Optional) = phoneNumber(phoneNumber.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 [VerificationManagementSandboxDeletePhoneNumberParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): VerificationManagementSandboxDeletePhoneNumberParams = + VerificationManagementSandboxDeletePhoneNumberParams( + phoneNumber, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> phoneNumber ?: "" + 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 VerificationManagementSandboxDeletePhoneNumberParams && + phoneNumber == other.phoneNumber && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash( + phoneNumber, + additionalHeaders, + additionalQueryParams, + additionalBodyProperties, + ) + + override fun toString() = + "VerificationManagementSandboxDeletePhoneNumberParams{phoneNumber=$phoneNumber, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/VerificationManagementSandboxDeletePhoneNumberResponse.kt b/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/VerificationManagementSandboxDeletePhoneNumberResponse.kt new file mode 100644 index 00000000..9beaabd4 --- /dev/null +++ b/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/VerificationManagementSandboxDeletePhoneNumberResponse.kt @@ -0,0 +1,193 @@ +// File generated from our OpenAPI spec by Stainless. + +package so.prelude.sdk.models + +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 so.prelude.sdk.core.ExcludeMissing +import so.prelude.sdk.core.JsonField +import so.prelude.sdk.core.JsonMissing +import so.prelude.sdk.core.JsonValue +import so.prelude.sdk.core.checkRequired +import so.prelude.sdk.errors.PreludeInvalidDataException + +class VerificationManagementSandboxDeletePhoneNumberResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val phoneNumber: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("phone_number") + @ExcludeMissing + phoneNumber: JsonField = JsonMissing.of() + ) : this(phoneNumber, mutableMapOf()) + + /** + * The E.164 formatted phone number that was removed from the sandbox list. + * + * @throws PreludeInvalidDataException 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 phoneNumber(): String = phoneNumber.getRequired("phone_number") + + /** + * Returns the raw JSON value of [phoneNumber]. + * + * Unlike [phoneNumber], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("phone_number") + @ExcludeMissing + fun _phoneNumber(): JsonField = phoneNumber + + @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 + * [VerificationManagementSandboxDeletePhoneNumberResponse]. + * + * The following fields are required: + * ```java + * .phoneNumber() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [VerificationManagementSandboxDeletePhoneNumberResponse]. */ + class Builder internal constructor() { + + private var phoneNumber: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + verificationManagementSandboxDeletePhoneNumberResponse: + VerificationManagementSandboxDeletePhoneNumberResponse + ) = apply { + phoneNumber = verificationManagementSandboxDeletePhoneNumberResponse.phoneNumber + additionalProperties = + verificationManagementSandboxDeletePhoneNumberResponse.additionalProperties + .toMutableMap() + } + + /** The E.164 formatted phone number that was removed from the sandbox list. */ + fun phoneNumber(phoneNumber: String) = phoneNumber(JsonField.of(phoneNumber)) + + /** + * Sets [Builder.phoneNumber] to an arbitrary JSON value. + * + * You should usually call [Builder.phoneNumber] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun phoneNumber(phoneNumber: JsonField) = apply { this.phoneNumber = phoneNumber } + + 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 + * [VerificationManagementSandboxDeletePhoneNumberResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .phoneNumber() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): VerificationManagementSandboxDeletePhoneNumberResponse = + VerificationManagementSandboxDeletePhoneNumberResponse( + checkRequired("phoneNumber", phoneNumber), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws PreludeInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): VerificationManagementSandboxDeletePhoneNumberResponse = apply { + if (validated) { + return@apply + } + + phoneNumber() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: PreludeInvalidDataException) { + 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 (phoneNumber.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is VerificationManagementSandboxDeletePhoneNumberResponse && + phoneNumber == other.phoneNumber && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(phoneNumber, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "VerificationManagementSandboxDeletePhoneNumberResponse{phoneNumber=$phoneNumber, additionalProperties=$additionalProperties}" +} diff --git a/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/VerificationManagementSandboxListPhoneNumbersParams.kt b/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/VerificationManagementSandboxListPhoneNumbersParams.kt new file mode 100644 index 00000000..566704ca --- /dev/null +++ b/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/VerificationManagementSandboxListPhoneNumbersParams.kt @@ -0,0 +1,188 @@ +// File generated from our OpenAPI spec by Stainless. + +package so.prelude.sdk.models + +import java.util.Objects +import so.prelude.sdk.core.Params +import so.prelude.sdk.core.http.Headers +import so.prelude.sdk.core.http.QueryParams + +/** + * Retrieve the list of sandbox phone numbers for the account. Sandbox numbers are test numbers that + * bypass the real verification flow and return a fixed attempt code. + * + * In order to get access to this endpoint, contact our support team. + */ +class VerificationManagementSandboxListPhoneNumbersParams +private constructor( + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** 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(): VerificationManagementSandboxListPhoneNumbersParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of + * [VerificationManagementSandboxListPhoneNumbersParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [VerificationManagementSandboxListPhoneNumbersParams]. */ + class Builder internal constructor() { + + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from( + verificationManagementSandboxListPhoneNumbersParams: + VerificationManagementSandboxListPhoneNumbersParams + ) = apply { + additionalHeaders = + verificationManagementSandboxListPhoneNumbersParams.additionalHeaders.toBuilder() + additionalQueryParams = + verificationManagementSandboxListPhoneNumbersParams.additionalQueryParams + .toBuilder() + } + + 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 [VerificationManagementSandboxListPhoneNumbersParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): VerificationManagementSandboxListPhoneNumbersParams = + VerificationManagementSandboxListPhoneNumbersParams( + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is VerificationManagementSandboxListPhoneNumbersParams && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(additionalHeaders, additionalQueryParams) + + override fun toString() = + "VerificationManagementSandboxListPhoneNumbersParams{additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/VerificationManagementSandboxListPhoneNumbersResponse.kt b/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/VerificationManagementSandboxListPhoneNumbersResponse.kt new file mode 100644 index 00000000..0c59cd90 --- /dev/null +++ b/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/VerificationManagementSandboxListPhoneNumbersResponse.kt @@ -0,0 +1,479 @@ +// File generated from our OpenAPI spec by Stainless. + +package so.prelude.sdk.models + +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 kotlin.jvm.optionals.getOrNull +import so.prelude.sdk.core.ExcludeMissing +import so.prelude.sdk.core.JsonField +import so.prelude.sdk.core.JsonMissing +import so.prelude.sdk.core.JsonValue +import so.prelude.sdk.core.checkKnown +import so.prelude.sdk.core.checkRequired +import so.prelude.sdk.core.toImmutable +import so.prelude.sdk.errors.PreludeInvalidDataException + +class VerificationManagementSandboxListPhoneNumbersResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val phoneNumbers: JsonField>, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("phone_numbers") + @ExcludeMissing + phoneNumbers: JsonField> = JsonMissing.of() + ) : this(phoneNumbers, mutableMapOf()) + + /** + * A list of sandbox phone numbers. + * + * @throws PreludeInvalidDataException 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 phoneNumbers(): List = phoneNumbers.getRequired("phone_numbers") + + /** + * Returns the raw JSON value of [phoneNumbers]. + * + * Unlike [phoneNumbers], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("phone_numbers") + @ExcludeMissing + fun _phoneNumbers(): JsonField> = phoneNumbers + + @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 + * [VerificationManagementSandboxListPhoneNumbersResponse]. + * + * The following fields are required: + * ```java + * .phoneNumbers() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [VerificationManagementSandboxListPhoneNumbersResponse]. */ + class Builder internal constructor() { + + private var phoneNumbers: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + verificationManagementSandboxListPhoneNumbersResponse: + VerificationManagementSandboxListPhoneNumbersResponse + ) = apply { + phoneNumbers = + verificationManagementSandboxListPhoneNumbersResponse.phoneNumbers.map { + it.toMutableList() + } + additionalProperties = + verificationManagementSandboxListPhoneNumbersResponse.additionalProperties + .toMutableMap() + } + + /** A list of sandbox phone numbers. */ + fun phoneNumbers(phoneNumbers: List) = phoneNumbers(JsonField.of(phoneNumbers)) + + /** + * Sets [Builder.phoneNumbers] to an arbitrary JSON value. + * + * You should usually call [Builder.phoneNumbers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun phoneNumbers(phoneNumbers: JsonField>) = apply { + this.phoneNumbers = phoneNumbers.map { it.toMutableList() } + } + + /** + * Adds a single [PhoneNumber] to [phoneNumbers]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addPhoneNumber(phoneNumber: PhoneNumber) = apply { + phoneNumbers = + (phoneNumbers ?: JsonField.of(mutableListOf())).also { + checkKnown("phoneNumbers", it).add(phoneNumber) + } + } + + 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 [VerificationManagementSandboxListPhoneNumbersResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .phoneNumbers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): VerificationManagementSandboxListPhoneNumbersResponse = + VerificationManagementSandboxListPhoneNumbersResponse( + checkRequired("phoneNumbers", phoneNumbers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws PreludeInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): VerificationManagementSandboxListPhoneNumbersResponse = apply { + if (validated) { + return@apply + } + + phoneNumbers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: PreludeInvalidDataException) { + 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 = + (phoneNumbers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + class PhoneNumber + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val attemptCode: JsonField, + private val createdAt: JsonField, + private val phoneNumber: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("attempt_code") + @ExcludeMissing + attemptCode: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField = JsonMissing.of(), + @JsonProperty("phone_number") + @ExcludeMissing + phoneNumber: JsonField = JsonMissing.of(), + ) : this(attemptCode, createdAt, phoneNumber, mutableMapOf()) + + /** + * The fixed attempt code associated with the sandbox phone number. + * + * @throws PreludeInvalidDataException 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 attemptCode(): String = attemptCode.getRequired("attempt_code") + + /** + * The date and time when the phone number was added to the sandbox list. + * + * @throws PreludeInvalidDataException 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 createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * An E.164 formatted phone number. + * + * @throws PreludeInvalidDataException 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 phoneNumber(): String = phoneNumber.getRequired("phone_number") + + /** + * Returns the raw JSON value of [attemptCode]. + * + * Unlike [attemptCode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("attempt_code") + @ExcludeMissing + fun _attemptCode(): JsonField = attemptCode + + /** + * 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 [phoneNumber]. + * + * Unlike [phoneNumber], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("phone_number") + @ExcludeMissing + fun _phoneNumber(): JsonField = phoneNumber + + @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 [PhoneNumber]. + * + * The following fields are required: + * ```java + * .attemptCode() + * .createdAt() + * .phoneNumber() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PhoneNumber]. */ + class Builder internal constructor() { + + private var attemptCode: JsonField? = null + private var createdAt: JsonField? = null + private var phoneNumber: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(phoneNumber: PhoneNumber) = apply { + attemptCode = phoneNumber.attemptCode + createdAt = phoneNumber.createdAt + this.phoneNumber = phoneNumber.phoneNumber + additionalProperties = phoneNumber.additionalProperties.toMutableMap() + } + + /** The fixed attempt code associated with the sandbox phone number. */ + fun attemptCode(attemptCode: String) = attemptCode(JsonField.of(attemptCode)) + + /** + * Sets [Builder.attemptCode] to an arbitrary JSON value. + * + * You should usually call [Builder.attemptCode] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun attemptCode(attemptCode: JsonField) = apply { + this.attemptCode = attemptCode + } + + /** The date and time when the phone number was added to the sandbox list. */ + 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 + } + + /** An E.164 formatted phone number. */ + fun phoneNumber(phoneNumber: String) = phoneNumber(JsonField.of(phoneNumber)) + + /** + * Sets [Builder.phoneNumber] to an arbitrary JSON value. + * + * You should usually call [Builder.phoneNumber] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun phoneNumber(phoneNumber: JsonField) = apply { + this.phoneNumber = phoneNumber + } + + 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 [PhoneNumber]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .attemptCode() + * .createdAt() + * .phoneNumber() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PhoneNumber = + PhoneNumber( + checkRequired("attemptCode", attemptCode), + checkRequired("createdAt", createdAt), + checkRequired("phoneNumber", phoneNumber), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws PreludeInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): PhoneNumber = apply { + if (validated) { + return@apply + } + + attemptCode() + createdAt() + phoneNumber() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: PreludeInvalidDataException) { + 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 (attemptCode.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (phoneNumber.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PhoneNumber && + attemptCode == other.attemptCode && + createdAt == other.createdAt && + phoneNumber == other.phoneNumber && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(attemptCode, createdAt, phoneNumber, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PhoneNumber{attemptCode=$attemptCode, createdAt=$createdAt, phoneNumber=$phoneNumber, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is VerificationManagementSandboxListPhoneNumbersResponse && + phoneNumbers == other.phoneNumbers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(phoneNumbers, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "VerificationManagementSandboxListPhoneNumbersResponse{phoneNumbers=$phoneNumbers, additionalProperties=$additionalProperties}" +} diff --git a/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/VerificationPhoneHistoryListParams.kt b/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/VerificationPhoneHistoryListParams.kt new file mode 100644 index 00000000..2971b8ec --- /dev/null +++ b/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/VerificationPhoneHistoryListParams.kt @@ -0,0 +1,977 @@ +// File generated from our OpenAPI spec by Stainless. + +package so.prelude.sdk.models + +import com.fasterxml.jackson.annotation.JsonCreator +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull +import so.prelude.sdk.core.Enum +import so.prelude.sdk.core.JsonField +import so.prelude.sdk.core.Params +import so.prelude.sdk.core.http.Headers +import so.prelude.sdk.core.http.QueryParams +import so.prelude.sdk.core.toImmutable +import so.prelude.sdk.errors.PreludeInvalidDataException + +/** + * List your phone verifications, most recent first, one entry per verification with its outcome, + * channels, attempts and cost. Every filter is optional and they combine with AND. + * + * Use it to find every verification a phone number went through from your support tooling, then + * [Get a phone verification](/verify/v2/api-reference/history/get-a-phone-verification) for the + * full timeline of one of them. A cursor is bound to the filters that produced it: pass + * `next_cursor` back with the exact same query parameters. + */ +class VerificationPhoneHistoryListParams +private constructor( + private val channels: List?, + private val cursor: String?, + private val devicePlatform: DevicePlatform?, + private val from: OffsetDateTime?, + private val limit: Long?, + private val maxAttempts: Long?, + private val minAttempts: Long?, + private val phoneNumber: String?, + private val region: String?, + private val status: Status?, + private val templateId: String?, + private val to: OffsetDateTime?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * Only verifications that could use one of these channels. Repeat the parameter for several + * values. + */ + fun channels(): Optional> = Optional.ofNullable(channels) + + /** Pagination cursor from the previous response. */ + fun cursor(): Optional = Optional.ofNullable(cursor) + + /** Only verifications created from this device platform. */ + fun devicePlatform(): Optional = Optional.ofNullable(devicePlatform) + + /** + * Only verifications created at or after this RFC 3339 timestamp. Goes with `to`, at most 6 + * months apart. Without them the whole history is searched. + */ + fun from(): Optional = Optional.ofNullable(from) + + /** Maximum number of verifications to return per page. */ + fun limit(): Optional = Optional.ofNullable(limit) + + /** + * Only verifications that sent at most this many messages. `0` keeps the verifications that + * never sent one. + */ + fun maxAttempts(): Optional = Optional.ofNullable(maxAttempts) + + /** Only verifications that sent at least this many messages. */ + fun minAttempts(): Optional = Optional.ofNullable(minAttempts) + + /** Only verifications targeting this E.164 phone number. The leading `+` may be omitted. */ + fun phoneNumber(): Optional = Optional.ofNullable(phoneNumber) + + /** Only verifications of phone numbers from this region, as an ISO 3166-1 alpha-2 code. */ + fun region(): Optional = Optional.ofNullable(region) + + /** Only verifications in this status. `pending_check` cannot be filtered on. */ + fun status(): Optional = Optional.ofNullable(status) + + /** + * Only verifications sent with this template, as returned in `template_id` by + * [Get a phone verification](/verify/v2/api-reference/history/get-a-phone-verification). + * Built-in templates (`prelude:*`) cannot be filtered on. + */ + fun templateId(): Optional = Optional.ofNullable(templateId) + + /** Only verifications created at or before this RFC 3339 timestamp. Goes with `from`. */ + fun to(): Optional = Optional.ofNullable(to) + + /** 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(): VerificationPhoneHistoryListParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of + * [VerificationPhoneHistoryListParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [VerificationPhoneHistoryListParams]. */ + class Builder internal constructor() { + + private var channels: MutableList? = null + private var cursor: String? = null + private var devicePlatform: DevicePlatform? = null + private var from: OffsetDateTime? = null + private var limit: Long? = null + private var maxAttempts: Long? = null + private var minAttempts: Long? = null + private var phoneNumber: String? = null + private var region: String? = null + private var status: Status? = null + private var templateId: String? = null + private var to: OffsetDateTime? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(verificationPhoneHistoryListParams: VerificationPhoneHistoryListParams) = + apply { + channels = verificationPhoneHistoryListParams.channels?.toMutableList() + cursor = verificationPhoneHistoryListParams.cursor + devicePlatform = verificationPhoneHistoryListParams.devicePlatform + from = verificationPhoneHistoryListParams.from + limit = verificationPhoneHistoryListParams.limit + maxAttempts = verificationPhoneHistoryListParams.maxAttempts + minAttempts = verificationPhoneHistoryListParams.minAttempts + phoneNumber = verificationPhoneHistoryListParams.phoneNumber + region = verificationPhoneHistoryListParams.region + status = verificationPhoneHistoryListParams.status + templateId = verificationPhoneHistoryListParams.templateId + to = verificationPhoneHistoryListParams.to + additionalHeaders = verificationPhoneHistoryListParams.additionalHeaders.toBuilder() + additionalQueryParams = + verificationPhoneHistoryListParams.additionalQueryParams.toBuilder() + } + + /** + * Only verifications that could use one of these channels. Repeat the parameter for several + * values. + */ + fun channels(channels: List?) = apply { this.channels = channels?.toMutableList() } + + /** Alias for calling [Builder.channels] with `channels.orElse(null)`. */ + fun channels(channels: Optional>) = channels(channels.getOrNull()) + + /** + * Adds a single [Channel] to [channels]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addChannel(channel: Channel) = apply { + channels = (channels ?: mutableListOf()).apply { add(channel) } + } + + /** Pagination cursor from the previous response. */ + fun cursor(cursor: String?) = apply { this.cursor = cursor } + + /** Alias for calling [Builder.cursor] with `cursor.orElse(null)`. */ + fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) + + /** Only verifications created from this device platform. */ + fun devicePlatform(devicePlatform: DevicePlatform?) = apply { + this.devicePlatform = devicePlatform + } + + /** Alias for calling [Builder.devicePlatform] with `devicePlatform.orElse(null)`. */ + fun devicePlatform(devicePlatform: Optional) = + devicePlatform(devicePlatform.getOrNull()) + + /** + * Only verifications created at or after this RFC 3339 timestamp. Goes with `to`, at most 6 + * months apart. Without them the whole history is searched. + */ + fun from(from: OffsetDateTime?) = apply { this.from = from } + + /** Alias for calling [Builder.from] with `from.orElse(null)`. */ + fun from(from: Optional) = from(from.getOrNull()) + + /** Maximum number of verifications to return per page. */ + 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()) + + /** + * Only verifications that sent at most this many messages. `0` keeps the verifications that + * never sent one. + */ + fun maxAttempts(maxAttempts: Long?) = apply { this.maxAttempts = maxAttempts } + + /** + * Alias for [Builder.maxAttempts]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun maxAttempts(maxAttempts: Long) = maxAttempts(maxAttempts as Long?) + + /** Alias for calling [Builder.maxAttempts] with `maxAttempts.orElse(null)`. */ + fun maxAttempts(maxAttempts: Optional) = maxAttempts(maxAttempts.getOrNull()) + + /** Only verifications that sent at least this many messages. */ + fun minAttempts(minAttempts: Long?) = apply { this.minAttempts = minAttempts } + + /** + * Alias for [Builder.minAttempts]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun minAttempts(minAttempts: Long) = minAttempts(minAttempts as Long?) + + /** Alias for calling [Builder.minAttempts] with `minAttempts.orElse(null)`. */ + fun minAttempts(minAttempts: Optional) = minAttempts(minAttempts.getOrNull()) + + /** Only verifications targeting this E.164 phone number. The leading `+` may be omitted. */ + fun phoneNumber(phoneNumber: String?) = apply { this.phoneNumber = phoneNumber } + + /** Alias for calling [Builder.phoneNumber] with `phoneNumber.orElse(null)`. */ + fun phoneNumber(phoneNumber: Optional) = phoneNumber(phoneNumber.getOrNull()) + + /** Only verifications of phone numbers from this region, as an ISO 3166-1 alpha-2 code. */ + fun region(region: String?) = apply { this.region = region } + + /** Alias for calling [Builder.region] with `region.orElse(null)`. */ + fun region(region: Optional) = region(region.getOrNull()) + + /** Only verifications in this status. `pending_check` cannot be filtered on. */ + fun status(status: Status?) = apply { this.status = status } + + /** Alias for calling [Builder.status] with `status.orElse(null)`. */ + fun status(status: Optional) = status(status.getOrNull()) + + /** + * Only verifications sent with this template, as returned in `template_id` by + * [Get a phone verification](/verify/v2/api-reference/history/get-a-phone-verification). + * Built-in templates (`prelude:*`) cannot be filtered on. + */ + fun templateId(templateId: String?) = apply { this.templateId = templateId } + + /** Alias for calling [Builder.templateId] with `templateId.orElse(null)`. */ + fun templateId(templateId: Optional) = templateId(templateId.getOrNull()) + + /** Only verifications created at or before this RFC 3339 timestamp. Goes with `from`. */ + fun to(to: OffsetDateTime?) = apply { this.to = to } + + /** Alias for calling [Builder.to] with `to.orElse(null)`. */ + fun to(to: Optional) = to(to.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 [VerificationPhoneHistoryListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): VerificationPhoneHistoryListParams = + VerificationPhoneHistoryListParams( + channels?.toImmutable(), + cursor, + devicePlatform, + from, + limit, + maxAttempts, + minAttempts, + phoneNumber, + region, + status, + templateId, + to, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + channels?.let { put("channels", it.joinToString(",") { it.toString() }) } + cursor?.let { put("cursor", it) } + devicePlatform?.let { put("device_platform", it.toString()) } + from?.let { put("from", DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(it)) } + limit?.let { put("limit", it.toString()) } + maxAttempts?.let { put("max_attempts", it.toString()) } + minAttempts?.let { put("min_attempts", it.toString()) } + phoneNumber?.let { put("phone_number", it) } + region?.let { put("region", it) } + status?.let { put("status", it.toString()) } + templateId?.let { put("template_id", it) } + to?.let { put("to", DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(it)) } + putAll(additionalQueryParams) + } + .build() + + class Channel @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 SMS = of("sms") + + @JvmField val RCS = of("rcs") + + @JvmField val WHATSAPP = of("whatsapp") + + @JvmField val VIBER = of("viber") + + @JvmField val ZALO = of("zalo") + + @JvmField val TELEGRAM = of("telegram") + + @JvmField val VOICE = of("voice") + + @JvmField val SILENT = of("silent") + + @JvmStatic fun of(value: String) = Channel(JsonField.of(value)) + } + + /** An enum containing [Channel]'s known values. */ + enum class Known { + SMS, + RCS, + WHATSAPP, + VIBER, + ZALO, + TELEGRAM, + VOICE, + SILENT, + } + + /** + * An enum containing [Channel]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Channel] 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 { + SMS, + RCS, + WHATSAPP, + VIBER, + ZALO, + TELEGRAM, + VOICE, + SILENT, + /** An enum member indicating that [Channel] 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) { + SMS -> Value.SMS + RCS -> Value.RCS + WHATSAPP -> Value.WHATSAPP + VIBER -> Value.VIBER + ZALO -> Value.ZALO + TELEGRAM -> Value.TELEGRAM + VOICE -> Value.VOICE + SILENT -> Value.SILENT + 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 PreludeInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + SMS -> Known.SMS + RCS -> Known.RCS + WHATSAPP -> Known.WHATSAPP + VIBER -> Known.VIBER + ZALO -> Known.ZALO + TELEGRAM -> Known.TELEGRAM + VOICE -> Known.VOICE + SILENT -> Known.SILENT + else -> throw PreludeInvalidDataException("Unknown Channel: $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 PreludeInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { PreludeInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws PreludeInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Channel = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: PreludeInvalidDataException) { + 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 Channel && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Only verifications created from this device platform. */ + class DevicePlatform @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 ANDROID = of("android") + + @JvmField val IOS = of("ios") + + @JvmField val IPADOS = of("ipados") + + @JvmField val TVOS = of("tvos") + + @JvmField val WEB = of("web") + + @JvmStatic fun of(value: String) = DevicePlatform(JsonField.of(value)) + } + + /** An enum containing [DevicePlatform]'s known values. */ + enum class Known { + ANDROID, + IOS, + IPADOS, + TVOS, + WEB, + } + + /** + * An enum containing [DevicePlatform]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [DevicePlatform] 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 { + ANDROID, + IOS, + IPADOS, + TVOS, + WEB, + /** + * An enum member indicating that [DevicePlatform] 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) { + ANDROID -> Value.ANDROID + IOS -> Value.IOS + IPADOS -> Value.IPADOS + TVOS -> Value.TVOS + WEB -> Value.WEB + 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 PreludeInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ANDROID -> Known.ANDROID + IOS -> Known.IOS + IPADOS -> Known.IPADOS + TVOS -> Known.TVOS + WEB -> Known.WEB + else -> throw PreludeInvalidDataException("Unknown DevicePlatform: $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 PreludeInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { PreludeInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws PreludeInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): DevicePlatform = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: PreludeInvalidDataException) { + 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 DevicePlatform && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Only verifications in this status. `pending_check` cannot be filtered on. */ + 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 CONVERTED = of("converted") + + @JvmField val NOT_CONVERTED = of("not_converted") + + @JvmField val PENDING_CHECK = of("pending_check") + + @JvmField val SENT = of("sent") + + @JvmField val CHALLENGED = of("challenged") + + @JvmField val SUSPECTED_FRAUD = of("suspected_fraud") + + @JvmField val IN_BLOCKLIST = of("in_blocklist") + + @JvmField val INVALID_LINE = of("invalid_line") + + @JvmField val INVALID_NUMBER = of("invalid_number") + + @JvmField val RATE_LIMITED = of("rate_limited") + + @JvmField val EXPIRED_SIGNALS = of("expired_signals") + + @JvmField val SHADOWED = of("shadowed") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + CONVERTED, + NOT_CONVERTED, + PENDING_CHECK, + SENT, + CHALLENGED, + SUSPECTED_FRAUD, + IN_BLOCKLIST, + INVALID_LINE, + INVALID_NUMBER, + RATE_LIMITED, + EXPIRED_SIGNALS, + SHADOWED, + } + + /** + * 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 { + CONVERTED, + NOT_CONVERTED, + PENDING_CHECK, + SENT, + CHALLENGED, + SUSPECTED_FRAUD, + IN_BLOCKLIST, + INVALID_LINE, + INVALID_NUMBER, + RATE_LIMITED, + EXPIRED_SIGNALS, + SHADOWED, + /** 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) { + CONVERTED -> Value.CONVERTED + NOT_CONVERTED -> Value.NOT_CONVERTED + PENDING_CHECK -> Value.PENDING_CHECK + SENT -> Value.SENT + CHALLENGED -> Value.CHALLENGED + SUSPECTED_FRAUD -> Value.SUSPECTED_FRAUD + IN_BLOCKLIST -> Value.IN_BLOCKLIST + INVALID_LINE -> Value.INVALID_LINE + INVALID_NUMBER -> Value.INVALID_NUMBER + RATE_LIMITED -> Value.RATE_LIMITED + EXPIRED_SIGNALS -> Value.EXPIRED_SIGNALS + SHADOWED -> Value.SHADOWED + 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 PreludeInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + CONVERTED -> Known.CONVERTED + NOT_CONVERTED -> Known.NOT_CONVERTED + PENDING_CHECK -> Known.PENDING_CHECK + SENT -> Known.SENT + CHALLENGED -> Known.CHALLENGED + SUSPECTED_FRAUD -> Known.SUSPECTED_FRAUD + IN_BLOCKLIST -> Known.IN_BLOCKLIST + INVALID_LINE -> Known.INVALID_LINE + INVALID_NUMBER -> Known.INVALID_NUMBER + RATE_LIMITED -> Known.RATE_LIMITED + EXPIRED_SIGNALS -> Known.EXPIRED_SIGNALS + SHADOWED -> Known.SHADOWED + else -> throw PreludeInvalidDataException("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 PreludeInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { PreludeInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws PreludeInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: PreludeInvalidDataException) { + 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 VerificationPhoneHistoryListParams && + channels == other.channels && + cursor == other.cursor && + devicePlatform == other.devicePlatform && + from == other.from && + limit == other.limit && + maxAttempts == other.maxAttempts && + minAttempts == other.minAttempts && + phoneNumber == other.phoneNumber && + region == other.region && + status == other.status && + templateId == other.templateId && + to == other.to && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash( + channels, + cursor, + devicePlatform, + from, + limit, + maxAttempts, + minAttempts, + phoneNumber, + region, + status, + templateId, + to, + additionalHeaders, + additionalQueryParams, + ) + + override fun toString() = + "VerificationPhoneHistoryListParams{channels=$channels, cursor=$cursor, devicePlatform=$devicePlatform, from=$from, limit=$limit, maxAttempts=$maxAttempts, minAttempts=$minAttempts, phoneNumber=$phoneNumber, region=$region, status=$status, templateId=$templateId, to=$to, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/VerificationPhoneHistoryListResponse.kt b/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/VerificationPhoneHistoryListResponse.kt new file mode 100644 index 00000000..e6f808dc --- /dev/null +++ b/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/VerificationPhoneHistoryListResponse.kt @@ -0,0 +1,2032 @@ +// File generated from our OpenAPI spec by Stainless. + +package so.prelude.sdk.models + +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 +import so.prelude.sdk.core.Enum +import so.prelude.sdk.core.ExcludeMissing +import so.prelude.sdk.core.JsonField +import so.prelude.sdk.core.JsonMissing +import so.prelude.sdk.core.JsonValue +import so.prelude.sdk.core.checkKnown +import so.prelude.sdk.core.checkRequired +import so.prelude.sdk.core.toImmutable +import so.prelude.sdk.errors.PreludeInvalidDataException + +class VerificationPhoneHistoryListResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val verifications: JsonField>, + private val nextCursor: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("verifications") + @ExcludeMissing + verifications: JsonField> = JsonMissing.of(), + @JsonProperty("next_cursor") + @ExcludeMissing + nextCursor: JsonField = JsonMissing.of(), + ) : this(verifications, nextCursor, mutableMapOf()) + + /** + * The page of verifications, most recent first. + * + * @throws PreludeInvalidDataException 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 verifications(): List = verifications.getRequired("verifications") + + /** + * Pagination cursor for the next page of results. Omitted if there are no more pages. + * + * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun nextCursor(): Optional = nextCursor.getOptional("next_cursor") + + /** + * Returns the raw JSON value of [verifications]. + * + * Unlike [verifications], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("verifications") + @ExcludeMissing + fun _verifications(): JsonField> = verifications + + /** + * Returns the raw JSON value of [nextCursor]. + * + * Unlike [nextCursor], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("next_cursor") @ExcludeMissing fun _nextCursor(): JsonField = nextCursor + + @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 + * [VerificationPhoneHistoryListResponse]. + * + * The following fields are required: + * ```java + * .verifications() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [VerificationPhoneHistoryListResponse]. */ + class Builder internal constructor() { + + private var verifications: JsonField>? = null + private var nextCursor: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + verificationPhoneHistoryListResponse: VerificationPhoneHistoryListResponse + ) = apply { + verifications = + verificationPhoneHistoryListResponse.verifications.map { it.toMutableList() } + nextCursor = verificationPhoneHistoryListResponse.nextCursor + additionalProperties = + verificationPhoneHistoryListResponse.additionalProperties.toMutableMap() + } + + /** The page of verifications, most recent first. */ + fun verifications(verifications: List) = + verifications(JsonField.of(verifications)) + + /** + * Sets [Builder.verifications] to an arbitrary JSON value. + * + * You should usually call [Builder.verifications] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun verifications(verifications: JsonField>) = apply { + this.verifications = verifications.map { it.toMutableList() } + } + + /** + * Adds a single [Verification] to [verifications]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addVerification(verification: Verification) = apply { + verifications = + (verifications ?: JsonField.of(mutableListOf())).also { + checkKnown("verifications", it).add(verification) + } + } + + /** Pagination cursor for the next page of results. Omitted if there are no more pages. */ + fun nextCursor(nextCursor: String) = nextCursor(JsonField.of(nextCursor)) + + /** + * Sets [Builder.nextCursor] to an arbitrary JSON value. + * + * You should usually call [Builder.nextCursor] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun nextCursor(nextCursor: JsonField) = apply { this.nextCursor = nextCursor } + + 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 [VerificationPhoneHistoryListResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .verifications() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): VerificationPhoneHistoryListResponse = + VerificationPhoneHistoryListResponse( + checkRequired("verifications", verifications).map { it.toImmutable() }, + nextCursor, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws PreludeInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): VerificationPhoneHistoryListResponse = apply { + if (validated) { + return@apply + } + + verifications().forEach { it.validate() } + nextCursor() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: PreludeInvalidDataException) { + 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 = + (verifications.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (nextCursor.asKnown().isPresent) 1 else 0) + + /** + * One entry of the verification history. + * [Get a phone verification](/verify/v2/api-reference/history/get-a-phone-verification) returns + * the full record. + */ + class Verification + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val channels: JsonField>, + private val createdAt: JsonField, + private val delivered: JsonField, + private val phoneNumber: JsonField, + private val status: JsonField, + private val attempts: JsonField, + private val convertedAt: JsonField, + private val cost: JsonField, + private val devicePlatform: JsonField, + private val phoneNumberCondition: JsonField, + private val signalsHashStatus: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("channels") + @ExcludeMissing + channels: JsonField> = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField = JsonMissing.of(), + @JsonProperty("delivered") + @ExcludeMissing + delivered: JsonField = JsonMissing.of(), + @JsonProperty("phone_number") + @ExcludeMissing + phoneNumber: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + @JsonProperty("attempts") @ExcludeMissing attempts: JsonField = JsonMissing.of(), + @JsonProperty("converted_at") + @ExcludeMissing + convertedAt: JsonField = JsonMissing.of(), + @JsonProperty("cost") + @ExcludeMissing + cost: JsonField = JsonMissing.of(), + @JsonProperty("device_platform") + @ExcludeMissing + devicePlatform: JsonField = JsonMissing.of(), + @JsonProperty("phone_number_condition") + @ExcludeMissing + phoneNumberCondition: JsonField = JsonMissing.of(), + @JsonProperty("signals_hash_status") + @ExcludeMissing + signalsHashStatus: JsonField = JsonMissing.of(), + ) : this( + id, + channels, + createdAt, + delivered, + phoneNumber, + status, + attempts, + convertedAt, + cost, + devicePlatform, + phoneNumberCondition, + signalsHashStatus, + mutableMapOf(), + ) + + /** + * The verification identifier. + * + * @throws PreludeInvalidDataException 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 id(): String = id.getRequired("id") + + /** + * The channels the verification could use, and which one the end user converted through. + * Empty when the verification used only channels this API does not list. + * + * @throws PreludeInvalidDataException 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 channels(): List = channels.getRequired("channels") + + /** + * @throws PreludeInvalidDataException 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 createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * Whether at least one message was reported delivered. + * + * @throws PreludeInvalidDataException 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 delivered(): Boolean = delivered.getRequired("delivered") + + /** + * The E.164 phone number the verification targeted. + * + * @throws PreludeInvalidDataException 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 phoneNumber(): String = phoneNumber.getRequired("phone_number") + + /** + * The outcome of the verification. + * * `converted` - The end user submitted a valid code. + * * `not_converted` - The verification expired without a valid code. + * * `pending_check` - A code was delivered and Prelude is still waiting for a check. + * * `sent` - A code was sent and the verification window is still open. + * * `challenged` - The verification was restricted to non-SMS and non-voice channels. + * * `suspected_fraud` - The anti-fraud system blocked the verification. + * * `in_blocklist` - The phone number is on the configured block list. + * * `invalid_line` - The phone number is not a valid line type. + * * `invalid_number` - The phone number is not a valid number. + * * `rate_limited` - The verification was refused by a rate limit. + * * `expired_signals` - The SDK signals were collected too long before the request. + * * `shadowed` - The anti-fraud system flagged the verification without blocking it. + * + * @throws PreludeInvalidDataException 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 status(): Status = status.getRequired("status") + + /** + * Number of messages sent for the verification, `0` when none was. Absent for sandboxed + * phone numbers. + * + * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun attempts(): Optional = attempts.getOptional("attempts") + + /** + * When the end user submitted a valid code. Absent unless the verification converted. + * + * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun convertedAt(): Optional = convertedAt.getOptional("converted_at") + + /** + * Total cost of the verification. Absent when nothing was billed. + * + * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun cost(): Optional = cost.getOptional("cost") + + /** + * Platform of the end-user device, when known. + * + * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun devicePlatform(): Optional = + devicePlatform.getOptional("device_platform") + + /** + * Whether the phone number was allow-listed, block-listed, or sandboxed at verification + * time. + * + * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun phoneNumberCondition(): Optional = + phoneNumberCondition.getOptional("phone_number_condition") + + /** + * Whether the SDK signals integrity check passed. + * + * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun signalsHashStatus(): Optional = + signalsHashStatus.getOptional("signals_hash_status") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [channels]. + * + * Unlike [channels], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("channels") + @ExcludeMissing + fun _channels(): JsonField> = channels + + /** + * 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 [delivered]. + * + * Unlike [delivered], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("delivered") @ExcludeMissing fun _delivered(): JsonField = delivered + + /** + * Returns the raw JSON value of [phoneNumber]. + * + * Unlike [phoneNumber], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("phone_number") + @ExcludeMissing + fun _phoneNumber(): JsonField = phoneNumber + + /** + * 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 [attempts]. + * + * Unlike [attempts], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("attempts") @ExcludeMissing fun _attempts(): JsonField = attempts + + /** + * Returns the raw JSON value of [convertedAt]. + * + * Unlike [convertedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("converted_at") + @ExcludeMissing + fun _convertedAt(): JsonField = convertedAt + + /** + * Returns the raw JSON value of [cost]. + * + * Unlike [cost], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("cost") @ExcludeMissing fun _cost(): JsonField = cost + + /** + * Returns the raw JSON value of [devicePlatform]. + * + * Unlike [devicePlatform], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("device_platform") + @ExcludeMissing + fun _devicePlatform(): JsonField = devicePlatform + + /** + * Returns the raw JSON value of [phoneNumberCondition]. + * + * Unlike [phoneNumberCondition], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("phone_number_condition") + @ExcludeMissing + fun _phoneNumberCondition(): JsonField = phoneNumberCondition + + /** + * Returns the raw JSON value of [signalsHashStatus]. + * + * Unlike [signalsHashStatus], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("signals_hash_status") + @ExcludeMissing + fun _signalsHashStatus(): JsonField = signalsHashStatus + + @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 [Verification]. + * + * The following fields are required: + * ```java + * .id() + * .channels() + * .createdAt() + * .delivered() + * .phoneNumber() + * .status() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Verification]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var channels: JsonField>? = null + private var createdAt: JsonField? = null + private var delivered: JsonField? = null + private var phoneNumber: JsonField? = null + private var status: JsonField? = null + private var attempts: JsonField = JsonMissing.of() + private var convertedAt: JsonField = JsonMissing.of() + private var cost: JsonField = JsonMissing.of() + private var devicePlatform: JsonField = JsonMissing.of() + private var phoneNumberCondition: JsonField = JsonMissing.of() + private var signalsHashStatus: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(verification: Verification) = apply { + id = verification.id + channels = verification.channels.map { it.toMutableList() } + createdAt = verification.createdAt + delivered = verification.delivered + phoneNumber = verification.phoneNumber + status = verification.status + attempts = verification.attempts + convertedAt = verification.convertedAt + cost = verification.cost + devicePlatform = verification.devicePlatform + phoneNumberCondition = verification.phoneNumberCondition + signalsHashStatus = verification.signalsHashStatus + additionalProperties = verification.additionalProperties.toMutableMap() + } + + /** The verification identifier. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The channels the verification could use, and which one the end user converted + * through. Empty when the verification used only channels this API does not list. + */ + fun channels(channels: List) = channels(JsonField.of(channels)) + + /** + * Sets [Builder.channels] to an arbitrary JSON value. + * + * You should usually call [Builder.channels] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun channels(channels: JsonField>) = apply { + this.channels = channels.map { it.toMutableList() } + } + + /** + * Adds a single [Channel] to [channels]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addChannel(channel: Channel) = apply { + channels = + (channels ?: JsonField.of(mutableListOf())).also { + checkKnown("channels", it).add(channel) + } + } + + 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 + } + + /** Whether at least one message was reported delivered. */ + fun delivered(delivered: Boolean) = delivered(JsonField.of(delivered)) + + /** + * Sets [Builder.delivered] to an arbitrary JSON value. + * + * You should usually call [Builder.delivered] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun delivered(delivered: JsonField) = apply { this.delivered = delivered } + + /** The E.164 phone number the verification targeted. */ + fun phoneNumber(phoneNumber: String) = phoneNumber(JsonField.of(phoneNumber)) + + /** + * Sets [Builder.phoneNumber] to an arbitrary JSON value. + * + * You should usually call [Builder.phoneNumber] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun phoneNumber(phoneNumber: JsonField) = apply { + this.phoneNumber = phoneNumber + } + + /** + * The outcome of the verification. + * * `converted` - The end user submitted a valid code. + * * `not_converted` - The verification expired without a valid code. + * * `pending_check` - A code was delivered and Prelude is still waiting for a check. + * * `sent` - A code was sent and the verification window is still open. + * * `challenged` - The verification was restricted to non-SMS and non-voice channels. + * * `suspected_fraud` - The anti-fraud system blocked the verification. + * * `in_blocklist` - The phone number is on the configured block list. + * * `invalid_line` - The phone number is not a valid line type. + * * `invalid_number` - The phone number is not a valid number. + * * `rate_limited` - The verification was refused by a rate limit. + * * `expired_signals` - The SDK signals were collected too long before the request. + * * `shadowed` - The anti-fraud system flagged the verification without blocking it. + */ + 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 } + + /** + * Number of messages sent for the verification, `0` when none was. Absent for sandboxed + * phone numbers. + */ + fun attempts(attempts: Long) = attempts(JsonField.of(attempts)) + + /** + * Sets [Builder.attempts] to an arbitrary JSON value. + * + * You should usually call [Builder.attempts] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun attempts(attempts: JsonField) = apply { this.attempts = attempts } + + /** + * When the end user submitted a valid code. Absent unless the verification converted. + */ + fun convertedAt(convertedAt: OffsetDateTime) = convertedAt(JsonField.of(convertedAt)) + + /** + * Sets [Builder.convertedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.convertedAt] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun convertedAt(convertedAt: JsonField) = apply { + this.convertedAt = convertedAt + } + + /** Total cost of the verification. Absent when nothing was billed. */ + fun cost(cost: PhoneVerificationMoney) = cost(JsonField.of(cost)) + + /** + * Sets [Builder.cost] to an arbitrary JSON value. + * + * You should usually call [Builder.cost] with a well-typed [PhoneVerificationMoney] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cost(cost: JsonField) = apply { this.cost = cost } + + /** Platform of the end-user device, when known. */ + fun devicePlatform(devicePlatform: DevicePlatform) = + devicePlatform(JsonField.of(devicePlatform)) + + /** + * Sets [Builder.devicePlatform] to an arbitrary JSON value. + * + * You should usually call [Builder.devicePlatform] with a well-typed [DevicePlatform] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun devicePlatform(devicePlatform: JsonField) = apply { + this.devicePlatform = devicePlatform + } + + /** + * Whether the phone number was allow-listed, block-listed, or sandboxed at verification + * time. + */ + fun phoneNumberCondition(phoneNumberCondition: PhoneNumberCondition) = + phoneNumberCondition(JsonField.of(phoneNumberCondition)) + + /** + * Sets [Builder.phoneNumberCondition] to an arbitrary JSON value. + * + * You should usually call [Builder.phoneNumberCondition] with a well-typed + * [PhoneNumberCondition] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun phoneNumberCondition(phoneNumberCondition: JsonField) = + apply { + this.phoneNumberCondition = phoneNumberCondition + } + + /** Whether the SDK signals integrity check passed. */ + fun signalsHashStatus(signalsHashStatus: SignalsHashStatus) = + signalsHashStatus(JsonField.of(signalsHashStatus)) + + /** + * Sets [Builder.signalsHashStatus] to an arbitrary JSON value. + * + * You should usually call [Builder.signalsHashStatus] with a well-typed + * [SignalsHashStatus] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun signalsHashStatus(signalsHashStatus: JsonField) = apply { + this.signalsHashStatus = signalsHashStatus + } + + 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 [Verification]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .channels() + * .createdAt() + * .delivered() + * .phoneNumber() + * .status() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Verification = + Verification( + checkRequired("id", id), + checkRequired("channels", channels).map { it.toImmutable() }, + checkRequired("createdAt", createdAt), + checkRequired("delivered", delivered), + checkRequired("phoneNumber", phoneNumber), + checkRequired("status", status), + attempts, + convertedAt, + cost, + devicePlatform, + phoneNumberCondition, + signalsHashStatus, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws PreludeInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Verification = apply { + if (validated) { + return@apply + } + + id() + channels().forEach { it.validate() } + createdAt() + delivered() + phoneNumber() + status().validate() + attempts() + convertedAt() + cost().ifPresent { it.validate() } + devicePlatform().ifPresent { it.validate() } + phoneNumberCondition().ifPresent { it.validate() } + signalsHashStatus().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: PreludeInvalidDataException) { + 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 (id.asKnown().isPresent) 1 else 0) + + (channels.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (delivered.asKnown().isPresent) 1 else 0) + + (if (phoneNumber.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (if (attempts.asKnown().isPresent) 1 else 0) + + (if (convertedAt.asKnown().isPresent) 1 else 0) + + (cost.asKnown().getOrNull()?.validity() ?: 0) + + (devicePlatform.asKnown().getOrNull()?.validity() ?: 0) + + (phoneNumberCondition.asKnown().getOrNull()?.validity() ?: 0) + + (signalsHashStatus.asKnown().getOrNull()?.validity() ?: 0) + + class Channel + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val channel: JsonField, + private val converted: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("channel") + @ExcludeMissing + channel: JsonField = JsonMissing.of(), + @JsonProperty("converted") + @ExcludeMissing + converted: JsonField = JsonMissing.of(), + ) : this(channel, converted, mutableMapOf()) + + /** + * @throws PreludeInvalidDataException 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 channel(): InnerChannel = channel.getRequired("channel") + + /** + * Whether the end user submitted a valid code received through this channel. + * + * @throws PreludeInvalidDataException 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 converted(): Boolean = converted.getRequired("converted") + + /** + * Returns the raw JSON value of [channel]. + * + * Unlike [channel], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("channel") + @ExcludeMissing + fun _channel(): JsonField = channel + + /** + * Returns the raw JSON value of [converted]. + * + * Unlike [converted], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("converted") + @ExcludeMissing + fun _converted(): JsonField = converted + + @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 [Channel]. + * + * The following fields are required: + * ```java + * .channel() + * .converted() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Channel]. */ + class Builder internal constructor() { + + private var channel: JsonField? = null + private var converted: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(channel: Channel) = apply { + this.channel = channel.channel + converted = channel.converted + additionalProperties = channel.additionalProperties.toMutableMap() + } + + fun channel(channel: InnerChannel) = channel(JsonField.of(channel)) + + /** + * Sets [Builder.channel] to an arbitrary JSON value. + * + * You should usually call [Builder.channel] with a well-typed [InnerChannel] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun channel(channel: JsonField) = apply { this.channel = channel } + + /** Whether the end user submitted a valid code received through this channel. */ + fun converted(converted: Boolean) = converted(JsonField.of(converted)) + + /** + * Sets [Builder.converted] to an arbitrary JSON value. + * + * You should usually call [Builder.converted] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun converted(converted: JsonField) = apply { this.converted = converted } + + 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 [Channel]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .channel() + * .converted() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Channel = + Channel( + checkRequired("channel", channel), + checkRequired("converted", converted), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws PreludeInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): Channel = apply { + if (validated) { + return@apply + } + + channel().validate() + converted() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: PreludeInvalidDataException) { + 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 = + (channel.asKnown().getOrNull()?.validity() ?: 0) + + (if (converted.asKnown().isPresent) 1 else 0) + + class InnerChannel + @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 SMS = of("sms") + + @JvmField val RCS = of("rcs") + + @JvmField val WHATSAPP = of("whatsapp") + + @JvmField val VIBER = of("viber") + + @JvmField val ZALO = of("zalo") + + @JvmField val TELEGRAM = of("telegram") + + @JvmField val VOICE = of("voice") + + @JvmField val SILENT = of("silent") + + @JvmStatic fun of(value: String) = InnerChannel(JsonField.of(value)) + } + + /** An enum containing [InnerChannel]'s known values. */ + enum class Known { + SMS, + RCS, + WHATSAPP, + VIBER, + ZALO, + TELEGRAM, + VOICE, + SILENT, + } + + /** + * An enum containing [InnerChannel]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [InnerChannel] 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 { + SMS, + RCS, + WHATSAPP, + VIBER, + ZALO, + TELEGRAM, + VOICE, + SILENT, + /** + * An enum member indicating that [InnerChannel] 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) { + SMS -> Value.SMS + RCS -> Value.RCS + WHATSAPP -> Value.WHATSAPP + VIBER -> Value.VIBER + ZALO -> Value.ZALO + TELEGRAM -> Value.TELEGRAM + VOICE -> Value.VOICE + SILENT -> Value.SILENT + 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 PreludeInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + SMS -> Known.SMS + RCS -> Known.RCS + WHATSAPP -> Known.WHATSAPP + VIBER -> Known.VIBER + ZALO -> Known.ZALO + TELEGRAM -> Known.TELEGRAM + VOICE -> Known.VOICE + SILENT -> Known.SILENT + else -> throw PreludeInvalidDataException("Unknown InnerChannel: $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 PreludeInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + PreludeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws PreludeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): InnerChannel = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: PreludeInvalidDataException) { + 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 InnerChannel && 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 Channel && + channel == other.channel && + converted == other.converted && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(channel, converted, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Channel{channel=$channel, converted=$converted, additionalProperties=$additionalProperties}" + } + + /** + * The outcome of the verification. + * * `converted` - The end user submitted a valid code. + * * `not_converted` - The verification expired without a valid code. + * * `pending_check` - A code was delivered and Prelude is still waiting for a check. + * * `sent` - A code was sent and the verification window is still open. + * * `challenged` - The verification was restricted to non-SMS and non-voice channels. + * * `suspected_fraud` - The anti-fraud system blocked the verification. + * * `in_blocklist` - The phone number is on the configured block list. + * * `invalid_line` - The phone number is not a valid line type. + * * `invalid_number` - The phone number is not a valid number. + * * `rate_limited` - The verification was refused by a rate limit. + * * `expired_signals` - The SDK signals were collected too long before the request. + * * `shadowed` - The anti-fraud system flagged the verification without blocking it. + */ + 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 CONVERTED = of("converted") + + @JvmField val NOT_CONVERTED = of("not_converted") + + @JvmField val PENDING_CHECK = of("pending_check") + + @JvmField val SENT = of("sent") + + @JvmField val CHALLENGED = of("challenged") + + @JvmField val SUSPECTED_FRAUD = of("suspected_fraud") + + @JvmField val IN_BLOCKLIST = of("in_blocklist") + + @JvmField val INVALID_LINE = of("invalid_line") + + @JvmField val INVALID_NUMBER = of("invalid_number") + + @JvmField val RATE_LIMITED = of("rate_limited") + + @JvmField val EXPIRED_SIGNALS = of("expired_signals") + + @JvmField val SHADOWED = of("shadowed") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + CONVERTED, + NOT_CONVERTED, + PENDING_CHECK, + SENT, + CHALLENGED, + SUSPECTED_FRAUD, + IN_BLOCKLIST, + INVALID_LINE, + INVALID_NUMBER, + RATE_LIMITED, + EXPIRED_SIGNALS, + SHADOWED, + } + + /** + * 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 { + CONVERTED, + NOT_CONVERTED, + PENDING_CHECK, + SENT, + CHALLENGED, + SUSPECTED_FRAUD, + IN_BLOCKLIST, + INVALID_LINE, + INVALID_NUMBER, + RATE_LIMITED, + EXPIRED_SIGNALS, + SHADOWED, + /** + * 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) { + CONVERTED -> Value.CONVERTED + NOT_CONVERTED -> Value.NOT_CONVERTED + PENDING_CHECK -> Value.PENDING_CHECK + SENT -> Value.SENT + CHALLENGED -> Value.CHALLENGED + SUSPECTED_FRAUD -> Value.SUSPECTED_FRAUD + IN_BLOCKLIST -> Value.IN_BLOCKLIST + INVALID_LINE -> Value.INVALID_LINE + INVALID_NUMBER -> Value.INVALID_NUMBER + RATE_LIMITED -> Value.RATE_LIMITED + EXPIRED_SIGNALS -> Value.EXPIRED_SIGNALS + SHADOWED -> Value.SHADOWED + 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 PreludeInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + CONVERTED -> Known.CONVERTED + NOT_CONVERTED -> Known.NOT_CONVERTED + PENDING_CHECK -> Known.PENDING_CHECK + SENT -> Known.SENT + CHALLENGED -> Known.CHALLENGED + SUSPECTED_FRAUD -> Known.SUSPECTED_FRAUD + IN_BLOCKLIST -> Known.IN_BLOCKLIST + INVALID_LINE -> Known.INVALID_LINE + INVALID_NUMBER -> Known.INVALID_NUMBER + RATE_LIMITED -> Known.RATE_LIMITED + EXPIRED_SIGNALS -> Known.EXPIRED_SIGNALS + SHADOWED -> Known.SHADOWED + else -> throw PreludeInvalidDataException("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 PreludeInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + PreludeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws PreludeInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: PreludeInvalidDataException) { + 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() + } + + /** Platform of the end-user device, when known. */ + class DevicePlatform + @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 ANDROID = of("android") + + @JvmField val IOS = of("ios") + + @JvmField val IPADOS = of("ipados") + + @JvmField val TVOS = of("tvos") + + @JvmField val WEB = of("web") + + @JvmStatic fun of(value: String) = DevicePlatform(JsonField.of(value)) + } + + /** An enum containing [DevicePlatform]'s known values. */ + enum class Known { + ANDROID, + IOS, + IPADOS, + TVOS, + WEB, + } + + /** + * An enum containing [DevicePlatform]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [DevicePlatform] 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 { + ANDROID, + IOS, + IPADOS, + TVOS, + WEB, + /** + * An enum member indicating that [DevicePlatform] 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) { + ANDROID -> Value.ANDROID + IOS -> Value.IOS + IPADOS -> Value.IPADOS + TVOS -> Value.TVOS + WEB -> Value.WEB + 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 PreludeInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ANDROID -> Known.ANDROID + IOS -> Known.IOS + IPADOS -> Known.IPADOS + TVOS -> Known.TVOS + WEB -> Known.WEB + else -> throw PreludeInvalidDataException("Unknown DevicePlatform: $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 PreludeInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + PreludeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws PreludeInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): DevicePlatform = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: PreludeInvalidDataException) { + 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 DevicePlatform && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * Whether the phone number was allow-listed, block-listed, or sandboxed at verification + * time. + */ + class PhoneNumberCondition + @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 ALLOW_LISTED = of("allow_listed") + + @JvmField val BLOCK_LISTED = of("block_listed") + + @JvmField val SANDBOXED = of("sandboxed") + + @JvmStatic fun of(value: String) = PhoneNumberCondition(JsonField.of(value)) + } + + /** An enum containing [PhoneNumberCondition]'s known values. */ + enum class Known { + ALLOW_LISTED, + BLOCK_LISTED, + SANDBOXED, + } + + /** + * An enum containing [PhoneNumberCondition]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [PhoneNumberCondition] 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 { + ALLOW_LISTED, + BLOCK_LISTED, + SANDBOXED, + /** + * An enum member indicating that [PhoneNumberCondition] 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) { + ALLOW_LISTED -> Value.ALLOW_LISTED + BLOCK_LISTED -> Value.BLOCK_LISTED + SANDBOXED -> Value.SANDBOXED + 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 PreludeInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ALLOW_LISTED -> Known.ALLOW_LISTED + BLOCK_LISTED -> Known.BLOCK_LISTED + SANDBOXED -> Known.SANDBOXED + else -> + throw PreludeInvalidDataException("Unknown PhoneNumberCondition: $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 PreludeInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + PreludeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws PreludeInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): PhoneNumberCondition = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: PreludeInvalidDataException) { + 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 PhoneNumberCondition && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Whether the SDK signals integrity check passed. */ + class SignalsHashStatus + @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 VALID = of("valid") + + @JvmField val INVALID = of("invalid") + + @JvmStatic fun of(value: String) = SignalsHashStatus(JsonField.of(value)) + } + + /** An enum containing [SignalsHashStatus]'s known values. */ + enum class Known { + VALID, + INVALID, + } + + /** + * An enum containing [SignalsHashStatus]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [SignalsHashStatus] 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 { + VALID, + INVALID, + /** + * An enum member indicating that [SignalsHashStatus] 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) { + VALID -> Value.VALID + INVALID -> Value.INVALID + 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 PreludeInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + VALID -> Known.VALID + INVALID -> Known.INVALID + else -> throw PreludeInvalidDataException("Unknown SignalsHashStatus: $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 PreludeInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + PreludeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws PreludeInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): SignalsHashStatus = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: PreludeInvalidDataException) { + 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 SignalsHashStatus && 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 Verification && + id == other.id && + channels == other.channels && + createdAt == other.createdAt && + delivered == other.delivered && + phoneNumber == other.phoneNumber && + status == other.status && + attempts == other.attempts && + convertedAt == other.convertedAt && + cost == other.cost && + devicePlatform == other.devicePlatform && + phoneNumberCondition == other.phoneNumberCondition && + signalsHashStatus == other.signalsHashStatus && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + channels, + createdAt, + delivered, + phoneNumber, + status, + attempts, + convertedAt, + cost, + devicePlatform, + phoneNumberCondition, + signalsHashStatus, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Verification{id=$id, channels=$channels, createdAt=$createdAt, delivered=$delivered, phoneNumber=$phoneNumber, status=$status, attempts=$attempts, convertedAt=$convertedAt, cost=$cost, devicePlatform=$devicePlatform, phoneNumberCondition=$phoneNumberCondition, signalsHashStatus=$signalsHashStatus, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is VerificationPhoneHistoryListResponse && + verifications == other.verifications && + nextCursor == other.nextCursor && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(verifications, nextCursor, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "VerificationPhoneHistoryListResponse{verifications=$verifications, nextCursor=$nextCursor, additionalProperties=$additionalProperties}" +} diff --git a/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/VerificationPhoneHistoryRetrieveParams.kt b/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/VerificationPhoneHistoryRetrieveParams.kt new file mode 100644 index 00000000..ad20af27 --- /dev/null +++ b/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/VerificationPhoneHistoryRetrieveParams.kt @@ -0,0 +1,208 @@ +// File generated from our OpenAPI spec by Stainless. + +package so.prelude.sdk.models + +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull +import so.prelude.sdk.core.Params +import so.prelude.sdk.core.http.Headers +import so.prelude.sdk.core.http.QueryParams + +/** + * Retrieve everything Prelude recorded for one phone verification: its outcome and the device, + * network and anti-fraud context it was created in, the chronological timeline of every message + * attempt and code check, and the anti-fraud signals you forwarded. + * + * The identifier is the `id` returned by + * [Create or retry a verification](/verify/v2/api-reference/create-or-retry-a-verification) or the + * `verification_id` of the verification webhooks. Both `lifecycle` and `signals` are optional: a + * verification can resolve with its top-level fields alone. + */ +class VerificationPhoneHistoryRetrieveParams +private constructor( + private val id: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun id(): Optional = Optional.ofNullable(id) + + /** 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(): VerificationPhoneHistoryRetrieveParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of + * [VerificationPhoneHistoryRetrieveParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [VerificationPhoneHistoryRetrieveParams]. */ + class Builder internal constructor() { + + private var id: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from( + verificationPhoneHistoryRetrieveParams: VerificationPhoneHistoryRetrieveParams + ) = apply { + id = verificationPhoneHistoryRetrieveParams.id + additionalHeaders = verificationPhoneHistoryRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = + verificationPhoneHistoryRetrieveParams.additionalQueryParams.toBuilder() + } + + fun id(id: String?) = apply { this.id = id } + + /** Alias for calling [Builder.id] with `id.orElse(null)`. */ + fun id(id: Optional) = id(id.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 [VerificationPhoneHistoryRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): VerificationPhoneHistoryRetrieveParams = + VerificationPhoneHistoryRetrieveParams( + id, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> id ?: "" + 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 VerificationPhoneHistoryRetrieveParams && + id == other.id && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(id, additionalHeaders, additionalQueryParams) + + override fun toString() = + "VerificationPhoneHistoryRetrieveParams{id=$id, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/VerificationPhoneHistoryRetrieveResponse.kt b/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/VerificationPhoneHistoryRetrieveResponse.kt new file mode 100644 index 00000000..e40b360d --- /dev/null +++ b/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/VerificationPhoneHistoryRetrieveResponse.kt @@ -0,0 +1,6682 @@ +// File generated from our OpenAPI spec by Stainless. + +package so.prelude.sdk.models + +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 +import so.prelude.sdk.core.Enum +import so.prelude.sdk.core.ExcludeMissing +import so.prelude.sdk.core.JsonField +import so.prelude.sdk.core.JsonMissing +import so.prelude.sdk.core.JsonValue +import so.prelude.sdk.core.checkKnown +import so.prelude.sdk.core.checkRequired +import so.prelude.sdk.core.toImmutable +import so.prelude.sdk.errors.PreludeInvalidDataException + +/** A verification and everything Prelude recorded about it. */ +class VerificationPhoneHistoryRetrieveResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val createdAt: JsonField, + private val expiresAt: JsonField, + private val phoneNumber: JsonField, + private val status: JsonField, + private val appVersion: JsonField, + private val blockReasons: JsonField>, + private val carrier: JsonField, + private val correlationId: JsonField, + private val deviceModel: JsonField, + private val devicePlatform: JsonField, + private val ipAddress: JsonField, + private val ipAddressRegion: JsonField, + private val ipDistanceMeters: JsonField, + private val lifecycle: JsonField, + private val phoneNumberCondition: JsonField, + private val phoneNumberCurrentCondition: JsonField, + private val phoneNumberRegion: JsonField, + private val signals: JsonField, + private val signalsHashStatus: JsonField, + private val templateId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField = JsonMissing.of(), + @JsonProperty("expires_at") + @ExcludeMissing + expiresAt: JsonField = JsonMissing.of(), + @JsonProperty("phone_number") + @ExcludeMissing + phoneNumber: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + @JsonProperty("app_version") + @ExcludeMissing + appVersion: JsonField = JsonMissing.of(), + @JsonProperty("block_reasons") + @ExcludeMissing + blockReasons: JsonField> = JsonMissing.of(), + @JsonProperty("carrier") + @ExcludeMissing + carrier: JsonField = JsonMissing.of(), + @JsonProperty("correlation_id") + @ExcludeMissing + correlationId: JsonField = JsonMissing.of(), + @JsonProperty("device_model") + @ExcludeMissing + deviceModel: JsonField = JsonMissing.of(), + @JsonProperty("device_platform") + @ExcludeMissing + devicePlatform: JsonField = JsonMissing.of(), + @JsonProperty("ip_address") @ExcludeMissing ipAddress: JsonField = JsonMissing.of(), + @JsonProperty("ip_address_region") + @ExcludeMissing + ipAddressRegion: JsonField = JsonMissing.of(), + @JsonProperty("ip_distance_meters") + @ExcludeMissing + ipDistanceMeters: JsonField = JsonMissing.of(), + @JsonProperty("lifecycle") + @ExcludeMissing + lifecycle: JsonField = JsonMissing.of(), + @JsonProperty("phone_number_condition") + @ExcludeMissing + phoneNumberCondition: JsonField = JsonMissing.of(), + @JsonProperty("phone_number_current_condition") + @ExcludeMissing + phoneNumberCurrentCondition: JsonField = JsonMissing.of(), + @JsonProperty("phone_number_region") + @ExcludeMissing + phoneNumberRegion: JsonField = JsonMissing.of(), + @JsonProperty("signals") @ExcludeMissing signals: JsonField = JsonMissing.of(), + @JsonProperty("signals_hash_status") + @ExcludeMissing + signalsHashStatus: JsonField = JsonMissing.of(), + @JsonProperty("template_id") + @ExcludeMissing + templateId: JsonField = JsonMissing.of(), + ) : this( + id, + createdAt, + expiresAt, + phoneNumber, + status, + appVersion, + blockReasons, + carrier, + correlationId, + deviceModel, + devicePlatform, + ipAddress, + ipAddressRegion, + ipDistanceMeters, + lifecycle, + phoneNumberCondition, + phoneNumberCurrentCondition, + phoneNumberRegion, + signals, + signalsHashStatus, + templateId, + mutableMapOf(), + ) + + /** + * The verification identifier. + * + * @throws PreludeInvalidDataException 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 id(): String = id.getRequired("id") + + /** + * @throws PreludeInvalidDataException 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 createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * @throws PreludeInvalidDataException 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 expiresAt(): OffsetDateTime = expiresAt.getRequired("expires_at") + + /** + * The E.164 phone number the verification targeted. + * + * @throws PreludeInvalidDataException 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 phoneNumber(): String = phoneNumber.getRequired("phone_number") + + /** + * The outcome of the verification. + * * `converted` - The end user submitted a valid code. + * * `not_converted` - The verification expired without a valid code. + * * `pending_check` - A code was delivered and Prelude is still waiting for a check. + * * `sent` - A code was sent and the verification window is still open. + * * `challenged` - The verification was restricted to non-SMS and non-voice channels. + * * `suspected_fraud` - The anti-fraud system blocked the verification. + * * `in_blocklist` - The phone number is on the configured block list. + * * `invalid_line` - The phone number is not a valid line type. + * * `invalid_number` - The phone number is not a valid number. + * * `rate_limited` - The verification was refused by a rate limit. + * * `expired_signals` - The SDK signals were collected too long before the request. + * * `shadowed` - The anti-fraud system flagged the verification without blocking it. + * + * @throws PreludeInvalidDataException 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 status(): Status = status.getRequired("status") + + /** + * Version of your application, when known. + * + * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun appVersion(): Optional = appVersion.getOptional("app_version") + + /** + * Why the anti-fraud system blocked the verification. Empty unless it did. + * * `behavioral_pattern` - The phone number past behavior during verification flows exhibits + * suspicious patterns. + * * `device_attribute` - The end-user device reported attributes associated with fraud or + * emulation. + * * `fraud_database` - The phone number appears in a fraud database. + * * `location_discrepancy` - The phone number region and the observed location disagree. + * * `missing_signals` - The verification expected Prelude SDK signals and none arrived. + * * `network_fingerprint` - The network fingerprint matches known fraudulent traffic. + * * `poor_conversion_history` - The phone number rarely completes the verifications it starts. + * * `prefix_concentration` - The phone number is part of a range known to be associated with + * suspicious activity patterns. + * * `repeated_number` - The phone number was used far more often than normal traffic would + * explain. + * * `suspected_request_tampering` - The SDK signals were altered or expired between collection + * and use. + * * `suspicious_ip_address` - The originating IP address is associated with suspicious + * activity. + * * `temporary_phone_number` - The phone number is known to be a temporary or disposable + * number. + * + * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun blockReasons(): Optional> = blockReasons.getOptional("block_reasons") + + /** + * The end user's mobile network. + * + * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun carrier(): Optional = carrier.getOptional("carrier") + + /** + * The correlation identifier you supplied when creating the verification. + * + * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun correlationId(): Optional = correlationId.getOptional("correlation_id") + + /** + * Model of the end-user device, when known. + * + * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun deviceModel(): Optional = deviceModel.getOptional("device_model") + + /** + * Platform of the end-user device, when known. + * + * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun devicePlatform(): Optional = devicePlatform.getOptional("device_platform") + + /** + * IP address the verification was created from. + * + * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun ipAddress(): Optional = ipAddress.getOptional("ip_address") + + /** + * ISO 3166-1 alpha-2 region of the caller's IP address. + * + * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun ipAddressRegion(): Optional = ipAddressRegion.getOptional("ip_address_region") + + /** + * Distance between the phone number region and the IP location. + * + * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun ipDistanceMeters(): Optional = ipDistanceMeters.getOptional("ip_distance_meters") + + /** + * Chronological timeline of the verification: creation, message attempts with delivery events, + * code checks and signals reception. Omitted when Prelude holds no timeline for the + * verification. + * + * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun lifecycle(): Optional = lifecycle.getOptional("lifecycle") + + /** + * Whether the phone number was allow-listed, block-listed, or sandboxed at verification time. + * + * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun phoneNumberCondition(): Optional = + phoneNumberCondition.getOptional("phone_number_condition") + + /** + * Whether the phone number is currently allow-listed, block-listed, or sandboxed. + * + * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun phoneNumberCurrentCondition(): Optional = + phoneNumberCurrentCondition.getOptional("phone_number_current_condition") + + /** + * ISO 3166-1 alpha-2 region of the phone number. + * + * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun phoneNumberRegion(): Optional = phoneNumberRegion.getOptional("phone_number_region") + + /** + * The anti-fraud signals you forwarded when creating the verification. + * + * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun signals(): Optional = signals.getOptional("signals") + + /** + * Whether the SDK signals integrity check passed. + * + * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun signalsHashStatus(): Optional = + signalsHashStatus.getOptional("signals_hash_status") + + /** + * The template used for this verification. + * + * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun templateId(): Optional = templateId.getOptional("template_id") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * 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 [expiresAt]. + * + * Unlike [expiresAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("expires_at") + @ExcludeMissing + fun _expiresAt(): JsonField = expiresAt + + /** + * Returns the raw JSON value of [phoneNumber]. + * + * Unlike [phoneNumber], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("phone_number") + @ExcludeMissing + fun _phoneNumber(): JsonField = phoneNumber + + /** + * 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 [appVersion]. + * + * Unlike [appVersion], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("app_version") @ExcludeMissing fun _appVersion(): JsonField = appVersion + + /** + * Returns the raw JSON value of [blockReasons]. + * + * Unlike [blockReasons], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("block_reasons") + @ExcludeMissing + fun _blockReasons(): JsonField> = blockReasons + + /** + * Returns the raw JSON value of [carrier]. + * + * Unlike [carrier], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("carrier") + @ExcludeMissing + fun _carrier(): JsonField = carrier + + /** + * Returns the raw JSON value of [correlationId]. + * + * Unlike [correlationId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("correlation_id") + @ExcludeMissing + fun _correlationId(): JsonField = correlationId + + /** + * Returns the raw JSON value of [deviceModel]. + * + * Unlike [deviceModel], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("device_model") + @ExcludeMissing + fun _deviceModel(): JsonField = deviceModel + + /** + * Returns the raw JSON value of [devicePlatform]. + * + * Unlike [devicePlatform], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("device_platform") + @ExcludeMissing + fun _devicePlatform(): JsonField = devicePlatform + + /** + * Returns the raw JSON value of [ipAddress]. + * + * Unlike [ipAddress], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ip_address") @ExcludeMissing fun _ipAddress(): JsonField = ipAddress + + /** + * Returns the raw JSON value of [ipAddressRegion]. + * + * Unlike [ipAddressRegion], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ip_address_region") + @ExcludeMissing + fun _ipAddressRegion(): JsonField = ipAddressRegion + + /** + * Returns the raw JSON value of [ipDistanceMeters]. + * + * Unlike [ipDistanceMeters], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("ip_distance_meters") + @ExcludeMissing + fun _ipDistanceMeters(): JsonField = ipDistanceMeters + + /** + * Returns the raw JSON value of [lifecycle]. + * + * Unlike [lifecycle], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("lifecycle") @ExcludeMissing fun _lifecycle(): JsonField = lifecycle + + /** + * Returns the raw JSON value of [phoneNumberCondition]. + * + * Unlike [phoneNumberCondition], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("phone_number_condition") + @ExcludeMissing + fun _phoneNumberCondition(): JsonField = phoneNumberCondition + + /** + * Returns the raw JSON value of [phoneNumberCurrentCondition]. + * + * Unlike [phoneNumberCurrentCondition], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("phone_number_current_condition") + @ExcludeMissing + fun _phoneNumberCurrentCondition(): JsonField = + phoneNumberCurrentCondition + + /** + * Returns the raw JSON value of [phoneNumberRegion]. + * + * Unlike [phoneNumberRegion], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("phone_number_region") + @ExcludeMissing + fun _phoneNumberRegion(): JsonField = phoneNumberRegion + + /** + * Returns the raw JSON value of [signals]. + * + * Unlike [signals], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("signals") @ExcludeMissing fun _signals(): JsonField = signals + + /** + * Returns the raw JSON value of [signalsHashStatus]. + * + * Unlike [signalsHashStatus], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("signals_hash_status") + @ExcludeMissing + fun _signalsHashStatus(): JsonField = signalsHashStatus + + /** + * Returns the raw JSON value of [templateId]. + * + * Unlike [templateId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("template_id") @ExcludeMissing fun _templateId(): JsonField = templateId + + @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 + * [VerificationPhoneHistoryRetrieveResponse]. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .expiresAt() + * .phoneNumber() + * .status() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [VerificationPhoneHistoryRetrieveResponse]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var createdAt: JsonField? = null + private var expiresAt: JsonField? = null + private var phoneNumber: JsonField? = null + private var status: JsonField? = null + private var appVersion: JsonField = JsonMissing.of() + private var blockReasons: JsonField>? = null + private var carrier: JsonField = JsonMissing.of() + private var correlationId: JsonField = JsonMissing.of() + private var deviceModel: JsonField = JsonMissing.of() + private var devicePlatform: JsonField = JsonMissing.of() + private var ipAddress: JsonField = JsonMissing.of() + private var ipAddressRegion: JsonField = JsonMissing.of() + private var ipDistanceMeters: JsonField = JsonMissing.of() + private var lifecycle: JsonField = JsonMissing.of() + private var phoneNumberCondition: JsonField = JsonMissing.of() + private var phoneNumberCurrentCondition: JsonField = + JsonMissing.of() + private var phoneNumberRegion: JsonField = JsonMissing.of() + private var signals: JsonField = JsonMissing.of() + private var signalsHashStatus: JsonField = JsonMissing.of() + private var templateId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + verificationPhoneHistoryRetrieveResponse: VerificationPhoneHistoryRetrieveResponse + ) = apply { + id = verificationPhoneHistoryRetrieveResponse.id + createdAt = verificationPhoneHistoryRetrieveResponse.createdAt + expiresAt = verificationPhoneHistoryRetrieveResponse.expiresAt + phoneNumber = verificationPhoneHistoryRetrieveResponse.phoneNumber + status = verificationPhoneHistoryRetrieveResponse.status + appVersion = verificationPhoneHistoryRetrieveResponse.appVersion + blockReasons = + verificationPhoneHistoryRetrieveResponse.blockReasons.map { it.toMutableList() } + carrier = verificationPhoneHistoryRetrieveResponse.carrier + correlationId = verificationPhoneHistoryRetrieveResponse.correlationId + deviceModel = verificationPhoneHistoryRetrieveResponse.deviceModel + devicePlatform = verificationPhoneHistoryRetrieveResponse.devicePlatform + ipAddress = verificationPhoneHistoryRetrieveResponse.ipAddress + ipAddressRegion = verificationPhoneHistoryRetrieveResponse.ipAddressRegion + ipDistanceMeters = verificationPhoneHistoryRetrieveResponse.ipDistanceMeters + lifecycle = verificationPhoneHistoryRetrieveResponse.lifecycle + phoneNumberCondition = verificationPhoneHistoryRetrieveResponse.phoneNumberCondition + phoneNumberCurrentCondition = + verificationPhoneHistoryRetrieveResponse.phoneNumberCurrentCondition + phoneNumberRegion = verificationPhoneHistoryRetrieveResponse.phoneNumberRegion + signals = verificationPhoneHistoryRetrieveResponse.signals + signalsHashStatus = verificationPhoneHistoryRetrieveResponse.signalsHashStatus + templateId = verificationPhoneHistoryRetrieveResponse.templateId + additionalProperties = + verificationPhoneHistoryRetrieveResponse.additionalProperties.toMutableMap() + } + + /** The verification identifier. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + 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 } + + fun expiresAt(expiresAt: OffsetDateTime) = expiresAt(JsonField.of(expiresAt)) + + /** + * Sets [Builder.expiresAt] to an arbitrary JSON value. + * + * You should usually call [Builder.expiresAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun expiresAt(expiresAt: JsonField) = apply { this.expiresAt = expiresAt } + + /** The E.164 phone number the verification targeted. */ + fun phoneNumber(phoneNumber: String) = phoneNumber(JsonField.of(phoneNumber)) + + /** + * Sets [Builder.phoneNumber] to an arbitrary JSON value. + * + * You should usually call [Builder.phoneNumber] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun phoneNumber(phoneNumber: JsonField) = apply { this.phoneNumber = phoneNumber } + + /** + * The outcome of the verification. + * * `converted` - The end user submitted a valid code. + * * `not_converted` - The verification expired without a valid code. + * * `pending_check` - A code was delivered and Prelude is still waiting for a check. + * * `sent` - A code was sent and the verification window is still open. + * * `challenged` - The verification was restricted to non-SMS and non-voice channels. + * * `suspected_fraud` - The anti-fraud system blocked the verification. + * * `in_blocklist` - The phone number is on the configured block list. + * * `invalid_line` - The phone number is not a valid line type. + * * `invalid_number` - The phone number is not a valid number. + * * `rate_limited` - The verification was refused by a rate limit. + * * `expired_signals` - The SDK signals were collected too long before the request. + * * `shadowed` - The anti-fraud system flagged the verification without blocking it. + */ + 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 } + + /** Version of your application, when known. */ + fun appVersion(appVersion: String) = appVersion(JsonField.of(appVersion)) + + /** + * Sets [Builder.appVersion] to an arbitrary JSON value. + * + * You should usually call [Builder.appVersion] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun appVersion(appVersion: JsonField) = apply { this.appVersion = appVersion } + + /** + * Why the anti-fraud system blocked the verification. Empty unless it did. + * * `behavioral_pattern` - The phone number past behavior during verification flows + * exhibits suspicious patterns. + * * `device_attribute` - The end-user device reported attributes associated with fraud or + * emulation. + * * `fraud_database` - The phone number appears in a fraud database. + * * `location_discrepancy` - The phone number region and the observed location disagree. + * * `missing_signals` - The verification expected Prelude SDK signals and none arrived. + * * `network_fingerprint` - The network fingerprint matches known fraudulent traffic. + * * `poor_conversion_history` - The phone number rarely completes the verifications it + * starts. + * * `prefix_concentration` - The phone number is part of a range known to be associated + * with suspicious activity patterns. + * * `repeated_number` - The phone number was used far more often than normal traffic would + * explain. + * * `suspected_request_tampering` - The SDK signals were altered or expired between + * collection and use. + * * `suspicious_ip_address` - The originating IP address is associated with suspicious + * activity. + * * `temporary_phone_number` - The phone number is known to be a temporary or disposable + * number. + */ + fun blockReasons(blockReasons: List) = blockReasons(JsonField.of(blockReasons)) + + /** + * Sets [Builder.blockReasons] to an arbitrary JSON value. + * + * You should usually call [Builder.blockReasons] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun blockReasons(blockReasons: JsonField>) = apply { + this.blockReasons = blockReasons.map { it.toMutableList() } + } + + /** + * Adds a single [BlockReason] to [blockReasons]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addBlockReason(blockReason: BlockReason) = apply { + blockReasons = + (blockReasons ?: JsonField.of(mutableListOf())).also { + checkKnown("blockReasons", it).add(blockReason) + } + } + + /** The end user's mobile network. */ + fun carrier(carrier: PhoneVerificationCarrier) = carrier(JsonField.of(carrier)) + + /** + * Sets [Builder.carrier] to an arbitrary JSON value. + * + * You should usually call [Builder.carrier] with a well-typed [PhoneVerificationCarrier] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun carrier(carrier: JsonField) = apply { this.carrier = carrier } + + /** The correlation identifier you supplied when creating the verification. */ + fun correlationId(correlationId: String) = correlationId(JsonField.of(correlationId)) + + /** + * Sets [Builder.correlationId] to an arbitrary JSON value. + * + * You should usually call [Builder.correlationId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun correlationId(correlationId: JsonField) = apply { + this.correlationId = correlationId + } + + /** Model of the end-user device, when known. */ + fun deviceModel(deviceModel: String) = deviceModel(JsonField.of(deviceModel)) + + /** + * Sets [Builder.deviceModel] to an arbitrary JSON value. + * + * You should usually call [Builder.deviceModel] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun deviceModel(deviceModel: JsonField) = apply { this.deviceModel = deviceModel } + + /** Platform of the end-user device, when known. */ + fun devicePlatform(devicePlatform: DevicePlatform) = + devicePlatform(JsonField.of(devicePlatform)) + + /** + * Sets [Builder.devicePlatform] to an arbitrary JSON value. + * + * You should usually call [Builder.devicePlatform] with a well-typed [DevicePlatform] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun devicePlatform(devicePlatform: JsonField) = apply { + this.devicePlatform = devicePlatform + } + + /** IP address the verification was created from. */ + fun ipAddress(ipAddress: String) = ipAddress(JsonField.of(ipAddress)) + + /** + * Sets [Builder.ipAddress] to an arbitrary JSON value. + * + * You should usually call [Builder.ipAddress] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun ipAddress(ipAddress: JsonField) = apply { this.ipAddress = ipAddress } + + /** ISO 3166-1 alpha-2 region of the caller's IP address. */ + fun ipAddressRegion(ipAddressRegion: String) = + ipAddressRegion(JsonField.of(ipAddressRegion)) + + /** + * Sets [Builder.ipAddressRegion] to an arbitrary JSON value. + * + * You should usually call [Builder.ipAddressRegion] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun ipAddressRegion(ipAddressRegion: JsonField) = apply { + this.ipAddressRegion = ipAddressRegion + } + + /** Distance between the phone number region and the IP location. */ + fun ipDistanceMeters(ipDistanceMeters: Long) = + ipDistanceMeters(JsonField.of(ipDistanceMeters)) + + /** + * Sets [Builder.ipDistanceMeters] to an arbitrary JSON value. + * + * You should usually call [Builder.ipDistanceMeters] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun ipDistanceMeters(ipDistanceMeters: JsonField) = apply { + this.ipDistanceMeters = ipDistanceMeters + } + + /** + * Chronological timeline of the verification: creation, message attempts with delivery + * events, code checks and signals reception. Omitted when Prelude holds no timeline for the + * verification. + */ + fun lifecycle(lifecycle: Lifecycle) = lifecycle(JsonField.of(lifecycle)) + + /** + * Sets [Builder.lifecycle] to an arbitrary JSON value. + * + * You should usually call [Builder.lifecycle] with a well-typed [Lifecycle] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun lifecycle(lifecycle: JsonField) = apply { this.lifecycle = lifecycle } + + /** + * Whether the phone number was allow-listed, block-listed, or sandboxed at verification + * time. + */ + fun phoneNumberCondition(phoneNumberCondition: PhoneNumberCondition) = + phoneNumberCondition(JsonField.of(phoneNumberCondition)) + + /** + * Sets [Builder.phoneNumberCondition] to an arbitrary JSON value. + * + * You should usually call [Builder.phoneNumberCondition] with a well-typed + * [PhoneNumberCondition] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun phoneNumberCondition(phoneNumberCondition: JsonField) = apply { + this.phoneNumberCondition = phoneNumberCondition + } + + /** Whether the phone number is currently allow-listed, block-listed, or sandboxed. */ + fun phoneNumberCurrentCondition(phoneNumberCurrentCondition: PhoneNumberCurrentCondition) = + phoneNumberCurrentCondition(JsonField.of(phoneNumberCurrentCondition)) + + /** + * Sets [Builder.phoneNumberCurrentCondition] to an arbitrary JSON value. + * + * You should usually call [Builder.phoneNumberCurrentCondition] with a well-typed + * [PhoneNumberCurrentCondition] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun phoneNumberCurrentCondition( + phoneNumberCurrentCondition: JsonField + ) = apply { this.phoneNumberCurrentCondition = phoneNumberCurrentCondition } + + /** ISO 3166-1 alpha-2 region of the phone number. */ + fun phoneNumberRegion(phoneNumberRegion: String) = + phoneNumberRegion(JsonField.of(phoneNumberRegion)) + + /** + * Sets [Builder.phoneNumberRegion] to an arbitrary JSON value. + * + * You should usually call [Builder.phoneNumberRegion] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun phoneNumberRegion(phoneNumberRegion: JsonField) = apply { + this.phoneNumberRegion = phoneNumberRegion + } + + /** The anti-fraud signals you forwarded when creating the verification. */ + fun signals(signals: Signals) = signals(JsonField.of(signals)) + + /** + * Sets [Builder.signals] to an arbitrary JSON value. + * + * You should usually call [Builder.signals] with a well-typed [Signals] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun signals(signals: JsonField) = apply { this.signals = signals } + + /** Whether the SDK signals integrity check passed. */ + fun signalsHashStatus(signalsHashStatus: SignalsHashStatus) = + signalsHashStatus(JsonField.of(signalsHashStatus)) + + /** + * Sets [Builder.signalsHashStatus] to an arbitrary JSON value. + * + * You should usually call [Builder.signalsHashStatus] with a well-typed [SignalsHashStatus] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun signalsHashStatus(signalsHashStatus: JsonField) = apply { + this.signalsHashStatus = signalsHashStatus + } + + /** The template used for this verification. */ + fun templateId(templateId: String) = templateId(JsonField.of(templateId)) + + /** + * Sets [Builder.templateId] to an arbitrary JSON value. + * + * You should usually call [Builder.templateId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun templateId(templateId: JsonField) = apply { this.templateId = templateId } + + 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 [VerificationPhoneHistoryRetrieveResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .expiresAt() + * .phoneNumber() + * .status() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): VerificationPhoneHistoryRetrieveResponse = + VerificationPhoneHistoryRetrieveResponse( + checkRequired("id", id), + checkRequired("createdAt", createdAt), + checkRequired("expiresAt", expiresAt), + checkRequired("phoneNumber", phoneNumber), + checkRequired("status", status), + appVersion, + (blockReasons ?: JsonMissing.of()).map { it.toImmutable() }, + carrier, + correlationId, + deviceModel, + devicePlatform, + ipAddress, + ipAddressRegion, + ipDistanceMeters, + lifecycle, + phoneNumberCondition, + phoneNumberCurrentCondition, + phoneNumberRegion, + signals, + signalsHashStatus, + templateId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws PreludeInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): VerificationPhoneHistoryRetrieveResponse = apply { + if (validated) { + return@apply + } + + id() + createdAt() + expiresAt() + phoneNumber() + status().validate() + appVersion() + blockReasons().ifPresent { it.forEach { it.validate() } } + carrier().ifPresent { it.validate() } + correlationId() + deviceModel() + devicePlatform().ifPresent { it.validate() } + ipAddress() + ipAddressRegion() + ipDistanceMeters() + lifecycle().ifPresent { it.validate() } + phoneNumberCondition().ifPresent { it.validate() } + phoneNumberCurrentCondition().ifPresent { it.validate() } + phoneNumberRegion() + signals().ifPresent { it.validate() } + signalsHashStatus().ifPresent { it.validate() } + templateId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: PreludeInvalidDataException) { + 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 (id.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (expiresAt.asKnown().isPresent) 1 else 0) + + (if (phoneNumber.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (if (appVersion.asKnown().isPresent) 1 else 0) + + (blockReasons.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (carrier.asKnown().getOrNull()?.validity() ?: 0) + + (if (correlationId.asKnown().isPresent) 1 else 0) + + (if (deviceModel.asKnown().isPresent) 1 else 0) + + (devicePlatform.asKnown().getOrNull()?.validity() ?: 0) + + (if (ipAddress.asKnown().isPresent) 1 else 0) + + (if (ipAddressRegion.asKnown().isPresent) 1 else 0) + + (if (ipDistanceMeters.asKnown().isPresent) 1 else 0) + + (lifecycle.asKnown().getOrNull()?.validity() ?: 0) + + (phoneNumberCondition.asKnown().getOrNull()?.validity() ?: 0) + + (phoneNumberCurrentCondition.asKnown().getOrNull()?.validity() ?: 0) + + (if (phoneNumberRegion.asKnown().isPresent) 1 else 0) + + (signals.asKnown().getOrNull()?.validity() ?: 0) + + (signalsHashStatus.asKnown().getOrNull()?.validity() ?: 0) + + (if (templateId.asKnown().isPresent) 1 else 0) + + /** + * The outcome of the verification. + * * `converted` - The end user submitted a valid code. + * * `not_converted` - The verification expired without a valid code. + * * `pending_check` - A code was delivered and Prelude is still waiting for a check. + * * `sent` - A code was sent and the verification window is still open. + * * `challenged` - The verification was restricted to non-SMS and non-voice channels. + * * `suspected_fraud` - The anti-fraud system blocked the verification. + * * `in_blocklist` - The phone number is on the configured block list. + * * `invalid_line` - The phone number is not a valid line type. + * * `invalid_number` - The phone number is not a valid number. + * * `rate_limited` - The verification was refused by a rate limit. + * * `expired_signals` - The SDK signals were collected too long before the request. + * * `shadowed` - The anti-fraud system flagged the verification without blocking it. + */ + 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 CONVERTED = of("converted") + + @JvmField val NOT_CONVERTED = of("not_converted") + + @JvmField val PENDING_CHECK = of("pending_check") + + @JvmField val SENT = of("sent") + + @JvmField val CHALLENGED = of("challenged") + + @JvmField val SUSPECTED_FRAUD = of("suspected_fraud") + + @JvmField val IN_BLOCKLIST = of("in_blocklist") + + @JvmField val INVALID_LINE = of("invalid_line") + + @JvmField val INVALID_NUMBER = of("invalid_number") + + @JvmField val RATE_LIMITED = of("rate_limited") + + @JvmField val EXPIRED_SIGNALS = of("expired_signals") + + @JvmField val SHADOWED = of("shadowed") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + CONVERTED, + NOT_CONVERTED, + PENDING_CHECK, + SENT, + CHALLENGED, + SUSPECTED_FRAUD, + IN_BLOCKLIST, + INVALID_LINE, + INVALID_NUMBER, + RATE_LIMITED, + EXPIRED_SIGNALS, + SHADOWED, + } + + /** + * 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 { + CONVERTED, + NOT_CONVERTED, + PENDING_CHECK, + SENT, + CHALLENGED, + SUSPECTED_FRAUD, + IN_BLOCKLIST, + INVALID_LINE, + INVALID_NUMBER, + RATE_LIMITED, + EXPIRED_SIGNALS, + SHADOWED, + /** 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) { + CONVERTED -> Value.CONVERTED + NOT_CONVERTED -> Value.NOT_CONVERTED + PENDING_CHECK -> Value.PENDING_CHECK + SENT -> Value.SENT + CHALLENGED -> Value.CHALLENGED + SUSPECTED_FRAUD -> Value.SUSPECTED_FRAUD + IN_BLOCKLIST -> Value.IN_BLOCKLIST + INVALID_LINE -> Value.INVALID_LINE + INVALID_NUMBER -> Value.INVALID_NUMBER + RATE_LIMITED -> Value.RATE_LIMITED + EXPIRED_SIGNALS -> Value.EXPIRED_SIGNALS + SHADOWED -> Value.SHADOWED + 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 PreludeInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + CONVERTED -> Known.CONVERTED + NOT_CONVERTED -> Known.NOT_CONVERTED + PENDING_CHECK -> Known.PENDING_CHECK + SENT -> Known.SENT + CHALLENGED -> Known.CHALLENGED + SUSPECTED_FRAUD -> Known.SUSPECTED_FRAUD + IN_BLOCKLIST -> Known.IN_BLOCKLIST + INVALID_LINE -> Known.INVALID_LINE + INVALID_NUMBER -> Known.INVALID_NUMBER + RATE_LIMITED -> Known.RATE_LIMITED + EXPIRED_SIGNALS -> Known.EXPIRED_SIGNALS + SHADOWED -> Known.SHADOWED + else -> throw PreludeInvalidDataException("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 PreludeInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { PreludeInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws PreludeInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: PreludeInvalidDataException) { + 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() + } + + class BlockReason @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 BEHAVIORAL_PATTERN = of("behavioral_pattern") + + @JvmField val DEVICE_ATTRIBUTE = of("device_attribute") + + @JvmField val FRAUD_DATABASE = of("fraud_database") + + @JvmField val LOCATION_DISCREPANCY = of("location_discrepancy") + + @JvmField val MISSING_SIGNALS = of("missing_signals") + + @JvmField val NETWORK_FINGERPRINT = of("network_fingerprint") + + @JvmField val POOR_CONVERSION_HISTORY = of("poor_conversion_history") + + @JvmField val PREFIX_CONCENTRATION = of("prefix_concentration") + + @JvmField val REPEATED_NUMBER = of("repeated_number") + + @JvmField val SUSPECTED_REQUEST_TAMPERING = of("suspected_request_tampering") + + @JvmField val SUSPICIOUS_IP_ADDRESS = of("suspicious_ip_address") + + @JvmField val TEMPORARY_PHONE_NUMBER = of("temporary_phone_number") + + @JvmStatic fun of(value: String) = BlockReason(JsonField.of(value)) + } + + /** An enum containing [BlockReason]'s known values. */ + enum class Known { + BEHAVIORAL_PATTERN, + DEVICE_ATTRIBUTE, + FRAUD_DATABASE, + LOCATION_DISCREPANCY, + MISSING_SIGNALS, + NETWORK_FINGERPRINT, + POOR_CONVERSION_HISTORY, + PREFIX_CONCENTRATION, + REPEATED_NUMBER, + SUSPECTED_REQUEST_TAMPERING, + SUSPICIOUS_IP_ADDRESS, + TEMPORARY_PHONE_NUMBER, + } + + /** + * An enum containing [BlockReason]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [BlockReason] 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 { + BEHAVIORAL_PATTERN, + DEVICE_ATTRIBUTE, + FRAUD_DATABASE, + LOCATION_DISCREPANCY, + MISSING_SIGNALS, + NETWORK_FINGERPRINT, + POOR_CONVERSION_HISTORY, + PREFIX_CONCENTRATION, + REPEATED_NUMBER, + SUSPECTED_REQUEST_TAMPERING, + SUSPICIOUS_IP_ADDRESS, + TEMPORARY_PHONE_NUMBER, + /** + * An enum member indicating that [BlockReason] 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) { + BEHAVIORAL_PATTERN -> Value.BEHAVIORAL_PATTERN + DEVICE_ATTRIBUTE -> Value.DEVICE_ATTRIBUTE + FRAUD_DATABASE -> Value.FRAUD_DATABASE + LOCATION_DISCREPANCY -> Value.LOCATION_DISCREPANCY + MISSING_SIGNALS -> Value.MISSING_SIGNALS + NETWORK_FINGERPRINT -> Value.NETWORK_FINGERPRINT + POOR_CONVERSION_HISTORY -> Value.POOR_CONVERSION_HISTORY + PREFIX_CONCENTRATION -> Value.PREFIX_CONCENTRATION + REPEATED_NUMBER -> Value.REPEATED_NUMBER + SUSPECTED_REQUEST_TAMPERING -> Value.SUSPECTED_REQUEST_TAMPERING + SUSPICIOUS_IP_ADDRESS -> Value.SUSPICIOUS_IP_ADDRESS + TEMPORARY_PHONE_NUMBER -> Value.TEMPORARY_PHONE_NUMBER + 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 PreludeInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + BEHAVIORAL_PATTERN -> Known.BEHAVIORAL_PATTERN + DEVICE_ATTRIBUTE -> Known.DEVICE_ATTRIBUTE + FRAUD_DATABASE -> Known.FRAUD_DATABASE + LOCATION_DISCREPANCY -> Known.LOCATION_DISCREPANCY + MISSING_SIGNALS -> Known.MISSING_SIGNALS + NETWORK_FINGERPRINT -> Known.NETWORK_FINGERPRINT + POOR_CONVERSION_HISTORY -> Known.POOR_CONVERSION_HISTORY + PREFIX_CONCENTRATION -> Known.PREFIX_CONCENTRATION + REPEATED_NUMBER -> Known.REPEATED_NUMBER + SUSPECTED_REQUEST_TAMPERING -> Known.SUSPECTED_REQUEST_TAMPERING + SUSPICIOUS_IP_ADDRESS -> Known.SUSPICIOUS_IP_ADDRESS + TEMPORARY_PHONE_NUMBER -> Known.TEMPORARY_PHONE_NUMBER + else -> throw PreludeInvalidDataException("Unknown BlockReason: $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 PreludeInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { PreludeInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws PreludeInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): BlockReason = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: PreludeInvalidDataException) { + 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 BlockReason && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Platform of the end-user device, when known. */ + class DevicePlatform @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 ANDROID = of("android") + + @JvmField val IOS = of("ios") + + @JvmField val IPADOS = of("ipados") + + @JvmField val TVOS = of("tvos") + + @JvmField val WEB = of("web") + + @JvmStatic fun of(value: String) = DevicePlatform(JsonField.of(value)) + } + + /** An enum containing [DevicePlatform]'s known values. */ + enum class Known { + ANDROID, + IOS, + IPADOS, + TVOS, + WEB, + } + + /** + * An enum containing [DevicePlatform]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [DevicePlatform] 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 { + ANDROID, + IOS, + IPADOS, + TVOS, + WEB, + /** + * An enum member indicating that [DevicePlatform] 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) { + ANDROID -> Value.ANDROID + IOS -> Value.IOS + IPADOS -> Value.IPADOS + TVOS -> Value.TVOS + WEB -> Value.WEB + 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 PreludeInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ANDROID -> Known.ANDROID + IOS -> Known.IOS + IPADOS -> Known.IPADOS + TVOS -> Known.TVOS + WEB -> Known.WEB + else -> throw PreludeInvalidDataException("Unknown DevicePlatform: $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 PreludeInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { PreludeInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws PreludeInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): DevicePlatform = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: PreludeInvalidDataException) { + 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 DevicePlatform && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * Chronological timeline of the verification: creation, message attempts with delivery events, + * code checks and signals reception. Omitted when Prelude holds no timeline for the + * verification. + */ + class Lifecycle + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val events: JsonField>, + private val totalCost: JsonField, + private val undeliverableRouteCount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("events") + @ExcludeMissing + events: JsonField> = JsonMissing.of(), + @JsonProperty("total_cost") + @ExcludeMissing + totalCost: JsonField = JsonMissing.of(), + @JsonProperty("undeliverable_route_count") + @ExcludeMissing + undeliverableRouteCount: JsonField = JsonMissing.of(), + ) : this(events, totalCost, undeliverableRouteCount, mutableMapOf()) + + /** + * @throws PreludeInvalidDataException 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 events(): List = events.getRequired("events") + + /** + * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun totalCost(): Optional = totalCost.getOptional("total_cost") + + /** + * How many times the message was reported undeliverable by independent routes. Above zero + * usually means the phone number is incorrect or the device unreachable. + * + * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun undeliverableRouteCount(): Optional = + undeliverableRouteCount.getOptional("undeliverable_route_count") + + /** + * Returns the raw JSON value of [events]. + * + * Unlike [events], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("events") @ExcludeMissing fun _events(): JsonField> = events + + /** + * Returns the raw JSON value of [totalCost]. + * + * Unlike [totalCost], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("total_cost") + @ExcludeMissing + fun _totalCost(): JsonField = totalCost + + /** + * Returns the raw JSON value of [undeliverableRouteCount]. + * + * Unlike [undeliverableRouteCount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("undeliverable_route_count") + @ExcludeMissing + fun _undeliverableRouteCount(): JsonField = undeliverableRouteCount + + @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 [Lifecycle]. + * + * The following fields are required: + * ```java + * .events() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Lifecycle]. */ + class Builder internal constructor() { + + private var events: JsonField>? = null + private var totalCost: JsonField = JsonMissing.of() + private var undeliverableRouteCount: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(lifecycle: Lifecycle) = apply { + events = lifecycle.events.map { it.toMutableList() } + totalCost = lifecycle.totalCost + undeliverableRouteCount = lifecycle.undeliverableRouteCount + additionalProperties = lifecycle.additionalProperties.toMutableMap() + } + + fun events(events: List) = events(JsonField.of(events)) + + /** + * Sets [Builder.events] to an arbitrary JSON value. + * + * You should usually call [Builder.events] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun events(events: JsonField>) = apply { + this.events = events.map { it.toMutableList() } + } + + /** + * Adds a single [Event] to [events]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addEvent(event: Event) = apply { + events = + (events ?: JsonField.of(mutableListOf())).also { + checkKnown("events", it).add(event) + } + } + + fun totalCost(totalCost: PhoneVerificationMoney) = totalCost(JsonField.of(totalCost)) + + /** + * Sets [Builder.totalCost] to an arbitrary JSON value. + * + * You should usually call [Builder.totalCost] with a well-typed + * [PhoneVerificationMoney] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun totalCost(totalCost: JsonField) = apply { + this.totalCost = totalCost + } + + /** + * How many times the message was reported undeliverable by independent routes. Above + * zero usually means the phone number is incorrect or the device unreachable. + */ + fun undeliverableRouteCount(undeliverableRouteCount: Long) = + undeliverableRouteCount(JsonField.of(undeliverableRouteCount)) + + /** + * Sets [Builder.undeliverableRouteCount] to an arbitrary JSON value. + * + * You should usually call [Builder.undeliverableRouteCount] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun undeliverableRouteCount(undeliverableRouteCount: JsonField) = apply { + this.undeliverableRouteCount = undeliverableRouteCount + } + + 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 [Lifecycle]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .events() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Lifecycle = + Lifecycle( + checkRequired("events", events).map { it.toImmutable() }, + totalCost, + undeliverableRouteCount, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws PreludeInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Lifecycle = apply { + if (validated) { + return@apply + } + + events().forEach { it.validate() } + totalCost().ifPresent { it.validate() } + undeliverableRouteCount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: PreludeInvalidDataException) { + 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 = + (events.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (totalCost.asKnown().getOrNull()?.validity() ?: 0) + + (if (undeliverableRouteCount.asKnown().isPresent) 1 else 0) + + /** One timeline entry. `type` names the single payload field that is set. */ + class Event + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val type: JsonField, + private val attempt: JsonField, + private val check: JsonField, + private val create: JsonField, + private val signals: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("attempt") + @ExcludeMissing + attempt: JsonField = JsonMissing.of(), + @JsonProperty("check") @ExcludeMissing check: JsonField = JsonMissing.of(), + @JsonProperty("create") + @ExcludeMissing + create: JsonField = JsonMissing.of(), + @JsonProperty("signals") + @ExcludeMissing + signals: JsonField = JsonMissing.of(), + ) : this(type, attempt, check, create, signals, mutableMapOf()) + + /** + * @throws PreludeInvalidDataException 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 type(): Type = type.getRequired("type") + + /** + * One message sent for this verification. + * + * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun attempt(): Optional = attempt.getOptional("attempt") + + /** + * One code submission for this verification. + * + * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun check(): Optional = check.getOptional("check") + + /** + * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun create(): Optional = create.getOptional("create") + + /** + * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun signals(): Optional = signals.getOptional("signals") + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + /** + * Returns the raw JSON value of [attempt]. + * + * Unlike [attempt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("attempt") @ExcludeMissing fun _attempt(): JsonField = attempt + + /** + * Returns the raw JSON value of [check]. + * + * Unlike [check], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("check") @ExcludeMissing fun _check(): JsonField = check + + /** + * Returns the raw JSON value of [create]. + * + * Unlike [create], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("create") @ExcludeMissing fun _create(): JsonField = create + + /** + * Returns the raw JSON value of [signals]. + * + * Unlike [signals], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("signals") @ExcludeMissing fun _signals(): JsonField = signals + + @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 [Event]. + * + * The following fields are required: + * ```java + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Event]. */ + class Builder internal constructor() { + + private var type: JsonField? = null + private var attempt: JsonField = JsonMissing.of() + private var check: JsonField = JsonMissing.of() + private var create: JsonField = JsonMissing.of() + private var signals: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(event: Event) = apply { + type = event.type + attempt = event.attempt + check = event.check + create = event.create + signals = event.signals + additionalProperties = event.additionalProperties.toMutableMap() + } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + /** One message sent for this verification. */ + fun attempt(attempt: Attempt) = attempt(JsonField.of(attempt)) + + /** + * Sets [Builder.attempt] to an arbitrary JSON value. + * + * You should usually call [Builder.attempt] with a well-typed [Attempt] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun attempt(attempt: JsonField) = apply { this.attempt = attempt } + + /** One code submission for this verification. */ + fun check(check: Check) = check(JsonField.of(check)) + + /** + * Sets [Builder.check] to an arbitrary JSON value. + * + * You should usually call [Builder.check] with a well-typed [Check] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun check(check: JsonField) = apply { this.check = check } + + fun create(create: Create) = create(JsonField.of(create)) + + /** + * Sets [Builder.create] to an arbitrary JSON value. + * + * You should usually call [Builder.create] with a well-typed [Create] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun create(create: JsonField) = apply { this.create = create } + + fun signals(signals: Signals) = signals(JsonField.of(signals)) + + /** + * Sets [Builder.signals] to an arbitrary JSON value. + * + * You should usually call [Builder.signals] with a well-typed [Signals] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun signals(signals: JsonField) = apply { this.signals = signals } + + 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 [Event]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Event = + Event( + checkRequired("type", type), + attempt, + check, + create, + signals, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws PreludeInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): Event = apply { + if (validated) { + return@apply + } + + type().validate() + attempt().ifPresent { it.validate() } + check().ifPresent { it.validate() } + create().ifPresent { it.validate() } + signals().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: PreludeInvalidDataException) { + 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 = + (type.asKnown().getOrNull()?.validity() ?: 0) + + (attempt.asKnown().getOrNull()?.validity() ?: 0) + + (check.asKnown().getOrNull()?.validity() ?: 0) + + (create.asKnown().getOrNull()?.validity() ?: 0) + + (signals.asKnown().getOrNull()?.validity() ?: 0) + + class Type @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 CREATE = of("create") + + @JvmField val ATTEMPT = of("attempt") + + @JvmField val CHECK = of("check") + + @JvmField val SIGNALS = of("signals") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + CREATE, + ATTEMPT, + CHECK, + SIGNALS, + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] 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 { + CREATE, + ATTEMPT, + CHECK, + SIGNALS, + /** + * An enum member indicating that [Type] 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) { + CREATE -> Value.CREATE + ATTEMPT -> Value.ATTEMPT + CHECK -> Value.CHECK + SIGNALS -> Value.SIGNALS + 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 PreludeInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + CREATE -> Known.CREATE + ATTEMPT -> Known.ATTEMPT + CHECK -> Known.CHECK + SIGNALS -> Known.SIGNALS + else -> throw PreludeInvalidDataException("Unknown Type: $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 PreludeInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + PreludeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws PreludeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: PreludeInvalidDataException) { + 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 Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** One message sent for this verification. */ + class Attempt + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val createdAt: JsonField, + private val carrier: JsonField, + private val channel: JsonField, + private val content: JsonField, + private val cost: JsonField, + private val deliveryEvents: JsonField>, + private val deliveryStatus: JsonField, + private val preferredChannel: JsonField, + private val status: JsonField, + private val trigger: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField = JsonMissing.of(), + @JsonProperty("carrier") + @ExcludeMissing + carrier: JsonField = JsonMissing.of(), + @JsonProperty("channel") + @ExcludeMissing + channel: JsonField = JsonMissing.of(), + @JsonProperty("content") + @ExcludeMissing + content: JsonField = JsonMissing.of(), + @JsonProperty("cost") + @ExcludeMissing + cost: JsonField = JsonMissing.of(), + @JsonProperty("delivery_events") + @ExcludeMissing + deliveryEvents: JsonField> = JsonMissing.of(), + @JsonProperty("delivery_status") + @ExcludeMissing + deliveryStatus: JsonField = JsonMissing.of(), + @JsonProperty("preferred_channel") + @ExcludeMissing + preferredChannel: JsonField = JsonMissing.of(), + @JsonProperty("status") + @ExcludeMissing + status: JsonField = JsonMissing.of(), + @JsonProperty("trigger") + @ExcludeMissing + trigger: JsonField = JsonMissing.of(), + ) : this( + id, + createdAt, + carrier, + channel, + content, + cost, + deliveryEvents, + deliveryStatus, + preferredChannel, + status, + trigger, + mutableMapOf(), + ) + + /** + * @throws PreludeInvalidDataException 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 id(): String = id.getRequired("id") + + /** + * @throws PreludeInvalidDataException 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 createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * The end user's mobile network. + * + * @throws PreludeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun carrier(): Optional = carrier.getOptional("carrier") + + /** + * @throws PreludeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun channel(): Optional = channel.getOptional("channel") + + /** + * Message body. While the verification can still be completed, the code inside it + * is masked rather than removed. + * + * @throws PreludeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun content(): Optional = content.getOptional("content") + + /** + * @throws PreludeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun cost(): Optional = cost.getOptional("cost") + + /** + * @throws PreludeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun deliveryEvents(): Optional> = + deliveryEvents.getOptional("delivery_events") + + /** + * @throws PreludeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun deliveryStatus(): Optional = + deliveryStatus.getOptional("delivery_status") + + /** + * Channel you asked for, when it differs from the one used. + * + * @throws PreludeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun preferredChannel(): Optional = + preferredChannel.getOptional("preferred_channel") + + /** + * @throws PreludeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun status(): Optional = status.getOptional("status") + + /** + * What caused the attempt. + * + * @throws PreludeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun trigger(): Optional = trigger.getOptional("trigger") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * 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 [carrier]. + * + * Unlike [carrier], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("carrier") + @ExcludeMissing + fun _carrier(): JsonField = carrier + + /** + * Returns the raw JSON value of [channel]. + * + * Unlike [channel], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("channel") + @ExcludeMissing + fun _channel(): JsonField = channel + + /** + * Returns the raw JSON value of [content]. + * + * Unlike [content], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("content") @ExcludeMissing fun _content(): JsonField = content + + /** + * Returns the raw JSON value of [cost]. + * + * Unlike [cost], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cost") + @ExcludeMissing + fun _cost(): JsonField = cost + + /** + * Returns the raw JSON value of [deliveryEvents]. + * + * Unlike [deliveryEvents], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("delivery_events") + @ExcludeMissing + fun _deliveryEvents(): JsonField> = deliveryEvents + + /** + * Returns the raw JSON value of [deliveryStatus]. + * + * Unlike [deliveryStatus], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("delivery_status") + @ExcludeMissing + fun _deliveryStatus(): JsonField = deliveryStatus + + /** + * Returns the raw JSON value of [preferredChannel]. + * + * Unlike [preferredChannel], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("preferred_channel") + @ExcludeMissing + fun _preferredChannel(): JsonField = preferredChannel + + /** + * 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 [trigger]. + * + * Unlike [trigger], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("trigger") + @ExcludeMissing + fun _trigger(): JsonField = trigger + + @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 [Attempt]. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Attempt]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var createdAt: JsonField? = null + private var carrier: JsonField = JsonMissing.of() + private var channel: JsonField = JsonMissing.of() + private var content: JsonField = JsonMissing.of() + private var cost: JsonField = JsonMissing.of() + private var deliveryEvents: JsonField>? = null + private var deliveryStatus: JsonField = JsonMissing.of() + private var preferredChannel: JsonField = JsonMissing.of() + private var status: JsonField = JsonMissing.of() + private var trigger: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(attempt: Attempt) = apply { + id = attempt.id + createdAt = attempt.createdAt + carrier = attempt.carrier + channel = attempt.channel + content = attempt.content + cost = attempt.cost + deliveryEvents = attempt.deliveryEvents.map { it.toMutableList() } + deliveryStatus = attempt.deliveryStatus + preferredChannel = attempt.preferredChannel + status = attempt.status + trigger = attempt.trigger + additionalProperties = attempt.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + 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 end user's mobile network. */ + fun carrier(carrier: PhoneVerificationCarrier) = carrier(JsonField.of(carrier)) + + /** + * Sets [Builder.carrier] to an arbitrary JSON value. + * + * You should usually call [Builder.carrier] with a well-typed + * [PhoneVerificationCarrier] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun carrier(carrier: JsonField) = apply { + this.carrier = carrier + } + + fun channel(channel: Channel) = channel(JsonField.of(channel)) + + /** + * Sets [Builder.channel] to an arbitrary JSON value. + * + * You should usually call [Builder.channel] with a well-typed [Channel] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun channel(channel: JsonField) = apply { this.channel = channel } + + /** + * Message body. While the verification can still be completed, the code inside + * it is masked rather than removed. + */ + fun content(content: String) = content(JsonField.of(content)) + + /** + * Sets [Builder.content] to an arbitrary JSON value. + * + * You should usually call [Builder.content] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun content(content: JsonField) = apply { this.content = content } + + fun cost(cost: PhoneVerificationMoney) = cost(JsonField.of(cost)) + + /** + * Sets [Builder.cost] to an arbitrary JSON value. + * + * You should usually call [Builder.cost] with a well-typed + * [PhoneVerificationMoney] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun cost(cost: JsonField) = apply { this.cost = cost } + + fun deliveryEvents(deliveryEvents: List) = + deliveryEvents(JsonField.of(deliveryEvents)) + + /** + * Sets [Builder.deliveryEvents] to an arbitrary JSON value. + * + * You should usually call [Builder.deliveryEvents] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun deliveryEvents(deliveryEvents: JsonField>) = apply { + this.deliveryEvents = deliveryEvents.map { it.toMutableList() } + } + + /** + * Adds a single [DeliveryEvent] to [deliveryEvents]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addDeliveryEvent(deliveryEvent: DeliveryEvent) = apply { + deliveryEvents = + (deliveryEvents ?: JsonField.of(mutableListOf())).also { + checkKnown("deliveryEvents", it).add(deliveryEvent) + } + } + + fun deliveryStatus(deliveryStatus: DeliveryStatus) = + deliveryStatus(JsonField.of(deliveryStatus)) + + /** + * Sets [Builder.deliveryStatus] to an arbitrary JSON value. + * + * You should usually call [Builder.deliveryStatus] with a well-typed + * [DeliveryStatus] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun deliveryStatus(deliveryStatus: JsonField) = apply { + this.deliveryStatus = deliveryStatus + } + + /** Channel you asked for, when it differs from the one used. */ + fun preferredChannel(preferredChannel: PreferredChannel) = + preferredChannel(JsonField.of(preferredChannel)) + + /** + * Sets [Builder.preferredChannel] to an arbitrary JSON value. + * + * You should usually call [Builder.preferredChannel] with a well-typed + * [PreferredChannel] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun preferredChannel(preferredChannel: JsonField) = apply { + this.preferredChannel = preferredChannel + } + + 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 } + + /** What caused the attempt. */ + fun trigger(trigger: Trigger) = trigger(JsonField.of(trigger)) + + /** + * Sets [Builder.trigger] to an arbitrary JSON value. + * + * You should usually call [Builder.trigger] with a well-typed [Trigger] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun trigger(trigger: JsonField) = apply { this.trigger = trigger } + + 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 [Attempt]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Attempt = + Attempt( + checkRequired("id", id), + checkRequired("createdAt", createdAt), + carrier, + channel, + content, + cost, + (deliveryEvents ?: JsonMissing.of()).map { it.toImmutable() }, + deliveryStatus, + preferredChannel, + status, + trigger, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws PreludeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Attempt = apply { + if (validated) { + return@apply + } + + id() + createdAt() + carrier().ifPresent { it.validate() } + channel().ifPresent { it.validate() } + content() + cost().ifPresent { it.validate() } + deliveryEvents().ifPresent { it.forEach { it.validate() } } + deliveryStatus().ifPresent { it.validate() } + preferredChannel().ifPresent { it.validate() } + status().ifPresent { it.validate() } + trigger().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: PreludeInvalidDataException) { + 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 (id.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (carrier.asKnown().getOrNull()?.validity() ?: 0) + + (channel.asKnown().getOrNull()?.validity() ?: 0) + + (if (content.asKnown().isPresent) 1 else 0) + + (cost.asKnown().getOrNull()?.validity() ?: 0) + + (deliveryEvents.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (deliveryStatus.asKnown().getOrNull()?.validity() ?: 0) + + (preferredChannel.asKnown().getOrNull()?.validity() ?: 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (trigger.asKnown().getOrNull()?.validity() ?: 0) + + class Channel + @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 SMS = of("sms") + + @JvmField val RCS = of("rcs") + + @JvmField val WHATSAPP = of("whatsapp") + + @JvmField val VIBER = of("viber") + + @JvmField val ZALO = of("zalo") + + @JvmField val TELEGRAM = of("telegram") + + @JvmField val VOICE = of("voice") + + @JvmField val SILENT = of("silent") + + @JvmStatic fun of(value: String) = Channel(JsonField.of(value)) + } + + /** An enum containing [Channel]'s known values. */ + enum class Known { + SMS, + RCS, + WHATSAPP, + VIBER, + ZALO, + TELEGRAM, + VOICE, + SILENT, + } + + /** + * An enum containing [Channel]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Channel] 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 { + SMS, + RCS, + WHATSAPP, + VIBER, + ZALO, + TELEGRAM, + VOICE, + SILENT, + /** + * An enum member indicating that [Channel] 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) { + SMS -> Value.SMS + RCS -> Value.RCS + WHATSAPP -> Value.WHATSAPP + VIBER -> Value.VIBER + ZALO -> Value.ZALO + TELEGRAM -> Value.TELEGRAM + VOICE -> Value.VOICE + SILENT -> Value.SILENT + 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 PreludeInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + SMS -> Known.SMS + RCS -> Known.RCS + WHATSAPP -> Known.WHATSAPP + VIBER -> Known.VIBER + ZALO -> Known.ZALO + TELEGRAM -> Known.TELEGRAM + VOICE -> Known.VOICE + SILENT -> Known.SILENT + else -> throw PreludeInvalidDataException("Unknown Channel: $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 PreludeInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + PreludeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws PreludeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Channel = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: PreludeInvalidDataException) { + 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 Channel && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class DeliveryEvent + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val receivedAt: JsonField, + private val status: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("received_at") + @ExcludeMissing + receivedAt: JsonField = JsonMissing.of(), + @JsonProperty("status") + @ExcludeMissing + status: JsonField = JsonMissing.of(), + ) : this(receivedAt, status, mutableMapOf()) + + /** + * @throws PreludeInvalidDataException 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 receivedAt(): OffsetDateTime = receivedAt.getRequired("received_at") + + /** + * The state this event reported. It is finer-grained than the attempt's + * `delivery_status` and includes the states a silent verification goes through. + * + * @throws PreludeInvalidDataException 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 status(): Status = status.getRequired("status") + + /** + * Returns the raw JSON value of [receivedAt]. + * + * Unlike [receivedAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("received_at") + @ExcludeMissing + fun _receivedAt(): JsonField = receivedAt + + /** + * 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 + * [DeliveryEvent]. + * + * The following fields are required: + * ```java + * .receivedAt() + * .status() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DeliveryEvent]. */ + class Builder internal constructor() { + + private var receivedAt: JsonField? = null + private var status: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(deliveryEvent: DeliveryEvent) = apply { + receivedAt = deliveryEvent.receivedAt + status = deliveryEvent.status + additionalProperties = deliveryEvent.additionalProperties.toMutableMap() + } + + fun receivedAt(receivedAt: OffsetDateTime) = + receivedAt(JsonField.of(receivedAt)) + + /** + * Sets [Builder.receivedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.receivedAt] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun receivedAt(receivedAt: JsonField) = apply { + this.receivedAt = receivedAt + } + + /** + * The state this event reported. It is finer-grained than the attempt's + * `delivery_status` and includes the states a silent verification goes + * through. + */ + 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 } + + 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 [DeliveryEvent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .receivedAt() + * .status() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): DeliveryEvent = + DeliveryEvent( + checkRequired("receivedAt", receivedAt), + checkRequired("status", status), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws PreludeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): DeliveryEvent = apply { + if (validated) { + return@apply + } + + receivedAt() + status().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: PreludeInvalidDataException) { + 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 (receivedAt.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + /** + * The state this event reported. It is finer-grained than the attempt's + * `delivery_status` and includes the states a silent verification goes through. + */ + 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 UNKNOWN = of("unknown") + + @JvmField val SUBMITTED = of("submitted") + + @JvmField val IN_TRANSIT = of("in_transit") + + @JvmField val DELIVERED = of("delivered") + + @JvmField val UNDELIVERABLE = of("undeliverable") + + @JvmField val EXPIRED = of("expired") + + @JvmField val READ = of("read") + + @JvmField val SILENT_STARTED = of("silent_started") + + @JvmField val SILENT_VERIFIED = of("silent_verified") + + @JvmField val SILENT_MISMATCH = of("silent_mismatch") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + UNKNOWN, + SUBMITTED, + IN_TRANSIT, + DELIVERED, + UNDELIVERABLE, + EXPIRED, + READ, + SILENT_STARTED, + SILENT_VERIFIED, + SILENT_MISMATCH, + } + + /** + * 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 { + UNKNOWN, + SUBMITTED, + IN_TRANSIT, + DELIVERED, + UNDELIVERABLE, + EXPIRED, + READ, + SILENT_STARTED, + SILENT_VERIFIED, + SILENT_MISMATCH, + /** + * 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) { + UNKNOWN -> Value.UNKNOWN + SUBMITTED -> Value.SUBMITTED + IN_TRANSIT -> Value.IN_TRANSIT + DELIVERED -> Value.DELIVERED + UNDELIVERABLE -> Value.UNDELIVERABLE + EXPIRED -> Value.EXPIRED + READ -> Value.READ + SILENT_STARTED -> Value.SILENT_STARTED + SILENT_VERIFIED -> Value.SILENT_VERIFIED + SILENT_MISMATCH -> Value.SILENT_MISMATCH + 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 PreludeInvalidDataException if this class instance's value is a + * not a known member. + */ + fun known(): Known = + when (this) { + UNKNOWN -> Known.UNKNOWN + SUBMITTED -> Known.SUBMITTED + IN_TRANSIT -> Known.IN_TRANSIT + DELIVERED -> Known.DELIVERED + UNDELIVERABLE -> Known.UNDELIVERABLE + EXPIRED -> Known.EXPIRED + READ -> Known.READ + SILENT_STARTED -> Known.SILENT_STARTED + SILENT_VERIFIED -> Known.SILENT_VERIFIED + SILENT_MISMATCH -> Known.SILENT_MISMATCH + else -> throw PreludeInvalidDataException("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 PreludeInvalidDataException if this class instance's value does + * not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + PreludeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws PreludeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: PreludeInvalidDataException) { + 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 DeliveryEvent && + receivedAt == other.receivedAt && + status == other.status && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(receivedAt, status, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "DeliveryEvent{receivedAt=$receivedAt, status=$status, additionalProperties=$additionalProperties}" + } + + class DeliveryStatus + @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 UNKNOWN = of("unknown") + + @JvmField val IN_TRANSIT = of("in_transit") + + @JvmField val DELIVERED = of("delivered") + + @JvmField val UNDELIVERABLE = of("undeliverable") + + @JvmField val READ = of("read") + + @JvmStatic fun of(value: String) = DeliveryStatus(JsonField.of(value)) + } + + /** An enum containing [DeliveryStatus]'s known values. */ + enum class Known { + UNKNOWN, + IN_TRANSIT, + DELIVERED, + UNDELIVERABLE, + READ, + } + + /** + * An enum containing [DeliveryStatus]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [DeliveryStatus] 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 { + UNKNOWN, + IN_TRANSIT, + DELIVERED, + UNDELIVERABLE, + READ, + /** + * An enum member indicating that [DeliveryStatus] 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) { + UNKNOWN -> Value.UNKNOWN + IN_TRANSIT -> Value.IN_TRANSIT + DELIVERED -> Value.DELIVERED + UNDELIVERABLE -> Value.UNDELIVERABLE + READ -> Value.READ + 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 PreludeInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + UNKNOWN -> Known.UNKNOWN + IN_TRANSIT -> Known.IN_TRANSIT + DELIVERED -> Known.DELIVERED + UNDELIVERABLE -> Known.UNDELIVERABLE + READ -> Known.READ + else -> + throw PreludeInvalidDataException("Unknown DeliveryStatus: $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 PreludeInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + PreludeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws PreludeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): DeliveryStatus = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: PreludeInvalidDataException) { + 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 DeliveryStatus && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Channel you asked for, when it differs from the one used. */ + class PreferredChannel + @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 SMS = of("sms") + + @JvmField val RCS = of("rcs") + + @JvmField val WHATSAPP = of("whatsapp") + + @JvmField val VIBER = of("viber") + + @JvmField val ZALO = of("zalo") + + @JvmField val TELEGRAM = of("telegram") + + @JvmField val VOICE = of("voice") + + @JvmField val SILENT = of("silent") + + @JvmStatic fun of(value: String) = PreferredChannel(JsonField.of(value)) + } + + /** An enum containing [PreferredChannel]'s known values. */ + enum class Known { + SMS, + RCS, + WHATSAPP, + VIBER, + ZALO, + TELEGRAM, + VOICE, + SILENT, + } + + /** + * An enum containing [PreferredChannel]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [PreferredChannel] 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 { + SMS, + RCS, + WHATSAPP, + VIBER, + ZALO, + TELEGRAM, + VOICE, + SILENT, + /** + * An enum member indicating that [PreferredChannel] 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) { + SMS -> Value.SMS + RCS -> Value.RCS + WHATSAPP -> Value.WHATSAPP + VIBER -> Value.VIBER + ZALO -> Value.ZALO + TELEGRAM -> Value.TELEGRAM + VOICE -> Value.VOICE + SILENT -> Value.SILENT + 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 PreludeInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + SMS -> Known.SMS + RCS -> Known.RCS + WHATSAPP -> Known.WHATSAPP + VIBER -> Known.VIBER + ZALO -> Known.ZALO + TELEGRAM -> Known.TELEGRAM + VOICE -> Known.VOICE + SILENT -> Known.SILENT + else -> + throw PreludeInvalidDataException( + "Unknown PreferredChannel: $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 PreludeInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + PreludeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws PreludeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): PreferredChannel = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: PreludeInvalidDataException) { + 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 PreferredChannel && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + 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 SUCCEEDED = of("succeeded") + + @JvmField val FAILED = of("failed") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + SUCCEEDED, + FAILED, + } + + /** + * 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 { + SUCCEEDED, + FAILED, + /** + * 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) { + SUCCEEDED -> Value.SUCCEEDED + FAILED -> Value.FAILED + 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 PreludeInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + SUCCEEDED -> Known.SUCCEEDED + FAILED -> Known.FAILED + else -> throw PreludeInvalidDataException("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 PreludeInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + PreludeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws PreludeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: PreludeInvalidDataException) { + 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() + } + + /** What caused the attempt. */ + class Trigger + @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 INITIAL = of("initial") + + @JvmField val AUTO_RETRY = of("auto_retry") + + @JvmField val USER_RETRY = of("user_retry") + + @JvmStatic fun of(value: String) = Trigger(JsonField.of(value)) + } + + /** An enum containing [Trigger]'s known values. */ + enum class Known { + INITIAL, + AUTO_RETRY, + USER_RETRY, + } + + /** + * An enum containing [Trigger]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Trigger] 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 { + INITIAL, + AUTO_RETRY, + USER_RETRY, + /** + * An enum member indicating that [Trigger] 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) { + INITIAL -> Value.INITIAL + AUTO_RETRY -> Value.AUTO_RETRY + USER_RETRY -> Value.USER_RETRY + 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 PreludeInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + INITIAL -> Known.INITIAL + AUTO_RETRY -> Known.AUTO_RETRY + USER_RETRY -> Known.USER_RETRY + else -> throw PreludeInvalidDataException("Unknown Trigger: $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 PreludeInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + PreludeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws PreludeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Trigger = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: PreludeInvalidDataException) { + 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 Trigger && 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 Attempt && + id == other.id && + createdAt == other.createdAt && + carrier == other.carrier && + channel == other.channel && + content == other.content && + cost == other.cost && + deliveryEvents == other.deliveryEvents && + deliveryStatus == other.deliveryStatus && + preferredChannel == other.preferredChannel && + status == other.status && + trigger == other.trigger && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + createdAt, + carrier, + channel, + content, + cost, + deliveryEvents, + deliveryStatus, + preferredChannel, + status, + trigger, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Attempt{id=$id, createdAt=$createdAt, carrier=$carrier, channel=$channel, content=$content, cost=$cost, deliveryEvents=$deliveryEvents, deliveryStatus=$deliveryStatus, preferredChannel=$preferredChannel, status=$status, trigger=$trigger, additionalProperties=$additionalProperties}" + } + + /** One code submission for this verification. */ + class Check + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val createdAt: JsonField, + private val isValid_: JsonField, + private val channel: JsonField, + private val psd2Info: JsonField, + private val statusDetail: JsonField, + private val value: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField = JsonMissing.of(), + @JsonProperty("is_valid") + @ExcludeMissing + isValid_: JsonField = JsonMissing.of(), + @JsonProperty("channel") + @ExcludeMissing + channel: JsonField = JsonMissing.of(), + @JsonProperty("psd2_info") + @ExcludeMissing + psd2Info: JsonField = JsonMissing.of(), + @JsonProperty("status_detail") + @ExcludeMissing + statusDetail: JsonField = JsonMissing.of(), + @JsonProperty("value") + @ExcludeMissing + value: JsonField = JsonMissing.of(), + ) : this( + createdAt, + isValid_, + channel, + psd2Info, + statusDetail, + value, + mutableMapOf(), + ) + + /** + * @throws PreludeInvalidDataException 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 createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * @throws PreludeInvalidDataException 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 isValid_(): Boolean = isValid_.getRequired("is_valid") + + /** + * @throws PreludeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun channel(): Optional = channel.getOptional("channel") + + /** + * Present on checks against a `prelude:psd2` code. + * + * @throws PreludeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun psd2Info(): Optional = psd2Info.getOptional("psd2_info") + + /** + * Why an invalid check failed, when known. + * + * @throws PreludeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun statusDetail(): Optional = + statusDetail.getOptional("status_detail") + + /** + * The submitted code. Absent while the verification can still be completed, so that + * a check in flight cannot be read back through this endpoint, and absent on silent + * verification checks, which carry no code. + * + * @throws PreludeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun value(): Optional = value.getOptional("value") + + /** + * 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 [isValid_]. + * + * Unlike [isValid_], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("is_valid") + @ExcludeMissing + fun _isValid_(): JsonField = isValid_ + + /** + * Returns the raw JSON value of [channel]. + * + * Unlike [channel], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("channel") + @ExcludeMissing + fun _channel(): JsonField = channel + + /** + * Returns the raw JSON value of [psd2Info]. + * + * Unlike [psd2Info], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("psd2_info") + @ExcludeMissing + fun _psd2Info(): JsonField = psd2Info + + /** + * Returns the raw JSON value of [statusDetail]. + * + * Unlike [statusDetail], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("status_detail") + @ExcludeMissing + fun _statusDetail(): JsonField = statusDetail + + /** + * Returns the raw JSON value of [value]. + * + * Unlike [value], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value + + @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 [Check]. + * + * The following fields are required: + * ```java + * .createdAt() + * .isValid_() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Check]. */ + class Builder internal constructor() { + + private var createdAt: JsonField? = null + private var isValid_: JsonField? = null + private var channel: JsonField = JsonMissing.of() + private var psd2Info: JsonField = JsonMissing.of() + private var statusDetail: JsonField = JsonMissing.of() + private var value: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(check: Check) = apply { + createdAt = check.createdAt + isValid_ = check.isValid_ + channel = check.channel + psd2Info = check.psd2Info + statusDetail = check.statusDetail + value = check.value + additionalProperties = check.additionalProperties.toMutableMap() + } + + 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 + } + + fun isValid_(isValid_: Boolean) = isValid_(JsonField.of(isValid_)) + + /** + * Sets [Builder.isValid_] to an arbitrary JSON value. + * + * You should usually call [Builder.isValid_] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun isValid_(isValid_: JsonField) = apply { this.isValid_ = isValid_ } + + fun channel(channel: Channel) = channel(JsonField.of(channel)) + + /** + * Sets [Builder.channel] to an arbitrary JSON value. + * + * You should usually call [Builder.channel] with a well-typed [Channel] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun channel(channel: JsonField) = apply { this.channel = channel } + + /** Present on checks against a `prelude:psd2` code. */ + fun psd2Info(psd2Info: Psd2Info) = psd2Info(JsonField.of(psd2Info)) + + /** + * Sets [Builder.psd2Info] to an arbitrary JSON value. + * + * You should usually call [Builder.psd2Info] with a well-typed [Psd2Info] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun psd2Info(psd2Info: JsonField) = apply { this.psd2Info = psd2Info } + + /** Why an invalid check failed, when known. */ + fun statusDetail(statusDetail: StatusDetail) = + statusDetail(JsonField.of(statusDetail)) + + /** + * Sets [Builder.statusDetail] to an arbitrary JSON value. + * + * You should usually call [Builder.statusDetail] with a well-typed + * [StatusDetail] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun statusDetail(statusDetail: JsonField) = apply { + this.statusDetail = statusDetail + } + + /** + * The submitted code. Absent while the verification can still be completed, so + * that a check in flight cannot be read back through this endpoint, and absent + * on silent verification checks, which carry no code. + */ + fun value(value: String) = value(JsonField.of(value)) + + /** + * Sets [Builder.value] to an arbitrary JSON value. + * + * You should usually call [Builder.value] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun value(value: JsonField) = apply { this.value = value } + + 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 [Check]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .createdAt() + * .isValid_() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Check = + Check( + checkRequired("createdAt", createdAt), + checkRequired("isValid_", isValid_), + channel, + psd2Info, + statusDetail, + value, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws PreludeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Check = apply { + if (validated) { + return@apply + } + + createdAt() + isValid_() + channel().ifPresent { it.validate() } + psd2Info().ifPresent { it.validate() } + statusDetail().ifPresent { it.validate() } + value() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: PreludeInvalidDataException) { + 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 (createdAt.asKnown().isPresent) 1 else 0) + + (if (isValid_.asKnown().isPresent) 1 else 0) + + (channel.asKnown().getOrNull()?.validity() ?: 0) + + (psd2Info.asKnown().getOrNull()?.validity() ?: 0) + + (statusDetail.asKnown().getOrNull()?.validity() ?: 0) + + (if (value.asKnown().isPresent) 1 else 0) + + class Channel + @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 SMS = of("sms") + + @JvmField val RCS = of("rcs") + + @JvmField val WHATSAPP = of("whatsapp") + + @JvmField val VIBER = of("viber") + + @JvmField val ZALO = of("zalo") + + @JvmField val TELEGRAM = of("telegram") + + @JvmField val VOICE = of("voice") + + @JvmField val SILENT = of("silent") + + @JvmStatic fun of(value: String) = Channel(JsonField.of(value)) + } + + /** An enum containing [Channel]'s known values. */ + enum class Known { + SMS, + RCS, + WHATSAPP, + VIBER, + ZALO, + TELEGRAM, + VOICE, + SILENT, + } + + /** + * An enum containing [Channel]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Channel] 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 { + SMS, + RCS, + WHATSAPP, + VIBER, + ZALO, + TELEGRAM, + VOICE, + SILENT, + /** + * An enum member indicating that [Channel] 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) { + SMS -> Value.SMS + RCS -> Value.RCS + WHATSAPP -> Value.WHATSAPP + VIBER -> Value.VIBER + ZALO -> Value.ZALO + TELEGRAM -> Value.TELEGRAM + VOICE -> Value.VOICE + SILENT -> Value.SILENT + 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 PreludeInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + SMS -> Known.SMS + RCS -> Known.RCS + WHATSAPP -> Known.WHATSAPP + VIBER -> Known.VIBER + ZALO -> Known.ZALO + TELEGRAM -> Known.TELEGRAM + VOICE -> Known.VOICE + SILENT -> Known.SILENT + else -> throw PreludeInvalidDataException("Unknown Channel: $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 PreludeInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + PreludeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws PreludeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Channel = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: PreludeInvalidDataException) { + 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 Channel && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Present on checks against a `prelude:psd2` code. */ + class Psd2Info + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val expectedTransaction: JsonField, + private val receivedTransaction: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("expected_transaction") + @ExcludeMissing + expectedTransaction: JsonField = + JsonMissing.of(), + @JsonProperty("received_transaction") + @ExcludeMissing + receivedTransaction: JsonField = + JsonMissing.of(), + ) : this(expectedTransaction, receivedTransaction, mutableMapOf()) + + /** + * The transaction submitted when the code was issued. + * + * @throws PreludeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun expectedTransaction(): Optional = + expectedTransaction.getOptional("expected_transaction") + + /** + * The transaction submitted with this check. Differs from + * `expected_transaction` when `status_detail` is `transaction_mismatch`. + * + * @throws PreludeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun receivedTransaction(): Optional = + receivedTransaction.getOptional("received_transaction") + + /** + * Returns the raw JSON value of [expectedTransaction]. + * + * Unlike [expectedTransaction], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("expected_transaction") + @ExcludeMissing + fun _expectedTransaction(): JsonField = + expectedTransaction + + /** + * Returns the raw JSON value of [receivedTransaction]. + * + * Unlike [receivedTransaction], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("received_transaction") + @ExcludeMissing + fun _receivedTransaction(): JsonField = + receivedTransaction + + @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 [Psd2Info]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Psd2Info]. */ + class Builder internal constructor() { + + private var expectedTransaction: + JsonField = + JsonMissing.of() + private var receivedTransaction: + JsonField = + JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(psd2Info: Psd2Info) = apply { + expectedTransaction = psd2Info.expectedTransaction + receivedTransaction = psd2Info.receivedTransaction + additionalProperties = psd2Info.additionalProperties.toMutableMap() + } + + /** The transaction submitted when the code was issued. */ + fun expectedTransaction( + expectedTransaction: PhoneVerificationPsd2Transaction + ) = expectedTransaction(JsonField.of(expectedTransaction)) + + /** + * Sets [Builder.expectedTransaction] to an arbitrary JSON value. + * + * You should usually call [Builder.expectedTransaction] with a well-typed + * [PhoneVerificationPsd2Transaction] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun expectedTransaction( + expectedTransaction: JsonField + ) = apply { this.expectedTransaction = expectedTransaction } + + /** + * The transaction submitted with this check. Differs from + * `expected_transaction` when `status_detail` is `transaction_mismatch`. + */ + fun receivedTransaction( + receivedTransaction: PhoneVerificationPsd2Transaction + ) = receivedTransaction(JsonField.of(receivedTransaction)) + + /** + * Sets [Builder.receivedTransaction] to an arbitrary JSON value. + * + * You should usually call [Builder.receivedTransaction] with a well-typed + * [PhoneVerificationPsd2Transaction] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun receivedTransaction( + receivedTransaction: JsonField + ) = apply { this.receivedTransaction = receivedTransaction } + + 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 [Psd2Info]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Psd2Info = + Psd2Info( + expectedTransaction, + receivedTransaction, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws PreludeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Psd2Info = apply { + if (validated) { + return@apply + } + + expectedTransaction().ifPresent { it.validate() } + receivedTransaction().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: PreludeInvalidDataException) { + 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 = + (expectedTransaction.asKnown().getOrNull()?.validity() ?: 0) + + (receivedTransaction.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Psd2Info && + expectedTransaction == other.expectedTransaction && + receivedTransaction == other.receivedTransaction && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(expectedTransaction, receivedTransaction, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Psd2Info{expectedTransaction=$expectedTransaction, receivedTransaction=$receivedTransaction, additionalProperties=$additionalProperties}" + } + + /** Why an invalid check failed, when known. */ + class StatusDetail + @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 EXPIRED_ATTEMPT = of("expired_attempt") + + @JvmField val EXPIRED_AUTH = of("expired_auth") + + @JvmField val RATE_LIMITED = of("rate_limited") + + @JvmField val TRANSACTION_MISSING = of("transaction_missing") + + @JvmField val TRANSACTION_MISMATCH = of("transaction_mismatch") + + @JvmStatic fun of(value: String) = StatusDetail(JsonField.of(value)) + } + + /** An enum containing [StatusDetail]'s known values. */ + enum class Known { + EXPIRED_ATTEMPT, + EXPIRED_AUTH, + RATE_LIMITED, + TRANSACTION_MISSING, + TRANSACTION_MISMATCH, + } + + /** + * An enum containing [StatusDetail]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [StatusDetail] 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 { + EXPIRED_ATTEMPT, + EXPIRED_AUTH, + RATE_LIMITED, + TRANSACTION_MISSING, + TRANSACTION_MISMATCH, + /** + * An enum member indicating that [StatusDetail] 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) { + EXPIRED_ATTEMPT -> Value.EXPIRED_ATTEMPT + EXPIRED_AUTH -> Value.EXPIRED_AUTH + RATE_LIMITED -> Value.RATE_LIMITED + TRANSACTION_MISSING -> Value.TRANSACTION_MISSING + TRANSACTION_MISMATCH -> Value.TRANSACTION_MISMATCH + 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 PreludeInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + EXPIRED_ATTEMPT -> Known.EXPIRED_ATTEMPT + EXPIRED_AUTH -> Known.EXPIRED_AUTH + RATE_LIMITED -> Known.RATE_LIMITED + TRANSACTION_MISSING -> Known.TRANSACTION_MISSING + TRANSACTION_MISMATCH -> Known.TRANSACTION_MISMATCH + else -> + throw PreludeInvalidDataException("Unknown StatusDetail: $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 PreludeInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + PreludeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws PreludeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): StatusDetail = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: PreludeInvalidDataException) { + 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 StatusDetail && 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 Check && + createdAt == other.createdAt && + isValid_ == other.isValid_ && + channel == other.channel && + psd2Info == other.psd2Info && + statusDetail == other.statusDetail && + value == other.value && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + createdAt, + isValid_, + channel, + psd2Info, + statusDetail, + value, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Check{createdAt=$createdAt, isValid_=$isValid_, channel=$channel, psd2Info=$psd2Info, statusDetail=$statusDetail, value=$value, additionalProperties=$additionalProperties}" + } + + class Create + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val createdAt: JsonField, + private val cost: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField = JsonMissing.of(), + @JsonProperty("cost") + @ExcludeMissing + cost: JsonField = JsonMissing.of(), + ) : this(createdAt, cost, mutableMapOf()) + + /** + * @throws PreludeInvalidDataException 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 createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * @throws PreludeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun cost(): Optional = cost.getOptional("cost") + + /** + * 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 [cost]. + * + * Unlike [cost], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cost") + @ExcludeMissing + fun _cost(): JsonField = cost + + @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 [Create]. + * + * The following fields are required: + * ```java + * .createdAt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Create]. */ + class Builder internal constructor() { + + private var createdAt: JsonField? = null + private var cost: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(create: Create) = apply { + createdAt = create.createdAt + cost = create.cost + additionalProperties = create.additionalProperties.toMutableMap() + } + + 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 + } + + fun cost(cost: PhoneVerificationMoney) = cost(JsonField.of(cost)) + + /** + * Sets [Builder.cost] to an arbitrary JSON value. + * + * You should usually call [Builder.cost] with a well-typed + * [PhoneVerificationMoney] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun cost(cost: JsonField) = apply { this.cost = cost } + + 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 [Create]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .createdAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Create = + Create( + checkRequired("createdAt", createdAt), + cost, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws PreludeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Create = apply { + if (validated) { + return@apply + } + + createdAt() + cost().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: PreludeInvalidDataException) { + 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 (createdAt.asKnown().isPresent) 1 else 0) + + (cost.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Create && + createdAt == other.createdAt && + cost == other.cost && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(createdAt, cost, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Create{createdAt=$createdAt, cost=$cost, additionalProperties=$additionalProperties}" + } + + class Signals + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val receivedAt: JsonField, + private val expiredAt: JsonField, + private val status: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("received_at") + @ExcludeMissing + receivedAt: JsonField = JsonMissing.of(), + @JsonProperty("expired_at") + @ExcludeMissing + expiredAt: JsonField = JsonMissing.of(), + @JsonProperty("status") + @ExcludeMissing + status: JsonField = JsonMissing.of(), + ) : this(receivedAt, expiredAt, status, mutableMapOf()) + + /** + * @throws PreludeInvalidDataException 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 receivedAt(): OffsetDateTime = receivedAt.getRequired("received_at") + + /** + * @throws PreludeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun expiredAt(): Optional = expiredAt.getOptional("expired_at") + + /** + * @throws PreludeInvalidDataException 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 [receivedAt]. + * + * Unlike [receivedAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("received_at") + @ExcludeMissing + fun _receivedAt(): JsonField = receivedAt + + /** + * Returns the raw JSON value of [expiredAt]. + * + * Unlike [expiredAt], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("expired_at") + @ExcludeMissing + fun _expiredAt(): JsonField = expiredAt + + /** + * 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 [Signals]. + * + * The following fields are required: + * ```java + * .receivedAt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Signals]. */ + class Builder internal constructor() { + + private var receivedAt: JsonField? = null + private var expiredAt: JsonField = JsonMissing.of() + private var status: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(signals: Signals) = apply { + receivedAt = signals.receivedAt + expiredAt = signals.expiredAt + status = signals.status + additionalProperties = signals.additionalProperties.toMutableMap() + } + + fun receivedAt(receivedAt: OffsetDateTime) = + receivedAt(JsonField.of(receivedAt)) + + /** + * Sets [Builder.receivedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.receivedAt] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun receivedAt(receivedAt: JsonField) = apply { + this.receivedAt = receivedAt + } + + fun expiredAt(expiredAt: OffsetDateTime) = expiredAt(JsonField.of(expiredAt)) + + /** + * Sets [Builder.expiredAt] to an arbitrary JSON value. + * + * You should usually call [Builder.expiredAt] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun expiredAt(expiredAt: JsonField) = apply { + this.expiredAt = expiredAt + } + + 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 } + + 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 [Signals]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .receivedAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Signals = + Signals( + checkRequired("receivedAt", receivedAt), + expiredAt, + status, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws PreludeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Signals = apply { + if (validated) { + return@apply + } + + receivedAt() + expiredAt() + status().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: PreludeInvalidDataException) { + 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 (receivedAt.asKnown().isPresent) 1 else 0) + + (if (expiredAt.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + 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 VALID = of("valid") + + @JvmField val INVALID = of("invalid") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + VALID, + INVALID, + } + + /** + * 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 { + VALID, + INVALID, + /** + * 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) { + VALID -> Value.VALID + INVALID -> Value.INVALID + 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 PreludeInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + VALID -> Known.VALID + INVALID -> Known.INVALID + else -> throw PreludeInvalidDataException("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 PreludeInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + PreludeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws PreludeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: PreludeInvalidDataException) { + 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 Signals && + receivedAt == other.receivedAt && + expiredAt == other.expiredAt && + status == other.status && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(receivedAt, expiredAt, status, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Signals{receivedAt=$receivedAt, expiredAt=$expiredAt, status=$status, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Event && + type == other.type && + attempt == other.attempt && + check == other.check && + create == other.create && + signals == other.signals && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(type, attempt, check, create, signals, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Event{type=$type, attempt=$attempt, check=$check, create=$create, signals=$signals, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Lifecycle && + events == other.events && + totalCost == other.totalCost && + undeliverableRouteCount == other.undeliverableRouteCount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(events, totalCost, undeliverableRouteCount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Lifecycle{events=$events, totalCost=$totalCost, undeliverableRouteCount=$undeliverableRouteCount, additionalProperties=$additionalProperties}" + } + + /** + * Whether the phone number was allow-listed, block-listed, or sandboxed at verification time. + */ + class PhoneNumberCondition + @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 ALLOW_LISTED = of("allow_listed") + + @JvmField val BLOCK_LISTED = of("block_listed") + + @JvmField val SANDBOXED = of("sandboxed") + + @JvmStatic fun of(value: String) = PhoneNumberCondition(JsonField.of(value)) + } + + /** An enum containing [PhoneNumberCondition]'s known values. */ + enum class Known { + ALLOW_LISTED, + BLOCK_LISTED, + SANDBOXED, + } + + /** + * An enum containing [PhoneNumberCondition]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [PhoneNumberCondition] 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 { + ALLOW_LISTED, + BLOCK_LISTED, + SANDBOXED, + /** + * An enum member indicating that [PhoneNumberCondition] 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) { + ALLOW_LISTED -> Value.ALLOW_LISTED + BLOCK_LISTED -> Value.BLOCK_LISTED + SANDBOXED -> Value.SANDBOXED + 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 PreludeInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ALLOW_LISTED -> Known.ALLOW_LISTED + BLOCK_LISTED -> Known.BLOCK_LISTED + SANDBOXED -> Known.SANDBOXED + else -> throw PreludeInvalidDataException("Unknown PhoneNumberCondition: $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 PreludeInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { PreludeInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws PreludeInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): PhoneNumberCondition = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: PreludeInvalidDataException) { + 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 PhoneNumberCondition && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Whether the phone number is currently allow-listed, block-listed, or sandboxed. */ + class PhoneNumberCurrentCondition + @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 ALLOW_LISTED = of("allow_listed") + + @JvmField val BLOCK_LISTED = of("block_listed") + + @JvmField val SANDBOXED = of("sandboxed") + + @JvmStatic fun of(value: String) = PhoneNumberCurrentCondition(JsonField.of(value)) + } + + /** An enum containing [PhoneNumberCurrentCondition]'s known values. */ + enum class Known { + ALLOW_LISTED, + BLOCK_LISTED, + SANDBOXED, + } + + /** + * An enum containing [PhoneNumberCurrentCondition]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [PhoneNumberCurrentCondition] 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 { + ALLOW_LISTED, + BLOCK_LISTED, + SANDBOXED, + /** + * An enum member indicating that [PhoneNumberCurrentCondition] 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) { + ALLOW_LISTED -> Value.ALLOW_LISTED + BLOCK_LISTED -> Value.BLOCK_LISTED + SANDBOXED -> Value.SANDBOXED + 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 PreludeInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ALLOW_LISTED -> Known.ALLOW_LISTED + BLOCK_LISTED -> Known.BLOCK_LISTED + SANDBOXED -> Known.SANDBOXED + else -> + throw PreludeInvalidDataException("Unknown PhoneNumberCurrentCondition: $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 PreludeInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { PreludeInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws PreludeInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): PhoneNumberCurrentCondition = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: PreludeInvalidDataException) { + 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 PhoneNumberCurrentCondition && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** The anti-fraud signals you forwarded when creating the verification. */ + class Signals + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val isTrustedUser: JsonField, + private val deviceId: JsonField, + private val ja4Fingerprint: JsonField, + private val osVersion: JsonField, + private val userAgent: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("is_trusted_user") + @ExcludeMissing + isTrustedUser: JsonField = JsonMissing.of(), + @JsonProperty("device_id") + @ExcludeMissing + deviceId: JsonField = JsonMissing.of(), + @JsonProperty("ja4_fingerprint") + @ExcludeMissing + ja4Fingerprint: JsonField = JsonMissing.of(), + @JsonProperty("os_version") + @ExcludeMissing + osVersion: JsonField = JsonMissing.of(), + @JsonProperty("user_agent") + @ExcludeMissing + userAgent: JsonField = JsonMissing.of(), + ) : this(isTrustedUser, deviceId, ja4Fingerprint, osVersion, userAgent, mutableMapOf()) + + /** + * Whether you flagged this end user as trusted when creating the verification. Declared by + * you, not computed by Prelude. + * + * @throws PreludeInvalidDataException 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 isTrustedUser(): Boolean = isTrustedUser.getRequired("is_trusted_user") + + /** + * End-user device identifier you forwarded. + * + * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun deviceId(): Optional = deviceId.getOptional("device_id") + + /** + * TLS fingerprint you forwarded. + * + * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun ja4Fingerprint(): Optional = ja4Fingerprint.getOptional("ja4_fingerprint") + + /** + * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun osVersion(): Optional = osVersion.getOptional("os_version") + + /** + * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun userAgent(): Optional = userAgent.getOptional("user_agent") + + /** + * Returns the raw JSON value of [isTrustedUser]. + * + * Unlike [isTrustedUser], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("is_trusted_user") + @ExcludeMissing + fun _isTrustedUser(): JsonField = isTrustedUser + + /** + * Returns the raw JSON value of [deviceId]. + * + * Unlike [deviceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("device_id") @ExcludeMissing fun _deviceId(): JsonField = deviceId + + /** + * Returns the raw JSON value of [ja4Fingerprint]. + * + * Unlike [ja4Fingerprint], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("ja4_fingerprint") + @ExcludeMissing + fun _ja4Fingerprint(): JsonField = ja4Fingerprint + + /** + * Returns the raw JSON value of [osVersion]. + * + * Unlike [osVersion], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("os_version") @ExcludeMissing fun _osVersion(): JsonField = osVersion + + /** + * Returns the raw JSON value of [userAgent]. + * + * Unlike [userAgent], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("user_agent") @ExcludeMissing fun _userAgent(): JsonField = userAgent + + @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 [Signals]. + * + * The following fields are required: + * ```java + * .isTrustedUser() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Signals]. */ + class Builder internal constructor() { + + private var isTrustedUser: JsonField? = null + private var deviceId: JsonField = JsonMissing.of() + private var ja4Fingerprint: JsonField = JsonMissing.of() + private var osVersion: JsonField = JsonMissing.of() + private var userAgent: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(signals: Signals) = apply { + isTrustedUser = signals.isTrustedUser + deviceId = signals.deviceId + ja4Fingerprint = signals.ja4Fingerprint + osVersion = signals.osVersion + userAgent = signals.userAgent + additionalProperties = signals.additionalProperties.toMutableMap() + } + + /** + * Whether you flagged this end user as trusted when creating the verification. Declared + * by you, not computed by Prelude. + */ + fun isTrustedUser(isTrustedUser: Boolean) = isTrustedUser(JsonField.of(isTrustedUser)) + + /** + * Sets [Builder.isTrustedUser] to an arbitrary JSON value. + * + * You should usually call [Builder.isTrustedUser] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun isTrustedUser(isTrustedUser: JsonField) = apply { + this.isTrustedUser = isTrustedUser + } + + /** End-user device identifier you forwarded. */ + fun deviceId(deviceId: String) = deviceId(JsonField.of(deviceId)) + + /** + * Sets [Builder.deviceId] to an arbitrary JSON value. + * + * You should usually call [Builder.deviceId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun deviceId(deviceId: JsonField) = apply { this.deviceId = deviceId } + + /** TLS fingerprint you forwarded. */ + fun ja4Fingerprint(ja4Fingerprint: String) = + ja4Fingerprint(JsonField.of(ja4Fingerprint)) + + /** + * Sets [Builder.ja4Fingerprint] to an arbitrary JSON value. + * + * You should usually call [Builder.ja4Fingerprint] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun ja4Fingerprint(ja4Fingerprint: JsonField) = apply { + this.ja4Fingerprint = ja4Fingerprint + } + + fun osVersion(osVersion: String) = osVersion(JsonField.of(osVersion)) + + /** + * Sets [Builder.osVersion] to an arbitrary JSON value. + * + * You should usually call [Builder.osVersion] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun osVersion(osVersion: JsonField) = apply { this.osVersion = osVersion } + + fun userAgent(userAgent: String) = userAgent(JsonField.of(userAgent)) + + /** + * Sets [Builder.userAgent] to an arbitrary JSON value. + * + * You should usually call [Builder.userAgent] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun userAgent(userAgent: JsonField) = apply { this.userAgent = userAgent } + + 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 [Signals]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .isTrustedUser() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Signals = + Signals( + checkRequired("isTrustedUser", isTrustedUser), + deviceId, + ja4Fingerprint, + osVersion, + userAgent, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws PreludeInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Signals = apply { + if (validated) { + return@apply + } + + isTrustedUser() + deviceId() + ja4Fingerprint() + osVersion() + userAgent() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: PreludeInvalidDataException) { + 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 (isTrustedUser.asKnown().isPresent) 1 else 0) + + (if (deviceId.asKnown().isPresent) 1 else 0) + + (if (ja4Fingerprint.asKnown().isPresent) 1 else 0) + + (if (osVersion.asKnown().isPresent) 1 else 0) + + (if (userAgent.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Signals && + isTrustedUser == other.isTrustedUser && + deviceId == other.deviceId && + ja4Fingerprint == other.ja4Fingerprint && + osVersion == other.osVersion && + userAgent == other.userAgent && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + isTrustedUser, + deviceId, + ja4Fingerprint, + osVersion, + userAgent, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Signals{isTrustedUser=$isTrustedUser, deviceId=$deviceId, ja4Fingerprint=$ja4Fingerprint, osVersion=$osVersion, userAgent=$userAgent, additionalProperties=$additionalProperties}" + } + + /** Whether the SDK signals integrity check passed. */ + class SignalsHashStatus @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 VALID = of("valid") + + @JvmField val INVALID = of("invalid") + + @JvmStatic fun of(value: String) = SignalsHashStatus(JsonField.of(value)) + } + + /** An enum containing [SignalsHashStatus]'s known values. */ + enum class Known { + VALID, + INVALID, + } + + /** + * An enum containing [SignalsHashStatus]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [SignalsHashStatus] 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 { + VALID, + INVALID, + /** + * An enum member indicating that [SignalsHashStatus] 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) { + VALID -> Value.VALID + INVALID -> Value.INVALID + 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 PreludeInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + VALID -> Known.VALID + INVALID -> Known.INVALID + else -> throw PreludeInvalidDataException("Unknown SignalsHashStatus: $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 PreludeInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { PreludeInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws PreludeInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): SignalsHashStatus = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: PreludeInvalidDataException) { + 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 SignalsHashStatus && 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 VerificationPhoneHistoryRetrieveResponse && + id == other.id && + createdAt == other.createdAt && + expiresAt == other.expiresAt && + phoneNumber == other.phoneNumber && + status == other.status && + appVersion == other.appVersion && + blockReasons == other.blockReasons && + carrier == other.carrier && + correlationId == other.correlationId && + deviceModel == other.deviceModel && + devicePlatform == other.devicePlatform && + ipAddress == other.ipAddress && + ipAddressRegion == other.ipAddressRegion && + ipDistanceMeters == other.ipDistanceMeters && + lifecycle == other.lifecycle && + phoneNumberCondition == other.phoneNumberCondition && + phoneNumberCurrentCondition == other.phoneNumberCurrentCondition && + phoneNumberRegion == other.phoneNumberRegion && + signals == other.signals && + signalsHashStatus == other.signalsHashStatus && + templateId == other.templateId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + createdAt, + expiresAt, + phoneNumber, + status, + appVersion, + blockReasons, + carrier, + correlationId, + deviceModel, + devicePlatform, + ipAddress, + ipAddressRegion, + ipDistanceMeters, + lifecycle, + phoneNumberCondition, + phoneNumberCurrentCondition, + phoneNumberRegion, + signals, + signalsHashStatus, + templateId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "VerificationPhoneHistoryRetrieveResponse{id=$id, createdAt=$createdAt, expiresAt=$expiresAt, phoneNumber=$phoneNumber, status=$status, appVersion=$appVersion, blockReasons=$blockReasons, carrier=$carrier, correlationId=$correlationId, deviceModel=$deviceModel, devicePlatform=$devicePlatform, ipAddress=$ipAddress, ipAddressRegion=$ipAddressRegion, ipDistanceMeters=$ipDistanceMeters, lifecycle=$lifecycle, phoneNumberCondition=$phoneNumberCondition, phoneNumberCurrentCondition=$phoneNumberCurrentCondition, phoneNumberRegion=$phoneNumberRegion, signals=$signals, signalsHashStatus=$signalsHashStatus, templateId=$templateId, additionalProperties=$additionalProperties}" +} diff --git a/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/WatchEvaluateParams.kt b/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/WatchEvaluateParams.kt new file mode 100644 index 00000000..b6cbb0ab --- /dev/null +++ b/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/WatchEvaluateParams.kt @@ -0,0 +1,880 @@ +// File generated from our OpenAPI spec by Stainless. + +package so.prelude.sdk.models + +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 +import so.prelude.sdk.core.ExcludeMissing +import so.prelude.sdk.core.JsonField +import so.prelude.sdk.core.JsonMissing +import so.prelude.sdk.core.JsonValue +import so.prelude.sdk.core.Params +import so.prelude.sdk.core.checkRequired +import so.prelude.sdk.core.http.Headers +import so.prelude.sdk.core.http.QueryParams +import so.prelude.sdk.core.toImmutable +import so.prelude.sdk.errors.PreludeInvalidDataException + +/** + * **Beta.** The request and response shapes may still change, and flows and recipes are configured + * by Prelude on your behalf for now. Talk to us before you build against it. + * + * Score a target against the rules configured for one moment in your product — signup, checkout, + * password reset. The flow selects which recipes run; each recipe scores its rules against a + * threshold and returns its own verdict, and the evaluation answers with the most severe verdict + * and action across them. Where Predict returns a single model-derived outcome, Eval returns the + * full breakdown, so you can see which rules fired and which could not run. Scoring-only — it does + * not update counters by itself. + */ +class WatchEvaluateParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * The flow to evaluate. A flow names the moment you are guarding and selects the recipes that + * run. + * + * @throws PreludeInvalidDataException 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 flowId(): String = body.flowId() + + /** + * The identifier to score — a phone number or email address. + * + * @throws PreludeInvalidDataException 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 target(): Target = body.target() + + /** + * Values for the attributes the flow's recipes declare, keyed without the `attr.` namespace a + * rule uses to reference them. + * + * An attribute a recipe declares and this request omits is treated as missing evidence, not as + * an empty value: the rules reading it report `NOT_EVALUATED` rather than being scored as + * though the condition were false. A key no recipe in the flow declares is ignored rather than + * rejected, so one payload can serve flows that read different attributes. + * + * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun attributes(): Optional = body.attributes() + + /** + * The identifier of the dispatch that came from the front-end SDK. Signals it carries fill in + * anything the request did not state; the request wins where both supply a value. + * + * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun dispatchId(): Optional = body.dispatchId() + + /** + * The signals used for anti-fraud. For more details, refer to + * [Signals](/verify/v2/documentation/prevent-fraud#signals). + * + * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun signals(): Optional = body.signals() + + /** + * Returns the raw JSON value of [flowId]. + * + * Unlike [flowId], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _flowId(): JsonField = body._flowId() + + /** + * Returns the raw JSON value of [target]. + * + * Unlike [target], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _target(): JsonField = body._target() + + /** + * Returns the raw JSON value of [attributes]. + * + * Unlike [attributes], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _attributes(): JsonField = body._attributes() + + /** + * Returns the raw JSON value of [dispatchId]. + * + * Unlike [dispatchId], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _dispatchId(): JsonField = body._dispatchId() + + /** + * Returns the raw JSON value of [signals]. + * + * Unlike [signals], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _signals(): JsonField = body._signals() + + 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 [WatchEvaluateParams]. + * + * The following fields are required: + * ```java + * .flowId() + * .target() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [WatchEvaluateParams]. */ + 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(watchEvaluateParams: WatchEvaluateParams) = apply { + body = watchEvaluateParams.body.toBuilder() + additionalHeaders = watchEvaluateParams.additionalHeaders.toBuilder() + additionalQueryParams = watchEvaluateParams.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: + * - [flowId] + * - [target] + * - [attributes] + * - [dispatchId] + * - [signals] + * - etc. + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** + * The flow to evaluate. A flow names the moment you are guarding and selects the recipes + * that run. + */ + fun flowId(flowId: String) = apply { body.flowId(flowId) } + + /** + * Sets [Builder.flowId] to an arbitrary JSON value. + * + * You should usually call [Builder.flowId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun flowId(flowId: JsonField) = apply { body.flowId(flowId) } + + /** The identifier to score — a phone number or email address. */ + fun target(target: Target) = apply { body.target(target) } + + /** + * Sets [Builder.target] to an arbitrary JSON value. + * + * You should usually call [Builder.target] with a well-typed [Target] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun target(target: JsonField) = apply { body.target(target) } + + /** + * Values for the attributes the flow's recipes declare, keyed without the `attr.` namespace + * a rule uses to reference them. + * + * An attribute a recipe declares and this request omits is treated as missing evidence, not + * as an empty value: the rules reading it report `NOT_EVALUATED` rather than being scored + * as though the condition were false. A key no recipe in the flow declares is ignored + * rather than rejected, so one payload can serve flows that read different attributes. + */ + fun attributes(attributes: Attributes) = apply { body.attributes(attributes) } + + /** + * Sets [Builder.attributes] to an arbitrary JSON value. + * + * You should usually call [Builder.attributes] with a well-typed [Attributes] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun attributes(attributes: JsonField) = apply { body.attributes(attributes) } + + /** + * The identifier of the dispatch that came from the front-end SDK. Signals it carries fill + * in anything the request did not state; the request wins where both supply a value. + */ + fun dispatchId(dispatchId: String) = apply { body.dispatchId(dispatchId) } + + /** + * Sets [Builder.dispatchId] to an arbitrary JSON value. + * + * You should usually call [Builder.dispatchId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dispatchId(dispatchId: JsonField) = apply { body.dispatchId(dispatchId) } + + /** + * The signals used for anti-fraud. For more details, refer to + * [Signals](/verify/v2/documentation/prevent-fraud#signals). + */ + fun signals(signals: Signals) = apply { body.signals(signals) } + + /** + * Sets [Builder.signals] to an arbitrary JSON value. + * + * You should usually call [Builder.signals] with a well-typed [Signals] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun signals(signals: JsonField) = apply { body.signals(signals) } + + 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 [WatchEvaluateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .flowId() + * .target() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): WatchEvaluateParams = + WatchEvaluateParams( + 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 flowId: JsonField, + private val target: JsonField, + private val attributes: JsonField, + private val dispatchId: JsonField, + private val signals: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("flow_id") @ExcludeMissing flowId: JsonField = JsonMissing.of(), + @JsonProperty("target") @ExcludeMissing target: JsonField = JsonMissing.of(), + @JsonProperty("attributes") + @ExcludeMissing + attributes: JsonField = JsonMissing.of(), + @JsonProperty("dispatch_id") + @ExcludeMissing + dispatchId: JsonField = JsonMissing.of(), + @JsonProperty("signals") @ExcludeMissing signals: JsonField = JsonMissing.of(), + ) : this(flowId, target, attributes, dispatchId, signals, mutableMapOf()) + + /** + * The flow to evaluate. A flow names the moment you are guarding and selects the recipes + * that run. + * + * @throws PreludeInvalidDataException 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 flowId(): String = flowId.getRequired("flow_id") + + /** + * The identifier to score — a phone number or email address. + * + * @throws PreludeInvalidDataException 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 target(): Target = target.getRequired("target") + + /** + * Values for the attributes the flow's recipes declare, keyed without the `attr.` namespace + * a rule uses to reference them. + * + * An attribute a recipe declares and this request omits is treated as missing evidence, not + * as an empty value: the rules reading it report `NOT_EVALUATED` rather than being scored + * as though the condition were false. A key no recipe in the flow declares is ignored + * rather than rejected, so one payload can serve flows that read different attributes. + * + * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun attributes(): Optional = attributes.getOptional("attributes") + + /** + * The identifier of the dispatch that came from the front-end SDK. Signals it carries fill + * in anything the request did not state; the request wins where both supply a value. + * + * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun dispatchId(): Optional = dispatchId.getOptional("dispatch_id") + + /** + * The signals used for anti-fraud. For more details, refer to + * [Signals](/verify/v2/documentation/prevent-fraud#signals). + * + * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun signals(): Optional = signals.getOptional("signals") + + /** + * Returns the raw JSON value of [flowId]. + * + * Unlike [flowId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("flow_id") @ExcludeMissing fun _flowId(): JsonField = flowId + + /** + * Returns the raw JSON value of [target]. + * + * Unlike [target], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("target") @ExcludeMissing fun _target(): JsonField = target + + /** + * Returns the raw JSON value of [attributes]. + * + * Unlike [attributes], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("attributes") + @ExcludeMissing + fun _attributes(): JsonField = attributes + + /** + * Returns the raw JSON value of [dispatchId]. + * + * Unlike [dispatchId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dispatch_id") + @ExcludeMissing + fun _dispatchId(): JsonField = dispatchId + + /** + * Returns the raw JSON value of [signals]. + * + * Unlike [signals], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("signals") @ExcludeMissing fun _signals(): JsonField = signals + + @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 + * .flowId() + * .target() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var flowId: JsonField? = null + private var target: JsonField? = null + private var attributes: JsonField = JsonMissing.of() + private var dispatchId: JsonField = JsonMissing.of() + private var signals: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + flowId = body.flowId + target = body.target + attributes = body.attributes + dispatchId = body.dispatchId + signals = body.signals + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** + * The flow to evaluate. A flow names the moment you are guarding and selects the + * recipes that run. + */ + fun flowId(flowId: String) = flowId(JsonField.of(flowId)) + + /** + * Sets [Builder.flowId] to an arbitrary JSON value. + * + * You should usually call [Builder.flowId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun flowId(flowId: JsonField) = apply { this.flowId = flowId } + + /** The identifier to score — a phone number or email address. */ + fun target(target: Target) = target(JsonField.of(target)) + + /** + * Sets [Builder.target] to an arbitrary JSON value. + * + * You should usually call [Builder.target] with a well-typed [Target] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun target(target: JsonField) = apply { this.target = target } + + /** + * Values for the attributes the flow's recipes declare, keyed without the `attr.` + * namespace a rule uses to reference them. + * + * An attribute a recipe declares and this request omits is treated as missing evidence, + * not as an empty value: the rules reading it report `NOT_EVALUATED` rather than being + * scored as though the condition were false. A key no recipe in the flow declares is + * ignored rather than rejected, so one payload can serve flows that read different + * attributes. + */ + fun attributes(attributes: Attributes) = attributes(JsonField.of(attributes)) + + /** + * Sets [Builder.attributes] to an arbitrary JSON value. + * + * You should usually call [Builder.attributes] with a well-typed [Attributes] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun attributes(attributes: JsonField) = apply { + this.attributes = attributes + } + + /** + * The identifier of the dispatch that came from the front-end SDK. Signals it carries + * fill in anything the request did not state; the request wins where both supply a + * value. + */ + fun dispatchId(dispatchId: String) = dispatchId(JsonField.of(dispatchId)) + + /** + * Sets [Builder.dispatchId] to an arbitrary JSON value. + * + * You should usually call [Builder.dispatchId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun dispatchId(dispatchId: JsonField) = apply { this.dispatchId = dispatchId } + + /** + * The signals used for anti-fraud. For more details, refer to + * [Signals](/verify/v2/documentation/prevent-fraud#signals). + */ + fun signals(signals: Signals) = signals(JsonField.of(signals)) + + /** + * Sets [Builder.signals] to an arbitrary JSON value. + * + * You should usually call [Builder.signals] with a well-typed [Signals] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun signals(signals: JsonField) = apply { this.signals = signals } + + 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 + * .flowId() + * .target() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("flowId", flowId), + checkRequired("target", target), + attributes, + dispatchId, + signals, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws PreludeInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Body = apply { + if (validated) { + return@apply + } + + flowId() + target().validate() + attributes().ifPresent { it.validate() } + dispatchId() + signals().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: PreludeInvalidDataException) { + 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 (flowId.asKnown().isPresent) 1 else 0) + + (target.asKnown().getOrNull()?.validity() ?: 0) + + (attributes.asKnown().getOrNull()?.validity() ?: 0) + + (if (dispatchId.asKnown().isPresent) 1 else 0) + + (signals.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + flowId == other.flowId && + target == other.target && + attributes == other.attributes && + dispatchId == other.dispatchId && + signals == other.signals && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(flowId, target, attributes, dispatchId, signals, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{flowId=$flowId, target=$target, attributes=$attributes, dispatchId=$dispatchId, signals=$signals, additionalProperties=$additionalProperties}" + } + + /** + * Values for the attributes the flow's recipes declare, keyed without the `attr.` namespace a + * rule uses to reference them. + * + * An attribute a recipe declares and this request omits is treated as missing evidence, not as + * an empty value: the rules reading it report `NOT_EVALUATED` rather than being scored as + * though the condition were false. A key no recipe in the flow declares is ignored rather than + * rejected, so one payload can serve flows that read different attributes. + */ + class Attributes + @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 [Attributes]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Attributes]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(attributes: Attributes) = apply { + additionalProperties = attributes.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 [Attributes]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Attributes = Attributes(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws PreludeInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Attributes = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: PreludeInvalidDataException) { + 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 Attributes && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Attributes{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is WatchEvaluateParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "WatchEvaluateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/WatchEvaluateResponse.kt b/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/WatchEvaluateResponse.kt new file mode 100644 index 00000000..b1f9e167 --- /dev/null +++ b/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/WatchEvaluateResponse.kt @@ -0,0 +1,1808 @@ +// File generated from our OpenAPI spec by Stainless. + +package so.prelude.sdk.models + +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 +import so.prelude.sdk.core.Enum +import so.prelude.sdk.core.ExcludeMissing +import so.prelude.sdk.core.JsonField +import so.prelude.sdk.core.JsonMissing +import so.prelude.sdk.core.JsonValue +import so.prelude.sdk.core.checkKnown +import so.prelude.sdk.core.checkRequired +import so.prelude.sdk.core.toImmutable +import so.prelude.sdk.errors.PreludeInvalidDataException + +class WatchEvaluateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val action: JsonField, + private val recipes: JsonField>, + private val verdict: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("action") @ExcludeMissing action: JsonField = JsonMissing.of(), + @JsonProperty("recipes") + @ExcludeMissing + recipes: JsonField> = JsonMissing.of(), + @JsonProperty("verdict") @ExcludeMissing verdict: JsonField = JsonMissing.of(), + ) : this(id, action, recipes, verdict, mutableMapOf()) + + /** + * The evaluation identifier. + * + * @throws PreludeInvalidDataException 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 id(): String = id.getRequired("id") + + /** + * What the evaluation suggests you do, being the most severe action across the recipes that + * ran. Advisory: enforcement is yours. + * * `ALLOW` - Let the request through. + * * `BLOCK` - Refuse the request. + * * `CHALLENGE` - Let the request through behind an additional check. + * + * @throws PreludeInvalidDataException 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 action(): Action = action.getRequired("action") + + /** + * One result per recipe that ran. A recipe the flow names but that is not in service is absent + * rather than reported as having passed. + * + * @throws PreludeInvalidDataException 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 recipes(): List = recipes.getRequired("recipes") + + /** + * The evaluation-level verdict, being the most severe verdict across the recipes that ran. + * * `PASS` - No recipe flagged. + * * `FLAG` - At least one recipe flagged. + * + * @throws PreludeInvalidDataException 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 verdict(): Verdict = verdict.getRequired("verdict") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [action]. + * + * Unlike [action], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("action") @ExcludeMissing fun _action(): JsonField = action + + /** + * Returns the raw JSON value of [recipes]. + * + * Unlike [recipes], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("recipes") @ExcludeMissing fun _recipes(): JsonField> = recipes + + /** + * Returns the raw JSON value of [verdict]. + * + * Unlike [verdict], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("verdict") @ExcludeMissing fun _verdict(): JsonField = verdict + + @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 [WatchEvaluateResponse]. + * + * The following fields are required: + * ```java + * .id() + * .action() + * .recipes() + * .verdict() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [WatchEvaluateResponse]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var action: JsonField? = null + private var recipes: JsonField>? = null + private var verdict: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(watchEvaluateResponse: WatchEvaluateResponse) = apply { + id = watchEvaluateResponse.id + action = watchEvaluateResponse.action + recipes = watchEvaluateResponse.recipes.map { it.toMutableList() } + verdict = watchEvaluateResponse.verdict + additionalProperties = watchEvaluateResponse.additionalProperties.toMutableMap() + } + + /** The evaluation identifier. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * What the evaluation suggests you do, being the most severe action across the recipes that + * ran. Advisory: enforcement is yours. + * * `ALLOW` - Let the request through. + * * `BLOCK` - Refuse the request. + * * `CHALLENGE` - Let the request through behind an additional check. + */ + fun action(action: Action) = action(JsonField.of(action)) + + /** + * Sets [Builder.action] to an arbitrary JSON value. + * + * You should usually call [Builder.action] with a well-typed [Action] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun action(action: JsonField) = apply { this.action = action } + + /** + * One result per recipe that ran. A recipe the flow names but that is not in service is + * absent rather than reported as having passed. + */ + fun recipes(recipes: List) = recipes(JsonField.of(recipes)) + + /** + * Sets [Builder.recipes] to an arbitrary JSON value. + * + * You should usually call [Builder.recipes] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun recipes(recipes: JsonField>) = apply { + this.recipes = recipes.map { it.toMutableList() } + } + + /** + * Adds a single [Recipe] to [recipes]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addRecipe(recipe: Recipe) = apply { + recipes = + (recipes ?: JsonField.of(mutableListOf())).also { + checkKnown("recipes", it).add(recipe) + } + } + + /** + * The evaluation-level verdict, being the most severe verdict across the recipes that ran. + * * `PASS` - No recipe flagged. + * * `FLAG` - At least one recipe flagged. + */ + fun verdict(verdict: Verdict) = verdict(JsonField.of(verdict)) + + /** + * Sets [Builder.verdict] to an arbitrary JSON value. + * + * You should usually call [Builder.verdict] with a well-typed [Verdict] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun verdict(verdict: JsonField) = apply { this.verdict = verdict } + + 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 [WatchEvaluateResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .action() + * .recipes() + * .verdict() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): WatchEvaluateResponse = + WatchEvaluateResponse( + checkRequired("id", id), + checkRequired("action", action), + checkRequired("recipes", recipes).map { it.toImmutable() }, + checkRequired("verdict", verdict), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws PreludeInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): WatchEvaluateResponse = apply { + if (validated) { + return@apply + } + + id() + action().validate() + recipes().forEach { it.validate() } + verdict().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: PreludeInvalidDataException) { + 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 (id.asKnown().isPresent) 1 else 0) + + (action.asKnown().getOrNull()?.validity() ?: 0) + + (recipes.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (verdict.asKnown().getOrNull()?.validity() ?: 0) + + /** + * What the evaluation suggests you do, being the most severe action across the recipes that + * ran. Advisory: enforcement is yours. + * * `ALLOW` - Let the request through. + * * `BLOCK` - Refuse the request. + * * `CHALLENGE` - Let the request through behind an additional check. + */ + class Action @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 ALLOW = of("ALLOW") + + @JvmField val BLOCK = of("BLOCK") + + @JvmField val CHALLENGE = of("CHALLENGE") + + @JvmStatic fun of(value: String) = Action(JsonField.of(value)) + } + + /** An enum containing [Action]'s known values. */ + enum class Known { + ALLOW, + BLOCK, + CHALLENGE, + } + + /** + * An enum containing [Action]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Action] 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 { + ALLOW, + BLOCK, + CHALLENGE, + /** An enum member indicating that [Action] 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) { + ALLOW -> Value.ALLOW + BLOCK -> Value.BLOCK + CHALLENGE -> Value.CHALLENGE + 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 PreludeInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ALLOW -> Known.ALLOW + BLOCK -> Known.BLOCK + CHALLENGE -> Known.CHALLENGE + else -> throw PreludeInvalidDataException("Unknown Action: $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 PreludeInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { PreludeInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws PreludeInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Action = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: PreludeInvalidDataException) { + 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 Action && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class Recipe + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val partialEvidence: JsonField, + private val recipeId: JsonField, + private val rules: JsonField>, + private val score: JsonField, + private val threshold: JsonField, + private val verdict: JsonField, + private val determinedBy: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("partial_evidence") + @ExcludeMissing + partialEvidence: JsonField = JsonMissing.of(), + @JsonProperty("recipe_id") + @ExcludeMissing + recipeId: JsonField = JsonMissing.of(), + @JsonProperty("rules") @ExcludeMissing rules: JsonField> = JsonMissing.of(), + @JsonProperty("score") @ExcludeMissing score: JsonField = JsonMissing.of(), + @JsonProperty("threshold") + @ExcludeMissing + threshold: JsonField = JsonMissing.of(), + @JsonProperty("verdict") @ExcludeMissing verdict: JsonField = JsonMissing.of(), + @JsonProperty("determined_by") + @ExcludeMissing + determinedBy: JsonField = JsonMissing.of(), + ) : this( + partialEvidence, + recipeId, + rules, + score, + threshold, + verdict, + determinedBy, + mutableMapOf(), + ) + + /** + * At least one rule could not be evaluated, so the score rests on less than the whole + * recipe. The score is still returned — a partial verdict is more useful than none — but it + * is labeled rather than passed off as whole. + * + * @throws PreludeInvalidDataException 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 partialEvidence(): Boolean = partialEvidence.getRequired("partial_evidence") + + /** + * The recipe that produced this result. + * + * @throws PreludeInvalidDataException 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 recipeId(): String = recipeId.getRequired("recipe_id") + + /** + * One result per rule in the recipe, in membership order. Every rule runs — a score is only + * meaningful when complete, so there is no short-circuit on the first trigger. + * + * @throws PreludeInvalidDataException 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 rules(): List = rules.getRequired("rules") + + /** + * The sum of the weights of the rules that triggered, clamped to the range -100 to 100. Two + * scores at a bound are not comparable. + * + * @throws PreludeInvalidDataException 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 score(): Long = score.getRequired("score") + + /** + * The score at or above which this recipe flags. + * + * @throws PreludeInvalidDataException 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 threshold(): Long = threshold.getRequired("threshold") + + /** + * This recipe's own verdict. Normally the score against the threshold, unless a preempting + * rule fired — see `determined_by`. + * + * @throws PreludeInvalidDataException 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 verdict(): Verdict = verdict.getRequired("verdict") + + /** + * The preempting rule that set `verdict`, present only when a rule rather than the score + * decided it. Without it a recipe can report a score under its threshold and still flag, + * with nothing in the payload accounting for the difference. + * + * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun determinedBy(): Optional = determinedBy.getOptional("determined_by") + + /** + * Returns the raw JSON value of [partialEvidence]. + * + * Unlike [partialEvidence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("partial_evidence") + @ExcludeMissing + fun _partialEvidence(): JsonField = partialEvidence + + /** + * Returns the raw JSON value of [recipeId]. + * + * Unlike [recipeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("recipe_id") @ExcludeMissing fun _recipeId(): JsonField = recipeId + + /** + * Returns the raw JSON value of [rules]. + * + * Unlike [rules], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("rules") @ExcludeMissing fun _rules(): JsonField> = rules + + /** + * Returns the raw JSON value of [score]. + * + * Unlike [score], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("score") @ExcludeMissing fun _score(): JsonField = score + + /** + * Returns the raw JSON value of [threshold]. + * + * Unlike [threshold], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("threshold") @ExcludeMissing fun _threshold(): JsonField = threshold + + /** + * Returns the raw JSON value of [verdict]. + * + * Unlike [verdict], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("verdict") @ExcludeMissing fun _verdict(): JsonField = verdict + + /** + * Returns the raw JSON value of [determinedBy]. + * + * Unlike [determinedBy], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("determined_by") + @ExcludeMissing + fun _determinedBy(): JsonField = determinedBy + + @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 [Recipe]. + * + * The following fields are required: + * ```java + * .partialEvidence() + * .recipeId() + * .rules() + * .score() + * .threshold() + * .verdict() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Recipe]. */ + class Builder internal constructor() { + + private var partialEvidence: JsonField? = null + private var recipeId: JsonField? = null + private var rules: JsonField>? = null + private var score: JsonField? = null + private var threshold: JsonField? = null + private var verdict: JsonField? = null + private var determinedBy: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(recipe: Recipe) = apply { + partialEvidence = recipe.partialEvidence + recipeId = recipe.recipeId + rules = recipe.rules.map { it.toMutableList() } + score = recipe.score + threshold = recipe.threshold + verdict = recipe.verdict + determinedBy = recipe.determinedBy + additionalProperties = recipe.additionalProperties.toMutableMap() + } + + /** + * At least one rule could not be evaluated, so the score rests on less than the whole + * recipe. The score is still returned — a partial verdict is more useful than none — + * but it is labeled rather than passed off as whole. + */ + fun partialEvidence(partialEvidence: Boolean) = + partialEvidence(JsonField.of(partialEvidence)) + + /** + * Sets [Builder.partialEvidence] to an arbitrary JSON value. + * + * You should usually call [Builder.partialEvidence] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun partialEvidence(partialEvidence: JsonField) = apply { + this.partialEvidence = partialEvidence + } + + /** The recipe that produced this result. */ + fun recipeId(recipeId: String) = recipeId(JsonField.of(recipeId)) + + /** + * Sets [Builder.recipeId] to an arbitrary JSON value. + * + * You should usually call [Builder.recipeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun recipeId(recipeId: JsonField) = apply { this.recipeId = recipeId } + + /** + * One result per rule in the recipe, in membership order. Every rule runs — a score is + * only meaningful when complete, so there is no short-circuit on the first trigger. + */ + fun rules(rules: List) = rules(JsonField.of(rules)) + + /** + * Sets [Builder.rules] to an arbitrary JSON value. + * + * You should usually call [Builder.rules] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun rules(rules: JsonField>) = apply { + this.rules = rules.map { it.toMutableList() } + } + + /** + * Adds a single [Rule] to [rules]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addRule(rule: Rule) = apply { + rules = + (rules ?: JsonField.of(mutableListOf())).also { + checkKnown("rules", it).add(rule) + } + } + + /** + * The sum of the weights of the rules that triggered, clamped to the range -100 to 100. + * Two scores at a bound are not comparable. + */ + fun score(score: Long) = score(JsonField.of(score)) + + /** + * Sets [Builder.score] to an arbitrary JSON value. + * + * You should usually call [Builder.score] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun score(score: JsonField) = apply { this.score = score } + + /** The score at or above which this recipe flags. */ + fun threshold(threshold: Long) = threshold(JsonField.of(threshold)) + + /** + * Sets [Builder.threshold] to an arbitrary JSON value. + * + * You should usually call [Builder.threshold] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun threshold(threshold: JsonField) = apply { this.threshold = threshold } + + /** + * This recipe's own verdict. Normally the score against the threshold, unless a + * preempting rule fired — see `determined_by`. + */ + fun verdict(verdict: Verdict) = verdict(JsonField.of(verdict)) + + /** + * Sets [Builder.verdict] to an arbitrary JSON value. + * + * You should usually call [Builder.verdict] with a well-typed [Verdict] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun verdict(verdict: JsonField) = apply { this.verdict = verdict } + + /** + * The preempting rule that set `verdict`, present only when a rule rather than the + * score decided it. Without it a recipe can report a score under its threshold and + * still flag, with nothing in the payload accounting for the difference. + */ + fun determinedBy(determinedBy: String) = determinedBy(JsonField.of(determinedBy)) + + /** + * Sets [Builder.determinedBy] to an arbitrary JSON value. + * + * You should usually call [Builder.determinedBy] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun determinedBy(determinedBy: JsonField) = apply { + this.determinedBy = determinedBy + } + + 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 [Recipe]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .partialEvidence() + * .recipeId() + * .rules() + * .score() + * .threshold() + * .verdict() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Recipe = + Recipe( + checkRequired("partialEvidence", partialEvidence), + checkRequired("recipeId", recipeId), + checkRequired("rules", rules).map { it.toImmutable() }, + checkRequired("score", score), + checkRequired("threshold", threshold), + checkRequired("verdict", verdict), + determinedBy, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws PreludeInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Recipe = apply { + if (validated) { + return@apply + } + + partialEvidence() + recipeId() + rules().forEach { it.validate() } + score() + threshold() + verdict().validate() + determinedBy() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: PreludeInvalidDataException) { + 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 (partialEvidence.asKnown().isPresent) 1 else 0) + + (if (recipeId.asKnown().isPresent) 1 else 0) + + (rules.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (score.asKnown().isPresent) 1 else 0) + + (if (threshold.asKnown().isPresent) 1 else 0) + + (verdict.asKnown().getOrNull()?.validity() ?: 0) + + (if (determinedBy.asKnown().isPresent) 1 else 0) + + class Rule + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val outcome: JsonField, + private val ruleId: JsonField, + private val weight: JsonField, + private val blockedBy: JsonField, + private val name: JsonField, + private val unavailable: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("outcome") + @ExcludeMissing + outcome: JsonField = JsonMissing.of(), + @JsonProperty("rule_id") + @ExcludeMissing + ruleId: JsonField = JsonMissing.of(), + @JsonProperty("weight") @ExcludeMissing weight: JsonField = JsonMissing.of(), + @JsonProperty("blocked_by") + @ExcludeMissing + blockedBy: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("unavailable") + @ExcludeMissing + unavailable: JsonField = JsonMissing.of(), + ) : this(outcome, ruleId, weight, blockedBy, name, unavailable, mutableMapOf()) + + /** + * What the rule concluded. + * * `TRIGGERED` - The condition held; `weight` was added to the score. + * * `NOT_TRIGGERED` - The condition did not hold. + * * `NOT_EVALUATED` - The rule could not run, because something it reads never arrived. + * This is not a quieter `NOT_TRIGGERED`: it contributed nothing either way, and it is + * why `partial_evidence` is set on the recipe. + * + * @throws PreludeInvalidDataException 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 outcome(): Outcome = outcome.getRequired("outcome") + + /** + * The rule that produced this result. Present whatever the rule's visibility, so a rule + * you cannot see the condition of is still one you can reweight, switch off, or ask us + * about. + * + * @throws PreludeInvalidDataException 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 ruleId(): String = ruleId.getRequired("rule_id") + + /** + * What this rule contributes to the recipe's score when it triggers. + * + * @throws PreludeInvalidDataException 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 weight(): Long = weight.getRequired("weight") + + /** + * Why the rule could not run, set only when `outcome` is `NOT_EVALUATED`. + * + * A rule you authored names the signal or attribute it waited on, since you wrote the + * expression that reads it. A Prelude-managed rule reports `missing_data` and nothing + * more: the signal it waited on is part of a condition that is not disclosed. + * + * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun blockedBy(): Optional = blockedBy.getOptional("blocked_by") + + /** + * The rule's name, present for a rule you authored and omitted for a Prelude-managed + * one. A managed rule's name describes what it looks for, which is as much of the + * condition as the expression is. + * + * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun name(): Optional = name.getOptional("name") + + /** + * The rule could not run for a reason on our side rather than anything about your + * request. `outcome` is `NOT_EVALUATED` and the failure is ours to fix. + * + * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun unavailable(): Optional = unavailable.getOptional("unavailable") + + /** + * Returns the raw JSON value of [outcome]. + * + * Unlike [outcome], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("outcome") @ExcludeMissing fun _outcome(): JsonField = outcome + + /** + * Returns the raw JSON value of [ruleId]. + * + * Unlike [ruleId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("rule_id") @ExcludeMissing fun _ruleId(): JsonField = ruleId + + /** + * Returns the raw JSON value of [weight]. + * + * Unlike [weight], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("weight") @ExcludeMissing fun _weight(): JsonField = weight + + /** + * Returns the raw JSON value of [blockedBy]. + * + * Unlike [blockedBy], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("blocked_by") + @ExcludeMissing + fun _blockedBy(): JsonField = blockedBy + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [unavailable]. + * + * Unlike [unavailable], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("unavailable") + @ExcludeMissing + fun _unavailable(): JsonField = unavailable + + @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 [Rule]. + * + * The following fields are required: + * ```java + * .outcome() + * .ruleId() + * .weight() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Rule]. */ + class Builder internal constructor() { + + private var outcome: JsonField? = null + private var ruleId: JsonField? = null + private var weight: JsonField? = null + private var blockedBy: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var unavailable: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(rule: Rule) = apply { + outcome = rule.outcome + ruleId = rule.ruleId + weight = rule.weight + blockedBy = rule.blockedBy + name = rule.name + unavailable = rule.unavailable + additionalProperties = rule.additionalProperties.toMutableMap() + } + + /** + * What the rule concluded. + * * `TRIGGERED` - The condition held; `weight` was added to the score. + * * `NOT_TRIGGERED` - The condition did not hold. + * * `NOT_EVALUATED` - The rule could not run, because something it reads never + * arrived. This is not a quieter `NOT_TRIGGERED`: it contributed nothing either + * way, and it is why `partial_evidence` is set on the recipe. + */ + fun outcome(outcome: Outcome) = outcome(JsonField.of(outcome)) + + /** + * Sets [Builder.outcome] to an arbitrary JSON value. + * + * You should usually call [Builder.outcome] with a well-typed [Outcome] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun outcome(outcome: JsonField) = apply { this.outcome = outcome } + + /** + * The rule that produced this result. Present whatever the rule's visibility, so a + * rule you cannot see the condition of is still one you can reweight, switch off, + * or ask us about. + */ + fun ruleId(ruleId: String) = ruleId(JsonField.of(ruleId)) + + /** + * Sets [Builder.ruleId] to an arbitrary JSON value. + * + * You should usually call [Builder.ruleId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun ruleId(ruleId: JsonField) = apply { this.ruleId = ruleId } + + /** What this rule contributes to the recipe's score when it triggers. */ + fun weight(weight: Long) = weight(JsonField.of(weight)) + + /** + * Sets [Builder.weight] to an arbitrary JSON value. + * + * You should usually call [Builder.weight] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun weight(weight: JsonField) = apply { this.weight = weight } + + /** + * Why the rule could not run, set only when `outcome` is `NOT_EVALUATED`. + * + * A rule you authored names the signal or attribute it waited on, since you wrote + * the expression that reads it. A Prelude-managed rule reports `missing_data` and + * nothing more: the signal it waited on is part of a condition that is not + * disclosed. + */ + fun blockedBy(blockedBy: String) = blockedBy(JsonField.of(blockedBy)) + + /** + * Sets [Builder.blockedBy] to an arbitrary JSON value. + * + * You should usually call [Builder.blockedBy] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun blockedBy(blockedBy: JsonField) = apply { this.blockedBy = blockedBy } + + /** + * The rule's name, present for a rule you authored and omitted for a + * Prelude-managed one. A managed rule's name describes what it looks for, which is + * as much of the condition as the expression is. + */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The rule could not run for a reason on our side rather than anything about your + * request. `outcome` is `NOT_EVALUATED` and the failure is ours to fix. + */ + fun unavailable(unavailable: Boolean) = unavailable(JsonField.of(unavailable)) + + /** + * Sets [Builder.unavailable] to an arbitrary JSON value. + * + * You should usually call [Builder.unavailable] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun unavailable(unavailable: JsonField) = apply { + this.unavailable = unavailable + } + + 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 [Rule]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .outcome() + * .ruleId() + * .weight() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Rule = + Rule( + checkRequired("outcome", outcome), + checkRequired("ruleId", ruleId), + checkRequired("weight", weight), + blockedBy, + name, + unavailable, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws PreludeInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): Rule = apply { + if (validated) { + return@apply + } + + outcome().validate() + ruleId() + weight() + blockedBy() + name() + unavailable() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: PreludeInvalidDataException) { + 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 = + (outcome.asKnown().getOrNull()?.validity() ?: 0) + + (if (ruleId.asKnown().isPresent) 1 else 0) + + (if (weight.asKnown().isPresent) 1 else 0) + + (if (blockedBy.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (unavailable.asKnown().isPresent) 1 else 0) + + /** + * What the rule concluded. + * * `TRIGGERED` - The condition held; `weight` was added to the score. + * * `NOT_TRIGGERED` - The condition did not hold. + * * `NOT_EVALUATED` - The rule could not run, because something it reads never arrived. + * This is not a quieter `NOT_TRIGGERED`: it contributed nothing either way, and it is + * why `partial_evidence` is set on the recipe. + */ + class Outcome @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 TRIGGERED = of("TRIGGERED") + + @JvmField val NOT_TRIGGERED = of("NOT_TRIGGERED") + + @JvmField val NOT_EVALUATED = of("NOT_EVALUATED") + + @JvmStatic fun of(value: String) = Outcome(JsonField.of(value)) + } + + /** An enum containing [Outcome]'s known values. */ + enum class Known { + TRIGGERED, + NOT_TRIGGERED, + NOT_EVALUATED, + } + + /** + * An enum containing [Outcome]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Outcome] 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 { + TRIGGERED, + NOT_TRIGGERED, + NOT_EVALUATED, + /** + * An enum member indicating that [Outcome] 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) { + TRIGGERED -> Value.TRIGGERED + NOT_TRIGGERED -> Value.NOT_TRIGGERED + NOT_EVALUATED -> Value.NOT_EVALUATED + 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 PreludeInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + TRIGGERED -> Known.TRIGGERED + NOT_TRIGGERED -> Known.NOT_TRIGGERED + NOT_EVALUATED -> Known.NOT_EVALUATED + else -> throw PreludeInvalidDataException("Unknown Outcome: $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 PreludeInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + PreludeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws PreludeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Outcome = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: PreludeInvalidDataException) { + 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 Outcome && 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 Rule && + outcome == other.outcome && + ruleId == other.ruleId && + weight == other.weight && + blockedBy == other.blockedBy && + name == other.name && + unavailable == other.unavailable && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + outcome, + ruleId, + weight, + blockedBy, + name, + unavailable, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Rule{outcome=$outcome, ruleId=$ruleId, weight=$weight, blockedBy=$blockedBy, name=$name, unavailable=$unavailable, additionalProperties=$additionalProperties}" + } + + /** + * This recipe's own verdict. Normally the score against the threshold, unless a preempting + * rule fired — see `determined_by`. + */ + class Verdict @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 PASS = of("PASS") + + @JvmField val FLAG = of("FLAG") + + @JvmStatic fun of(value: String) = Verdict(JsonField.of(value)) + } + + /** An enum containing [Verdict]'s known values. */ + enum class Known { + PASS, + FLAG, + } + + /** + * An enum containing [Verdict]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Verdict] 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 { + PASS, + FLAG, + /** + * An enum member indicating that [Verdict] 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) { + PASS -> Value.PASS + FLAG -> Value.FLAG + 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 PreludeInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PASS -> Known.PASS + FLAG -> Known.FLAG + else -> throw PreludeInvalidDataException("Unknown Verdict: $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 PreludeInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + PreludeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws PreludeInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): Verdict = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: PreludeInvalidDataException) { + 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 Verdict && 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 Recipe && + partialEvidence == other.partialEvidence && + recipeId == other.recipeId && + rules == other.rules && + score == other.score && + threshold == other.threshold && + verdict == other.verdict && + determinedBy == other.determinedBy && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + partialEvidence, + recipeId, + rules, + score, + threshold, + verdict, + determinedBy, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Recipe{partialEvidence=$partialEvidence, recipeId=$recipeId, rules=$rules, score=$score, threshold=$threshold, verdict=$verdict, determinedBy=$determinedBy, additionalProperties=$additionalProperties}" + } + + /** + * The evaluation-level verdict, being the most severe verdict across the recipes that ran. + * * `PASS` - No recipe flagged. + * * `FLAG` - At least one recipe flagged. + */ + class Verdict @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 PASS = of("PASS") + + @JvmField val FLAG = of("FLAG") + + @JvmStatic fun of(value: String) = Verdict(JsonField.of(value)) + } + + /** An enum containing [Verdict]'s known values. */ + enum class Known { + PASS, + FLAG, + } + + /** + * An enum containing [Verdict]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Verdict] 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 { + PASS, + FLAG, + /** An enum member indicating that [Verdict] 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) { + PASS -> Value.PASS + FLAG -> Value.FLAG + 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 PreludeInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PASS -> Known.PASS + FLAG -> Known.FLAG + else -> throw PreludeInvalidDataException("Unknown Verdict: $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 PreludeInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { PreludeInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws PreludeInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Verdict = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: PreludeInvalidDataException) { + 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 Verdict && 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 WatchEvaluateResponse && + id == other.id && + action == other.action && + recipes == other.recipes && + verdict == other.verdict && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, action, recipes, verdict, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "WatchEvaluateResponse{id=$id, action=$action, recipes=$recipes, verdict=$verdict, additionalProperties=$additionalProperties}" +} diff --git a/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/WatchPredictParams.kt b/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/WatchPredictParams.kt index eb21b53b..0bd20f5a 100644 --- a/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/WatchPredictParams.kt +++ b/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/WatchPredictParams.kt @@ -10,7 +10,6 @@ import java.util.Collections import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull -import so.prelude.sdk.core.Enum import so.prelude.sdk.core.ExcludeMissing import so.prelude.sdk.core.JsonField import so.prelude.sdk.core.JsonMissing @@ -624,352 +623,6 @@ private constructor( "Body{target=$target, dispatchId=$dispatchId, metadata=$metadata, signals=$signals, additionalProperties=$additionalProperties}" } - /** The signup identifier to score — a phone number or email address. */ - class Target - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val type: JsonField, - private val value: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - @JsonProperty("value") @ExcludeMissing value: JsonField = JsonMissing.of(), - ) : this(type, value, mutableMapOf()) - - /** - * The type of the target. Either "phone_number" or "email_address". - * - * @throws PreludeInvalidDataException 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 type(): Type = type.getRequired("type") - - /** - * An E.164 formatted phone number or an email address. - * - * @throws PreludeInvalidDataException 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 value(): String = value.getRequired("value") - - /** - * Returns the raw JSON value of [type]. - * - * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - /** - * Returns the raw JSON value of [value]. - * - * Unlike [value], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value - - @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 [Target]. - * - * The following fields are required: - * ```java - * .type() - * .value() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Target]. */ - class Builder internal constructor() { - - private var type: JsonField? = null - private var value: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(target: Target) = apply { - type = target.type - value = target.value - additionalProperties = target.additionalProperties.toMutableMap() - } - - /** The type of the target. Either "phone_number" or "email_address". */ - fun type(type: Type) = type(JsonField.of(type)) - - /** - * Sets [Builder.type] to an arbitrary JSON value. - * - * You should usually call [Builder.type] with a well-typed [Type] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun type(type: JsonField) = apply { this.type = type } - - /** An E.164 formatted phone number or an email address. */ - fun value(value: String) = value(JsonField.of(value)) - - /** - * Sets [Builder.value] to an arbitrary JSON value. - * - * You should usually call [Builder.value] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun value(value: JsonField) = apply { this.value = value } - - 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 [Target]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .type() - * .value() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Target = - Target( - checkRequired("type", type), - checkRequired("value", value), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing fields. - * - * @throws PreludeInvalidDataException if any value type in this object doesn't match its - * expected type. - */ - fun validate(): Target = apply { - if (validated) { - return@apply - } - - type().validate() - value() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: PreludeInvalidDataException) { - 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 = - (type.asKnown().getOrNull()?.validity() ?: 0) + - (if (value.asKnown().isPresent) 1 else 0) - - /** The type of the target. Either "phone_number" or "email_address". */ - class Type @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 PHONE_NUMBER = of("phone_number") - - @JvmField val EMAIL_ADDRESS = of("email_address") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - PHONE_NUMBER, - EMAIL_ADDRESS, - } - - /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Type] 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 { - PHONE_NUMBER, - EMAIL_ADDRESS, - /** An enum member indicating that [Type] 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) { - PHONE_NUMBER -> Value.PHONE_NUMBER - EMAIL_ADDRESS -> Value.EMAIL_ADDRESS - 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 PreludeInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - PHONE_NUMBER -> Known.PHONE_NUMBER - EMAIL_ADDRESS -> Known.EMAIL_ADDRESS - else -> throw PreludeInvalidDataException("Unknown Type: $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 PreludeInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - PreludeInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws PreludeInvalidDataException if any value type in this object doesn't match - * its expected type. - */ - fun validate(): Type = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: PreludeInvalidDataException) { - 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 Type && 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 Target && - type == other.type && - value == other.value && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(type, value, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Target{type=$type, value=$value, additionalProperties=$additionalProperties}" - } - /** The metadata for this prediction. */ class Metadata @JsonCreator(mode = JsonCreator.Mode.DISABLED) @@ -1133,757 +786,6 @@ private constructor( "Metadata{correlationId=$correlationId, additionalProperties=$additionalProperties}" } - /** - * The signals used for anti-fraud. For more details, refer to - * [Signals](/verify/v2/documentation/prevent-fraud#signals). - */ - class Signals - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val appVersion: JsonField, - private val deviceId: JsonField, - private val deviceModel: JsonField, - private val devicePlatform: JsonField, - private val existingUser: JsonField, - private val ip: JsonField, - private val isTrustedUser: JsonField, - private val ja4Fingerprint: JsonField, - private val osVersion: JsonField, - private val userAgent: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("app_version") - @ExcludeMissing - appVersion: JsonField = JsonMissing.of(), - @JsonProperty("device_id") - @ExcludeMissing - deviceId: JsonField = JsonMissing.of(), - @JsonProperty("device_model") - @ExcludeMissing - deviceModel: JsonField = JsonMissing.of(), - @JsonProperty("device_platform") - @ExcludeMissing - devicePlatform: JsonField = JsonMissing.of(), - @JsonProperty("existing_user") - @ExcludeMissing - existingUser: JsonField = JsonMissing.of(), - @JsonProperty("ip") @ExcludeMissing ip: JsonField = JsonMissing.of(), - @JsonProperty("is_trusted_user") - @ExcludeMissing - isTrustedUser: JsonField = JsonMissing.of(), - @JsonProperty("ja4_fingerprint") - @ExcludeMissing - ja4Fingerprint: JsonField = JsonMissing.of(), - @JsonProperty("os_version") - @ExcludeMissing - osVersion: JsonField = JsonMissing.of(), - @JsonProperty("user_agent") - @ExcludeMissing - userAgent: JsonField = JsonMissing.of(), - ) : this( - appVersion, - deviceId, - deviceModel, - devicePlatform, - existingUser, - ip, - isTrustedUser, - ja4Fingerprint, - osVersion, - userAgent, - mutableMapOf(), - ) - - /** - * The version of your application. - * - * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun appVersion(): Optional = appVersion.getOptional("app_version") - - /** - * A unique ID for the user's device. You should ensure that each user device has a unique - * `device_id` value. Ideally, for Android, this corresponds to the `ANDROID_ID` and for - * iOS, this corresponds to the `identifierForVendor`. - * - * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun deviceId(): Optional = deviceId.getOptional("device_id") - - /** - * The model of the user's device. - * - * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun deviceModel(): Optional = deviceModel.getOptional("device_model") - - /** - * The type of the user's device. - * - * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun devicePlatform(): Optional = - devicePlatform.getOptional("device_platform") - - /** - * Whether the end-user already exists in your system, for example an existing account - * signing in again rather than a first-time signup. Unlike `is_trusted_user`, this signal - * does not bypass fraud checks; it is taken into account as one additional anti-fraud - * signal. For more details, refer to - * [Signals](/verify/v2/documentation/prevent-fraud#signals). - * - * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun existingUser(): Optional = existingUser.getOptional("existing_user") - - /** - * The public IP v4 or v6 address of the end-user's device. You should collect this from - * your backend. If your backend is behind a proxy, use the `X-Forwarded-For`, `Forwarded`, - * `True-Client-IP`, `CF-Connecting-IP` or an equivalent header to get the actual public IP - * of the end-user's device. - * - * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun ip(): Optional = ip.getOptional("ip") - - /** - * This signal should indicate a higher level of trust, explicitly stating that the user is - * genuine. Contact us to discuss your use case. For more details, refer to - * [Signals](/verify/v2/documentation/prevent-fraud#signals). - * - * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun isTrustedUser(): Optional = isTrustedUser.getOptional("is_trusted_user") - - /** - * The JA4 fingerprint observed for the end-user's connection. Prelude will infer it - * automatically when you use our Frontend SDKs (which use Prelude's edge network), but you - * can also forward the value if you terminate TLS yourself. - * - * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun ja4Fingerprint(): Optional = ja4Fingerprint.getOptional("ja4_fingerprint") - - /** - * The version of the user's device operating system. - * - * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun osVersion(): Optional = osVersion.getOptional("os_version") - - /** - * The user agent of the user's device. If the individual fields (os_version, - * device_platform, device_model) are provided, we will prioritize those values instead of - * parsing them from the user agent string. - * - * @throws PreludeInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun userAgent(): Optional = userAgent.getOptional("user_agent") - - /** - * Returns the raw JSON value of [appVersion]. - * - * Unlike [appVersion], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("app_version") - @ExcludeMissing - fun _appVersion(): JsonField = appVersion - - /** - * Returns the raw JSON value of [deviceId]. - * - * Unlike [deviceId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("device_id") @ExcludeMissing fun _deviceId(): JsonField = deviceId - - /** - * Returns the raw JSON value of [deviceModel]. - * - * Unlike [deviceModel], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("device_model") - @ExcludeMissing - fun _deviceModel(): JsonField = deviceModel - - /** - * Returns the raw JSON value of [devicePlatform]. - * - * Unlike [devicePlatform], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("device_platform") - @ExcludeMissing - fun _devicePlatform(): JsonField = devicePlatform - - /** - * Returns the raw JSON value of [existingUser]. - * - * Unlike [existingUser], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("existing_user") - @ExcludeMissing - fun _existingUser(): JsonField = existingUser - - /** - * Returns the raw JSON value of [ip]. - * - * Unlike [ip], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("ip") @ExcludeMissing fun _ip(): JsonField = ip - - /** - * Returns the raw JSON value of [isTrustedUser]. - * - * Unlike [isTrustedUser], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("is_trusted_user") - @ExcludeMissing - fun _isTrustedUser(): JsonField = isTrustedUser - - /** - * Returns the raw JSON value of [ja4Fingerprint]. - * - * Unlike [ja4Fingerprint], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("ja4_fingerprint") - @ExcludeMissing - fun _ja4Fingerprint(): JsonField = ja4Fingerprint - - /** - * Returns the raw JSON value of [osVersion]. - * - * Unlike [osVersion], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("os_version") @ExcludeMissing fun _osVersion(): JsonField = osVersion - - /** - * Returns the raw JSON value of [userAgent]. - * - * Unlike [userAgent], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("user_agent") @ExcludeMissing fun _userAgent(): JsonField = userAgent - - @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 [Signals]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Signals]. */ - class Builder internal constructor() { - - private var appVersion: JsonField = JsonMissing.of() - private var deviceId: JsonField = JsonMissing.of() - private var deviceModel: JsonField = JsonMissing.of() - private var devicePlatform: JsonField = JsonMissing.of() - private var existingUser: JsonField = JsonMissing.of() - private var ip: JsonField = JsonMissing.of() - private var isTrustedUser: JsonField = JsonMissing.of() - private var ja4Fingerprint: JsonField = JsonMissing.of() - private var osVersion: JsonField = JsonMissing.of() - private var userAgent: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(signals: Signals) = apply { - appVersion = signals.appVersion - deviceId = signals.deviceId - deviceModel = signals.deviceModel - devicePlatform = signals.devicePlatform - existingUser = signals.existingUser - ip = signals.ip - isTrustedUser = signals.isTrustedUser - ja4Fingerprint = signals.ja4Fingerprint - osVersion = signals.osVersion - userAgent = signals.userAgent - additionalProperties = signals.additionalProperties.toMutableMap() - } - - /** The version of your application. */ - fun appVersion(appVersion: String) = appVersion(JsonField.of(appVersion)) - - /** - * Sets [Builder.appVersion] to an arbitrary JSON value. - * - * You should usually call [Builder.appVersion] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun appVersion(appVersion: JsonField) = apply { this.appVersion = appVersion } - - /** - * A unique ID for the user's device. You should ensure that each user device has a - * unique `device_id` value. Ideally, for Android, this corresponds to the `ANDROID_ID` - * and for iOS, this corresponds to the `identifierForVendor`. - */ - fun deviceId(deviceId: String) = deviceId(JsonField.of(deviceId)) - - /** - * Sets [Builder.deviceId] to an arbitrary JSON value. - * - * You should usually call [Builder.deviceId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun deviceId(deviceId: JsonField) = apply { this.deviceId = deviceId } - - /** The model of the user's device. */ - fun deviceModel(deviceModel: String) = deviceModel(JsonField.of(deviceModel)) - - /** - * Sets [Builder.deviceModel] to an arbitrary JSON value. - * - * You should usually call [Builder.deviceModel] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun deviceModel(deviceModel: JsonField) = apply { - this.deviceModel = deviceModel - } - - /** The type of the user's device. */ - fun devicePlatform(devicePlatform: DevicePlatform) = - devicePlatform(JsonField.of(devicePlatform)) - - /** - * Sets [Builder.devicePlatform] to an arbitrary JSON value. - * - * You should usually call [Builder.devicePlatform] with a well-typed [DevicePlatform] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun devicePlatform(devicePlatform: JsonField) = apply { - this.devicePlatform = devicePlatform - } - - /** - * Whether the end-user already exists in your system, for example an existing account - * signing in again rather than a first-time signup. Unlike `is_trusted_user`, this - * signal does not bypass fraud checks; it is taken into account as one additional - * anti-fraud signal. For more details, refer to - * [Signals](/verify/v2/documentation/prevent-fraud#signals). - */ - fun existingUser(existingUser: Boolean) = existingUser(JsonField.of(existingUser)) - - /** - * Sets [Builder.existingUser] to an arbitrary JSON value. - * - * You should usually call [Builder.existingUser] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun existingUser(existingUser: JsonField) = apply { - this.existingUser = existingUser - } - - /** - * The public IP v4 or v6 address of the end-user's device. You should collect this from - * your backend. If your backend is behind a proxy, use the `X-Forwarded-For`, - * `Forwarded`, `True-Client-IP`, `CF-Connecting-IP` or an equivalent header to get the - * actual public IP of the end-user's device. - */ - fun ip(ip: String) = ip(JsonField.of(ip)) - - /** - * Sets [Builder.ip] to an arbitrary JSON value. - * - * You should usually call [Builder.ip] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun ip(ip: JsonField) = apply { this.ip = ip } - - /** - * This signal should indicate a higher level of trust, explicitly stating that the user - * is genuine. Contact us to discuss your use case. For more details, refer to - * [Signals](/verify/v2/documentation/prevent-fraud#signals). - */ - fun isTrustedUser(isTrustedUser: Boolean) = isTrustedUser(JsonField.of(isTrustedUser)) - - /** - * Sets [Builder.isTrustedUser] to an arbitrary JSON value. - * - * You should usually call [Builder.isTrustedUser] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun isTrustedUser(isTrustedUser: JsonField) = apply { - this.isTrustedUser = isTrustedUser - } - - /** - * The JA4 fingerprint observed for the end-user's connection. Prelude will infer it - * automatically when you use our Frontend SDKs (which use Prelude's edge network), but - * you can also forward the value if you terminate TLS yourself. - */ - fun ja4Fingerprint(ja4Fingerprint: String) = - ja4Fingerprint(JsonField.of(ja4Fingerprint)) - - /** - * Sets [Builder.ja4Fingerprint] to an arbitrary JSON value. - * - * You should usually call [Builder.ja4Fingerprint] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun ja4Fingerprint(ja4Fingerprint: JsonField) = apply { - this.ja4Fingerprint = ja4Fingerprint - } - - /** The version of the user's device operating system. */ - fun osVersion(osVersion: String) = osVersion(JsonField.of(osVersion)) - - /** - * Sets [Builder.osVersion] to an arbitrary JSON value. - * - * You should usually call [Builder.osVersion] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun osVersion(osVersion: JsonField) = apply { this.osVersion = osVersion } - - /** - * The user agent of the user's device. If the individual fields (os_version, - * device_platform, device_model) are provided, we will prioritize those values instead - * of parsing them from the user agent string. - */ - fun userAgent(userAgent: String) = userAgent(JsonField.of(userAgent)) - - /** - * Sets [Builder.userAgent] to an arbitrary JSON value. - * - * You should usually call [Builder.userAgent] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun userAgent(userAgent: JsonField) = apply { this.userAgent = userAgent } - - 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 [Signals]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Signals = - Signals( - appVersion, - deviceId, - deviceModel, - devicePlatform, - existingUser, - ip, - isTrustedUser, - ja4Fingerprint, - osVersion, - userAgent, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing fields. - * - * @throws PreludeInvalidDataException if any value type in this object doesn't match its - * expected type. - */ - fun validate(): Signals = apply { - if (validated) { - return@apply - } - - appVersion() - deviceId() - deviceModel() - devicePlatform().ifPresent { it.validate() } - existingUser() - ip() - isTrustedUser() - ja4Fingerprint() - osVersion() - userAgent() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: PreludeInvalidDataException) { - 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 (appVersion.asKnown().isPresent) 1 else 0) + - (if (deviceId.asKnown().isPresent) 1 else 0) + - (if (deviceModel.asKnown().isPresent) 1 else 0) + - (devicePlatform.asKnown().getOrNull()?.validity() ?: 0) + - (if (existingUser.asKnown().isPresent) 1 else 0) + - (if (ip.asKnown().isPresent) 1 else 0) + - (if (isTrustedUser.asKnown().isPresent) 1 else 0) + - (if (ja4Fingerprint.asKnown().isPresent) 1 else 0) + - (if (osVersion.asKnown().isPresent) 1 else 0) + - (if (userAgent.asKnown().isPresent) 1 else 0) - - /** The type of the user's device. */ - class DevicePlatform - @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 ANDROID = of("android") - - @JvmField val IOS = of("ios") - - @JvmField val IPADOS = of("ipados") - - @JvmField val TVOS = of("tvos") - - @JvmField val WEB = of("web") - - @JvmStatic fun of(value: String) = DevicePlatform(JsonField.of(value)) - } - - /** An enum containing [DevicePlatform]'s known values. */ - enum class Known { - ANDROID, - IOS, - IPADOS, - TVOS, - WEB, - } - - /** - * An enum containing [DevicePlatform]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [DevicePlatform] 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 { - ANDROID, - IOS, - IPADOS, - TVOS, - WEB, - /** - * An enum member indicating that [DevicePlatform] 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) { - ANDROID -> Value.ANDROID - IOS -> Value.IOS - IPADOS -> Value.IPADOS - TVOS -> Value.TVOS - WEB -> Value.WEB - 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 PreludeInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - ANDROID -> Known.ANDROID - IOS -> Known.IOS - IPADOS -> Known.IPADOS - TVOS -> Known.TVOS - WEB -> Known.WEB - else -> throw PreludeInvalidDataException("Unknown DevicePlatform: $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 PreludeInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - PreludeInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws PreludeInvalidDataException if any value type in this object doesn't match - * its expected type. - */ - fun validate(): DevicePlatform = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: PreludeInvalidDataException) { - 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 DevicePlatform && 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 Signals && - appVersion == other.appVersion && - deviceId == other.deviceId && - deviceModel == other.deviceModel && - devicePlatform == other.devicePlatform && - existingUser == other.existingUser && - ip == other.ip && - isTrustedUser == other.isTrustedUser && - ja4Fingerprint == other.ja4Fingerprint && - osVersion == other.osVersion && - userAgent == other.userAgent && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - appVersion, - deviceId, - deviceModel, - devicePlatform, - existingUser, - ip, - isTrustedUser, - ja4Fingerprint, - osVersion, - userAgent, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Signals{appVersion=$appVersion, deviceId=$deviceId, deviceModel=$deviceModel, devicePlatform=$devicePlatform, existingUser=$existingUser, ip=$ip, isTrustedUser=$isTrustedUser, ja4Fingerprint=$ja4Fingerprint, osVersion=$osVersion, userAgent=$userAgent, additionalProperties=$additionalProperties}" - } - override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/WatchSendEventsParams.kt b/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/WatchSendEventsParams.kt index 122fb7aa..904d7b04 100644 --- a/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/WatchSendEventsParams.kt +++ b/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/WatchSendEventsParams.kt @@ -866,361 +866,6 @@ private constructor( override fun toString() = value.toString() } - /** The event target. Only supports phone numbers for now. */ - class Target - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val type: JsonField, - private val value: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - @JsonProperty("value") @ExcludeMissing value: JsonField = JsonMissing.of(), - ) : this(type, value, mutableMapOf()) - - /** - * The type of the target. Either "phone_number" or "email_address". - * - * @throws PreludeInvalidDataException 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 type(): Type = type.getRequired("type") - - /** - * An E.164 formatted phone number or an email address. - * - * @throws PreludeInvalidDataException 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 value(): String = value.getRequired("value") - - /** - * Returns the raw JSON value of [type]. - * - * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - /** - * Returns the raw JSON value of [value]. - * - * Unlike [value], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value - - @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 [Target]. - * - * The following fields are required: - * ```java - * .type() - * .value() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Target]. */ - class Builder internal constructor() { - - private var type: JsonField? = null - private var value: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(target: Target) = apply { - type = target.type - value = target.value - additionalProperties = target.additionalProperties.toMutableMap() - } - - /** The type of the target. Either "phone_number" or "email_address". */ - fun type(type: Type) = type(JsonField.of(type)) - - /** - * Sets [Builder.type] to an arbitrary JSON value. - * - * You should usually call [Builder.type] with a well-typed [Type] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun type(type: JsonField) = apply { this.type = type } - - /** An E.164 formatted phone number or an email address. */ - fun value(value: String) = value(JsonField.of(value)) - - /** - * Sets [Builder.value] to an arbitrary JSON value. - * - * You should usually call [Builder.value] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun value(value: JsonField) = apply { this.value = value } - - 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 [Target]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .type() - * .value() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Target = - Target( - checkRequired("type", type), - checkRequired("value", value), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws PreludeInvalidDataException if any value type in this object doesn't match - * its expected type. - */ - fun validate(): Target = apply { - if (validated) { - return@apply - } - - type().validate() - value() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: PreludeInvalidDataException) { - 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 = - (type.asKnown().getOrNull()?.validity() ?: 0) + - (if (value.asKnown().isPresent) 1 else 0) - - /** The type of the target. Either "phone_number" or "email_address". */ - class Type @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 PHONE_NUMBER = of("phone_number") - - @JvmField val EMAIL_ADDRESS = of("email_address") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - PHONE_NUMBER, - EMAIL_ADDRESS, - } - - /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Type] 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 { - PHONE_NUMBER, - EMAIL_ADDRESS, - /** - * An enum member indicating that [Type] 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) { - PHONE_NUMBER -> Value.PHONE_NUMBER - EMAIL_ADDRESS -> Value.EMAIL_ADDRESS - 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 PreludeInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - PHONE_NUMBER -> Known.PHONE_NUMBER - EMAIL_ADDRESS -> Known.EMAIL_ADDRESS - else -> throw PreludeInvalidDataException("Unknown Type: $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 PreludeInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - PreludeInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws PreludeInvalidDataException if any value type in this object doesn't - * match its expected type. - */ - fun validate(): Type = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: PreludeInvalidDataException) { - 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 Type && 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 Target && - type == other.type && - value == other.value && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(type, value, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Target{type=$type, value=$value, additionalProperties=$additionalProperties}" - } - override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/WatchSendFeedbacksParams.kt b/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/WatchSendFeedbacksParams.kt index 2b637782..8dad9b30 100644 --- a/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/WatchSendFeedbacksParams.kt +++ b/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/WatchSendFeedbacksParams.kt @@ -678,361 +678,6 @@ private constructor( (type.asKnown().getOrNull()?.validity() ?: 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) - /** The feedback target. Only supports phone numbers for now. */ - class Target - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val type: JsonField, - private val value: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - @JsonProperty("value") @ExcludeMissing value: JsonField = JsonMissing.of(), - ) : this(type, value, mutableMapOf()) - - /** - * The type of the target. Either "phone_number" or "email_address". - * - * @throws PreludeInvalidDataException 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 type(): Type = type.getRequired("type") - - /** - * An E.164 formatted phone number or an email address. - * - * @throws PreludeInvalidDataException 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 value(): String = value.getRequired("value") - - /** - * Returns the raw JSON value of [type]. - * - * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - /** - * Returns the raw JSON value of [value]. - * - * Unlike [value], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value - - @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 [Target]. - * - * The following fields are required: - * ```java - * .type() - * .value() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Target]. */ - class Builder internal constructor() { - - private var type: JsonField? = null - private var value: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(target: Target) = apply { - type = target.type - value = target.value - additionalProperties = target.additionalProperties.toMutableMap() - } - - /** The type of the target. Either "phone_number" or "email_address". */ - fun type(type: Type) = type(JsonField.of(type)) - - /** - * Sets [Builder.type] to an arbitrary JSON value. - * - * You should usually call [Builder.type] with a well-typed [Type] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun type(type: JsonField) = apply { this.type = type } - - /** An E.164 formatted phone number or an email address. */ - fun value(value: String) = value(JsonField.of(value)) - - /** - * Sets [Builder.value] to an arbitrary JSON value. - * - * You should usually call [Builder.value] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun value(value: JsonField) = apply { this.value = value } - - 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 [Target]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .type() - * .value() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Target = - Target( - checkRequired("type", type), - checkRequired("value", value), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws PreludeInvalidDataException if any value type in this object doesn't match - * its expected type. - */ - fun validate(): Target = apply { - if (validated) { - return@apply - } - - type().validate() - value() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: PreludeInvalidDataException) { - 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 = - (type.asKnown().getOrNull()?.validity() ?: 0) + - (if (value.asKnown().isPresent) 1 else 0) - - /** The type of the target. Either "phone_number" or "email_address". */ - class Type @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 PHONE_NUMBER = of("phone_number") - - @JvmField val EMAIL_ADDRESS = of("email_address") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - PHONE_NUMBER, - EMAIL_ADDRESS, - } - - /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Type] 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 { - PHONE_NUMBER, - EMAIL_ADDRESS, - /** - * An enum member indicating that [Type] 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) { - PHONE_NUMBER -> Value.PHONE_NUMBER - EMAIL_ADDRESS -> Value.EMAIL_ADDRESS - 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 PreludeInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - PHONE_NUMBER -> Known.PHONE_NUMBER - EMAIL_ADDRESS -> Known.EMAIL_ADDRESS - else -> throw PreludeInvalidDataException("Unknown Type: $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 PreludeInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - PreludeInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws PreludeInvalidDataException if any value type in this object doesn't - * match its expected type. - */ - fun validate(): Type = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: PreludeInvalidDataException) { - 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 Type && 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 Target && - type == other.type && - value == other.value && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(type, value, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Target{type=$type, value=$value, additionalProperties=$additionalProperties}" - } - /** The type of feedback. */ class Type @JsonCreator private constructor(private val value: JsonField) : Enum { diff --git a/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/async/IntelServiceAsync.kt b/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/async/IntelServiceAsync.kt new file mode 100644 index 00000000..47a4e1d6 --- /dev/null +++ b/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/async/IntelServiceAsync.kt @@ -0,0 +1,47 @@ +// File generated from our OpenAPI spec by Stainless. + +package so.prelude.sdk.services.async + +import java.util.function.Consumer +import so.prelude.sdk.core.ClientOptions +import so.prelude.sdk.services.async.intel.KycServiceAsync + +interface IntelServiceAsync { + + /** + * 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): IntelServiceAsync + + /** + * Retrieve detailed information about a phone number including carrier data, line type, and + * portability status. + */ + fun kyc(): KycServiceAsync + + /** A view of [IntelServiceAsync] 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 + ): IntelServiceAsync.WithRawResponse + + /** + * Retrieve detailed information about a phone number including carrier data, line type, and + * portability status. + */ + fun kyc(): KycServiceAsync.WithRawResponse + } +} diff --git a/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/async/IntelServiceAsyncImpl.kt b/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/async/IntelServiceAsyncImpl.kt new file mode 100644 index 00000000..8aef6917 --- /dev/null +++ b/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/async/IntelServiceAsyncImpl.kt @@ -0,0 +1,50 @@ +// File generated from our OpenAPI spec by Stainless. + +package so.prelude.sdk.services.async + +import java.util.function.Consumer +import so.prelude.sdk.core.ClientOptions +import so.prelude.sdk.services.async.intel.KycServiceAsync +import so.prelude.sdk.services.async.intel.KycServiceAsyncImpl + +class IntelServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + IntelServiceAsync { + + private val withRawResponse: IntelServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val kyc: KycServiceAsync by lazy { KycServiceAsyncImpl(clientOptions) } + + override fun withRawResponse(): IntelServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): IntelServiceAsync = + IntelServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + /** + * Retrieve detailed information about a phone number including carrier data, line type, and + * portability status. + */ + override fun kyc(): KycServiceAsync = kyc + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + IntelServiceAsync.WithRawResponse { + + private val kyc: KycServiceAsync.WithRawResponse by lazy { + KycServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer + ): IntelServiceAsync.WithRawResponse = + IntelServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + /** + * Retrieve detailed information about a phone number including carrier data, line type, and + * portability status. + */ + override fun kyc(): KycServiceAsync.WithRawResponse = kyc + } +} diff --git a/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/async/NotifyServiceAsync.kt b/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/async/NotifyServiceAsync.kt index 7acfade2..5e3a04f6 100644 --- a/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/async/NotifyServiceAsync.kt +++ b/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/async/NotifyServiceAsync.kt @@ -17,6 +17,8 @@ import so.prelude.sdk.models.NotifyListSubscriptionPhoneNumberEventsParams import so.prelude.sdk.models.NotifyListSubscriptionPhoneNumberEventsResponse import so.prelude.sdk.models.NotifyListSubscriptionPhoneNumbersParams import so.prelude.sdk.models.NotifyListSubscriptionPhoneNumbersResponse +import so.prelude.sdk.models.NotifyReplyParams +import so.prelude.sdk.models.NotifyReplyResponse import so.prelude.sdk.models.NotifySendBatchParams import so.prelude.sdk.models.NotifySendBatchResponse import so.prelude.sdk.models.NotifySendParams @@ -235,6 +237,19 @@ interface NotifyServiceAsync { requestOptions, ) + /** + * Send a free-form text reply to an inbound WhatsApp message within the 24-hour conversation + * window. See [WhatsApp 2-Way Messaging](/notify/v2/documentation/whatsapp) for details. + */ + fun reply(params: NotifyReplyParams): CompletableFuture = + reply(params, RequestOptions.none()) + + /** @see reply */ + fun reply( + params: NotifyReplyParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + /** * Send transactional and marketing messages to your users via SMS, RCS and WhatsApp with * automatic compliance enforcement. @@ -467,6 +482,21 @@ interface NotifyServiceAsync { requestOptions, ) + /** + * Returns a raw HTTP response for `post /v2/notify/reply`, but is otherwise the same as + * [NotifyServiceAsync.reply]. + */ + fun reply( + params: NotifyReplyParams + ): CompletableFuture> = + reply(params, RequestOptions.none()) + + /** @see reply */ + fun reply( + params: NotifyReplyParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + /** * Returns a raw HTTP response for `post /v2/notify`, but is otherwise the same as * [NotifyServiceAsync.send]. diff --git a/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/async/NotifyServiceAsyncImpl.kt b/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/async/NotifyServiceAsyncImpl.kt index b6eedef3..c0cf14bd 100644 --- a/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/async/NotifyServiceAsyncImpl.kt +++ b/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/async/NotifyServiceAsyncImpl.kt @@ -29,6 +29,8 @@ import so.prelude.sdk.models.NotifyListSubscriptionPhoneNumberEventsParams import so.prelude.sdk.models.NotifyListSubscriptionPhoneNumberEventsResponse import so.prelude.sdk.models.NotifyListSubscriptionPhoneNumbersParams import so.prelude.sdk.models.NotifyListSubscriptionPhoneNumbersResponse +import so.prelude.sdk.models.NotifyReplyParams +import so.prelude.sdk.models.NotifyReplyResponse import so.prelude.sdk.models.NotifySendBatchParams import so.prelude.sdk.models.NotifySendBatchResponse import so.prelude.sdk.models.NotifySendParams @@ -88,6 +90,13 @@ class NotifyServiceAsyncImpl internal constructor(private val clientOptions: Cli it.parse() } + override fun reply( + params: NotifyReplyParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /v2/notify/reply + withRawResponse().reply(params, requestOptions).thenApply { it.parse() } + override fun send( params: NotifySendParams, requestOptions: RequestOptions, @@ -310,6 +319,37 @@ class NotifyServiceAsyncImpl internal constructor(private val clientOptions: Cli } } + private val replyHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun reply( + params: NotifyReplyParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v2", "notify", "reply") + .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 { replyHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + private val sendHandler: Handler = jsonHandler(clientOptions.jsonMapper) diff --git a/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/async/VerificationManagementServiceAsync.kt b/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/async/VerificationManagementServiceAsync.kt index 9ffd8995..57d8bbe2 100644 --- a/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/async/VerificationManagementServiceAsync.kt +++ b/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/async/VerificationManagementServiceAsync.kt @@ -17,6 +17,7 @@ import so.prelude.sdk.models.VerificationManagementSetPhoneNumberParams import so.prelude.sdk.models.VerificationManagementSetPhoneNumberResponse import so.prelude.sdk.models.VerificationManagementSubmitSenderIdParams import so.prelude.sdk.models.VerificationManagementSubmitSenderIdResponse +import so.prelude.sdk.services.async.verificationManagement.SandboxServiceAsync /** Verify phone numbers. */ interface VerificationManagementServiceAsync { @@ -33,6 +34,9 @@ interface VerificationManagementServiceAsync { */ fun withOptions(modifier: Consumer): VerificationManagementServiceAsync + /** Verify phone numbers. */ + fun sandbox(): SandboxServiceAsync + /** * Remove a phone number from the allow or block list. * @@ -212,6 +216,9 @@ interface VerificationManagementServiceAsync { modifier: Consumer ): VerificationManagementServiceAsync.WithRawResponse + /** Verify phone numbers. */ + fun sandbox(): SandboxServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `delete * /v2/verification/management/phone-numbers/{action}`, but is otherwise the same as diff --git a/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/async/VerificationManagementServiceAsyncImpl.kt b/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/async/VerificationManagementServiceAsyncImpl.kt index 114fa82d..24f486a6 100644 --- a/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/async/VerificationManagementServiceAsyncImpl.kt +++ b/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/async/VerificationManagementServiceAsyncImpl.kt @@ -29,6 +29,8 @@ import so.prelude.sdk.models.VerificationManagementSetPhoneNumberParams import so.prelude.sdk.models.VerificationManagementSetPhoneNumberResponse import so.prelude.sdk.models.VerificationManagementSubmitSenderIdParams import so.prelude.sdk.models.VerificationManagementSubmitSenderIdResponse +import so.prelude.sdk.services.async.verificationManagement.SandboxServiceAsync +import so.prelude.sdk.services.async.verificationManagement.SandboxServiceAsyncImpl /** Verify phone numbers. */ class VerificationManagementServiceAsyncImpl @@ -39,6 +41,8 @@ internal constructor(private val clientOptions: ClientOptions) : WithRawResponseImpl(clientOptions) } + private val sandbox: SandboxServiceAsync by lazy { SandboxServiceAsyncImpl(clientOptions) } + override fun withRawResponse(): VerificationManagementServiceAsync.WithRawResponse = withRawResponse @@ -49,6 +53,9 @@ internal constructor(private val clientOptions: ClientOptions) : clientOptions.toBuilder().apply(modifier::accept).build() ) + /** Verify phone numbers. */ + override fun sandbox(): SandboxServiceAsync = sandbox + override fun deletePhoneNumber( params: VerificationManagementDeletePhoneNumberParams, requestOptions: RequestOptions, @@ -90,6 +97,10 @@ internal constructor(private val clientOptions: ClientOptions) : private val errorHandler: Handler = errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + private val sandbox: SandboxServiceAsync.WithRawResponse by lazy { + SandboxServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + override fun withOptions( modifier: Consumer ): VerificationManagementServiceAsync.WithRawResponse = @@ -97,6 +108,9 @@ internal constructor(private val clientOptions: ClientOptions) : clientOptions.toBuilder().apply(modifier::accept).build() ) + /** Verify phone numbers. */ + override fun sandbox(): SandboxServiceAsync.WithRawResponse = sandbox + private val deletePhoneNumberHandler: Handler = jsonHandler(clientOptions.jsonMapper) diff --git a/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/async/VerificationServiceAsync.kt b/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/async/VerificationServiceAsync.kt index 8fc8aa45..3d26d3a8 100644 --- a/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/async/VerificationServiceAsync.kt +++ b/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/async/VerificationServiceAsync.kt @@ -11,6 +11,7 @@ import so.prelude.sdk.models.VerificationCheckParams import so.prelude.sdk.models.VerificationCheckResponse import so.prelude.sdk.models.VerificationCreateParams import so.prelude.sdk.models.VerificationCreateResponse +import so.prelude.sdk.services.async.verification.PhoneServiceAsync /** Verify phone numbers. */ interface VerificationServiceAsync { @@ -27,6 +28,8 @@ interface VerificationServiceAsync { */ fun withOptions(modifier: Consumer): VerificationServiceAsync + fun phone(): PhoneServiceAsync + /** * Create a new verification for a specific phone number. If another non-expired verification * exists (the request is performed within the verification window), this endpoint will perform @@ -66,6 +69,8 @@ interface VerificationServiceAsync { modifier: Consumer ): VerificationServiceAsync.WithRawResponse + fun phone(): PhoneServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `post /v2/verification`, but is otherwise the same as * [VerificationServiceAsync.create]. diff --git a/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/async/VerificationServiceAsyncImpl.kt b/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/async/VerificationServiceAsyncImpl.kt index 38f8fe50..17910c55 100644 --- a/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/async/VerificationServiceAsyncImpl.kt +++ b/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/async/VerificationServiceAsyncImpl.kt @@ -21,6 +21,8 @@ import so.prelude.sdk.models.VerificationCheckParams import so.prelude.sdk.models.VerificationCheckResponse import so.prelude.sdk.models.VerificationCreateParams import so.prelude.sdk.models.VerificationCreateResponse +import so.prelude.sdk.services.async.verification.PhoneServiceAsync +import so.prelude.sdk.services.async.verification.PhoneServiceAsyncImpl /** Verify phone numbers. */ class VerificationServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : @@ -30,11 +32,15 @@ class VerificationServiceAsyncImpl internal constructor(private val clientOption WithRawResponseImpl(clientOptions) } + private val phone: PhoneServiceAsync by lazy { PhoneServiceAsyncImpl(clientOptions) } + override fun withRawResponse(): VerificationServiceAsync.WithRawResponse = withRawResponse override fun withOptions(modifier: Consumer): VerificationServiceAsync = VerificationServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun phone(): PhoneServiceAsync = phone + override fun create( params: VerificationCreateParams, requestOptions: RequestOptions, @@ -55,6 +61,10 @@ class VerificationServiceAsyncImpl internal constructor(private val clientOption private val errorHandler: Handler = errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + private val phone: PhoneServiceAsync.WithRawResponse by lazy { + PhoneServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + override fun withOptions( modifier: Consumer ): VerificationServiceAsync.WithRawResponse = @@ -62,6 +72,8 @@ class VerificationServiceAsyncImpl internal constructor(private val clientOption clientOptions.toBuilder().apply(modifier::accept).build() ) + override fun phone(): PhoneServiceAsync.WithRawResponse = phone + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) diff --git a/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/async/WatchServiceAsync.kt b/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/async/WatchServiceAsync.kt index 3e9ba8ed..4cc71753 100644 --- a/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/async/WatchServiceAsync.kt +++ b/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/async/WatchServiceAsync.kt @@ -7,6 +7,8 @@ import java.util.function.Consumer import so.prelude.sdk.core.ClientOptions import so.prelude.sdk.core.RequestOptions import so.prelude.sdk.core.http.HttpResponseFor +import so.prelude.sdk.models.WatchEvaluateParams +import so.prelude.sdk.models.WatchEvaluateResponse import so.prelude.sdk.models.WatchPredictParams import so.prelude.sdk.models.WatchPredictResponse import so.prelude.sdk.models.WatchSendEventsParams @@ -29,6 +31,26 @@ interface WatchServiceAsync { */ fun withOptions(modifier: Consumer): WatchServiceAsync + /** + * **Beta.** The request and response shapes may still change, and flows and recipes are + * configured by Prelude on your behalf for now. Talk to us before you build against it. + * + * Score a target against the rules configured for one moment in your product — signup, + * checkout, password reset. The flow selects which recipes run; each recipe scores its rules + * against a threshold and returns its own verdict, and the evaluation answers with the most + * severe verdict and action across them. Where Predict returns a single model-derived outcome, + * Eval returns the full breakdown, so you can see which rules fired and which could not run. + * Scoring-only — it does not update counters by itself. + */ + fun evaluate(params: WatchEvaluateParams): CompletableFuture = + evaluate(params, RequestOptions.none()) + + /** @see evaluate */ + fun evaluate( + params: WatchEvaluateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + /** * At signup, score the user's phone number or email address (target) as legitimate or * suspicious. Scoring-only — does not update counters by itself. When using Feedback, call @@ -91,6 +113,21 @@ interface WatchServiceAsync { modifier: Consumer ): WatchServiceAsync.WithRawResponse + /** + * Returns a raw HTTP response for `post /v2/watch/eval`, but is otherwise the same as + * [WatchServiceAsync.evaluate]. + */ + fun evaluate( + params: WatchEvaluateParams + ): CompletableFuture> = + evaluate(params, RequestOptions.none()) + + /** @see evaluate */ + fun evaluate( + params: WatchEvaluateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + /** * Returns a raw HTTP response for `post /v2/watch/predict`, but is otherwise the same as * [WatchServiceAsync.predict]. diff --git a/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/async/WatchServiceAsyncImpl.kt b/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/async/WatchServiceAsyncImpl.kt index 10f44729..398488f5 100644 --- a/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/async/WatchServiceAsyncImpl.kt +++ b/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/async/WatchServiceAsyncImpl.kt @@ -17,6 +17,8 @@ import so.prelude.sdk.core.http.HttpResponseFor import so.prelude.sdk.core.http.json import so.prelude.sdk.core.http.parseable import so.prelude.sdk.core.prepareAsync +import so.prelude.sdk.models.WatchEvaluateParams +import so.prelude.sdk.models.WatchEvaluateResponse import so.prelude.sdk.models.WatchPredictParams import so.prelude.sdk.models.WatchPredictResponse import so.prelude.sdk.models.WatchSendEventsParams @@ -37,6 +39,13 @@ class WatchServiceAsyncImpl internal constructor(private val clientOptions: Clie override fun withOptions(modifier: Consumer): WatchServiceAsync = WatchServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun evaluate( + params: WatchEvaluateParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /v2/watch/eval + withRawResponse().evaluate(params, requestOptions).thenApply { it.parse() } + override fun predict( params: WatchPredictParams, requestOptions: RequestOptions, @@ -71,6 +80,37 @@ class WatchServiceAsyncImpl internal constructor(private val clientOptions: Clie clientOptions.toBuilder().apply(modifier::accept).build() ) + private val evaluateHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun evaluate( + params: WatchEvaluateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v2", "watch", "eval") + .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 { evaluateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + private val predictHandler: Handler = jsonHandler(clientOptions.jsonMapper) diff --git a/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/async/intel/KycServiceAsync.kt b/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/async/intel/KycServiceAsync.kt new file mode 100644 index 00000000..cb9b0356 --- /dev/null +++ b/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/async/intel/KycServiceAsync.kt @@ -0,0 +1,122 @@ +// File generated from our OpenAPI spec by Stainless. + +package so.prelude.sdk.services.async.intel + +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import so.prelude.sdk.core.ClientOptions +import so.prelude.sdk.core.RequestOptions +import so.prelude.sdk.core.http.HttpResponseFor +import so.prelude.sdk.models.IntelKycMatchParams +import so.prelude.sdk.models.IntelKycMatchResponse + +/** + * Retrieve detailed information about a phone number including carrier data, line type, and + * portability status. + */ +interface KycServiceAsync { + + /** + * 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): KycServiceAsync + + /** + * Verify identity attributes against the subscriber record held by the end-user's mobile + * operator. Send a phone number along with the attributes to check; Prelude resolves the + * operator internally and returns a per-attribute match. Currently available for France only + * (Orange, SFR, Bouygues) and must be enabled for your account. + */ + fun match(phone: String): CompletableFuture = + match(phone, IntelKycMatchParams.none()) + + /** @see match */ + fun match( + phone: String, + params: IntelKycMatchParams = IntelKycMatchParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + match(params.toBuilder().phone(phone).build(), requestOptions) + + /** @see match */ + fun match( + phone: String, + params: IntelKycMatchParams = IntelKycMatchParams.none(), + ): CompletableFuture = match(phone, params, RequestOptions.none()) + + /** @see match */ + fun match( + params: IntelKycMatchParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see match */ + fun match(params: IntelKycMatchParams): CompletableFuture = + match(params, RequestOptions.none()) + + /** @see match */ + fun match( + phone: String, + requestOptions: RequestOptions, + ): CompletableFuture = + match(phone, IntelKycMatchParams.none(), requestOptions) + + /** A view of [KycServiceAsync] 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): KycServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /v2/intel/kyc/match/{phone}`, but is otherwise the + * same as [KycServiceAsync.match]. + */ + fun match(phone: String): CompletableFuture> = + match(phone, IntelKycMatchParams.none()) + + /** @see match */ + fun match( + phone: String, + params: IntelKycMatchParams = IntelKycMatchParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + match(params.toBuilder().phone(phone).build(), requestOptions) + + /** @see match */ + fun match( + phone: String, + params: IntelKycMatchParams = IntelKycMatchParams.none(), + ): CompletableFuture> = + match(phone, params, RequestOptions.none()) + + /** @see match */ + fun match( + params: IntelKycMatchParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see match */ + fun match( + params: IntelKycMatchParams + ): CompletableFuture> = + match(params, RequestOptions.none()) + + /** @see match */ + fun match( + phone: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + match(phone, IntelKycMatchParams.none(), requestOptions) + } +} diff --git a/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/async/intel/KycServiceAsyncImpl.kt b/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/async/intel/KycServiceAsyncImpl.kt new file mode 100644 index 00000000..123645ee --- /dev/null +++ b/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/async/intel/KycServiceAsyncImpl.kt @@ -0,0 +1,95 @@ +// File generated from our OpenAPI spec by Stainless. + +package so.prelude.sdk.services.async.intel + +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull +import so.prelude.sdk.core.ClientOptions +import so.prelude.sdk.core.RequestOptions +import so.prelude.sdk.core.checkRequired +import so.prelude.sdk.core.handlers.errorBodyHandler +import so.prelude.sdk.core.handlers.errorHandler +import so.prelude.sdk.core.handlers.jsonHandler +import so.prelude.sdk.core.http.HttpMethod +import so.prelude.sdk.core.http.HttpRequest +import so.prelude.sdk.core.http.HttpResponse +import so.prelude.sdk.core.http.HttpResponse.Handler +import so.prelude.sdk.core.http.HttpResponseFor +import so.prelude.sdk.core.http.json +import so.prelude.sdk.core.http.parseable +import so.prelude.sdk.core.prepareAsync +import so.prelude.sdk.models.IntelKycMatchParams +import so.prelude.sdk.models.IntelKycMatchResponse + +/** + * Retrieve detailed information about a phone number including carrier data, line type, and + * portability status. + */ +class KycServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + KycServiceAsync { + + private val withRawResponse: KycServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): KycServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): KycServiceAsync = + KycServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun match( + params: IntelKycMatchParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /v2/intel/kyc/match/{phone} + withRawResponse().match(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + KycServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): KycServiceAsync.WithRawResponse = + KycServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val matchHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun match( + params: IntelKycMatchParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("phone", params.phone().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v2", "intel", "kyc", "match", params._pathParam(0)) + .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 { matchHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/async/verification/PhoneServiceAsync.kt b/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/async/verification/PhoneServiceAsync.kt new file mode 100644 index 00000000..9d20f615 --- /dev/null +++ b/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/async/verification/PhoneServiceAsync.kt @@ -0,0 +1,41 @@ +// File generated from our OpenAPI spec by Stainless. + +package so.prelude.sdk.services.async.verification + +import java.util.function.Consumer +import so.prelude.sdk.core.ClientOptions +import so.prelude.sdk.services.async.verification.phone.HistoryServiceAsync + +interface PhoneServiceAsync { + + /** + * 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): PhoneServiceAsync + + /** Verify phone numbers. */ + fun history(): HistoryServiceAsync + + /** A view of [PhoneServiceAsync] 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 + ): PhoneServiceAsync.WithRawResponse + + /** Verify phone numbers. */ + fun history(): HistoryServiceAsync.WithRawResponse + } +} diff --git a/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/async/verification/PhoneServiceAsyncImpl.kt b/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/async/verification/PhoneServiceAsyncImpl.kt new file mode 100644 index 00000000..5e0b84f9 --- /dev/null +++ b/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/async/verification/PhoneServiceAsyncImpl.kt @@ -0,0 +1,44 @@ +// File generated from our OpenAPI spec by Stainless. + +package so.prelude.sdk.services.async.verification + +import java.util.function.Consumer +import so.prelude.sdk.core.ClientOptions +import so.prelude.sdk.services.async.verification.phone.HistoryServiceAsync +import so.prelude.sdk.services.async.verification.phone.HistoryServiceAsyncImpl + +class PhoneServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + PhoneServiceAsync { + + private val withRawResponse: PhoneServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val history: HistoryServiceAsync by lazy { HistoryServiceAsyncImpl(clientOptions) } + + override fun withRawResponse(): PhoneServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): PhoneServiceAsync = + PhoneServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + /** Verify phone numbers. */ + override fun history(): HistoryServiceAsync = history + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + PhoneServiceAsync.WithRawResponse { + + private val history: HistoryServiceAsync.WithRawResponse by lazy { + HistoryServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer + ): PhoneServiceAsync.WithRawResponse = + PhoneServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + /** Verify phone numbers. */ + override fun history(): HistoryServiceAsync.WithRawResponse = history + } +} diff --git a/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/async/verification/phone/HistoryServiceAsync.kt b/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/async/verification/phone/HistoryServiceAsync.kt new file mode 100644 index 00000000..54659e86 --- /dev/null +++ b/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/async/verification/phone/HistoryServiceAsync.kt @@ -0,0 +1,192 @@ +// File generated from our OpenAPI spec by Stainless. + +package so.prelude.sdk.services.async.verification.phone + +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import so.prelude.sdk.core.ClientOptions +import so.prelude.sdk.core.RequestOptions +import so.prelude.sdk.core.http.HttpResponseFor +import so.prelude.sdk.models.VerificationPhoneHistoryListParams +import so.prelude.sdk.models.VerificationPhoneHistoryListResponse +import so.prelude.sdk.models.VerificationPhoneHistoryRetrieveParams +import so.prelude.sdk.models.VerificationPhoneHistoryRetrieveResponse + +/** Verify phone numbers. */ +interface HistoryServiceAsync { + + /** + * 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): HistoryServiceAsync + + /** + * Retrieve everything Prelude recorded for one phone verification: its outcome and the device, + * network and anti-fraud context it was created in, the chronological timeline of every message + * attempt and code check, and the anti-fraud signals you forwarded. + * + * The identifier is the `id` returned by + * [Create or retry a verification](/verify/v2/api-reference/create-or-retry-a-verification) or + * the `verification_id` of the verification webhooks. Both `lifecycle` and `signals` are + * optional: a verification can resolve with its top-level fields alone. + */ + fun retrieve(id: String): CompletableFuture = + retrieve(id, VerificationPhoneHistoryRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + id: String, + params: VerificationPhoneHistoryRetrieveParams = + VerificationPhoneHistoryRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + retrieve(params.toBuilder().id(id).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + id: String, + params: VerificationPhoneHistoryRetrieveParams = + VerificationPhoneHistoryRetrieveParams.none(), + ): CompletableFuture = + retrieve(id, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: VerificationPhoneHistoryRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see retrieve */ + fun retrieve( + params: VerificationPhoneHistoryRetrieveParams + ): CompletableFuture = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + id: String, + requestOptions: RequestOptions, + ): CompletableFuture = + retrieve(id, VerificationPhoneHistoryRetrieveParams.none(), requestOptions) + + /** + * List your phone verifications, most recent first, one entry per verification with its + * outcome, channels, attempts and cost. Every filter is optional and they combine with AND. + * + * Use it to find every verification a phone number went through from your support tooling, then + * [Get a phone verification](/verify/v2/api-reference/history/get-a-phone-verification) for the + * full timeline of one of them. A cursor is bound to the filters that produced it: pass + * `next_cursor` back with the exact same query parameters. + */ + fun list(): CompletableFuture = + list(VerificationPhoneHistoryListParams.none()) + + /** @see list */ + fun list( + params: VerificationPhoneHistoryListParams = VerificationPhoneHistoryListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see list */ + fun list( + params: VerificationPhoneHistoryListParams = VerificationPhoneHistoryListParams.none() + ): CompletableFuture = list(params, RequestOptions.none()) + + /** @see list */ + fun list( + requestOptions: RequestOptions + ): CompletableFuture = + list(VerificationPhoneHistoryListParams.none(), requestOptions) + + /** + * A view of [HistoryServiceAsync] 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 + ): HistoryServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get /v2/verification/phone/history/{id}`, but is + * otherwise the same as [HistoryServiceAsync.retrieve]. + */ + fun retrieve( + id: String + ): CompletableFuture> = + retrieve(id, VerificationPhoneHistoryRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + id: String, + params: VerificationPhoneHistoryRetrieveParams = + VerificationPhoneHistoryRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + retrieve(params.toBuilder().id(id).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + id: String, + params: VerificationPhoneHistoryRetrieveParams = + VerificationPhoneHistoryRetrieveParams.none(), + ): CompletableFuture> = + retrieve(id, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: VerificationPhoneHistoryRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see retrieve */ + fun retrieve( + params: VerificationPhoneHistoryRetrieveParams + ): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + id: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + retrieve(id, VerificationPhoneHistoryRetrieveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /v2/verification/phone/history`, but is otherwise + * the same as [HistoryServiceAsync.list]. + */ + fun list(): CompletableFuture> = + list(VerificationPhoneHistoryListParams.none()) + + /** @see list */ + fun list( + params: VerificationPhoneHistoryListParams = VerificationPhoneHistoryListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see list */ + fun list( + params: VerificationPhoneHistoryListParams = VerificationPhoneHistoryListParams.none() + ): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + requestOptions: RequestOptions + ): CompletableFuture> = + list(VerificationPhoneHistoryListParams.none(), requestOptions) + } +} diff --git a/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/async/verification/phone/HistoryServiceAsyncImpl.kt b/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/async/verification/phone/HistoryServiceAsyncImpl.kt new file mode 100644 index 00000000..e31ce7c0 --- /dev/null +++ b/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/async/verification/phone/HistoryServiceAsyncImpl.kt @@ -0,0 +1,129 @@ +// File generated from our OpenAPI spec by Stainless. + +package so.prelude.sdk.services.async.verification.phone + +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull +import so.prelude.sdk.core.ClientOptions +import so.prelude.sdk.core.RequestOptions +import so.prelude.sdk.core.checkRequired +import so.prelude.sdk.core.handlers.errorBodyHandler +import so.prelude.sdk.core.handlers.errorHandler +import so.prelude.sdk.core.handlers.jsonHandler +import so.prelude.sdk.core.http.HttpMethod +import so.prelude.sdk.core.http.HttpRequest +import so.prelude.sdk.core.http.HttpResponse +import so.prelude.sdk.core.http.HttpResponse.Handler +import so.prelude.sdk.core.http.HttpResponseFor +import so.prelude.sdk.core.http.parseable +import so.prelude.sdk.core.prepareAsync +import so.prelude.sdk.models.VerificationPhoneHistoryListParams +import so.prelude.sdk.models.VerificationPhoneHistoryListResponse +import so.prelude.sdk.models.VerificationPhoneHistoryRetrieveParams +import so.prelude.sdk.models.VerificationPhoneHistoryRetrieveResponse + +/** Verify phone numbers. */ +class HistoryServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + HistoryServiceAsync { + + private val withRawResponse: HistoryServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): HistoryServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): HistoryServiceAsync = + HistoryServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun retrieve( + params: VerificationPhoneHistoryRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /v2/verification/phone/history/{id} + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + + override fun list( + params: VerificationPhoneHistoryListParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /v2/verification/phone/history + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + HistoryServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): HistoryServiceAsync.WithRawResponse = + HistoryServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieve( + params: VerificationPhoneHistoryRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("id", params.id().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v2", "verification", "phone", "history", 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: VerificationPhoneHistoryListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v2", "verification", "phone", "history") + .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() + } + } + } + } + } + } +} diff --git a/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/async/verificationManagement/SandboxServiceAsync.kt b/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/async/verificationManagement/SandboxServiceAsync.kt new file mode 100644 index 00000000..69ffa3f5 --- /dev/null +++ b/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/async/verificationManagement/SandboxServiceAsync.kt @@ -0,0 +1,262 @@ +// File generated from our OpenAPI spec by Stainless. + +package so.prelude.sdk.services.async.verificationManagement + +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import so.prelude.sdk.core.ClientOptions +import so.prelude.sdk.core.RequestOptions +import so.prelude.sdk.core.http.HttpResponseFor +import so.prelude.sdk.models.VerificationManagementSandboxAddPhoneNumberParams +import so.prelude.sdk.models.VerificationManagementSandboxAddPhoneNumberResponse +import so.prelude.sdk.models.VerificationManagementSandboxDeletePhoneNumberParams +import so.prelude.sdk.models.VerificationManagementSandboxDeletePhoneNumberResponse +import so.prelude.sdk.models.VerificationManagementSandboxListPhoneNumbersParams +import so.prelude.sdk.models.VerificationManagementSandboxListPhoneNumbersResponse + +/** Verify phone numbers. */ +interface SandboxServiceAsync { + + /** + * 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): SandboxServiceAsync + + /** + * Register a phone number as a sandbox number and associate it with a fixed attempt code. + * Subsequent verification attempts against this number will not trigger a real SMS/call and + * will validate against the configured attempt code. + * + * This operation is idempotent - re-adding the same phone number will overwrite the existing + * attempt code. + * + * In order to get access to this endpoint, contact our support team. + */ + fun addPhoneNumber( + params: VerificationManagementSandboxAddPhoneNumberParams + ): CompletableFuture = + addPhoneNumber(params, RequestOptions.none()) + + /** @see addPhoneNumber */ + fun addPhoneNumber( + params: VerificationManagementSandboxAddPhoneNumberParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * Remove a phone number from the sandbox list. + * + * This operation is idempotent - deleting a phone number that is not in the sandbox list will + * succeed without making any changes. + * + * In order to get access to this endpoint, contact our support team. + */ + fun deletePhoneNumber( + phoneNumber: String + ): CompletableFuture = + deletePhoneNumber(phoneNumber, VerificationManagementSandboxDeletePhoneNumberParams.none()) + + /** @see deletePhoneNumber */ + fun deletePhoneNumber( + phoneNumber: String, + params: VerificationManagementSandboxDeletePhoneNumberParams = + VerificationManagementSandboxDeletePhoneNumberParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + deletePhoneNumber(params.toBuilder().phoneNumber(phoneNumber).build(), requestOptions) + + /** @see deletePhoneNumber */ + fun deletePhoneNumber( + phoneNumber: String, + params: VerificationManagementSandboxDeletePhoneNumberParams = + VerificationManagementSandboxDeletePhoneNumberParams.none(), + ): CompletableFuture = + deletePhoneNumber(phoneNumber, params, RequestOptions.none()) + + /** @see deletePhoneNumber */ + fun deletePhoneNumber( + params: VerificationManagementSandboxDeletePhoneNumberParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see deletePhoneNumber */ + fun deletePhoneNumber( + params: VerificationManagementSandboxDeletePhoneNumberParams + ): CompletableFuture = + deletePhoneNumber(params, RequestOptions.none()) + + /** @see deletePhoneNumber */ + fun deletePhoneNumber( + phoneNumber: String, + requestOptions: RequestOptions, + ): CompletableFuture = + deletePhoneNumber( + phoneNumber, + VerificationManagementSandboxDeletePhoneNumberParams.none(), + requestOptions, + ) + + /** + * Retrieve the list of sandbox phone numbers for the account. Sandbox numbers are test numbers + * that bypass the real verification flow and return a fixed attempt code. + * + * In order to get access to this endpoint, contact our support team. + */ + fun listPhoneNumbers(): + CompletableFuture = + listPhoneNumbers(VerificationManagementSandboxListPhoneNumbersParams.none()) + + /** @see listPhoneNumbers */ + fun listPhoneNumbers( + params: VerificationManagementSandboxListPhoneNumbersParams = + VerificationManagementSandboxListPhoneNumbersParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see listPhoneNumbers */ + fun listPhoneNumbers( + params: VerificationManagementSandboxListPhoneNumbersParams = + VerificationManagementSandboxListPhoneNumbersParams.none() + ): CompletableFuture = + listPhoneNumbers(params, RequestOptions.none()) + + /** @see listPhoneNumbers */ + fun listPhoneNumbers( + requestOptions: RequestOptions + ): CompletableFuture = + listPhoneNumbers(VerificationManagementSandboxListPhoneNumbersParams.none(), requestOptions) + + /** + * A view of [SandboxServiceAsync] 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 + ): SandboxServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `put /v2/verification/management/phone-numbers/sandbox`, + * but is otherwise the same as [SandboxServiceAsync.addPhoneNumber]. + */ + fun addPhoneNumber( + params: VerificationManagementSandboxAddPhoneNumberParams + ): CompletableFuture> = + addPhoneNumber(params, RequestOptions.none()) + + /** @see addPhoneNumber */ + fun addPhoneNumber( + params: VerificationManagementSandboxAddPhoneNumberParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `delete + * /v2/verification/management/phone-numbers/sandbox/{phone_number}`, but is otherwise the + * same as [SandboxServiceAsync.deletePhoneNumber]. + */ + fun deletePhoneNumber( + phoneNumber: String + ): CompletableFuture< + HttpResponseFor + > = + deletePhoneNumber( + phoneNumber, + VerificationManagementSandboxDeletePhoneNumberParams.none(), + ) + + /** @see deletePhoneNumber */ + fun deletePhoneNumber( + phoneNumber: String, + params: VerificationManagementSandboxDeletePhoneNumberParams = + VerificationManagementSandboxDeletePhoneNumberParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture< + HttpResponseFor + > = deletePhoneNumber(params.toBuilder().phoneNumber(phoneNumber).build(), requestOptions) + + /** @see deletePhoneNumber */ + fun deletePhoneNumber( + phoneNumber: String, + params: VerificationManagementSandboxDeletePhoneNumberParams = + VerificationManagementSandboxDeletePhoneNumberParams.none(), + ): CompletableFuture< + HttpResponseFor + > = deletePhoneNumber(phoneNumber, params, RequestOptions.none()) + + /** @see deletePhoneNumber */ + fun deletePhoneNumber( + params: VerificationManagementSandboxDeletePhoneNumberParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture< + HttpResponseFor + > + + /** @see deletePhoneNumber */ + fun deletePhoneNumber( + params: VerificationManagementSandboxDeletePhoneNumberParams + ): CompletableFuture< + HttpResponseFor + > = deletePhoneNumber(params, RequestOptions.none()) + + /** @see deletePhoneNumber */ + fun deletePhoneNumber( + phoneNumber: String, + requestOptions: RequestOptions, + ): CompletableFuture< + HttpResponseFor + > = + deletePhoneNumber( + phoneNumber, + VerificationManagementSandboxDeletePhoneNumberParams.none(), + requestOptions, + ) + + /** + * Returns a raw HTTP response for `get /v2/verification/management/phone-numbers/sandbox`, + * but is otherwise the same as [SandboxServiceAsync.listPhoneNumbers]. + */ + fun listPhoneNumbers(): + CompletableFuture< + HttpResponseFor + > = listPhoneNumbers(VerificationManagementSandboxListPhoneNumbersParams.none()) + + /** @see listPhoneNumbers */ + fun listPhoneNumbers( + params: VerificationManagementSandboxListPhoneNumbersParams = + VerificationManagementSandboxListPhoneNumbersParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see listPhoneNumbers */ + fun listPhoneNumbers( + params: VerificationManagementSandboxListPhoneNumbersParams = + VerificationManagementSandboxListPhoneNumbersParams.none() + ): CompletableFuture< + HttpResponseFor + > = listPhoneNumbers(params, RequestOptions.none()) + + /** @see listPhoneNumbers */ + fun listPhoneNumbers( + requestOptions: RequestOptions + ): CompletableFuture< + HttpResponseFor + > = + listPhoneNumbers( + VerificationManagementSandboxListPhoneNumbersParams.none(), + requestOptions, + ) + } +} diff --git a/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/async/verificationManagement/SandboxServiceAsyncImpl.kt b/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/async/verificationManagement/SandboxServiceAsyncImpl.kt new file mode 100644 index 00000000..70276db5 --- /dev/null +++ b/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/async/verificationManagement/SandboxServiceAsyncImpl.kt @@ -0,0 +1,191 @@ +// File generated from our OpenAPI spec by Stainless. + +package so.prelude.sdk.services.async.verificationManagement + +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull +import so.prelude.sdk.core.ClientOptions +import so.prelude.sdk.core.RequestOptions +import so.prelude.sdk.core.checkRequired +import so.prelude.sdk.core.handlers.errorBodyHandler +import so.prelude.sdk.core.handlers.errorHandler +import so.prelude.sdk.core.handlers.jsonHandler +import so.prelude.sdk.core.http.HttpMethod +import so.prelude.sdk.core.http.HttpRequest +import so.prelude.sdk.core.http.HttpResponse +import so.prelude.sdk.core.http.HttpResponse.Handler +import so.prelude.sdk.core.http.HttpResponseFor +import so.prelude.sdk.core.http.json +import so.prelude.sdk.core.http.parseable +import so.prelude.sdk.core.prepareAsync +import so.prelude.sdk.models.VerificationManagementSandboxAddPhoneNumberParams +import so.prelude.sdk.models.VerificationManagementSandboxAddPhoneNumberResponse +import so.prelude.sdk.models.VerificationManagementSandboxDeletePhoneNumberParams +import so.prelude.sdk.models.VerificationManagementSandboxDeletePhoneNumberResponse +import so.prelude.sdk.models.VerificationManagementSandboxListPhoneNumbersParams +import so.prelude.sdk.models.VerificationManagementSandboxListPhoneNumbersResponse + +/** Verify phone numbers. */ +class SandboxServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + SandboxServiceAsync { + + private val withRawResponse: SandboxServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): SandboxServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): SandboxServiceAsync = + SandboxServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun addPhoneNumber( + params: VerificationManagementSandboxAddPhoneNumberParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // put /v2/verification/management/phone-numbers/sandbox + withRawResponse().addPhoneNumber(params, requestOptions).thenApply { it.parse() } + + override fun deletePhoneNumber( + params: VerificationManagementSandboxDeletePhoneNumberParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // delete /v2/verification/management/phone-numbers/sandbox/{phone_number} + withRawResponse().deletePhoneNumber(params, requestOptions).thenApply { it.parse() } + + override fun listPhoneNumbers( + params: VerificationManagementSandboxListPhoneNumbersParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /v2/verification/management/phone-numbers/sandbox + withRawResponse().listPhoneNumbers(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + SandboxServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): SandboxServiceAsync.WithRawResponse = + SandboxServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val addPhoneNumberHandler: + Handler = + jsonHandler( + clientOptions.jsonMapper + ) + + override fun addPhoneNumber( + params: VerificationManagementSandboxAddPhoneNumberParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v2", "verification", "management", "phone-numbers", "sandbox") + .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 { addPhoneNumberHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val deletePhoneNumberHandler: + Handler = + jsonHandler( + clientOptions.jsonMapper + ) + + override fun deletePhoneNumber( + params: VerificationManagementSandboxDeletePhoneNumberParams, + requestOptions: RequestOptions, + ): CompletableFuture< + HttpResponseFor + > { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("phoneNumber", params.phoneNumber().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "v2", + "verification", + "management", + "phone-numbers", + "sandbox", + 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 { deletePhoneNumberHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val listPhoneNumbersHandler: + Handler = + jsonHandler( + clientOptions.jsonMapper + ) + + override fun listPhoneNumbers( + params: VerificationManagementSandboxListPhoneNumbersParams, + requestOptions: RequestOptions, + ): CompletableFuture< + HttpResponseFor + > { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v2", "verification", "management", "phone-numbers", "sandbox") + .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 { listPhoneNumbersHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/blocking/IntelService.kt b/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/blocking/IntelService.kt new file mode 100644 index 00000000..f3c635d7 --- /dev/null +++ b/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/blocking/IntelService.kt @@ -0,0 +1,45 @@ +// File generated from our OpenAPI spec by Stainless. + +package so.prelude.sdk.services.blocking + +import java.util.function.Consumer +import so.prelude.sdk.core.ClientOptions +import so.prelude.sdk.services.blocking.intel.KycService + +interface IntelService { + + /** + * 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): IntelService + + /** + * Retrieve detailed information about a phone number including carrier data, line type, and + * portability status. + */ + fun kyc(): KycService + + /** A view of [IntelService] 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): IntelService.WithRawResponse + + /** + * Retrieve detailed information about a phone number including carrier data, line type, and + * portability status. + */ + fun kyc(): KycService.WithRawResponse + } +} diff --git a/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/blocking/IntelServiceImpl.kt b/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/blocking/IntelServiceImpl.kt new file mode 100644 index 00000000..13f41d1c --- /dev/null +++ b/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/blocking/IntelServiceImpl.kt @@ -0,0 +1,50 @@ +// File generated from our OpenAPI spec by Stainless. + +package so.prelude.sdk.services.blocking + +import java.util.function.Consumer +import so.prelude.sdk.core.ClientOptions +import so.prelude.sdk.services.blocking.intel.KycService +import so.prelude.sdk.services.blocking.intel.KycServiceImpl + +class IntelServiceImpl internal constructor(private val clientOptions: ClientOptions) : + IntelService { + + private val withRawResponse: IntelService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val kyc: KycService by lazy { KycServiceImpl(clientOptions) } + + override fun withRawResponse(): IntelService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): IntelService = + IntelServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + /** + * Retrieve detailed information about a phone number including carrier data, line type, and + * portability status. + */ + override fun kyc(): KycService = kyc + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + IntelService.WithRawResponse { + + private val kyc: KycService.WithRawResponse by lazy { + KycServiceImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer + ): IntelService.WithRawResponse = + IntelServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + /** + * Retrieve detailed information about a phone number including carrier data, line type, and + * portability status. + */ + override fun kyc(): KycService.WithRawResponse = kyc + } +} diff --git a/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/blocking/NotifyService.kt b/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/blocking/NotifyService.kt index 92fecfbf..1e5e5f36 100644 --- a/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/blocking/NotifyService.kt +++ b/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/blocking/NotifyService.kt @@ -17,6 +17,8 @@ import so.prelude.sdk.models.NotifyListSubscriptionPhoneNumberEventsParams import so.prelude.sdk.models.NotifyListSubscriptionPhoneNumberEventsResponse import so.prelude.sdk.models.NotifyListSubscriptionPhoneNumbersParams import so.prelude.sdk.models.NotifyListSubscriptionPhoneNumbersResponse +import so.prelude.sdk.models.NotifyReplyParams +import so.prelude.sdk.models.NotifyReplyResponse import so.prelude.sdk.models.NotifySendBatchParams import so.prelude.sdk.models.NotifySendBatchResponse import so.prelude.sdk.models.NotifySendParams @@ -230,6 +232,18 @@ interface NotifyService { requestOptions, ) + /** + * Send a free-form text reply to an inbound WhatsApp message within the 24-hour conversation + * window. See [WhatsApp 2-Way Messaging](/notify/v2/documentation/whatsapp) for details. + */ + fun reply(params: NotifyReplyParams): NotifyReplyResponse = reply(params, RequestOptions.none()) + + /** @see reply */ + fun reply( + params: NotifyReplyParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): NotifyReplyResponse + /** * Send transactional and marketing messages to your users via SMS, RCS and WhatsApp with * automatic compliance enforcement. @@ -480,6 +494,21 @@ interface NotifyService { requestOptions, ) + /** + * Returns a raw HTTP response for `post /v2/notify/reply`, but is otherwise the same as + * [NotifyService.reply]. + */ + @MustBeClosed + fun reply(params: NotifyReplyParams): HttpResponseFor = + reply(params, RequestOptions.none()) + + /** @see reply */ + @MustBeClosed + fun reply( + params: NotifyReplyParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + /** * Returns a raw HTTP response for `post /v2/notify`, but is otherwise the same as * [NotifyService.send]. diff --git a/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/blocking/NotifyServiceImpl.kt b/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/blocking/NotifyServiceImpl.kt index 7bb132ad..22538aa1 100644 --- a/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/blocking/NotifyServiceImpl.kt +++ b/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/blocking/NotifyServiceImpl.kt @@ -28,6 +28,8 @@ import so.prelude.sdk.models.NotifyListSubscriptionPhoneNumberEventsParams import so.prelude.sdk.models.NotifyListSubscriptionPhoneNumberEventsResponse import so.prelude.sdk.models.NotifyListSubscriptionPhoneNumbersParams import so.prelude.sdk.models.NotifyListSubscriptionPhoneNumbersResponse +import so.prelude.sdk.models.NotifyReplyParams +import so.prelude.sdk.models.NotifyReplyResponse import so.prelude.sdk.models.NotifySendBatchParams import so.prelude.sdk.models.NotifySendBatchResponse import so.prelude.sdk.models.NotifySendParams @@ -81,6 +83,13 @@ class NotifyServiceImpl internal constructor(private val clientOptions: ClientOp // get /v2/notify/management/subscriptions/{config_id}/phone_numbers withRawResponse().listSubscriptionPhoneNumbers(params, requestOptions).parse() + override fun reply( + params: NotifyReplyParams, + requestOptions: RequestOptions, + ): NotifyReplyResponse = + // post /v2/notify/reply + withRawResponse().reply(params, requestOptions).parse() + override fun send( params: NotifySendParams, requestOptions: RequestOptions, @@ -288,6 +297,34 @@ class NotifyServiceImpl internal constructor(private val clientOptions: ClientOp } } + private val replyHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun reply( + params: NotifyReplyParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v2", "notify", "reply") + .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 { replyHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + private val sendHandler: Handler = jsonHandler(clientOptions.jsonMapper) diff --git a/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/blocking/VerificationManagementService.kt b/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/blocking/VerificationManagementService.kt index a0a546bc..c0c2e5ce 100644 --- a/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/blocking/VerificationManagementService.kt +++ b/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/blocking/VerificationManagementService.kt @@ -17,6 +17,7 @@ import so.prelude.sdk.models.VerificationManagementSetPhoneNumberParams import so.prelude.sdk.models.VerificationManagementSetPhoneNumberResponse import so.prelude.sdk.models.VerificationManagementSubmitSenderIdParams import so.prelude.sdk.models.VerificationManagementSubmitSenderIdResponse +import so.prelude.sdk.services.blocking.verificationManagement.SandboxService /** Verify phone numbers. */ interface VerificationManagementService { @@ -33,6 +34,9 @@ interface VerificationManagementService { */ fun withOptions(modifier: Consumer): VerificationManagementService + /** Verify phone numbers. */ + fun sandbox(): SandboxService + /** * Remove a phone number from the allow or block list. * @@ -207,6 +211,9 @@ interface VerificationManagementService { modifier: Consumer ): VerificationManagementService.WithRawResponse + /** Verify phone numbers. */ + fun sandbox(): SandboxService.WithRawResponse + /** * Returns a raw HTTP response for `delete * /v2/verification/management/phone-numbers/{action}`, but is otherwise the same as diff --git a/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/blocking/VerificationManagementServiceImpl.kt b/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/blocking/VerificationManagementServiceImpl.kt index 9f359532..ac93a206 100644 --- a/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/blocking/VerificationManagementServiceImpl.kt +++ b/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/blocking/VerificationManagementServiceImpl.kt @@ -28,6 +28,8 @@ import so.prelude.sdk.models.VerificationManagementSetPhoneNumberParams import so.prelude.sdk.models.VerificationManagementSetPhoneNumberResponse import so.prelude.sdk.models.VerificationManagementSubmitSenderIdParams import so.prelude.sdk.models.VerificationManagementSubmitSenderIdResponse +import so.prelude.sdk.services.blocking.verificationManagement.SandboxService +import so.prelude.sdk.services.blocking.verificationManagement.SandboxServiceImpl /** Verify phone numbers. */ class VerificationManagementServiceImpl @@ -37,6 +39,8 @@ internal constructor(private val clientOptions: ClientOptions) : VerificationMan WithRawResponseImpl(clientOptions) } + private val sandbox: SandboxService by lazy { SandboxServiceImpl(clientOptions) } + override fun withRawResponse(): VerificationManagementService.WithRawResponse = withRawResponse override fun withOptions( @@ -44,6 +48,9 @@ internal constructor(private val clientOptions: ClientOptions) : VerificationMan ): VerificationManagementService = VerificationManagementServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + /** Verify phone numbers. */ + override fun sandbox(): SandboxService = sandbox + override fun deletePhoneNumber( params: VerificationManagementDeletePhoneNumberParams, requestOptions: RequestOptions, @@ -85,6 +92,10 @@ internal constructor(private val clientOptions: ClientOptions) : VerificationMan private val errorHandler: Handler = errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + private val sandbox: SandboxService.WithRawResponse by lazy { + SandboxServiceImpl.WithRawResponseImpl(clientOptions) + } + override fun withOptions( modifier: Consumer ): VerificationManagementService.WithRawResponse = @@ -92,6 +103,9 @@ internal constructor(private val clientOptions: ClientOptions) : VerificationMan clientOptions.toBuilder().apply(modifier::accept).build() ) + /** Verify phone numbers. */ + override fun sandbox(): SandboxService.WithRawResponse = sandbox + private val deletePhoneNumberHandler: Handler = jsonHandler(clientOptions.jsonMapper) diff --git a/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/blocking/VerificationService.kt b/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/blocking/VerificationService.kt index f36b24c5..b09535f2 100644 --- a/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/blocking/VerificationService.kt +++ b/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/blocking/VerificationService.kt @@ -11,6 +11,7 @@ import so.prelude.sdk.models.VerificationCheckParams import so.prelude.sdk.models.VerificationCheckResponse import so.prelude.sdk.models.VerificationCreateParams import so.prelude.sdk.models.VerificationCreateResponse +import so.prelude.sdk.services.blocking.verification.PhoneService /** Verify phone numbers. */ interface VerificationService { @@ -27,6 +28,8 @@ interface VerificationService { */ fun withOptions(modifier: Consumer): VerificationService + fun phone(): PhoneService + /** * Create a new verification for a specific phone number. If another non-expired verification * exists (the request is performed within the verification window), this endpoint will perform @@ -65,6 +68,8 @@ interface VerificationService { modifier: Consumer ): VerificationService.WithRawResponse + fun phone(): PhoneService.WithRawResponse + /** * Returns a raw HTTP response for `post /v2/verification`, but is otherwise the same as * [VerificationService.create]. diff --git a/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/blocking/VerificationServiceImpl.kt b/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/blocking/VerificationServiceImpl.kt index c9bc3c91..18b42e6b 100644 --- a/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/blocking/VerificationServiceImpl.kt +++ b/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/blocking/VerificationServiceImpl.kt @@ -20,6 +20,8 @@ import so.prelude.sdk.models.VerificationCheckParams import so.prelude.sdk.models.VerificationCheckResponse import so.prelude.sdk.models.VerificationCreateParams import so.prelude.sdk.models.VerificationCreateResponse +import so.prelude.sdk.services.blocking.verification.PhoneService +import so.prelude.sdk.services.blocking.verification.PhoneServiceImpl /** Verify phone numbers. */ class VerificationServiceImpl internal constructor(private val clientOptions: ClientOptions) : @@ -29,11 +31,15 @@ class VerificationServiceImpl internal constructor(private val clientOptions: Cl WithRawResponseImpl(clientOptions) } + private val phone: PhoneService by lazy { PhoneServiceImpl(clientOptions) } + override fun withRawResponse(): VerificationService.WithRawResponse = withRawResponse override fun withOptions(modifier: Consumer): VerificationService = VerificationServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun phone(): PhoneService = phone + override fun create( params: VerificationCreateParams, requestOptions: RequestOptions, @@ -54,6 +60,10 @@ class VerificationServiceImpl internal constructor(private val clientOptions: Cl private val errorHandler: Handler = errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + private val phone: PhoneService.WithRawResponse by lazy { + PhoneServiceImpl.WithRawResponseImpl(clientOptions) + } + override fun withOptions( modifier: Consumer ): VerificationService.WithRawResponse = @@ -61,6 +71,8 @@ class VerificationServiceImpl internal constructor(private val clientOptions: Cl clientOptions.toBuilder().apply(modifier::accept).build() ) + override fun phone(): PhoneService.WithRawResponse = phone + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) diff --git a/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/blocking/WatchService.kt b/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/blocking/WatchService.kt index fcef54f6..c0cdd836 100644 --- a/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/blocking/WatchService.kt +++ b/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/blocking/WatchService.kt @@ -7,6 +7,8 @@ import java.util.function.Consumer import so.prelude.sdk.core.ClientOptions import so.prelude.sdk.core.RequestOptions import so.prelude.sdk.core.http.HttpResponseFor +import so.prelude.sdk.models.WatchEvaluateParams +import so.prelude.sdk.models.WatchEvaluateResponse import so.prelude.sdk.models.WatchPredictParams import so.prelude.sdk.models.WatchPredictResponse import so.prelude.sdk.models.WatchSendEventsParams @@ -29,6 +31,26 @@ interface WatchService { */ fun withOptions(modifier: Consumer): WatchService + /** + * **Beta.** The request and response shapes may still change, and flows and recipes are + * configured by Prelude on your behalf for now. Talk to us before you build against it. + * + * Score a target against the rules configured for one moment in your product — signup, + * checkout, password reset. The flow selects which recipes run; each recipe scores its rules + * against a threshold and returns its own verdict, and the evaluation answers with the most + * severe verdict and action across them. Where Predict returns a single model-derived outcome, + * Eval returns the full breakdown, so you can see which rules fired and which could not run. + * Scoring-only — it does not update counters by itself. + */ + fun evaluate(params: WatchEvaluateParams): WatchEvaluateResponse = + evaluate(params, RequestOptions.none()) + + /** @see evaluate */ + fun evaluate( + params: WatchEvaluateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): WatchEvaluateResponse + /** * At signup, score the user's phone number or email address (target) as legitimate or * suspicious. Scoring-only — does not update counters by itself. When using Feedback, call @@ -88,6 +110,21 @@ interface WatchService { */ fun withOptions(modifier: Consumer): WatchService.WithRawResponse + /** + * Returns a raw HTTP response for `post /v2/watch/eval`, but is otherwise the same as + * [WatchService.evaluate]. + */ + @MustBeClosed + fun evaluate(params: WatchEvaluateParams): HttpResponseFor = + evaluate(params, RequestOptions.none()) + + /** @see evaluate */ + @MustBeClosed + fun evaluate( + params: WatchEvaluateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + /** * Returns a raw HTTP response for `post /v2/watch/predict`, but is otherwise the same as * [WatchService.predict]. diff --git a/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/blocking/WatchServiceImpl.kt b/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/blocking/WatchServiceImpl.kt index 5476a500..9de32c04 100644 --- a/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/blocking/WatchServiceImpl.kt +++ b/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/blocking/WatchServiceImpl.kt @@ -16,6 +16,8 @@ import so.prelude.sdk.core.http.HttpResponseFor import so.prelude.sdk.core.http.json import so.prelude.sdk.core.http.parseable import so.prelude.sdk.core.prepare +import so.prelude.sdk.models.WatchEvaluateParams +import so.prelude.sdk.models.WatchEvaluateResponse import so.prelude.sdk.models.WatchPredictParams import so.prelude.sdk.models.WatchPredictResponse import so.prelude.sdk.models.WatchSendEventsParams @@ -36,6 +38,13 @@ class WatchServiceImpl internal constructor(private val clientOptions: ClientOpt override fun withOptions(modifier: Consumer): WatchService = WatchServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun evaluate( + params: WatchEvaluateParams, + requestOptions: RequestOptions, + ): WatchEvaluateResponse = + // post /v2/watch/eval + withRawResponse().evaluate(params, requestOptions).parse() + override fun predict( params: WatchPredictParams, requestOptions: RequestOptions, @@ -70,6 +79,34 @@ class WatchServiceImpl internal constructor(private val clientOptions: ClientOpt clientOptions.toBuilder().apply(modifier::accept).build() ) + private val evaluateHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun evaluate( + params: WatchEvaluateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v2", "watch", "eval") + .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 { evaluateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + private val predictHandler: Handler = jsonHandler(clientOptions.jsonMapper) diff --git a/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/blocking/intel/KycService.kt b/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/blocking/intel/KycService.kt new file mode 100644 index 00000000..6376bca3 --- /dev/null +++ b/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/blocking/intel/KycService.kt @@ -0,0 +1,120 @@ +// File generated from our OpenAPI spec by Stainless. + +package so.prelude.sdk.services.blocking.intel + +import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer +import so.prelude.sdk.core.ClientOptions +import so.prelude.sdk.core.RequestOptions +import so.prelude.sdk.core.http.HttpResponseFor +import so.prelude.sdk.models.IntelKycMatchParams +import so.prelude.sdk.models.IntelKycMatchResponse + +/** + * Retrieve detailed information about a phone number including carrier data, line type, and + * portability status. + */ +interface KycService { + + /** + * 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): KycService + + /** + * Verify identity attributes against the subscriber record held by the end-user's mobile + * operator. Send a phone number along with the attributes to check; Prelude resolves the + * operator internally and returns a per-attribute match. Currently available for France only + * (Orange, SFR, Bouygues) and must be enabled for your account. + */ + fun match(phone: String): IntelKycMatchResponse = match(phone, IntelKycMatchParams.none()) + + /** @see match */ + fun match( + phone: String, + params: IntelKycMatchParams = IntelKycMatchParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): IntelKycMatchResponse = match(params.toBuilder().phone(phone).build(), requestOptions) + + /** @see match */ + fun match( + phone: String, + params: IntelKycMatchParams = IntelKycMatchParams.none(), + ): IntelKycMatchResponse = match(phone, params, RequestOptions.none()) + + /** @see match */ + fun match( + params: IntelKycMatchParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): IntelKycMatchResponse + + /** @see match */ + fun match(params: IntelKycMatchParams): IntelKycMatchResponse = + match(params, RequestOptions.none()) + + /** @see match */ + fun match(phone: String, requestOptions: RequestOptions): IntelKycMatchResponse = + match(phone, IntelKycMatchParams.none(), requestOptions) + + /** A view of [KycService] 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): KycService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /v2/intel/kyc/match/{phone}`, but is otherwise the + * same as [KycService.match]. + */ + @MustBeClosed + fun match(phone: String): HttpResponseFor = + match(phone, IntelKycMatchParams.none()) + + /** @see match */ + @MustBeClosed + fun match( + phone: String, + params: IntelKycMatchParams = IntelKycMatchParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + match(params.toBuilder().phone(phone).build(), requestOptions) + + /** @see match */ + @MustBeClosed + fun match( + phone: String, + params: IntelKycMatchParams = IntelKycMatchParams.none(), + ): HttpResponseFor = match(phone, params, RequestOptions.none()) + + /** @see match */ + @MustBeClosed + fun match( + params: IntelKycMatchParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see match */ + @MustBeClosed + fun match(params: IntelKycMatchParams): HttpResponseFor = + match(params, RequestOptions.none()) + + /** @see match */ + @MustBeClosed + fun match( + phone: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + match(phone, IntelKycMatchParams.none(), requestOptions) + } +} diff --git a/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/blocking/intel/KycServiceImpl.kt b/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/blocking/intel/KycServiceImpl.kt new file mode 100644 index 00000000..79a1b125 --- /dev/null +++ b/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/blocking/intel/KycServiceImpl.kt @@ -0,0 +1,90 @@ +// File generated from our OpenAPI spec by Stainless. + +package so.prelude.sdk.services.blocking.intel + +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull +import so.prelude.sdk.core.ClientOptions +import so.prelude.sdk.core.RequestOptions +import so.prelude.sdk.core.checkRequired +import so.prelude.sdk.core.handlers.errorBodyHandler +import so.prelude.sdk.core.handlers.errorHandler +import so.prelude.sdk.core.handlers.jsonHandler +import so.prelude.sdk.core.http.HttpMethod +import so.prelude.sdk.core.http.HttpRequest +import so.prelude.sdk.core.http.HttpResponse +import so.prelude.sdk.core.http.HttpResponse.Handler +import so.prelude.sdk.core.http.HttpResponseFor +import so.prelude.sdk.core.http.json +import so.prelude.sdk.core.http.parseable +import so.prelude.sdk.core.prepare +import so.prelude.sdk.models.IntelKycMatchParams +import so.prelude.sdk.models.IntelKycMatchResponse + +/** + * Retrieve detailed information about a phone number including carrier data, line type, and + * portability status. + */ +class KycServiceImpl internal constructor(private val clientOptions: ClientOptions) : KycService { + + private val withRawResponse: KycService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): KycService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): KycService = + KycServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun match( + params: IntelKycMatchParams, + requestOptions: RequestOptions, + ): IntelKycMatchResponse = + // post /v2/intel/kyc/match/{phone} + withRawResponse().match(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + KycService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): KycService.WithRawResponse = + KycServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val matchHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun match( + params: IntelKycMatchParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("phone", params.phone().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v2", "intel", "kyc", "match", params._pathParam(0)) + .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 { matchHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/blocking/verification/PhoneService.kt b/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/blocking/verification/PhoneService.kt new file mode 100644 index 00000000..bbd9c119 --- /dev/null +++ b/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/blocking/verification/PhoneService.kt @@ -0,0 +1,39 @@ +// File generated from our OpenAPI spec by Stainless. + +package so.prelude.sdk.services.blocking.verification + +import java.util.function.Consumer +import so.prelude.sdk.core.ClientOptions +import so.prelude.sdk.services.blocking.verification.phone.HistoryService + +interface PhoneService { + + /** + * 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): PhoneService + + /** Verify phone numbers. */ + fun history(): HistoryService + + /** A view of [PhoneService] 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): PhoneService.WithRawResponse + + /** Verify phone numbers. */ + fun history(): HistoryService.WithRawResponse + } +} diff --git a/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/blocking/verification/PhoneServiceImpl.kt b/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/blocking/verification/PhoneServiceImpl.kt new file mode 100644 index 00000000..976599a6 --- /dev/null +++ b/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/blocking/verification/PhoneServiceImpl.kt @@ -0,0 +1,44 @@ +// File generated from our OpenAPI spec by Stainless. + +package so.prelude.sdk.services.blocking.verification + +import java.util.function.Consumer +import so.prelude.sdk.core.ClientOptions +import so.prelude.sdk.services.blocking.verification.phone.HistoryService +import so.prelude.sdk.services.blocking.verification.phone.HistoryServiceImpl + +class PhoneServiceImpl internal constructor(private val clientOptions: ClientOptions) : + PhoneService { + + private val withRawResponse: PhoneService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val history: HistoryService by lazy { HistoryServiceImpl(clientOptions) } + + override fun withRawResponse(): PhoneService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): PhoneService = + PhoneServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + /** Verify phone numbers. */ + override fun history(): HistoryService = history + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + PhoneService.WithRawResponse { + + private val history: HistoryService.WithRawResponse by lazy { + HistoryServiceImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer + ): PhoneService.WithRawResponse = + PhoneServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + /** Verify phone numbers. */ + override fun history(): HistoryService.WithRawResponse = history + } +} diff --git a/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/blocking/verification/phone/HistoryService.kt b/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/blocking/verification/phone/HistoryService.kt new file mode 100644 index 00000000..84b29dd9 --- /dev/null +++ b/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/blocking/verification/phone/HistoryService.kt @@ -0,0 +1,192 @@ +// File generated from our OpenAPI spec by Stainless. + +package so.prelude.sdk.services.blocking.verification.phone + +import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer +import so.prelude.sdk.core.ClientOptions +import so.prelude.sdk.core.RequestOptions +import so.prelude.sdk.core.http.HttpResponseFor +import so.prelude.sdk.models.VerificationPhoneHistoryListParams +import so.prelude.sdk.models.VerificationPhoneHistoryListResponse +import so.prelude.sdk.models.VerificationPhoneHistoryRetrieveParams +import so.prelude.sdk.models.VerificationPhoneHistoryRetrieveResponse + +/** Verify phone numbers. */ +interface HistoryService { + + /** + * 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): HistoryService + + /** + * Retrieve everything Prelude recorded for one phone verification: its outcome and the device, + * network and anti-fraud context it was created in, the chronological timeline of every message + * attempt and code check, and the anti-fraud signals you forwarded. + * + * The identifier is the `id` returned by + * [Create or retry a verification](/verify/v2/api-reference/create-or-retry-a-verification) or + * the `verification_id` of the verification webhooks. Both `lifecycle` and `signals` are + * optional: a verification can resolve with its top-level fields alone. + */ + fun retrieve(id: String): VerificationPhoneHistoryRetrieveResponse = + retrieve(id, VerificationPhoneHistoryRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + id: String, + params: VerificationPhoneHistoryRetrieveParams = + VerificationPhoneHistoryRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): VerificationPhoneHistoryRetrieveResponse = + retrieve(params.toBuilder().id(id).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + id: String, + params: VerificationPhoneHistoryRetrieveParams = + VerificationPhoneHistoryRetrieveParams.none(), + ): VerificationPhoneHistoryRetrieveResponse = retrieve(id, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: VerificationPhoneHistoryRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): VerificationPhoneHistoryRetrieveResponse + + /** @see retrieve */ + fun retrieve( + params: VerificationPhoneHistoryRetrieveParams + ): VerificationPhoneHistoryRetrieveResponse = retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + id: String, + requestOptions: RequestOptions, + ): VerificationPhoneHistoryRetrieveResponse = + retrieve(id, VerificationPhoneHistoryRetrieveParams.none(), requestOptions) + + /** + * List your phone verifications, most recent first, one entry per verification with its + * outcome, channels, attempts and cost. Every filter is optional and they combine with AND. + * + * Use it to find every verification a phone number went through from your support tooling, then + * [Get a phone verification](/verify/v2/api-reference/history/get-a-phone-verification) for the + * full timeline of one of them. A cursor is bound to the filters that produced it: pass + * `next_cursor` back with the exact same query parameters. + */ + fun list(): VerificationPhoneHistoryListResponse = + list(VerificationPhoneHistoryListParams.none()) + + /** @see list */ + fun list( + params: VerificationPhoneHistoryListParams = VerificationPhoneHistoryListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): VerificationPhoneHistoryListResponse + + /** @see list */ + fun list( + params: VerificationPhoneHistoryListParams = VerificationPhoneHistoryListParams.none() + ): VerificationPhoneHistoryListResponse = list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): VerificationPhoneHistoryListResponse = + list(VerificationPhoneHistoryListParams.none(), requestOptions) + + /** A view of [HistoryService] 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): HistoryService.WithRawResponse + + /** + * Returns a raw HTTP response for `get /v2/verification/phone/history/{id}`, but is + * otherwise the same as [HistoryService.retrieve]. + */ + @MustBeClosed + fun retrieve(id: String): HttpResponseFor = + retrieve(id, VerificationPhoneHistoryRetrieveParams.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + id: String, + params: VerificationPhoneHistoryRetrieveParams = + VerificationPhoneHistoryRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieve(params.toBuilder().id(id).build(), requestOptions) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + id: String, + params: VerificationPhoneHistoryRetrieveParams = + VerificationPhoneHistoryRetrieveParams.none(), + ): HttpResponseFor = + retrieve(id, params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + params: VerificationPhoneHistoryRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + params: VerificationPhoneHistoryRetrieveParams + ): HttpResponseFor = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + id: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + retrieve(id, VerificationPhoneHistoryRetrieveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /v2/verification/phone/history`, but is otherwise + * the same as [HistoryService.list]. + */ + @MustBeClosed + fun list(): HttpResponseFor = + list(VerificationPhoneHistoryListParams.none()) + + /** @see list */ + @MustBeClosed + fun list( + params: VerificationPhoneHistoryListParams = VerificationPhoneHistoryListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see list */ + @MustBeClosed + fun list( + params: VerificationPhoneHistoryListParams = VerificationPhoneHistoryListParams.none() + ): HttpResponseFor = + list(params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list( + requestOptions: RequestOptions + ): HttpResponseFor = + list(VerificationPhoneHistoryListParams.none(), requestOptions) + } +} diff --git a/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/blocking/verification/phone/HistoryServiceImpl.kt b/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/blocking/verification/phone/HistoryServiceImpl.kt new file mode 100644 index 00000000..fc8e0645 --- /dev/null +++ b/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/blocking/verification/phone/HistoryServiceImpl.kt @@ -0,0 +1,122 @@ +// File generated from our OpenAPI spec by Stainless. + +package so.prelude.sdk.services.blocking.verification.phone + +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull +import so.prelude.sdk.core.ClientOptions +import so.prelude.sdk.core.RequestOptions +import so.prelude.sdk.core.checkRequired +import so.prelude.sdk.core.handlers.errorBodyHandler +import so.prelude.sdk.core.handlers.errorHandler +import so.prelude.sdk.core.handlers.jsonHandler +import so.prelude.sdk.core.http.HttpMethod +import so.prelude.sdk.core.http.HttpRequest +import so.prelude.sdk.core.http.HttpResponse +import so.prelude.sdk.core.http.HttpResponse.Handler +import so.prelude.sdk.core.http.HttpResponseFor +import so.prelude.sdk.core.http.parseable +import so.prelude.sdk.core.prepare +import so.prelude.sdk.models.VerificationPhoneHistoryListParams +import so.prelude.sdk.models.VerificationPhoneHistoryListResponse +import so.prelude.sdk.models.VerificationPhoneHistoryRetrieveParams +import so.prelude.sdk.models.VerificationPhoneHistoryRetrieveResponse + +/** Verify phone numbers. */ +class HistoryServiceImpl internal constructor(private val clientOptions: ClientOptions) : + HistoryService { + + private val withRawResponse: HistoryService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): HistoryService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): HistoryService = + HistoryServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun retrieve( + params: VerificationPhoneHistoryRetrieveParams, + requestOptions: RequestOptions, + ): VerificationPhoneHistoryRetrieveResponse = + // get /v2/verification/phone/history/{id} + withRawResponse().retrieve(params, requestOptions).parse() + + override fun list( + params: VerificationPhoneHistoryListParams, + requestOptions: RequestOptions, + ): VerificationPhoneHistoryListResponse = + // get /v2/verification/phone/history + withRawResponse().list(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + HistoryService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): HistoryService.WithRawResponse = + HistoryServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieve( + params: VerificationPhoneHistoryRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("id", params.id().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v2", "verification", "phone", "history", 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: VerificationPhoneHistoryListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v2", "verification", "phone", "history") + .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() + } + } + } + } + } +} diff --git a/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/blocking/verificationManagement/SandboxService.kt b/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/blocking/verificationManagement/SandboxService.kt new file mode 100644 index 00000000..9b94d85f --- /dev/null +++ b/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/blocking/verificationManagement/SandboxService.kt @@ -0,0 +1,256 @@ +// File generated from our OpenAPI spec by Stainless. + +package so.prelude.sdk.services.blocking.verificationManagement + +import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer +import so.prelude.sdk.core.ClientOptions +import so.prelude.sdk.core.RequestOptions +import so.prelude.sdk.core.http.HttpResponseFor +import so.prelude.sdk.models.VerificationManagementSandboxAddPhoneNumberParams +import so.prelude.sdk.models.VerificationManagementSandboxAddPhoneNumberResponse +import so.prelude.sdk.models.VerificationManagementSandboxDeletePhoneNumberParams +import so.prelude.sdk.models.VerificationManagementSandboxDeletePhoneNumberResponse +import so.prelude.sdk.models.VerificationManagementSandboxListPhoneNumbersParams +import so.prelude.sdk.models.VerificationManagementSandboxListPhoneNumbersResponse + +/** Verify phone numbers. */ +interface SandboxService { + + /** + * 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): SandboxService + + /** + * Register a phone number as a sandbox number and associate it with a fixed attempt code. + * Subsequent verification attempts against this number will not trigger a real SMS/call and + * will validate against the configured attempt code. + * + * This operation is idempotent - re-adding the same phone number will overwrite the existing + * attempt code. + * + * In order to get access to this endpoint, contact our support team. + */ + fun addPhoneNumber( + params: VerificationManagementSandboxAddPhoneNumberParams + ): VerificationManagementSandboxAddPhoneNumberResponse = + addPhoneNumber(params, RequestOptions.none()) + + /** @see addPhoneNumber */ + fun addPhoneNumber( + params: VerificationManagementSandboxAddPhoneNumberParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): VerificationManagementSandboxAddPhoneNumberResponse + + /** + * Remove a phone number from the sandbox list. + * + * This operation is idempotent - deleting a phone number that is not in the sandbox list will + * succeed without making any changes. + * + * In order to get access to this endpoint, contact our support team. + */ + fun deletePhoneNumber( + phoneNumber: String + ): VerificationManagementSandboxDeletePhoneNumberResponse = + deletePhoneNumber(phoneNumber, VerificationManagementSandboxDeletePhoneNumberParams.none()) + + /** @see deletePhoneNumber */ + fun deletePhoneNumber( + phoneNumber: String, + params: VerificationManagementSandboxDeletePhoneNumberParams = + VerificationManagementSandboxDeletePhoneNumberParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): VerificationManagementSandboxDeletePhoneNumberResponse = + deletePhoneNumber(params.toBuilder().phoneNumber(phoneNumber).build(), requestOptions) + + /** @see deletePhoneNumber */ + fun deletePhoneNumber( + phoneNumber: String, + params: VerificationManagementSandboxDeletePhoneNumberParams = + VerificationManagementSandboxDeletePhoneNumberParams.none(), + ): VerificationManagementSandboxDeletePhoneNumberResponse = + deletePhoneNumber(phoneNumber, params, RequestOptions.none()) + + /** @see deletePhoneNumber */ + fun deletePhoneNumber( + params: VerificationManagementSandboxDeletePhoneNumberParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): VerificationManagementSandboxDeletePhoneNumberResponse + + /** @see deletePhoneNumber */ + fun deletePhoneNumber( + params: VerificationManagementSandboxDeletePhoneNumberParams + ): VerificationManagementSandboxDeletePhoneNumberResponse = + deletePhoneNumber(params, RequestOptions.none()) + + /** @see deletePhoneNumber */ + fun deletePhoneNumber( + phoneNumber: String, + requestOptions: RequestOptions, + ): VerificationManagementSandboxDeletePhoneNumberResponse = + deletePhoneNumber( + phoneNumber, + VerificationManagementSandboxDeletePhoneNumberParams.none(), + requestOptions, + ) + + /** + * Retrieve the list of sandbox phone numbers for the account. Sandbox numbers are test numbers + * that bypass the real verification flow and return a fixed attempt code. + * + * In order to get access to this endpoint, contact our support team. + */ + fun listPhoneNumbers(): VerificationManagementSandboxListPhoneNumbersResponse = + listPhoneNumbers(VerificationManagementSandboxListPhoneNumbersParams.none()) + + /** @see listPhoneNumbers */ + fun listPhoneNumbers( + params: VerificationManagementSandboxListPhoneNumbersParams = + VerificationManagementSandboxListPhoneNumbersParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): VerificationManagementSandboxListPhoneNumbersResponse + + /** @see listPhoneNumbers */ + fun listPhoneNumbers( + params: VerificationManagementSandboxListPhoneNumbersParams = + VerificationManagementSandboxListPhoneNumbersParams.none() + ): VerificationManagementSandboxListPhoneNumbersResponse = + listPhoneNumbers(params, RequestOptions.none()) + + /** @see listPhoneNumbers */ + fun listPhoneNumbers( + requestOptions: RequestOptions + ): VerificationManagementSandboxListPhoneNumbersResponse = + listPhoneNumbers(VerificationManagementSandboxListPhoneNumbersParams.none(), requestOptions) + + /** A view of [SandboxService] 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): SandboxService.WithRawResponse + + /** + * Returns a raw HTTP response for `put /v2/verification/management/phone-numbers/sandbox`, + * but is otherwise the same as [SandboxService.addPhoneNumber]. + */ + @MustBeClosed + fun addPhoneNumber( + params: VerificationManagementSandboxAddPhoneNumberParams + ): HttpResponseFor = + addPhoneNumber(params, RequestOptions.none()) + + /** @see addPhoneNumber */ + @MustBeClosed + fun addPhoneNumber( + params: VerificationManagementSandboxAddPhoneNumberParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `delete + * /v2/verification/management/phone-numbers/sandbox/{phone_number}`, but is otherwise the + * same as [SandboxService.deletePhoneNumber]. + */ + @MustBeClosed + fun deletePhoneNumber( + phoneNumber: String + ): HttpResponseFor = + deletePhoneNumber( + phoneNumber, + VerificationManagementSandboxDeletePhoneNumberParams.none(), + ) + + /** @see deletePhoneNumber */ + @MustBeClosed + fun deletePhoneNumber( + phoneNumber: String, + params: VerificationManagementSandboxDeletePhoneNumberParams = + VerificationManagementSandboxDeletePhoneNumberParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + deletePhoneNumber(params.toBuilder().phoneNumber(phoneNumber).build(), requestOptions) + + /** @see deletePhoneNumber */ + @MustBeClosed + fun deletePhoneNumber( + phoneNumber: String, + params: VerificationManagementSandboxDeletePhoneNumberParams = + VerificationManagementSandboxDeletePhoneNumberParams.none(), + ): HttpResponseFor = + deletePhoneNumber(phoneNumber, params, RequestOptions.none()) + + /** @see deletePhoneNumber */ + @MustBeClosed + fun deletePhoneNumber( + params: VerificationManagementSandboxDeletePhoneNumberParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see deletePhoneNumber */ + @MustBeClosed + fun deletePhoneNumber( + params: VerificationManagementSandboxDeletePhoneNumberParams + ): HttpResponseFor = + deletePhoneNumber(params, RequestOptions.none()) + + /** @see deletePhoneNumber */ + @MustBeClosed + fun deletePhoneNumber( + phoneNumber: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + deletePhoneNumber( + phoneNumber, + VerificationManagementSandboxDeletePhoneNumberParams.none(), + requestOptions, + ) + + /** + * Returns a raw HTTP response for `get /v2/verification/management/phone-numbers/sandbox`, + * but is otherwise the same as [SandboxService.listPhoneNumbers]. + */ + @MustBeClosed + fun listPhoneNumbers(): + HttpResponseFor = + listPhoneNumbers(VerificationManagementSandboxListPhoneNumbersParams.none()) + + /** @see listPhoneNumbers */ + @MustBeClosed + fun listPhoneNumbers( + params: VerificationManagementSandboxListPhoneNumbersParams = + VerificationManagementSandboxListPhoneNumbersParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see listPhoneNumbers */ + @MustBeClosed + fun listPhoneNumbers( + params: VerificationManagementSandboxListPhoneNumbersParams = + VerificationManagementSandboxListPhoneNumbersParams.none() + ): HttpResponseFor = + listPhoneNumbers(params, RequestOptions.none()) + + /** @see listPhoneNumbers */ + @MustBeClosed + fun listPhoneNumbers( + requestOptions: RequestOptions + ): HttpResponseFor = + listPhoneNumbers( + VerificationManagementSandboxListPhoneNumbersParams.none(), + requestOptions, + ) + } +} diff --git a/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/blocking/verificationManagement/SandboxServiceImpl.kt b/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/blocking/verificationManagement/SandboxServiceImpl.kt new file mode 100644 index 00000000..7e73356f --- /dev/null +++ b/prelude-java-core/src/main/kotlin/so/prelude/sdk/services/blocking/verificationManagement/SandboxServiceImpl.kt @@ -0,0 +1,177 @@ +// File generated from our OpenAPI spec by Stainless. + +package so.prelude.sdk.services.blocking.verificationManagement + +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull +import so.prelude.sdk.core.ClientOptions +import so.prelude.sdk.core.RequestOptions +import so.prelude.sdk.core.checkRequired +import so.prelude.sdk.core.handlers.errorBodyHandler +import so.prelude.sdk.core.handlers.errorHandler +import so.prelude.sdk.core.handlers.jsonHandler +import so.prelude.sdk.core.http.HttpMethod +import so.prelude.sdk.core.http.HttpRequest +import so.prelude.sdk.core.http.HttpResponse +import so.prelude.sdk.core.http.HttpResponse.Handler +import so.prelude.sdk.core.http.HttpResponseFor +import so.prelude.sdk.core.http.json +import so.prelude.sdk.core.http.parseable +import so.prelude.sdk.core.prepare +import so.prelude.sdk.models.VerificationManagementSandboxAddPhoneNumberParams +import so.prelude.sdk.models.VerificationManagementSandboxAddPhoneNumberResponse +import so.prelude.sdk.models.VerificationManagementSandboxDeletePhoneNumberParams +import so.prelude.sdk.models.VerificationManagementSandboxDeletePhoneNumberResponse +import so.prelude.sdk.models.VerificationManagementSandboxListPhoneNumbersParams +import so.prelude.sdk.models.VerificationManagementSandboxListPhoneNumbersResponse + +/** Verify phone numbers. */ +class SandboxServiceImpl internal constructor(private val clientOptions: ClientOptions) : + SandboxService { + + private val withRawResponse: SandboxService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): SandboxService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): SandboxService = + SandboxServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun addPhoneNumber( + params: VerificationManagementSandboxAddPhoneNumberParams, + requestOptions: RequestOptions, + ): VerificationManagementSandboxAddPhoneNumberResponse = + // put /v2/verification/management/phone-numbers/sandbox + withRawResponse().addPhoneNumber(params, requestOptions).parse() + + override fun deletePhoneNumber( + params: VerificationManagementSandboxDeletePhoneNumberParams, + requestOptions: RequestOptions, + ): VerificationManagementSandboxDeletePhoneNumberResponse = + // delete /v2/verification/management/phone-numbers/sandbox/{phone_number} + withRawResponse().deletePhoneNumber(params, requestOptions).parse() + + override fun listPhoneNumbers( + params: VerificationManagementSandboxListPhoneNumbersParams, + requestOptions: RequestOptions, + ): VerificationManagementSandboxListPhoneNumbersResponse = + // get /v2/verification/management/phone-numbers/sandbox + withRawResponse().listPhoneNumbers(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + SandboxService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): SandboxService.WithRawResponse = + SandboxServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val addPhoneNumberHandler: + Handler = + jsonHandler( + clientOptions.jsonMapper + ) + + override fun addPhoneNumber( + params: VerificationManagementSandboxAddPhoneNumberParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v2", "verification", "management", "phone-numbers", "sandbox") + .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 { addPhoneNumberHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val deletePhoneNumberHandler: + Handler = + jsonHandler( + clientOptions.jsonMapper + ) + + override fun deletePhoneNumber( + params: VerificationManagementSandboxDeletePhoneNumberParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("phoneNumber", params.phoneNumber().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "v2", + "verification", + "management", + "phone-numbers", + "sandbox", + 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 { deletePhoneNumberHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val listPhoneNumbersHandler: + Handler = + jsonHandler( + clientOptions.jsonMapper + ) + + override fun listPhoneNumbers( + params: VerificationManagementSandboxListPhoneNumbersParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v2", "verification", "management", "phone-numbers", "sandbox") + .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 { listPhoneNumbersHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/prelude-java-core/src/test/kotlin/so/prelude/sdk/models/IntelKycMatchParamsTest.kt b/prelude-java-core/src/test/kotlin/so/prelude/sdk/models/IntelKycMatchParamsTest.kt new file mode 100644 index 00000000..d8337c0c --- /dev/null +++ b/prelude-java-core/src/test/kotlin/so/prelude/sdk/models/IntelKycMatchParamsTest.kt @@ -0,0 +1,71 @@ +// File generated from our OpenAPI spec by Stainless. + +package so.prelude.sdk.models + +import java.time.LocalDate +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class IntelKycMatchParamsTest { + + @Test + fun create() { + IntelKycMatchParams.builder() + .phone("+12065550100") + .address("12 rue de la Paix") + .birthdate(LocalDate.parse("1990-01-15")) + .country("FR") + .email("jean.dupont@example.com") + .familyName("Dupont") + .givenName("Jean") + .locality("Paris") + .postalCode("75002") + .region("Île-de-France") + .build() + } + + @Test + fun pathParams() { + val params = IntelKycMatchParams.builder().phone("+12065550100").build() + + assertThat(params._pathParam(0)).isEqualTo("+12065550100") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun body() { + val params = + IntelKycMatchParams.builder() + .phone("+12065550100") + .address("12 rue de la Paix") + .birthdate(LocalDate.parse("1990-01-15")) + .country("FR") + .email("jean.dupont@example.com") + .familyName("Dupont") + .givenName("Jean") + .locality("Paris") + .postalCode("75002") + .region("Île-de-France") + .build() + + val body = params._body() + + assertThat(body.address()).contains("12 rue de la Paix") + assertThat(body.birthdate()).contains(LocalDate.parse("1990-01-15")) + assertThat(body.country()).contains("FR") + assertThat(body.email()).contains("jean.dupont@example.com") + assertThat(body.familyName()).contains("Dupont") + assertThat(body.givenName()).contains("Jean") + assertThat(body.locality()).contains("Paris") + assertThat(body.postalCode()).contains("75002") + assertThat(body.region()).contains("Île-de-France") + } + + @Test + fun bodyWithoutOptionalFields() { + val params = IntelKycMatchParams.builder().phone("+12065550100").build() + + val body = params._body() + } +} diff --git a/prelude-java-core/src/test/kotlin/so/prelude/sdk/models/IntelKycMatchResponseTest.kt b/prelude-java-core/src/test/kotlin/so/prelude/sdk/models/IntelKycMatchResponseTest.kt new file mode 100644 index 00000000..81a77bef --- /dev/null +++ b/prelude-java-core/src/test/kotlin/so/prelude/sdk/models/IntelKycMatchResponseTest.kt @@ -0,0 +1,101 @@ +// File generated from our OpenAPI spec by Stainless. + +package so.prelude.sdk.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import so.prelude.sdk.core.jsonMapper + +internal class IntelKycMatchResponseTest { + + @Test + fun create() { + val intelKycMatchResponse = + IntelKycMatchResponse.builder() + .addressMatch(IntelKycMatchResponse.AddressMatch.FALSE) + .addressMatchScore(64L) + .birthdateMatch(IntelKycMatchResponse.BirthdateMatch.TRUE) + .countryCode("FR") + .countryMatch(IntelKycMatchResponse.CountryMatch.TRUE) + .emailMatch(IntelKycMatchResponse.EmailMatch.NOT_AVAILABLE) + .emailMatchScore(0L) + .familyNameMatch(IntelKycMatchResponse.FamilyNameMatch.FALSE) + .familyNameMatchScore(82L) + .givenNameMatch(IntelKycMatchResponse.GivenNameMatch.TRUE) + .givenNameMatchScore(0L) + .localityMatch(IntelKycMatchResponse.LocalityMatch.TRUE) + .localityMatchScore(0L) + .operator("orange_fr") + .phoneNumber("+33612345678") + .postalCodeMatch(IntelKycMatchResponse.PostalCodeMatch.TRUE) + .regionMatch(IntelKycMatchResponse.RegionMatch.NOT_AVAILABLE) + .regionMatchScore(0L) + .requestId("01HVE0000000000000000000000") + .build() + + assertThat(intelKycMatchResponse.addressMatch()) + .contains(IntelKycMatchResponse.AddressMatch.FALSE) + assertThat(intelKycMatchResponse.addressMatchScore()).contains(64L) + assertThat(intelKycMatchResponse.birthdateMatch()) + .contains(IntelKycMatchResponse.BirthdateMatch.TRUE) + assertThat(intelKycMatchResponse.countryCode()).contains("FR") + assertThat(intelKycMatchResponse.countryMatch()) + .contains(IntelKycMatchResponse.CountryMatch.TRUE) + assertThat(intelKycMatchResponse.emailMatch()) + .contains(IntelKycMatchResponse.EmailMatch.NOT_AVAILABLE) + assertThat(intelKycMatchResponse.emailMatchScore()).contains(0L) + assertThat(intelKycMatchResponse.familyNameMatch()) + .contains(IntelKycMatchResponse.FamilyNameMatch.FALSE) + assertThat(intelKycMatchResponse.familyNameMatchScore()).contains(82L) + assertThat(intelKycMatchResponse.givenNameMatch()) + .contains(IntelKycMatchResponse.GivenNameMatch.TRUE) + assertThat(intelKycMatchResponse.givenNameMatchScore()).contains(0L) + assertThat(intelKycMatchResponse.localityMatch()) + .contains(IntelKycMatchResponse.LocalityMatch.TRUE) + assertThat(intelKycMatchResponse.localityMatchScore()).contains(0L) + assertThat(intelKycMatchResponse.operator()).contains("orange_fr") + assertThat(intelKycMatchResponse.phoneNumber()).contains("+33612345678") + assertThat(intelKycMatchResponse.postalCodeMatch()) + .contains(IntelKycMatchResponse.PostalCodeMatch.TRUE) + assertThat(intelKycMatchResponse.regionMatch()) + .contains(IntelKycMatchResponse.RegionMatch.NOT_AVAILABLE) + assertThat(intelKycMatchResponse.regionMatchScore()).contains(0L) + assertThat(intelKycMatchResponse.requestId()).contains("01HVE0000000000000000000000") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val intelKycMatchResponse = + IntelKycMatchResponse.builder() + .addressMatch(IntelKycMatchResponse.AddressMatch.FALSE) + .addressMatchScore(64L) + .birthdateMatch(IntelKycMatchResponse.BirthdateMatch.TRUE) + .countryCode("FR") + .countryMatch(IntelKycMatchResponse.CountryMatch.TRUE) + .emailMatch(IntelKycMatchResponse.EmailMatch.NOT_AVAILABLE) + .emailMatchScore(0L) + .familyNameMatch(IntelKycMatchResponse.FamilyNameMatch.FALSE) + .familyNameMatchScore(82L) + .givenNameMatch(IntelKycMatchResponse.GivenNameMatch.TRUE) + .givenNameMatchScore(0L) + .localityMatch(IntelKycMatchResponse.LocalityMatch.TRUE) + .localityMatchScore(0L) + .operator("orange_fr") + .phoneNumber("+33612345678") + .postalCodeMatch(IntelKycMatchResponse.PostalCodeMatch.TRUE) + .regionMatch(IntelKycMatchResponse.RegionMatch.NOT_AVAILABLE) + .regionMatchScore(0L) + .requestId("01HVE0000000000000000000000") + .build() + + val roundtrippedIntelKycMatchResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(intelKycMatchResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedIntelKycMatchResponse).isEqualTo(intelKycMatchResponse) + } +} diff --git a/prelude-java-core/src/test/kotlin/so/prelude/sdk/models/NotifyReplyParamsTest.kt b/prelude-java-core/src/test/kotlin/so/prelude/sdk/models/NotifyReplyParamsTest.kt new file mode 100644 index 00000000..869771fc --- /dev/null +++ b/prelude-java-core/src/test/kotlin/so/prelude/sdk/models/NotifyReplyParamsTest.kt @@ -0,0 +1,56 @@ +// File generated from our OpenAPI spec by Stainless. + +package so.prelude.sdk.models + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class NotifyReplyParamsTest { + + @Test + fun create() { + NotifyReplyParams.builder() + .replyTo("im_01k8aq2zggeyssvt53zgvpx63a") + .text("Thanks for reaching out! We'll look into your request.") + .to("+33612345678") + .callbackUrl("https://your-app.com/webhooks/notify") + .correlationId("support-ticket-42") + .build() + } + + @Test + fun body() { + val params = + NotifyReplyParams.builder() + .replyTo("im_01k8aq2zggeyssvt53zgvpx63a") + .text("Thanks for reaching out! We'll look into your request.") + .to("+33612345678") + .callbackUrl("https://your-app.com/webhooks/notify") + .correlationId("support-ticket-42") + .build() + + val body = params._body() + + assertThat(body.replyTo()).isEqualTo("im_01k8aq2zggeyssvt53zgvpx63a") + assertThat(body.text()).isEqualTo("Thanks for reaching out! We'll look into your request.") + assertThat(body.to()).isEqualTo("+33612345678") + assertThat(body.callbackUrl()).contains("https://your-app.com/webhooks/notify") + assertThat(body.correlationId()).contains("support-ticket-42") + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + NotifyReplyParams.builder() + .replyTo("im_01k8aq2zggeyssvt53zgvpx63a") + .text("Thanks for reaching out! We'll look into your request.") + .to("+33612345678") + .build() + + val body = params._body() + + assertThat(body.replyTo()).isEqualTo("im_01k8aq2zggeyssvt53zgvpx63a") + assertThat(body.text()).isEqualTo("Thanks for reaching out! We'll look into your request.") + assertThat(body.to()).isEqualTo("+33612345678") + } +} diff --git a/prelude-java-core/src/test/kotlin/so/prelude/sdk/models/NotifyReplyResponseTest.kt b/prelude-java-core/src/test/kotlin/so/prelude/sdk/models/NotifyReplyResponseTest.kt new file mode 100644 index 00000000..712698d0 --- /dev/null +++ b/prelude-java-core/src/test/kotlin/so/prelude/sdk/models/NotifyReplyResponseTest.kt @@ -0,0 +1,60 @@ +// File generated from our OpenAPI spec by Stainless. + +package so.prelude.sdk.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import so.prelude.sdk.core.jsonMapper + +internal class NotifyReplyResponseTest { + + @Test + fun create() { + val notifyReplyResponse = + NotifyReplyResponse.builder() + .id("tx_01k8ap1btqf5r9fq2c8ax5fhc9") + .createdAt(OffsetDateTime.parse("2025-10-24T12:00:00Z")) + .replyTo("im_01k8aq2zggeyssvt53zgvpx63a") + .text("Thanks for reaching out! We'll look into your request.") + .to("+33612345678") + .callbackUrl("https://your-app.com/webhooks/notify") + .correlationId("support-ticket-42") + .build() + + assertThat(notifyReplyResponse.id()).isEqualTo("tx_01k8ap1btqf5r9fq2c8ax5fhc9") + assertThat(notifyReplyResponse.createdAt()) + .isEqualTo(OffsetDateTime.parse("2025-10-24T12:00:00Z")) + assertThat(notifyReplyResponse.replyTo()).isEqualTo("im_01k8aq2zggeyssvt53zgvpx63a") + assertThat(notifyReplyResponse.text()) + .isEqualTo("Thanks for reaching out! We'll look into your request.") + assertThat(notifyReplyResponse.to()).isEqualTo("+33612345678") + assertThat(notifyReplyResponse.callbackUrl()) + .contains("https://your-app.com/webhooks/notify") + assertThat(notifyReplyResponse.correlationId()).contains("support-ticket-42") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val notifyReplyResponse = + NotifyReplyResponse.builder() + .id("tx_01k8ap1btqf5r9fq2c8ax5fhc9") + .createdAt(OffsetDateTime.parse("2025-10-24T12:00:00Z")) + .replyTo("im_01k8aq2zggeyssvt53zgvpx63a") + .text("Thanks for reaching out! We'll look into your request.") + .to("+33612345678") + .callbackUrl("https://your-app.com/webhooks/notify") + .correlationId("support-ticket-42") + .build() + + val roundtrippedNotifyReplyResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(notifyReplyResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedNotifyReplyResponse).isEqualTo(notifyReplyResponse) + } +} diff --git a/prelude-java-core/src/test/kotlin/so/prelude/sdk/models/PhoneVerificationCarrierTest.kt b/prelude-java-core/src/test/kotlin/so/prelude/sdk/models/PhoneVerificationCarrierTest.kt new file mode 100644 index 00000000..414bb1e3 --- /dev/null +++ b/prelude-java-core/src/test/kotlin/so/prelude/sdk/models/PhoneVerificationCarrierTest.kt @@ -0,0 +1,35 @@ +// File generated from our OpenAPI spec by Stainless. + +package so.prelude.sdk.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import so.prelude.sdk.core.jsonMapper + +internal class PhoneVerificationCarrierTest { + + @Test + fun create() { + val phoneVerificationCarrier = + PhoneVerificationCarrier.builder().mccmnc("208-01").name("Orange").build() + + assertThat(phoneVerificationCarrier.mccmnc()).isEqualTo("208-01") + assertThat(phoneVerificationCarrier.name()).contains("Orange") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val phoneVerificationCarrier = + PhoneVerificationCarrier.builder().mccmnc("208-01").name("Orange").build() + + val roundtrippedPhoneVerificationCarrier = + jsonMapper.readValue( + jsonMapper.writeValueAsString(phoneVerificationCarrier), + jacksonTypeRef(), + ) + + assertThat(roundtrippedPhoneVerificationCarrier).isEqualTo(phoneVerificationCarrier) + } +} diff --git a/prelude-java-core/src/test/kotlin/so/prelude/sdk/models/PhoneVerificationMoneyTest.kt b/prelude-java-core/src/test/kotlin/so/prelude/sdk/models/PhoneVerificationMoneyTest.kt new file mode 100644 index 00000000..4e08388e --- /dev/null +++ b/prelude-java-core/src/test/kotlin/so/prelude/sdk/models/PhoneVerificationMoneyTest.kt @@ -0,0 +1,35 @@ +// File generated from our OpenAPI spec by Stainless. + +package so.prelude.sdk.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import so.prelude.sdk.core.jsonMapper + +internal class PhoneVerificationMoneyTest { + + @Test + fun create() { + val phoneVerificationMoney = + PhoneVerificationMoney.builder().amount("0.042").currency("EUR").build() + + assertThat(phoneVerificationMoney.amount()).isEqualTo("0.042") + assertThat(phoneVerificationMoney.currency()).isEqualTo("EUR") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val phoneVerificationMoney = + PhoneVerificationMoney.builder().amount("0.042").currency("EUR").build() + + val roundtrippedPhoneVerificationMoney = + jsonMapper.readValue( + jsonMapper.writeValueAsString(phoneVerificationMoney), + jacksonTypeRef(), + ) + + assertThat(roundtrippedPhoneVerificationMoney).isEqualTo(phoneVerificationMoney) + } +} diff --git a/prelude-java-core/src/test/kotlin/so/prelude/sdk/models/PhoneVerificationPsd2TransactionTest.kt b/prelude-java-core/src/test/kotlin/so/prelude/sdk/models/PhoneVerificationPsd2TransactionTest.kt new file mode 100644 index 00000000..38d56af0 --- /dev/null +++ b/prelude-java-core/src/test/kotlin/so/prelude/sdk/models/PhoneVerificationPsd2TransactionTest.kt @@ -0,0 +1,43 @@ +// File generated from our OpenAPI spec by Stainless. + +package so.prelude.sdk.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import so.prelude.sdk.core.jsonMapper + +internal class PhoneVerificationPsd2TransactionTest { + + @Test + fun create() { + val phoneVerificationPsd2Transaction = + PhoneVerificationPsd2Transaction.builder() + .amount(PhoneVerificationMoney.builder().amount("0.042").currency("EUR").build()) + .recipient("recipient") + .build() + + assertThat(phoneVerificationPsd2Transaction.amount()) + .contains(PhoneVerificationMoney.builder().amount("0.042").currency("EUR").build()) + assertThat(phoneVerificationPsd2Transaction.recipient()).contains("recipient") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val phoneVerificationPsd2Transaction = + PhoneVerificationPsd2Transaction.builder() + .amount(PhoneVerificationMoney.builder().amount("0.042").currency("EUR").build()) + .recipient("recipient") + .build() + + val roundtrippedPhoneVerificationPsd2Transaction = + jsonMapper.readValue( + jsonMapper.writeValueAsString(phoneVerificationPsd2Transaction), + jacksonTypeRef(), + ) + + assertThat(roundtrippedPhoneVerificationPsd2Transaction) + .isEqualTo(phoneVerificationPsd2Transaction) + } +} diff --git a/prelude-java-core/src/test/kotlin/so/prelude/sdk/models/SignalsTest.kt b/prelude-java-core/src/test/kotlin/so/prelude/sdk/models/SignalsTest.kt new file mode 100644 index 00000000..234bcc4e --- /dev/null +++ b/prelude-java-core/src/test/kotlin/so/prelude/sdk/models/SignalsTest.kt @@ -0,0 +1,69 @@ +// File generated from our OpenAPI spec by Stainless. + +package so.prelude.sdk.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import so.prelude.sdk.core.jsonMapper + +internal class SignalsTest { + + @Test + fun create() { + val signals = + Signals.builder() + .appVersion("1.2.34") + .deviceId("8F0B8FDD-C2CB-4387-B20A-56E9B2E5A0D2") + .deviceModel("iPhone17,2") + .devicePlatform(Signals.DevicePlatform.IOS) + .existingUser(false) + .ip("203.0.113.123") + .isTrustedUser(false) + .ja4Fingerprint("t13d1516h2_8daaf6152771_e5627efa2ab1") + .osVersion("18.0.1") + .userAgent( + "Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.3 Mobile/15E148 Safari/604.1" + ) + .build() + + assertThat(signals.appVersion()).contains("1.2.34") + assertThat(signals.deviceId()).contains("8F0B8FDD-C2CB-4387-B20A-56E9B2E5A0D2") + assertThat(signals.deviceModel()).contains("iPhone17,2") + assertThat(signals.devicePlatform()).contains(Signals.DevicePlatform.IOS) + assertThat(signals.existingUser()).contains(false) + assertThat(signals.ip()).contains("203.0.113.123") + assertThat(signals.isTrustedUser()).contains(false) + assertThat(signals.ja4Fingerprint()).contains("t13d1516h2_8daaf6152771_e5627efa2ab1") + assertThat(signals.osVersion()).contains("18.0.1") + assertThat(signals.userAgent()) + .contains( + "Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.3 Mobile/15E148 Safari/604.1" + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val signals = + Signals.builder() + .appVersion("1.2.34") + .deviceId("8F0B8FDD-C2CB-4387-B20A-56E9B2E5A0D2") + .deviceModel("iPhone17,2") + .devicePlatform(Signals.DevicePlatform.IOS) + .existingUser(false) + .ip("203.0.113.123") + .isTrustedUser(false) + .ja4Fingerprint("t13d1516h2_8daaf6152771_e5627efa2ab1") + .osVersion("18.0.1") + .userAgent( + "Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.3 Mobile/15E148 Safari/604.1" + ) + .build() + + val roundtrippedSignals = + jsonMapper.readValue(jsonMapper.writeValueAsString(signals), jacksonTypeRef()) + + assertThat(roundtrippedSignals).isEqualTo(signals) + } +} diff --git a/prelude-java-core/src/test/kotlin/so/prelude/sdk/models/TargetTest.kt b/prelude-java-core/src/test/kotlin/so/prelude/sdk/models/TargetTest.kt new file mode 100644 index 00000000..113c9c50 --- /dev/null +++ b/prelude-java-core/src/test/kotlin/so/prelude/sdk/models/TargetTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package so.prelude.sdk.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import so.prelude.sdk.core.jsonMapper + +internal class TargetTest { + + @Test + fun create() { + val target = Target.builder().type(Target.Type.PHONE_NUMBER).value("+30123456789").build() + + assertThat(target.type()).isEqualTo(Target.Type.PHONE_NUMBER) + assertThat(target.value()).isEqualTo("+30123456789") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val target = Target.builder().type(Target.Type.PHONE_NUMBER).value("+30123456789").build() + + val roundtrippedTarget = + jsonMapper.readValue(jsonMapper.writeValueAsString(target), jacksonTypeRef()) + + assertThat(roundtrippedTarget).isEqualTo(target) + } +} diff --git a/prelude-java-core/src/test/kotlin/so/prelude/sdk/models/VerificationCheckParamsTest.kt b/prelude-java-core/src/test/kotlin/so/prelude/sdk/models/VerificationCheckParamsTest.kt index 224ac0bd..54bbec0b 100644 --- a/prelude-java-core/src/test/kotlin/so/prelude/sdk/models/VerificationCheckParamsTest.kt +++ b/prelude-java-core/src/test/kotlin/so/prelude/sdk/models/VerificationCheckParamsTest.kt @@ -11,12 +11,7 @@ internal class VerificationCheckParamsTest { fun create() { VerificationCheckParams.builder() .code("12345") - .target( - VerificationCheckParams.Target.builder() - .type(VerificationCheckParams.Target.Type.PHONE_NUMBER) - .value("+30123456789") - .build() - ) + .target(Target.builder().type(Target.Type.PHONE_NUMBER).value("+30123456789").build()) .psd2( VerificationCheckParams.Psd2.builder() .amount("99999.99") @@ -33,10 +28,7 @@ internal class VerificationCheckParamsTest { VerificationCheckParams.builder() .code("12345") .target( - VerificationCheckParams.Target.builder() - .type(VerificationCheckParams.Target.Type.PHONE_NUMBER) - .value("+30123456789") - .build() + Target.builder().type(Target.Type.PHONE_NUMBER).value("+30123456789").build() ) .psd2( VerificationCheckParams.Psd2.builder() @@ -52,10 +44,7 @@ internal class VerificationCheckParamsTest { assertThat(body.code()).isEqualTo("12345") assertThat(body.target()) .isEqualTo( - VerificationCheckParams.Target.builder() - .type(VerificationCheckParams.Target.Type.PHONE_NUMBER) - .value("+30123456789") - .build() + Target.builder().type(Target.Type.PHONE_NUMBER).value("+30123456789").build() ) assertThat(body.psd2()) .contains( @@ -73,10 +62,7 @@ internal class VerificationCheckParamsTest { VerificationCheckParams.builder() .code("12345") .target( - VerificationCheckParams.Target.builder() - .type(VerificationCheckParams.Target.Type.PHONE_NUMBER) - .value("+30123456789") - .build() + Target.builder().type(Target.Type.PHONE_NUMBER).value("+30123456789").build() ) .build() @@ -85,10 +71,7 @@ internal class VerificationCheckParamsTest { assertThat(body.code()).isEqualTo("12345") assertThat(body.target()) .isEqualTo( - VerificationCheckParams.Target.builder() - .type(VerificationCheckParams.Target.Type.PHONE_NUMBER) - .value("+30123456789") - .build() + Target.builder().type(Target.Type.PHONE_NUMBER).value("+30123456789").build() ) } } diff --git a/prelude-java-core/src/test/kotlin/so/prelude/sdk/models/VerificationCreateParamsTest.kt b/prelude-java-core/src/test/kotlin/so/prelude/sdk/models/VerificationCreateParamsTest.kt index 391e9e34..5b29df8a 100644 --- a/prelude-java-core/src/test/kotlin/so/prelude/sdk/models/VerificationCreateParamsTest.kt +++ b/prelude-java-core/src/test/kotlin/so/prelude/sdk/models/VerificationCreateParamsTest.kt @@ -11,12 +11,7 @@ internal class VerificationCreateParamsTest { @Test fun create() { VerificationCreateParams.builder() - .target( - VerificationCreateParams.Target.builder() - .type(VerificationCreateParams.Target.Type.PHONE_NUMBER) - .value("+30123456789") - .build() - ) + .target(Target.builder().type(Target.Type.PHONE_NUMBER).value("+30123456789").build()) .dispatchId("123e4567-e89b-12d3-a456-426614174000") .metadata( VerificationCreateParams.Metadata.builder().correlationId("correlation_id").build() @@ -49,11 +44,11 @@ internal class VerificationCreateParamsTest { .build() ) .signals( - VerificationCreateParams.Signals.builder() + Signals.builder() .appVersion("1.2.34") .deviceId("8F0B8FDD-C2CB-4387-B20A-56E9B2E5A0D2") .deviceModel("iPhone17,2") - .devicePlatform(VerificationCreateParams.Signals.DevicePlatform.IOS) + .devicePlatform(Signals.DevicePlatform.IOS) .existingUser(false) .ip("203.0.113.123") .isTrustedUser(false) @@ -72,10 +67,7 @@ internal class VerificationCreateParamsTest { val params = VerificationCreateParams.builder() .target( - VerificationCreateParams.Target.builder() - .type(VerificationCreateParams.Target.Type.PHONE_NUMBER) - .value("+30123456789") - .build() + Target.builder().type(Target.Type.PHONE_NUMBER).value("+30123456789").build() ) .dispatchId("123e4567-e89b-12d3-a456-426614174000") .metadata( @@ -113,11 +105,11 @@ internal class VerificationCreateParamsTest { .build() ) .signals( - VerificationCreateParams.Signals.builder() + Signals.builder() .appVersion("1.2.34") .deviceId("8F0B8FDD-C2CB-4387-B20A-56E9B2E5A0D2") .deviceModel("iPhone17,2") - .devicePlatform(VerificationCreateParams.Signals.DevicePlatform.IOS) + .devicePlatform(Signals.DevicePlatform.IOS) .existingUser(false) .ip("203.0.113.123") .isTrustedUser(false) @@ -134,10 +126,7 @@ internal class VerificationCreateParamsTest { assertThat(body.target()) .isEqualTo( - VerificationCreateParams.Target.builder() - .type(VerificationCreateParams.Target.Type.PHONE_NUMBER) - .value("+30123456789") - .build() + Target.builder().type(Target.Type.PHONE_NUMBER).value("+30123456789").build() ) assertThat(body.dispatchId()).contains("123e4567-e89b-12d3-a456-426614174000") assertThat(body.metadata()) @@ -174,11 +163,11 @@ internal class VerificationCreateParamsTest { ) assertThat(body.signals()) .contains( - VerificationCreateParams.Signals.builder() + Signals.builder() .appVersion("1.2.34") .deviceId("8F0B8FDD-C2CB-4387-B20A-56E9B2E5A0D2") .deviceModel("iPhone17,2") - .devicePlatform(VerificationCreateParams.Signals.DevicePlatform.IOS) + .devicePlatform(Signals.DevicePlatform.IOS) .existingUser(false) .ip("203.0.113.123") .isTrustedUser(false) @@ -196,10 +185,7 @@ internal class VerificationCreateParamsTest { val params = VerificationCreateParams.builder() .target( - VerificationCreateParams.Target.builder() - .type(VerificationCreateParams.Target.Type.PHONE_NUMBER) - .value("+30123456789") - .build() + Target.builder().type(Target.Type.PHONE_NUMBER).value("+30123456789").build() ) .build() @@ -207,10 +193,7 @@ internal class VerificationCreateParamsTest { assertThat(body.target()) .isEqualTo( - VerificationCreateParams.Target.builder() - .type(VerificationCreateParams.Target.Type.PHONE_NUMBER) - .value("+30123456789") - .build() + Target.builder().type(Target.Type.PHONE_NUMBER).value("+30123456789").build() ) } } diff --git a/prelude-java-core/src/test/kotlin/so/prelude/sdk/models/VerificationManagementSandboxAddPhoneNumberParamsTest.kt b/prelude-java-core/src/test/kotlin/so/prelude/sdk/models/VerificationManagementSandboxAddPhoneNumberParamsTest.kt new file mode 100644 index 00000000..5b7d4e64 --- /dev/null +++ b/prelude-java-core/src/test/kotlin/so/prelude/sdk/models/VerificationManagementSandboxAddPhoneNumberParamsTest.kt @@ -0,0 +1,31 @@ +// File generated from our OpenAPI spec by Stainless. + +package so.prelude.sdk.models + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class VerificationManagementSandboxAddPhoneNumberParamsTest { + + @Test + fun create() { + VerificationManagementSandboxAddPhoneNumberParams.builder() + .attemptCode("123456") + .phoneNumber("+30123456789") + .build() + } + + @Test + fun body() { + val params = + VerificationManagementSandboxAddPhoneNumberParams.builder() + .attemptCode("123456") + .phoneNumber("+30123456789") + .build() + + val body = params._body() + + assertThat(body.attemptCode()).isEqualTo("123456") + assertThat(body.phoneNumber()).isEqualTo("+30123456789") + } +} diff --git a/prelude-java-core/src/test/kotlin/so/prelude/sdk/models/VerificationManagementSandboxAddPhoneNumberResponseTest.kt b/prelude-java-core/src/test/kotlin/so/prelude/sdk/models/VerificationManagementSandboxAddPhoneNumberResponseTest.kt new file mode 100644 index 00000000..67f50e3a --- /dev/null +++ b/prelude-java-core/src/test/kotlin/so/prelude/sdk/models/VerificationManagementSandboxAddPhoneNumberResponseTest.kt @@ -0,0 +1,44 @@ +// File generated from our OpenAPI spec by Stainless. + +package so.prelude.sdk.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import so.prelude.sdk.core.jsonMapper + +internal class VerificationManagementSandboxAddPhoneNumberResponseTest { + + @Test + fun create() { + val verificationManagementSandboxAddPhoneNumberResponse = + VerificationManagementSandboxAddPhoneNumberResponse.builder() + .attemptCode("123456") + .phoneNumber("+30123456789") + .build() + + assertThat(verificationManagementSandboxAddPhoneNumberResponse.attemptCode()) + .isEqualTo("123456") + assertThat(verificationManagementSandboxAddPhoneNumberResponse.phoneNumber()) + .isEqualTo("+30123456789") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val verificationManagementSandboxAddPhoneNumberResponse = + VerificationManagementSandboxAddPhoneNumberResponse.builder() + .attemptCode("123456") + .phoneNumber("+30123456789") + .build() + + val roundtrippedVerificationManagementSandboxAddPhoneNumberResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(verificationManagementSandboxAddPhoneNumberResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedVerificationManagementSandboxAddPhoneNumberResponse) + .isEqualTo(verificationManagementSandboxAddPhoneNumberResponse) + } +} diff --git a/prelude-java-core/src/test/kotlin/so/prelude/sdk/models/VerificationManagementSandboxDeletePhoneNumberParamsTest.kt b/prelude-java-core/src/test/kotlin/so/prelude/sdk/models/VerificationManagementSandboxDeletePhoneNumberParamsTest.kt new file mode 100644 index 00000000..f1030509 --- /dev/null +++ b/prelude-java-core/src/test/kotlin/so/prelude/sdk/models/VerificationManagementSandboxDeletePhoneNumberParamsTest.kt @@ -0,0 +1,28 @@ +// File generated from our OpenAPI spec by Stainless. + +package so.prelude.sdk.models + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class VerificationManagementSandboxDeletePhoneNumberParamsTest { + + @Test + fun create() { + VerificationManagementSandboxDeletePhoneNumberParams.builder() + .phoneNumber("+12065550100") + .build() + } + + @Test + fun pathParams() { + val params = + VerificationManagementSandboxDeletePhoneNumberParams.builder() + .phoneNumber("+12065550100") + .build() + + assertThat(params._pathParam(0)).isEqualTo("+12065550100") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/prelude-java-core/src/test/kotlin/so/prelude/sdk/models/VerificationManagementSandboxDeletePhoneNumberResponseTest.kt b/prelude-java-core/src/test/kotlin/so/prelude/sdk/models/VerificationManagementSandboxDeletePhoneNumberResponseTest.kt new file mode 100644 index 00000000..f9bc3d62 --- /dev/null +++ b/prelude-java-core/src/test/kotlin/so/prelude/sdk/models/VerificationManagementSandboxDeletePhoneNumberResponseTest.kt @@ -0,0 +1,42 @@ +// File generated from our OpenAPI spec by Stainless. + +package so.prelude.sdk.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import so.prelude.sdk.core.jsonMapper + +internal class VerificationManagementSandboxDeletePhoneNumberResponseTest { + + @Test + fun create() { + val verificationManagementSandboxDeletePhoneNumberResponse = + VerificationManagementSandboxDeletePhoneNumberResponse.builder() + .phoneNumber("+30123456789") + .build() + + assertThat(verificationManagementSandboxDeletePhoneNumberResponse.phoneNumber()) + .isEqualTo("+30123456789") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val verificationManagementSandboxDeletePhoneNumberResponse = + VerificationManagementSandboxDeletePhoneNumberResponse.builder() + .phoneNumber("+30123456789") + .build() + + val roundtrippedVerificationManagementSandboxDeletePhoneNumberResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString( + verificationManagementSandboxDeletePhoneNumberResponse + ), + jacksonTypeRef(), + ) + + assertThat(roundtrippedVerificationManagementSandboxDeletePhoneNumberResponse) + .isEqualTo(verificationManagementSandboxDeletePhoneNumberResponse) + } +} diff --git a/prelude-java-core/src/test/kotlin/so/prelude/sdk/models/VerificationManagementSandboxListPhoneNumbersParamsTest.kt b/prelude-java-core/src/test/kotlin/so/prelude/sdk/models/VerificationManagementSandboxListPhoneNumbersParamsTest.kt new file mode 100644 index 00000000..4005c755 --- /dev/null +++ b/prelude-java-core/src/test/kotlin/so/prelude/sdk/models/VerificationManagementSandboxListPhoneNumbersParamsTest.kt @@ -0,0 +1,13 @@ +// File generated from our OpenAPI spec by Stainless. + +package so.prelude.sdk.models + +import org.junit.jupiter.api.Test + +internal class VerificationManagementSandboxListPhoneNumbersParamsTest { + + @Test + fun create() { + VerificationManagementSandboxListPhoneNumbersParams.builder().build() + } +} diff --git a/prelude-java-core/src/test/kotlin/so/prelude/sdk/models/VerificationManagementSandboxListPhoneNumbersResponseTest.kt b/prelude-java-core/src/test/kotlin/so/prelude/sdk/models/VerificationManagementSandboxListPhoneNumbersResponseTest.kt new file mode 100644 index 00000000..3b06be21 --- /dev/null +++ b/prelude-java-core/src/test/kotlin/so/prelude/sdk/models/VerificationManagementSandboxListPhoneNumbersResponseTest.kt @@ -0,0 +1,61 @@ +// File generated from our OpenAPI spec by Stainless. + +package so.prelude.sdk.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import so.prelude.sdk.core.jsonMapper + +internal class VerificationManagementSandboxListPhoneNumbersResponseTest { + + @Test + fun create() { + val verificationManagementSandboxListPhoneNumbersResponse = + VerificationManagementSandboxListPhoneNumbersResponse.builder() + .addPhoneNumber( + VerificationManagementSandboxListPhoneNumbersResponse.PhoneNumber.builder() + .attemptCode("123456") + .createdAt(OffsetDateTime.parse("2024-01-01T12:00:00Z")) + .phoneNumber("+30123456789") + .build() + ) + .build() + + assertThat(verificationManagementSandboxListPhoneNumbersResponse.phoneNumbers()) + .containsExactly( + VerificationManagementSandboxListPhoneNumbersResponse.PhoneNumber.builder() + .attemptCode("123456") + .createdAt(OffsetDateTime.parse("2024-01-01T12:00:00Z")) + .phoneNumber("+30123456789") + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val verificationManagementSandboxListPhoneNumbersResponse = + VerificationManagementSandboxListPhoneNumbersResponse.builder() + .addPhoneNumber( + VerificationManagementSandboxListPhoneNumbersResponse.PhoneNumber.builder() + .attemptCode("123456") + .createdAt(OffsetDateTime.parse("2024-01-01T12:00:00Z")) + .phoneNumber("+30123456789") + .build() + ) + .build() + + val roundtrippedVerificationManagementSandboxListPhoneNumbersResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString( + verificationManagementSandboxListPhoneNumbersResponse + ), + jacksonTypeRef(), + ) + + assertThat(roundtrippedVerificationManagementSandboxListPhoneNumbersResponse) + .isEqualTo(verificationManagementSandboxListPhoneNumbersResponse) + } +} diff --git a/prelude-java-core/src/test/kotlin/so/prelude/sdk/models/VerificationPhoneHistoryListParamsTest.kt b/prelude-java-core/src/test/kotlin/so/prelude/sdk/models/VerificationPhoneHistoryListParamsTest.kt new file mode 100644 index 00000000..cf96b6f2 --- /dev/null +++ b/prelude-java-core/src/test/kotlin/so/prelude/sdk/models/VerificationPhoneHistoryListParamsTest.kt @@ -0,0 +1,77 @@ +// File generated from our OpenAPI spec by Stainless. + +package so.prelude.sdk.models + +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import so.prelude.sdk.core.http.QueryParams + +internal class VerificationPhoneHistoryListParamsTest { + + @Test + fun create() { + VerificationPhoneHistoryListParams.builder() + .addChannel(VerificationPhoneHistoryListParams.Channel.SMS) + .cursor("cursor") + .devicePlatform(VerificationPhoneHistoryListParams.DevicePlatform.ANDROID) + .from(OffsetDateTime.parse("2026-09-01T00:00:00Z")) + .limit(1L) + .maxAttempts(0L) + .minAttempts(0L) + .phoneNumber("+33612345678") + .region("FR") + .status(VerificationPhoneHistoryListParams.Status.CONVERTED) + .templateId("template_01jc0t6fwwfgfsq1md24mhyztj") + .to(OffsetDateTime.parse("2026-09-08T00:00:00Z")) + .build() + } + + @Test + fun queryParams() { + val params = + VerificationPhoneHistoryListParams.builder() + .addChannel(VerificationPhoneHistoryListParams.Channel.SMS) + .cursor("cursor") + .devicePlatform(VerificationPhoneHistoryListParams.DevicePlatform.ANDROID) + .from(OffsetDateTime.parse("2026-09-01T00:00:00Z")) + .limit(1L) + .maxAttempts(0L) + .minAttempts(0L) + .phoneNumber("+33612345678") + .region("FR") + .status(VerificationPhoneHistoryListParams.Status.CONVERTED) + .templateId("template_01jc0t6fwwfgfsq1md24mhyztj") + .to(OffsetDateTime.parse("2026-09-08T00:00:00Z")) + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("channels", listOf("sms").joinToString(",")) + .put("cursor", "cursor") + .put("device_platform", "android") + .put("from", "2026-09-01T00:00:00Z") + .put("limit", "1") + .put("max_attempts", "0") + .put("min_attempts", "0") + .put("phone_number", "+33612345678") + .put("region", "FR") + .put("status", "converted") + .put("template_id", "template_01jc0t6fwwfgfsq1md24mhyztj") + .put("to", "2026-09-08T00:00:00Z") + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = VerificationPhoneHistoryListParams.builder().build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/prelude-java-core/src/test/kotlin/so/prelude/sdk/models/VerificationPhoneHistoryListResponseTest.kt b/prelude-java-core/src/test/kotlin/so/prelude/sdk/models/VerificationPhoneHistoryListResponseTest.kt new file mode 100644 index 00000000..3a139459 --- /dev/null +++ b/prelude-java-core/src/test/kotlin/so/prelude/sdk/models/VerificationPhoneHistoryListResponseTest.kt @@ -0,0 +1,150 @@ +// File generated from our OpenAPI spec by Stainless. + +package so.prelude.sdk.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import so.prelude.sdk.core.jsonMapper + +internal class VerificationPhoneHistoryListResponseTest { + + @Test + fun create() { + val verificationPhoneHistoryListResponse = + VerificationPhoneHistoryListResponse.builder() + .addVerification( + VerificationPhoneHistoryListResponse.Verification.builder() + .id("vrf_01jc0t6fwwfgfsq1md24mhyztj") + .addChannel( + VerificationPhoneHistoryListResponse.Verification.Channel.builder() + .channel( + VerificationPhoneHistoryListResponse.Verification.Channel + .InnerChannel + .SMS + ) + .converted(true) + .build() + ) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .delivered(true) + .phoneNumber("+33612345678") + .status(VerificationPhoneHistoryListResponse.Verification.Status.CONVERTED) + .attempts(0L) + .convertedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .cost( + PhoneVerificationMoney.builder().amount("0.042").currency("EUR").build() + ) + .devicePlatform( + VerificationPhoneHistoryListResponse.Verification.DevicePlatform.ANDROID + ) + .phoneNumberCondition( + VerificationPhoneHistoryListResponse.Verification.PhoneNumberCondition + .ALLOW_LISTED + ) + .signalsHashStatus( + VerificationPhoneHistoryListResponse.Verification.SignalsHashStatus + .VALID + ) + .build() + ) + .nextCursor( + "MIZw2XwtkcEcC5SKsMEfSx6a3XAgW-Ct6waU8NCqUkAvFxz41DJbjQIkqHWJS1JY6-it7ZsZHFYN3luFH8yTdCAB" + ) + .build() + + assertThat(verificationPhoneHistoryListResponse.verifications()) + .containsExactly( + VerificationPhoneHistoryListResponse.Verification.builder() + .id("vrf_01jc0t6fwwfgfsq1md24mhyztj") + .addChannel( + VerificationPhoneHistoryListResponse.Verification.Channel.builder() + .channel( + VerificationPhoneHistoryListResponse.Verification.Channel + .InnerChannel + .SMS + ) + .converted(true) + .build() + ) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .delivered(true) + .phoneNumber("+33612345678") + .status(VerificationPhoneHistoryListResponse.Verification.Status.CONVERTED) + .attempts(0L) + .convertedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .cost(PhoneVerificationMoney.builder().amount("0.042").currency("EUR").build()) + .devicePlatform( + VerificationPhoneHistoryListResponse.Verification.DevicePlatform.ANDROID + ) + .phoneNumberCondition( + VerificationPhoneHistoryListResponse.Verification.PhoneNumberCondition + .ALLOW_LISTED + ) + .signalsHashStatus( + VerificationPhoneHistoryListResponse.Verification.SignalsHashStatus.VALID + ) + .build() + ) + assertThat(verificationPhoneHistoryListResponse.nextCursor()) + .contains( + "MIZw2XwtkcEcC5SKsMEfSx6a3XAgW-Ct6waU8NCqUkAvFxz41DJbjQIkqHWJS1JY6-it7ZsZHFYN3luFH8yTdCAB" + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val verificationPhoneHistoryListResponse = + VerificationPhoneHistoryListResponse.builder() + .addVerification( + VerificationPhoneHistoryListResponse.Verification.builder() + .id("vrf_01jc0t6fwwfgfsq1md24mhyztj") + .addChannel( + VerificationPhoneHistoryListResponse.Verification.Channel.builder() + .channel( + VerificationPhoneHistoryListResponse.Verification.Channel + .InnerChannel + .SMS + ) + .converted(true) + .build() + ) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .delivered(true) + .phoneNumber("+33612345678") + .status(VerificationPhoneHistoryListResponse.Verification.Status.CONVERTED) + .attempts(0L) + .convertedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .cost( + PhoneVerificationMoney.builder().amount("0.042").currency("EUR").build() + ) + .devicePlatform( + VerificationPhoneHistoryListResponse.Verification.DevicePlatform.ANDROID + ) + .phoneNumberCondition( + VerificationPhoneHistoryListResponse.Verification.PhoneNumberCondition + .ALLOW_LISTED + ) + .signalsHashStatus( + VerificationPhoneHistoryListResponse.Verification.SignalsHashStatus + .VALID + ) + .build() + ) + .nextCursor( + "MIZw2XwtkcEcC5SKsMEfSx6a3XAgW-Ct6waU8NCqUkAvFxz41DJbjQIkqHWJS1JY6-it7ZsZHFYN3luFH8yTdCAB" + ) + .build() + + val roundtrippedVerificationPhoneHistoryListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(verificationPhoneHistoryListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedVerificationPhoneHistoryListResponse) + .isEqualTo(verificationPhoneHistoryListResponse) + } +} diff --git a/prelude-java-core/src/test/kotlin/so/prelude/sdk/models/VerificationPhoneHistoryRetrieveParamsTest.kt b/prelude-java-core/src/test/kotlin/so/prelude/sdk/models/VerificationPhoneHistoryRetrieveParamsTest.kt new file mode 100644 index 00000000..0f7becee --- /dev/null +++ b/prelude-java-core/src/test/kotlin/so/prelude/sdk/models/VerificationPhoneHistoryRetrieveParamsTest.kt @@ -0,0 +1,28 @@ +// File generated from our OpenAPI spec by Stainless. + +package so.prelude.sdk.models + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class VerificationPhoneHistoryRetrieveParamsTest { + + @Test + fun create() { + VerificationPhoneHistoryRetrieveParams.builder() + .id("vrf_01jc0t6fwwfgfsq1md24mhyztj") + .build() + } + + @Test + fun pathParams() { + val params = + VerificationPhoneHistoryRetrieveParams.builder() + .id("vrf_01jc0t6fwwfgfsq1md24mhyztj") + .build() + + assertThat(params._pathParam(0)).isEqualTo("vrf_01jc0t6fwwfgfsq1md24mhyztj") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/prelude-java-core/src/test/kotlin/so/prelude/sdk/models/VerificationPhoneHistoryRetrieveResponseTest.kt b/prelude-java-core/src/test/kotlin/so/prelude/sdk/models/VerificationPhoneHistoryRetrieveResponseTest.kt new file mode 100644 index 00000000..3e51d763 --- /dev/null +++ b/prelude-java-core/src/test/kotlin/so/prelude/sdk/models/VerificationPhoneHistoryRetrieveResponseTest.kt @@ -0,0 +1,632 @@ +// File generated from our OpenAPI spec by Stainless. + +package so.prelude.sdk.models + +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 +import so.prelude.sdk.core.jsonMapper + +internal class VerificationPhoneHistoryRetrieveResponseTest { + + @Test + fun create() { + val verificationPhoneHistoryRetrieveResponse = + VerificationPhoneHistoryRetrieveResponse.builder() + .id("vrf_01jc0t6fwwfgfsq1md24mhyztj") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .expiresAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .phoneNumber("+33612345678") + .status(VerificationPhoneHistoryRetrieveResponse.Status.CONVERTED) + .appVersion("app_version") + .addBlockReason( + VerificationPhoneHistoryRetrieveResponse.BlockReason.BEHAVIORAL_PATTERN + ) + .carrier(PhoneVerificationCarrier.builder().mccmnc("208-01").name("Orange").build()) + .correlationId("correlation_id") + .deviceModel("iPhone15,2") + .devicePlatform(VerificationPhoneHistoryRetrieveResponse.DevicePlatform.ANDROID) + .ipAddress("ip_address") + .ipAddressRegion("FR") + .ipDistanceMeters(0L) + .lifecycle( + VerificationPhoneHistoryRetrieveResponse.Lifecycle.builder() + .addEvent( + VerificationPhoneHistoryRetrieveResponse.Lifecycle.Event.builder() + .type( + VerificationPhoneHistoryRetrieveResponse.Lifecycle.Event.Type + .CREATE + ) + .attempt( + VerificationPhoneHistoryRetrieveResponse.Lifecycle.Event.Attempt + .builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .carrier( + PhoneVerificationCarrier.builder() + .mccmnc("208-01") + .name("Orange") + .build() + ) + .channel( + VerificationPhoneHistoryRetrieveResponse.Lifecycle.Event + .Attempt + .Channel + .SMS + ) + .content("content") + .cost( + PhoneVerificationMoney.builder() + .amount("0.042") + .currency("EUR") + .build() + ) + .addDeliveryEvent( + VerificationPhoneHistoryRetrieveResponse.Lifecycle.Event + .Attempt + .DeliveryEvent + .builder() + .receivedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .status( + VerificationPhoneHistoryRetrieveResponse + .Lifecycle + .Event + .Attempt + .DeliveryEvent + .Status + .UNKNOWN + ) + .build() + ) + .deliveryStatus( + VerificationPhoneHistoryRetrieveResponse.Lifecycle.Event + .Attempt + .DeliveryStatus + .UNKNOWN + ) + .preferredChannel( + VerificationPhoneHistoryRetrieveResponse.Lifecycle.Event + .Attempt + .PreferredChannel + .SMS + ) + .status( + VerificationPhoneHistoryRetrieveResponse.Lifecycle.Event + .Attempt + .Status + .SUCCEEDED + ) + .trigger( + VerificationPhoneHistoryRetrieveResponse.Lifecycle.Event + .Attempt + .Trigger + .INITIAL + ) + .build() + ) + .check( + VerificationPhoneHistoryRetrieveResponse.Lifecycle.Event.Check + .builder() + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .isValid_(true) + .channel( + VerificationPhoneHistoryRetrieveResponse.Lifecycle.Event + .Check + .Channel + .SMS + ) + .psd2Info( + VerificationPhoneHistoryRetrieveResponse.Lifecycle.Event + .Check + .Psd2Info + .builder() + .expectedTransaction( + PhoneVerificationPsd2Transaction.builder() + .amount( + PhoneVerificationMoney.builder() + .amount("0.042") + .currency("EUR") + .build() + ) + .recipient("recipient") + .build() + ) + .receivedTransaction( + PhoneVerificationPsd2Transaction.builder() + .amount( + PhoneVerificationMoney.builder() + .amount("0.042") + .currency("EUR") + .build() + ) + .recipient("recipient") + .build() + ) + .build() + ) + .statusDetail( + VerificationPhoneHistoryRetrieveResponse.Lifecycle.Event + .Check + .StatusDetail + .EXPIRED_ATTEMPT + ) + .value("value") + .build() + ) + .create( + VerificationPhoneHistoryRetrieveResponse.Lifecycle.Event.Create + .builder() + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .cost( + PhoneVerificationMoney.builder() + .amount("0.042") + .currency("EUR") + .build() + ) + .build() + ) + .signals( + VerificationPhoneHistoryRetrieveResponse.Lifecycle.Event.Signals + .builder() + .receivedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .expiredAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .status( + VerificationPhoneHistoryRetrieveResponse.Lifecycle.Event + .Signals + .Status + .VALID + ) + .build() + ) + .build() + ) + .totalCost( + PhoneVerificationMoney.builder().amount("0.042").currency("EUR").build() + ) + .undeliverableRouteCount(0L) + .build() + ) + .phoneNumberCondition( + VerificationPhoneHistoryRetrieveResponse.PhoneNumberCondition.ALLOW_LISTED + ) + .phoneNumberCurrentCondition( + VerificationPhoneHistoryRetrieveResponse.PhoneNumberCurrentCondition + .ALLOW_LISTED + ) + .phoneNumberRegion("FR") + .signals( + VerificationPhoneHistoryRetrieveResponse.Signals.builder() + .isTrustedUser(true) + .deviceId("device_id") + .ja4Fingerprint("ja4_fingerprint") + .osVersion("os_version") + .userAgent("user_agent") + .build() + ) + .signalsHashStatus(VerificationPhoneHistoryRetrieveResponse.SignalsHashStatus.VALID) + .templateId("template_id") + .build() + + assertThat(verificationPhoneHistoryRetrieveResponse.id()) + .isEqualTo("vrf_01jc0t6fwwfgfsq1md24mhyztj") + assertThat(verificationPhoneHistoryRetrieveResponse.createdAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(verificationPhoneHistoryRetrieveResponse.expiresAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(verificationPhoneHistoryRetrieveResponse.phoneNumber()).isEqualTo("+33612345678") + assertThat(verificationPhoneHistoryRetrieveResponse.status()) + .isEqualTo(VerificationPhoneHistoryRetrieveResponse.Status.CONVERTED) + assertThat(verificationPhoneHistoryRetrieveResponse.appVersion()).contains("app_version") + assertThat(verificationPhoneHistoryRetrieveResponse.blockReasons().getOrNull()) + .containsExactly( + VerificationPhoneHistoryRetrieveResponse.BlockReason.BEHAVIORAL_PATTERN + ) + assertThat(verificationPhoneHistoryRetrieveResponse.carrier()) + .contains(PhoneVerificationCarrier.builder().mccmnc("208-01").name("Orange").build()) + assertThat(verificationPhoneHistoryRetrieveResponse.correlationId()) + .contains("correlation_id") + assertThat(verificationPhoneHistoryRetrieveResponse.deviceModel()).contains("iPhone15,2") + assertThat(verificationPhoneHistoryRetrieveResponse.devicePlatform()) + .contains(VerificationPhoneHistoryRetrieveResponse.DevicePlatform.ANDROID) + assertThat(verificationPhoneHistoryRetrieveResponse.ipAddress()).contains("ip_address") + assertThat(verificationPhoneHistoryRetrieveResponse.ipAddressRegion()).contains("FR") + assertThat(verificationPhoneHistoryRetrieveResponse.ipDistanceMeters()).contains(0L) + assertThat(verificationPhoneHistoryRetrieveResponse.lifecycle()) + .contains( + VerificationPhoneHistoryRetrieveResponse.Lifecycle.builder() + .addEvent( + VerificationPhoneHistoryRetrieveResponse.Lifecycle.Event.builder() + .type( + VerificationPhoneHistoryRetrieveResponse.Lifecycle.Event.Type.CREATE + ) + .attempt( + VerificationPhoneHistoryRetrieveResponse.Lifecycle.Event.Attempt + .builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .carrier( + PhoneVerificationCarrier.builder() + .mccmnc("208-01") + .name("Orange") + .build() + ) + .channel( + VerificationPhoneHistoryRetrieveResponse.Lifecycle.Event + .Attempt + .Channel + .SMS + ) + .content("content") + .cost( + PhoneVerificationMoney.builder() + .amount("0.042") + .currency("EUR") + .build() + ) + .addDeliveryEvent( + VerificationPhoneHistoryRetrieveResponse.Lifecycle.Event + .Attempt + .DeliveryEvent + .builder() + .receivedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .status( + VerificationPhoneHistoryRetrieveResponse.Lifecycle + .Event + .Attempt + .DeliveryEvent + .Status + .UNKNOWN + ) + .build() + ) + .deliveryStatus( + VerificationPhoneHistoryRetrieveResponse.Lifecycle.Event + .Attempt + .DeliveryStatus + .UNKNOWN + ) + .preferredChannel( + VerificationPhoneHistoryRetrieveResponse.Lifecycle.Event + .Attempt + .PreferredChannel + .SMS + ) + .status( + VerificationPhoneHistoryRetrieveResponse.Lifecycle.Event + .Attempt + .Status + .SUCCEEDED + ) + .trigger( + VerificationPhoneHistoryRetrieveResponse.Lifecycle.Event + .Attempt + .Trigger + .INITIAL + ) + .build() + ) + .check( + VerificationPhoneHistoryRetrieveResponse.Lifecycle.Event.Check + .builder() + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .isValid_(true) + .channel( + VerificationPhoneHistoryRetrieveResponse.Lifecycle.Event + .Check + .Channel + .SMS + ) + .psd2Info( + VerificationPhoneHistoryRetrieveResponse.Lifecycle.Event + .Check + .Psd2Info + .builder() + .expectedTransaction( + PhoneVerificationPsd2Transaction.builder() + .amount( + PhoneVerificationMoney.builder() + .amount("0.042") + .currency("EUR") + .build() + ) + .recipient("recipient") + .build() + ) + .receivedTransaction( + PhoneVerificationPsd2Transaction.builder() + .amount( + PhoneVerificationMoney.builder() + .amount("0.042") + .currency("EUR") + .build() + ) + .recipient("recipient") + .build() + ) + .build() + ) + .statusDetail( + VerificationPhoneHistoryRetrieveResponse.Lifecycle.Event + .Check + .StatusDetail + .EXPIRED_ATTEMPT + ) + .value("value") + .build() + ) + .create( + VerificationPhoneHistoryRetrieveResponse.Lifecycle.Event.Create + .builder() + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .cost( + PhoneVerificationMoney.builder() + .amount("0.042") + .currency("EUR") + .build() + ) + .build() + ) + .signals( + VerificationPhoneHistoryRetrieveResponse.Lifecycle.Event.Signals + .builder() + .receivedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .expiredAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .status( + VerificationPhoneHistoryRetrieveResponse.Lifecycle.Event + .Signals + .Status + .VALID + ) + .build() + ) + .build() + ) + .totalCost( + PhoneVerificationMoney.builder().amount("0.042").currency("EUR").build() + ) + .undeliverableRouteCount(0L) + .build() + ) + assertThat(verificationPhoneHistoryRetrieveResponse.phoneNumberCondition()) + .contains(VerificationPhoneHistoryRetrieveResponse.PhoneNumberCondition.ALLOW_LISTED) + assertThat(verificationPhoneHistoryRetrieveResponse.phoneNumberCurrentCondition()) + .contains( + VerificationPhoneHistoryRetrieveResponse.PhoneNumberCurrentCondition.ALLOW_LISTED + ) + assertThat(verificationPhoneHistoryRetrieveResponse.phoneNumberRegion()).contains("FR") + assertThat(verificationPhoneHistoryRetrieveResponse.signals()) + .contains( + VerificationPhoneHistoryRetrieveResponse.Signals.builder() + .isTrustedUser(true) + .deviceId("device_id") + .ja4Fingerprint("ja4_fingerprint") + .osVersion("os_version") + .userAgent("user_agent") + .build() + ) + assertThat(verificationPhoneHistoryRetrieveResponse.signalsHashStatus()) + .contains(VerificationPhoneHistoryRetrieveResponse.SignalsHashStatus.VALID) + assertThat(verificationPhoneHistoryRetrieveResponse.templateId()).contains("template_id") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val verificationPhoneHistoryRetrieveResponse = + VerificationPhoneHistoryRetrieveResponse.builder() + .id("vrf_01jc0t6fwwfgfsq1md24mhyztj") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .expiresAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .phoneNumber("+33612345678") + .status(VerificationPhoneHistoryRetrieveResponse.Status.CONVERTED) + .appVersion("app_version") + .addBlockReason( + VerificationPhoneHistoryRetrieveResponse.BlockReason.BEHAVIORAL_PATTERN + ) + .carrier(PhoneVerificationCarrier.builder().mccmnc("208-01").name("Orange").build()) + .correlationId("correlation_id") + .deviceModel("iPhone15,2") + .devicePlatform(VerificationPhoneHistoryRetrieveResponse.DevicePlatform.ANDROID) + .ipAddress("ip_address") + .ipAddressRegion("FR") + .ipDistanceMeters(0L) + .lifecycle( + VerificationPhoneHistoryRetrieveResponse.Lifecycle.builder() + .addEvent( + VerificationPhoneHistoryRetrieveResponse.Lifecycle.Event.builder() + .type( + VerificationPhoneHistoryRetrieveResponse.Lifecycle.Event.Type + .CREATE + ) + .attempt( + VerificationPhoneHistoryRetrieveResponse.Lifecycle.Event.Attempt + .builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .carrier( + PhoneVerificationCarrier.builder() + .mccmnc("208-01") + .name("Orange") + .build() + ) + .channel( + VerificationPhoneHistoryRetrieveResponse.Lifecycle.Event + .Attempt + .Channel + .SMS + ) + .content("content") + .cost( + PhoneVerificationMoney.builder() + .amount("0.042") + .currency("EUR") + .build() + ) + .addDeliveryEvent( + VerificationPhoneHistoryRetrieveResponse.Lifecycle.Event + .Attempt + .DeliveryEvent + .builder() + .receivedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .status( + VerificationPhoneHistoryRetrieveResponse + .Lifecycle + .Event + .Attempt + .DeliveryEvent + .Status + .UNKNOWN + ) + .build() + ) + .deliveryStatus( + VerificationPhoneHistoryRetrieveResponse.Lifecycle.Event + .Attempt + .DeliveryStatus + .UNKNOWN + ) + .preferredChannel( + VerificationPhoneHistoryRetrieveResponse.Lifecycle.Event + .Attempt + .PreferredChannel + .SMS + ) + .status( + VerificationPhoneHistoryRetrieveResponse.Lifecycle.Event + .Attempt + .Status + .SUCCEEDED + ) + .trigger( + VerificationPhoneHistoryRetrieveResponse.Lifecycle.Event + .Attempt + .Trigger + .INITIAL + ) + .build() + ) + .check( + VerificationPhoneHistoryRetrieveResponse.Lifecycle.Event.Check + .builder() + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .isValid_(true) + .channel( + VerificationPhoneHistoryRetrieveResponse.Lifecycle.Event + .Check + .Channel + .SMS + ) + .psd2Info( + VerificationPhoneHistoryRetrieveResponse.Lifecycle.Event + .Check + .Psd2Info + .builder() + .expectedTransaction( + PhoneVerificationPsd2Transaction.builder() + .amount( + PhoneVerificationMoney.builder() + .amount("0.042") + .currency("EUR") + .build() + ) + .recipient("recipient") + .build() + ) + .receivedTransaction( + PhoneVerificationPsd2Transaction.builder() + .amount( + PhoneVerificationMoney.builder() + .amount("0.042") + .currency("EUR") + .build() + ) + .recipient("recipient") + .build() + ) + .build() + ) + .statusDetail( + VerificationPhoneHistoryRetrieveResponse.Lifecycle.Event + .Check + .StatusDetail + .EXPIRED_ATTEMPT + ) + .value("value") + .build() + ) + .create( + VerificationPhoneHistoryRetrieveResponse.Lifecycle.Event.Create + .builder() + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .cost( + PhoneVerificationMoney.builder() + .amount("0.042") + .currency("EUR") + .build() + ) + .build() + ) + .signals( + VerificationPhoneHistoryRetrieveResponse.Lifecycle.Event.Signals + .builder() + .receivedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .expiredAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .status( + VerificationPhoneHistoryRetrieveResponse.Lifecycle.Event + .Signals + .Status + .VALID + ) + .build() + ) + .build() + ) + .totalCost( + PhoneVerificationMoney.builder().amount("0.042").currency("EUR").build() + ) + .undeliverableRouteCount(0L) + .build() + ) + .phoneNumberCondition( + VerificationPhoneHistoryRetrieveResponse.PhoneNumberCondition.ALLOW_LISTED + ) + .phoneNumberCurrentCondition( + VerificationPhoneHistoryRetrieveResponse.PhoneNumberCurrentCondition + .ALLOW_LISTED + ) + .phoneNumberRegion("FR") + .signals( + VerificationPhoneHistoryRetrieveResponse.Signals.builder() + .isTrustedUser(true) + .deviceId("device_id") + .ja4Fingerprint("ja4_fingerprint") + .osVersion("os_version") + .userAgent("user_agent") + .build() + ) + .signalsHashStatus(VerificationPhoneHistoryRetrieveResponse.SignalsHashStatus.VALID) + .templateId("template_id") + .build() + + val roundtrippedVerificationPhoneHistoryRetrieveResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(verificationPhoneHistoryRetrieveResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedVerificationPhoneHistoryRetrieveResponse) + .isEqualTo(verificationPhoneHistoryRetrieveResponse) + } +} diff --git a/prelude-java-core/src/test/kotlin/so/prelude/sdk/models/WatchEvaluateParamsTest.kt b/prelude-java-core/src/test/kotlin/so/prelude/sdk/models/WatchEvaluateParamsTest.kt new file mode 100644 index 00000000..2cb80291 --- /dev/null +++ b/prelude-java-core/src/test/kotlin/so/prelude/sdk/models/WatchEvaluateParamsTest.kt @@ -0,0 +1,127 @@ +// File generated from our OpenAPI spec by Stainless. + +package so.prelude.sdk.models + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import so.prelude.sdk.core.JsonValue + +internal class WatchEvaluateParamsTest { + + @Test + fun create() { + WatchEvaluateParams.builder() + .flowId("flo_01jc0t6fwwfgfsq1md24mhyztj") + .target(Target.builder().type(Target.Type.PHONE_NUMBER).value("+30123456789").build()) + .attributes( + WatchEvaluateParams.Attributes.builder() + .putAdditionalProperty("plan_tier", JsonValue.from("free")) + .putAdditionalProperty("account_age_days", JsonValue.from("3")) + .build() + ) + .dispatchId("123e4567-e89b-12d3-a456-426614174000") + .signals( + Signals.builder() + .appVersion("1.2.34") + .deviceId("8F0B8FDD-C2CB-4387-B20A-56E9B2E5A0D2") + .deviceModel("iPhone17,2") + .devicePlatform(Signals.DevicePlatform.IOS) + .existingUser(false) + .ip("203.0.113.123") + .isTrustedUser(false) + .ja4Fingerprint("t13d1516h2_8daaf6152771_e5627efa2ab1") + .osVersion("18.0.1") + .userAgent( + "Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.3 Mobile/15E148 Safari/604.1" + ) + .build() + ) + .build() + } + + @Test + fun body() { + val params = + WatchEvaluateParams.builder() + .flowId("flo_01jc0t6fwwfgfsq1md24mhyztj") + .target( + Target.builder().type(Target.Type.PHONE_NUMBER).value("+30123456789").build() + ) + .attributes( + WatchEvaluateParams.Attributes.builder() + .putAdditionalProperty("plan_tier", JsonValue.from("free")) + .putAdditionalProperty("account_age_days", JsonValue.from("3")) + .build() + ) + .dispatchId("123e4567-e89b-12d3-a456-426614174000") + .signals( + Signals.builder() + .appVersion("1.2.34") + .deviceId("8F0B8FDD-C2CB-4387-B20A-56E9B2E5A0D2") + .deviceModel("iPhone17,2") + .devicePlatform(Signals.DevicePlatform.IOS) + .existingUser(false) + .ip("203.0.113.123") + .isTrustedUser(false) + .ja4Fingerprint("t13d1516h2_8daaf6152771_e5627efa2ab1") + .osVersion("18.0.1") + .userAgent( + "Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.3 Mobile/15E148 Safari/604.1" + ) + .build() + ) + .build() + + val body = params._body() + + assertThat(body.flowId()).isEqualTo("flo_01jc0t6fwwfgfsq1md24mhyztj") + assertThat(body.target()) + .isEqualTo( + Target.builder().type(Target.Type.PHONE_NUMBER).value("+30123456789").build() + ) + assertThat(body.attributes()) + .contains( + WatchEvaluateParams.Attributes.builder() + .putAdditionalProperty("plan_tier", JsonValue.from("free")) + .putAdditionalProperty("account_age_days", JsonValue.from("3")) + .build() + ) + assertThat(body.dispatchId()).contains("123e4567-e89b-12d3-a456-426614174000") + assertThat(body.signals()) + .contains( + Signals.builder() + .appVersion("1.2.34") + .deviceId("8F0B8FDD-C2CB-4387-B20A-56E9B2E5A0D2") + .deviceModel("iPhone17,2") + .devicePlatform(Signals.DevicePlatform.IOS) + .existingUser(false) + .ip("203.0.113.123") + .isTrustedUser(false) + .ja4Fingerprint("t13d1516h2_8daaf6152771_e5627efa2ab1") + .osVersion("18.0.1") + .userAgent( + "Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.3 Mobile/15E148 Safari/604.1" + ) + .build() + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + WatchEvaluateParams.builder() + .flowId("flo_01jc0t6fwwfgfsq1md24mhyztj") + .target( + Target.builder().type(Target.Type.PHONE_NUMBER).value("+30123456789").build() + ) + .build() + + val body = params._body() + + assertThat(body.flowId()).isEqualTo("flo_01jc0t6fwwfgfsq1md24mhyztj") + assertThat(body.target()) + .isEqualTo( + Target.builder().type(Target.Type.PHONE_NUMBER).value("+30123456789").build() + ) + } +} diff --git a/prelude-java-core/src/test/kotlin/so/prelude/sdk/models/WatchEvaluateResponseTest.kt b/prelude-java-core/src/test/kotlin/so/prelude/sdk/models/WatchEvaluateResponseTest.kt new file mode 100644 index 00000000..d04670ff --- /dev/null +++ b/prelude-java-core/src/test/kotlin/so/prelude/sdk/models/WatchEvaluateResponseTest.kt @@ -0,0 +1,105 @@ +// File generated from our OpenAPI spec by Stainless. + +package so.prelude.sdk.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import so.prelude.sdk.core.jsonMapper + +internal class WatchEvaluateResponseTest { + + @Test + fun create() { + val watchEvaluateResponse = + WatchEvaluateResponse.builder() + .id("evl_01jc0t6fwwfgfsq1md24mhyztj") + .action(WatchEvaluateResponse.Action.ALLOW) + .addRecipe( + WatchEvaluateResponse.Recipe.builder() + .partialEvidence(true) + .recipeId("rcp_01jc0t6fwwfgfsq1md24mhyztj") + .addRule( + WatchEvaluateResponse.Recipe.Rule.builder() + .outcome(WatchEvaluateResponse.Recipe.Rule.Outcome.TRIGGERED) + .ruleId("rul_01jc0t6fwwfgfsq1md24mhyztj") + .weight(10L) + .blockedBy("missing_data") + .name("high_value_cart_new_account") + .unavailable(true) + .build() + ) + .score(20L) + .threshold(30L) + .verdict(WatchEvaluateResponse.Recipe.Verdict.PASS) + .determinedBy("rul_01jc0t6fwwfgfsq1md24mhyztj") + .build() + ) + .verdict(WatchEvaluateResponse.Verdict.PASS) + .build() + + assertThat(watchEvaluateResponse.id()).isEqualTo("evl_01jc0t6fwwfgfsq1md24mhyztj") + assertThat(watchEvaluateResponse.action()).isEqualTo(WatchEvaluateResponse.Action.ALLOW) + assertThat(watchEvaluateResponse.recipes()) + .containsExactly( + WatchEvaluateResponse.Recipe.builder() + .partialEvidence(true) + .recipeId("rcp_01jc0t6fwwfgfsq1md24mhyztj") + .addRule( + WatchEvaluateResponse.Recipe.Rule.builder() + .outcome(WatchEvaluateResponse.Recipe.Rule.Outcome.TRIGGERED) + .ruleId("rul_01jc0t6fwwfgfsq1md24mhyztj") + .weight(10L) + .blockedBy("missing_data") + .name("high_value_cart_new_account") + .unavailable(true) + .build() + ) + .score(20L) + .threshold(30L) + .verdict(WatchEvaluateResponse.Recipe.Verdict.PASS) + .determinedBy("rul_01jc0t6fwwfgfsq1md24mhyztj") + .build() + ) + assertThat(watchEvaluateResponse.verdict()).isEqualTo(WatchEvaluateResponse.Verdict.PASS) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val watchEvaluateResponse = + WatchEvaluateResponse.builder() + .id("evl_01jc0t6fwwfgfsq1md24mhyztj") + .action(WatchEvaluateResponse.Action.ALLOW) + .addRecipe( + WatchEvaluateResponse.Recipe.builder() + .partialEvidence(true) + .recipeId("rcp_01jc0t6fwwfgfsq1md24mhyztj") + .addRule( + WatchEvaluateResponse.Recipe.Rule.builder() + .outcome(WatchEvaluateResponse.Recipe.Rule.Outcome.TRIGGERED) + .ruleId("rul_01jc0t6fwwfgfsq1md24mhyztj") + .weight(10L) + .blockedBy("missing_data") + .name("high_value_cart_new_account") + .unavailable(true) + .build() + ) + .score(20L) + .threshold(30L) + .verdict(WatchEvaluateResponse.Recipe.Verdict.PASS) + .determinedBy("rul_01jc0t6fwwfgfsq1md24mhyztj") + .build() + ) + .verdict(WatchEvaluateResponse.Verdict.PASS) + .build() + + val roundtrippedWatchEvaluateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(watchEvaluateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedWatchEvaluateResponse).isEqualTo(watchEvaluateResponse) + } +} diff --git a/prelude-java-core/src/test/kotlin/so/prelude/sdk/models/WatchPredictParamsTest.kt b/prelude-java-core/src/test/kotlin/so/prelude/sdk/models/WatchPredictParamsTest.kt index 362cff8d..22aaf691 100644 --- a/prelude-java-core/src/test/kotlin/so/prelude/sdk/models/WatchPredictParamsTest.kt +++ b/prelude-java-core/src/test/kotlin/so/prelude/sdk/models/WatchPredictParamsTest.kt @@ -10,20 +10,15 @@ internal class WatchPredictParamsTest { @Test fun create() { WatchPredictParams.builder() - .target( - WatchPredictParams.Target.builder() - .type(WatchPredictParams.Target.Type.PHONE_NUMBER) - .value("+30123456789") - .build() - ) + .target(Target.builder().type(Target.Type.PHONE_NUMBER).value("+30123456789").build()) .dispatchId("123e4567-e89b-12d3-a456-426614174000") .metadata(WatchPredictParams.Metadata.builder().correlationId("correlation_id").build()) .signals( - WatchPredictParams.Signals.builder() + Signals.builder() .appVersion("1.2.34") .deviceId("8F0B8FDD-C2CB-4387-B20A-56E9B2E5A0D2") .deviceModel("iPhone17,2") - .devicePlatform(WatchPredictParams.Signals.DevicePlatform.IOS) + .devicePlatform(Signals.DevicePlatform.IOS) .existingUser(false) .ip("203.0.113.123") .isTrustedUser(false) @@ -42,21 +37,18 @@ internal class WatchPredictParamsTest { val params = WatchPredictParams.builder() .target( - WatchPredictParams.Target.builder() - .type(WatchPredictParams.Target.Type.PHONE_NUMBER) - .value("+30123456789") - .build() + Target.builder().type(Target.Type.PHONE_NUMBER).value("+30123456789").build() ) .dispatchId("123e4567-e89b-12d3-a456-426614174000") .metadata( WatchPredictParams.Metadata.builder().correlationId("correlation_id").build() ) .signals( - WatchPredictParams.Signals.builder() + Signals.builder() .appVersion("1.2.34") .deviceId("8F0B8FDD-C2CB-4387-B20A-56E9B2E5A0D2") .deviceModel("iPhone17,2") - .devicePlatform(WatchPredictParams.Signals.DevicePlatform.IOS) + .devicePlatform(Signals.DevicePlatform.IOS) .existingUser(false) .ip("203.0.113.123") .isTrustedUser(false) @@ -73,21 +65,18 @@ internal class WatchPredictParamsTest { assertThat(body.target()) .isEqualTo( - WatchPredictParams.Target.builder() - .type(WatchPredictParams.Target.Type.PHONE_NUMBER) - .value("+30123456789") - .build() + Target.builder().type(Target.Type.PHONE_NUMBER).value("+30123456789").build() ) assertThat(body.dispatchId()).contains("123e4567-e89b-12d3-a456-426614174000") assertThat(body.metadata()) .contains(WatchPredictParams.Metadata.builder().correlationId("correlation_id").build()) assertThat(body.signals()) .contains( - WatchPredictParams.Signals.builder() + Signals.builder() .appVersion("1.2.34") .deviceId("8F0B8FDD-C2CB-4387-B20A-56E9B2E5A0D2") .deviceModel("iPhone17,2") - .devicePlatform(WatchPredictParams.Signals.DevicePlatform.IOS) + .devicePlatform(Signals.DevicePlatform.IOS) .existingUser(false) .ip("203.0.113.123") .isTrustedUser(false) @@ -105,10 +94,7 @@ internal class WatchPredictParamsTest { val params = WatchPredictParams.builder() .target( - WatchPredictParams.Target.builder() - .type(WatchPredictParams.Target.Type.PHONE_NUMBER) - .value("+30123456789") - .build() + Target.builder().type(Target.Type.PHONE_NUMBER).value("+30123456789").build() ) .build() @@ -116,10 +102,7 @@ internal class WatchPredictParamsTest { assertThat(body.target()) .isEqualTo( - WatchPredictParams.Target.builder() - .type(WatchPredictParams.Target.Type.PHONE_NUMBER) - .value("+30123456789") - .build() + Target.builder().type(Target.Type.PHONE_NUMBER).value("+30123456789").build() ) } } diff --git a/prelude-java-core/src/test/kotlin/so/prelude/sdk/models/WatchSendEventsParamsTest.kt b/prelude-java-core/src/test/kotlin/so/prelude/sdk/models/WatchSendEventsParamsTest.kt index 143f0aee..654f58fb 100644 --- a/prelude-java-core/src/test/kotlin/so/prelude/sdk/models/WatchSendEventsParamsTest.kt +++ b/prelude-java-core/src/test/kotlin/so/prelude/sdk/models/WatchSendEventsParamsTest.kt @@ -15,8 +15,8 @@ internal class WatchSendEventsParamsTest { .confidence(WatchSendEventsParams.Event.Confidence.MAXIMUM) .label("account.banned") .target( - WatchSendEventsParams.Event.Target.builder() - .type(WatchSendEventsParams.Event.Target.Type.PHONE_NUMBER) + Target.builder() + .type(Target.Type.PHONE_NUMBER) .value("+30123456789") .build() ) @@ -34,8 +34,8 @@ internal class WatchSendEventsParamsTest { .confidence(WatchSendEventsParams.Event.Confidence.MAXIMUM) .label("account.banned") .target( - WatchSendEventsParams.Event.Target.builder() - .type(WatchSendEventsParams.Event.Target.Type.PHONE_NUMBER) + Target.builder() + .type(Target.Type.PHONE_NUMBER) .value("+30123456789") .build() ) @@ -51,8 +51,8 @@ internal class WatchSendEventsParamsTest { .confidence(WatchSendEventsParams.Event.Confidence.MAXIMUM) .label("account.banned") .target( - WatchSendEventsParams.Event.Target.builder() - .type(WatchSendEventsParams.Event.Target.Type.PHONE_NUMBER) + Target.builder() + .type(Target.Type.PHONE_NUMBER) .value("+30123456789") .build() ) diff --git a/prelude-java-core/src/test/kotlin/so/prelude/sdk/models/WatchSendFeedbacksParamsTest.kt b/prelude-java-core/src/test/kotlin/so/prelude/sdk/models/WatchSendFeedbacksParamsTest.kt index ac936f2e..bc4ad09f 100644 --- a/prelude-java-core/src/test/kotlin/so/prelude/sdk/models/WatchSendFeedbacksParamsTest.kt +++ b/prelude-java-core/src/test/kotlin/so/prelude/sdk/models/WatchSendFeedbacksParamsTest.kt @@ -13,8 +13,8 @@ internal class WatchSendFeedbacksParamsTest { .addFeedback( WatchSendFeedbacksParams.Feedback.builder() .target( - WatchSendFeedbacksParams.Feedback.Target.builder() - .type(WatchSendFeedbacksParams.Feedback.Target.Type.PHONE_NUMBER) + Target.builder() + .type(Target.Type.PHONE_NUMBER) .value("+30123456789") .build() ) @@ -36,8 +36,8 @@ internal class WatchSendFeedbacksParamsTest { .addFeedback( WatchSendFeedbacksParams.Feedback.builder() .target( - WatchSendFeedbacksParams.Feedback.Target.builder() - .type(WatchSendFeedbacksParams.Feedback.Target.Type.PHONE_NUMBER) + Target.builder() + .type(Target.Type.PHONE_NUMBER) .value("+30123456789") .build() ) @@ -57,8 +57,8 @@ internal class WatchSendFeedbacksParamsTest { .containsExactly( WatchSendFeedbacksParams.Feedback.builder() .target( - WatchSendFeedbacksParams.Feedback.Target.builder() - .type(WatchSendFeedbacksParams.Feedback.Target.Type.PHONE_NUMBER) + Target.builder() + .type(Target.Type.PHONE_NUMBER) .value("+30123456789") .build() ) @@ -79,8 +79,8 @@ internal class WatchSendFeedbacksParamsTest { .addFeedback( WatchSendFeedbacksParams.Feedback.builder() .target( - WatchSendFeedbacksParams.Feedback.Target.builder() - .type(WatchSendFeedbacksParams.Feedback.Target.Type.PHONE_NUMBER) + Target.builder() + .type(Target.Type.PHONE_NUMBER) .value("+30123456789") .build() ) @@ -95,8 +95,8 @@ internal class WatchSendFeedbacksParamsTest { .containsExactly( WatchSendFeedbacksParams.Feedback.builder() .target( - WatchSendFeedbacksParams.Feedback.Target.builder() - .type(WatchSendFeedbacksParams.Feedback.Target.Type.PHONE_NUMBER) + Target.builder() + .type(Target.Type.PHONE_NUMBER) .value("+30123456789") .build() ) diff --git a/prelude-java-core/src/test/kotlin/so/prelude/sdk/services/ErrorHandlingTest.kt b/prelude-java-core/src/test/kotlin/so/prelude/sdk/services/ErrorHandlingTest.kt index 4e027818..8f0ba1d7 100644 --- a/prelude-java-core/src/test/kotlin/so/prelude/sdk/services/ErrorHandlingTest.kt +++ b/prelude-java-core/src/test/kotlin/so/prelude/sdk/services/ErrorHandlingTest.kt @@ -28,6 +28,8 @@ import so.prelude.sdk.errors.RateLimitException import so.prelude.sdk.errors.UnauthorizedException import so.prelude.sdk.errors.UnexpectedStatusCodeException import so.prelude.sdk.errors.UnprocessableEntityException +import so.prelude.sdk.models.Signals +import so.prelude.sdk.models.Target import so.prelude.sdk.models.VerificationCreateParams @WireMockTest @@ -73,8 +75,8 @@ internal class ErrorHandlingTest { verificationService.create( VerificationCreateParams.builder() .target( - VerificationCreateParams.Target.builder() - .type(VerificationCreateParams.Target.Type.PHONE_NUMBER) + Target.builder() + .type(Target.Type.PHONE_NUMBER) .value("+30123456789") .build() ) @@ -117,11 +119,11 @@ internal class ErrorHandlingTest { .build() ) .signals( - VerificationCreateParams.Signals.builder() + Signals.builder() .appVersion("1.2.34") .deviceId("8F0B8FDD-C2CB-4387-B20A-56E9B2E5A0D2") .deviceModel("iPhone17,2") - .devicePlatform(VerificationCreateParams.Signals.DevicePlatform.IOS) + .devicePlatform(Signals.DevicePlatform.IOS) .existingUser(false) .ip("203.0.113.123") .isTrustedUser(false) @@ -156,8 +158,8 @@ internal class ErrorHandlingTest { verificationService.create( VerificationCreateParams.builder() .target( - VerificationCreateParams.Target.builder() - .type(VerificationCreateParams.Target.Type.PHONE_NUMBER) + Target.builder() + .type(Target.Type.PHONE_NUMBER) .value("+30123456789") .build() ) @@ -200,11 +202,11 @@ internal class ErrorHandlingTest { .build() ) .signals( - VerificationCreateParams.Signals.builder() + Signals.builder() .appVersion("1.2.34") .deviceId("8F0B8FDD-C2CB-4387-B20A-56E9B2E5A0D2") .deviceModel("iPhone17,2") - .devicePlatform(VerificationCreateParams.Signals.DevicePlatform.IOS) + .devicePlatform(Signals.DevicePlatform.IOS) .existingUser(false) .ip("203.0.113.123") .isTrustedUser(false) @@ -239,8 +241,8 @@ internal class ErrorHandlingTest { verificationService.create( VerificationCreateParams.builder() .target( - VerificationCreateParams.Target.builder() - .type(VerificationCreateParams.Target.Type.PHONE_NUMBER) + Target.builder() + .type(Target.Type.PHONE_NUMBER) .value("+30123456789") .build() ) @@ -283,11 +285,11 @@ internal class ErrorHandlingTest { .build() ) .signals( - VerificationCreateParams.Signals.builder() + Signals.builder() .appVersion("1.2.34") .deviceId("8F0B8FDD-C2CB-4387-B20A-56E9B2E5A0D2") .deviceModel("iPhone17,2") - .devicePlatform(VerificationCreateParams.Signals.DevicePlatform.IOS) + .devicePlatform(Signals.DevicePlatform.IOS) .existingUser(false) .ip("203.0.113.123") .isTrustedUser(false) @@ -322,8 +324,8 @@ internal class ErrorHandlingTest { verificationService.create( VerificationCreateParams.builder() .target( - VerificationCreateParams.Target.builder() - .type(VerificationCreateParams.Target.Type.PHONE_NUMBER) + Target.builder() + .type(Target.Type.PHONE_NUMBER) .value("+30123456789") .build() ) @@ -366,11 +368,11 @@ internal class ErrorHandlingTest { .build() ) .signals( - VerificationCreateParams.Signals.builder() + Signals.builder() .appVersion("1.2.34") .deviceId("8F0B8FDD-C2CB-4387-B20A-56E9B2E5A0D2") .deviceModel("iPhone17,2") - .devicePlatform(VerificationCreateParams.Signals.DevicePlatform.IOS) + .devicePlatform(Signals.DevicePlatform.IOS) .existingUser(false) .ip("203.0.113.123") .isTrustedUser(false) @@ -405,8 +407,8 @@ internal class ErrorHandlingTest { verificationService.create( VerificationCreateParams.builder() .target( - VerificationCreateParams.Target.builder() - .type(VerificationCreateParams.Target.Type.PHONE_NUMBER) + Target.builder() + .type(Target.Type.PHONE_NUMBER) .value("+30123456789") .build() ) @@ -449,11 +451,11 @@ internal class ErrorHandlingTest { .build() ) .signals( - VerificationCreateParams.Signals.builder() + Signals.builder() .appVersion("1.2.34") .deviceId("8F0B8FDD-C2CB-4387-B20A-56E9B2E5A0D2") .deviceModel("iPhone17,2") - .devicePlatform(VerificationCreateParams.Signals.DevicePlatform.IOS) + .devicePlatform(Signals.DevicePlatform.IOS) .existingUser(false) .ip("203.0.113.123") .isTrustedUser(false) @@ -488,8 +490,8 @@ internal class ErrorHandlingTest { verificationService.create( VerificationCreateParams.builder() .target( - VerificationCreateParams.Target.builder() - .type(VerificationCreateParams.Target.Type.PHONE_NUMBER) + Target.builder() + .type(Target.Type.PHONE_NUMBER) .value("+30123456789") .build() ) @@ -532,11 +534,11 @@ internal class ErrorHandlingTest { .build() ) .signals( - VerificationCreateParams.Signals.builder() + Signals.builder() .appVersion("1.2.34") .deviceId("8F0B8FDD-C2CB-4387-B20A-56E9B2E5A0D2") .deviceModel("iPhone17,2") - .devicePlatform(VerificationCreateParams.Signals.DevicePlatform.IOS) + .devicePlatform(Signals.DevicePlatform.IOS) .existingUser(false) .ip("203.0.113.123") .isTrustedUser(false) @@ -571,8 +573,8 @@ internal class ErrorHandlingTest { verificationService.create( VerificationCreateParams.builder() .target( - VerificationCreateParams.Target.builder() - .type(VerificationCreateParams.Target.Type.PHONE_NUMBER) + Target.builder() + .type(Target.Type.PHONE_NUMBER) .value("+30123456789") .build() ) @@ -615,11 +617,11 @@ internal class ErrorHandlingTest { .build() ) .signals( - VerificationCreateParams.Signals.builder() + Signals.builder() .appVersion("1.2.34") .deviceId("8F0B8FDD-C2CB-4387-B20A-56E9B2E5A0D2") .deviceModel("iPhone17,2") - .devicePlatform(VerificationCreateParams.Signals.DevicePlatform.IOS) + .devicePlatform(Signals.DevicePlatform.IOS) .existingUser(false) .ip("203.0.113.123") .isTrustedUser(false) @@ -654,8 +656,8 @@ internal class ErrorHandlingTest { verificationService.create( VerificationCreateParams.builder() .target( - VerificationCreateParams.Target.builder() - .type(VerificationCreateParams.Target.Type.PHONE_NUMBER) + Target.builder() + .type(Target.Type.PHONE_NUMBER) .value("+30123456789") .build() ) @@ -698,11 +700,11 @@ internal class ErrorHandlingTest { .build() ) .signals( - VerificationCreateParams.Signals.builder() + Signals.builder() .appVersion("1.2.34") .deviceId("8F0B8FDD-C2CB-4387-B20A-56E9B2E5A0D2") .deviceModel("iPhone17,2") - .devicePlatform(VerificationCreateParams.Signals.DevicePlatform.IOS) + .devicePlatform(Signals.DevicePlatform.IOS) .existingUser(false) .ip("203.0.113.123") .isTrustedUser(false) @@ -737,8 +739,8 @@ internal class ErrorHandlingTest { verificationService.create( VerificationCreateParams.builder() .target( - VerificationCreateParams.Target.builder() - .type(VerificationCreateParams.Target.Type.PHONE_NUMBER) + Target.builder() + .type(Target.Type.PHONE_NUMBER) .value("+30123456789") .build() ) @@ -781,11 +783,11 @@ internal class ErrorHandlingTest { .build() ) .signals( - VerificationCreateParams.Signals.builder() + Signals.builder() .appVersion("1.2.34") .deviceId("8F0B8FDD-C2CB-4387-B20A-56E9B2E5A0D2") .deviceModel("iPhone17,2") - .devicePlatform(VerificationCreateParams.Signals.DevicePlatform.IOS) + .devicePlatform(Signals.DevicePlatform.IOS) .existingUser(false) .ip("203.0.113.123") .isTrustedUser(false) @@ -820,8 +822,8 @@ internal class ErrorHandlingTest { verificationService.create( VerificationCreateParams.builder() .target( - VerificationCreateParams.Target.builder() - .type(VerificationCreateParams.Target.Type.PHONE_NUMBER) + Target.builder() + .type(Target.Type.PHONE_NUMBER) .value("+30123456789") .build() ) @@ -864,11 +866,11 @@ internal class ErrorHandlingTest { .build() ) .signals( - VerificationCreateParams.Signals.builder() + Signals.builder() .appVersion("1.2.34") .deviceId("8F0B8FDD-C2CB-4387-B20A-56E9B2E5A0D2") .deviceModel("iPhone17,2") - .devicePlatform(VerificationCreateParams.Signals.DevicePlatform.IOS) + .devicePlatform(Signals.DevicePlatform.IOS) .existingUser(false) .ip("203.0.113.123") .isTrustedUser(false) @@ -903,8 +905,8 @@ internal class ErrorHandlingTest { verificationService.create( VerificationCreateParams.builder() .target( - VerificationCreateParams.Target.builder() - .type(VerificationCreateParams.Target.Type.PHONE_NUMBER) + Target.builder() + .type(Target.Type.PHONE_NUMBER) .value("+30123456789") .build() ) @@ -947,11 +949,11 @@ internal class ErrorHandlingTest { .build() ) .signals( - VerificationCreateParams.Signals.builder() + Signals.builder() .appVersion("1.2.34") .deviceId("8F0B8FDD-C2CB-4387-B20A-56E9B2E5A0D2") .deviceModel("iPhone17,2") - .devicePlatform(VerificationCreateParams.Signals.DevicePlatform.IOS) + .devicePlatform(Signals.DevicePlatform.IOS) .existingUser(false) .ip("203.0.113.123") .isTrustedUser(false) @@ -986,8 +988,8 @@ internal class ErrorHandlingTest { verificationService.create( VerificationCreateParams.builder() .target( - VerificationCreateParams.Target.builder() - .type(VerificationCreateParams.Target.Type.PHONE_NUMBER) + Target.builder() + .type(Target.Type.PHONE_NUMBER) .value("+30123456789") .build() ) @@ -1030,11 +1032,11 @@ internal class ErrorHandlingTest { .build() ) .signals( - VerificationCreateParams.Signals.builder() + Signals.builder() .appVersion("1.2.34") .deviceId("8F0B8FDD-C2CB-4387-B20A-56E9B2E5A0D2") .deviceModel("iPhone17,2") - .devicePlatform(VerificationCreateParams.Signals.DevicePlatform.IOS) + .devicePlatform(Signals.DevicePlatform.IOS) .existingUser(false) .ip("203.0.113.123") .isTrustedUser(false) @@ -1069,8 +1071,8 @@ internal class ErrorHandlingTest { verificationService.create( VerificationCreateParams.builder() .target( - VerificationCreateParams.Target.builder() - .type(VerificationCreateParams.Target.Type.PHONE_NUMBER) + Target.builder() + .type(Target.Type.PHONE_NUMBER) .value("+30123456789") .build() ) @@ -1113,11 +1115,11 @@ internal class ErrorHandlingTest { .build() ) .signals( - VerificationCreateParams.Signals.builder() + Signals.builder() .appVersion("1.2.34") .deviceId("8F0B8FDD-C2CB-4387-B20A-56E9B2E5A0D2") .deviceModel("iPhone17,2") - .devicePlatform(VerificationCreateParams.Signals.DevicePlatform.IOS) + .devicePlatform(Signals.DevicePlatform.IOS) .existingUser(false) .ip("203.0.113.123") .isTrustedUser(false) @@ -1152,8 +1154,8 @@ internal class ErrorHandlingTest { verificationService.create( VerificationCreateParams.builder() .target( - VerificationCreateParams.Target.builder() - .type(VerificationCreateParams.Target.Type.PHONE_NUMBER) + Target.builder() + .type(Target.Type.PHONE_NUMBER) .value("+30123456789") .build() ) @@ -1196,11 +1198,11 @@ internal class ErrorHandlingTest { .build() ) .signals( - VerificationCreateParams.Signals.builder() + Signals.builder() .appVersion("1.2.34") .deviceId("8F0B8FDD-C2CB-4387-B20A-56E9B2E5A0D2") .deviceModel("iPhone17,2") - .devicePlatform(VerificationCreateParams.Signals.DevicePlatform.IOS) + .devicePlatform(Signals.DevicePlatform.IOS) .existingUser(false) .ip("203.0.113.123") .isTrustedUser(false) @@ -1235,8 +1237,8 @@ internal class ErrorHandlingTest { verificationService.create( VerificationCreateParams.builder() .target( - VerificationCreateParams.Target.builder() - .type(VerificationCreateParams.Target.Type.PHONE_NUMBER) + Target.builder() + .type(Target.Type.PHONE_NUMBER) .value("+30123456789") .build() ) @@ -1279,11 +1281,11 @@ internal class ErrorHandlingTest { .build() ) .signals( - VerificationCreateParams.Signals.builder() + Signals.builder() .appVersion("1.2.34") .deviceId("8F0B8FDD-C2CB-4387-B20A-56E9B2E5A0D2") .deviceModel("iPhone17,2") - .devicePlatform(VerificationCreateParams.Signals.DevicePlatform.IOS) + .devicePlatform(Signals.DevicePlatform.IOS) .existingUser(false) .ip("203.0.113.123") .isTrustedUser(false) @@ -1318,8 +1320,8 @@ internal class ErrorHandlingTest { verificationService.create( VerificationCreateParams.builder() .target( - VerificationCreateParams.Target.builder() - .type(VerificationCreateParams.Target.Type.PHONE_NUMBER) + Target.builder() + .type(Target.Type.PHONE_NUMBER) .value("+30123456789") .build() ) @@ -1362,11 +1364,11 @@ internal class ErrorHandlingTest { .build() ) .signals( - VerificationCreateParams.Signals.builder() + Signals.builder() .appVersion("1.2.34") .deviceId("8F0B8FDD-C2CB-4387-B20A-56E9B2E5A0D2") .deviceModel("iPhone17,2") - .devicePlatform(VerificationCreateParams.Signals.DevicePlatform.IOS) + .devicePlatform(Signals.DevicePlatform.IOS) .existingUser(false) .ip("203.0.113.123") .isTrustedUser(false) @@ -1399,8 +1401,8 @@ internal class ErrorHandlingTest { verificationService.create( VerificationCreateParams.builder() .target( - VerificationCreateParams.Target.builder() - .type(VerificationCreateParams.Target.Type.PHONE_NUMBER) + Target.builder() + .type(Target.Type.PHONE_NUMBER) .value("+30123456789") .build() ) @@ -1443,11 +1445,11 @@ internal class ErrorHandlingTest { .build() ) .signals( - VerificationCreateParams.Signals.builder() + Signals.builder() .appVersion("1.2.34") .deviceId("8F0B8FDD-C2CB-4387-B20A-56E9B2E5A0D2") .deviceModel("iPhone17,2") - .devicePlatform(VerificationCreateParams.Signals.DevicePlatform.IOS) + .devicePlatform(Signals.DevicePlatform.IOS) .existingUser(false) .ip("203.0.113.123") .isTrustedUser(false) diff --git a/prelude-java-core/src/test/kotlin/so/prelude/sdk/services/ServiceParamsTest.kt b/prelude-java-core/src/test/kotlin/so/prelude/sdk/services/ServiceParamsTest.kt index 460f418b..9e31af03 100644 --- a/prelude-java-core/src/test/kotlin/so/prelude/sdk/services/ServiceParamsTest.kt +++ b/prelude-java-core/src/test/kotlin/so/prelude/sdk/services/ServiceParamsTest.kt @@ -18,6 +18,8 @@ import org.junit.jupiter.api.parallel.ResourceLock import so.prelude.sdk.client.PreludeClient import so.prelude.sdk.client.okhttp.PreludeOkHttpClient import so.prelude.sdk.core.JsonValue +import so.prelude.sdk.models.Signals +import so.prelude.sdk.models.Target import so.prelude.sdk.models.VerificationCreateParams @WireMockTest @@ -43,10 +45,7 @@ internal class ServiceParamsTest { verificationService.create( VerificationCreateParams.builder() .target( - VerificationCreateParams.Target.builder() - .type(VerificationCreateParams.Target.Type.PHONE_NUMBER) - .value("+30123456789") - .build() + Target.builder().type(Target.Type.PHONE_NUMBER).value("+30123456789").build() ) .dispatchId("123e4567-e89b-12d3-a456-426614174000") .metadata( @@ -84,11 +83,11 @@ internal class ServiceParamsTest { .build() ) .signals( - VerificationCreateParams.Signals.builder() + Signals.builder() .appVersion("1.2.34") .deviceId("8F0B8FDD-C2CB-4387-B20A-56E9B2E5A0D2") .deviceModel("iPhone17,2") - .devicePlatform(VerificationCreateParams.Signals.DevicePlatform.IOS) + .devicePlatform(Signals.DevicePlatform.IOS) .existingUser(false) .ip("203.0.113.123") .isTrustedUser(false) diff --git a/prelude-java-core/src/test/kotlin/so/prelude/sdk/services/async/NotifyServiceAsyncTest.kt b/prelude-java-core/src/test/kotlin/so/prelude/sdk/services/async/NotifyServiceAsyncTest.kt index 4b56196a..8c480dd5 100644 --- a/prelude-java-core/src/test/kotlin/so/prelude/sdk/services/async/NotifyServiceAsyncTest.kt +++ b/prelude-java-core/src/test/kotlin/so/prelude/sdk/services/async/NotifyServiceAsyncTest.kt @@ -12,6 +12,7 @@ import so.prelude.sdk.models.NotifyGetSubscriptionPhoneNumberParams import so.prelude.sdk.models.NotifyListSubscriptionConfigsParams import so.prelude.sdk.models.NotifyListSubscriptionPhoneNumberEventsParams import so.prelude.sdk.models.NotifyListSubscriptionPhoneNumbersParams +import so.prelude.sdk.models.NotifyReplyParams import so.prelude.sdk.models.NotifySendBatchParams import so.prelude.sdk.models.NotifySendParams @@ -118,6 +119,30 @@ internal class NotifyServiceAsyncTest { response.validate() } + @Test + fun reply() { + val client = + PreludeOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiToken("My API Token") + .build() + val notifyServiceAsync = client.notify() + + val responseFuture = + notifyServiceAsync.reply( + NotifyReplyParams.builder() + .replyTo("im_01k8aq2zggeyssvt53zgvpx63a") + .text("Thanks for reaching out! We'll look into your request.") + .to("+33612345678") + .callbackUrl("https://your-app.com/webhooks/notify") + .correlationId("support-ticket-42") + .build() + ) + + val response = responseFuture.get() + response.validate() + } + @Test fun send() { val client = diff --git a/prelude-java-core/src/test/kotlin/so/prelude/sdk/services/async/VerificationServiceAsyncTest.kt b/prelude-java-core/src/test/kotlin/so/prelude/sdk/services/async/VerificationServiceAsyncTest.kt index fac0dab0..e8a4e1fd 100644 --- a/prelude-java-core/src/test/kotlin/so/prelude/sdk/services/async/VerificationServiceAsyncTest.kt +++ b/prelude-java-core/src/test/kotlin/so/prelude/sdk/services/async/VerificationServiceAsyncTest.kt @@ -7,6 +7,8 @@ import org.junit.jupiter.api.extension.ExtendWith import so.prelude.sdk.TestServerExtension import so.prelude.sdk.client.okhttp.PreludeOkHttpClientAsync import so.prelude.sdk.core.JsonValue +import so.prelude.sdk.models.Signals +import so.prelude.sdk.models.Target import so.prelude.sdk.models.VerificationCheckParams import so.prelude.sdk.models.VerificationCreateParams @@ -26,8 +28,8 @@ internal class VerificationServiceAsyncTest { verificationServiceAsync.create( VerificationCreateParams.builder() .target( - VerificationCreateParams.Target.builder() - .type(VerificationCreateParams.Target.Type.PHONE_NUMBER) + Target.builder() + .type(Target.Type.PHONE_NUMBER) .value("+30123456789") .build() ) @@ -67,11 +69,11 @@ internal class VerificationServiceAsyncTest { .build() ) .signals( - VerificationCreateParams.Signals.builder() + Signals.builder() .appVersion("1.2.34") .deviceId("8F0B8FDD-C2CB-4387-B20A-56E9B2E5A0D2") .deviceModel("iPhone17,2") - .devicePlatform(VerificationCreateParams.Signals.DevicePlatform.IOS) + .devicePlatform(Signals.DevicePlatform.IOS) .existingUser(false) .ip("203.0.113.123") .isTrustedUser(false) @@ -103,8 +105,8 @@ internal class VerificationServiceAsyncTest { VerificationCheckParams.builder() .code("12345") .target( - VerificationCheckParams.Target.builder() - .type(VerificationCheckParams.Target.Type.PHONE_NUMBER) + Target.builder() + .type(Target.Type.PHONE_NUMBER) .value("+30123456789") .build() ) diff --git a/prelude-java-core/src/test/kotlin/so/prelude/sdk/services/async/WatchServiceAsyncTest.kt b/prelude-java-core/src/test/kotlin/so/prelude/sdk/services/async/WatchServiceAsyncTest.kt index b30e19a3..951597c7 100644 --- a/prelude-java-core/src/test/kotlin/so/prelude/sdk/services/async/WatchServiceAsyncTest.kt +++ b/prelude-java-core/src/test/kotlin/so/prelude/sdk/services/async/WatchServiceAsyncTest.kt @@ -6,6 +6,10 @@ import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith import so.prelude.sdk.TestServerExtension import so.prelude.sdk.client.okhttp.PreludeOkHttpClientAsync +import so.prelude.sdk.core.JsonValue +import so.prelude.sdk.models.Signals +import so.prelude.sdk.models.Target +import so.prelude.sdk.models.WatchEvaluateParams import so.prelude.sdk.models.WatchPredictParams import so.prelude.sdk.models.WatchSendEventsParams import so.prelude.sdk.models.WatchSendFeedbacksParams @@ -13,6 +17,55 @@ import so.prelude.sdk.models.WatchSendFeedbacksParams @ExtendWith(TestServerExtension::class) internal class WatchServiceAsyncTest { + @Test + fun evaluate() { + val client = + PreludeOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiToken("My API Token") + .build() + val watchServiceAsync = client.watch() + + val responseFuture = + watchServiceAsync.evaluate( + WatchEvaluateParams.builder() + .flowId("flo_01jc0t6fwwfgfsq1md24mhyztj") + .target( + Target.builder() + .type(Target.Type.PHONE_NUMBER) + .value("+30123456789") + .build() + ) + .attributes( + WatchEvaluateParams.Attributes.builder() + .putAdditionalProperty("plan_tier", JsonValue.from("free")) + .putAdditionalProperty("account_age_days", JsonValue.from("3")) + .build() + ) + .dispatchId("123e4567-e89b-12d3-a456-426614174000") + .signals( + Signals.builder() + .appVersion("1.2.34") + .deviceId("8F0B8FDD-C2CB-4387-B20A-56E9B2E5A0D2") + .deviceModel("iPhone17,2") + .devicePlatform(Signals.DevicePlatform.IOS) + .existingUser(false) + .ip("203.0.113.123") + .isTrustedUser(false) + .ja4Fingerprint("t13d1516h2_8daaf6152771_e5627efa2ab1") + .osVersion("18.0.1") + .userAgent( + "Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.3 Mobile/15E148 Safari/604.1" + ) + .build() + ) + .build() + ) + + val response = responseFuture.get() + response.validate() + } + @Test fun predict() { val client = @@ -26,8 +79,8 @@ internal class WatchServiceAsyncTest { watchServiceAsync.predict( WatchPredictParams.builder() .target( - WatchPredictParams.Target.builder() - .type(WatchPredictParams.Target.Type.PHONE_NUMBER) + Target.builder() + .type(Target.Type.PHONE_NUMBER) .value("+30123456789") .build() ) @@ -38,11 +91,11 @@ internal class WatchServiceAsyncTest { .build() ) .signals( - WatchPredictParams.Signals.builder() + Signals.builder() .appVersion("1.2.34") .deviceId("8F0B8FDD-C2CB-4387-B20A-56E9B2E5A0D2") .deviceModel("iPhone17,2") - .devicePlatform(WatchPredictParams.Signals.DevicePlatform.IOS) + .devicePlatform(Signals.DevicePlatform.IOS) .existingUser(false) .ip("203.0.113.123") .isTrustedUser(false) @@ -77,8 +130,8 @@ internal class WatchServiceAsyncTest { .confidence(WatchSendEventsParams.Event.Confidence.MAXIMUM) .label("account.banned") .target( - WatchSendEventsParams.Event.Target.builder() - .type(WatchSendEventsParams.Event.Target.Type.PHONE_NUMBER) + Target.builder() + .type(Target.Type.PHONE_NUMBER) .value("+30123456789") .build() ) @@ -106,10 +159,8 @@ internal class WatchServiceAsyncTest { .addFeedback( WatchSendFeedbacksParams.Feedback.builder() .target( - WatchSendFeedbacksParams.Feedback.Target.builder() - .type( - WatchSendFeedbacksParams.Feedback.Target.Type.PHONE_NUMBER - ) + Target.builder() + .type(Target.Type.PHONE_NUMBER) .value("+30123456789") .build() ) diff --git a/prelude-java-core/src/test/kotlin/so/prelude/sdk/services/async/intel/KycServiceAsyncTest.kt b/prelude-java-core/src/test/kotlin/so/prelude/sdk/services/async/intel/KycServiceAsyncTest.kt new file mode 100644 index 00000000..74e222b0 --- /dev/null +++ b/prelude-java-core/src/test/kotlin/so/prelude/sdk/services/async/intel/KycServiceAsyncTest.kt @@ -0,0 +1,43 @@ +// File generated from our OpenAPI spec by Stainless. + +package so.prelude.sdk.services.async.intel + +import java.time.LocalDate +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith +import so.prelude.sdk.TestServerExtension +import so.prelude.sdk.client.okhttp.PreludeOkHttpClientAsync +import so.prelude.sdk.models.IntelKycMatchParams + +@ExtendWith(TestServerExtension::class) +internal class KycServiceAsyncTest { + + @Test + fun match() { + val client = + PreludeOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiToken("My API Token") + .build() + val kycServiceAsync = client.intel().kyc() + + val responseFuture = + kycServiceAsync.match( + IntelKycMatchParams.builder() + .phone("+12065550100") + .address("12 rue de la Paix") + .birthdate(LocalDate.parse("1990-01-15")) + .country("FR") + .email("jean.dupont@example.com") + .familyName("Dupont") + .givenName("Jean") + .locality("Paris") + .postalCode("75002") + .region("Île-de-France") + .build() + ) + + val response = responseFuture.get() + response.validate() + } +} diff --git a/prelude-java-core/src/test/kotlin/so/prelude/sdk/services/async/verification/phone/HistoryServiceAsyncTest.kt b/prelude-java-core/src/test/kotlin/so/prelude/sdk/services/async/verification/phone/HistoryServiceAsyncTest.kt new file mode 100644 index 00000000..c3e0bb92 --- /dev/null +++ b/prelude-java-core/src/test/kotlin/so/prelude/sdk/services/async/verification/phone/HistoryServiceAsyncTest.kt @@ -0,0 +1,60 @@ +// File generated from our OpenAPI spec by Stainless. + +package so.prelude.sdk.services.async.verification.phone + +import java.time.OffsetDateTime +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith +import so.prelude.sdk.TestServerExtension +import so.prelude.sdk.client.okhttp.PreludeOkHttpClientAsync +import so.prelude.sdk.models.VerificationPhoneHistoryListParams + +@ExtendWith(TestServerExtension::class) +internal class HistoryServiceAsyncTest { + + @Test + fun retrieve() { + val client = + PreludeOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiToken("My API Token") + .build() + val historyServiceAsync = client.verification().phone().history() + + val historyFuture = historyServiceAsync.retrieve("vrf_01jc0t6fwwfgfsq1md24mhyztj") + + val history = historyFuture.get() + history.validate() + } + + @Test + fun list() { + val client = + PreludeOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiToken("My API Token") + .build() + val historyServiceAsync = client.verification().phone().history() + + val historiesFuture = + historyServiceAsync.list( + VerificationPhoneHistoryListParams.builder() + .addChannel(VerificationPhoneHistoryListParams.Channel.SMS) + .cursor("cursor") + .devicePlatform(VerificationPhoneHistoryListParams.DevicePlatform.ANDROID) + .from(OffsetDateTime.parse("2026-09-01T00:00:00Z")) + .limit(1L) + .maxAttempts(0L) + .minAttempts(0L) + .phoneNumber("+33612345678") + .region("FR") + .status(VerificationPhoneHistoryListParams.Status.CONVERTED) + .templateId("template_01jc0t6fwwfgfsq1md24mhyztj") + .to(OffsetDateTime.parse("2026-09-08T00:00:00Z")) + .build() + ) + + val histories = historiesFuture.get() + histories.validate() + } +} diff --git a/prelude-java-core/src/test/kotlin/so/prelude/sdk/services/async/verificationManagement/SandboxServiceAsyncTest.kt b/prelude-java-core/src/test/kotlin/so/prelude/sdk/services/async/verificationManagement/SandboxServiceAsyncTest.kt new file mode 100644 index 00000000..79b67bc3 --- /dev/null +++ b/prelude-java-core/src/test/kotlin/so/prelude/sdk/services/async/verificationManagement/SandboxServiceAsyncTest.kt @@ -0,0 +1,64 @@ +// File generated from our OpenAPI spec by Stainless. + +package so.prelude.sdk.services.async.verificationManagement + +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith +import so.prelude.sdk.TestServerExtension +import so.prelude.sdk.client.okhttp.PreludeOkHttpClientAsync +import so.prelude.sdk.models.VerificationManagementSandboxAddPhoneNumberParams + +@ExtendWith(TestServerExtension::class) +internal class SandboxServiceAsyncTest { + + @Test + fun addPhoneNumber() { + val client = + PreludeOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiToken("My API Token") + .build() + val sandboxServiceAsync = client.verificationManagement().sandbox() + + val responseFuture = + sandboxServiceAsync.addPhoneNumber( + VerificationManagementSandboxAddPhoneNumberParams.builder() + .attemptCode("123456") + .phoneNumber("+30123456789") + .build() + ) + + val response = responseFuture.get() + response.validate() + } + + @Test + fun deletePhoneNumber() { + val client = + PreludeOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiToken("My API Token") + .build() + val sandboxServiceAsync = client.verificationManagement().sandbox() + + val responseFuture = sandboxServiceAsync.deletePhoneNumber("+12065550100") + + val response = responseFuture.get() + response.validate() + } + + @Test + fun listPhoneNumbers() { + val client = + PreludeOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiToken("My API Token") + .build() + val sandboxServiceAsync = client.verificationManagement().sandbox() + + val responseFuture = sandboxServiceAsync.listPhoneNumbers() + + val response = responseFuture.get() + response.validate() + } +} diff --git a/prelude-java-core/src/test/kotlin/so/prelude/sdk/services/blocking/NotifyServiceTest.kt b/prelude-java-core/src/test/kotlin/so/prelude/sdk/services/blocking/NotifyServiceTest.kt index 64b81af4..63d007c1 100644 --- a/prelude-java-core/src/test/kotlin/so/prelude/sdk/services/blocking/NotifyServiceTest.kt +++ b/prelude-java-core/src/test/kotlin/so/prelude/sdk/services/blocking/NotifyServiceTest.kt @@ -12,6 +12,7 @@ import so.prelude.sdk.models.NotifyGetSubscriptionPhoneNumberParams import so.prelude.sdk.models.NotifyListSubscriptionConfigsParams import so.prelude.sdk.models.NotifyListSubscriptionPhoneNumberEventsParams import so.prelude.sdk.models.NotifyListSubscriptionPhoneNumbersParams +import so.prelude.sdk.models.NotifyReplyParams import so.prelude.sdk.models.NotifySendBatchParams import so.prelude.sdk.models.NotifySendParams @@ -113,6 +114,29 @@ internal class NotifyServiceTest { response.validate() } + @Test + fun reply() { + val client = + PreludeOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiToken("My API Token") + .build() + val notifyService = client.notify() + + val response = + notifyService.reply( + NotifyReplyParams.builder() + .replyTo("im_01k8aq2zggeyssvt53zgvpx63a") + .text("Thanks for reaching out! We'll look into your request.") + .to("+33612345678") + .callbackUrl("https://your-app.com/webhooks/notify") + .correlationId("support-ticket-42") + .build() + ) + + response.validate() + } + @Test fun send() { val client = diff --git a/prelude-java-core/src/test/kotlin/so/prelude/sdk/services/blocking/VerificationServiceTest.kt b/prelude-java-core/src/test/kotlin/so/prelude/sdk/services/blocking/VerificationServiceTest.kt index 0001a2d2..082247cb 100644 --- a/prelude-java-core/src/test/kotlin/so/prelude/sdk/services/blocking/VerificationServiceTest.kt +++ b/prelude-java-core/src/test/kotlin/so/prelude/sdk/services/blocking/VerificationServiceTest.kt @@ -7,6 +7,8 @@ import org.junit.jupiter.api.extension.ExtendWith import so.prelude.sdk.TestServerExtension import so.prelude.sdk.client.okhttp.PreludeOkHttpClient import so.prelude.sdk.core.JsonValue +import so.prelude.sdk.models.Signals +import so.prelude.sdk.models.Target import so.prelude.sdk.models.VerificationCheckParams import so.prelude.sdk.models.VerificationCreateParams @@ -26,8 +28,8 @@ internal class VerificationServiceTest { verificationService.create( VerificationCreateParams.builder() .target( - VerificationCreateParams.Target.builder() - .type(VerificationCreateParams.Target.Type.PHONE_NUMBER) + Target.builder() + .type(Target.Type.PHONE_NUMBER) .value("+30123456789") .build() ) @@ -67,11 +69,11 @@ internal class VerificationServiceTest { .build() ) .signals( - VerificationCreateParams.Signals.builder() + Signals.builder() .appVersion("1.2.34") .deviceId("8F0B8FDD-C2CB-4387-B20A-56E9B2E5A0D2") .deviceModel("iPhone17,2") - .devicePlatform(VerificationCreateParams.Signals.DevicePlatform.IOS) + .devicePlatform(Signals.DevicePlatform.IOS) .existingUser(false) .ip("203.0.113.123") .isTrustedUser(false) @@ -102,8 +104,8 @@ internal class VerificationServiceTest { VerificationCheckParams.builder() .code("12345") .target( - VerificationCheckParams.Target.builder() - .type(VerificationCheckParams.Target.Type.PHONE_NUMBER) + Target.builder() + .type(Target.Type.PHONE_NUMBER) .value("+30123456789") .build() ) diff --git a/prelude-java-core/src/test/kotlin/so/prelude/sdk/services/blocking/WatchServiceTest.kt b/prelude-java-core/src/test/kotlin/so/prelude/sdk/services/blocking/WatchServiceTest.kt index 7bee3348..72061dc4 100644 --- a/prelude-java-core/src/test/kotlin/so/prelude/sdk/services/blocking/WatchServiceTest.kt +++ b/prelude-java-core/src/test/kotlin/so/prelude/sdk/services/blocking/WatchServiceTest.kt @@ -6,6 +6,10 @@ import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith import so.prelude.sdk.TestServerExtension import so.prelude.sdk.client.okhttp.PreludeOkHttpClient +import so.prelude.sdk.core.JsonValue +import so.prelude.sdk.models.Signals +import so.prelude.sdk.models.Target +import so.prelude.sdk.models.WatchEvaluateParams import so.prelude.sdk.models.WatchPredictParams import so.prelude.sdk.models.WatchSendEventsParams import so.prelude.sdk.models.WatchSendFeedbacksParams @@ -13,6 +17,54 @@ import so.prelude.sdk.models.WatchSendFeedbacksParams @ExtendWith(TestServerExtension::class) internal class WatchServiceTest { + @Test + fun evaluate() { + val client = + PreludeOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiToken("My API Token") + .build() + val watchService = client.watch() + + val response = + watchService.evaluate( + WatchEvaluateParams.builder() + .flowId("flo_01jc0t6fwwfgfsq1md24mhyztj") + .target( + Target.builder() + .type(Target.Type.PHONE_NUMBER) + .value("+30123456789") + .build() + ) + .attributes( + WatchEvaluateParams.Attributes.builder() + .putAdditionalProperty("plan_tier", JsonValue.from("free")) + .putAdditionalProperty("account_age_days", JsonValue.from("3")) + .build() + ) + .dispatchId("123e4567-e89b-12d3-a456-426614174000") + .signals( + Signals.builder() + .appVersion("1.2.34") + .deviceId("8F0B8FDD-C2CB-4387-B20A-56E9B2E5A0D2") + .deviceModel("iPhone17,2") + .devicePlatform(Signals.DevicePlatform.IOS) + .existingUser(false) + .ip("203.0.113.123") + .isTrustedUser(false) + .ja4Fingerprint("t13d1516h2_8daaf6152771_e5627efa2ab1") + .osVersion("18.0.1") + .userAgent( + "Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.3 Mobile/15E148 Safari/604.1" + ) + .build() + ) + .build() + ) + + response.validate() + } + @Test fun predict() { val client = @@ -26,8 +78,8 @@ internal class WatchServiceTest { watchService.predict( WatchPredictParams.builder() .target( - WatchPredictParams.Target.builder() - .type(WatchPredictParams.Target.Type.PHONE_NUMBER) + Target.builder() + .type(Target.Type.PHONE_NUMBER) .value("+30123456789") .build() ) @@ -38,11 +90,11 @@ internal class WatchServiceTest { .build() ) .signals( - WatchPredictParams.Signals.builder() + Signals.builder() .appVersion("1.2.34") .deviceId("8F0B8FDD-C2CB-4387-B20A-56E9B2E5A0D2") .deviceModel("iPhone17,2") - .devicePlatform(WatchPredictParams.Signals.DevicePlatform.IOS) + .devicePlatform(Signals.DevicePlatform.IOS) .existingUser(false) .ip("203.0.113.123") .isTrustedUser(false) @@ -76,8 +128,8 @@ internal class WatchServiceTest { .confidence(WatchSendEventsParams.Event.Confidence.MAXIMUM) .label("account.banned") .target( - WatchSendEventsParams.Event.Target.builder() - .type(WatchSendEventsParams.Event.Target.Type.PHONE_NUMBER) + Target.builder() + .type(Target.Type.PHONE_NUMBER) .value("+30123456789") .build() ) @@ -104,10 +156,8 @@ internal class WatchServiceTest { .addFeedback( WatchSendFeedbacksParams.Feedback.builder() .target( - WatchSendFeedbacksParams.Feedback.Target.builder() - .type( - WatchSendFeedbacksParams.Feedback.Target.Type.PHONE_NUMBER - ) + Target.builder() + .type(Target.Type.PHONE_NUMBER) .value("+30123456789") .build() ) diff --git a/prelude-java-core/src/test/kotlin/so/prelude/sdk/services/blocking/intel/KycServiceTest.kt b/prelude-java-core/src/test/kotlin/so/prelude/sdk/services/blocking/intel/KycServiceTest.kt new file mode 100644 index 00000000..1b15a3d2 --- /dev/null +++ b/prelude-java-core/src/test/kotlin/so/prelude/sdk/services/blocking/intel/KycServiceTest.kt @@ -0,0 +1,42 @@ +// File generated from our OpenAPI spec by Stainless. + +package so.prelude.sdk.services.blocking.intel + +import java.time.LocalDate +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith +import so.prelude.sdk.TestServerExtension +import so.prelude.sdk.client.okhttp.PreludeOkHttpClient +import so.prelude.sdk.models.IntelKycMatchParams + +@ExtendWith(TestServerExtension::class) +internal class KycServiceTest { + + @Test + fun match() { + val client = + PreludeOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiToken("My API Token") + .build() + val kycService = client.intel().kyc() + + val response = + kycService.match( + IntelKycMatchParams.builder() + .phone("+12065550100") + .address("12 rue de la Paix") + .birthdate(LocalDate.parse("1990-01-15")) + .country("FR") + .email("jean.dupont@example.com") + .familyName("Dupont") + .givenName("Jean") + .locality("Paris") + .postalCode("75002") + .region("Île-de-France") + .build() + ) + + response.validate() + } +} diff --git a/prelude-java-core/src/test/kotlin/so/prelude/sdk/services/blocking/verification/phone/HistoryServiceTest.kt b/prelude-java-core/src/test/kotlin/so/prelude/sdk/services/blocking/verification/phone/HistoryServiceTest.kt new file mode 100644 index 00000000..6fff0f9b --- /dev/null +++ b/prelude-java-core/src/test/kotlin/so/prelude/sdk/services/blocking/verification/phone/HistoryServiceTest.kt @@ -0,0 +1,58 @@ +// File generated from our OpenAPI spec by Stainless. + +package so.prelude.sdk.services.blocking.verification.phone + +import java.time.OffsetDateTime +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith +import so.prelude.sdk.TestServerExtension +import so.prelude.sdk.client.okhttp.PreludeOkHttpClient +import so.prelude.sdk.models.VerificationPhoneHistoryListParams + +@ExtendWith(TestServerExtension::class) +internal class HistoryServiceTest { + + @Test + fun retrieve() { + val client = + PreludeOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiToken("My API Token") + .build() + val historyService = client.verification().phone().history() + + val history = historyService.retrieve("vrf_01jc0t6fwwfgfsq1md24mhyztj") + + history.validate() + } + + @Test + fun list() { + val client = + PreludeOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiToken("My API Token") + .build() + val historyService = client.verification().phone().history() + + val histories = + historyService.list( + VerificationPhoneHistoryListParams.builder() + .addChannel(VerificationPhoneHistoryListParams.Channel.SMS) + .cursor("cursor") + .devicePlatform(VerificationPhoneHistoryListParams.DevicePlatform.ANDROID) + .from(OffsetDateTime.parse("2026-09-01T00:00:00Z")) + .limit(1L) + .maxAttempts(0L) + .minAttempts(0L) + .phoneNumber("+33612345678") + .region("FR") + .status(VerificationPhoneHistoryListParams.Status.CONVERTED) + .templateId("template_01jc0t6fwwfgfsq1md24mhyztj") + .to(OffsetDateTime.parse("2026-09-08T00:00:00Z")) + .build() + ) + + histories.validate() + } +} diff --git a/prelude-java-core/src/test/kotlin/so/prelude/sdk/services/blocking/verificationManagement/SandboxServiceTest.kt b/prelude-java-core/src/test/kotlin/so/prelude/sdk/services/blocking/verificationManagement/SandboxServiceTest.kt new file mode 100644 index 00000000..205327d3 --- /dev/null +++ b/prelude-java-core/src/test/kotlin/so/prelude/sdk/services/blocking/verificationManagement/SandboxServiceTest.kt @@ -0,0 +1,61 @@ +// File generated from our OpenAPI spec by Stainless. + +package so.prelude.sdk.services.blocking.verificationManagement + +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith +import so.prelude.sdk.TestServerExtension +import so.prelude.sdk.client.okhttp.PreludeOkHttpClient +import so.prelude.sdk.models.VerificationManagementSandboxAddPhoneNumberParams + +@ExtendWith(TestServerExtension::class) +internal class SandboxServiceTest { + + @Test + fun addPhoneNumber() { + val client = + PreludeOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiToken("My API Token") + .build() + val sandboxService = client.verificationManagement().sandbox() + + val response = + sandboxService.addPhoneNumber( + VerificationManagementSandboxAddPhoneNumberParams.builder() + .attemptCode("123456") + .phoneNumber("+30123456789") + .build() + ) + + response.validate() + } + + @Test + fun deletePhoneNumber() { + val client = + PreludeOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiToken("My API Token") + .build() + val sandboxService = client.verificationManagement().sandbox() + + val response = sandboxService.deletePhoneNumber("+12065550100") + + response.validate() + } + + @Test + fun listPhoneNumbers() { + val client = + PreludeOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiToken("My API Token") + .build() + val sandboxService = client.verificationManagement().sandbox() + + val response = sandboxService.listPhoneNumbers() + + response.validate() + } +} diff --git a/prelude-java-proguard-test/src/test/kotlin/so/prelude/sdk/proguard/ProGuardCompatibilityTest.kt b/prelude-java-proguard-test/src/test/kotlin/so/prelude/sdk/proguard/ProGuardCompatibilityTest.kt index 7b85eea3..9df77a52 100644 --- a/prelude-java-proguard-test/src/test/kotlin/so/prelude/sdk/proguard/ProGuardCompatibilityTest.kt +++ b/prelude-java-proguard-test/src/test/kotlin/so/prelude/sdk/proguard/ProGuardCompatibilityTest.kt @@ -53,6 +53,7 @@ internal class ProGuardCompatibilityTest { assertThat(client.verification()).isNotNull() assertThat(client.verificationManagement()).isNotNull() assertThat(client.watch()).isNotNull() + assertThat(client.intel()).isNotNull() } @Test