diff --git a/.release-please-manifest.json b/.release-please-manifest.json index dd4fc525c..4d6b09da1 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "6.29.0" + ".": "6.30.0" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index 5be268d0c..bc43a0f0e 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ -configured_endpoints: 975 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/telnyx%2Ftelnyx-dd7ad9ab732796305a9df0e8d9a179ade1da3fc61481e97b5cb32fc8b994ec3e.yml -openapi_spec_hash: 181b2e53e84c5fc20c94655071723527 -config_hash: 5d71cbaf27f63f9d363f3007d99d52e9 +configured_endpoints: 990 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/telnyx%2Ftelnyx-c39f4809dcbdc6578bcbac6dee9201bf644b3ea726a177bad109dc1741bb1af7.yml +openapi_spec_hash: 83778fa2320ecccb46e85201c47c6a26 +config_hash: b314a1db2a665ac943d39160db40c05d diff --git a/CHANGELOG.md b/CHANGELOG.md index f6d3fd65f..4c759ed06 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,23 @@ # Changelog +## 6.30.0 (2026-03-13) + +Full Changelog: [v6.29.0...v6.30.0](https://github.com/team-telnyx/telnyx-java/compare/v6.29.0...v6.30.0) + +### Features + +* add public x402 payment endpoints to external specs ([b7fd2ea](https://github.com/team-telnyx/telnyx-java/commit/b7fd2ea5a9b2a0db79343811989ff18a4b3bc045)) +* Add Voice Designs and Voice Clones API specification ([aa3b836](https://github.com/team-telnyx/telnyx-java/commit/aa3b83691821a2b4f6ee8b545e02790fc272d92b)) +* AI-2131: Add expressive_mode boolean to VoiceSettings ([7394919](https://github.com/team-telnyx/telnyx-java/commit/7394919715a13fdb079cf5c514cbae747a0faca6)) +* **api:** manual updates ([8ec5265](https://github.com/team-telnyx/telnyx-java/commit/8ec526546a542d94fdfbae12fc5a8013b37d90f4)) +* **api:** Merge pull request [#29](https://github.com/team-telnyx/telnyx-java/issues/29) from stainless-sdks/fix-add-voice-model ([d23bcc4](https://github.com/team-telnyx/telnyx-java/commit/d23bcc4e2a6a8f17b0b51d622e8bd0f96676cf56)) +* **api:** update OpenAPI spec or Stainless config ([d23bcc4](https://github.com/team-telnyx/telnyx-java/commit/d23bcc4e2a6a8f17b0b51d622e8bd0f96676cf56)) + + +### Bug Fixes + +* **call-recordings:** align OpenAPI spec with implementation ([57e7cae](https://github.com/team-telnyx/telnyx-java/commit/57e7cae9781f30c09498d7023b4993dfc9b0f422)) + ## 6.29.0 (2026-03-11) Full Changelog: [v6.28.0...v6.29.0](https://github.com/team-telnyx/telnyx-java/compare/v6.28.0...v6.29.0) diff --git a/README.md b/README.md index 7f474ceea..2ba241ace 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ -[![Maven Central](https://img.shields.io/maven-central/v/com.telnyx.sdk/telnyx)](https://central.sonatype.com/artifact/com.telnyx.sdk/telnyx/6.29.0) +[![Maven Central](https://img.shields.io/maven-central/v/com.telnyx.sdk/telnyx)](https://central.sonatype.com/artifact/com.telnyx.sdk/telnyx/6.30.0) @@ -26,7 +26,7 @@ Use the Telnyx MCP Server to enable AI assistants to interact with this API, all ### Gradle ```kotlin -implementation("com.telnyx.sdk:telnyx:6.29.0") +implementation("com.telnyx.sdk:telnyx:6.30.0") ``` ### Maven @@ -35,7 +35,7 @@ implementation("com.telnyx.sdk:telnyx:6.29.0") com.telnyx.sdk telnyx - 6.29.0 + 6.30.0 ``` diff --git a/build.gradle.kts b/build.gradle.kts index a1f4c6bc3..1b9c9895b 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,6 +1,6 @@ allprojects { group = "com.telnyx.sdk" - version = "6.29.0" // x-release-please-version + version = "6.30.0" // x-release-please-version } subprojects { diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/client/TelnyxClient.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/client/TelnyxClient.kt index f6d316302..46bd10599 100644 --- a/telnyx-core/src/main/kotlin/com/telnyx/sdk/client/TelnyxClient.kt +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/client/TelnyxClient.kt @@ -148,6 +148,8 @@ import com.telnyx.sdk.services.blocking.VerifiedNumberService import com.telnyx.sdk.services.blocking.VerifyProfileService import com.telnyx.sdk.services.blocking.VirtualCrossConnectService import com.telnyx.sdk.services.blocking.VirtualCrossConnectsCoverageService +import com.telnyx.sdk.services.blocking.VoiceCloneService +import com.telnyx.sdk.services.blocking.VoiceDesignService import com.telnyx.sdk.services.blocking.WebhookDeliveryService import com.telnyx.sdk.services.blocking.WebhookService import com.telnyx.sdk.services.blocking.WellKnownService @@ -158,6 +160,7 @@ import com.telnyx.sdk.services.blocking.WireguardPeerService import com.telnyx.sdk.services.blocking.WirelessBlocklistService import com.telnyx.sdk.services.blocking.WirelessBlocklistValueService import com.telnyx.sdk.services.blocking.WirelessService +import com.telnyx.sdk.services.blocking.X402Service import java.util.function.Consumer /** @@ -642,6 +645,14 @@ interface TelnyxClient { /** Manage Whatsapp message templates */ fun whatsappMessageTemplates(): WhatsappMessageTemplateService + /** Capture and manage voice identities as clones for use in text-to-speech synthesis. */ + fun voiceClones(): VoiceCloneService + + /** Create and manage AI-generated voice designs using natural language prompts. */ + fun voiceDesigns(): VoiceDesignService + + fun x402(): X402Service + /** * Closes this client, relinquishing any underlying resources. * @@ -1111,5 +1122,13 @@ interface TelnyxClient { /** Manage Whatsapp message templates */ fun whatsappMessageTemplates(): WhatsappMessageTemplateService.WithRawResponse + + /** Capture and manage voice identities as clones for use in text-to-speech synthesis. */ + fun voiceClones(): VoiceCloneService.WithRawResponse + + /** Create and manage AI-generated voice designs using natural language prompts. */ + fun voiceDesigns(): VoiceDesignService.WithRawResponse + + fun x402(): X402Service.WithRawResponse } } diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/client/TelnyxClientAsync.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/client/TelnyxClientAsync.kt index d40aca647..48e0f2f22 100644 --- a/telnyx-core/src/main/kotlin/com/telnyx/sdk/client/TelnyxClientAsync.kt +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/client/TelnyxClientAsync.kt @@ -148,6 +148,8 @@ import com.telnyx.sdk.services.async.VerifiedNumberServiceAsync import com.telnyx.sdk.services.async.VerifyProfileServiceAsync import com.telnyx.sdk.services.async.VirtualCrossConnectServiceAsync import com.telnyx.sdk.services.async.VirtualCrossConnectsCoverageServiceAsync +import com.telnyx.sdk.services.async.VoiceCloneServiceAsync +import com.telnyx.sdk.services.async.VoiceDesignServiceAsync import com.telnyx.sdk.services.async.WebhookDeliveryServiceAsync import com.telnyx.sdk.services.async.WebhookServiceAsync import com.telnyx.sdk.services.async.WellKnownServiceAsync @@ -158,6 +160,7 @@ import com.telnyx.sdk.services.async.WireguardPeerServiceAsync import com.telnyx.sdk.services.async.WirelessBlocklistServiceAsync import com.telnyx.sdk.services.async.WirelessBlocklistValueServiceAsync import com.telnyx.sdk.services.async.WirelessServiceAsync +import com.telnyx.sdk.services.async.X402ServiceAsync import java.util.function.Consumer /** @@ -642,6 +645,14 @@ interface TelnyxClientAsync { /** Manage Whatsapp message templates */ fun whatsappMessageTemplates(): WhatsappMessageTemplateServiceAsync + /** Capture and manage voice identities as clones for use in text-to-speech synthesis. */ + fun voiceClones(): VoiceCloneServiceAsync + + /** Create and manage AI-generated voice designs using natural language prompts. */ + fun voiceDesigns(): VoiceDesignServiceAsync + + fun x402(): X402ServiceAsync + /** * Closes this client, relinquishing any underlying resources. * @@ -1114,5 +1125,13 @@ interface TelnyxClientAsync { /** Manage Whatsapp message templates */ fun whatsappMessageTemplates(): WhatsappMessageTemplateServiceAsync.WithRawResponse + + /** Capture and manage voice identities as clones for use in text-to-speech synthesis. */ + fun voiceClones(): VoiceCloneServiceAsync.WithRawResponse + + /** Create and manage AI-generated voice designs using natural language prompts. */ + fun voiceDesigns(): VoiceDesignServiceAsync.WithRawResponse + + fun x402(): X402ServiceAsync.WithRawResponse } } diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/client/TelnyxClientAsyncImpl.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/client/TelnyxClientAsyncImpl.kt index b3aed03d1..4c27f1dd2 100644 --- a/telnyx-core/src/main/kotlin/com/telnyx/sdk/client/TelnyxClientAsyncImpl.kt +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/client/TelnyxClientAsyncImpl.kt @@ -294,6 +294,10 @@ import com.telnyx.sdk.services.async.VirtualCrossConnectServiceAsync import com.telnyx.sdk.services.async.VirtualCrossConnectServiceAsyncImpl import com.telnyx.sdk.services.async.VirtualCrossConnectsCoverageServiceAsync import com.telnyx.sdk.services.async.VirtualCrossConnectsCoverageServiceAsyncImpl +import com.telnyx.sdk.services.async.VoiceCloneServiceAsync +import com.telnyx.sdk.services.async.VoiceCloneServiceAsyncImpl +import com.telnyx.sdk.services.async.VoiceDesignServiceAsync +import com.telnyx.sdk.services.async.VoiceDesignServiceAsyncImpl import com.telnyx.sdk.services.async.WebhookDeliveryServiceAsync import com.telnyx.sdk.services.async.WebhookDeliveryServiceAsyncImpl import com.telnyx.sdk.services.async.WebhookServiceAsync @@ -314,6 +318,8 @@ import com.telnyx.sdk.services.async.WirelessBlocklistValueServiceAsync import com.telnyx.sdk.services.async.WirelessBlocklistValueServiceAsyncImpl import com.telnyx.sdk.services.async.WirelessServiceAsync import com.telnyx.sdk.services.async.WirelessServiceAsyncImpl +import com.telnyx.sdk.services.async.X402ServiceAsync +import com.telnyx.sdk.services.async.X402ServiceAsyncImpl import java.util.function.Consumer class TelnyxClientAsyncImpl(private val clientOptions: ClientOptions) : TelnyxClientAsync { @@ -938,6 +944,16 @@ class TelnyxClientAsyncImpl(private val clientOptions: ClientOptions) : TelnyxCl WhatsappMessageTemplateServiceAsyncImpl(clientOptionsWithUserAgent) } + private val voiceClones: VoiceCloneServiceAsync by lazy { + VoiceCloneServiceAsyncImpl(clientOptionsWithUserAgent) + } + + private val voiceDesigns: VoiceDesignServiceAsync by lazy { + VoiceDesignServiceAsyncImpl(clientOptionsWithUserAgent) + } + + private val x402: X402ServiceAsync by lazy { X402ServiceAsyncImpl(clientOptionsWithUserAgent) } + override fun sync(): TelnyxClient = sync override fun withRawResponse(): TelnyxClientAsync.WithRawResponse = withRawResponse @@ -1420,6 +1436,14 @@ class TelnyxClientAsyncImpl(private val clientOptions: ClientOptions) : TelnyxCl override fun whatsappMessageTemplates(): WhatsappMessageTemplateServiceAsync = whatsappMessageTemplates + /** Capture and manage voice identities as clones for use in text-to-speech synthesis. */ + override fun voiceClones(): VoiceCloneServiceAsync = voiceClones + + /** Create and manage AI-generated voice designs using natural language prompts. */ + override fun voiceDesigns(): VoiceDesignServiceAsync = voiceDesigns + + override fun x402(): X402ServiceAsync = x402 + override fun close() = clientOptions.close() class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : @@ -2081,6 +2105,18 @@ class TelnyxClientAsyncImpl(private val clientOptions: ClientOptions) : TelnyxCl WhatsappMessageTemplateServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + private val voiceClones: VoiceCloneServiceAsync.WithRawResponse by lazy { + VoiceCloneServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val voiceDesigns: VoiceDesignServiceAsync.WithRawResponse by lazy { + VoiceDesignServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val x402: X402ServiceAsync.WithRawResponse by lazy { + X402ServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + override fun withOptions( modifier: Consumer ): TelnyxClientAsync.WithRawResponse = @@ -2611,5 +2647,13 @@ class TelnyxClientAsyncImpl(private val clientOptions: ClientOptions) : TelnyxCl /** Manage Whatsapp message templates */ override fun whatsappMessageTemplates(): WhatsappMessageTemplateServiceAsync.WithRawResponse = whatsappMessageTemplates + + /** Capture and manage voice identities as clones for use in text-to-speech synthesis. */ + override fun voiceClones(): VoiceCloneServiceAsync.WithRawResponse = voiceClones + + /** Create and manage AI-generated voice designs using natural language prompts. */ + override fun voiceDesigns(): VoiceDesignServiceAsync.WithRawResponse = voiceDesigns + + override fun x402(): X402ServiceAsync.WithRawResponse = x402 } } diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/client/TelnyxClientImpl.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/client/TelnyxClientImpl.kt index 5fe595600..452ca3bae 100644 --- a/telnyx-core/src/main/kotlin/com/telnyx/sdk/client/TelnyxClientImpl.kt +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/client/TelnyxClientImpl.kt @@ -294,6 +294,10 @@ import com.telnyx.sdk.services.blocking.VirtualCrossConnectService import com.telnyx.sdk.services.blocking.VirtualCrossConnectServiceImpl import com.telnyx.sdk.services.blocking.VirtualCrossConnectsCoverageService import com.telnyx.sdk.services.blocking.VirtualCrossConnectsCoverageServiceImpl +import com.telnyx.sdk.services.blocking.VoiceCloneService +import com.telnyx.sdk.services.blocking.VoiceCloneServiceImpl +import com.telnyx.sdk.services.blocking.VoiceDesignService +import com.telnyx.sdk.services.blocking.VoiceDesignServiceImpl import com.telnyx.sdk.services.blocking.WebhookDeliveryService import com.telnyx.sdk.services.blocking.WebhookDeliveryServiceImpl import com.telnyx.sdk.services.blocking.WebhookService @@ -314,6 +318,8 @@ import com.telnyx.sdk.services.blocking.WirelessBlocklistValueService import com.telnyx.sdk.services.blocking.WirelessBlocklistValueServiceImpl import com.telnyx.sdk.services.blocking.WirelessService import com.telnyx.sdk.services.blocking.WirelessServiceImpl +import com.telnyx.sdk.services.blocking.X402Service +import com.telnyx.sdk.services.blocking.X402ServiceImpl import java.util.function.Consumer class TelnyxClientImpl(private val clientOptions: ClientOptions) : TelnyxClient { @@ -896,6 +902,16 @@ class TelnyxClientImpl(private val clientOptions: ClientOptions) : TelnyxClient WhatsappMessageTemplateServiceImpl(clientOptionsWithUserAgent) } + private val voiceClones: VoiceCloneService by lazy { + VoiceCloneServiceImpl(clientOptionsWithUserAgent) + } + + private val voiceDesigns: VoiceDesignService by lazy { + VoiceDesignServiceImpl(clientOptionsWithUserAgent) + } + + private val x402: X402Service by lazy { X402ServiceImpl(clientOptionsWithUserAgent) } + override fun async(): TelnyxClientAsync = async override fun withRawResponse(): TelnyxClient.WithRawResponse = withRawResponse @@ -1364,6 +1380,14 @@ class TelnyxClientImpl(private val clientOptions: ClientOptions) : TelnyxClient override fun whatsappMessageTemplates(): WhatsappMessageTemplateService = whatsappMessageTemplates + /** Capture and manage voice identities as clones for use in text-to-speech synthesis. */ + override fun voiceClones(): VoiceCloneService = voiceClones + + /** Create and manage AI-generated voice designs using natural language prompts. */ + override fun voiceDesigns(): VoiceDesignService = voiceDesigns + + override fun x402(): X402Service = x402 + override fun close() = clientOptions.close() class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : @@ -2004,6 +2028,18 @@ class TelnyxClientImpl(private val clientOptions: ClientOptions) : TelnyxClient WhatsappMessageTemplateServiceImpl.WithRawResponseImpl(clientOptions) } + private val voiceClones: VoiceCloneService.WithRawResponse by lazy { + VoiceCloneServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val voiceDesigns: VoiceDesignService.WithRawResponse by lazy { + VoiceDesignServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val x402: X402Service.WithRawResponse by lazy { + X402ServiceImpl.WithRawResponseImpl(clientOptions) + } + override fun withOptions( modifier: Consumer ): TelnyxClient.WithRawResponse = @@ -2521,5 +2557,13 @@ class TelnyxClientImpl(private val clientOptions: ClientOptions) : TelnyxClient /** Manage Whatsapp message templates */ override fun whatsappMessageTemplates(): WhatsappMessageTemplateService.WithRawResponse = whatsappMessageTemplates + + /** Capture and manage voice identities as clones for use in text-to-speech synthesis. */ + override fun voiceClones(): VoiceCloneService.WithRawResponse = voiceClones + + /** Create and manage AI-generated voice designs using natural language prompts. */ + override fun voiceDesigns(): VoiceDesignService.WithRawResponse = voiceDesigns + + override fun x402(): X402Service.WithRawResponse = x402 } } diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/ai/assistants/VoiceSettings.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/ai/assistants/VoiceSettings.kt index 1430f6b74..195e634a8 100644 --- a/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/ai/assistants/VoiceSettings.kt +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/ai/assistants/VoiceSettings.kt @@ -34,6 +34,7 @@ private constructor( private val voice: JsonField, private val apiKeyRef: JsonField, private val backgroundAudio: JsonField, + private val expressiveMode: JsonField, private val languageBoost: JsonField, private val similarityBoost: JsonField, private val speed: JsonField, @@ -53,6 +54,9 @@ private constructor( @JsonProperty("background_audio") @ExcludeMissing backgroundAudio: JsonField = JsonMissing.of(), + @JsonProperty("expressive_mode") + @ExcludeMissing + expressiveMode: JsonField = JsonMissing.of(), @JsonProperty("language_boost") @ExcludeMissing languageBoost: JsonField = JsonMissing.of(), @@ -74,6 +78,7 @@ private constructor( voice, apiKeyRef, backgroundAudio, + expressiveMode, languageBoost, similarityBoost, speed, @@ -119,6 +124,16 @@ private constructor( fun backgroundAudio(): Optional = backgroundAudio.getOptional("background_audio") + /** + * Enables emotionally expressive speech using SSML emotion tags. When enabled, the assistant + * uses audio tags like angry, excited, content, and sad to add emotional nuance. Only supported + * for Telnyx Ultra voices. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun expressiveMode(): Optional = expressiveMode.getOptional("expressive_mode") + /** * Enhances recognition for specific languages and dialects during MiniMax TTS synthesis. * Default is null (no boost). Set to 'auto' for automatic language detection. Only applicable @@ -208,6 +223,15 @@ private constructor( @ExcludeMissing fun _backgroundAudio(): JsonField = backgroundAudio + /** + * Returns the raw JSON value of [expressiveMode]. + * + * Unlike [expressiveMode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("expressive_mode") + @ExcludeMissing + fun _expressiveMode(): JsonField = expressiveMode + /** * Returns the raw JSON value of [languageBoost]. * @@ -294,6 +318,7 @@ private constructor( private var voice: JsonField? = null private var apiKeyRef: JsonField = JsonMissing.of() private var backgroundAudio: JsonField = JsonMissing.of() + private var expressiveMode: JsonField = JsonMissing.of() private var languageBoost: JsonField = JsonMissing.of() private var similarityBoost: JsonField = JsonMissing.of() private var speed: JsonField = JsonMissing.of() @@ -308,6 +333,7 @@ private constructor( voice = voiceSettings.voice apiKeyRef = voiceSettings.apiKeyRef backgroundAudio = voiceSettings.backgroundAudio + expressiveMode = voiceSettings.expressiveMode languageBoost = voiceSettings.languageBoost similarityBoost = voiceSettings.similarityBoost speed = voiceSettings.speed @@ -422,6 +448,24 @@ private constructor( fun mediaNameBackgroundAudio(value: String) = backgroundAudio(BackgroundAudio.MediaName.builder().value(value).build()) + /** + * Enables emotionally expressive speech using SSML emotion tags. When enabled, the + * assistant uses audio tags like angry, excited, content, and sad to add emotional nuance. + * Only supported for Telnyx Ultra voices. + */ + fun expressiveMode(expressiveMode: Boolean) = expressiveMode(JsonField.of(expressiveMode)) + + /** + * Sets [Builder.expressiveMode] to an arbitrary JSON value. + * + * You should usually call [Builder.expressiveMode] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun expressiveMode(expressiveMode: JsonField) = apply { + this.expressiveMode = expressiveMode + } + /** * Enhances recognition for specific languages and dialects during MiniMax TTS synthesis. * Default is null (no boost). Set to 'auto' for automatic language detection. Only @@ -577,6 +621,7 @@ private constructor( checkRequired("voice", voice), apiKeyRef, backgroundAudio, + expressiveMode, languageBoost, similarityBoost, speed, @@ -598,6 +643,7 @@ private constructor( voice() apiKeyRef() backgroundAudio().ifPresent { it.validate() } + expressiveMode() languageBoost().ifPresent { it.validate() } similarityBoost() speed() @@ -626,6 +672,7 @@ private constructor( (if (voice.asKnown().isPresent) 1 else 0) + (if (apiKeyRef.asKnown().isPresent) 1 else 0) + (backgroundAudio.asKnown().getOrNull()?.validity() ?: 0) + + (if (expressiveMode.asKnown().isPresent) 1 else 0) + (languageBoost.asKnown().getOrNull()?.validity() ?: 0) + (if (similarityBoost.asKnown().isPresent) 1 else 0) + (if (speed.asKnown().isPresent) 1 else 0) + @@ -1972,6 +2019,7 @@ private constructor( voice == other.voice && apiKeyRef == other.apiKeyRef && backgroundAudio == other.backgroundAudio && + expressiveMode == other.expressiveMode && languageBoost == other.languageBoost && similarityBoost == other.similarityBoost && speed == other.speed && @@ -1987,6 +2035,7 @@ private constructor( voice, apiKeyRef, backgroundAudio, + expressiveMode, languageBoost, similarityBoost, speed, @@ -2001,5 +2050,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "VoiceSettings{voice=$voice, apiKeyRef=$apiKeyRef, backgroundAudio=$backgroundAudio, languageBoost=$languageBoost, similarityBoost=$similarityBoost, speed=$speed, style=$style, temperature=$temperature, useSpeakerBoost=$useSpeakerBoost, voiceSpeed=$voiceSpeed, additionalProperties=$additionalProperties}" + "VoiceSettings{voice=$voice, apiKeyRef=$apiKeyRef, backgroundAudio=$backgroundAudio, expressiveMode=$expressiveMode, languageBoost=$languageBoost, similarityBoost=$similarityBoost, speed=$speed, style=$style, temperature=$temperature, useSpeakerBoost=$useSpeakerBoost, voiceSpeed=$voiceSpeed, additionalProperties=$additionalProperties}" } diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/recordings/RecordingListParams.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/recordings/RecordingListParams.kt index 35fd4a76d..6ba134cae 100644 --- a/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/recordings/RecordingListParams.kt +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/recordings/RecordingListParams.kt @@ -19,11 +19,7 @@ private constructor( private val additionalQueryParams: QueryParams, ) : Params { - /** - * Consolidated filter parameter (deepObject style). Originally: filter[conference_id], - * filter[created_at][gte], filter[created_at][lte], filter[call_leg_id], - * filter[call_session_id], filter[from], filter[to], filter[connection_id], filter[sip_call_id] - */ + /** Filter recordings by various attributes. */ fun filter(): Optional = Optional.ofNullable(filter) fun pageNumber(): Optional = Optional.ofNullable(pageNumber) @@ -64,12 +60,7 @@ private constructor( additionalQueryParams = recordingListParams.additionalQueryParams.toBuilder() } - /** - * Consolidated filter parameter (deepObject style). Originally: filter[conference_id], - * filter[created_at][gte], filter[created_at][lte], filter[call_leg_id], - * filter[call_session_id], filter[from], filter[to], filter[connection_id], - * filter[sip_call_id] - */ + /** Filter recordings by various attributes. */ fun filter(filter: Filter?) = apply { this.filter = filter } /** Alias for calling [Builder.filter] with `filter.orElse(null)`. */ @@ -218,9 +209,11 @@ private constructor( QueryParams.builder() .apply { filter?.let { + it.callControlId().ifPresent { put("filter[call_control_id]", it) } it.callLegId().ifPresent { put("filter[call_leg_id]", it) } it.callSessionId().ifPresent { put("filter[call_session_id]", it) } it.conferenceId().ifPresent { put("filter[conference_id]", it) } + it.conferenceRegion().ifPresent { put("filter[conference_region]", it) } it.connectionId().ifPresent { put("filter[connection_id]", it) } it.createdAt().ifPresent { it.gte().ifPresent { put("filter[created_at][gte]", it) } @@ -231,8 +224,26 @@ private constructor( } } } + it.endTime().ifPresent { + it.gte().ifPresent { put("filter[end_time][gte]", it) } + it.lte().ifPresent { put("filter[end_time][lte]", it) } + it._additionalProperties().keys().forEach { key -> + it._additionalProperties().values(key).forEach { value -> + put("filter[end_time][$key]", value) + } + } + } it.from().ifPresent { put("filter[from]", it) } it.sipCallId().ifPresent { put("filter[sip_call_id]", it) } + it.startTime().ifPresent { + it.gte().ifPresent { put("filter[start_time][gte]", it) } + it.lte().ifPresent { put("filter[start_time][lte]", it) } + it._additionalProperties().keys().forEach { key -> + it._additionalProperties().values(key).forEach { value -> + put("filter[start_time][$key]", value) + } + } + } it.to().ifPresent { put("filter[to]", it) } it._additionalProperties().keys().forEach { key -> it._additionalProperties().values(key).forEach { value -> @@ -246,24 +257,27 @@ private constructor( } .build() - /** - * Consolidated filter parameter (deepObject style). Originally: filter[conference_id], - * filter[created_at][gte], filter[created_at][lte], filter[call_leg_id], - * filter[call_session_id], filter[from], filter[to], filter[connection_id], filter[sip_call_id] - */ + /** Filter recordings by various attributes. */ class Filter private constructor( + private val callControlId: String?, private val callLegId: String?, private val callSessionId: String?, private val conferenceId: String?, + private val conferenceRegion: String?, private val connectionId: String?, private val createdAt: CreatedAt?, + private val endTime: EndTime?, private val from: String?, private val sipCallId: String?, + private val startTime: StartTime?, private val to: String?, private val additionalProperties: QueryParams, ) { + /** If present, recordings will be filtered to those with a matching `call_control_id`. */ + fun callControlId(): Optional = Optional.ofNullable(callControlId) + /** If present, recordings will be filtered to those with a matching call_leg_id. */ fun callLegId(): Optional = Optional.ofNullable(callLegId) @@ -273,6 +287,9 @@ private constructor( /** Returns only recordings associated with a given conference. */ fun conferenceId(): Optional = Optional.ofNullable(conferenceId) + /** If present, recordings will be filtered to those with a matching `conference_region`. */ + fun conferenceRegion(): Optional = Optional.ofNullable(conferenceRegion) + /** * If present, recordings will be filtered to those with a matching `connection_id` * attribute (case-sensitive). @@ -281,6 +298,8 @@ private constructor( fun createdAt(): Optional = Optional.ofNullable(createdAt) + fun endTime(): Optional = Optional.ofNullable(endTime) + /** * If present, recordings will be filtered to those with a matching `from` attribute * (case-sensitive). @@ -289,10 +308,12 @@ private constructor( /** * If present, recordings will be filtered to those with a matching `sip_call_id` attribute. - * Matching is case-sensitive + * Matching is case-sensitive. */ fun sipCallId(): Optional = Optional.ofNullable(sipCallId) + fun startTime(): Optional = Optional.ofNullable(startTime) + /** * If present, recordings will be filtered to those with a matching `to` attribute * (case-sensitive). @@ -313,29 +334,46 @@ private constructor( /** A builder for [Filter]. */ class Builder internal constructor() { + private var callControlId: String? = null private var callLegId: String? = null private var callSessionId: String? = null private var conferenceId: String? = null + private var conferenceRegion: String? = null private var connectionId: String? = null private var createdAt: CreatedAt? = null + private var endTime: EndTime? = null private var from: String? = null private var sipCallId: String? = null + private var startTime: StartTime? = null private var to: String? = null private var additionalProperties: QueryParams.Builder = QueryParams.builder() @JvmSynthetic internal fun from(filter: Filter) = apply { + callControlId = filter.callControlId callLegId = filter.callLegId callSessionId = filter.callSessionId conferenceId = filter.conferenceId + conferenceRegion = filter.conferenceRegion connectionId = filter.connectionId createdAt = filter.createdAt + endTime = filter.endTime from = filter.from sipCallId = filter.sipCallId + startTime = filter.startTime to = filter.to additionalProperties = filter.additionalProperties.toBuilder() } + /** + * If present, recordings will be filtered to those with a matching `call_control_id`. + */ + fun callControlId(callControlId: String?) = apply { this.callControlId = callControlId } + + /** Alias for calling [Builder.callControlId] with `callControlId.orElse(null)`. */ + fun callControlId(callControlId: Optional) = + callControlId(callControlId.getOrNull()) + /** If present, recordings will be filtered to those with a matching call_leg_id. */ fun callLegId(callLegId: String?) = apply { this.callLegId = callLegId } @@ -356,6 +394,19 @@ private constructor( fun conferenceId(conferenceId: Optional) = conferenceId(conferenceId.getOrNull()) + /** + * If present, recordings will be filtered to those with a matching `conference_region`. + */ + fun conferenceRegion(conferenceRegion: String?) = apply { + this.conferenceRegion = conferenceRegion + } + + /** + * Alias for calling [Builder.conferenceRegion] with `conferenceRegion.orElse(null)`. + */ + fun conferenceRegion(conferenceRegion: Optional) = + conferenceRegion(conferenceRegion.getOrNull()) + /** * If present, recordings will be filtered to those with a matching `connection_id` * attribute (case-sensitive). @@ -371,6 +422,11 @@ private constructor( /** Alias for calling [Builder.createdAt] with `createdAt.orElse(null)`. */ fun createdAt(createdAt: Optional) = createdAt(createdAt.getOrNull()) + fun endTime(endTime: EndTime?) = apply { this.endTime = endTime } + + /** Alias for calling [Builder.endTime] with `endTime.orElse(null)`. */ + fun endTime(endTime: Optional) = endTime(endTime.getOrNull()) + /** * If present, recordings will be filtered to those with a matching `from` attribute * (case-sensitive). @@ -382,13 +438,18 @@ private constructor( /** * If present, recordings will be filtered to those with a matching `sip_call_id` - * attribute. Matching is case-sensitive + * attribute. Matching is case-sensitive. */ fun sipCallId(sipCallId: String?) = apply { this.sipCallId = sipCallId } /** Alias for calling [Builder.sipCallId] with `sipCallId.orElse(null)`. */ fun sipCallId(sipCallId: Optional) = sipCallId(sipCallId.getOrNull()) + fun startTime(startTime: StartTime?) = apply { this.startTime = startTime } + + /** Alias for calling [Builder.startTime] with `startTime.orElse(null)`. */ + fun startTime(startTime: Optional) = startTime(startTime.getOrNull()) + /** * If present, recordings will be filtered to those with a matching `to` attribute * (case-sensitive). @@ -454,13 +515,17 @@ private constructor( */ fun build(): Filter = Filter( + callControlId, callLegId, callSessionId, conferenceId, + conferenceRegion, connectionId, createdAt, + endTime, from, sipCallId, + startTime, to, additionalProperties.build(), ) @@ -594,32 +659,320 @@ private constructor( "CreatedAt{gte=$gte, lte=$lte, additionalProperties=$additionalProperties}" } + class EndTime + private constructor( + private val gte: String?, + private val lte: String?, + private val additionalProperties: QueryParams, + ) { + + /** + * Returns only recordings with an end time later than or equal to the given ISO 8601 + * datetime. + */ + fun gte(): Optional = Optional.ofNullable(gte) + + /** + * Returns only recordings with an end time earlier than or equal to the given ISO 8601 + * datetime. + */ + fun lte(): Optional = Optional.ofNullable(lte) + + /** Query params to send with the request. */ + fun _additionalProperties(): QueryParams = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [EndTime]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [EndTime]. */ + class Builder internal constructor() { + + private var gte: String? = null + private var lte: String? = null + private var additionalProperties: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(endTime: EndTime) = apply { + gte = endTime.gte + lte = endTime.lte + additionalProperties = endTime.additionalProperties.toBuilder() + } + + /** + * Returns only recordings with an end time later than or equal to the given ISO + * 8601 datetime. + */ + fun gte(gte: String?) = apply { this.gte = gte } + + /** Alias for calling [Builder.gte] with `gte.orElse(null)`. */ + fun gte(gte: Optional) = gte(gte.getOrNull()) + + /** + * Returns only recordings with an end time earlier than or equal to the given ISO + * 8601 datetime. + */ + fun lte(lte: String?) = apply { this.lte = lte } + + /** Alias for calling [Builder.lte] with `lte.orElse(null)`. */ + fun lte(lte: Optional) = lte(lte.getOrNull()) + + fun additionalProperties(additionalProperties: QueryParams) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun additionalProperties(additionalProperties: Map>) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: String) = apply { + additionalProperties.put(key, value) + } + + fun putAdditionalProperties(key: String, values: Iterable) = apply { + additionalProperties.put(key, values) + } + + fun putAllAdditionalProperties(additionalProperties: QueryParams) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun putAllAdditionalProperties( + additionalProperties: Map> + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun replaceAdditionalProperties(key: String, value: String) = apply { + additionalProperties.replace(key, value) + } + + fun replaceAdditionalProperties(key: String, values: Iterable) = apply { + additionalProperties.replace(key, values) + } + + fun replaceAllAdditionalProperties(additionalProperties: QueryParams) = apply { + this.additionalProperties.replaceAll(additionalProperties) + } + + fun replaceAllAdditionalProperties( + additionalProperties: Map> + ) = apply { this.additionalProperties.replaceAll(additionalProperties) } + + fun removeAdditionalProperties(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + additionalProperties.removeAll(keys) + } + + /** + * Returns an immutable instance of [EndTime]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): EndTime = EndTime(gte, lte, additionalProperties.build()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is EndTime && + gte == other.gte && + lte == other.lte && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(gte, lte, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "EndTime{gte=$gte, lte=$lte, additionalProperties=$additionalProperties}" + } + + class StartTime + private constructor( + private val gte: String?, + private val lte: String?, + private val additionalProperties: QueryParams, + ) { + + /** + * Returns only recordings with a start time later than or equal to the given ISO 8601 + * datetime. + */ + fun gte(): Optional = Optional.ofNullable(gte) + + /** + * Returns only recordings with a start time earlier than or equal to the given ISO 8601 + * datetime. + */ + fun lte(): Optional = Optional.ofNullable(lte) + + /** Query params to send with the request. */ + fun _additionalProperties(): QueryParams = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [StartTime]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [StartTime]. */ + class Builder internal constructor() { + + private var gte: String? = null + private var lte: String? = null + private var additionalProperties: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(startTime: StartTime) = apply { + gte = startTime.gte + lte = startTime.lte + additionalProperties = startTime.additionalProperties.toBuilder() + } + + /** + * Returns only recordings with a start time later than or equal to the given ISO + * 8601 datetime. + */ + fun gte(gte: String?) = apply { this.gte = gte } + + /** Alias for calling [Builder.gte] with `gte.orElse(null)`. */ + fun gte(gte: Optional) = gte(gte.getOrNull()) + + /** + * Returns only recordings with a start time earlier than or equal to the given ISO + * 8601 datetime. + */ + fun lte(lte: String?) = apply { this.lte = lte } + + /** Alias for calling [Builder.lte] with `lte.orElse(null)`. */ + fun lte(lte: Optional) = lte(lte.getOrNull()) + + fun additionalProperties(additionalProperties: QueryParams) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun additionalProperties(additionalProperties: Map>) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: String) = apply { + additionalProperties.put(key, value) + } + + fun putAdditionalProperties(key: String, values: Iterable) = apply { + additionalProperties.put(key, values) + } + + fun putAllAdditionalProperties(additionalProperties: QueryParams) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun putAllAdditionalProperties( + additionalProperties: Map> + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun replaceAdditionalProperties(key: String, value: String) = apply { + additionalProperties.replace(key, value) + } + + fun replaceAdditionalProperties(key: String, values: Iterable) = apply { + additionalProperties.replace(key, values) + } + + fun replaceAllAdditionalProperties(additionalProperties: QueryParams) = apply { + this.additionalProperties.replaceAll(additionalProperties) + } + + fun replaceAllAdditionalProperties( + additionalProperties: Map> + ) = apply { this.additionalProperties.replaceAll(additionalProperties) } + + fun removeAdditionalProperties(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + additionalProperties.removeAll(keys) + } + + /** + * Returns an immutable instance of [StartTime]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): StartTime = StartTime(gte, lte, additionalProperties.build()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is StartTime && + gte == other.gte && + lte == other.lte && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(gte, lte, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "StartTime{gte=$gte, lte=$lte, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true } return other is Filter && + callControlId == other.callControlId && callLegId == other.callLegId && callSessionId == other.callSessionId && conferenceId == other.conferenceId && + conferenceRegion == other.conferenceRegion && connectionId == other.connectionId && createdAt == other.createdAt && + endTime == other.endTime && from == other.from && sipCallId == other.sipCallId && + startTime == other.startTime && to == other.to && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( + callControlId, callLegId, callSessionId, conferenceId, + conferenceRegion, connectionId, createdAt, + endTime, from, sipCallId, + startTime, to, additionalProperties, ) @@ -628,7 +981,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Filter{callLegId=$callLegId, callSessionId=$callSessionId, conferenceId=$conferenceId, connectionId=$connectionId, createdAt=$createdAt, from=$from, sipCallId=$sipCallId, to=$to, additionalProperties=$additionalProperties}" + "Filter{callControlId=$callControlId, callLegId=$callLegId, callSessionId=$callSessionId, conferenceId=$conferenceId, conferenceRegion=$conferenceRegion, connectionId=$connectionId, createdAt=$createdAt, endTime=$endTime, from=$from, sipCallId=$sipCallId, startTime=$startTime, to=$to, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/recordings/RecordingResponseData.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/recordings/RecordingResponseData.kt index 2ea43d721..d9df7a167 100644 --- a/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/recordings/RecordingResponseData.kt +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/recordings/RecordingResponseData.kt @@ -26,14 +26,18 @@ private constructor( private val callSessionId: JsonField, private val channels: JsonField, private val conferenceId: JsonField, + private val connectionId: JsonField, private val createdAt: JsonField, private val downloadUrls: JsonField, private val durationMillis: JsonField, + private val from: JsonField, + private val initiatedBy: JsonField, private val recordType: JsonField, private val recordingEndedAt: JsonField, private val recordingStartedAt: JsonField, private val source: JsonField, private val status: JsonField, + private val to: JsonField, private val updatedAt: JsonField, private val additionalProperties: MutableMap, ) { @@ -54,6 +58,9 @@ private constructor( @JsonProperty("conference_id") @ExcludeMissing conferenceId: JsonField = JsonMissing.of(), + @JsonProperty("connection_id") + @ExcludeMissing + connectionId: JsonField = JsonMissing.of(), @JsonProperty("created_at") @ExcludeMissing createdAt: JsonField = JsonMissing.of(), @JsonProperty("download_urls") @ExcludeMissing @@ -61,6 +68,10 @@ private constructor( @JsonProperty("duration_millis") @ExcludeMissing durationMillis: JsonField = JsonMissing.of(), + @JsonProperty("from") @ExcludeMissing from: JsonField = JsonMissing.of(), + @JsonProperty("initiated_by") + @ExcludeMissing + initiatedBy: JsonField = JsonMissing.of(), @JsonProperty("record_type") @ExcludeMissing recordType: JsonField = JsonMissing.of(), @@ -72,6 +83,7 @@ private constructor( recordingStartedAt: JsonField = JsonMissing.of(), @JsonProperty("source") @ExcludeMissing source: JsonField = JsonMissing.of(), @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + @JsonProperty("to") @ExcludeMissing to: JsonField = JsonMissing.of(), @JsonProperty("updated_at") @ExcludeMissing updatedAt: JsonField = JsonMissing.of(), ) : this( id, @@ -80,14 +92,18 @@ private constructor( callSessionId, channels, conferenceId, + connectionId, createdAt, downloadUrls, durationMillis, + from, + initiatedBy, recordType, recordingEndedAt, recordingStartedAt, source, status, + to, updatedAt, mutableMapOf(), ) @@ -142,6 +158,15 @@ private constructor( */ fun conferenceId(): Optional = conferenceId.getOptional("conference_id") + /** + * Identifies the Telnyx application (Call Control, TeXML) or SIP connection resource associated + * with this recording. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun connectionId(): Optional = connectionId.getOptional("connection_id") + /** * ISO 8601 formatted date indicating when the resource was created. * @@ -166,6 +191,24 @@ private constructor( */ fun durationMillis(): Optional = durationMillis.getOptional("duration_millis") + /** + * The `from` (caller) number for the call that generated this recording. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun from(): Optional = from.getOptional("from") + + /** + * Indicates what triggered the recording. Possible values include `DialVerb`, `Conference`, + * `OutboundAPI`, `Trunking`, `RecordVerb`, `StartCallRecordingAPI`, + * `StartConferenceRecordingAPI`. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun initiatedBy(): Optional = initiatedBy.getOptional("initiated_by") + /** * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -205,6 +248,14 @@ private constructor( */ fun status(): Optional = status.getOptional("status") + /** + * The `to` (callee) number for the call that generated this recording. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun to(): Optional = to.getOptional("to") + /** * ISO 8601 formatted date indicating when the resource was updated. * @@ -261,6 +312,15 @@ private constructor( @ExcludeMissing fun _conferenceId(): JsonField = conferenceId + /** + * Returns the raw JSON value of [connectionId]. + * + * Unlike [connectionId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("connection_id") + @ExcludeMissing + fun _connectionId(): JsonField = connectionId + /** * Returns the raw JSON value of [createdAt]. * @@ -286,6 +346,22 @@ private constructor( @ExcludeMissing fun _durationMillis(): JsonField = durationMillis + /** + * Returns the raw JSON value of [from]. + * + * Unlike [from], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("from") @ExcludeMissing fun _from(): JsonField = from + + /** + * Returns the raw JSON value of [initiatedBy]. + * + * Unlike [initiatedBy], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("initiated_by") + @ExcludeMissing + fun _initiatedBy(): JsonField = initiatedBy + /** * Returns the raw JSON value of [recordType]. * @@ -329,6 +405,13 @@ private constructor( */ @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + /** + * 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 [updatedAt]. * @@ -363,14 +446,18 @@ private constructor( private var callSessionId: JsonField = JsonMissing.of() private var channels: JsonField = JsonMissing.of() private var conferenceId: JsonField = JsonMissing.of() + private var connectionId: JsonField = JsonMissing.of() private var createdAt: JsonField = JsonMissing.of() private var downloadUrls: JsonField = JsonMissing.of() private var durationMillis: JsonField = JsonMissing.of() + private var from: JsonField = JsonMissing.of() + private var initiatedBy: JsonField = JsonMissing.of() private var recordType: JsonField = JsonMissing.of() private var recordingEndedAt: JsonField = JsonMissing.of() private var recordingStartedAt: JsonField = JsonMissing.of() private var source: JsonField = JsonMissing.of() private var status: JsonField = JsonMissing.of() + private var to: JsonField = JsonMissing.of() private var updatedAt: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -382,14 +469,18 @@ private constructor( callSessionId = recordingResponseData.callSessionId channels = recordingResponseData.channels conferenceId = recordingResponseData.conferenceId + connectionId = recordingResponseData.connectionId createdAt = recordingResponseData.createdAt downloadUrls = recordingResponseData.downloadUrls durationMillis = recordingResponseData.durationMillis + from = recordingResponseData.from + initiatedBy = recordingResponseData.initiatedBy recordType = recordingResponseData.recordType recordingEndedAt = recordingResponseData.recordingEndedAt recordingStartedAt = recordingResponseData.recordingStartedAt source = recordingResponseData.source status = recordingResponseData.status + to = recordingResponseData.to updatedAt = recordingResponseData.updatedAt additionalProperties = recordingResponseData.additionalProperties.toMutableMap() } @@ -478,6 +569,23 @@ private constructor( this.conferenceId = conferenceId } + /** + * Identifies the Telnyx application (Call Control, TeXML) or SIP connection resource + * associated with this recording. + */ + fun connectionId(connectionId: String) = connectionId(JsonField.of(connectionId)) + + /** + * Sets [Builder.connectionId] to an arbitrary JSON value. + * + * You should usually call [Builder.connectionId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun connectionId(connectionId: JsonField) = apply { + this.connectionId = connectionId + } + /** ISO 8601 formatted date indicating when the resource was created. */ fun createdAt(createdAt: String) = createdAt(JsonField.of(createdAt)) @@ -518,6 +626,33 @@ private constructor( this.durationMillis = durationMillis } + /** The `from` (caller) number for the call that generated this recording. */ + fun from(from: String) = from(JsonField.of(from)) + + /** + * Sets [Builder.from] to an arbitrary JSON value. + * + * You should usually call [Builder.from] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun from(from: JsonField) = apply { this.from = from } + + /** + * Indicates what triggered the recording. Possible values include `DialVerb`, `Conference`, + * `OutboundAPI`, `Trunking`, `RecordVerb`, `StartCallRecordingAPI`, + * `StartConferenceRecordingAPI`. + */ + fun initiatedBy(initiatedBy: String) = initiatedBy(JsonField.of(initiatedBy)) + + /** + * Sets [Builder.initiatedBy] to an arbitrary JSON value. + * + * You should usually call [Builder.initiatedBy] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun initiatedBy(initiatedBy: JsonField) = apply { this.initiatedBy = initiatedBy } + fun recordType(recordType: RecordType) = recordType(JsonField.of(recordType)) /** @@ -581,6 +716,17 @@ private constructor( */ fun status(status: JsonField) = apply { this.status = status } + /** The `to` (callee) number for the call that generated this recording. */ + 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 } + /** ISO 8601 formatted date indicating when the resource was updated. */ fun updatedAt(updatedAt: String) = updatedAt(JsonField.of(updatedAt)) @@ -625,14 +771,18 @@ private constructor( callSessionId, channels, conferenceId, + connectionId, createdAt, downloadUrls, durationMillis, + from, + initiatedBy, recordType, recordingEndedAt, recordingStartedAt, source, status, + to, updatedAt, additionalProperties.toMutableMap(), ) @@ -651,14 +801,18 @@ private constructor( callSessionId() channels().ifPresent { it.validate() } conferenceId() + connectionId() createdAt() downloadUrls().ifPresent { it.validate() } durationMillis() + from() + initiatedBy() recordType().ifPresent { it.validate() } recordingEndedAt() recordingStartedAt() source().ifPresent { it.validate() } status().ifPresent { it.validate() } + to() updatedAt() validated = true } @@ -684,14 +838,18 @@ private constructor( (if (callSessionId.asKnown().isPresent) 1 else 0) + (channels.asKnown().getOrNull()?.validity() ?: 0) + (if (conferenceId.asKnown().isPresent) 1 else 0) + + (if (connectionId.asKnown().isPresent) 1 else 0) + (if (createdAt.asKnown().isPresent) 1 else 0) + (downloadUrls.asKnown().getOrNull()?.validity() ?: 0) + (if (durationMillis.asKnown().isPresent) 1 else 0) + + (if (from.asKnown().isPresent) 1 else 0) + + (if (initiatedBy.asKnown().isPresent) 1 else 0) + (recordType.asKnown().getOrNull()?.validity() ?: 0) + (if (recordingEndedAt.asKnown().isPresent) 1 else 0) + (if (recordingStartedAt.asKnown().isPresent) 1 else 0) + (source.asKnown().getOrNull()?.validity() ?: 0) + (status.asKnown().getOrNull()?.validity() ?: 0) + + (if (to.asKnown().isPresent) 1 else 0) + (if (updatedAt.asKnown().isPresent) 1 else 0) /** @@ -1378,14 +1536,18 @@ private constructor( callSessionId == other.callSessionId && channels == other.channels && conferenceId == other.conferenceId && + connectionId == other.connectionId && createdAt == other.createdAt && downloadUrls == other.downloadUrls && durationMillis == other.durationMillis && + from == other.from && + initiatedBy == other.initiatedBy && recordType == other.recordType && recordingEndedAt == other.recordingEndedAt && recordingStartedAt == other.recordingStartedAt && source == other.source && status == other.status && + to == other.to && updatedAt == other.updatedAt && additionalProperties == other.additionalProperties } @@ -1398,14 +1560,18 @@ private constructor( callSessionId, channels, conferenceId, + connectionId, createdAt, downloadUrls, durationMillis, + from, + initiatedBy, recordType, recordingEndedAt, recordingStartedAt, source, status, + to, updatedAt, additionalProperties, ) @@ -1414,5 +1580,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "RecordingResponseData{id=$id, callControlId=$callControlId, callLegId=$callLegId, callSessionId=$callSessionId, channels=$channels, conferenceId=$conferenceId, createdAt=$createdAt, downloadUrls=$downloadUrls, durationMillis=$durationMillis, recordType=$recordType, recordingEndedAt=$recordingEndedAt, recordingStartedAt=$recordingStartedAt, source=$source, status=$status, updatedAt=$updatedAt, additionalProperties=$additionalProperties}" + "RecordingResponseData{id=$id, callControlId=$callControlId, callLegId=$callLegId, callSessionId=$callSessionId, channels=$channels, conferenceId=$conferenceId, connectionId=$connectionId, createdAt=$createdAt, downloadUrls=$downloadUrls, durationMillis=$durationMillis, from=$from, initiatedBy=$initiatedBy, recordType=$recordType, recordingEndedAt=$recordingEndedAt, recordingStartedAt=$recordingStartedAt, source=$source, status=$status, to=$to, updatedAt=$updatedAt, additionalProperties=$additionalProperties}" } diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/recordings/actions/ActionDeleteResponse.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/recordings/actions/ActionDeleteResponse.kt new file mode 100644 index 000000000..45c14b83e --- /dev/null +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/recordings/actions/ActionDeleteResponse.kt @@ -0,0 +1,274 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.recordings.actions + +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 com.telnyx.sdk.core.Enum +import com.telnyx.sdk.core.ExcludeMissing +import com.telnyx.sdk.core.JsonField +import com.telnyx.sdk.core.JsonMissing +import com.telnyx.sdk.core.JsonValue +import com.telnyx.sdk.errors.TelnyxInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class ActionDeleteResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val status: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of() + ) : this(status, mutableMapOf()) + + /** + * @throws TelnyxInvalidDataException 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 [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 [ActionDeleteResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ActionDeleteResponse]. */ + class Builder internal constructor() { + + private var status: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(actionDeleteResponse: ActionDeleteResponse) = apply { + status = actionDeleteResponse.status + additionalProperties = actionDeleteResponse.additionalProperties.toMutableMap() + } + + 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 [ActionDeleteResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ActionDeleteResponse = + ActionDeleteResponse(status, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): ActionDeleteResponse = apply { + if (validated) { + return@apply + } + + status().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: TelnyxInvalidDataException) { + 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 = (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 OK = of("ok") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + OK + } + + /** + * 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 { + OK, + /** 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) { + OK -> Value.OK + 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 TelnyxInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + OK -> Known.OK + else -> throw TelnyxInvalidDataException("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 TelnyxInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { TelnyxInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: TelnyxInvalidDataException) { + 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 ActionDeleteResponse && + status == other.status && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(status, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ActionDeleteResponse{status=$status, additionalProperties=$additionalProperties}" +} diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/recordingtranscriptions/RecordingTranscriptionListPage.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/recordingtranscriptions/RecordingTranscriptionListPage.kt new file mode 100644 index 000000000..ae3f5d415 --- /dev/null +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/recordingtranscriptions/RecordingTranscriptionListPage.kt @@ -0,0 +1,136 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.recordingtranscriptions + +import com.telnyx.sdk.core.AutoPager +import com.telnyx.sdk.core.Page +import com.telnyx.sdk.core.checkRequired +import com.telnyx.sdk.services.blocking.RecordingTranscriptionService +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrDefault +import kotlin.jvm.optionals.getOrNull + +/** @see RecordingTranscriptionService.list */ +class RecordingTranscriptionListPage +private constructor( + private val service: RecordingTranscriptionService, + private val params: RecordingTranscriptionListParams, + private val response: RecordingTranscriptionListPageResponse, +) : Page { + + /** + * Delegates to [RecordingTranscriptionListPageResponse], but gracefully handles missing data. + * + * @see RecordingTranscriptionListPageResponse.data + */ + fun data(): List = + response._data().getOptional("data").getOrNull() ?: emptyList() + + /** + * Delegates to [RecordingTranscriptionListPageResponse], but gracefully handles missing data. + * + * @see RecordingTranscriptionListPageResponse.meta + */ + fun meta(): Optional = + response._meta().getOptional("meta") + + override fun items(): List = data() + + override fun hasNextPage(): Boolean = items().isNotEmpty() + + fun nextPageParams(): RecordingTranscriptionListParams { + val pageNumber = params.pageNumber().getOrDefault(1) + return params.toBuilder().pageNumber(pageNumber + 1).build() + } + + override fun nextPage(): RecordingTranscriptionListPage = service.list(nextPageParams()) + + fun autoPager(): AutoPager = AutoPager.from(this) + + /** The parameters that were used to request this page. */ + fun params(): RecordingTranscriptionListParams = params + + /** The response that this page was parsed from. */ + fun response(): RecordingTranscriptionListPageResponse = response + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [RecordingTranscriptionListPage]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RecordingTranscriptionListPage]. */ + class Builder internal constructor() { + + private var service: RecordingTranscriptionService? = null + private var params: RecordingTranscriptionListParams? = null + private var response: RecordingTranscriptionListPageResponse? = null + + @JvmSynthetic + internal fun from(recordingTranscriptionListPage: RecordingTranscriptionListPage) = apply { + service = recordingTranscriptionListPage.service + params = recordingTranscriptionListPage.params + response = recordingTranscriptionListPage.response + } + + fun service(service: RecordingTranscriptionService) = apply { this.service = service } + + /** The parameters that were used to request this page. */ + fun params(params: RecordingTranscriptionListParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: RecordingTranscriptionListPageResponse) = apply { + this.response = response + } + + /** + * Returns an immutable instance of [RecordingTranscriptionListPage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RecordingTranscriptionListPage = + RecordingTranscriptionListPage( + checkRequired("service", service), + checkRequired("params", params), + checkRequired("response", response), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RecordingTranscriptionListPage && + service == other.service && + params == other.params && + response == other.response + } + + override fun hashCode(): Int = Objects.hash(service, params, response) + + override fun toString() = + "RecordingTranscriptionListPage{service=$service, params=$params, response=$response}" +} diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/recordingtranscriptions/RecordingTranscriptionListPageAsync.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/recordingtranscriptions/RecordingTranscriptionListPageAsync.kt new file mode 100644 index 000000000..5d6b42b9a --- /dev/null +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/recordingtranscriptions/RecordingTranscriptionListPageAsync.kt @@ -0,0 +1,153 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.recordingtranscriptions + +import com.telnyx.sdk.core.AutoPagerAsync +import com.telnyx.sdk.core.PageAsync +import com.telnyx.sdk.core.checkRequired +import com.telnyx.sdk.services.async.RecordingTranscriptionServiceAsync +import java.util.Objects +import java.util.Optional +import java.util.concurrent.CompletableFuture +import java.util.concurrent.Executor +import kotlin.jvm.optionals.getOrDefault +import kotlin.jvm.optionals.getOrNull + +/** @see RecordingTranscriptionServiceAsync.list */ +class RecordingTranscriptionListPageAsync +private constructor( + private val service: RecordingTranscriptionServiceAsync, + private val streamHandlerExecutor: Executor, + private val params: RecordingTranscriptionListParams, + private val response: RecordingTranscriptionListPageResponse, +) : PageAsync { + + /** + * Delegates to [RecordingTranscriptionListPageResponse], but gracefully handles missing data. + * + * @see RecordingTranscriptionListPageResponse.data + */ + fun data(): List = + response._data().getOptional("data").getOrNull() ?: emptyList() + + /** + * Delegates to [RecordingTranscriptionListPageResponse], but gracefully handles missing data. + * + * @see RecordingTranscriptionListPageResponse.meta + */ + fun meta(): Optional = + response._meta().getOptional("meta") + + override fun items(): List = data() + + override fun hasNextPage(): Boolean = items().isNotEmpty() + + fun nextPageParams(): RecordingTranscriptionListParams { + val pageNumber = params.pageNumber().getOrDefault(1) + return params.toBuilder().pageNumber(pageNumber + 1).build() + } + + override fun nextPage(): CompletableFuture = + service.list(nextPageParams()) + + fun autoPager(): AutoPagerAsync = + AutoPagerAsync.from(this, streamHandlerExecutor) + + /** The parameters that were used to request this page. */ + fun params(): RecordingTranscriptionListParams = params + + /** The response that this page was parsed from. */ + fun response(): RecordingTranscriptionListPageResponse = response + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [RecordingTranscriptionListPageAsync]. + * + * The following fields are required: + * ```java + * .service() + * .streamHandlerExecutor() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RecordingTranscriptionListPageAsync]. */ + class Builder internal constructor() { + + private var service: RecordingTranscriptionServiceAsync? = null + private var streamHandlerExecutor: Executor? = null + private var params: RecordingTranscriptionListParams? = null + private var response: RecordingTranscriptionListPageResponse? = null + + @JvmSynthetic + internal fun from( + recordingTranscriptionListPageAsync: RecordingTranscriptionListPageAsync + ) = apply { + service = recordingTranscriptionListPageAsync.service + streamHandlerExecutor = recordingTranscriptionListPageAsync.streamHandlerExecutor + params = recordingTranscriptionListPageAsync.params + response = recordingTranscriptionListPageAsync.response + } + + fun service(service: RecordingTranscriptionServiceAsync) = apply { this.service = service } + + fun streamHandlerExecutor(streamHandlerExecutor: Executor) = apply { + this.streamHandlerExecutor = streamHandlerExecutor + } + + /** The parameters that were used to request this page. */ + fun params(params: RecordingTranscriptionListParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: RecordingTranscriptionListPageResponse) = apply { + this.response = response + } + + /** + * Returns an immutable instance of [RecordingTranscriptionListPageAsync]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .streamHandlerExecutor() + * .params() + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RecordingTranscriptionListPageAsync = + RecordingTranscriptionListPageAsync( + checkRequired("service", service), + checkRequired("streamHandlerExecutor", streamHandlerExecutor), + checkRequired("params", params), + checkRequired("response", response), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RecordingTranscriptionListPageAsync && + service == other.service && + streamHandlerExecutor == other.streamHandlerExecutor && + params == other.params && + response == other.response + } + + override fun hashCode(): Int = Objects.hash(service, streamHandlerExecutor, params, response) + + override fun toString() = + "RecordingTranscriptionListPageAsync{service=$service, streamHandlerExecutor=$streamHandlerExecutor, params=$params, response=$response}" +} diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/recordingtranscriptions/RecordingTranscriptionListResponse.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/recordingtranscriptions/RecordingTranscriptionListPageResponse.kt similarity index 94% rename from telnyx-core/src/main/kotlin/com/telnyx/sdk/models/recordingtranscriptions/RecordingTranscriptionListResponse.kt rename to telnyx-core/src/main/kotlin/com/telnyx/sdk/models/recordingtranscriptions/RecordingTranscriptionListPageResponse.kt index 2080fc1a6..745a12ce6 100644 --- a/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/recordingtranscriptions/RecordingTranscriptionListResponse.kt +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/recordingtranscriptions/RecordingTranscriptionListPageResponse.kt @@ -19,7 +19,7 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull -class RecordingTranscriptionListResponse +class RecordingTranscriptionListPageResponse @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val data: JsonField>, @@ -79,12 +79,12 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [RecordingTranscriptionListResponse]. + * [RecordingTranscriptionListPageResponse]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [RecordingTranscriptionListResponse]. */ + /** A builder for [RecordingTranscriptionListPageResponse]. */ class Builder internal constructor() { private var data: JsonField>? = null @@ -92,13 +92,14 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(recordingTranscriptionListResponse: RecordingTranscriptionListResponse) = - apply { - data = recordingTranscriptionListResponse.data.map { it.toMutableList() } - meta = recordingTranscriptionListResponse.meta - additionalProperties = - recordingTranscriptionListResponse.additionalProperties.toMutableMap() - } + internal fun from( + recordingTranscriptionListPageResponse: RecordingTranscriptionListPageResponse + ) = apply { + data = recordingTranscriptionListPageResponse.data.map { it.toMutableList() } + meta = recordingTranscriptionListPageResponse.meta + additionalProperties = + recordingTranscriptionListPageResponse.additionalProperties.toMutableMap() + } fun data(data: List) = data(JsonField.of(data)) @@ -155,12 +156,12 @@ private constructor( } /** - * Returns an immutable instance of [RecordingTranscriptionListResponse]. + * Returns an immutable instance of [RecordingTranscriptionListPageResponse]. * * Further updates to this [Builder] will not mutate the returned instance. */ - fun build(): RecordingTranscriptionListResponse = - RecordingTranscriptionListResponse( + fun build(): RecordingTranscriptionListPageResponse = + RecordingTranscriptionListPageResponse( (data ?: JsonMissing.of()).map { it.toImmutable() }, meta, additionalProperties.toMutableMap(), @@ -169,7 +170,7 @@ private constructor( private var validated: Boolean = false - fun validate(): RecordingTranscriptionListResponse = apply { + fun validate(): RecordingTranscriptionListPageResponse = apply { if (validated) { return@apply } @@ -412,7 +413,7 @@ private constructor( return true } - return other is RecordingTranscriptionListResponse && + return other is RecordingTranscriptionListPageResponse && data == other.data && meta == other.meta && additionalProperties == other.additionalProperties @@ -423,5 +424,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "RecordingTranscriptionListResponse{data=$data, meta=$meta, additionalProperties=$additionalProperties}" + "RecordingTranscriptionListPageResponse{data=$data, meta=$meta, additionalProperties=$additionalProperties}" } diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/recordingtranscriptions/RecordingTranscriptionListParams.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/recordingtranscriptions/RecordingTranscriptionListParams.kt index b4984d631..af6d40ff5 100644 --- a/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/recordingtranscriptions/RecordingTranscriptionListParams.kt +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/recordingtranscriptions/RecordingTranscriptionListParams.kt @@ -6,14 +6,26 @@ import com.telnyx.sdk.core.Params import com.telnyx.sdk.core.http.Headers import com.telnyx.sdk.core.http.QueryParams import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** Returns a list of your recording transcriptions. */ class RecordingTranscriptionListParams private constructor( + private val filter: Filter?, + private val pageNumber: Long?, + private val pageSize: Long?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { + /** Filter recording transcriptions by various attributes. */ + fun filter(): Optional = Optional.ofNullable(filter) + + fun pageNumber(): Optional = Optional.ofNullable(pageNumber) + + fun pageSize(): Optional = Optional.ofNullable(pageSize) + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders @@ -36,17 +48,53 @@ private constructor( /** A builder for [RecordingTranscriptionListParams]. */ class Builder internal constructor() { + private var filter: Filter? = null + private var pageNumber: Long? = null + private var pageSize: Long? = null private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic internal fun from(recordingTranscriptionListParams: RecordingTranscriptionListParams) = apply { + filter = recordingTranscriptionListParams.filter + pageNumber = recordingTranscriptionListParams.pageNumber + pageSize = recordingTranscriptionListParams.pageSize additionalHeaders = recordingTranscriptionListParams.additionalHeaders.toBuilder() additionalQueryParams = recordingTranscriptionListParams.additionalQueryParams.toBuilder() } + /** Filter recording transcriptions by various attributes. */ + fun filter(filter: Filter?) = apply { this.filter = filter } + + /** Alias for calling [Builder.filter] with `filter.orElse(null)`. */ + fun filter(filter: Optional) = filter(filter.getOrNull()) + + fun pageNumber(pageNumber: Long?) = apply { this.pageNumber = pageNumber } + + /** + * Alias for [Builder.pageNumber]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun pageNumber(pageNumber: Long) = pageNumber(pageNumber as Long?) + + /** Alias for calling [Builder.pageNumber] with `pageNumber.orElse(null)`. */ + fun pageNumber(pageNumber: Optional) = pageNumber(pageNumber.getOrNull()) + + fun pageSize(pageSize: Long?) = apply { this.pageSize = pageSize } + + /** + * Alias for [Builder.pageSize]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun pageSize(pageSize: Long) = pageSize(pageSize as Long?) + + /** Alias for calling [Builder.pageSize] with `pageSize.orElse(null)`. */ + fun pageSize(pageSize: Optional) = pageSize(pageSize.getOrNull()) + fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -152,6 +200,9 @@ private constructor( */ fun build(): RecordingTranscriptionListParams = RecordingTranscriptionListParams( + filter, + pageNumber, + pageSize, additionalHeaders.build(), additionalQueryParams.build(), ) @@ -159,7 +210,293 @@ private constructor( override fun _headers(): Headers = additionalHeaders - override fun _queryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + filter?.let { + it.createdAt().ifPresent { + it.gte().ifPresent { put("filter[created_at][gte]", it) } + it.lte().ifPresent { put("filter[created_at][lte]", it) } + it._additionalProperties().keys().forEach { key -> + it._additionalProperties().values(key).forEach { value -> + put("filter[created_at][$key]", value) + } + } + } + it.recordingId().ifPresent { put("filter[recording_id]", it) } + it._additionalProperties().keys().forEach { key -> + it._additionalProperties().values(key).forEach { value -> + put("filter[$key]", value) + } + } + } + pageNumber?.let { put("page[number]", it.toString()) } + pageSize?.let { put("page[size]", it.toString()) } + putAll(additionalQueryParams) + } + .build() + + /** Filter recording transcriptions by various attributes. */ + class Filter + private constructor( + private val createdAt: CreatedAt?, + private val recordingId: String?, + private val additionalProperties: QueryParams, + ) { + + fun createdAt(): Optional = Optional.ofNullable(createdAt) + + /** + * If present, transcriptions will be filtered to those associated with the given recording. + */ + fun recordingId(): Optional = Optional.ofNullable(recordingId) + + /** Query params to send with the request. */ + fun _additionalProperties(): QueryParams = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Filter]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Filter]. */ + class Builder internal constructor() { + + private var createdAt: CreatedAt? = null + private var recordingId: String? = null + private var additionalProperties: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(filter: Filter) = apply { + createdAt = filter.createdAt + recordingId = filter.recordingId + additionalProperties = filter.additionalProperties.toBuilder() + } + + fun createdAt(createdAt: CreatedAt?) = apply { this.createdAt = createdAt } + + /** Alias for calling [Builder.createdAt] with `createdAt.orElse(null)`. */ + fun createdAt(createdAt: Optional) = createdAt(createdAt.getOrNull()) + + /** + * If present, transcriptions will be filtered to those associated with the given + * recording. + */ + fun recordingId(recordingId: String?) = apply { this.recordingId = recordingId } + + /** Alias for calling [Builder.recordingId] with `recordingId.orElse(null)`. */ + fun recordingId(recordingId: Optional) = recordingId(recordingId.getOrNull()) + + fun additionalProperties(additionalProperties: QueryParams) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun additionalProperties(additionalProperties: Map>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: String) = apply { + additionalProperties.put(key, value) + } + + fun putAdditionalProperties(key: String, values: Iterable) = apply { + additionalProperties.put(key, values) + } + + fun putAllAdditionalProperties(additionalProperties: QueryParams) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun putAllAdditionalProperties(additionalProperties: Map>) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun replaceAdditionalProperties(key: String, value: String) = apply { + additionalProperties.replace(key, value) + } + + fun replaceAdditionalProperties(key: String, values: Iterable) = apply { + additionalProperties.replace(key, values) + } + + fun replaceAllAdditionalProperties(additionalProperties: QueryParams) = apply { + this.additionalProperties.replaceAll(additionalProperties) + } + + fun replaceAllAdditionalProperties( + additionalProperties: Map> + ) = apply { this.additionalProperties.replaceAll(additionalProperties) } + + fun removeAdditionalProperties(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + additionalProperties.removeAll(keys) + } + + /** + * Returns an immutable instance of [Filter]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Filter = Filter(createdAt, recordingId, additionalProperties.build()) + } + + class CreatedAt + private constructor( + private val gte: String?, + private val lte: String?, + private val additionalProperties: QueryParams, + ) { + + /** Returns only transcriptions created later than or at given ISO 8601 datetime. */ + fun gte(): Optional = Optional.ofNullable(gte) + + /** Returns only transcriptions created earlier than or at given ISO 8601 datetime. */ + fun lte(): Optional = Optional.ofNullable(lte) + + /** Query params to send with the request. */ + fun _additionalProperties(): QueryParams = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [CreatedAt]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CreatedAt]. */ + class Builder internal constructor() { + + private var gte: String? = null + private var lte: String? = null + private var additionalProperties: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(createdAt: CreatedAt) = apply { + gte = createdAt.gte + lte = createdAt.lte + additionalProperties = createdAt.additionalProperties.toBuilder() + } + + /** Returns only transcriptions created later than or at given ISO 8601 datetime. */ + fun gte(gte: String?) = apply { this.gte = gte } + + /** Alias for calling [Builder.gte] with `gte.orElse(null)`. */ + fun gte(gte: Optional) = gte(gte.getOrNull()) + + /** + * Returns only transcriptions created earlier than or at given ISO 8601 datetime. + */ + fun lte(lte: String?) = apply { this.lte = lte } + + /** Alias for calling [Builder.lte] with `lte.orElse(null)`. */ + fun lte(lte: Optional) = lte(lte.getOrNull()) + + fun additionalProperties(additionalProperties: QueryParams) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun additionalProperties(additionalProperties: Map>) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: String) = apply { + additionalProperties.put(key, value) + } + + fun putAdditionalProperties(key: String, values: Iterable) = apply { + additionalProperties.put(key, values) + } + + fun putAllAdditionalProperties(additionalProperties: QueryParams) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun putAllAdditionalProperties( + additionalProperties: Map> + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun replaceAdditionalProperties(key: String, value: String) = apply { + additionalProperties.replace(key, value) + } + + fun replaceAdditionalProperties(key: String, values: Iterable) = apply { + additionalProperties.replace(key, values) + } + + fun replaceAllAdditionalProperties(additionalProperties: QueryParams) = apply { + this.additionalProperties.replaceAll(additionalProperties) + } + + fun replaceAllAdditionalProperties( + additionalProperties: Map> + ) = apply { this.additionalProperties.replaceAll(additionalProperties) } + + fun removeAdditionalProperties(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + additionalProperties.removeAll(keys) + } + + /** + * Returns an immutable instance of [CreatedAt]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CreatedAt = CreatedAt(gte, lte, additionalProperties.build()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CreatedAt && + gte == other.gte && + lte == other.lte && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(gte, lte, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CreatedAt{gte=$gte, lte=$lte, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Filter && + createdAt == other.createdAt && + recordingId == other.recordingId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(createdAt, recordingId, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Filter{createdAt=$createdAt, recordingId=$recordingId, additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { @@ -167,12 +504,16 @@ private constructor( } return other is RecordingTranscriptionListParams && + filter == other.filter && + pageNumber == other.pageNumber && + pageSize == other.pageSize && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = Objects.hash(additionalHeaders, additionalQueryParams) + override fun hashCode(): Int = + Objects.hash(filter, pageNumber, pageSize, additionalHeaders, additionalQueryParams) override fun toString() = - "RecordingTranscriptionListParams{additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "RecordingTranscriptionListParams{filter=$filter, pageNumber=$pageNumber, pageSize=$pageSize, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/voiceclones/VoiceCloneCreateFromUploadParams.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/voiceclones/VoiceCloneCreateFromUploadParams.kt new file mode 100644 index 000000000..e36b64128 --- /dev/null +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/voiceclones/VoiceCloneCreateFromUploadParams.kt @@ -0,0 +1,923 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.voiceclones + +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 com.telnyx.sdk.core.Enum +import com.telnyx.sdk.core.ExcludeMissing +import com.telnyx.sdk.core.JsonField +import com.telnyx.sdk.core.JsonValue +import com.telnyx.sdk.core.MultipartField +import com.telnyx.sdk.core.Params +import com.telnyx.sdk.core.checkRequired +import com.telnyx.sdk.core.http.Headers +import com.telnyx.sdk.core.http.QueryParams +import com.telnyx.sdk.core.toImmutable +import com.telnyx.sdk.errors.TelnyxInvalidDataException +import java.io.InputStream +import java.nio.file.Path +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.io.path.inputStream +import kotlin.io.path.name + +/** + * Creates a new voice clone by uploading an audio file directly. Supported formats: WAV, MP3, FLAC, + * OGG, M4A. For best results, provide 5–10 seconds of clear speech. Maximum file size: 2MB. + */ +class VoiceCloneCreateFromUploadParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * Audio file to clone the voice from. Supported formats: WAV, MP3, FLAC, OGG, M4A. For best + * quality, provide 5–10 seconds of clear, uninterrupted speech. Maximum size: 2MB. + * + * @throws TelnyxInvalidDataException 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 audioFile(): InputStream = body.audioFile() + + /** + * ISO 639-1 language code (e.g. `en`, `fr`) or `auto` for automatic detection. + * + * @throws TelnyxInvalidDataException 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 language(): String = body.language() + + /** + * Name for the voice clone. + * + * @throws TelnyxInvalidDataException 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 name(): String = body.name() + + /** + * Gender of the voice clone. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun gender(): Optional = body.gender() + + /** + * Optional custom label describing the voice style. If omitted, falls back to the source + * design's prompt text. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun label(): Optional = body.label() + + /** + * Optional transcript of the audio file. Providing this improves clone quality. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun refText(): Optional = body.refText() + + /** + * Returns the raw multipart value of [audioFile]. + * + * Unlike [audioFile], this method doesn't throw if the multipart field has an unexpected type. + */ + fun _audioFile(): MultipartField = body._audioFile() + + /** + * Returns the raw multipart value of [language]. + * + * Unlike [language], this method doesn't throw if the multipart field has an unexpected type. + */ + fun _language(): MultipartField = body._language() + + /** + * Returns the raw multipart value of [name]. + * + * Unlike [name], this method doesn't throw if the multipart field has an unexpected type. + */ + fun _name(): MultipartField = body._name() + + /** + * Returns the raw multipart value of [gender]. + * + * Unlike [gender], this method doesn't throw if the multipart field has an unexpected type. + */ + fun _gender(): MultipartField = body._gender() + + /** + * Returns the raw multipart value of [label]. + * + * Unlike [label], this method doesn't throw if the multipart field has an unexpected type. + */ + fun _label(): MultipartField = body._label() + + /** + * Returns the raw multipart value of [refText]. + * + * Unlike [refText], this method doesn't throw if the multipart field has an unexpected type. + */ + fun _refText(): MultipartField = body._refText() + + 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 + * [VoiceCloneCreateFromUploadParams]. + * + * The following fields are required: + * ```java + * .audioFile() + * .language() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [VoiceCloneCreateFromUploadParams]. */ + 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(voiceCloneCreateFromUploadParams: VoiceCloneCreateFromUploadParams) = + apply { + body = voiceCloneCreateFromUploadParams.body.toBuilder() + additionalHeaders = voiceCloneCreateFromUploadParams.additionalHeaders.toBuilder() + additionalQueryParams = + voiceCloneCreateFromUploadParams.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: + * - [audioFile] + * - [language] + * - [name] + * - [gender] + * - [label] + * - etc. + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** + * Audio file to clone the voice from. Supported formats: WAV, MP3, FLAC, OGG, M4A. For best + * quality, provide 5–10 seconds of clear, uninterrupted speech. Maximum size: 2MB. + */ + fun audioFile(audioFile: InputStream) = apply { body.audioFile(audioFile) } + + /** + * Sets [Builder.audioFile] to an arbitrary multipart value. + * + * You should usually call [Builder.audioFile] with a well-typed [InputStream] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun audioFile(audioFile: MultipartField) = apply { body.audioFile(audioFile) } + + /** + * Audio file to clone the voice from. Supported formats: WAV, MP3, FLAC, OGG, M4A. For best + * quality, provide 5–10 seconds of clear, uninterrupted speech. Maximum size: 2MB. + */ + fun audioFile(audioFile: ByteArray) = apply { body.audioFile(audioFile) } + + /** + * Audio file to clone the voice from. Supported formats: WAV, MP3, FLAC, OGG, M4A. For best + * quality, provide 5–10 seconds of clear, uninterrupted speech. Maximum size: 2MB. + */ + fun audioFile(path: Path) = apply { body.audioFile(path) } + + /** ISO 639-1 language code (e.g. `en`, `fr`) or `auto` for automatic detection. */ + fun language(language: String) = apply { body.language(language) } + + /** + * Sets [Builder.language] to an arbitrary multipart value. + * + * You should usually call [Builder.language] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun language(language: MultipartField) = apply { body.language(language) } + + /** Name for the voice clone. */ + fun name(name: String) = apply { body.name(name) } + + /** + * Sets [Builder.name] to an arbitrary multipart 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: MultipartField) = apply { body.name(name) } + + /** Gender of the voice clone. */ + fun gender(gender: Gender) = apply { body.gender(gender) } + + /** + * Sets [Builder.gender] to an arbitrary multipart value. + * + * You should usually call [Builder.gender] with a well-typed [Gender] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun gender(gender: MultipartField) = apply { body.gender(gender) } + + /** + * Optional custom label describing the voice style. If omitted, falls back to the source + * design's prompt text. + */ + fun label(label: String) = apply { body.label(label) } + + /** + * Sets [Builder.label] to an arbitrary multipart value. + * + * You should usually call [Builder.label] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun label(label: MultipartField) = apply { body.label(label) } + + /** Optional transcript of the audio file. Providing this improves clone quality. */ + fun refText(refText: String) = apply { body.refText(refText) } + + /** + * Sets [Builder.refText] to an arbitrary multipart value. + * + * You should usually call [Builder.refText] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun refText(refText: MultipartField) = apply { body.refText(refText) } + + 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 [VoiceCloneCreateFromUploadParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .audioFile() + * .language() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): VoiceCloneCreateFromUploadParams = + VoiceCloneCreateFromUploadParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Map> = + (mapOf( + "audio_file" to _audioFile(), + "language" to _language(), + "name" to _name(), + "gender" to _gender(), + "label" to _label(), + "ref_text" to _refText(), + ) + _additionalBodyProperties().mapValues { (_, value) -> MultipartField.of(value) }) + .toImmutable() + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + /** Multipart form data for creating a voice clone from a direct audio upload. */ + class Body + private constructor( + private val audioFile: MultipartField, + private val language: MultipartField, + private val name: MultipartField, + private val gender: MultipartField, + private val label: MultipartField, + private val refText: MultipartField, + private val additionalProperties: MutableMap, + ) { + + /** + * Audio file to clone the voice from. Supported formats: WAV, MP3, FLAC, OGG, M4A. For best + * quality, provide 5–10 seconds of clear, uninterrupted speech. Maximum size: 2MB. + * + * @throws TelnyxInvalidDataException 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 audioFile(): InputStream = audioFile.value.getRequired("audio_file") + + /** + * ISO 639-1 language code (e.g. `en`, `fr`) or `auto` for automatic detection. + * + * @throws TelnyxInvalidDataException 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 language(): String = language.value.getRequired("language") + + /** + * Name for the voice clone. + * + * @throws TelnyxInvalidDataException 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 name(): String = name.value.getRequired("name") + + /** + * Gender of the voice clone. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun gender(): Optional = gender.value.getOptional("gender") + + /** + * Optional custom label describing the voice style. If omitted, falls back to the source + * design's prompt text. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun label(): Optional = label.value.getOptional("label") + + /** + * Optional transcript of the audio file. Providing this improves clone quality. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun refText(): Optional = refText.value.getOptional("ref_text") + + /** + * Returns the raw multipart value of [audioFile]. + * + * Unlike [audioFile], this method doesn't throw if the multipart field has an unexpected + * type. + */ + @JsonProperty("audio_file") + @ExcludeMissing + fun _audioFile(): MultipartField = audioFile + + /** + * Returns the raw multipart value of [language]. + * + * Unlike [language], this method doesn't throw if the multipart field has an unexpected + * type. + */ + @JsonProperty("language") @ExcludeMissing fun _language(): MultipartField = language + + /** + * Returns the raw multipart value of [name]. + * + * Unlike [name], this method doesn't throw if the multipart field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): MultipartField = name + + /** + * Returns the raw multipart value of [gender]. + * + * Unlike [gender], this method doesn't throw if the multipart field has an unexpected type. + */ + @JsonProperty("gender") @ExcludeMissing fun _gender(): MultipartField = gender + + /** + * Returns the raw multipart value of [label]. + * + * Unlike [label], this method doesn't throw if the multipart field has an unexpected type. + */ + @JsonProperty("label") @ExcludeMissing fun _label(): MultipartField = label + + /** + * Returns the raw multipart value of [refText]. + * + * Unlike [refText], this method doesn't throw if the multipart field has an unexpected + * type. + */ + @JsonProperty("ref_text") @ExcludeMissing fun _refText(): MultipartField = refText + + @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 + * .audioFile() + * .language() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var audioFile: MultipartField? = null + private var language: MultipartField? = null + private var name: MultipartField? = null + private var gender: MultipartField = MultipartField.of(null) + private var label: MultipartField = MultipartField.of(null) + private var refText: MultipartField = MultipartField.of(null) + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + audioFile = body.audioFile + language = body.language + name = body.name + gender = body.gender + label = body.label + refText = body.refText + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** + * Audio file to clone the voice from. Supported formats: WAV, MP3, FLAC, OGG, M4A. For + * best quality, provide 5–10 seconds of clear, uninterrupted speech. Maximum size: 2MB. + */ + fun audioFile(audioFile: InputStream) = audioFile(MultipartField.of(audioFile)) + + /** + * Sets [Builder.audioFile] to an arbitrary multipart value. + * + * You should usually call [Builder.audioFile] with a well-typed [InputStream] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun audioFile(audioFile: MultipartField) = apply { + this.audioFile = audioFile + } + + /** + * Audio file to clone the voice from. Supported formats: WAV, MP3, FLAC, OGG, M4A. For + * best quality, provide 5–10 seconds of clear, uninterrupted speech. Maximum size: 2MB. + */ + fun audioFile(audioFile: ByteArray) = audioFile(audioFile.inputStream()) + + /** + * Audio file to clone the voice from. Supported formats: WAV, MP3, FLAC, OGG, M4A. For + * best quality, provide 5–10 seconds of clear, uninterrupted speech. Maximum size: 2MB. + */ + fun audioFile(path: Path) = + audioFile( + MultipartField.builder() + .value(path.inputStream()) + .filename(path.name) + .build() + ) + + /** ISO 639-1 language code (e.g. `en`, `fr`) or `auto` for automatic detection. */ + fun language(language: String) = language(MultipartField.of(language)) + + /** + * Sets [Builder.language] to an arbitrary multipart value. + * + * You should usually call [Builder.language] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun language(language: MultipartField) = apply { this.language = language } + + /** Name for the voice clone. */ + fun name(name: String) = name(MultipartField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary multipart 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: MultipartField) = apply { this.name = name } + + /** Gender of the voice clone. */ + fun gender(gender: Gender) = gender(MultipartField.of(gender)) + + /** + * Sets [Builder.gender] to an arbitrary multipart value. + * + * You should usually call [Builder.gender] with a well-typed [Gender] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun gender(gender: MultipartField) = apply { this.gender = gender } + + /** + * Optional custom label describing the voice style. If omitted, falls back to the + * source design's prompt text. + */ + fun label(label: String) = label(MultipartField.of(label)) + + /** + * Sets [Builder.label] to an arbitrary multipart value. + * + * You should usually call [Builder.label] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun label(label: MultipartField) = apply { this.label = label } + + /** Optional transcript of the audio file. Providing this improves clone quality. */ + fun refText(refText: String) = refText(MultipartField.of(refText)) + + /** + * Sets [Builder.refText] to an arbitrary multipart value. + * + * You should usually call [Builder.refText] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun refText(refText: MultipartField) = apply { this.refText = refText } + + 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 + * .audioFile() + * .language() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("audioFile", audioFile), + checkRequired("language", language), + checkRequired("name", name), + gender, + label, + refText, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + audioFile() + language() + name() + gender().ifPresent { it.validate() } + label() + refText() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: TelnyxInvalidDataException) { + false + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + audioFile == other.audioFile && + language == other.language && + name == other.name && + gender == other.gender && + label == other.label && + refText == other.refText && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(audioFile, language, name, gender, label, refText, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{audioFile=$audioFile, language=$language, name=$name, gender=$gender, label=$label, refText=$refText, additionalProperties=$additionalProperties}" + } + + /** Gender of the voice clone. */ + class Gender @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 MALE = of("male") + + @JvmField val FEMALE = of("female") + + @JvmField val NEUTRAL = of("neutral") + + @JvmStatic fun of(value: String) = Gender(JsonField.of(value)) + } + + /** An enum containing [Gender]'s known values. */ + enum class Known { + MALE, + FEMALE, + NEUTRAL, + } + + /** + * An enum containing [Gender]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Gender] 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 { + MALE, + FEMALE, + NEUTRAL, + /** An enum member indicating that [Gender] 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) { + MALE -> Value.MALE + FEMALE -> Value.FEMALE + NEUTRAL -> Value.NEUTRAL + 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 TelnyxInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + MALE -> Known.MALE + FEMALE -> Known.FEMALE + NEUTRAL -> Known.NEUTRAL + else -> throw TelnyxInvalidDataException("Unknown Gender: $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 TelnyxInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { TelnyxInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): Gender = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: TelnyxInvalidDataException) { + 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 Gender && 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 VoiceCloneCreateFromUploadParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "VoiceCloneCreateFromUploadParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/voiceclones/VoiceCloneCreateFromUploadResponse.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/voiceclones/VoiceCloneCreateFromUploadResponse.kt new file mode 100644 index 000000000..252333713 --- /dev/null +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/voiceclones/VoiceCloneCreateFromUploadResponse.kt @@ -0,0 +1,164 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.voiceclones + +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 com.telnyx.sdk.core.ExcludeMissing +import com.telnyx.sdk.core.JsonField +import com.telnyx.sdk.core.JsonMissing +import com.telnyx.sdk.core.JsonValue +import com.telnyx.sdk.errors.TelnyxInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Response envelope for a single voice clone. */ +class VoiceCloneCreateFromUploadResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val data: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of() + ) : this(data, mutableMapOf()) + + /** + * A voice clone object. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun data(): Optional = data.getOptional("data") + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + @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 + * [VoiceCloneCreateFromUploadResponse]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [VoiceCloneCreateFromUploadResponse]. */ + class Builder internal constructor() { + + private var data: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(voiceCloneCreateFromUploadResponse: VoiceCloneCreateFromUploadResponse) = + apply { + data = voiceCloneCreateFromUploadResponse.data + additionalProperties = + voiceCloneCreateFromUploadResponse.additionalProperties.toMutableMap() + } + + /** A voice clone object. */ + fun data(data: VoiceCloneData) = data(JsonField.of(data)) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed [VoiceCloneData] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun data(data: JsonField) = apply { this.data = data } + + 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 [VoiceCloneCreateFromUploadResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): VoiceCloneCreateFromUploadResponse = + VoiceCloneCreateFromUploadResponse(data, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): VoiceCloneCreateFromUploadResponse = apply { + if (validated) { + return@apply + } + + data().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: TelnyxInvalidDataException) { + 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 = (data.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is VoiceCloneCreateFromUploadResponse && + data == other.data && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(data, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "VoiceCloneCreateFromUploadResponse{data=$data, additionalProperties=$additionalProperties}" +} diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/voiceclones/VoiceCloneCreateParams.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/voiceclones/VoiceCloneCreateParams.kt new file mode 100644 index 000000000..f700847b0 --- /dev/null +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/voiceclones/VoiceCloneCreateParams.kt @@ -0,0 +1,770 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.voiceclones + +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 com.telnyx.sdk.core.Enum +import com.telnyx.sdk.core.ExcludeMissing +import com.telnyx.sdk.core.JsonField +import com.telnyx.sdk.core.JsonMissing +import com.telnyx.sdk.core.JsonValue +import com.telnyx.sdk.core.Params +import com.telnyx.sdk.core.checkRequired +import com.telnyx.sdk.core.http.Headers +import com.telnyx.sdk.core.http.QueryParams +import com.telnyx.sdk.errors.TelnyxInvalidDataException +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +/** + * Creates a new voice clone by capturing the voice identity of an existing voice design. The clone + * can then be used for text-to-speech synthesis. + */ +class VoiceCloneCreateParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * Gender of the voice clone. + * + * @throws TelnyxInvalidDataException 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 gender(): Gender = body.gender() + + /** + * ISO 639-1 language code for the clone (e.g. `en`, `fr`, `de`). + * + * @throws TelnyxInvalidDataException 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 language(): String = body.language() + + /** + * Name for the voice clone. + * + * @throws TelnyxInvalidDataException 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 name(): String = body.name() + + /** + * UUID of the source voice design to clone. + * + * @throws TelnyxInvalidDataException 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 voiceDesignId(): String = body.voiceDesignId() + + /** + * Returns the raw JSON value of [gender]. + * + * Unlike [gender], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _gender(): JsonField = body._gender() + + /** + * Returns the raw JSON value of [language]. + * + * Unlike [language], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _language(): JsonField = body._language() + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _name(): JsonField = body._name() + + /** + * Returns the raw JSON value of [voiceDesignId]. + * + * Unlike [voiceDesignId], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _voiceDesignId(): JsonField = body._voiceDesignId() + + 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 [VoiceCloneCreateParams]. + * + * The following fields are required: + * ```java + * .gender() + * .language() + * .name() + * .voiceDesignId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [VoiceCloneCreateParams]. */ + 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(voiceCloneCreateParams: VoiceCloneCreateParams) = apply { + body = voiceCloneCreateParams.body.toBuilder() + additionalHeaders = voiceCloneCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = voiceCloneCreateParams.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: + * - [gender] + * - [language] + * - [name] + * - [voiceDesignId] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** Gender of the voice clone. */ + fun gender(gender: Gender) = apply { body.gender(gender) } + + /** + * Sets [Builder.gender] to an arbitrary JSON value. + * + * You should usually call [Builder.gender] with a well-typed [Gender] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun gender(gender: JsonField) = apply { body.gender(gender) } + + /** ISO 639-1 language code for the clone (e.g. `en`, `fr`, `de`). */ + fun language(language: String) = apply { body.language(language) } + + /** + * Sets [Builder.language] to an arbitrary JSON value. + * + * You should usually call [Builder.language] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun language(language: JsonField) = apply { body.language(language) } + + /** Name for the voice clone. */ + fun name(name: String) = apply { body.name(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 { body.name(name) } + + /** UUID of the source voice design to clone. */ + fun voiceDesignId(voiceDesignId: String) = apply { body.voiceDesignId(voiceDesignId) } + + /** + * Sets [Builder.voiceDesignId] to an arbitrary JSON value. + * + * You should usually call [Builder.voiceDesignId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun voiceDesignId(voiceDesignId: JsonField) = apply { + body.voiceDesignId(voiceDesignId) + } + + 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 [VoiceCloneCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .gender() + * .language() + * .name() + * .voiceDesignId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): VoiceCloneCreateParams = + VoiceCloneCreateParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + /** Request body for creating a voice clone from an existing voice design. */ + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val gender: JsonField, + private val language: JsonField, + private val name: JsonField, + private val voiceDesignId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("gender") @ExcludeMissing gender: JsonField = JsonMissing.of(), + @JsonProperty("language") + @ExcludeMissing + language: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("voice_design_id") + @ExcludeMissing + voiceDesignId: JsonField = JsonMissing.of(), + ) : this(gender, language, name, voiceDesignId, mutableMapOf()) + + /** + * Gender of the voice clone. + * + * @throws TelnyxInvalidDataException 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 gender(): Gender = gender.getRequired("gender") + + /** + * ISO 639-1 language code for the clone (e.g. `en`, `fr`, `de`). + * + * @throws TelnyxInvalidDataException 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 language(): String = language.getRequired("language") + + /** + * Name for the voice clone. + * + * @throws TelnyxInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * UUID of the source voice design to clone. + * + * @throws TelnyxInvalidDataException 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 voiceDesignId(): String = voiceDesignId.getRequired("voice_design_id") + + /** + * Returns the raw JSON value of [gender]. + * + * Unlike [gender], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("gender") @ExcludeMissing fun _gender(): JsonField = gender + + /** + * Returns the raw JSON value of [language]. + * + * Unlike [language], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("language") @ExcludeMissing fun _language(): JsonField = language + + /** + * 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 [voiceDesignId]. + * + * Unlike [voiceDesignId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("voice_design_id") + @ExcludeMissing + fun _voiceDesignId(): JsonField = voiceDesignId + + @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 + * .gender() + * .language() + * .name() + * .voiceDesignId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var gender: JsonField? = null + private var language: JsonField? = null + private var name: JsonField? = null + private var voiceDesignId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + gender = body.gender + language = body.language + name = body.name + voiceDesignId = body.voiceDesignId + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** Gender of the voice clone. */ + fun gender(gender: Gender) = gender(JsonField.of(gender)) + + /** + * Sets [Builder.gender] to an arbitrary JSON value. + * + * You should usually call [Builder.gender] with a well-typed [Gender] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun gender(gender: JsonField) = apply { this.gender = gender } + + /** ISO 639-1 language code for the clone (e.g. `en`, `fr`, `de`). */ + fun language(language: String) = language(JsonField.of(language)) + + /** + * Sets [Builder.language] to an arbitrary JSON value. + * + * You should usually call [Builder.language] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun language(language: JsonField) = apply { this.language = language } + + /** Name for the voice clone. */ + 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 } + + /** UUID of the source voice design to clone. */ + fun voiceDesignId(voiceDesignId: String) = voiceDesignId(JsonField.of(voiceDesignId)) + + /** + * Sets [Builder.voiceDesignId] to an arbitrary JSON value. + * + * You should usually call [Builder.voiceDesignId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun voiceDesignId(voiceDesignId: JsonField) = apply { + this.voiceDesignId = voiceDesignId + } + + 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 + * .gender() + * .language() + * .name() + * .voiceDesignId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("gender", gender), + checkRequired("language", language), + checkRequired("name", name), + checkRequired("voiceDesignId", voiceDesignId), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + gender().validate() + language() + name() + voiceDesignId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: TelnyxInvalidDataException) { + 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 = + (gender.asKnown().getOrNull()?.validity() ?: 0) + + (if (language.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (voiceDesignId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + gender == other.gender && + language == other.language && + name == other.name && + voiceDesignId == other.voiceDesignId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(gender, language, name, voiceDesignId, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{gender=$gender, language=$language, name=$name, voiceDesignId=$voiceDesignId, additionalProperties=$additionalProperties}" + } + + /** Gender of the voice clone. */ + class Gender @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 MALE = of("male") + + @JvmField val FEMALE = of("female") + + @JvmField val NEUTRAL = of("neutral") + + @JvmStatic fun of(value: String) = Gender(JsonField.of(value)) + } + + /** An enum containing [Gender]'s known values. */ + enum class Known { + MALE, + FEMALE, + NEUTRAL, + } + + /** + * An enum containing [Gender]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Gender] 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 { + MALE, + FEMALE, + NEUTRAL, + /** An enum member indicating that [Gender] 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) { + MALE -> Value.MALE + FEMALE -> Value.FEMALE + NEUTRAL -> Value.NEUTRAL + 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 TelnyxInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + MALE -> Known.MALE + FEMALE -> Known.FEMALE + NEUTRAL -> Known.NEUTRAL + else -> throw TelnyxInvalidDataException("Unknown Gender: $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 TelnyxInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { TelnyxInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): Gender = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: TelnyxInvalidDataException) { + 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 Gender && 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 VoiceCloneCreateParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "VoiceCloneCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/voiceclones/VoiceCloneCreateResponse.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/voiceclones/VoiceCloneCreateResponse.kt new file mode 100644 index 000000000..7e6390313 --- /dev/null +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/voiceclones/VoiceCloneCreateResponse.kt @@ -0,0 +1,159 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.voiceclones + +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 com.telnyx.sdk.core.ExcludeMissing +import com.telnyx.sdk.core.JsonField +import com.telnyx.sdk.core.JsonMissing +import com.telnyx.sdk.core.JsonValue +import com.telnyx.sdk.errors.TelnyxInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Response envelope for a single voice clone. */ +class VoiceCloneCreateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val data: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of() + ) : this(data, mutableMapOf()) + + /** + * A voice clone object. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun data(): Optional = data.getOptional("data") + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + @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 [VoiceCloneCreateResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [VoiceCloneCreateResponse]. */ + class Builder internal constructor() { + + private var data: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(voiceCloneCreateResponse: VoiceCloneCreateResponse) = apply { + data = voiceCloneCreateResponse.data + additionalProperties = voiceCloneCreateResponse.additionalProperties.toMutableMap() + } + + /** A voice clone object. */ + fun data(data: VoiceCloneData) = data(JsonField.of(data)) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed [VoiceCloneData] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun data(data: JsonField) = apply { this.data = data } + + 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 [VoiceCloneCreateResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): VoiceCloneCreateResponse = + VoiceCloneCreateResponse(data, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): VoiceCloneCreateResponse = apply { + if (validated) { + return@apply + } + + data().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: TelnyxInvalidDataException) { + 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 = (data.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is VoiceCloneCreateResponse && + data == other.data && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(data, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "VoiceCloneCreateResponse{data=$data, additionalProperties=$additionalProperties}" +} diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/voiceclones/VoiceCloneData.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/voiceclones/VoiceCloneData.kt new file mode 100644 index 000000000..94a2de6c7 --- /dev/null +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/voiceclones/VoiceCloneData.kt @@ -0,0 +1,820 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.voiceclones + +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 com.telnyx.sdk.core.Enum +import com.telnyx.sdk.core.ExcludeMissing +import com.telnyx.sdk.core.JsonField +import com.telnyx.sdk.core.JsonMissing +import com.telnyx.sdk.core.JsonValue +import com.telnyx.sdk.errors.TelnyxInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** A voice clone object. */ +class VoiceCloneData +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val createdAt: JsonField, + private val gender: JsonField, + private val label: JsonField, + private val language: JsonField, + private val name: JsonField, + private val recordType: JsonField, + private val sourceVoiceDesignId: JsonField, + private val sourceVoiceDesignVersion: JsonField, + private val updatedAt: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField = JsonMissing.of(), + @JsonProperty("gender") @ExcludeMissing gender: JsonField = JsonMissing.of(), + @JsonProperty("label") @ExcludeMissing label: JsonField = JsonMissing.of(), + @JsonProperty("language") @ExcludeMissing language: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("record_type") + @ExcludeMissing + recordType: JsonField = JsonMissing.of(), + @JsonProperty("source_voice_design_id") + @ExcludeMissing + sourceVoiceDesignId: JsonField = JsonMissing.of(), + @JsonProperty("source_voice_design_version") + @ExcludeMissing + sourceVoiceDesignVersion: JsonField = JsonMissing.of(), + @JsonProperty("updated_at") + @ExcludeMissing + updatedAt: JsonField = JsonMissing.of(), + ) : this( + id, + createdAt, + gender, + label, + language, + name, + recordType, + sourceVoiceDesignId, + sourceVoiceDesignVersion, + updatedAt, + mutableMapOf(), + ) + + /** + * Unique identifier for the voice clone. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun id(): Optional = id.getOptional("id") + + /** + * Timestamp when the voice clone was created. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun createdAt(): Optional = createdAt.getOptional("created_at") + + /** + * Gender of the voice clone. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun gender(): Optional = gender.getOptional("gender") + + /** + * Voice style description. If not explicitly set on upload, falls back to the source design's + * prompt text. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun label(): Optional = label.getOptional("label") + + /** + * ISO 639-1 language code of the voice clone. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun language(): Optional = language.getOptional("language") + + /** + * Name of the voice clone. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun name(): Optional = name.getOptional("name") + + /** + * Identifies the resource type. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun recordType(): Optional = recordType.getOptional("record_type") + + /** + * UUID of the source voice design. `null` for upload-based clones. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun sourceVoiceDesignId(): Optional = + sourceVoiceDesignId.getOptional("source_voice_design_id") + + /** + * Version of the source voice design used. `null` for upload-based clones. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun sourceVoiceDesignVersion(): Optional = + sourceVoiceDesignVersion.getOptional("source_voice_design_version") + + /** + * Timestamp when the voice clone was last updated. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun updatedAt(): Optional = updatedAt.getOptional("updated_at") + + /** + * Returns the raw JSON value of [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 [gender]. + * + * Unlike [gender], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("gender") @ExcludeMissing fun _gender(): JsonField = gender + + /** + * Returns the raw JSON value of [label]. + * + * Unlike [label], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("label") @ExcludeMissing fun _label(): JsonField = label + + /** + * Returns the raw JSON value of [language]. + * + * Unlike [language], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("language") @ExcludeMissing fun _language(): JsonField = language + + /** + * 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 [recordType]. + * + * Unlike [recordType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("record_type") + @ExcludeMissing + fun _recordType(): JsonField = recordType + + /** + * Returns the raw JSON value of [sourceVoiceDesignId]. + * + * Unlike [sourceVoiceDesignId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("source_voice_design_id") + @ExcludeMissing + fun _sourceVoiceDesignId(): JsonField = sourceVoiceDesignId + + /** + * Returns the raw JSON value of [sourceVoiceDesignVersion]. + * + * Unlike [sourceVoiceDesignVersion], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("source_voice_design_version") + @ExcludeMissing + fun _sourceVoiceDesignVersion(): JsonField = sourceVoiceDesignVersion + + /** + * Returns the raw JSON value of [updatedAt]. + * + * Unlike [updatedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("updated_at") + @ExcludeMissing + fun _updatedAt(): JsonField = updatedAt + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [VoiceCloneData]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [VoiceCloneData]. */ + class Builder internal constructor() { + + private var id: JsonField = JsonMissing.of() + private var createdAt: JsonField = JsonMissing.of() + private var gender: JsonField = JsonMissing.of() + private var label: JsonField = JsonMissing.of() + private var language: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var recordType: JsonField = JsonMissing.of() + private var sourceVoiceDesignId: JsonField = JsonMissing.of() + private var sourceVoiceDesignVersion: JsonField = JsonMissing.of() + private var updatedAt: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(voiceCloneData: VoiceCloneData) = apply { + id = voiceCloneData.id + createdAt = voiceCloneData.createdAt + gender = voiceCloneData.gender + label = voiceCloneData.label + language = voiceCloneData.language + name = voiceCloneData.name + recordType = voiceCloneData.recordType + sourceVoiceDesignId = voiceCloneData.sourceVoiceDesignId + sourceVoiceDesignVersion = voiceCloneData.sourceVoiceDesignVersion + updatedAt = voiceCloneData.updatedAt + additionalProperties = voiceCloneData.additionalProperties.toMutableMap() + } + + /** Unique identifier for the voice clone. */ + 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 } + + /** Timestamp when the voice clone was created. */ + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } + + /** Gender of the voice clone. */ + fun gender(gender: Gender?) = gender(JsonField.ofNullable(gender)) + + /** Alias for calling [Builder.gender] with `gender.orElse(null)`. */ + fun gender(gender: Optional) = gender(gender.getOrNull()) + + /** + * Sets [Builder.gender] to an arbitrary JSON value. + * + * You should usually call [Builder.gender] with a well-typed [Gender] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun gender(gender: JsonField) = apply { this.gender = gender } + + /** + * Voice style description. If not explicitly set on upload, falls back to the source + * design's prompt text. + */ + fun label(label: String?) = label(JsonField.ofNullable(label)) + + /** Alias for calling [Builder.label] with `label.orElse(null)`. */ + fun label(label: Optional) = label(label.getOrNull()) + + /** + * Sets [Builder.label] to an arbitrary JSON value. + * + * You should usually call [Builder.label] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun label(label: JsonField) = apply { this.label = label } + + /** ISO 639-1 language code of the voice clone. */ + fun language(language: String?) = language(JsonField.ofNullable(language)) + + /** Alias for calling [Builder.language] with `language.orElse(null)`. */ + fun language(language: Optional) = language(language.getOrNull()) + + /** + * Sets [Builder.language] to an arbitrary JSON value. + * + * You should usually call [Builder.language] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun language(language: JsonField) = apply { this.language = language } + + /** Name of the voice clone. */ + 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 } + + /** Identifies the resource type. */ + fun recordType(recordType: RecordType) = recordType(JsonField.of(recordType)) + + /** + * Sets [Builder.recordType] to an arbitrary JSON value. + * + * You should usually call [Builder.recordType] with a well-typed [RecordType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun recordType(recordType: JsonField) = apply { this.recordType = recordType } + + /** UUID of the source voice design. `null` for upload-based clones. */ + fun sourceVoiceDesignId(sourceVoiceDesignId: String?) = + sourceVoiceDesignId(JsonField.ofNullable(sourceVoiceDesignId)) + + /** + * Alias for calling [Builder.sourceVoiceDesignId] with `sourceVoiceDesignId.orElse(null)`. + */ + fun sourceVoiceDesignId(sourceVoiceDesignId: Optional) = + sourceVoiceDesignId(sourceVoiceDesignId.getOrNull()) + + /** + * Sets [Builder.sourceVoiceDesignId] to an arbitrary JSON value. + * + * You should usually call [Builder.sourceVoiceDesignId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun sourceVoiceDesignId(sourceVoiceDesignId: JsonField) = apply { + this.sourceVoiceDesignId = sourceVoiceDesignId + } + + /** Version of the source voice design used. `null` for upload-based clones. */ + fun sourceVoiceDesignVersion(sourceVoiceDesignVersion: Long?) = + sourceVoiceDesignVersion(JsonField.ofNullable(sourceVoiceDesignVersion)) + + /** + * Alias for [Builder.sourceVoiceDesignVersion]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun sourceVoiceDesignVersion(sourceVoiceDesignVersion: Long) = + sourceVoiceDesignVersion(sourceVoiceDesignVersion as Long?) + + /** + * Alias for calling [Builder.sourceVoiceDesignVersion] with + * `sourceVoiceDesignVersion.orElse(null)`. + */ + fun sourceVoiceDesignVersion(sourceVoiceDesignVersion: Optional) = + sourceVoiceDesignVersion(sourceVoiceDesignVersion.getOrNull()) + + /** + * Sets [Builder.sourceVoiceDesignVersion] to an arbitrary JSON value. + * + * You should usually call [Builder.sourceVoiceDesignVersion] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun sourceVoiceDesignVersion(sourceVoiceDesignVersion: JsonField) = apply { + this.sourceVoiceDesignVersion = sourceVoiceDesignVersion + } + + /** Timestamp when the voice clone was last updated. */ + fun updatedAt(updatedAt: OffsetDateTime) = updatedAt(JsonField.of(updatedAt)) + + /** + * Sets [Builder.updatedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.updatedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun updatedAt(updatedAt: JsonField) = apply { this.updatedAt = updatedAt } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [VoiceCloneData]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): VoiceCloneData = + VoiceCloneData( + id, + createdAt, + gender, + label, + language, + name, + recordType, + sourceVoiceDesignId, + sourceVoiceDesignVersion, + updatedAt, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): VoiceCloneData = apply { + if (validated) { + return@apply + } + + id() + createdAt() + gender().ifPresent { it.validate() } + label() + language() + name() + recordType().ifPresent { it.validate() } + sourceVoiceDesignId() + sourceVoiceDesignVersion() + updatedAt() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: TelnyxInvalidDataException) { + 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) + + (gender.asKnown().getOrNull()?.validity() ?: 0) + + (if (label.asKnown().isPresent) 1 else 0) + + (if (language.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (recordType.asKnown().getOrNull()?.validity() ?: 0) + + (if (sourceVoiceDesignId.asKnown().isPresent) 1 else 0) + + (if (sourceVoiceDesignVersion.asKnown().isPresent) 1 else 0) + + (if (updatedAt.asKnown().isPresent) 1 else 0) + + /** Gender of the voice clone. */ + class Gender @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 MALE = of("male") + + @JvmField val FEMALE = of("female") + + @JvmField val NEUTRAL = of("neutral") + + @JvmStatic fun of(value: String) = Gender(JsonField.of(value)) + } + + /** An enum containing [Gender]'s known values. */ + enum class Known { + MALE, + FEMALE, + NEUTRAL, + } + + /** + * An enum containing [Gender]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Gender] 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 { + MALE, + FEMALE, + NEUTRAL, + /** An enum member indicating that [Gender] 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) { + MALE -> Value.MALE + FEMALE -> Value.FEMALE + NEUTRAL -> Value.NEUTRAL + 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 TelnyxInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + MALE -> Known.MALE + FEMALE -> Known.FEMALE + NEUTRAL -> Known.NEUTRAL + else -> throw TelnyxInvalidDataException("Unknown Gender: $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 TelnyxInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { TelnyxInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): Gender = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: TelnyxInvalidDataException) { + 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 Gender && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Identifies the resource type. */ + class RecordType @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 VOICE_CLONE = of("voice_clone") + + @JvmStatic fun of(value: String) = RecordType(JsonField.of(value)) + } + + /** An enum containing [RecordType]'s known values. */ + enum class Known { + VOICE_CLONE + } + + /** + * An enum containing [RecordType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [RecordType] 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 { + VOICE_CLONE, + /** + * An enum member indicating that [RecordType] 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) { + VOICE_CLONE -> Value.VOICE_CLONE + 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 TelnyxInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + VOICE_CLONE -> Known.VOICE_CLONE + else -> throw TelnyxInvalidDataException("Unknown RecordType: $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 TelnyxInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { TelnyxInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): RecordType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: TelnyxInvalidDataException) { + 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 RecordType && 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 VoiceCloneData && + id == other.id && + createdAt == other.createdAt && + gender == other.gender && + label == other.label && + language == other.language && + name == other.name && + recordType == other.recordType && + sourceVoiceDesignId == other.sourceVoiceDesignId && + sourceVoiceDesignVersion == other.sourceVoiceDesignVersion && + updatedAt == other.updatedAt && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + createdAt, + gender, + label, + language, + name, + recordType, + sourceVoiceDesignId, + sourceVoiceDesignVersion, + updatedAt, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "VoiceCloneData{id=$id, createdAt=$createdAt, gender=$gender, label=$label, language=$language, name=$name, recordType=$recordType, sourceVoiceDesignId=$sourceVoiceDesignId, sourceVoiceDesignVersion=$sourceVoiceDesignVersion, updatedAt=$updatedAt, additionalProperties=$additionalProperties}" +} diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/voiceclones/VoiceCloneDeleteParams.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/voiceclones/VoiceCloneDeleteParams.kt new file mode 100644 index 000000000..9089b8c32 --- /dev/null +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/voiceclones/VoiceCloneDeleteParams.kt @@ -0,0 +1,230 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.voiceclones + +import com.telnyx.sdk.core.JsonValue +import com.telnyx.sdk.core.Params +import com.telnyx.sdk.core.http.Headers +import com.telnyx.sdk.core.http.QueryParams +import com.telnyx.sdk.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Permanently deletes a voice clone. This action cannot be undone. */ +class VoiceCloneDeleteParams +private constructor( + private val id: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map, +) : Params { + + fun id(): Optional = Optional.ofNullable(id) + + /** 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(): VoiceCloneDeleteParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [VoiceCloneDeleteParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [VoiceCloneDeleteParams]. */ + class Builder internal constructor() { + + private var id: 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(voiceCloneDeleteParams: VoiceCloneDeleteParams) = apply { + id = voiceCloneDeleteParams.id + additionalHeaders = voiceCloneDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = voiceCloneDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = + voiceCloneDeleteParams.additionalBodyProperties.toMutableMap() + } + + 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) + } + + 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 [VoiceCloneDeleteParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): VoiceCloneDeleteParams = + VoiceCloneDeleteParams( + id, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + 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 VoiceCloneDeleteParams && + id == other.id && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash(id, additionalHeaders, additionalQueryParams, additionalBodyProperties) + + override fun toString() = + "VoiceCloneDeleteParams{id=$id, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/voiceclones/VoiceCloneDownloadSampleParams.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/voiceclones/VoiceCloneDownloadSampleParams.kt new file mode 100644 index 000000000..5c762a00b --- /dev/null +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/voiceclones/VoiceCloneDownloadSampleParams.kt @@ -0,0 +1,196 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.voiceclones + +import com.telnyx.sdk.core.Params +import com.telnyx.sdk.core.http.Headers +import com.telnyx.sdk.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Downloads the WAV audio sample that was used to create the voice clone. */ +class VoiceCloneDownloadSampleParams +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(): VoiceCloneDownloadSampleParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of + * [VoiceCloneDownloadSampleParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [VoiceCloneDownloadSampleParams]. */ + 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(voiceCloneDownloadSampleParams: VoiceCloneDownloadSampleParams) = apply { + id = voiceCloneDownloadSampleParams.id + additionalHeaders = voiceCloneDownloadSampleParams.additionalHeaders.toBuilder() + additionalQueryParams = voiceCloneDownloadSampleParams.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 [VoiceCloneDownloadSampleParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): VoiceCloneDownloadSampleParams = + VoiceCloneDownloadSampleParams( + 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 VoiceCloneDownloadSampleParams && + id == other.id && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(id, additionalHeaders, additionalQueryParams) + + override fun toString() = + "VoiceCloneDownloadSampleParams{id=$id, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/voiceclones/VoiceCloneListPage.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/voiceclones/VoiceCloneListPage.kt new file mode 100644 index 000000000..4dbb09c2f --- /dev/null +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/voiceclones/VoiceCloneListPage.kt @@ -0,0 +1,141 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.voiceclones + +import com.telnyx.sdk.core.AutoPager +import com.telnyx.sdk.core.Page +import com.telnyx.sdk.core.checkRequired +import com.telnyx.sdk.services.blocking.VoiceCloneService +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrDefault +import kotlin.jvm.optionals.getOrNull + +/** @see VoiceCloneService.list */ +class VoiceCloneListPage +private constructor( + private val service: VoiceCloneService, + private val params: VoiceCloneListParams, + private val response: VoiceCloneListPageResponse, +) : Page { + + /** + * Delegates to [VoiceCloneListPageResponse], but gracefully handles missing data. + * + * @see VoiceCloneListPageResponse.data + */ + fun data(): List = + response._data().getOptional("data").getOrNull() ?: emptyList() + + /** + * Delegates to [VoiceCloneListPageResponse], but gracefully handles missing data. + * + * @see VoiceCloneListPageResponse.meta + */ + fun meta(): Optional = response._meta().getOptional("meta") + + override fun items(): List = data() + + override fun hasNextPage(): Boolean { + if (items().isEmpty()) { + return false + } + + val pageNumber = + meta().flatMap { it._pageNumber().getOptional("page_number") }.getOrDefault(1) + val pageCount = meta().flatMap { it._totalPages().getOptional("total_pages") }.getOrNull() + return pageCount == null || pageNumber < pageCount + } + + fun nextPageParams(): VoiceCloneListParams { + val pageNumber = params.pageNumber().getOrDefault(1) + return params.toBuilder().pageNumber(pageNumber + 1).build() + } + + override fun nextPage(): VoiceCloneListPage = service.list(nextPageParams()) + + fun autoPager(): AutoPager = AutoPager.from(this) + + /** The parameters that were used to request this page. */ + fun params(): VoiceCloneListParams = params + + /** The response that this page was parsed from. */ + fun response(): VoiceCloneListPageResponse = response + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [VoiceCloneListPage]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [VoiceCloneListPage]. */ + class Builder internal constructor() { + + private var service: VoiceCloneService? = null + private var params: VoiceCloneListParams? = null + private var response: VoiceCloneListPageResponse? = null + + @JvmSynthetic + internal fun from(voiceCloneListPage: VoiceCloneListPage) = apply { + service = voiceCloneListPage.service + params = voiceCloneListPage.params + response = voiceCloneListPage.response + } + + fun service(service: VoiceCloneService) = apply { this.service = service } + + /** The parameters that were used to request this page. */ + fun params(params: VoiceCloneListParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: VoiceCloneListPageResponse) = apply { this.response = response } + + /** + * Returns an immutable instance of [VoiceCloneListPage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): VoiceCloneListPage = + VoiceCloneListPage( + checkRequired("service", service), + checkRequired("params", params), + checkRequired("response", response), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is VoiceCloneListPage && + service == other.service && + params == other.params && + response == other.response + } + + override fun hashCode(): Int = Objects.hash(service, params, response) + + override fun toString() = + "VoiceCloneListPage{service=$service, params=$params, response=$response}" +} diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/voiceclones/VoiceCloneListPageAsync.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/voiceclones/VoiceCloneListPageAsync.kt new file mode 100644 index 000000000..cb2910334 --- /dev/null +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/voiceclones/VoiceCloneListPageAsync.kt @@ -0,0 +1,156 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.voiceclones + +import com.telnyx.sdk.core.AutoPagerAsync +import com.telnyx.sdk.core.PageAsync +import com.telnyx.sdk.core.checkRequired +import com.telnyx.sdk.services.async.VoiceCloneServiceAsync +import java.util.Objects +import java.util.Optional +import java.util.concurrent.CompletableFuture +import java.util.concurrent.Executor +import kotlin.jvm.optionals.getOrDefault +import kotlin.jvm.optionals.getOrNull + +/** @see VoiceCloneServiceAsync.list */ +class VoiceCloneListPageAsync +private constructor( + private val service: VoiceCloneServiceAsync, + private val streamHandlerExecutor: Executor, + private val params: VoiceCloneListParams, + private val response: VoiceCloneListPageResponse, +) : PageAsync { + + /** + * Delegates to [VoiceCloneListPageResponse], but gracefully handles missing data. + * + * @see VoiceCloneListPageResponse.data + */ + fun data(): List = + response._data().getOptional("data").getOrNull() ?: emptyList() + + /** + * Delegates to [VoiceCloneListPageResponse], but gracefully handles missing data. + * + * @see VoiceCloneListPageResponse.meta + */ + fun meta(): Optional = response._meta().getOptional("meta") + + override fun items(): List = data() + + override fun hasNextPage(): Boolean { + if (items().isEmpty()) { + return false + } + + val pageNumber = + meta().flatMap { it._pageNumber().getOptional("page_number") }.getOrDefault(1) + val pageCount = meta().flatMap { it._totalPages().getOptional("total_pages") }.getOrNull() + return pageCount == null || pageNumber < pageCount + } + + fun nextPageParams(): VoiceCloneListParams { + val pageNumber = params.pageNumber().getOrDefault(1) + return params.toBuilder().pageNumber(pageNumber + 1).build() + } + + override fun nextPage(): CompletableFuture = + service.list(nextPageParams()) + + fun autoPager(): AutoPagerAsync = + AutoPagerAsync.from(this, streamHandlerExecutor) + + /** The parameters that were used to request this page. */ + fun params(): VoiceCloneListParams = params + + /** The response that this page was parsed from. */ + fun response(): VoiceCloneListPageResponse = response + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [VoiceCloneListPageAsync]. + * + * The following fields are required: + * ```java + * .service() + * .streamHandlerExecutor() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [VoiceCloneListPageAsync]. */ + class Builder internal constructor() { + + private var service: VoiceCloneServiceAsync? = null + private var streamHandlerExecutor: Executor? = null + private var params: VoiceCloneListParams? = null + private var response: VoiceCloneListPageResponse? = null + + @JvmSynthetic + internal fun from(voiceCloneListPageAsync: VoiceCloneListPageAsync) = apply { + service = voiceCloneListPageAsync.service + streamHandlerExecutor = voiceCloneListPageAsync.streamHandlerExecutor + params = voiceCloneListPageAsync.params + response = voiceCloneListPageAsync.response + } + + fun service(service: VoiceCloneServiceAsync) = apply { this.service = service } + + fun streamHandlerExecutor(streamHandlerExecutor: Executor) = apply { + this.streamHandlerExecutor = streamHandlerExecutor + } + + /** The parameters that were used to request this page. */ + fun params(params: VoiceCloneListParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: VoiceCloneListPageResponse) = apply { this.response = response } + + /** + * Returns an immutable instance of [VoiceCloneListPageAsync]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .streamHandlerExecutor() + * .params() + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): VoiceCloneListPageAsync = + VoiceCloneListPageAsync( + checkRequired("service", service), + checkRequired("streamHandlerExecutor", streamHandlerExecutor), + checkRequired("params", params), + checkRequired("response", response), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is VoiceCloneListPageAsync && + service == other.service && + streamHandlerExecutor == other.streamHandlerExecutor && + params == other.params && + response == other.response + } + + override fun hashCode(): Int = Objects.hash(service, streamHandlerExecutor, params, response) + + override fun toString() = + "VoiceCloneListPageAsync{service=$service, streamHandlerExecutor=$streamHandlerExecutor, params=$params, response=$response}" +} diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/voiceclones/VoiceCloneListPageResponse.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/voiceclones/VoiceCloneListPageResponse.kt new file mode 100644 index 000000000..c963c1d6c --- /dev/null +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/voiceclones/VoiceCloneListPageResponse.kt @@ -0,0 +1,484 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.voiceclones + +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 com.telnyx.sdk.core.ExcludeMissing +import com.telnyx.sdk.core.JsonField +import com.telnyx.sdk.core.JsonMissing +import com.telnyx.sdk.core.JsonValue +import com.telnyx.sdk.core.checkKnown +import com.telnyx.sdk.core.toImmutable +import com.telnyx.sdk.errors.TelnyxInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Paginated list of voice clones. */ +class VoiceCloneListPageResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val data: JsonField>, + private val meta: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("data") + @ExcludeMissing + data: JsonField> = JsonMissing.of(), + @JsonProperty("meta") @ExcludeMissing meta: JsonField = JsonMissing.of(), + ) : this(data, meta, mutableMapOf()) + + /** + * Array of voice clone objects. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun data(): Optional> = data.getOptional("data") + + /** + * Pagination metadata returned with list responses. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun meta(): Optional = meta.getOptional("meta") + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField> = data + + /** + * Returns the raw JSON value of [meta]. + * + * Unlike [meta], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("meta") @ExcludeMissing fun _meta(): JsonField = meta + + @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 [VoiceCloneListPageResponse]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [VoiceCloneListPageResponse]. */ + class Builder internal constructor() { + + private var data: JsonField>? = null + private var meta: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(voiceCloneListPageResponse: VoiceCloneListPageResponse) = apply { + data = voiceCloneListPageResponse.data.map { it.toMutableList() } + meta = voiceCloneListPageResponse.meta + additionalProperties = voiceCloneListPageResponse.additionalProperties.toMutableMap() + } + + /** Array of voice clone objects. */ + fun data(data: List) = data(JsonField.of(data)) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun data(data: JsonField>) = apply { + this.data = data.map { it.toMutableList() } + } + + /** + * Adds a single [VoiceCloneData] to [Builder.data]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addData(data: VoiceCloneData) = apply { + this.data = + (this.data ?: JsonField.of(mutableListOf())).also { + checkKnown("data", it).add(data) + } + } + + /** Pagination metadata returned with list responses. */ + fun meta(meta: Meta) = meta(JsonField.of(meta)) + + /** + * Sets [Builder.meta] to an arbitrary JSON value. + * + * You should usually call [Builder.meta] with a well-typed [Meta] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun meta(meta: JsonField) = apply { this.meta = meta } + + 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 [VoiceCloneListPageResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): VoiceCloneListPageResponse = + VoiceCloneListPageResponse( + (data ?: JsonMissing.of()).map { it.toImmutable() }, + meta, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): VoiceCloneListPageResponse = apply { + if (validated) { + return@apply + } + + data().ifPresent { it.forEach { it.validate() } } + meta().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: TelnyxInvalidDataException) { + 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 = + (data.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (meta.asKnown().getOrNull()?.validity() ?: 0) + + /** Pagination metadata returned with list responses. */ + class Meta + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val pageNumber: JsonField, + private val pageSize: JsonField, + private val totalPages: JsonField, + private val totalResults: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("page_number") + @ExcludeMissing + pageNumber: JsonField = JsonMissing.of(), + @JsonProperty("page_size") @ExcludeMissing pageSize: JsonField = JsonMissing.of(), + @JsonProperty("total_pages") + @ExcludeMissing + totalPages: JsonField = JsonMissing.of(), + @JsonProperty("total_results") + @ExcludeMissing + totalResults: JsonField = JsonMissing.of(), + ) : this(pageNumber, pageSize, totalPages, totalResults, mutableMapOf()) + + /** + * Current page number (1-based). + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun pageNumber(): Optional = pageNumber.getOptional("page_number") + + /** + * Number of results per page. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun pageSize(): Optional = pageSize.getOptional("page_size") + + /** + * Total number of pages. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun totalPages(): Optional = totalPages.getOptional("total_pages") + + /** + * Total number of results across all pages. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun totalResults(): Optional = totalResults.getOptional("total_results") + + /** + * Returns the raw JSON value of [pageNumber]. + * + * Unlike [pageNumber], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("page_number") @ExcludeMissing fun _pageNumber(): JsonField = pageNumber + + /** + * Returns the raw JSON value of [pageSize]. + * + * Unlike [pageSize], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("page_size") @ExcludeMissing fun _pageSize(): JsonField = pageSize + + /** + * Returns the raw JSON value of [totalPages]. + * + * Unlike [totalPages], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("total_pages") @ExcludeMissing fun _totalPages(): JsonField = totalPages + + /** + * Returns the raw JSON value of [totalResults]. + * + * Unlike [totalResults], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("total_results") + @ExcludeMissing + fun _totalResults(): JsonField = totalResults + + @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 [Meta]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Meta]. */ + class Builder internal constructor() { + + private var pageNumber: JsonField = JsonMissing.of() + private var pageSize: JsonField = JsonMissing.of() + private var totalPages: JsonField = JsonMissing.of() + private var totalResults: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(meta: Meta) = apply { + pageNumber = meta.pageNumber + pageSize = meta.pageSize + totalPages = meta.totalPages + totalResults = meta.totalResults + additionalProperties = meta.additionalProperties.toMutableMap() + } + + /** Current page number (1-based). */ + fun pageNumber(pageNumber: Long) = pageNumber(JsonField.of(pageNumber)) + + /** + * Sets [Builder.pageNumber] to an arbitrary JSON value. + * + * You should usually call [Builder.pageNumber] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun pageNumber(pageNumber: JsonField) = apply { this.pageNumber = pageNumber } + + /** Number of results per page. */ + fun pageSize(pageSize: Long) = pageSize(JsonField.of(pageSize)) + + /** + * Sets [Builder.pageSize] to an arbitrary JSON value. + * + * You should usually call [Builder.pageSize] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun pageSize(pageSize: JsonField) = apply { this.pageSize = pageSize } + + /** Total number of pages. */ + fun totalPages(totalPages: Long) = totalPages(JsonField.of(totalPages)) + + /** + * Sets [Builder.totalPages] to an arbitrary JSON value. + * + * You should usually call [Builder.totalPages] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun totalPages(totalPages: JsonField) = apply { this.totalPages = totalPages } + + /** Total number of results across all pages. */ + fun totalResults(totalResults: Long) = totalResults(JsonField.of(totalResults)) + + /** + * Sets [Builder.totalResults] to an arbitrary JSON value. + * + * You should usually call [Builder.totalResults] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun totalResults(totalResults: JsonField) = apply { + this.totalResults = totalResults + } + + 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 [Meta]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Meta = + Meta( + pageNumber, + pageSize, + totalPages, + totalResults, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Meta = apply { + if (validated) { + return@apply + } + + pageNumber() + pageSize() + totalPages() + totalResults() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: TelnyxInvalidDataException) { + 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 (pageNumber.asKnown().isPresent) 1 else 0) + + (if (pageSize.asKnown().isPresent) 1 else 0) + + (if (totalPages.asKnown().isPresent) 1 else 0) + + (if (totalResults.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Meta && + pageNumber == other.pageNumber && + pageSize == other.pageSize && + totalPages == other.totalPages && + totalResults == other.totalResults && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(pageNumber, pageSize, totalPages, totalResults, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Meta{pageNumber=$pageNumber, pageSize=$pageSize, totalPages=$totalPages, totalResults=$totalResults, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is VoiceCloneListPageResponse && + data == other.data && + meta == other.meta && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(data, meta, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "VoiceCloneListPageResponse{data=$data, meta=$meta, additionalProperties=$additionalProperties}" +} diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/voiceclones/VoiceCloneListParams.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/voiceclones/VoiceCloneListParams.kt new file mode 100644 index 000000000..43cb741e7 --- /dev/null +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/voiceclones/VoiceCloneListParams.kt @@ -0,0 +1,404 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.voiceclones + +import com.fasterxml.jackson.annotation.JsonCreator +import com.telnyx.sdk.core.Enum +import com.telnyx.sdk.core.JsonField +import com.telnyx.sdk.core.Params +import com.telnyx.sdk.core.http.Headers +import com.telnyx.sdk.core.http.QueryParams +import com.telnyx.sdk.errors.TelnyxInvalidDataException +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Returns a paginated list of voice clones belonging to the authenticated account. */ +class VoiceCloneListParams +private constructor( + private val filterName: String?, + private val pageNumber: Long?, + private val pageSize: Long?, + private val sort: Sort?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** Case-insensitive substring filter on the name field. */ + fun filterName(): Optional = Optional.ofNullable(filterName) + + /** Page number for pagination (1-based). */ + fun pageNumber(): Optional = Optional.ofNullable(pageNumber) + + /** Number of results per page. */ + fun pageSize(): Optional = Optional.ofNullable(pageSize) + + /** Sort order. Prefix with `-` for descending. Defaults to `-created_at`. */ + fun sort(): Optional = Optional.ofNullable(sort) + + /** 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(): VoiceCloneListParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [VoiceCloneListParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [VoiceCloneListParams]. */ + class Builder internal constructor() { + + private var filterName: String? = null + private var pageNumber: Long? = null + private var pageSize: Long? = null + private var sort: Sort? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(voiceCloneListParams: VoiceCloneListParams) = apply { + filterName = voiceCloneListParams.filterName + pageNumber = voiceCloneListParams.pageNumber + pageSize = voiceCloneListParams.pageSize + sort = voiceCloneListParams.sort + additionalHeaders = voiceCloneListParams.additionalHeaders.toBuilder() + additionalQueryParams = voiceCloneListParams.additionalQueryParams.toBuilder() + } + + /** Case-insensitive substring filter on the name field. */ + fun filterName(filterName: String?) = apply { this.filterName = filterName } + + /** Alias for calling [Builder.filterName] with `filterName.orElse(null)`. */ + fun filterName(filterName: Optional) = filterName(filterName.getOrNull()) + + /** Page number for pagination (1-based). */ + fun pageNumber(pageNumber: Long?) = apply { this.pageNumber = pageNumber } + + /** + * Alias for [Builder.pageNumber]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun pageNumber(pageNumber: Long) = pageNumber(pageNumber as Long?) + + /** Alias for calling [Builder.pageNumber] with `pageNumber.orElse(null)`. */ + fun pageNumber(pageNumber: Optional) = pageNumber(pageNumber.getOrNull()) + + /** Number of results per page. */ + fun pageSize(pageSize: Long?) = apply { this.pageSize = pageSize } + + /** + * Alias for [Builder.pageSize]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun pageSize(pageSize: Long) = pageSize(pageSize as Long?) + + /** Alias for calling [Builder.pageSize] with `pageSize.orElse(null)`. */ + fun pageSize(pageSize: Optional) = pageSize(pageSize.getOrNull()) + + /** Sort order. Prefix with `-` for descending. Defaults to `-created_at`. */ + fun sort(sort: Sort?) = apply { this.sort = sort } + + /** Alias for calling [Builder.sort] with `sort.orElse(null)`. */ + fun sort(sort: Optional) = sort(sort.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 [VoiceCloneListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): VoiceCloneListParams = + VoiceCloneListParams( + filterName, + pageNumber, + pageSize, + sort, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + filterName?.let { put("filter[name]", it) } + pageNumber?.let { put("page[number]", it.toString()) } + pageSize?.let { put("page[size]", it.toString()) } + sort?.let { put("sort", it.toString()) } + putAll(additionalQueryParams) + } + .build() + + /** Sort order. Prefix with `-` for descending. Defaults to `-created_at`. */ + class Sort @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 NAME = of("name") + + @JvmField val NAME_DESC = of("-name") + + @JvmField val CREATED_AT = of("created_at") + + @JvmField val CREATED_AT_DESC = of("-created_at") + + @JvmStatic fun of(value: String) = Sort(JsonField.of(value)) + } + + /** An enum containing [Sort]'s known values. */ + enum class Known { + NAME, + NAME_DESC, + CREATED_AT, + CREATED_AT_DESC, + } + + /** + * An enum containing [Sort]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Sort] 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 { + NAME, + NAME_DESC, + CREATED_AT, + CREATED_AT_DESC, + /** An enum member indicating that [Sort] 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) { + NAME -> Value.NAME + NAME_DESC -> Value.NAME_DESC + CREATED_AT -> Value.CREATED_AT + CREATED_AT_DESC -> Value.CREATED_AT_DESC + 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 TelnyxInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + NAME -> Known.NAME + NAME_DESC -> Known.NAME_DESC + CREATED_AT -> Known.CREATED_AT + CREATED_AT_DESC -> Known.CREATED_AT_DESC + else -> throw TelnyxInvalidDataException("Unknown Sort: $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 TelnyxInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { TelnyxInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): Sort = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: TelnyxInvalidDataException) { + 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 Sort && 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 VoiceCloneListParams && + filterName == other.filterName && + pageNumber == other.pageNumber && + pageSize == other.pageSize && + sort == other.sort && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash( + filterName, + pageNumber, + pageSize, + sort, + additionalHeaders, + additionalQueryParams, + ) + + override fun toString() = + "VoiceCloneListParams{filterName=$filterName, pageNumber=$pageNumber, pageSize=$pageSize, sort=$sort, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/voiceclones/VoiceCloneUpdateParams.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/voiceclones/VoiceCloneUpdateParams.kt new file mode 100644 index 000000000..799503ff6 --- /dev/null +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/voiceclones/VoiceCloneUpdateParams.kt @@ -0,0 +1,700 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.voiceclones + +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 com.telnyx.sdk.core.Enum +import com.telnyx.sdk.core.ExcludeMissing +import com.telnyx.sdk.core.JsonField +import com.telnyx.sdk.core.JsonMissing +import com.telnyx.sdk.core.JsonValue +import com.telnyx.sdk.core.Params +import com.telnyx.sdk.core.checkRequired +import com.telnyx.sdk.core.http.Headers +import com.telnyx.sdk.core.http.QueryParams +import com.telnyx.sdk.errors.TelnyxInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Updates the name, language, or gender of a voice clone. */ +class VoiceCloneUpdateParams +private constructor( + private val id: String?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun id(): Optional = Optional.ofNullable(id) + + /** + * New name for the voice clone. + * + * @throws TelnyxInvalidDataException 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 name(): String = body.name() + + /** + * Updated gender for the voice clone. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun gender(): Optional = body.gender() + + /** + * Updated ISO 639-1 language code or `auto`. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun language(): Optional = body.language() + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _name(): JsonField = body._name() + + /** + * Returns the raw JSON value of [gender]. + * + * Unlike [gender], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _gender(): JsonField = body._gender() + + /** + * Returns the raw JSON value of [language]. + * + * Unlike [language], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _language(): JsonField = body._language() + + 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 [VoiceCloneUpdateParams]. + * + * The following fields are required: + * ```java + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [VoiceCloneUpdateParams]. */ + class Builder internal constructor() { + + private var id: 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(voiceCloneUpdateParams: VoiceCloneUpdateParams) = apply { + id = voiceCloneUpdateParams.id + body = voiceCloneUpdateParams.body.toBuilder() + additionalHeaders = voiceCloneUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = voiceCloneUpdateParams.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()) + + /** + * 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: + * - [name] + * - [gender] + * - [language] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** New name for the voice clone. */ + fun name(name: String) = apply { body.name(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 { body.name(name) } + + /** Updated gender for the voice clone. */ + fun gender(gender: Gender) = apply { body.gender(gender) } + + /** + * Sets [Builder.gender] to an arbitrary JSON value. + * + * You should usually call [Builder.gender] with a well-typed [Gender] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun gender(gender: JsonField) = apply { body.gender(gender) } + + /** Updated ISO 639-1 language code or `auto`. */ + fun language(language: String) = apply { body.language(language) } + + /** + * Sets [Builder.language] to an arbitrary JSON value. + * + * You should usually call [Builder.language] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun language(language: JsonField) = apply { body.language(language) } + + 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 [VoiceCloneUpdateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): VoiceCloneUpdateParams = + VoiceCloneUpdateParams( + id, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> id ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + /** Request body for updating a voice clone. */ + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val name: JsonField, + private val gender: JsonField, + private val language: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("gender") @ExcludeMissing gender: JsonField = JsonMissing.of(), + @JsonProperty("language") @ExcludeMissing language: JsonField = JsonMissing.of(), + ) : this(name, gender, language, mutableMapOf()) + + /** + * New name for the voice clone. + * + * @throws TelnyxInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Updated gender for the voice clone. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun gender(): Optional = gender.getOptional("gender") + + /** + * Updated ISO 639-1 language code or `auto`. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun language(): Optional = language.getOptional("language") + + /** + * 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 [gender]. + * + * Unlike [gender], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("gender") @ExcludeMissing fun _gender(): JsonField = gender + + /** + * Returns the raw JSON value of [language]. + * + * Unlike [language], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("language") @ExcludeMissing fun _language(): JsonField = language + + @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 + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var name: JsonField? = null + private var gender: JsonField = JsonMissing.of() + private var language: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + name = body.name + gender = body.gender + language = body.language + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** New name for the voice clone. */ + 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 } + + /** Updated gender for the voice clone. */ + fun gender(gender: Gender) = gender(JsonField.of(gender)) + + /** + * Sets [Builder.gender] to an arbitrary JSON value. + * + * You should usually call [Builder.gender] with a well-typed [Gender] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun gender(gender: JsonField) = apply { this.gender = gender } + + /** Updated ISO 639-1 language code or `auto`. */ + fun language(language: String) = language(JsonField.of(language)) + + /** + * Sets [Builder.language] to an arbitrary JSON value. + * + * You should usually call [Builder.language] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun language(language: JsonField) = apply { this.language = language } + + 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 + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("name", name), + gender, + language, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + name() + gender().ifPresent { it.validate() } + language() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: TelnyxInvalidDataException) { + 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 (name.asKnown().isPresent) 1 else 0) + + (gender.asKnown().getOrNull()?.validity() ?: 0) + + (if (language.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + name == other.name && + gender == other.gender && + language == other.language && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(name, gender, language, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{name=$name, gender=$gender, language=$language, additionalProperties=$additionalProperties}" + } + + /** Updated gender for the voice clone. */ + class Gender @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 MALE = of("male") + + @JvmField val FEMALE = of("female") + + @JvmField val NEUTRAL = of("neutral") + + @JvmStatic fun of(value: String) = Gender(JsonField.of(value)) + } + + /** An enum containing [Gender]'s known values. */ + enum class Known { + MALE, + FEMALE, + NEUTRAL, + } + + /** + * An enum containing [Gender]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Gender] 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 { + MALE, + FEMALE, + NEUTRAL, + /** An enum member indicating that [Gender] 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) { + MALE -> Value.MALE + FEMALE -> Value.FEMALE + NEUTRAL -> Value.NEUTRAL + 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 TelnyxInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + MALE -> Known.MALE + FEMALE -> Known.FEMALE + NEUTRAL -> Known.NEUTRAL + else -> throw TelnyxInvalidDataException("Unknown Gender: $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 TelnyxInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { TelnyxInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): Gender = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: TelnyxInvalidDataException) { + 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 Gender && 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 VoiceCloneUpdateParams && + id == other.id && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(id, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "VoiceCloneUpdateParams{id=$id, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/voiceclones/VoiceCloneUpdateResponse.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/voiceclones/VoiceCloneUpdateResponse.kt new file mode 100644 index 000000000..b8760bd41 --- /dev/null +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/voiceclones/VoiceCloneUpdateResponse.kt @@ -0,0 +1,159 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.voiceclones + +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 com.telnyx.sdk.core.ExcludeMissing +import com.telnyx.sdk.core.JsonField +import com.telnyx.sdk.core.JsonMissing +import com.telnyx.sdk.core.JsonValue +import com.telnyx.sdk.errors.TelnyxInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Response envelope for a single voice clone. */ +class VoiceCloneUpdateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val data: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of() + ) : this(data, mutableMapOf()) + + /** + * A voice clone object. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun data(): Optional = data.getOptional("data") + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + @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 [VoiceCloneUpdateResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [VoiceCloneUpdateResponse]. */ + class Builder internal constructor() { + + private var data: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(voiceCloneUpdateResponse: VoiceCloneUpdateResponse) = apply { + data = voiceCloneUpdateResponse.data + additionalProperties = voiceCloneUpdateResponse.additionalProperties.toMutableMap() + } + + /** A voice clone object. */ + fun data(data: VoiceCloneData) = data(JsonField.of(data)) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed [VoiceCloneData] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun data(data: JsonField) = apply { this.data = data } + + 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 [VoiceCloneUpdateResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): VoiceCloneUpdateResponse = + VoiceCloneUpdateResponse(data, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): VoiceCloneUpdateResponse = apply { + if (validated) { + return@apply + } + + data().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: TelnyxInvalidDataException) { + 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 = (data.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is VoiceCloneUpdateResponse && + data == other.data && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(data, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "VoiceCloneUpdateResponse{data=$data, additionalProperties=$additionalProperties}" +} diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/voicedesigns/VoiceDesignCreateParams.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/voicedesigns/VoiceDesignCreateParams.kt new file mode 100644 index 000000000..6bfcec00e --- /dev/null +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/voicedesigns/VoiceDesignCreateParams.kt @@ -0,0 +1,1110 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.voicedesigns + +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 com.telnyx.sdk.core.ExcludeMissing +import com.telnyx.sdk.core.JsonField +import com.telnyx.sdk.core.JsonMissing +import com.telnyx.sdk.core.JsonValue +import com.telnyx.sdk.core.Params +import com.telnyx.sdk.core.checkRequired +import com.telnyx.sdk.core.http.Headers +import com.telnyx.sdk.core.http.QueryParams +import com.telnyx.sdk.errors.TelnyxInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional + +/** + * Creates a new voice design (version 1) when `voice_design_id` is omitted. When `voice_design_id` + * is provided, adds a new version to the existing design instead. A design can have at most 50 + * versions. + */ +class VoiceDesignCreateParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * Natural language description of the voice style, e.g. 'Speak in a warm, friendly tone with a + * slight British accent'. + * + * @throws TelnyxInvalidDataException 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 prompt(): String = body.prompt() + + /** + * Sample text to synthesize for this voice design. + * + * @throws TelnyxInvalidDataException 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() + + /** + * Language for synthesis. Supported values: Auto, Chinese, English, Japanese, Korean, German, + * French, Russian, Portuguese, Spanish, Italian. Defaults to Auto. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun language(): Optional = body.language() + + /** + * Maximum number of tokens to generate. Default: 2048. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun maxNewTokens(): Optional = body.maxNewTokens() + + /** + * Name for the voice design. Required when creating a new design (`voice_design_id` is not + * provided); ignored when adding a version. Cannot be a UUID. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun name(): Optional = body.name() + + /** + * Repetition penalty to reduce repeated patterns in generated audio. Default: 1.05. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun repetitionPenalty(): Optional = body.repetitionPenalty() + + /** + * Sampling temperature controlling randomness. Higher values produce more varied output. + * Default: 0.9. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun temperature(): Optional = body.temperature() + + /** + * Top-k sampling parameter — limits the token vocabulary considered at each step. Default: 50. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun topK(): Optional = body.topK() + + /** + * Top-p (nucleus) sampling parameter — cumulative probability cutoff for token selection. + * Default: 1.0. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun topP(): Optional = body.topP() + + /** + * ID of an existing voice design to add a new version to. When provided, a new version is + * created instead of a new design. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun voiceDesignId(): Optional = body.voiceDesignId() + + /** + * Returns the raw JSON value of [prompt]. + * + * Unlike [prompt], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _prompt(): JsonField = body._prompt() + + /** + * 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 [language]. + * + * Unlike [language], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _language(): JsonField = body._language() + + /** + * Returns the raw JSON value of [maxNewTokens]. + * + * Unlike [maxNewTokens], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _maxNewTokens(): JsonField = body._maxNewTokens() + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _name(): JsonField = body._name() + + /** + * Returns the raw JSON value of [repetitionPenalty]. + * + * Unlike [repetitionPenalty], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _repetitionPenalty(): JsonField = body._repetitionPenalty() + + /** + * Returns the raw JSON value of [temperature]. + * + * Unlike [temperature], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _temperature(): JsonField = body._temperature() + + /** + * Returns the raw JSON value of [topK]. + * + * Unlike [topK], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _topK(): JsonField = body._topK() + + /** + * Returns the raw JSON value of [topP]. + * + * Unlike [topP], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _topP(): JsonField = body._topP() + + /** + * Returns the raw JSON value of [voiceDesignId]. + * + * Unlike [voiceDesignId], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _voiceDesignId(): JsonField = body._voiceDesignId() + + 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 [VoiceDesignCreateParams]. + * + * The following fields are required: + * ```java + * .prompt() + * .text() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [VoiceDesignCreateParams]. */ + 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(voiceDesignCreateParams: VoiceDesignCreateParams) = apply { + body = voiceDesignCreateParams.body.toBuilder() + additionalHeaders = voiceDesignCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = voiceDesignCreateParams.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: + * - [prompt] + * - [text] + * - [language] + * - [maxNewTokens] + * - [name] + * - etc. + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** + * Natural language description of the voice style, e.g. 'Speak in a warm, friendly tone + * with a slight British accent'. + */ + fun prompt(prompt: String) = apply { body.prompt(prompt) } + + /** + * Sets [Builder.prompt] to an arbitrary JSON value. + * + * You should usually call [Builder.prompt] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun prompt(prompt: JsonField) = apply { body.prompt(prompt) } + + /** Sample text to synthesize for this voice design. */ + 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) } + + /** + * Language for synthesis. Supported values: Auto, Chinese, English, Japanese, Korean, + * German, French, Russian, Portuguese, Spanish, Italian. Defaults to Auto. + */ + fun language(language: String) = apply { body.language(language) } + + /** + * Sets [Builder.language] to an arbitrary JSON value. + * + * You should usually call [Builder.language] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun language(language: JsonField) = apply { body.language(language) } + + /** Maximum number of tokens to generate. Default: 2048. */ + fun maxNewTokens(maxNewTokens: Long) = apply { body.maxNewTokens(maxNewTokens) } + + /** + * Sets [Builder.maxNewTokens] to an arbitrary JSON value. + * + * You should usually call [Builder.maxNewTokens] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun maxNewTokens(maxNewTokens: JsonField) = apply { body.maxNewTokens(maxNewTokens) } + + /** + * Name for the voice design. Required when creating a new design (`voice_design_id` is not + * provided); ignored when adding a version. Cannot be a UUID. + */ + fun name(name: String) = apply { body.name(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 { body.name(name) } + + /** Repetition penalty to reduce repeated patterns in generated audio. Default: 1.05. */ + fun repetitionPenalty(repetitionPenalty: Float) = apply { + body.repetitionPenalty(repetitionPenalty) + } + + /** + * Sets [Builder.repetitionPenalty] to an arbitrary JSON value. + * + * You should usually call [Builder.repetitionPenalty] with a well-typed [Float] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun repetitionPenalty(repetitionPenalty: JsonField) = apply { + body.repetitionPenalty(repetitionPenalty) + } + + /** + * Sampling temperature controlling randomness. Higher values produce more varied output. + * Default: 0.9. + */ + fun temperature(temperature: Float) = apply { body.temperature(temperature) } + + /** + * Sets [Builder.temperature] to an arbitrary JSON value. + * + * You should usually call [Builder.temperature] with a well-typed [Float] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun temperature(temperature: JsonField) = apply { body.temperature(temperature) } + + /** + * Top-k sampling parameter — limits the token vocabulary considered at each step. + * Default: 50. + */ + fun topK(topK: Long) = apply { body.topK(topK) } + + /** + * Sets [Builder.topK] to an arbitrary JSON value. + * + * You should usually call [Builder.topK] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun topK(topK: JsonField) = apply { body.topK(topK) } + + /** + * Top-p (nucleus) sampling parameter — cumulative probability cutoff for token selection. + * Default: 1.0. + */ + fun topP(topP: Float) = apply { body.topP(topP) } + + /** + * Sets [Builder.topP] to an arbitrary JSON value. + * + * You should usually call [Builder.topP] with a well-typed [Float] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun topP(topP: JsonField) = apply { body.topP(topP) } + + /** + * ID of an existing voice design to add a new version to. When provided, a new version is + * created instead of a new design. + */ + fun voiceDesignId(voiceDesignId: String) = apply { body.voiceDesignId(voiceDesignId) } + + /** + * Sets [Builder.voiceDesignId] to an arbitrary JSON value. + * + * You should usually call [Builder.voiceDesignId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun voiceDesignId(voiceDesignId: JsonField) = apply { + body.voiceDesignId(voiceDesignId) + } + + 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 [VoiceDesignCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .prompt() + * .text() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): VoiceDesignCreateParams = + VoiceDesignCreateParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + /** + * Request body for creating a new voice design or adding a version to an existing one. Omit + * `voice_design_id` to create a new design; include it to add a new version. + */ + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val prompt: JsonField, + private val text: JsonField, + private val language: JsonField, + private val maxNewTokens: JsonField, + private val name: JsonField, + private val repetitionPenalty: JsonField, + private val temperature: JsonField, + private val topK: JsonField, + private val topP: JsonField, + private val voiceDesignId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("prompt") @ExcludeMissing prompt: JsonField = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), + @JsonProperty("language") + @ExcludeMissing + language: JsonField = JsonMissing.of(), + @JsonProperty("max_new_tokens") + @ExcludeMissing + maxNewTokens: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("repetition_penalty") + @ExcludeMissing + repetitionPenalty: JsonField = JsonMissing.of(), + @JsonProperty("temperature") + @ExcludeMissing + temperature: JsonField = JsonMissing.of(), + @JsonProperty("top_k") @ExcludeMissing topK: JsonField = JsonMissing.of(), + @JsonProperty("top_p") @ExcludeMissing topP: JsonField = JsonMissing.of(), + @JsonProperty("voice_design_id") + @ExcludeMissing + voiceDesignId: JsonField = JsonMissing.of(), + ) : this( + prompt, + text, + language, + maxNewTokens, + name, + repetitionPenalty, + temperature, + topK, + topP, + voiceDesignId, + mutableMapOf(), + ) + + /** + * Natural language description of the voice style, e.g. 'Speak in a warm, friendly tone + * with a slight British accent'. + * + * @throws TelnyxInvalidDataException 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 prompt(): String = prompt.getRequired("prompt") + + /** + * Sample text to synthesize for this voice design. + * + * @throws TelnyxInvalidDataException 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") + + /** + * Language for synthesis. Supported values: Auto, Chinese, English, Japanese, Korean, + * German, French, Russian, Portuguese, Spanish, Italian. Defaults to Auto. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun language(): Optional = language.getOptional("language") + + /** + * Maximum number of tokens to generate. Default: 2048. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun maxNewTokens(): Optional = maxNewTokens.getOptional("max_new_tokens") + + /** + * Name for the voice design. Required when creating a new design (`voice_design_id` is not + * provided); ignored when adding a version. Cannot be a UUID. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun name(): Optional = name.getOptional("name") + + /** + * Repetition penalty to reduce repeated patterns in generated audio. Default: 1.05. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun repetitionPenalty(): Optional = + repetitionPenalty.getOptional("repetition_penalty") + + /** + * Sampling temperature controlling randomness. Higher values produce more varied output. + * Default: 0.9. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun temperature(): Optional = temperature.getOptional("temperature") + + /** + * Top-k sampling parameter — limits the token vocabulary considered at each step. + * Default: 50. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun topK(): Optional = topK.getOptional("top_k") + + /** + * Top-p (nucleus) sampling parameter — cumulative probability cutoff for token selection. + * Default: 1.0. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun topP(): Optional = topP.getOptional("top_p") + + /** + * ID of an existing voice design to add a new version to. When provided, a new version is + * created instead of a new design. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun voiceDesignId(): Optional = voiceDesignId.getOptional("voice_design_id") + + /** + * Returns the raw JSON value of [prompt]. + * + * Unlike [prompt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("prompt") @ExcludeMissing fun _prompt(): JsonField = prompt + + /** + * 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 [language]. + * + * Unlike [language], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("language") @ExcludeMissing fun _language(): JsonField = language + + /** + * Returns the raw JSON value of [maxNewTokens]. + * + * Unlike [maxNewTokens], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("max_new_tokens") + @ExcludeMissing + fun _maxNewTokens(): JsonField = maxNewTokens + + /** + * 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 [repetitionPenalty]. + * + * Unlike [repetitionPenalty], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("repetition_penalty") + @ExcludeMissing + fun _repetitionPenalty(): JsonField = repetitionPenalty + + /** + * Returns the raw JSON value of [temperature]. + * + * Unlike [temperature], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("temperature") + @ExcludeMissing + fun _temperature(): JsonField = temperature + + /** + * Returns the raw JSON value of [topK]. + * + * Unlike [topK], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("top_k") @ExcludeMissing fun _topK(): JsonField = topK + + /** + * Returns the raw JSON value of [topP]. + * + * Unlike [topP], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("top_p") @ExcludeMissing fun _topP(): JsonField = topP + + /** + * Returns the raw JSON value of [voiceDesignId]. + * + * Unlike [voiceDesignId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("voice_design_id") + @ExcludeMissing + fun _voiceDesignId(): JsonField = voiceDesignId + + @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 + * .prompt() + * .text() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var prompt: JsonField? = null + private var text: JsonField? = null + private var language: JsonField = JsonMissing.of() + private var maxNewTokens: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var repetitionPenalty: JsonField = JsonMissing.of() + private var temperature: JsonField = JsonMissing.of() + private var topK: JsonField = JsonMissing.of() + private var topP: JsonField = JsonMissing.of() + private var voiceDesignId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + prompt = body.prompt + text = body.text + language = body.language + maxNewTokens = body.maxNewTokens + name = body.name + repetitionPenalty = body.repetitionPenalty + temperature = body.temperature + topK = body.topK + topP = body.topP + voiceDesignId = body.voiceDesignId + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** + * Natural language description of the voice style, e.g. 'Speak in a warm, friendly tone + * with a slight British accent'. + */ + fun prompt(prompt: String) = prompt(JsonField.of(prompt)) + + /** + * Sets [Builder.prompt] to an arbitrary JSON value. + * + * You should usually call [Builder.prompt] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun prompt(prompt: JsonField) = apply { this.prompt = prompt } + + /** Sample text to synthesize for this voice design. */ + 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 } + + /** + * Language for synthesis. Supported values: Auto, Chinese, English, Japanese, Korean, + * German, French, Russian, Portuguese, Spanish, Italian. Defaults to Auto. + */ + fun language(language: String) = language(JsonField.of(language)) + + /** + * Sets [Builder.language] to an arbitrary JSON value. + * + * You should usually call [Builder.language] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun language(language: JsonField) = apply { this.language = language } + + /** Maximum number of tokens to generate. Default: 2048. */ + fun maxNewTokens(maxNewTokens: Long) = maxNewTokens(JsonField.of(maxNewTokens)) + + /** + * Sets [Builder.maxNewTokens] to an arbitrary JSON value. + * + * You should usually call [Builder.maxNewTokens] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun maxNewTokens(maxNewTokens: JsonField) = apply { + this.maxNewTokens = maxNewTokens + } + + /** + * Name for the voice design. Required when creating a new design (`voice_design_id` is + * not provided); ignored when adding a version. Cannot be a UUID. + */ + 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 } + + /** Repetition penalty to reduce repeated patterns in generated audio. Default: 1.05. */ + fun repetitionPenalty(repetitionPenalty: Float) = + repetitionPenalty(JsonField.of(repetitionPenalty)) + + /** + * Sets [Builder.repetitionPenalty] to an arbitrary JSON value. + * + * You should usually call [Builder.repetitionPenalty] with a well-typed [Float] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun repetitionPenalty(repetitionPenalty: JsonField) = apply { + this.repetitionPenalty = repetitionPenalty + } + + /** + * Sampling temperature controlling randomness. Higher values produce more varied + * output. Default: 0.9. + */ + fun temperature(temperature: Float) = temperature(JsonField.of(temperature)) + + /** + * Sets [Builder.temperature] to an arbitrary JSON value. + * + * You should usually call [Builder.temperature] with a well-typed [Float] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun temperature(temperature: JsonField) = apply { + this.temperature = temperature + } + + /** + * Top-k sampling parameter — limits the token vocabulary considered at each step. + * Default: 50. + */ + fun topK(topK: Long) = topK(JsonField.of(topK)) + + /** + * Sets [Builder.topK] to an arbitrary JSON value. + * + * You should usually call [Builder.topK] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun topK(topK: JsonField) = apply { this.topK = topK } + + /** + * Top-p (nucleus) sampling parameter — cumulative probability cutoff for token + * selection. Default: 1.0. + */ + fun topP(topP: Float) = topP(JsonField.of(topP)) + + /** + * Sets [Builder.topP] to an arbitrary JSON value. + * + * You should usually call [Builder.topP] with a well-typed [Float] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun topP(topP: JsonField) = apply { this.topP = topP } + + /** + * ID of an existing voice design to add a new version to. When provided, a new version + * is created instead of a new design. + */ + fun voiceDesignId(voiceDesignId: String) = voiceDesignId(JsonField.of(voiceDesignId)) + + /** + * Sets [Builder.voiceDesignId] to an arbitrary JSON value. + * + * You should usually call [Builder.voiceDesignId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun voiceDesignId(voiceDesignId: JsonField) = apply { + this.voiceDesignId = voiceDesignId + } + + 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 + * .prompt() + * .text() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("prompt", prompt), + checkRequired("text", text), + language, + maxNewTokens, + name, + repetitionPenalty, + temperature, + topK, + topP, + voiceDesignId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + prompt() + text() + language() + maxNewTokens() + name() + repetitionPenalty() + temperature() + topK() + topP() + voiceDesignId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: TelnyxInvalidDataException) { + 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 (prompt.asKnown().isPresent) 1 else 0) + + (if (text.asKnown().isPresent) 1 else 0) + + (if (language.asKnown().isPresent) 1 else 0) + + (if (maxNewTokens.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (repetitionPenalty.asKnown().isPresent) 1 else 0) + + (if (temperature.asKnown().isPresent) 1 else 0) + + (if (topK.asKnown().isPresent) 1 else 0) + + (if (topP.asKnown().isPresent) 1 else 0) + + (if (voiceDesignId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + prompt == other.prompt && + text == other.text && + language == other.language && + maxNewTokens == other.maxNewTokens && + name == other.name && + repetitionPenalty == other.repetitionPenalty && + temperature == other.temperature && + topK == other.topK && + topP == other.topP && + voiceDesignId == other.voiceDesignId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + prompt, + text, + language, + maxNewTokens, + name, + repetitionPenalty, + temperature, + topK, + topP, + voiceDesignId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{prompt=$prompt, text=$text, language=$language, maxNewTokens=$maxNewTokens, name=$name, repetitionPenalty=$repetitionPenalty, temperature=$temperature, topK=$topK, topP=$topP, voiceDesignId=$voiceDesignId, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is VoiceDesignCreateParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "VoiceDesignCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/voicedesigns/VoiceDesignCreateResponse.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/voicedesigns/VoiceDesignCreateResponse.kt new file mode 100644 index 000000000..59657203d --- /dev/null +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/voicedesigns/VoiceDesignCreateResponse.kt @@ -0,0 +1,161 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.voicedesigns + +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 com.telnyx.sdk.core.ExcludeMissing +import com.telnyx.sdk.core.JsonField +import com.telnyx.sdk.core.JsonMissing +import com.telnyx.sdk.core.JsonValue +import com.telnyx.sdk.errors.TelnyxInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Response envelope for a single voice design with full version detail. */ +class VoiceDesignCreateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val data: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of() + ) : this(data, mutableMapOf()) + + /** + * A voice design object with full version detail. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun data(): Optional = data.getOptional("data") + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + @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 [VoiceDesignCreateResponse]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [VoiceDesignCreateResponse]. */ + class Builder internal constructor() { + + private var data: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(voiceDesignCreateResponse: VoiceDesignCreateResponse) = apply { + data = voiceDesignCreateResponse.data + additionalProperties = voiceDesignCreateResponse.additionalProperties.toMutableMap() + } + + /** A voice design object with full version detail. */ + fun data(data: VoiceDesignData) = data(JsonField.of(data)) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed [VoiceDesignData] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun data(data: JsonField) = apply { this.data = data } + + 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 [VoiceDesignCreateResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): VoiceDesignCreateResponse = + VoiceDesignCreateResponse(data, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): VoiceDesignCreateResponse = apply { + if (validated) { + return@apply + } + + data().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: TelnyxInvalidDataException) { + 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 = (data.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is VoiceDesignCreateResponse && + data == other.data && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(data, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "VoiceDesignCreateResponse{data=$data, additionalProperties=$additionalProperties}" +} diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/voicedesigns/VoiceDesignData.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/voicedesigns/VoiceDesignData.kt new file mode 100644 index 000000000..978652383 --- /dev/null +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/voicedesigns/VoiceDesignData.kt @@ -0,0 +1,651 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.voicedesigns + +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 com.telnyx.sdk.core.Enum +import com.telnyx.sdk.core.ExcludeMissing +import com.telnyx.sdk.core.JsonField +import com.telnyx.sdk.core.JsonMissing +import com.telnyx.sdk.core.JsonValue +import com.telnyx.sdk.errors.TelnyxInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** A voice design object with full version detail. */ +class VoiceDesignData +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val createdAt: JsonField, + private val name: JsonField, + private val prompt: JsonField, + private val recordType: JsonField, + private val text: JsonField, + private val updatedAt: JsonField, + private val version: JsonField, + private val versionCreatedAt: JsonField, + private val voiceSampleSize: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("prompt") @ExcludeMissing prompt: JsonField = JsonMissing.of(), + @JsonProperty("record_type") + @ExcludeMissing + recordType: JsonField = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), + @JsonProperty("updated_at") + @ExcludeMissing + updatedAt: JsonField = JsonMissing.of(), + @JsonProperty("version") @ExcludeMissing version: JsonField = JsonMissing.of(), + @JsonProperty("version_created_at") + @ExcludeMissing + versionCreatedAt: JsonField = JsonMissing.of(), + @JsonProperty("voice_sample_size") + @ExcludeMissing + voiceSampleSize: JsonField = JsonMissing.of(), + ) : this( + id, + createdAt, + name, + prompt, + recordType, + text, + updatedAt, + version, + versionCreatedAt, + voiceSampleSize, + mutableMapOf(), + ) + + /** + * Unique identifier for the voice design. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun id(): Optional = id.getOptional("id") + + /** + * Timestamp when the voice design was first created. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun createdAt(): Optional = createdAt.getOptional("created_at") + + /** + * Name of the voice design. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun name(): Optional = name.getOptional("name") + + /** + * Natural language prompt used to define the voice style for this version. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun prompt(): Optional = prompt.getOptional("prompt") + + /** + * Identifies the resource type. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun recordType(): Optional = recordType.getOptional("record_type") + + /** + * Sample text used to synthesize this version. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun text(): Optional = text.getOptional("text") + + /** + * Timestamp when the voice design was last updated. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun updatedAt(): Optional = updatedAt.getOptional("updated_at") + + /** + * Version number of this voice design. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun version(): Optional = version.getOptional("version") + + /** + * Timestamp when this specific version was created. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun versionCreatedAt(): Optional = + versionCreatedAt.getOptional("version_created_at") + + /** + * Size of the voice sample audio in bytes. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun voiceSampleSize(): Optional = voiceSampleSize.getOptional("voice_sample_size") + + /** + * 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 [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 [prompt]. + * + * Unlike [prompt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("prompt") @ExcludeMissing fun _prompt(): JsonField = prompt + + /** + * Returns the raw JSON value of [recordType]. + * + * Unlike [recordType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("record_type") + @ExcludeMissing + fun _recordType(): JsonField = recordType + + /** + * 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 [updatedAt]. + * + * Unlike [updatedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("updated_at") + @ExcludeMissing + fun _updatedAt(): JsonField = updatedAt + + /** + * Returns the raw JSON value of [version]. + * + * Unlike [version], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version + + /** + * Returns the raw JSON value of [versionCreatedAt]. + * + * Unlike [versionCreatedAt], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("version_created_at") + @ExcludeMissing + fun _versionCreatedAt(): JsonField = versionCreatedAt + + /** + * Returns the raw JSON value of [voiceSampleSize]. + * + * Unlike [voiceSampleSize], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("voice_sample_size") + @ExcludeMissing + fun _voiceSampleSize(): JsonField = voiceSampleSize + + @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 [VoiceDesignData]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [VoiceDesignData]. */ + class Builder internal constructor() { + + private var id: JsonField = JsonMissing.of() + private var createdAt: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var prompt: JsonField = JsonMissing.of() + private var recordType: JsonField = JsonMissing.of() + private var text: JsonField = JsonMissing.of() + private var updatedAt: JsonField = JsonMissing.of() + private var version: JsonField = JsonMissing.of() + private var versionCreatedAt: JsonField = JsonMissing.of() + private var voiceSampleSize: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(voiceDesignData: VoiceDesignData) = apply { + id = voiceDesignData.id + createdAt = voiceDesignData.createdAt + name = voiceDesignData.name + prompt = voiceDesignData.prompt + recordType = voiceDesignData.recordType + text = voiceDesignData.text + updatedAt = voiceDesignData.updatedAt + version = voiceDesignData.version + versionCreatedAt = voiceDesignData.versionCreatedAt + voiceSampleSize = voiceDesignData.voiceSampleSize + additionalProperties = voiceDesignData.additionalProperties.toMutableMap() + } + + /** Unique identifier for the voice design. */ + 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 } + + /** Timestamp when the voice design was first created. */ + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } + + /** Name of the voice design. */ + 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 } + + /** Natural language prompt used to define the voice style for this version. */ + fun prompt(prompt: String) = prompt(JsonField.of(prompt)) + + /** + * Sets [Builder.prompt] to an arbitrary JSON value. + * + * You should usually call [Builder.prompt] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun prompt(prompt: JsonField) = apply { this.prompt = prompt } + + /** Identifies the resource type. */ + fun recordType(recordType: RecordType) = recordType(JsonField.of(recordType)) + + /** + * Sets [Builder.recordType] to an arbitrary JSON value. + * + * You should usually call [Builder.recordType] with a well-typed [RecordType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun recordType(recordType: JsonField) = apply { this.recordType = recordType } + + /** Sample text used to synthesize this version. */ + 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 } + + /** Timestamp when the voice design was last updated. */ + fun updatedAt(updatedAt: OffsetDateTime) = updatedAt(JsonField.of(updatedAt)) + + /** + * Sets [Builder.updatedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.updatedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun updatedAt(updatedAt: JsonField) = apply { this.updatedAt = updatedAt } + + /** Version number of this voice design. */ + fun version(version: Long) = version(JsonField.of(version)) + + /** + * Sets [Builder.version] to an arbitrary JSON value. + * + * You should usually call [Builder.version] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun version(version: JsonField) = apply { this.version = version } + + /** Timestamp when this specific version was created. */ + fun versionCreatedAt(versionCreatedAt: OffsetDateTime) = + versionCreatedAt(JsonField.of(versionCreatedAt)) + + /** + * Sets [Builder.versionCreatedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.versionCreatedAt] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun versionCreatedAt(versionCreatedAt: JsonField) = apply { + this.versionCreatedAt = versionCreatedAt + } + + /** Size of the voice sample audio in bytes. */ + fun voiceSampleSize(voiceSampleSize: Long) = voiceSampleSize(JsonField.of(voiceSampleSize)) + + /** + * Sets [Builder.voiceSampleSize] to an arbitrary JSON value. + * + * You should usually call [Builder.voiceSampleSize] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun voiceSampleSize(voiceSampleSize: JsonField) = apply { + this.voiceSampleSize = voiceSampleSize + } + + 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 [VoiceDesignData]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): VoiceDesignData = + VoiceDesignData( + id, + createdAt, + name, + prompt, + recordType, + text, + updatedAt, + version, + versionCreatedAt, + voiceSampleSize, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): VoiceDesignData = apply { + if (validated) { + return@apply + } + + id() + createdAt() + name() + prompt() + recordType().ifPresent { it.validate() } + text() + updatedAt() + version() + versionCreatedAt() + voiceSampleSize() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: TelnyxInvalidDataException) { + 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 (name.asKnown().isPresent) 1 else 0) + + (if (prompt.asKnown().isPresent) 1 else 0) + + (recordType.asKnown().getOrNull()?.validity() ?: 0) + + (if (text.asKnown().isPresent) 1 else 0) + + (if (updatedAt.asKnown().isPresent) 1 else 0) + + (if (version.asKnown().isPresent) 1 else 0) + + (if (versionCreatedAt.asKnown().isPresent) 1 else 0) + + (if (voiceSampleSize.asKnown().isPresent) 1 else 0) + + /** Identifies the resource type. */ + class RecordType @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 VOICE_DESIGN = of("voice_design") + + @JvmStatic fun of(value: String) = RecordType(JsonField.of(value)) + } + + /** An enum containing [RecordType]'s known values. */ + enum class Known { + VOICE_DESIGN + } + + /** + * An enum containing [RecordType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [RecordType] 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 { + VOICE_DESIGN, + /** + * An enum member indicating that [RecordType] 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) { + VOICE_DESIGN -> Value.VOICE_DESIGN + 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 TelnyxInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + VOICE_DESIGN -> Known.VOICE_DESIGN + else -> throw TelnyxInvalidDataException("Unknown RecordType: $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 TelnyxInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { TelnyxInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): RecordType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: TelnyxInvalidDataException) { + 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 RecordType && 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 VoiceDesignData && + id == other.id && + createdAt == other.createdAt && + name == other.name && + prompt == other.prompt && + recordType == other.recordType && + text == other.text && + updatedAt == other.updatedAt && + version == other.version && + versionCreatedAt == other.versionCreatedAt && + voiceSampleSize == other.voiceSampleSize && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + createdAt, + name, + prompt, + recordType, + text, + updatedAt, + version, + versionCreatedAt, + voiceSampleSize, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "VoiceDesignData{id=$id, createdAt=$createdAt, name=$name, prompt=$prompt, recordType=$recordType, text=$text, updatedAt=$updatedAt, version=$version, versionCreatedAt=$versionCreatedAt, voiceSampleSize=$voiceSampleSize, additionalProperties=$additionalProperties}" +} diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/voicedesigns/VoiceDesignDeleteParams.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/voicedesigns/VoiceDesignDeleteParams.kt new file mode 100644 index 000000000..11327c528 --- /dev/null +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/voicedesigns/VoiceDesignDeleteParams.kt @@ -0,0 +1,230 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.voicedesigns + +import com.telnyx.sdk.core.JsonValue +import com.telnyx.sdk.core.Params +import com.telnyx.sdk.core.http.Headers +import com.telnyx.sdk.core.http.QueryParams +import com.telnyx.sdk.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Permanently deletes a voice design and all of its versions. This action cannot be undone. */ +class VoiceDesignDeleteParams +private constructor( + private val id: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map, +) : Params { + + fun id(): Optional = Optional.ofNullable(id) + + /** 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(): VoiceDesignDeleteParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [VoiceDesignDeleteParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [VoiceDesignDeleteParams]. */ + class Builder internal constructor() { + + private var id: 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(voiceDesignDeleteParams: VoiceDesignDeleteParams) = apply { + id = voiceDesignDeleteParams.id + additionalHeaders = voiceDesignDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = voiceDesignDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = + voiceDesignDeleteParams.additionalBodyProperties.toMutableMap() + } + + 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) + } + + 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 [VoiceDesignDeleteParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): VoiceDesignDeleteParams = + VoiceDesignDeleteParams( + id, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + 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 VoiceDesignDeleteParams && + id == other.id && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash(id, additionalHeaders, additionalQueryParams, additionalBodyProperties) + + override fun toString() = + "VoiceDesignDeleteParams{id=$id, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/voicedesigns/VoiceDesignDeleteVersionParams.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/voicedesigns/VoiceDesignDeleteVersionParams.kt new file mode 100644 index 000000000..973b984e1 --- /dev/null +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/voicedesigns/VoiceDesignDeleteVersionParams.kt @@ -0,0 +1,270 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.voicedesigns + +import com.telnyx.sdk.core.JsonValue +import com.telnyx.sdk.core.Params +import com.telnyx.sdk.core.checkRequired +import com.telnyx.sdk.core.http.Headers +import com.telnyx.sdk.core.http.QueryParams +import com.telnyx.sdk.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Permanently deletes a specific version of a voice design. The version number must be a positive + * integer. + */ +class VoiceDesignDeleteVersionParams +private constructor( + private val id: String, + private val version: Long?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map, +) : Params { + + fun id(): String = id + + fun version(): Optional = Optional.ofNullable(version) + + /** 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 { + + /** + * Returns a mutable builder for constructing an instance of + * [VoiceDesignDeleteVersionParams]. + * + * The following fields are required: + * ```java + * .id() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [VoiceDesignDeleteVersionParams]. */ + class Builder internal constructor() { + + private var id: String? = null + private var version: Long? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(voiceDesignDeleteVersionParams: VoiceDesignDeleteVersionParams) = apply { + id = voiceDesignDeleteVersionParams.id + version = voiceDesignDeleteVersionParams.version + additionalHeaders = voiceDesignDeleteVersionParams.additionalHeaders.toBuilder() + additionalQueryParams = voiceDesignDeleteVersionParams.additionalQueryParams.toBuilder() + additionalBodyProperties = + voiceDesignDeleteVersionParams.additionalBodyProperties.toMutableMap() + } + + fun id(id: String) = apply { this.id = id } + + fun version(version: Long?) = apply { this.version = version } + + /** + * Alias for [Builder.version]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun version(version: Long) = version(version as Long?) + + /** Alias for calling [Builder.version] with `version.orElse(null)`. */ + fun version(version: Optional) = version(version.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 [VoiceDesignDeleteVersionParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): VoiceDesignDeleteVersionParams = + VoiceDesignDeleteVersionParams( + checkRequired("id", id), + version, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> id + 1 -> version?.toString() ?: "" + 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 VoiceDesignDeleteVersionParams && + id == other.id && + version == other.version && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash( + id, + version, + additionalHeaders, + additionalQueryParams, + additionalBodyProperties, + ) + + override fun toString() = + "VoiceDesignDeleteVersionParams{id=$id, version=$version, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/voicedesigns/VoiceDesignDownloadSampleParams.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/voicedesigns/VoiceDesignDownloadSampleParams.kt new file mode 100644 index 000000000..90b1b9539 --- /dev/null +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/voicedesigns/VoiceDesignDownloadSampleParams.kt @@ -0,0 +1,230 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.voicedesigns + +import com.telnyx.sdk.core.Params +import com.telnyx.sdk.core.http.Headers +import com.telnyx.sdk.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Downloads the WAV audio sample for the voice design. Returns the latest version's sample by + * default, or a specific version when `?version=N` is provided. The `id` parameter accepts either a + * UUID or the design name. + */ +class VoiceDesignDownloadSampleParams +private constructor( + private val id: String?, + private val version: Long?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun id(): Optional = Optional.ofNullable(id) + + /** Specific version number to download the sample for. Defaults to the latest version. */ + fun version(): Optional = Optional.ofNullable(version) + + /** 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(): VoiceDesignDownloadSampleParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of + * [VoiceDesignDownloadSampleParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [VoiceDesignDownloadSampleParams]. */ + class Builder internal constructor() { + + private var id: String? = null + private var version: Long? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(voiceDesignDownloadSampleParams: VoiceDesignDownloadSampleParams) = + apply { + id = voiceDesignDownloadSampleParams.id + version = voiceDesignDownloadSampleParams.version + additionalHeaders = voiceDesignDownloadSampleParams.additionalHeaders.toBuilder() + additionalQueryParams = + voiceDesignDownloadSampleParams.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()) + + /** Specific version number to download the sample for. Defaults to the latest version. */ + fun version(version: Long?) = apply { this.version = version } + + /** + * Alias for [Builder.version]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun version(version: Long) = version(version as Long?) + + /** Alias for calling [Builder.version] with `version.orElse(null)`. */ + fun version(version: Optional) = version(version.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 [VoiceDesignDownloadSampleParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): VoiceDesignDownloadSampleParams = + VoiceDesignDownloadSampleParams( + id, + version, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> id ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + version?.let { put("version", it.toString()) } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is VoiceDesignDownloadSampleParams && + id == other.id && + version == other.version && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(id, version, additionalHeaders, additionalQueryParams) + + override fun toString() = + "VoiceDesignDownloadSampleParams{id=$id, version=$version, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/voicedesigns/VoiceDesignListPage.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/voicedesigns/VoiceDesignListPage.kt new file mode 100644 index 000000000..13ddc8036 --- /dev/null +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/voicedesigns/VoiceDesignListPage.kt @@ -0,0 +1,141 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.voicedesigns + +import com.telnyx.sdk.core.AutoPager +import com.telnyx.sdk.core.Page +import com.telnyx.sdk.core.checkRequired +import com.telnyx.sdk.services.blocking.VoiceDesignService +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrDefault +import kotlin.jvm.optionals.getOrNull + +/** @see VoiceDesignService.list */ +class VoiceDesignListPage +private constructor( + private val service: VoiceDesignService, + private val params: VoiceDesignListParams, + private val response: VoiceDesignListPageResponse, +) : Page { + + /** + * Delegates to [VoiceDesignListPageResponse], but gracefully handles missing data. + * + * @see VoiceDesignListPageResponse.data + */ + fun data(): List = + response._data().getOptional("data").getOrNull() ?: emptyList() + + /** + * Delegates to [VoiceDesignListPageResponse], but gracefully handles missing data. + * + * @see VoiceDesignListPageResponse.meta + */ + fun meta(): Optional = response._meta().getOptional("meta") + + override fun items(): List = data() + + override fun hasNextPage(): Boolean { + if (items().isEmpty()) { + return false + } + + val pageNumber = + meta().flatMap { it._pageNumber().getOptional("page_number") }.getOrDefault(1) + val pageCount = meta().flatMap { it._totalPages().getOptional("total_pages") }.getOrNull() + return pageCount == null || pageNumber < pageCount + } + + fun nextPageParams(): VoiceDesignListParams { + val pageNumber = params.pageNumber().getOrDefault(1) + return params.toBuilder().pageNumber(pageNumber + 1).build() + } + + override fun nextPage(): VoiceDesignListPage = service.list(nextPageParams()) + + fun autoPager(): AutoPager = AutoPager.from(this) + + /** The parameters that were used to request this page. */ + fun params(): VoiceDesignListParams = params + + /** The response that this page was parsed from. */ + fun response(): VoiceDesignListPageResponse = response + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [VoiceDesignListPage]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [VoiceDesignListPage]. */ + class Builder internal constructor() { + + private var service: VoiceDesignService? = null + private var params: VoiceDesignListParams? = null + private var response: VoiceDesignListPageResponse? = null + + @JvmSynthetic + internal fun from(voiceDesignListPage: VoiceDesignListPage) = apply { + service = voiceDesignListPage.service + params = voiceDesignListPage.params + response = voiceDesignListPage.response + } + + fun service(service: VoiceDesignService) = apply { this.service = service } + + /** The parameters that were used to request this page. */ + fun params(params: VoiceDesignListParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: VoiceDesignListPageResponse) = apply { this.response = response } + + /** + * Returns an immutable instance of [VoiceDesignListPage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): VoiceDesignListPage = + VoiceDesignListPage( + checkRequired("service", service), + checkRequired("params", params), + checkRequired("response", response), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is VoiceDesignListPage && + service == other.service && + params == other.params && + response == other.response + } + + override fun hashCode(): Int = Objects.hash(service, params, response) + + override fun toString() = + "VoiceDesignListPage{service=$service, params=$params, response=$response}" +} diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/voicedesigns/VoiceDesignListPageAsync.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/voicedesigns/VoiceDesignListPageAsync.kt new file mode 100644 index 000000000..c30955290 --- /dev/null +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/voicedesigns/VoiceDesignListPageAsync.kt @@ -0,0 +1,156 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.voicedesigns + +import com.telnyx.sdk.core.AutoPagerAsync +import com.telnyx.sdk.core.PageAsync +import com.telnyx.sdk.core.checkRequired +import com.telnyx.sdk.services.async.VoiceDesignServiceAsync +import java.util.Objects +import java.util.Optional +import java.util.concurrent.CompletableFuture +import java.util.concurrent.Executor +import kotlin.jvm.optionals.getOrDefault +import kotlin.jvm.optionals.getOrNull + +/** @see VoiceDesignServiceAsync.list */ +class VoiceDesignListPageAsync +private constructor( + private val service: VoiceDesignServiceAsync, + private val streamHandlerExecutor: Executor, + private val params: VoiceDesignListParams, + private val response: VoiceDesignListPageResponse, +) : PageAsync { + + /** + * Delegates to [VoiceDesignListPageResponse], but gracefully handles missing data. + * + * @see VoiceDesignListPageResponse.data + */ + fun data(): List = + response._data().getOptional("data").getOrNull() ?: emptyList() + + /** + * Delegates to [VoiceDesignListPageResponse], but gracefully handles missing data. + * + * @see VoiceDesignListPageResponse.meta + */ + fun meta(): Optional = response._meta().getOptional("meta") + + override fun items(): List = data() + + override fun hasNextPage(): Boolean { + if (items().isEmpty()) { + return false + } + + val pageNumber = + meta().flatMap { it._pageNumber().getOptional("page_number") }.getOrDefault(1) + val pageCount = meta().flatMap { it._totalPages().getOptional("total_pages") }.getOrNull() + return pageCount == null || pageNumber < pageCount + } + + fun nextPageParams(): VoiceDesignListParams { + val pageNumber = params.pageNumber().getOrDefault(1) + return params.toBuilder().pageNumber(pageNumber + 1).build() + } + + override fun nextPage(): CompletableFuture = + service.list(nextPageParams()) + + fun autoPager(): AutoPagerAsync = + AutoPagerAsync.from(this, streamHandlerExecutor) + + /** The parameters that were used to request this page. */ + fun params(): VoiceDesignListParams = params + + /** The response that this page was parsed from. */ + fun response(): VoiceDesignListPageResponse = response + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [VoiceDesignListPageAsync]. + * + * The following fields are required: + * ```java + * .service() + * .streamHandlerExecutor() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [VoiceDesignListPageAsync]. */ + class Builder internal constructor() { + + private var service: VoiceDesignServiceAsync? = null + private var streamHandlerExecutor: Executor? = null + private var params: VoiceDesignListParams? = null + private var response: VoiceDesignListPageResponse? = null + + @JvmSynthetic + internal fun from(voiceDesignListPageAsync: VoiceDesignListPageAsync) = apply { + service = voiceDesignListPageAsync.service + streamHandlerExecutor = voiceDesignListPageAsync.streamHandlerExecutor + params = voiceDesignListPageAsync.params + response = voiceDesignListPageAsync.response + } + + fun service(service: VoiceDesignServiceAsync) = apply { this.service = service } + + fun streamHandlerExecutor(streamHandlerExecutor: Executor) = apply { + this.streamHandlerExecutor = streamHandlerExecutor + } + + /** The parameters that were used to request this page. */ + fun params(params: VoiceDesignListParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: VoiceDesignListPageResponse) = apply { this.response = response } + + /** + * Returns an immutable instance of [VoiceDesignListPageAsync]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .streamHandlerExecutor() + * .params() + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): VoiceDesignListPageAsync = + VoiceDesignListPageAsync( + checkRequired("service", service), + checkRequired("streamHandlerExecutor", streamHandlerExecutor), + checkRequired("params", params), + checkRequired("response", response), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is VoiceDesignListPageAsync && + service == other.service && + streamHandlerExecutor == other.streamHandlerExecutor && + params == other.params && + response == other.response + } + + override fun hashCode(): Int = Objects.hash(service, streamHandlerExecutor, params, response) + + override fun toString() = + "VoiceDesignListPageAsync{service=$service, streamHandlerExecutor=$streamHandlerExecutor, params=$params, response=$response}" +} diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/voicedesigns/VoiceDesignListPageResponse.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/voicedesigns/VoiceDesignListPageResponse.kt new file mode 100644 index 000000000..f2150d8be --- /dev/null +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/voicedesigns/VoiceDesignListPageResponse.kt @@ -0,0 +1,486 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.voicedesigns + +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 com.telnyx.sdk.core.ExcludeMissing +import com.telnyx.sdk.core.JsonField +import com.telnyx.sdk.core.JsonMissing +import com.telnyx.sdk.core.JsonValue +import com.telnyx.sdk.core.checkKnown +import com.telnyx.sdk.core.toImmutable +import com.telnyx.sdk.errors.TelnyxInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Paginated list of voice designs. */ +class VoiceDesignListPageResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val data: JsonField>, + private val meta: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("data") + @ExcludeMissing + data: JsonField> = JsonMissing.of(), + @JsonProperty("meta") @ExcludeMissing meta: JsonField = JsonMissing.of(), + ) : this(data, meta, mutableMapOf()) + + /** + * Array of voice design summary objects. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun data(): Optional> = data.getOptional("data") + + /** + * Pagination metadata returned with list responses. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun meta(): Optional = meta.getOptional("meta") + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") + @ExcludeMissing + fun _data(): JsonField> = data + + /** + * Returns the raw JSON value of [meta]. + * + * Unlike [meta], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("meta") @ExcludeMissing fun _meta(): JsonField = meta + + @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 [VoiceDesignListPageResponse]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [VoiceDesignListPageResponse]. */ + class Builder internal constructor() { + + private var data: JsonField>? = null + private var meta: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(voiceDesignListPageResponse: VoiceDesignListPageResponse) = apply { + data = voiceDesignListPageResponse.data.map { it.toMutableList() } + meta = voiceDesignListPageResponse.meta + additionalProperties = voiceDesignListPageResponse.additionalProperties.toMutableMap() + } + + /** Array of voice design summary objects. */ + fun data(data: List) = data(JsonField.of(data)) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun data(data: JsonField>) = apply { + this.data = data.map { it.toMutableList() } + } + + /** + * Adds a single [VoiceDesignListResponse] to [Builder.data]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addData(data: VoiceDesignListResponse) = apply { + this.data = + (this.data ?: JsonField.of(mutableListOf())).also { + checkKnown("data", it).add(data) + } + } + + /** Pagination metadata returned with list responses. */ + fun meta(meta: Meta) = meta(JsonField.of(meta)) + + /** + * Sets [Builder.meta] to an arbitrary JSON value. + * + * You should usually call [Builder.meta] with a well-typed [Meta] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun meta(meta: JsonField) = apply { this.meta = meta } + + 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 [VoiceDesignListPageResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): VoiceDesignListPageResponse = + VoiceDesignListPageResponse( + (data ?: JsonMissing.of()).map { it.toImmutable() }, + meta, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): VoiceDesignListPageResponse = apply { + if (validated) { + return@apply + } + + data().ifPresent { it.forEach { it.validate() } } + meta().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: TelnyxInvalidDataException) { + 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 = + (data.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (meta.asKnown().getOrNull()?.validity() ?: 0) + + /** Pagination metadata returned with list responses. */ + class Meta + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val pageNumber: JsonField, + private val pageSize: JsonField, + private val totalPages: JsonField, + private val totalResults: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("page_number") + @ExcludeMissing + pageNumber: JsonField = JsonMissing.of(), + @JsonProperty("page_size") @ExcludeMissing pageSize: JsonField = JsonMissing.of(), + @JsonProperty("total_pages") + @ExcludeMissing + totalPages: JsonField = JsonMissing.of(), + @JsonProperty("total_results") + @ExcludeMissing + totalResults: JsonField = JsonMissing.of(), + ) : this(pageNumber, pageSize, totalPages, totalResults, mutableMapOf()) + + /** + * Current page number (1-based). + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun pageNumber(): Optional = pageNumber.getOptional("page_number") + + /** + * Number of results per page. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun pageSize(): Optional = pageSize.getOptional("page_size") + + /** + * Total number of pages. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun totalPages(): Optional = totalPages.getOptional("total_pages") + + /** + * Total number of results across all pages. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun totalResults(): Optional = totalResults.getOptional("total_results") + + /** + * Returns the raw JSON value of [pageNumber]. + * + * Unlike [pageNumber], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("page_number") @ExcludeMissing fun _pageNumber(): JsonField = pageNumber + + /** + * Returns the raw JSON value of [pageSize]. + * + * Unlike [pageSize], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("page_size") @ExcludeMissing fun _pageSize(): JsonField = pageSize + + /** + * Returns the raw JSON value of [totalPages]. + * + * Unlike [totalPages], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("total_pages") @ExcludeMissing fun _totalPages(): JsonField = totalPages + + /** + * Returns the raw JSON value of [totalResults]. + * + * Unlike [totalResults], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("total_results") + @ExcludeMissing + fun _totalResults(): JsonField = totalResults + + @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 [Meta]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Meta]. */ + class Builder internal constructor() { + + private var pageNumber: JsonField = JsonMissing.of() + private var pageSize: JsonField = JsonMissing.of() + private var totalPages: JsonField = JsonMissing.of() + private var totalResults: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(meta: Meta) = apply { + pageNumber = meta.pageNumber + pageSize = meta.pageSize + totalPages = meta.totalPages + totalResults = meta.totalResults + additionalProperties = meta.additionalProperties.toMutableMap() + } + + /** Current page number (1-based). */ + fun pageNumber(pageNumber: Long) = pageNumber(JsonField.of(pageNumber)) + + /** + * Sets [Builder.pageNumber] to an arbitrary JSON value. + * + * You should usually call [Builder.pageNumber] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun pageNumber(pageNumber: JsonField) = apply { this.pageNumber = pageNumber } + + /** Number of results per page. */ + fun pageSize(pageSize: Long) = pageSize(JsonField.of(pageSize)) + + /** + * Sets [Builder.pageSize] to an arbitrary JSON value. + * + * You should usually call [Builder.pageSize] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun pageSize(pageSize: JsonField) = apply { this.pageSize = pageSize } + + /** Total number of pages. */ + fun totalPages(totalPages: Long) = totalPages(JsonField.of(totalPages)) + + /** + * Sets [Builder.totalPages] to an arbitrary JSON value. + * + * You should usually call [Builder.totalPages] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun totalPages(totalPages: JsonField) = apply { this.totalPages = totalPages } + + /** Total number of results across all pages. */ + fun totalResults(totalResults: Long) = totalResults(JsonField.of(totalResults)) + + /** + * Sets [Builder.totalResults] to an arbitrary JSON value. + * + * You should usually call [Builder.totalResults] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun totalResults(totalResults: JsonField) = apply { + this.totalResults = totalResults + } + + 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 [Meta]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Meta = + Meta( + pageNumber, + pageSize, + totalPages, + totalResults, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Meta = apply { + if (validated) { + return@apply + } + + pageNumber() + pageSize() + totalPages() + totalResults() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: TelnyxInvalidDataException) { + 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 (pageNumber.asKnown().isPresent) 1 else 0) + + (if (pageSize.asKnown().isPresent) 1 else 0) + + (if (totalPages.asKnown().isPresent) 1 else 0) + + (if (totalResults.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Meta && + pageNumber == other.pageNumber && + pageSize == other.pageSize && + totalPages == other.totalPages && + totalResults == other.totalResults && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(pageNumber, pageSize, totalPages, totalResults, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Meta{pageNumber=$pageNumber, pageSize=$pageSize, totalPages=$totalPages, totalResults=$totalResults, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is VoiceDesignListPageResponse && + data == other.data && + meta == other.meta && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(data, meta, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "VoiceDesignListPageResponse{data=$data, meta=$meta, additionalProperties=$additionalProperties}" +} diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/voicedesigns/VoiceDesignListParams.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/voicedesigns/VoiceDesignListParams.kt new file mode 100644 index 000000000..95e2c3a7e --- /dev/null +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/voicedesigns/VoiceDesignListParams.kt @@ -0,0 +1,404 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.voicedesigns + +import com.fasterxml.jackson.annotation.JsonCreator +import com.telnyx.sdk.core.Enum +import com.telnyx.sdk.core.JsonField +import com.telnyx.sdk.core.Params +import com.telnyx.sdk.core.http.Headers +import com.telnyx.sdk.core.http.QueryParams +import com.telnyx.sdk.errors.TelnyxInvalidDataException +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Returns a paginated list of voice designs belonging to the authenticated account. */ +class VoiceDesignListParams +private constructor( + private val filterName: String?, + private val pageNumber: Long?, + private val pageSize: Long?, + private val sort: Sort?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** Case-insensitive substring filter on the name field. */ + fun filterName(): Optional = Optional.ofNullable(filterName) + + /** Page number for pagination (1-based). */ + fun pageNumber(): Optional = Optional.ofNullable(pageNumber) + + /** Number of results per page. */ + fun pageSize(): Optional = Optional.ofNullable(pageSize) + + /** Sort order. Prefix with `-` for descending. Defaults to `-created_at`. */ + fun sort(): Optional = Optional.ofNullable(sort) + + /** 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(): VoiceDesignListParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [VoiceDesignListParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [VoiceDesignListParams]. */ + class Builder internal constructor() { + + private var filterName: String? = null + private var pageNumber: Long? = null + private var pageSize: Long? = null + private var sort: Sort? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(voiceDesignListParams: VoiceDesignListParams) = apply { + filterName = voiceDesignListParams.filterName + pageNumber = voiceDesignListParams.pageNumber + pageSize = voiceDesignListParams.pageSize + sort = voiceDesignListParams.sort + additionalHeaders = voiceDesignListParams.additionalHeaders.toBuilder() + additionalQueryParams = voiceDesignListParams.additionalQueryParams.toBuilder() + } + + /** Case-insensitive substring filter on the name field. */ + fun filterName(filterName: String?) = apply { this.filterName = filterName } + + /** Alias for calling [Builder.filterName] with `filterName.orElse(null)`. */ + fun filterName(filterName: Optional) = filterName(filterName.getOrNull()) + + /** Page number for pagination (1-based). */ + fun pageNumber(pageNumber: Long?) = apply { this.pageNumber = pageNumber } + + /** + * Alias for [Builder.pageNumber]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun pageNumber(pageNumber: Long) = pageNumber(pageNumber as Long?) + + /** Alias for calling [Builder.pageNumber] with `pageNumber.orElse(null)`. */ + fun pageNumber(pageNumber: Optional) = pageNumber(pageNumber.getOrNull()) + + /** Number of results per page. */ + fun pageSize(pageSize: Long?) = apply { this.pageSize = pageSize } + + /** + * Alias for [Builder.pageSize]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun pageSize(pageSize: Long) = pageSize(pageSize as Long?) + + /** Alias for calling [Builder.pageSize] with `pageSize.orElse(null)`. */ + fun pageSize(pageSize: Optional) = pageSize(pageSize.getOrNull()) + + /** Sort order. Prefix with `-` for descending. Defaults to `-created_at`. */ + fun sort(sort: Sort?) = apply { this.sort = sort } + + /** Alias for calling [Builder.sort] with `sort.orElse(null)`. */ + fun sort(sort: Optional) = sort(sort.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 [VoiceDesignListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): VoiceDesignListParams = + VoiceDesignListParams( + filterName, + pageNumber, + pageSize, + sort, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + filterName?.let { put("filter[name]", it) } + pageNumber?.let { put("page[number]", it.toString()) } + pageSize?.let { put("page[size]", it.toString()) } + sort?.let { put("sort", it.toString()) } + putAll(additionalQueryParams) + } + .build() + + /** Sort order. Prefix with `-` for descending. Defaults to `-created_at`. */ + class Sort @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 NAME = of("name") + + @JvmField val NAME_DESC = of("-name") + + @JvmField val CREATED_AT = of("created_at") + + @JvmField val CREATED_AT_DESC = of("-created_at") + + @JvmStatic fun of(value: String) = Sort(JsonField.of(value)) + } + + /** An enum containing [Sort]'s known values. */ + enum class Known { + NAME, + NAME_DESC, + CREATED_AT, + CREATED_AT_DESC, + } + + /** + * An enum containing [Sort]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Sort] 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 { + NAME, + NAME_DESC, + CREATED_AT, + CREATED_AT_DESC, + /** An enum member indicating that [Sort] 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) { + NAME -> Value.NAME + NAME_DESC -> Value.NAME_DESC + CREATED_AT -> Value.CREATED_AT + CREATED_AT_DESC -> Value.CREATED_AT_DESC + 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 TelnyxInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + NAME -> Known.NAME + NAME_DESC -> Known.NAME_DESC + CREATED_AT -> Known.CREATED_AT + CREATED_AT_DESC -> Known.CREATED_AT_DESC + else -> throw TelnyxInvalidDataException("Unknown Sort: $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 TelnyxInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { TelnyxInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): Sort = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: TelnyxInvalidDataException) { + 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 Sort && 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 VoiceDesignListParams && + filterName == other.filterName && + pageNumber == other.pageNumber && + pageSize == other.pageSize && + sort == other.sort && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash( + filterName, + pageNumber, + pageSize, + sort, + additionalHeaders, + additionalQueryParams, + ) + + override fun toString() = + "VoiceDesignListParams{filterName=$filterName, pageNumber=$pageNumber, pageSize=$pageSize, sort=$sort, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/voicedesigns/VoiceDesignListResponse.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/voicedesigns/VoiceDesignListResponse.kt new file mode 100644 index 000000000..7c6ca6c5d --- /dev/null +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/voicedesigns/VoiceDesignListResponse.kt @@ -0,0 +1,440 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.voicedesigns + +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 com.telnyx.sdk.core.Enum +import com.telnyx.sdk.core.ExcludeMissing +import com.telnyx.sdk.core.JsonField +import com.telnyx.sdk.core.JsonMissing +import com.telnyx.sdk.core.JsonValue +import com.telnyx.sdk.errors.TelnyxInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** A summarized voice design object (without version-specific fields). */ +class VoiceDesignListResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val createdAt: JsonField, + private val name: JsonField, + private val recordType: JsonField, + private val updatedAt: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("record_type") + @ExcludeMissing + recordType: JsonField = JsonMissing.of(), + @JsonProperty("updated_at") + @ExcludeMissing + updatedAt: JsonField = JsonMissing.of(), + ) : this(id, createdAt, name, recordType, updatedAt, mutableMapOf()) + + /** + * Unique identifier for the voice design. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun id(): Optional = id.getOptional("id") + + /** + * Timestamp when the voice design was first created. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun createdAt(): Optional = createdAt.getOptional("created_at") + + /** + * Name of the voice design. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun name(): Optional = name.getOptional("name") + + /** + * Identifies the resource type. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun recordType(): Optional = recordType.getOptional("record_type") + + /** + * Timestamp when the voice design was last updated. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun updatedAt(): Optional = updatedAt.getOptional("updated_at") + + /** + * Returns the raw JSON value of [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 [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 [recordType]. + * + * Unlike [recordType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("record_type") + @ExcludeMissing + fun _recordType(): JsonField = recordType + + /** + * Returns the raw JSON value of [updatedAt]. + * + * Unlike [updatedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("updated_at") + @ExcludeMissing + fun _updatedAt(): JsonField = updatedAt + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [VoiceDesignListResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [VoiceDesignListResponse]. */ + class Builder internal constructor() { + + private var id: JsonField = JsonMissing.of() + private var createdAt: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var recordType: JsonField = JsonMissing.of() + private var updatedAt: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(voiceDesignListResponse: VoiceDesignListResponse) = apply { + id = voiceDesignListResponse.id + createdAt = voiceDesignListResponse.createdAt + name = voiceDesignListResponse.name + recordType = voiceDesignListResponse.recordType + updatedAt = voiceDesignListResponse.updatedAt + additionalProperties = voiceDesignListResponse.additionalProperties.toMutableMap() + } + + /** Unique identifier for the voice design. */ + 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 } + + /** Timestamp when the voice design was first created. */ + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } + + /** Name of the voice design. */ + 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 } + + /** Identifies the resource type. */ + fun recordType(recordType: RecordType) = recordType(JsonField.of(recordType)) + + /** + * Sets [Builder.recordType] to an arbitrary JSON value. + * + * You should usually call [Builder.recordType] with a well-typed [RecordType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun recordType(recordType: JsonField) = apply { this.recordType = recordType } + + /** Timestamp when the voice design was last updated. */ + fun updatedAt(updatedAt: OffsetDateTime) = updatedAt(JsonField.of(updatedAt)) + + /** + * Sets [Builder.updatedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.updatedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun updatedAt(updatedAt: JsonField) = apply { this.updatedAt = updatedAt } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [VoiceDesignListResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): VoiceDesignListResponse = + VoiceDesignListResponse( + id, + createdAt, + name, + recordType, + updatedAt, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): VoiceDesignListResponse = apply { + if (validated) { + return@apply + } + + id() + createdAt() + name() + recordType().ifPresent { it.validate() } + updatedAt() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: TelnyxInvalidDataException) { + 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 (name.asKnown().isPresent) 1 else 0) + + (recordType.asKnown().getOrNull()?.validity() ?: 0) + + (if (updatedAt.asKnown().isPresent) 1 else 0) + + /** Identifies the resource type. */ + class RecordType @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 VOICE_DESIGN = of("voice_design") + + @JvmStatic fun of(value: String) = RecordType(JsonField.of(value)) + } + + /** An enum containing [RecordType]'s known values. */ + enum class Known { + VOICE_DESIGN + } + + /** + * An enum containing [RecordType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [RecordType] 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 { + VOICE_DESIGN, + /** + * An enum member indicating that [RecordType] 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) { + VOICE_DESIGN -> Value.VOICE_DESIGN + 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 TelnyxInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + VOICE_DESIGN -> Known.VOICE_DESIGN + else -> throw TelnyxInvalidDataException("Unknown RecordType: $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 TelnyxInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { TelnyxInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): RecordType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: TelnyxInvalidDataException) { + 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 RecordType && 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 VoiceDesignListResponse && + id == other.id && + createdAt == other.createdAt && + name == other.name && + recordType == other.recordType && + updatedAt == other.updatedAt && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, createdAt, name, recordType, updatedAt, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "VoiceDesignListResponse{id=$id, createdAt=$createdAt, name=$name, recordType=$recordType, updatedAt=$updatedAt, additionalProperties=$additionalProperties}" +} diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/voicedesigns/VoiceDesignRenameParams.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/voicedesigns/VoiceDesignRenameParams.kt new file mode 100644 index 000000000..c9def9317 --- /dev/null +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/voicedesigns/VoiceDesignRenameParams.kt @@ -0,0 +1,435 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.voicedesigns + +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 com.telnyx.sdk.core.ExcludeMissing +import com.telnyx.sdk.core.JsonField +import com.telnyx.sdk.core.JsonMissing +import com.telnyx.sdk.core.JsonValue +import com.telnyx.sdk.core.Params +import com.telnyx.sdk.core.checkRequired +import com.telnyx.sdk.core.http.Headers +import com.telnyx.sdk.core.http.QueryParams +import com.telnyx.sdk.errors.TelnyxInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Updates the name of a voice design. All versions retain their other properties. */ +class VoiceDesignRenameParams +private constructor( + private val id: String?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun id(): Optional = Optional.ofNullable(id) + + /** + * New name for the voice design. + * + * @throws TelnyxInvalidDataException 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 name(): String = body.name() + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _name(): JsonField = body._name() + + 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 [VoiceDesignRenameParams]. + * + * The following fields are required: + * ```java + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [VoiceDesignRenameParams]. */ + class Builder internal constructor() { + + private var id: 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(voiceDesignRenameParams: VoiceDesignRenameParams) = apply { + id = voiceDesignRenameParams.id + body = voiceDesignRenameParams.body.toBuilder() + additionalHeaders = voiceDesignRenameParams.additionalHeaders.toBuilder() + additionalQueryParams = voiceDesignRenameParams.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()) + + /** + * 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: + * - [name] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** New name for the voice design. */ + fun name(name: String) = apply { body.name(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 { body.name(name) } + + 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 [VoiceDesignRenameParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): VoiceDesignRenameParams = + VoiceDesignRenameParams( + id, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> id ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + /** Request body for renaming a voice design. */ + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of() + ) : this(name, mutableMapOf()) + + /** + * New name for the voice design. + * + * @throws TelnyxInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * 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 [Body]. + * + * The following fields are required: + * ```java + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + name = body.name + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** New name for the voice design. */ + 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 [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body(checkRequired("name", name), additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: TelnyxInvalidDataException) { + 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 (name.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(name, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Body{name=$name, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is VoiceDesignRenameParams && + id == other.id && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(id, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "VoiceDesignRenameParams{id=$id, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/voicedesigns/VoiceDesignRenameResponse.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/voicedesigns/VoiceDesignRenameResponse.kt new file mode 100644 index 000000000..87c54f680 --- /dev/null +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/voicedesigns/VoiceDesignRenameResponse.kt @@ -0,0 +1,596 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.voicedesigns + +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 com.telnyx.sdk.core.Enum +import com.telnyx.sdk.core.ExcludeMissing +import com.telnyx.sdk.core.JsonField +import com.telnyx.sdk.core.JsonMissing +import com.telnyx.sdk.core.JsonValue +import com.telnyx.sdk.errors.TelnyxInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Response envelope for a voice design after a rename operation (no version-specific fields). */ +class VoiceDesignRenameResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val data: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of() + ) : this(data, mutableMapOf()) + + /** + * A summarized voice design object (without version-specific fields). + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun data(): Optional = data.getOptional("data") + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + @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 [VoiceDesignRenameResponse]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [VoiceDesignRenameResponse]. */ + class Builder internal constructor() { + + private var data: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(voiceDesignRenameResponse: VoiceDesignRenameResponse) = apply { + data = voiceDesignRenameResponse.data + additionalProperties = voiceDesignRenameResponse.additionalProperties.toMutableMap() + } + + /** A summarized voice design object (without version-specific fields). */ + fun data(data: Data) = data(JsonField.of(data)) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed [Data] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun data(data: JsonField) = apply { this.data = data } + + 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 [VoiceDesignRenameResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): VoiceDesignRenameResponse = + VoiceDesignRenameResponse(data, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): VoiceDesignRenameResponse = apply { + if (validated) { + return@apply + } + + data().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: TelnyxInvalidDataException) { + 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 = (data.asKnown().getOrNull()?.validity() ?: 0) + + /** A summarized voice design object (without version-specific fields). */ + class Data + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val createdAt: JsonField, + private val name: JsonField, + private val recordType: JsonField, + private val updatedAt: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("record_type") + @ExcludeMissing + recordType: JsonField = JsonMissing.of(), + @JsonProperty("updated_at") + @ExcludeMissing + updatedAt: JsonField = JsonMissing.of(), + ) : this(id, createdAt, name, recordType, updatedAt, mutableMapOf()) + + /** + * Unique identifier for the voice design. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun id(): Optional = id.getOptional("id") + + /** + * Timestamp when the voice design was first created. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun createdAt(): Optional = createdAt.getOptional("created_at") + + /** + * Name of the voice design. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun name(): Optional = name.getOptional("name") + + /** + * Identifies the resource type. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun recordType(): Optional = recordType.getOptional("record_type") + + /** + * Timestamp when the voice design was last updated. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun updatedAt(): Optional = updatedAt.getOptional("updated_at") + + /** + * Returns the raw JSON value of [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 [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 [recordType]. + * + * Unlike [recordType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("record_type") + @ExcludeMissing + fun _recordType(): JsonField = recordType + + /** + * Returns the raw JSON value of [updatedAt]. + * + * Unlike [updatedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("updated_at") + @ExcludeMissing + fun _updatedAt(): JsonField = updatedAt + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Data]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Data]. */ + class Builder internal constructor() { + + private var id: JsonField = JsonMissing.of() + private var createdAt: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var recordType: JsonField = JsonMissing.of() + private var updatedAt: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(data: Data) = apply { + id = data.id + createdAt = data.createdAt + name = data.name + recordType = data.recordType + updatedAt = data.updatedAt + additionalProperties = data.additionalProperties.toMutableMap() + } + + /** Unique identifier for the voice design. */ + 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 } + + /** Timestamp when the voice design was first created. */ + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField) = apply { + this.createdAt = createdAt + } + + /** Name of the voice design. */ + 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 } + + /** Identifies the resource type. */ + fun recordType(recordType: RecordType) = recordType(JsonField.of(recordType)) + + /** + * Sets [Builder.recordType] to an arbitrary JSON value. + * + * You should usually call [Builder.recordType] with a well-typed [RecordType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun recordType(recordType: JsonField) = apply { + this.recordType = recordType + } + + /** Timestamp when the voice design was last updated. */ + fun updatedAt(updatedAt: OffsetDateTime) = updatedAt(JsonField.of(updatedAt)) + + /** + * Sets [Builder.updatedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.updatedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun updatedAt(updatedAt: JsonField) = apply { + this.updatedAt = updatedAt + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Data]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Data = + Data( + id, + createdAt, + name, + recordType, + updatedAt, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Data = apply { + if (validated) { + return@apply + } + + id() + createdAt() + name() + recordType().ifPresent { it.validate() } + updatedAt() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: TelnyxInvalidDataException) { + 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 (name.asKnown().isPresent) 1 else 0) + + (recordType.asKnown().getOrNull()?.validity() ?: 0) + + (if (updatedAt.asKnown().isPresent) 1 else 0) + + /** Identifies the resource type. */ + class RecordType @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 VOICE_DESIGN = of("voice_design") + + @JvmStatic fun of(value: String) = RecordType(JsonField.of(value)) + } + + /** An enum containing [RecordType]'s known values. */ + enum class Known { + VOICE_DESIGN + } + + /** + * An enum containing [RecordType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [RecordType] 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 { + VOICE_DESIGN, + /** + * An enum member indicating that [RecordType] 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) { + VOICE_DESIGN -> Value.VOICE_DESIGN + 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 TelnyxInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + VOICE_DESIGN -> Known.VOICE_DESIGN + else -> throw TelnyxInvalidDataException("Unknown RecordType: $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 TelnyxInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + TelnyxInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): RecordType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: TelnyxInvalidDataException) { + 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 RecordType && 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 Data && + id == other.id && + createdAt == other.createdAt && + name == other.name && + recordType == other.recordType && + updatedAt == other.updatedAt && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, createdAt, name, recordType, updatedAt, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Data{id=$id, createdAt=$createdAt, name=$name, recordType=$recordType, updatedAt=$updatedAt, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is VoiceDesignRenameResponse && + data == other.data && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(data, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "VoiceDesignRenameResponse{data=$data, additionalProperties=$additionalProperties}" +} diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/voicedesigns/VoiceDesignRetrieveParams.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/voicedesigns/VoiceDesignRetrieveParams.kt new file mode 100644 index 000000000..7eaf6e325 --- /dev/null +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/voicedesigns/VoiceDesignRetrieveParams.kt @@ -0,0 +1,226 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.voicedesigns + +import com.telnyx.sdk.core.Params +import com.telnyx.sdk.core.http.Headers +import com.telnyx.sdk.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Returns the latest version of a voice design, or a specific version when `?version=N` is + * provided. The `id` parameter accepts either a UUID or the design name. + */ +class VoiceDesignRetrieveParams +private constructor( + private val id: String?, + private val version: Long?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun id(): Optional = Optional.ofNullable(id) + + /** Specific version number to retrieve. Defaults to the latest version. */ + fun version(): Optional = Optional.ofNullable(version) + + /** 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(): VoiceDesignRetrieveParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of [VoiceDesignRetrieveParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [VoiceDesignRetrieveParams]. */ + class Builder internal constructor() { + + private var id: String? = null + private var version: Long? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(voiceDesignRetrieveParams: VoiceDesignRetrieveParams) = apply { + id = voiceDesignRetrieveParams.id + version = voiceDesignRetrieveParams.version + additionalHeaders = voiceDesignRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = voiceDesignRetrieveParams.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()) + + /** Specific version number to retrieve. Defaults to the latest version. */ + fun version(version: Long?) = apply { this.version = version } + + /** + * Alias for [Builder.version]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun version(version: Long) = version(version as Long?) + + /** Alias for calling [Builder.version] with `version.orElse(null)`. */ + fun version(version: Optional) = version(version.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 [VoiceDesignRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): VoiceDesignRetrieveParams = + VoiceDesignRetrieveParams( + id, + version, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> id ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + version?.let { put("version", it.toString()) } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is VoiceDesignRetrieveParams && + id == other.id && + version == other.version && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(id, version, additionalHeaders, additionalQueryParams) + + override fun toString() = + "VoiceDesignRetrieveParams{id=$id, version=$version, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/voicedesigns/VoiceDesignRetrieveResponse.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/voicedesigns/VoiceDesignRetrieveResponse.kt new file mode 100644 index 000000000..3d61e5339 --- /dev/null +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/voicedesigns/VoiceDesignRetrieveResponse.kt @@ -0,0 +1,161 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.voicedesigns + +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 com.telnyx.sdk.core.ExcludeMissing +import com.telnyx.sdk.core.JsonField +import com.telnyx.sdk.core.JsonMissing +import com.telnyx.sdk.core.JsonValue +import com.telnyx.sdk.errors.TelnyxInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Response envelope for a single voice design with full version detail. */ +class VoiceDesignRetrieveResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val data: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of() + ) : this(data, mutableMapOf()) + + /** + * A voice design object with full version detail. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun data(): Optional = data.getOptional("data") + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + @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 [VoiceDesignRetrieveResponse]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [VoiceDesignRetrieveResponse]. */ + class Builder internal constructor() { + + private var data: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(voiceDesignRetrieveResponse: VoiceDesignRetrieveResponse) = apply { + data = voiceDesignRetrieveResponse.data + additionalProperties = voiceDesignRetrieveResponse.additionalProperties.toMutableMap() + } + + /** A voice design object with full version detail. */ + fun data(data: VoiceDesignData) = data(JsonField.of(data)) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed [VoiceDesignData] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun data(data: JsonField) = apply { this.data = data } + + 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 [VoiceDesignRetrieveResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): VoiceDesignRetrieveResponse = + VoiceDesignRetrieveResponse(data, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): VoiceDesignRetrieveResponse = apply { + if (validated) { + return@apply + } + + data().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: TelnyxInvalidDataException) { + 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 = (data.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is VoiceDesignRetrieveResponse && + data == other.data && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(data, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "VoiceDesignRetrieveResponse{data=$data, additionalProperties=$additionalProperties}" +} diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/x402/creditaccount/CreditAccountCreateQuoteParams.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/x402/creditaccount/CreditAccountCreateQuoteParams.kt new file mode 100644 index 000000000..0a67b9ee4 --- /dev/null +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/x402/creditaccount/CreditAccountCreateQuoteParams.kt @@ -0,0 +1,422 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.x402.creditaccount + +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 com.telnyx.sdk.core.ExcludeMissing +import com.telnyx.sdk.core.JsonField +import com.telnyx.sdk.core.JsonMissing +import com.telnyx.sdk.core.JsonValue +import com.telnyx.sdk.core.Params +import com.telnyx.sdk.core.checkRequired +import com.telnyx.sdk.core.http.Headers +import com.telnyx.sdk.core.http.QueryParams +import com.telnyx.sdk.errors.TelnyxInvalidDataException +import java.util.Collections +import java.util.Objects + +/** + * Creates a payment quote for the specified USD amount. Returns payment details including the x402 + * payment requirements, network, and expiration time. The quote must be settled before it expires. + */ +class CreditAccountCreateQuoteParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * Amount in USD to fund (minimum 5.00, maximum 10000.00). + * + * @throws TelnyxInvalidDataException 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 amountUsd(): String = body.amountUsd() + + /** + * Returns the raw JSON value of [amountUsd]. + * + * Unlike [amountUsd], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _amountUsd(): JsonField = body._amountUsd() + + 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 + * [CreditAccountCreateQuoteParams]. + * + * The following fields are required: + * ```java + * .amountUsd() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CreditAccountCreateQuoteParams]. */ + 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(creditAccountCreateQuoteParams: CreditAccountCreateQuoteParams) = apply { + body = creditAccountCreateQuoteParams.body.toBuilder() + additionalHeaders = creditAccountCreateQuoteParams.additionalHeaders.toBuilder() + additionalQueryParams = creditAccountCreateQuoteParams.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: + * - [amountUsd] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** Amount in USD to fund (minimum 5.00, maximum 10000.00). */ + fun amountUsd(amountUsd: String) = apply { body.amountUsd(amountUsd) } + + /** + * Sets [Builder.amountUsd] to an arbitrary JSON value. + * + * You should usually call [Builder.amountUsd] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun amountUsd(amountUsd: JsonField) = apply { body.amountUsd(amountUsd) } + + 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 [CreditAccountCreateQuoteParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amountUsd() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CreditAccountCreateQuoteParams = + CreditAccountCreateQuoteParams( + 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 amountUsd: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount_usd") + @ExcludeMissing + amountUsd: JsonField = JsonMissing.of() + ) : this(amountUsd, mutableMapOf()) + + /** + * Amount in USD to fund (minimum 5.00, maximum 10000.00). + * + * @throws TelnyxInvalidDataException 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 amountUsd(): String = amountUsd.getRequired("amount_usd") + + /** + * Returns the raw JSON value of [amountUsd]. + * + * Unlike [amountUsd], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("amount_usd") @ExcludeMissing fun _amountUsd(): JsonField = amountUsd + + @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 + * .amountUsd() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var amountUsd: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + amountUsd = body.amountUsd + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** Amount in USD to fund (minimum 5.00, maximum 10000.00). */ + fun amountUsd(amountUsd: String) = amountUsd(JsonField.of(amountUsd)) + + /** + * Sets [Builder.amountUsd] to an arbitrary JSON value. + * + * You should usually call [Builder.amountUsd] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun amountUsd(amountUsd: JsonField) = apply { this.amountUsd = amountUsd } + + 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 + * .amountUsd() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body(checkRequired("amountUsd", amountUsd), additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + amountUsd() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: TelnyxInvalidDataException) { + 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 (amountUsd.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + amountUsd == other.amountUsd && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(amountUsd, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{amountUsd=$amountUsd, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CreditAccountCreateQuoteParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "CreditAccountCreateQuoteParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/x402/creditaccount/CreditAccountCreateQuoteResponse.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/x402/creditaccount/CreditAccountCreateQuoteResponse.kt new file mode 100644 index 000000000..daeda6b05 --- /dev/null +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/x402/creditaccount/CreditAccountCreateQuoteResponse.kt @@ -0,0 +1,2004 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.x402.creditaccount + +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 com.telnyx.sdk.core.Enum +import com.telnyx.sdk.core.ExcludeMissing +import com.telnyx.sdk.core.JsonField +import com.telnyx.sdk.core.JsonMissing +import com.telnyx.sdk.core.JsonValue +import com.telnyx.sdk.core.checkKnown +import com.telnyx.sdk.core.toImmutable +import com.telnyx.sdk.errors.TelnyxInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class CreditAccountCreateQuoteResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val data: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of() + ) : this(data, mutableMapOf()) + + /** + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun data(): Optional = data.getOptional("data") + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + @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 + * [CreditAccountCreateQuoteResponse]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CreditAccountCreateQuoteResponse]. */ + class Builder internal constructor() { + + private var data: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(creditAccountCreateQuoteResponse: CreditAccountCreateQuoteResponse) = + apply { + data = creditAccountCreateQuoteResponse.data + additionalProperties = + creditAccountCreateQuoteResponse.additionalProperties.toMutableMap() + } + + fun data(data: Data) = data(JsonField.of(data)) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed [Data] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun data(data: JsonField) = apply { this.data = data } + + 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 [CreditAccountCreateQuoteResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CreditAccountCreateQuoteResponse = + CreditAccountCreateQuoteResponse(data, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): CreditAccountCreateQuoteResponse = apply { + if (validated) { + return@apply + } + + data().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: TelnyxInvalidDataException) { + 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 = (data.asKnown().getOrNull()?.validity() ?: 0) + + class Data + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val amountCrypto: JsonField, + private val amountUsd: JsonField, + private val expiresAt: JsonField, + private val network: JsonField, + private val paymentRequirements: JsonField, + private val recordType: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("amount_crypto") + @ExcludeMissing + amountCrypto: JsonField = JsonMissing.of(), + @JsonProperty("amount_usd") + @ExcludeMissing + amountUsd: JsonField = JsonMissing.of(), + @JsonProperty("expires_at") + @ExcludeMissing + expiresAt: JsonField = JsonMissing.of(), + @JsonProperty("network") @ExcludeMissing network: JsonField = JsonMissing.of(), + @JsonProperty("payment_requirements") + @ExcludeMissing + paymentRequirements: JsonField = JsonMissing.of(), + @JsonProperty("record_type") + @ExcludeMissing + recordType: JsonField = JsonMissing.of(), + ) : this( + id, + amountCrypto, + amountUsd, + expiresAt, + network, + paymentRequirements, + recordType, + mutableMapOf(), + ) + + /** + * Unique quote identifier. Use this to settle the payment. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun id(): Optional = id.getOptional("id") + + /** + * The equivalent amount in the payment cryptocurrency's smallest unit (e.g. USDC has 6 + * decimals, so $50.00 = "50000000"). + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun amountCrypto(): Optional = amountCrypto.getOptional("amount_crypto") + + /** + * The quoted amount in USD. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun amountUsd(): Optional = amountUsd.getOptional("amount_usd") + + /** + * ISO 8601 timestamp when the quote expires. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun expiresAt(): Optional = expiresAt.getOptional("expires_at") + + /** + * The blockchain network for the payment in CAIP-2 format (e.g. eip155:8453 for Base). + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun network(): Optional = network.getOptional("network") + + /** + * x402 protocol v2 payment requirements. Contains all information needed to construct and + * sign a payment authorization. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun paymentRequirements(): Optional = + paymentRequirements.getOptional("payment_requirements") + + /** + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun recordType(): Optional = recordType.getOptional("record_type") + + /** + * 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 [amountCrypto]. + * + * Unlike [amountCrypto], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("amount_crypto") + @ExcludeMissing + fun _amountCrypto(): JsonField = amountCrypto + + /** + * Returns the raw JSON value of [amountUsd]. + * + * Unlike [amountUsd], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("amount_usd") @ExcludeMissing fun _amountUsd(): JsonField = amountUsd + + /** + * 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 [network]. + * + * Unlike [network], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("network") @ExcludeMissing fun _network(): JsonField = network + + /** + * Returns the raw JSON value of [paymentRequirements]. + * + * Unlike [paymentRequirements], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("payment_requirements") + @ExcludeMissing + fun _paymentRequirements(): JsonField = paymentRequirements + + /** + * Returns the raw JSON value of [recordType]. + * + * Unlike [recordType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("record_type") + @ExcludeMissing + fun _recordType(): JsonField = recordType + + @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 [Data]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Data]. */ + class Builder internal constructor() { + + private var id: JsonField = JsonMissing.of() + private var amountCrypto: JsonField = JsonMissing.of() + private var amountUsd: JsonField = JsonMissing.of() + private var expiresAt: JsonField = JsonMissing.of() + private var network: JsonField = JsonMissing.of() + private var paymentRequirements: JsonField = JsonMissing.of() + private var recordType: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(data: Data) = apply { + id = data.id + amountCrypto = data.amountCrypto + amountUsd = data.amountUsd + expiresAt = data.expiresAt + network = data.network + paymentRequirements = data.paymentRequirements + recordType = data.recordType + additionalProperties = data.additionalProperties.toMutableMap() + } + + /** Unique quote identifier. Use this to settle the payment. */ + 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 equivalent amount in the payment cryptocurrency's smallest unit (e.g. USDC has 6 + * decimals, so $50.00 = "50000000"). + */ + fun amountCrypto(amountCrypto: String) = amountCrypto(JsonField.of(amountCrypto)) + + /** + * Sets [Builder.amountCrypto] to an arbitrary JSON value. + * + * You should usually call [Builder.amountCrypto] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun amountCrypto(amountCrypto: JsonField) = apply { + this.amountCrypto = amountCrypto + } + + /** The quoted amount in USD. */ + fun amountUsd(amountUsd: String) = amountUsd(JsonField.of(amountUsd)) + + /** + * Sets [Builder.amountUsd] to an arbitrary JSON value. + * + * You should usually call [Builder.amountUsd] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun amountUsd(amountUsd: JsonField) = apply { this.amountUsd = amountUsd } + + /** ISO 8601 timestamp when the quote expires. */ + 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 blockchain network for the payment in CAIP-2 format (e.g. eip155:8453 for Base). + */ + fun network(network: String) = network(JsonField.of(network)) + + /** + * Sets [Builder.network] to an arbitrary JSON value. + * + * You should usually call [Builder.network] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun network(network: JsonField) = apply { this.network = network } + + /** + * x402 protocol v2 payment requirements. Contains all information needed to construct + * and sign a payment authorization. + */ + fun paymentRequirements(paymentRequirements: PaymentRequirements) = + paymentRequirements(JsonField.of(paymentRequirements)) + + /** + * Sets [Builder.paymentRequirements] to an arbitrary JSON value. + * + * You should usually call [Builder.paymentRequirements] with a well-typed + * [PaymentRequirements] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun paymentRequirements(paymentRequirements: JsonField) = apply { + this.paymentRequirements = paymentRequirements + } + + fun recordType(recordType: RecordType) = recordType(JsonField.of(recordType)) + + /** + * Sets [Builder.recordType] to an arbitrary JSON value. + * + * You should usually call [Builder.recordType] with a well-typed [RecordType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun recordType(recordType: JsonField) = apply { + this.recordType = recordType + } + + 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 [Data]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Data = + Data( + id, + amountCrypto, + amountUsd, + expiresAt, + network, + paymentRequirements, + recordType, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Data = apply { + if (validated) { + return@apply + } + + id() + amountCrypto() + amountUsd() + expiresAt() + network() + paymentRequirements().ifPresent { it.validate() } + recordType().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: TelnyxInvalidDataException) { + 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 (amountCrypto.asKnown().isPresent) 1 else 0) + + (if (amountUsd.asKnown().isPresent) 1 else 0) + + (if (expiresAt.asKnown().isPresent) 1 else 0) + + (if (network.asKnown().isPresent) 1 else 0) + + (paymentRequirements.asKnown().getOrNull()?.validity() ?: 0) + + (recordType.asKnown().getOrNull()?.validity() ?: 0) + + /** + * x402 protocol v2 payment requirements. Contains all information needed to construct and + * sign a payment authorization. + */ + class PaymentRequirements + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val accepts: JsonField>, + private val resource: JsonField, + private val x402Version: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("accepts") + @ExcludeMissing + accepts: JsonField> = JsonMissing.of(), + @JsonProperty("resource") + @ExcludeMissing + resource: JsonField = JsonMissing.of(), + @JsonProperty("x402Version") + @ExcludeMissing + x402Version: JsonField = JsonMissing.of(), + ) : this(accepts, resource, x402Version, mutableMapOf()) + + /** + * Accepted payment schemes. Currently only the `exact` EVM scheme is supported. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun accepts(): Optional> = accepts.getOptional("accepts") + + /** + * The resource being paid for. Included in the payment signature. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun resource(): Optional = resource.getOptional("resource") + + /** + * x402 protocol version. Currently always 2. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun x402Version(): Optional = x402Version.getOptional("x402Version") + + /** + * Returns the raw JSON value of [accepts]. + * + * Unlike [accepts], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("accepts") + @ExcludeMissing + fun _accepts(): JsonField> = accepts + + /** + * Returns the raw JSON value of [resource]. + * + * Unlike [resource], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("resource") + @ExcludeMissing + fun _resource(): JsonField = resource + + /** + * Returns the raw JSON value of [x402Version]. + * + * Unlike [x402Version], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("x402Version") + @ExcludeMissing + fun _x402Version(): JsonField = x402Version + + @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 [PaymentRequirements]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PaymentRequirements]. */ + class Builder internal constructor() { + + private var accepts: JsonField>? = null + private var resource: JsonField = JsonMissing.of() + private var x402Version: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(paymentRequirements: PaymentRequirements) = apply { + accepts = paymentRequirements.accepts.map { it.toMutableList() } + resource = paymentRequirements.resource + x402Version = paymentRequirements.x402Version + additionalProperties = paymentRequirements.additionalProperties.toMutableMap() + } + + /** Accepted payment schemes. Currently only the `exact` EVM scheme is supported. */ + fun accepts(accepts: List) = accepts(JsonField.of(accepts)) + + /** + * Sets [Builder.accepts] to an arbitrary JSON value. + * + * You should usually call [Builder.accepts] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun accepts(accepts: JsonField>) = apply { + this.accepts = accepts.map { it.toMutableList() } + } + + /** + * Adds a single [Accept] to [accepts]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAccept(accept: Accept) = apply { + accepts = + (accepts ?: JsonField.of(mutableListOf())).also { + checkKnown("accepts", it).add(accept) + } + } + + /** The resource being paid for. Included in the payment signature. */ + fun resource(resource: Resource) = resource(JsonField.of(resource)) + + /** + * Sets [Builder.resource] to an arbitrary JSON value. + * + * You should usually call [Builder.resource] with a well-typed [Resource] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun resource(resource: JsonField) = apply { this.resource = resource } + + /** x402 protocol version. Currently always 2. */ + fun x402Version(x402Version: X402Version) = x402Version(JsonField.of(x402Version)) + + /** + * Sets [Builder.x402Version] to an arbitrary JSON value. + * + * You should usually call [Builder.x402Version] with a well-typed [X402Version] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun x402Version(x402Version: JsonField) = apply { + this.x402Version = x402Version + } + + 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 [PaymentRequirements]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): PaymentRequirements = + PaymentRequirements( + (accepts ?: JsonMissing.of()).map { it.toImmutable() }, + resource, + x402Version, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PaymentRequirements = apply { + if (validated) { + return@apply + } + + accepts().ifPresent { it.forEach { it.validate() } } + resource().ifPresent { it.validate() } + x402Version().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: TelnyxInvalidDataException) { + 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 = + (accepts.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (resource.asKnown().getOrNull()?.validity() ?: 0) + + (x402Version.asKnown().getOrNull()?.validity() ?: 0) + + class Accept + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val asset: JsonField, + private val extra: JsonField, + private val maxTimeoutSeconds: JsonField, + private val network: JsonField, + private val payTo: JsonField, + private val scheme: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("asset") + @ExcludeMissing + asset: JsonField = JsonMissing.of(), + @JsonProperty("extra") + @ExcludeMissing + extra: JsonField = JsonMissing.of(), + @JsonProperty("maxTimeoutSeconds") + @ExcludeMissing + maxTimeoutSeconds: JsonField = JsonMissing.of(), + @JsonProperty("network") + @ExcludeMissing + network: JsonField = JsonMissing.of(), + @JsonProperty("payTo") + @ExcludeMissing + payTo: JsonField = JsonMissing.of(), + @JsonProperty("scheme") + @ExcludeMissing + scheme: JsonField = JsonMissing.of(), + ) : this( + amount, + asset, + extra, + maxTimeoutSeconds, + network, + payTo, + scheme, + mutableMapOf(), + ) + + /** + * Amount in the token's smallest unit. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun amount(): Optional = amount.getOptional("amount") + + /** + * Token contract address (e.g. USDC on Base). + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun asset(): Optional = asset.getOptional("asset") + + /** + * Additional scheme-specific parameters including EIP-712 domain info and the + * facilitator URL. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun extra(): Optional = extra.getOptional("extra") + + /** + * Maximum time in seconds before the payment authorization expires. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun maxTimeoutSeconds(): Optional = + maxTimeoutSeconds.getOptional("maxTimeoutSeconds") + + /** + * Blockchain network identifier in CAIP-2 format (e.g. "eip155:8453" for Base). + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun network(): Optional = network.getOptional("network") + + /** + * Recipient wallet address. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun payTo(): Optional = payTo.getOptional("payTo") + + /** + * Payment scheme (e.g. "exact"). + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun scheme(): Optional = scheme.getOptional("scheme") + + /** + * 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 [asset]. + * + * Unlike [asset], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("asset") @ExcludeMissing fun _asset(): JsonField = asset + + /** + * Returns the raw JSON value of [extra]. + * + * Unlike [extra], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("extra") @ExcludeMissing fun _extra(): JsonField = extra + + /** + * Returns the raw JSON value of [maxTimeoutSeconds]. + * + * Unlike [maxTimeoutSeconds], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("maxTimeoutSeconds") + @ExcludeMissing + fun _maxTimeoutSeconds(): JsonField = maxTimeoutSeconds + + /** + * Returns the raw JSON value of [network]. + * + * Unlike [network], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("network") @ExcludeMissing fun _network(): JsonField = network + + /** + * Returns the raw JSON value of [payTo]. + * + * Unlike [payTo], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("payTo") @ExcludeMissing fun _payTo(): JsonField = payTo + + /** + * Returns the raw JSON value of [scheme]. + * + * Unlike [scheme], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("scheme") @ExcludeMissing fun _scheme(): JsonField = scheme + + @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 [Accept]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Accept]. */ + class Builder internal constructor() { + + private var amount: JsonField = JsonMissing.of() + private var asset: JsonField = JsonMissing.of() + private var extra: JsonField = JsonMissing.of() + private var maxTimeoutSeconds: JsonField = JsonMissing.of() + private var network: JsonField = JsonMissing.of() + private var payTo: JsonField = JsonMissing.of() + private var scheme: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(accept: Accept) = apply { + amount = accept.amount + asset = accept.asset + extra = accept.extra + maxTimeoutSeconds = accept.maxTimeoutSeconds + network = accept.network + payTo = accept.payTo + scheme = accept.scheme + additionalProperties = accept.additionalProperties.toMutableMap() + } + + /** Amount in the token's smallest unit. */ + 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 } + + /** Token contract address (e.g. USDC on Base). */ + fun asset(asset: String) = asset(JsonField.of(asset)) + + /** + * Sets [Builder.asset] to an arbitrary JSON value. + * + * You should usually call [Builder.asset] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun asset(asset: JsonField) = apply { this.asset = asset } + + /** + * Additional scheme-specific parameters including EIP-712 domain info and the + * facilitator URL. + */ + fun extra(extra: Extra) = extra(JsonField.of(extra)) + + /** + * Sets [Builder.extra] to an arbitrary JSON value. + * + * You should usually call [Builder.extra] with a well-typed [Extra] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun extra(extra: JsonField) = apply { this.extra = extra } + + /** Maximum time in seconds before the payment authorization expires. */ + fun maxTimeoutSeconds(maxTimeoutSeconds: Long) = + maxTimeoutSeconds(JsonField.of(maxTimeoutSeconds)) + + /** + * Sets [Builder.maxTimeoutSeconds] to an arbitrary JSON value. + * + * You should usually call [Builder.maxTimeoutSeconds] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun maxTimeoutSeconds(maxTimeoutSeconds: JsonField) = apply { + this.maxTimeoutSeconds = maxTimeoutSeconds + } + + /** + * Blockchain network identifier in CAIP-2 format (e.g. "eip155:8453" for Base). + */ + fun network(network: String) = network(JsonField.of(network)) + + /** + * Sets [Builder.network] to an arbitrary JSON value. + * + * You should usually call [Builder.network] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun network(network: JsonField) = apply { this.network = network } + + /** Recipient wallet address. */ + fun payTo(payTo: String) = payTo(JsonField.of(payTo)) + + /** + * Sets [Builder.payTo] to an arbitrary JSON value. + * + * You should usually call [Builder.payTo] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun payTo(payTo: JsonField) = apply { this.payTo = payTo } + + /** Payment scheme (e.g. "exact"). */ + fun scheme(scheme: String) = scheme(JsonField.of(scheme)) + + /** + * Sets [Builder.scheme] to an arbitrary JSON value. + * + * You should usually call [Builder.scheme] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun scheme(scheme: JsonField) = apply { this.scheme = scheme } + + 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 [Accept]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Accept = + Accept( + amount, + asset, + extra, + maxTimeoutSeconds, + network, + payTo, + scheme, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Accept = apply { + if (validated) { + return@apply + } + + amount() + asset() + extra().ifPresent { it.validate() } + maxTimeoutSeconds() + network() + payTo() + scheme() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: TelnyxInvalidDataException) { + 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 (asset.asKnown().isPresent) 1 else 0) + + (extra.asKnown().getOrNull()?.validity() ?: 0) + + (if (maxTimeoutSeconds.asKnown().isPresent) 1 else 0) + + (if (network.asKnown().isPresent) 1 else 0) + + (if (payTo.asKnown().isPresent) 1 else 0) + + (if (scheme.asKnown().isPresent) 1 else 0) + + /** + * Additional scheme-specific parameters including EIP-712 domain info and the + * facilitator URL. + */ + class Extra + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val facilitatorUrl: JsonField, + private val name: JsonField, + private val quoteId: JsonField, + private val version: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("facilitatorUrl") + @ExcludeMissing + facilitatorUrl: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("quoteId") + @ExcludeMissing + quoteId: JsonField = JsonMissing.of(), + @JsonProperty("version") + @ExcludeMissing + version: JsonField = JsonMissing.of(), + ) : this(facilitatorUrl, name, quoteId, version, mutableMapOf()) + + /** + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun facilitatorUrl(): Optional = + facilitatorUrl.getOptional("facilitatorUrl") + + /** + * EIP-712 domain name (e.g. "USD Coin"). + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun name(): Optional = name.getOptional("name") + + /** + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun quoteId(): Optional = quoteId.getOptional("quoteId") + + /** + * EIP-712 domain version. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun version(): Optional = version.getOptional("version") + + /** + * Returns the raw JSON value of [facilitatorUrl]. + * + * Unlike [facilitatorUrl], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("facilitatorUrl") + @ExcludeMissing + fun _facilitatorUrl(): JsonField = facilitatorUrl + + /** + * 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 [quoteId]. + * + * Unlike [quoteId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("quoteId") + @ExcludeMissing + fun _quoteId(): JsonField = quoteId + + /** + * Returns the raw JSON value of [version]. + * + * Unlike [version], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("version") + @ExcludeMissing + fun _version(): JsonField = version + + @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 [Extra]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Extra]. */ + class Builder internal constructor() { + + private var facilitatorUrl: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var quoteId: JsonField = JsonMissing.of() + private var version: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(extra: Extra) = apply { + facilitatorUrl = extra.facilitatorUrl + name = extra.name + quoteId = extra.quoteId + version = extra.version + additionalProperties = extra.additionalProperties.toMutableMap() + } + + fun facilitatorUrl(facilitatorUrl: String) = + facilitatorUrl(JsonField.of(facilitatorUrl)) + + /** + * Sets [Builder.facilitatorUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.facilitatorUrl] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun facilitatorUrl(facilitatorUrl: JsonField) = apply { + this.facilitatorUrl = facilitatorUrl + } + + /** EIP-712 domain name (e.g. "USD Coin"). */ + 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 quoteId(quoteId: String) = quoteId(JsonField.of(quoteId)) + + /** + * Sets [Builder.quoteId] to an arbitrary JSON value. + * + * You should usually call [Builder.quoteId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun quoteId(quoteId: JsonField) = apply { this.quoteId = quoteId } + + /** EIP-712 domain version. */ + fun version(version: String) = version(JsonField.of(version)) + + /** + * Sets [Builder.version] to an arbitrary JSON value. + * + * You should usually call [Builder.version] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun version(version: JsonField) = apply { this.version = version } + + 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 [Extra]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Extra = + Extra( + facilitatorUrl, + name, + quoteId, + version, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Extra = apply { + if (validated) { + return@apply + } + + facilitatorUrl() + name() + quoteId() + version() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: TelnyxInvalidDataException) { + 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 (facilitatorUrl.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (quoteId.asKnown().isPresent) 1 else 0) + + (if (version.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Extra && + facilitatorUrl == other.facilitatorUrl && + name == other.name && + quoteId == other.quoteId && + version == other.version && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(facilitatorUrl, name, quoteId, version, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Extra{facilitatorUrl=$facilitatorUrl, name=$name, quoteId=$quoteId, version=$version, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Accept && + amount == other.amount && + asset == other.asset && + extra == other.extra && + maxTimeoutSeconds == other.maxTimeoutSeconds && + network == other.network && + payTo == other.payTo && + scheme == other.scheme && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + amount, + asset, + extra, + maxTimeoutSeconds, + network, + payTo, + scheme, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Accept{amount=$amount, asset=$asset, extra=$extra, maxTimeoutSeconds=$maxTimeoutSeconds, network=$network, payTo=$payTo, scheme=$scheme, additionalProperties=$additionalProperties}" + } + + /** The resource being paid for. Included in the payment signature. */ + class Resource + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val description: JsonField, + private val mimeType: JsonField, + private val url: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + @JsonProperty("mimeType") + @ExcludeMissing + mimeType: JsonField = JsonMissing.of(), + @JsonProperty("url") @ExcludeMissing url: JsonField = JsonMissing.of(), + ) : this(description, mimeType, url, mutableMapOf()) + + /** + * Human-readable description of the payment. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun description(): Optional = description.getOptional("description") + + /** + * MIME type of the resource. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun mimeType(): Optional = mimeType.getOptional("mimeType") + + /** + * Canonical URL of the payment resource. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun url(): Optional = url.getOptional("url") + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description + + /** + * Returns the raw JSON value of [mimeType]. + * + * Unlike [mimeType], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("mimeType") + @ExcludeMissing + fun _mimeType(): JsonField = mimeType + + /** + * Returns the raw JSON value of [url]. + * + * Unlike [url], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url + + @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 [Resource]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Resource]. */ + class Builder internal constructor() { + + private var description: JsonField = JsonMissing.of() + private var mimeType: JsonField = JsonMissing.of() + private var url: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(resource: Resource) = apply { + description = resource.description + mimeType = resource.mimeType + url = resource.url + additionalProperties = resource.additionalProperties.toMutableMap() + } + + /** Human-readable description of the payment. */ + fun description(description: String) = description(JsonField.of(description)) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun description(description: JsonField) = apply { + this.description = description + } + + /** MIME type of the resource. */ + fun mimeType(mimeType: String) = mimeType(JsonField.of(mimeType)) + + /** + * Sets [Builder.mimeType] to an arbitrary JSON value. + * + * You should usually call [Builder.mimeType] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun mimeType(mimeType: JsonField) = apply { this.mimeType = mimeType } + + /** Canonical URL of the payment resource. */ + fun url(url: String) = url(JsonField.of(url)) + + /** + * Sets [Builder.url] to an arbitrary JSON value. + * + * You should usually call [Builder.url] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun url(url: JsonField) = apply { this.url = url } + + 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 [Resource]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Resource = + Resource(description, mimeType, url, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Resource = apply { + if (validated) { + return@apply + } + + description() + mimeType() + url() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: TelnyxInvalidDataException) { + 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 (description.asKnown().isPresent) 1 else 0) + + (if (mimeType.asKnown().isPresent) 1 else 0) + + (if (url.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Resource && + description == other.description && + mimeType == other.mimeType && + url == other.url && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(description, mimeType, url, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Resource{description=$description, mimeType=$mimeType, url=$url, additionalProperties=$additionalProperties}" + } + + /** x402 protocol version. Currently always 2. */ + class X402Version @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 V2 = of(2L) + + @JvmStatic fun of(value: Long) = X402Version(JsonField.of(value)) + } + + /** An enum containing [X402Version]'s known values. */ + enum class Known { + V2 + } + + /** + * An enum containing [X402Version]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [X402Version] 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 { + V2, + /** + * An enum member indicating that [X402Version] 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) { + V2 -> Value.V2 + 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 TelnyxInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + V2 -> Known.V2 + else -> throw TelnyxInvalidDataException("Unknown X402Version: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * @throws TelnyxInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asLong(): Long = + _value().asNumber().getOrNull()?.let { + if (it.toDouble() % 1 == 0.0) it.toLong() else null + } ?: throw TelnyxInvalidDataException("Value is not a Long") + + private var validated: Boolean = false + + fun validate(): X402Version = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: TelnyxInvalidDataException) { + 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 X402Version && 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 PaymentRequirements && + accepts == other.accepts && + resource == other.resource && + x402Version == other.x402Version && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(accepts, resource, x402Version, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PaymentRequirements{accepts=$accepts, resource=$resource, x402Version=$x402Version, additionalProperties=$additionalProperties}" + } + + class RecordType @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 QUOTE = of("quote") + + @JvmStatic fun of(value: String) = RecordType(JsonField.of(value)) + } + + /** An enum containing [RecordType]'s known values. */ + enum class Known { + QUOTE + } + + /** + * An enum containing [RecordType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [RecordType] 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 { + QUOTE, + /** + * An enum member indicating that [RecordType] 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) { + QUOTE -> Value.QUOTE + 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 TelnyxInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + QUOTE -> Known.QUOTE + else -> throw TelnyxInvalidDataException("Unknown RecordType: $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 TelnyxInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + TelnyxInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): RecordType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: TelnyxInvalidDataException) { + 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 RecordType && 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 Data && + id == other.id && + amountCrypto == other.amountCrypto && + amountUsd == other.amountUsd && + expiresAt == other.expiresAt && + network == other.network && + paymentRequirements == other.paymentRequirements && + recordType == other.recordType && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + amountCrypto, + amountUsd, + expiresAt, + network, + paymentRequirements, + recordType, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Data{id=$id, amountCrypto=$amountCrypto, amountUsd=$amountUsd, expiresAt=$expiresAt, network=$network, paymentRequirements=$paymentRequirements, recordType=$recordType, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CreditAccountCreateQuoteResponse && + data == other.data && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(data, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CreditAccountCreateQuoteResponse{data=$data, additionalProperties=$additionalProperties}" +} diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/x402/creditaccount/CreditAccountSettleParams.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/x402/creditaccount/CreditAccountSettleParams.kt new file mode 100644 index 000000000..e09fca8af --- /dev/null +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/x402/creditaccount/CreditAccountSettleParams.kt @@ -0,0 +1,534 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.x402.creditaccount + +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 com.telnyx.sdk.core.ExcludeMissing +import com.telnyx.sdk.core.JsonField +import com.telnyx.sdk.core.JsonMissing +import com.telnyx.sdk.core.JsonValue +import com.telnyx.sdk.core.Params +import com.telnyx.sdk.core.checkRequired +import com.telnyx.sdk.core.http.Headers +import com.telnyx.sdk.core.http.QueryParams +import com.telnyx.sdk.errors.TelnyxInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Settles an x402 payment using the quote ID and a signed payment authorization. The payment + * signature can be provided via the `PAYMENT-SIGNATURE` header or the `payment_signature` body + * parameter. Settlement is idempotent — submitting the same quote ID multiple times returns the + * existing transaction. + */ +class CreditAccountSettleParams +private constructor( + private val paymentSignatureHeader: String?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun paymentSignatureHeader(): Optional = Optional.ofNullable(paymentSignatureHeader) + + /** + * The quote ID to settle. + * + * @throws TelnyxInvalidDataException 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 = body.id() + + /** + * Base64-encoded signed payment authorization (x402 PaymentPayload). Can alternatively be + * provided via the PAYMENT-SIGNATURE header. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun paymentSignature(): Optional = body.paymentSignature() + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _id(): JsonField = body._id() + + /** + * Returns the raw JSON value of [paymentSignature]. + * + * Unlike [paymentSignature], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _paymentSignature(): JsonField = body._paymentSignature() + + 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 [CreditAccountSettleParams]. + * + * The following fields are required: + * ```java + * .id() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CreditAccountSettleParams]. */ + class Builder internal constructor() { + + private var paymentSignatureHeader: 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(creditAccountSettleParams: CreditAccountSettleParams) = apply { + paymentSignatureHeader = creditAccountSettleParams.paymentSignatureHeader + body = creditAccountSettleParams.body.toBuilder() + additionalHeaders = creditAccountSettleParams.additionalHeaders.toBuilder() + additionalQueryParams = creditAccountSettleParams.additionalQueryParams.toBuilder() + } + + fun paymentSignatureHeader(paymentSignatureHeader: String?) = apply { + this.paymentSignatureHeader = paymentSignatureHeader + } + + /** + * Alias for calling [Builder.paymentSignatureHeader] with + * `paymentSignatureHeader.orElse(null)`. + */ + fun paymentSignatureHeader(paymentSignatureHeader: Optional) = + paymentSignatureHeader(paymentSignatureHeader.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: + * - [id] + * - [paymentSignature] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** The quote ID to settle. */ + fun id(id: String) = apply { body.id(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 { body.id(id) } + + /** + * Base64-encoded signed payment authorization (x402 PaymentPayload). Can alternatively be + * provided via the PAYMENT-SIGNATURE header. + */ + fun paymentSignature(paymentSignature: String) = apply { + body.paymentSignature(paymentSignature) + } + + /** + * Sets [Builder.paymentSignature] to an arbitrary JSON value. + * + * You should usually call [Builder.paymentSignature] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun paymentSignature(paymentSignature: JsonField) = apply { + body.paymentSignature(paymentSignature) + } + + 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 [CreditAccountSettleParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CreditAccountSettleParams = + CreditAccountSettleParams( + paymentSignatureHeader, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = + Headers.builder() + .apply { + paymentSignatureHeader?.let { put("PAYMENT-SIGNATURE", it) } + putAll(additionalHeaders) + } + .build() + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val paymentSignature: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("payment_signature") + @ExcludeMissing + paymentSignature: JsonField = JsonMissing.of(), + ) : this(id, paymentSignature, mutableMapOf()) + + /** + * The quote ID to settle. + * + * @throws TelnyxInvalidDataException 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") + + /** + * Base64-encoded signed payment authorization (x402 PaymentPayload). Can alternatively be + * provided via the PAYMENT-SIGNATURE header. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun paymentSignature(): Optional = paymentSignature.getOptional("payment_signature") + + /** + * 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 [paymentSignature]. + * + * Unlike [paymentSignature], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("payment_signature") + @ExcludeMissing + fun _paymentSignature(): JsonField = paymentSignature + + @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 + * .id() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var paymentSignature: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + id = body.id + paymentSignature = body.paymentSignature + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** The quote ID to settle. */ + 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 } + + /** + * Base64-encoded signed payment authorization (x402 PaymentPayload). Can alternatively + * be provided via the PAYMENT-SIGNATURE header. + */ + fun paymentSignature(paymentSignature: String) = + paymentSignature(JsonField.of(paymentSignature)) + + /** + * Sets [Builder.paymentSignature] to an arbitrary JSON value. + * + * You should usually call [Builder.paymentSignature] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun paymentSignature(paymentSignature: JsonField) = apply { + this.paymentSignature = paymentSignature + } + + 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 + * .id() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body(checkRequired("id", id), paymentSignature, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + id() + paymentSignature() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: TelnyxInvalidDataException) { + 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 (paymentSignature.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + id == other.id && + paymentSignature == other.paymentSignature && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, paymentSignature, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{id=$id, paymentSignature=$paymentSignature, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CreditAccountSettleParams && + paymentSignatureHeader == other.paymentSignatureHeader && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(paymentSignatureHeader, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "CreditAccountSettleParams{paymentSignatureHeader=$paymentSignatureHeader, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/x402/creditaccount/CreditAccountSettleResponse.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/x402/creditaccount/CreditAccountSettleResponse.kt new file mode 100644 index 000000000..782142218 --- /dev/null +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/x402/creditaccount/CreditAccountSettleResponse.kt @@ -0,0 +1,835 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.x402.creditaccount + +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 com.telnyx.sdk.core.Enum +import com.telnyx.sdk.core.ExcludeMissing +import com.telnyx.sdk.core.JsonField +import com.telnyx.sdk.core.JsonMissing +import com.telnyx.sdk.core.JsonValue +import com.telnyx.sdk.errors.TelnyxInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class CreditAccountSettleResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val data: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of() + ) : this(data, mutableMapOf()) + + /** + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun data(): Optional = data.getOptional("data") + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + @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 [CreditAccountSettleResponse]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CreditAccountSettleResponse]. */ + class Builder internal constructor() { + + private var data: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(creditAccountSettleResponse: CreditAccountSettleResponse) = apply { + data = creditAccountSettleResponse.data + additionalProperties = creditAccountSettleResponse.additionalProperties.toMutableMap() + } + + fun data(data: Data) = data(JsonField.of(data)) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed [Data] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun data(data: JsonField) = apply { this.data = data } + + 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 [CreditAccountSettleResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CreditAccountSettleResponse = + CreditAccountSettleResponse(data, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): CreditAccountSettleResponse = apply { + if (validated) { + return@apply + } + + data().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: TelnyxInvalidDataException) { + 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 = (data.asKnown().getOrNull()?.validity() ?: 0) + + class Data + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val amount: JsonField, + private val createdAt: JsonField, + private val currency: JsonField, + private val quoteId: JsonField, + private val recordType: JsonField, + private val status: JsonField, + private val txHash: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("quote_id") @ExcludeMissing quoteId: JsonField = JsonMissing.of(), + @JsonProperty("record_type") + @ExcludeMissing + recordType: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + @JsonProperty("tx_hash") @ExcludeMissing txHash: JsonField = JsonMissing.of(), + ) : this( + id, + amount, + createdAt, + currency, + quoteId, + recordType, + status, + txHash, + mutableMapOf(), + ) + + /** + * Unique transaction identifier. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun id(): Optional = id.getOptional("id") + + /** + * The transaction amount in the specified currency. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun amount(): Optional = amount.getOptional("amount") + + /** + * ISO 8601 timestamp when the transaction was created. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun createdAt(): Optional = createdAt.getOptional("created_at") + + /** + * The currency of the transaction amount (e.g. USD). + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * The original quote ID associated with this transaction. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun quoteId(): Optional = quoteId.getOptional("quote_id") + + /** + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun recordType(): Optional = recordType.getOptional("record_type") + + /** + * The settlement status of the transaction. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun status(): Optional = status.getOptional("status") + + /** + * The on-chain transaction hash, if available. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun txHash(): Optional = txHash.getOptional("tx_hash") + + /** + * 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 [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 [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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [quoteId]. + * + * Unlike [quoteId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("quote_id") @ExcludeMissing fun _quoteId(): JsonField = quoteId + + /** + * Returns the raw JSON value of [recordType]. + * + * Unlike [recordType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("record_type") + @ExcludeMissing + fun _recordType(): JsonField = recordType + + /** + * 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 [txHash]. + * + * Unlike [txHash], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tx_hash") @ExcludeMissing fun _txHash(): JsonField = txHash + + @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 [Data]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Data]. */ + class Builder internal constructor() { + + private var id: JsonField = JsonMissing.of() + private var amount: JsonField = JsonMissing.of() + private var createdAt: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var quoteId: JsonField = JsonMissing.of() + private var recordType: JsonField = JsonMissing.of() + private var status: JsonField = JsonMissing.of() + private var txHash: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(data: Data) = apply { + id = data.id + amount = data.amount + createdAt = data.createdAt + currency = data.currency + quoteId = data.quoteId + recordType = data.recordType + status = data.status + txHash = data.txHash + additionalProperties = data.additionalProperties.toMutableMap() + } + + /** Unique transaction 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 transaction amount in the specified currency. */ + 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 8601 timestamp when the transaction was created. */ + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField) = apply { + this.createdAt = createdAt + } + + /** The currency of the transaction amount (e.g. USD). */ + 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 } + + /** The original quote ID associated with this transaction. */ + fun quoteId(quoteId: String) = quoteId(JsonField.of(quoteId)) + + /** + * Sets [Builder.quoteId] to an arbitrary JSON value. + * + * You should usually call [Builder.quoteId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun quoteId(quoteId: JsonField) = apply { this.quoteId = quoteId } + + fun recordType(recordType: RecordType) = recordType(JsonField.of(recordType)) + + /** + * Sets [Builder.recordType] to an arbitrary JSON value. + * + * You should usually call [Builder.recordType] with a well-typed [RecordType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun recordType(recordType: JsonField) = apply { + this.recordType = recordType + } + + /** The settlement status of the transaction. */ + 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 } + + /** The on-chain transaction hash, if available. */ + fun txHash(txHash: String?) = txHash(JsonField.ofNullable(txHash)) + + /** Alias for calling [Builder.txHash] with `txHash.orElse(null)`. */ + fun txHash(txHash: Optional) = txHash(txHash.getOrNull()) + + /** + * Sets [Builder.txHash] to an arbitrary JSON value. + * + * You should usually call [Builder.txHash] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun txHash(txHash: JsonField) = apply { this.txHash = txHash } + + 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 [Data]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Data = + Data( + id, + amount, + createdAt, + currency, + quoteId, + recordType, + status, + txHash, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Data = apply { + if (validated) { + return@apply + } + + id() + amount() + createdAt() + currency() + quoteId() + recordType().ifPresent { it.validate() } + status().ifPresent { it.validate() } + txHash() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: TelnyxInvalidDataException) { + 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 (amount.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (quoteId.asKnown().isPresent) 1 else 0) + + (recordType.asKnown().getOrNull()?.validity() ?: 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (if (txHash.asKnown().isPresent) 1 else 0) + + class RecordType @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 X402_TRANSACTION = of("x402_transaction") + + @JvmStatic fun of(value: String) = RecordType(JsonField.of(value)) + } + + /** An enum containing [RecordType]'s known values. */ + enum class Known { + X402_TRANSACTION + } + + /** + * An enum containing [RecordType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [RecordType] 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 { + X402_TRANSACTION, + /** + * An enum member indicating that [RecordType] 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) { + X402_TRANSACTION -> Value.X402_TRANSACTION + 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 TelnyxInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + X402_TRANSACTION -> Known.X402_TRANSACTION + else -> throw TelnyxInvalidDataException("Unknown RecordType: $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 TelnyxInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + TelnyxInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): RecordType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: TelnyxInvalidDataException) { + 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 RecordType && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** The settlement status of the transaction. */ + 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 SETTLED = of("settled") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + SETTLED + } + + /** + * 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 { + SETTLED, + /** + * 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) { + SETTLED -> Value.SETTLED + 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 TelnyxInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + SETTLED -> Known.SETTLED + else -> throw TelnyxInvalidDataException("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 TelnyxInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + TelnyxInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: TelnyxInvalidDataException) { + 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 Data && + id == other.id && + amount == other.amount && + createdAt == other.createdAt && + currency == other.currency && + quoteId == other.quoteId && + recordType == other.recordType && + status == other.status && + txHash == other.txHash && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + amount, + createdAt, + currency, + quoteId, + recordType, + status, + txHash, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Data{id=$id, amount=$amount, createdAt=$createdAt, currency=$currency, quoteId=$quoteId, recordType=$recordType, status=$status, txHash=$txHash, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CreditAccountSettleResponse && + data == other.data && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(data, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CreditAccountSettleResponse{data=$data, additionalProperties=$additionalProperties}" +} diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/async/RecordingTranscriptionServiceAsync.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/async/RecordingTranscriptionServiceAsync.kt index dc74f54af..5a688a833 100644 --- a/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/async/RecordingTranscriptionServiceAsync.kt +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/async/RecordingTranscriptionServiceAsync.kt @@ -7,8 +7,8 @@ import com.telnyx.sdk.core.RequestOptions import com.telnyx.sdk.core.http.HttpResponseFor import com.telnyx.sdk.models.recordingtranscriptions.RecordingTranscriptionDeleteParams import com.telnyx.sdk.models.recordingtranscriptions.RecordingTranscriptionDeleteResponse +import com.telnyx.sdk.models.recordingtranscriptions.RecordingTranscriptionListPageAsync import com.telnyx.sdk.models.recordingtranscriptions.RecordingTranscriptionListParams -import com.telnyx.sdk.models.recordingtranscriptions.RecordingTranscriptionListResponse import com.telnyx.sdk.models.recordingtranscriptions.RecordingTranscriptionRetrieveParams import com.telnyx.sdk.models.recordingtranscriptions.RecordingTranscriptionRetrieveResponse import java.util.concurrent.CompletableFuture @@ -77,24 +77,24 @@ interface RecordingTranscriptionServiceAsync { ) /** Returns a list of your recording transcriptions. */ - fun list(): CompletableFuture = + fun list(): CompletableFuture = list(RecordingTranscriptionListParams.none()) /** @see list */ fun list( params: RecordingTranscriptionListParams = RecordingTranscriptionListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** @see list */ fun list( params: RecordingTranscriptionListParams = RecordingTranscriptionListParams.none() - ): CompletableFuture = list(params, RequestOptions.none()) + ): CompletableFuture = list(params, RequestOptions.none()) /** @see list */ fun list( requestOptions: RequestOptions - ): CompletableFuture = + ): CompletableFuture = list(RecordingTranscriptionListParams.none(), requestOptions) /** Permanently deletes a recording transcription. */ @@ -212,25 +212,25 @@ interface RecordingTranscriptionServiceAsync { * Returns a raw HTTP response for `get /recording_transcriptions`, but is otherwise the * same as [RecordingTranscriptionServiceAsync.list]. */ - fun list(): CompletableFuture> = + fun list(): CompletableFuture> = list(RecordingTranscriptionListParams.none()) /** @see list */ fun list( params: RecordingTranscriptionListParams = RecordingTranscriptionListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + ): CompletableFuture> /** @see list */ fun list( params: RecordingTranscriptionListParams = RecordingTranscriptionListParams.none() - ): CompletableFuture> = + ): CompletableFuture> = list(params, RequestOptions.none()) /** @see list */ fun list( requestOptions: RequestOptions - ): CompletableFuture> = + ): CompletableFuture> = list(RecordingTranscriptionListParams.none(), requestOptions) /** diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/async/RecordingTranscriptionServiceAsyncImpl.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/async/RecordingTranscriptionServiceAsyncImpl.kt index 0bf9b8501..e3703df9e 100644 --- a/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/async/RecordingTranscriptionServiceAsyncImpl.kt +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/async/RecordingTranscriptionServiceAsyncImpl.kt @@ -18,8 +18,9 @@ import com.telnyx.sdk.core.http.parseable import com.telnyx.sdk.core.prepareAsync import com.telnyx.sdk.models.recordingtranscriptions.RecordingTranscriptionDeleteParams import com.telnyx.sdk.models.recordingtranscriptions.RecordingTranscriptionDeleteResponse +import com.telnyx.sdk.models.recordingtranscriptions.RecordingTranscriptionListPageAsync +import com.telnyx.sdk.models.recordingtranscriptions.RecordingTranscriptionListPageResponse import com.telnyx.sdk.models.recordingtranscriptions.RecordingTranscriptionListParams -import com.telnyx.sdk.models.recordingtranscriptions.RecordingTranscriptionListResponse import com.telnyx.sdk.models.recordingtranscriptions.RecordingTranscriptionRetrieveParams import com.telnyx.sdk.models.recordingtranscriptions.RecordingTranscriptionRetrieveResponse import java.util.concurrent.CompletableFuture @@ -55,7 +56,7 @@ internal constructor(private val clientOptions: ClientOptions) : override fun list( params: RecordingTranscriptionListParams, requestOptions: RequestOptions, - ): CompletableFuture = + ): CompletableFuture = // get /recording_transcriptions withRawResponse().list(params, requestOptions).thenApply { it.parse() } @@ -112,13 +113,13 @@ internal constructor(private val clientOptions: ClientOptions) : } } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) override fun list( params: RecordingTranscriptionListParams, requestOptions: RequestOptions, - ): CompletableFuture> { + ): CompletableFuture> { val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -138,6 +139,14 @@ internal constructor(private val clientOptions: ClientOptions) : it.validate() } } + .let { + RecordingTranscriptionListPageAsync.builder() + .service(RecordingTranscriptionServiceAsyncImpl(clientOptions)) + .streamHandlerExecutor(clientOptions.streamHandlerExecutor) + .params(params) + .response(it) + .build() + } } } } diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/async/VoiceCloneServiceAsync.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/async/VoiceCloneServiceAsync.kt new file mode 100644 index 000000000..71a2245d8 --- /dev/null +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/async/VoiceCloneServiceAsync.kt @@ -0,0 +1,347 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.services.async + +import com.telnyx.sdk.core.ClientOptions +import com.telnyx.sdk.core.RequestOptions +import com.telnyx.sdk.core.http.HttpResponse +import com.telnyx.sdk.core.http.HttpResponseFor +import com.telnyx.sdk.models.voiceclones.VoiceCloneCreateFromUploadParams +import com.telnyx.sdk.models.voiceclones.VoiceCloneCreateFromUploadResponse +import com.telnyx.sdk.models.voiceclones.VoiceCloneCreateParams +import com.telnyx.sdk.models.voiceclones.VoiceCloneCreateResponse +import com.telnyx.sdk.models.voiceclones.VoiceCloneDeleteParams +import com.telnyx.sdk.models.voiceclones.VoiceCloneDownloadSampleParams +import com.telnyx.sdk.models.voiceclones.VoiceCloneListPageAsync +import com.telnyx.sdk.models.voiceclones.VoiceCloneListParams +import com.telnyx.sdk.models.voiceclones.VoiceCloneUpdateParams +import com.telnyx.sdk.models.voiceclones.VoiceCloneUpdateResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +/** Capture and manage voice identities as clones for use in text-to-speech synthesis. */ +interface VoiceCloneServiceAsync { + + /** + * 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): VoiceCloneServiceAsync + + /** + * Creates a new voice clone by capturing the voice identity of an existing voice design. The + * clone can then be used for text-to-speech synthesis. + */ + fun create(params: VoiceCloneCreateParams): CompletableFuture = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: VoiceCloneCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** Updates the name, language, or gender of a voice clone. */ + fun update( + id: String, + params: VoiceCloneUpdateParams, + ): CompletableFuture = update(id, params, RequestOptions.none()) + + /** @see update */ + fun update( + id: String, + params: VoiceCloneUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + update(params.toBuilder().id(id).build(), requestOptions) + + /** @see update */ + fun update(params: VoiceCloneUpdateParams): CompletableFuture = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: VoiceCloneUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** Returns a paginated list of voice clones belonging to the authenticated account. */ + fun list(): CompletableFuture = list(VoiceCloneListParams.none()) + + /** @see list */ + fun list( + params: VoiceCloneListParams = VoiceCloneListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see list */ + fun list( + params: VoiceCloneListParams = VoiceCloneListParams.none() + ): CompletableFuture = list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): CompletableFuture = + list(VoiceCloneListParams.none(), requestOptions) + + /** Permanently deletes a voice clone. This action cannot be undone. */ + fun delete(id: String): CompletableFuture = delete(id, VoiceCloneDeleteParams.none()) + + /** @see delete */ + fun delete( + id: String, + params: VoiceCloneDeleteParams = VoiceCloneDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = delete(params.toBuilder().id(id).build(), requestOptions) + + /** @see delete */ + fun delete( + id: String, + params: VoiceCloneDeleteParams = VoiceCloneDeleteParams.none(), + ): CompletableFuture = delete(id, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: VoiceCloneDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see delete */ + fun delete(params: VoiceCloneDeleteParams): CompletableFuture = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete(id: String, requestOptions: RequestOptions): CompletableFuture = + delete(id, VoiceCloneDeleteParams.none(), requestOptions) + + /** + * Creates a new voice clone by uploading an audio file directly. Supported formats: WAV, MP3, + * FLAC, OGG, M4A. For best results, provide 5–10 seconds of clear speech. Maximum file size: + * 2MB. + */ + fun createFromUpload( + params: VoiceCloneCreateFromUploadParams + ): CompletableFuture = + createFromUpload(params, RequestOptions.none()) + + /** @see createFromUpload */ + fun createFromUpload( + params: VoiceCloneCreateFromUploadParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** Downloads the WAV audio sample that was used to create the voice clone. */ + fun downloadSample(id: String): CompletableFuture = + downloadSample(id, VoiceCloneDownloadSampleParams.none()) + + /** @see downloadSample */ + fun downloadSample( + id: String, + params: VoiceCloneDownloadSampleParams = VoiceCloneDownloadSampleParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + downloadSample(params.toBuilder().id(id).build(), requestOptions) + + /** @see downloadSample */ + fun downloadSample( + id: String, + params: VoiceCloneDownloadSampleParams = VoiceCloneDownloadSampleParams.none(), + ): CompletableFuture = downloadSample(id, params, RequestOptions.none()) + + /** @see downloadSample */ + fun downloadSample( + params: VoiceCloneDownloadSampleParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see downloadSample */ + fun downloadSample(params: VoiceCloneDownloadSampleParams): CompletableFuture = + downloadSample(params, RequestOptions.none()) + + /** @see downloadSample */ + fun downloadSample( + id: String, + requestOptions: RequestOptions, + ): CompletableFuture = + downloadSample(id, VoiceCloneDownloadSampleParams.none(), requestOptions) + + /** + * A view of [VoiceCloneServiceAsync] 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 + ): VoiceCloneServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /voice_clones`, but is otherwise the same as + * [VoiceCloneServiceAsync.create]. + */ + fun create( + params: VoiceCloneCreateParams + ): CompletableFuture> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: VoiceCloneCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `patch /voice_clones/{id}`, but is otherwise the same as + * [VoiceCloneServiceAsync.update]. + */ + fun update( + id: String, + params: VoiceCloneUpdateParams, + ): CompletableFuture> = + update(id, params, RequestOptions.none()) + + /** @see update */ + fun update( + id: String, + params: VoiceCloneUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + update(params.toBuilder().id(id).build(), requestOptions) + + /** @see update */ + fun update( + params: VoiceCloneUpdateParams + ): CompletableFuture> = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: VoiceCloneUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /voice_clones`, but is otherwise the same as + * [VoiceCloneServiceAsync.list]. + */ + fun list(): CompletableFuture> = + list(VoiceCloneListParams.none()) + + /** @see list */ + fun list( + params: VoiceCloneListParams = VoiceCloneListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see list */ + fun list( + params: VoiceCloneListParams = VoiceCloneListParams.none() + ): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + requestOptions: RequestOptions + ): CompletableFuture> = + list(VoiceCloneListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /voice_clones/{id}`, but is otherwise the same as + * [VoiceCloneServiceAsync.delete]. + */ + fun delete(id: String): CompletableFuture = + delete(id, VoiceCloneDeleteParams.none()) + + /** @see delete */ + fun delete( + id: String, + params: VoiceCloneDeleteParams = VoiceCloneDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + delete(params.toBuilder().id(id).build(), requestOptions) + + /** @see delete */ + fun delete( + id: String, + params: VoiceCloneDeleteParams = VoiceCloneDeleteParams.none(), + ): CompletableFuture = delete(id, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: VoiceCloneDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see delete */ + fun delete(params: VoiceCloneDeleteParams): CompletableFuture = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete(id: String, requestOptions: RequestOptions): CompletableFuture = + delete(id, VoiceCloneDeleteParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /voice_clones/from_upload`, but is otherwise the + * same as [VoiceCloneServiceAsync.createFromUpload]. + */ + fun createFromUpload( + params: VoiceCloneCreateFromUploadParams + ): CompletableFuture> = + createFromUpload(params, RequestOptions.none()) + + /** @see createFromUpload */ + fun createFromUpload( + params: VoiceCloneCreateFromUploadParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /voice_clones/{id}/sample`, but is otherwise the + * same as [VoiceCloneServiceAsync.downloadSample]. + */ + fun downloadSample(id: String): CompletableFuture = + downloadSample(id, VoiceCloneDownloadSampleParams.none()) + + /** @see downloadSample */ + fun downloadSample( + id: String, + params: VoiceCloneDownloadSampleParams = VoiceCloneDownloadSampleParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + downloadSample(params.toBuilder().id(id).build(), requestOptions) + + /** @see downloadSample */ + fun downloadSample( + id: String, + params: VoiceCloneDownloadSampleParams = VoiceCloneDownloadSampleParams.none(), + ): CompletableFuture = downloadSample(id, params, RequestOptions.none()) + + /** @see downloadSample */ + fun downloadSample( + params: VoiceCloneDownloadSampleParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see downloadSample */ + fun downloadSample( + params: VoiceCloneDownloadSampleParams + ): CompletableFuture = downloadSample(params, RequestOptions.none()) + + /** @see downloadSample */ + fun downloadSample( + id: String, + requestOptions: RequestOptions, + ): CompletableFuture = + downloadSample(id, VoiceCloneDownloadSampleParams.none(), requestOptions) + } +} diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/async/VoiceCloneServiceAsyncImpl.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/async/VoiceCloneServiceAsyncImpl.kt new file mode 100644 index 000000000..27afdfd77 --- /dev/null +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/async/VoiceCloneServiceAsyncImpl.kt @@ -0,0 +1,286 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.services.async + +import com.telnyx.sdk.core.ClientOptions +import com.telnyx.sdk.core.RequestOptions +import com.telnyx.sdk.core.checkRequired +import com.telnyx.sdk.core.handlers.emptyHandler +import com.telnyx.sdk.core.handlers.errorBodyHandler +import com.telnyx.sdk.core.handlers.errorHandler +import com.telnyx.sdk.core.handlers.jsonHandler +import com.telnyx.sdk.core.http.HttpMethod +import com.telnyx.sdk.core.http.HttpRequest +import com.telnyx.sdk.core.http.HttpResponse +import com.telnyx.sdk.core.http.HttpResponse.Handler +import com.telnyx.sdk.core.http.HttpResponseFor +import com.telnyx.sdk.core.http.json +import com.telnyx.sdk.core.http.multipartFormData +import com.telnyx.sdk.core.http.parseable +import com.telnyx.sdk.core.prepareAsync +import com.telnyx.sdk.models.voiceclones.VoiceCloneCreateFromUploadParams +import com.telnyx.sdk.models.voiceclones.VoiceCloneCreateFromUploadResponse +import com.telnyx.sdk.models.voiceclones.VoiceCloneCreateParams +import com.telnyx.sdk.models.voiceclones.VoiceCloneCreateResponse +import com.telnyx.sdk.models.voiceclones.VoiceCloneDeleteParams +import com.telnyx.sdk.models.voiceclones.VoiceCloneDownloadSampleParams +import com.telnyx.sdk.models.voiceclones.VoiceCloneListPageAsync +import com.telnyx.sdk.models.voiceclones.VoiceCloneListPageResponse +import com.telnyx.sdk.models.voiceclones.VoiceCloneListParams +import com.telnyx.sdk.models.voiceclones.VoiceCloneUpdateParams +import com.telnyx.sdk.models.voiceclones.VoiceCloneUpdateResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +/** Capture and manage voice identities as clones for use in text-to-speech synthesis. */ +class VoiceCloneServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + VoiceCloneServiceAsync { + + private val withRawResponse: VoiceCloneServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): VoiceCloneServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): VoiceCloneServiceAsync = + VoiceCloneServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: VoiceCloneCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /voice_clones + withRawResponse().create(params, requestOptions).thenApply { it.parse() } + + override fun update( + params: VoiceCloneUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // patch /voice_clones/{id} + withRawResponse().update(params, requestOptions).thenApply { it.parse() } + + override fun list( + params: VoiceCloneListParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /voice_clones + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + override fun delete( + params: VoiceCloneDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // delete /voice_clones/{id} + withRawResponse().delete(params, requestOptions).thenAccept {} + + override fun createFromUpload( + params: VoiceCloneCreateFromUploadParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /voice_clones/from_upload + withRawResponse().createFromUpload(params, requestOptions).thenApply { it.parse() } + + override fun downloadSample( + params: VoiceCloneDownloadSampleParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /voice_clones/{id}/sample + withRawResponse().downloadSample(params, requestOptions) + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + VoiceCloneServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): VoiceCloneServiceAsync.WithRawResponse = + VoiceCloneServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun create( + params: VoiceCloneCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("voice_clones") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun update( + params: VoiceCloneUpdateParams, + 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.PATCH) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("voice_clones", 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 { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun list( + params: VoiceCloneListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("voice_clones") + .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() + } + } + .let { + VoiceCloneListPageAsync.builder() + .service(VoiceCloneServiceAsyncImpl(clientOptions)) + .streamHandlerExecutor(clientOptions.streamHandlerExecutor) + .params(params) + .response(it) + .build() + } + } + } + } + + private val deleteHandler: Handler = emptyHandler() + + override fun delete( + params: VoiceCloneDeleteParams, + 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.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("voice_clones", params._pathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response.use { deleteHandler.handle(it) } + } + } + } + + private val createFromUploadHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun createFromUpload( + params: VoiceCloneCreateFromUploadParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("voice_clones", "from_upload") + .body(multipartFormData(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 { createFromUploadHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + override fun downloadSample( + params: VoiceCloneDownloadSampleParams, + 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("voice_clones", params._pathParam(0), "sample") + .putHeader("Accept", "audio/wav") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> errorHandler.handle(response) } + } + } +} diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/async/VoiceDesignServiceAsync.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/async/VoiceDesignServiceAsync.kt new file mode 100644 index 000000000..a84230c95 --- /dev/null +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/async/VoiceDesignServiceAsync.kt @@ -0,0 +1,456 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.services.async + +import com.telnyx.sdk.core.ClientOptions +import com.telnyx.sdk.core.RequestOptions +import com.telnyx.sdk.core.http.HttpResponse +import com.telnyx.sdk.core.http.HttpResponseFor +import com.telnyx.sdk.models.voicedesigns.VoiceDesignCreateParams +import com.telnyx.sdk.models.voicedesigns.VoiceDesignCreateResponse +import com.telnyx.sdk.models.voicedesigns.VoiceDesignDeleteParams +import com.telnyx.sdk.models.voicedesigns.VoiceDesignDeleteVersionParams +import com.telnyx.sdk.models.voicedesigns.VoiceDesignDownloadSampleParams +import com.telnyx.sdk.models.voicedesigns.VoiceDesignListPageAsync +import com.telnyx.sdk.models.voicedesigns.VoiceDesignListParams +import com.telnyx.sdk.models.voicedesigns.VoiceDesignRenameParams +import com.telnyx.sdk.models.voicedesigns.VoiceDesignRenameResponse +import com.telnyx.sdk.models.voicedesigns.VoiceDesignRetrieveParams +import com.telnyx.sdk.models.voicedesigns.VoiceDesignRetrieveResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +/** Create and manage AI-generated voice designs using natural language prompts. */ +interface VoiceDesignServiceAsync { + + /** + * 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): VoiceDesignServiceAsync + + /** + * Creates a new voice design (version 1) when `voice_design_id` is omitted. When + * `voice_design_id` is provided, adds a new version to the existing design instead. A design + * can have at most 50 versions. + */ + fun create(params: VoiceDesignCreateParams): CompletableFuture = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: VoiceDesignCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * Returns the latest version of a voice design, or a specific version when `?version=N` is + * provided. The `id` parameter accepts either a UUID or the design name. + */ + fun retrieve(id: String): CompletableFuture = + retrieve(id, VoiceDesignRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + id: String, + params: VoiceDesignRetrieveParams = VoiceDesignRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + retrieve(params.toBuilder().id(id).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + id: String, + params: VoiceDesignRetrieveParams = VoiceDesignRetrieveParams.none(), + ): CompletableFuture = retrieve(id, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: VoiceDesignRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see retrieve */ + fun retrieve( + params: VoiceDesignRetrieveParams + ): CompletableFuture = retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + id: String, + requestOptions: RequestOptions, + ): CompletableFuture = + retrieve(id, VoiceDesignRetrieveParams.none(), requestOptions) + + /** Returns a paginated list of voice designs belonging to the authenticated account. */ + fun list(): CompletableFuture = list(VoiceDesignListParams.none()) + + /** @see list */ + fun list( + params: VoiceDesignListParams = VoiceDesignListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see list */ + fun list( + params: VoiceDesignListParams = VoiceDesignListParams.none() + ): CompletableFuture = list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): CompletableFuture = + list(VoiceDesignListParams.none(), requestOptions) + + /** Permanently deletes a voice design and all of its versions. This action cannot be undone. */ + fun delete(id: String): CompletableFuture = delete(id, VoiceDesignDeleteParams.none()) + + /** @see delete */ + fun delete( + id: String, + params: VoiceDesignDeleteParams = VoiceDesignDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = delete(params.toBuilder().id(id).build(), requestOptions) + + /** @see delete */ + fun delete( + id: String, + params: VoiceDesignDeleteParams = VoiceDesignDeleteParams.none(), + ): CompletableFuture = delete(id, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: VoiceDesignDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see delete */ + fun delete(params: VoiceDesignDeleteParams): CompletableFuture = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete(id: String, requestOptions: RequestOptions): CompletableFuture = + delete(id, VoiceDesignDeleteParams.none(), requestOptions) + + /** + * Permanently deletes a specific version of a voice design. The version number must be a + * positive integer. + */ + fun deleteVersion( + version: Long, + params: VoiceDesignDeleteVersionParams, + ): CompletableFuture = deleteVersion(version, params, RequestOptions.none()) + + /** @see deleteVersion */ + fun deleteVersion( + version: Long, + params: VoiceDesignDeleteVersionParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + deleteVersion(params.toBuilder().version(version).build(), requestOptions) + + /** @see deleteVersion */ + fun deleteVersion(params: VoiceDesignDeleteVersionParams): CompletableFuture = + deleteVersion(params, RequestOptions.none()) + + /** @see deleteVersion */ + fun deleteVersion( + params: VoiceDesignDeleteVersionParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * Downloads the WAV audio sample for the voice design. Returns the latest version's sample by + * default, or a specific version when `?version=N` is provided. The `id` parameter accepts + * either a UUID or the design name. + */ + fun downloadSample(id: String): CompletableFuture = + downloadSample(id, VoiceDesignDownloadSampleParams.none()) + + /** @see downloadSample */ + fun downloadSample( + id: String, + params: VoiceDesignDownloadSampleParams = VoiceDesignDownloadSampleParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + downloadSample(params.toBuilder().id(id).build(), requestOptions) + + /** @see downloadSample */ + fun downloadSample( + id: String, + params: VoiceDesignDownloadSampleParams = VoiceDesignDownloadSampleParams.none(), + ): CompletableFuture = downloadSample(id, params, RequestOptions.none()) + + /** @see downloadSample */ + fun downloadSample( + params: VoiceDesignDownloadSampleParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see downloadSample */ + fun downloadSample(params: VoiceDesignDownloadSampleParams): CompletableFuture = + downloadSample(params, RequestOptions.none()) + + /** @see downloadSample */ + fun downloadSample( + id: String, + requestOptions: RequestOptions, + ): CompletableFuture = + downloadSample(id, VoiceDesignDownloadSampleParams.none(), requestOptions) + + /** Updates the name of a voice design. All versions retain their other properties. */ + fun rename( + id: String, + params: VoiceDesignRenameParams, + ): CompletableFuture = rename(id, params, RequestOptions.none()) + + /** @see rename */ + fun rename( + id: String, + params: VoiceDesignRenameParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + rename(params.toBuilder().id(id).build(), requestOptions) + + /** @see rename */ + fun rename(params: VoiceDesignRenameParams): CompletableFuture = + rename(params, RequestOptions.none()) + + /** @see rename */ + fun rename( + params: VoiceDesignRenameParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * A view of [VoiceDesignServiceAsync] 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 + ): VoiceDesignServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /voice_designs`, but is otherwise the same as + * [VoiceDesignServiceAsync.create]. + */ + fun create( + params: VoiceDesignCreateParams + ): CompletableFuture> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: VoiceDesignCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /voice_designs/{id}`, but is otherwise the same as + * [VoiceDesignServiceAsync.retrieve]. + */ + fun retrieve(id: String): CompletableFuture> = + retrieve(id, VoiceDesignRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + id: String, + params: VoiceDesignRetrieveParams = VoiceDesignRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + retrieve(params.toBuilder().id(id).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + id: String, + params: VoiceDesignRetrieveParams = VoiceDesignRetrieveParams.none(), + ): CompletableFuture> = + retrieve(id, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: VoiceDesignRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see retrieve */ + fun retrieve( + params: VoiceDesignRetrieveParams + ): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + id: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + retrieve(id, VoiceDesignRetrieveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /voice_designs`, but is otherwise the same as + * [VoiceDesignServiceAsync.list]. + */ + fun list(): CompletableFuture> = + list(VoiceDesignListParams.none()) + + /** @see list */ + fun list( + params: VoiceDesignListParams = VoiceDesignListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see list */ + fun list( + params: VoiceDesignListParams = VoiceDesignListParams.none() + ): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + requestOptions: RequestOptions + ): CompletableFuture> = + list(VoiceDesignListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /voice_designs/{id}`, but is otherwise the same + * as [VoiceDesignServiceAsync.delete]. + */ + fun delete(id: String): CompletableFuture = + delete(id, VoiceDesignDeleteParams.none()) + + /** @see delete */ + fun delete( + id: String, + params: VoiceDesignDeleteParams = VoiceDesignDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + delete(params.toBuilder().id(id).build(), requestOptions) + + /** @see delete */ + fun delete( + id: String, + params: VoiceDesignDeleteParams = VoiceDesignDeleteParams.none(), + ): CompletableFuture = delete(id, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: VoiceDesignDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see delete */ + fun delete(params: VoiceDesignDeleteParams): CompletableFuture = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete(id: String, requestOptions: RequestOptions): CompletableFuture = + delete(id, VoiceDesignDeleteParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /voice_designs/{id}/versions/{version}`, but is + * otherwise the same as [VoiceDesignServiceAsync.deleteVersion]. + */ + fun deleteVersion( + version: Long, + params: VoiceDesignDeleteVersionParams, + ): CompletableFuture = deleteVersion(version, params, RequestOptions.none()) + + /** @see deleteVersion */ + fun deleteVersion( + version: Long, + params: VoiceDesignDeleteVersionParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + deleteVersion(params.toBuilder().version(version).build(), requestOptions) + + /** @see deleteVersion */ + fun deleteVersion(params: VoiceDesignDeleteVersionParams): CompletableFuture = + deleteVersion(params, RequestOptions.none()) + + /** @see deleteVersion */ + fun deleteVersion( + params: VoiceDesignDeleteVersionParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * Returns a raw HTTP response for `get /voice_designs/{id}/sample`, but is otherwise the + * same as [VoiceDesignServiceAsync.downloadSample]. + */ + fun downloadSample(id: String): CompletableFuture = + downloadSample(id, VoiceDesignDownloadSampleParams.none()) + + /** @see downloadSample */ + fun downloadSample( + id: String, + params: VoiceDesignDownloadSampleParams = VoiceDesignDownloadSampleParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + downloadSample(params.toBuilder().id(id).build(), requestOptions) + + /** @see downloadSample */ + fun downloadSample( + id: String, + params: VoiceDesignDownloadSampleParams = VoiceDesignDownloadSampleParams.none(), + ): CompletableFuture = downloadSample(id, params, RequestOptions.none()) + + /** @see downloadSample */ + fun downloadSample( + params: VoiceDesignDownloadSampleParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see downloadSample */ + fun downloadSample( + params: VoiceDesignDownloadSampleParams + ): CompletableFuture = downloadSample(params, RequestOptions.none()) + + /** @see downloadSample */ + fun downloadSample( + id: String, + requestOptions: RequestOptions, + ): CompletableFuture = + downloadSample(id, VoiceDesignDownloadSampleParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `patch /voice_designs/{id}`, but is otherwise the same as + * [VoiceDesignServiceAsync.rename]. + */ + fun rename( + id: String, + params: VoiceDesignRenameParams, + ): CompletableFuture> = + rename(id, params, RequestOptions.none()) + + /** @see rename */ + fun rename( + id: String, + params: VoiceDesignRenameParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + rename(params.toBuilder().id(id).build(), requestOptions) + + /** @see rename */ + fun rename( + params: VoiceDesignRenameParams + ): CompletableFuture> = + rename(params, RequestOptions.none()) + + /** @see rename */ + fun rename( + params: VoiceDesignRenameParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + } +} diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/async/VoiceDesignServiceAsyncImpl.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/async/VoiceDesignServiceAsyncImpl.kt new file mode 100644 index 000000000..9892eee93 --- /dev/null +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/async/VoiceDesignServiceAsyncImpl.kt @@ -0,0 +1,327 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.services.async + +import com.telnyx.sdk.core.ClientOptions +import com.telnyx.sdk.core.RequestOptions +import com.telnyx.sdk.core.checkRequired +import com.telnyx.sdk.core.handlers.emptyHandler +import com.telnyx.sdk.core.handlers.errorBodyHandler +import com.telnyx.sdk.core.handlers.errorHandler +import com.telnyx.sdk.core.handlers.jsonHandler +import com.telnyx.sdk.core.http.HttpMethod +import com.telnyx.sdk.core.http.HttpRequest +import com.telnyx.sdk.core.http.HttpResponse +import com.telnyx.sdk.core.http.HttpResponse.Handler +import com.telnyx.sdk.core.http.HttpResponseFor +import com.telnyx.sdk.core.http.json +import com.telnyx.sdk.core.http.parseable +import com.telnyx.sdk.core.prepareAsync +import com.telnyx.sdk.models.voicedesigns.VoiceDesignCreateParams +import com.telnyx.sdk.models.voicedesigns.VoiceDesignCreateResponse +import com.telnyx.sdk.models.voicedesigns.VoiceDesignDeleteParams +import com.telnyx.sdk.models.voicedesigns.VoiceDesignDeleteVersionParams +import com.telnyx.sdk.models.voicedesigns.VoiceDesignDownloadSampleParams +import com.telnyx.sdk.models.voicedesigns.VoiceDesignListPageAsync +import com.telnyx.sdk.models.voicedesigns.VoiceDesignListPageResponse +import com.telnyx.sdk.models.voicedesigns.VoiceDesignListParams +import com.telnyx.sdk.models.voicedesigns.VoiceDesignRenameParams +import com.telnyx.sdk.models.voicedesigns.VoiceDesignRenameResponse +import com.telnyx.sdk.models.voicedesigns.VoiceDesignRetrieveParams +import com.telnyx.sdk.models.voicedesigns.VoiceDesignRetrieveResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +/** Create and manage AI-generated voice designs using natural language prompts. */ +class VoiceDesignServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + VoiceDesignServiceAsync { + + private val withRawResponse: VoiceDesignServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): VoiceDesignServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): VoiceDesignServiceAsync = + VoiceDesignServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: VoiceDesignCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /voice_designs + withRawResponse().create(params, requestOptions).thenApply { it.parse() } + + override fun retrieve( + params: VoiceDesignRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /voice_designs/{id} + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + + override fun list( + params: VoiceDesignListParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /voice_designs + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + override fun delete( + params: VoiceDesignDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // delete /voice_designs/{id} + withRawResponse().delete(params, requestOptions).thenAccept {} + + override fun deleteVersion( + params: VoiceDesignDeleteVersionParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // delete /voice_designs/{id}/versions/{version} + withRawResponse().deleteVersion(params, requestOptions).thenAccept {} + + override fun downloadSample( + params: VoiceDesignDownloadSampleParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /voice_designs/{id}/sample + withRawResponse().downloadSample(params, requestOptions) + + override fun rename( + params: VoiceDesignRenameParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // patch /voice_designs/{id} + withRawResponse().rename(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + VoiceDesignServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): VoiceDesignServiceAsync.WithRawResponse = + VoiceDesignServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun create( + params: VoiceDesignCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("voice_designs") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieve( + params: VoiceDesignRetrieveParams, + 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("voice_designs", 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: VoiceDesignListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("voice_designs") + .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() + } + } + .let { + VoiceDesignListPageAsync.builder() + .service(VoiceDesignServiceAsyncImpl(clientOptions)) + .streamHandlerExecutor(clientOptions.streamHandlerExecutor) + .params(params) + .response(it) + .build() + } + } + } + } + + private val deleteHandler: Handler = emptyHandler() + + override fun delete( + params: VoiceDesignDeleteParams, + 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.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("voice_designs", params._pathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response.use { deleteHandler.handle(it) } + } + } + } + + private val deleteVersionHandler: Handler = emptyHandler() + + override fun deleteVersion( + params: VoiceDesignDeleteVersionParams, + requestOptions: RequestOptions, + ): CompletableFuture { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("version", params.version().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "voice_designs", + params._pathParam(0), + "versions", + params._pathParam(1), + ) + .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 { deleteVersionHandler.handle(it) } + } + } + } + + override fun downloadSample( + params: VoiceDesignDownloadSampleParams, + 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("voice_designs", params._pathParam(0), "sample") + .putHeader("Accept", "audio/wav") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> errorHandler.handle(response) } + } + + private val renameHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun rename( + params: VoiceDesignRenameParams, + 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.PATCH) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("voice_designs", 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 { renameHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/async/X402ServiceAsync.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/async/X402ServiceAsync.kt new file mode 100644 index 000000000..fa5f50c36 --- /dev/null +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/async/X402ServiceAsync.kt @@ -0,0 +1,45 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.services.async + +import com.telnyx.sdk.core.ClientOptions +import com.telnyx.sdk.services.async.x402.CreditAccountServiceAsync +import java.util.function.Consumer + +interface X402ServiceAsync { + + /** + * 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): X402ServiceAsync + + /** + * Operations for x402 cryptocurrency payment transactions. Fund your Telnyx account using USDC + * stablecoin payments via the x402 protocol. + */ + fun creditAccount(): CreditAccountServiceAsync + + /** A view of [X402ServiceAsync] 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): X402ServiceAsync.WithRawResponse + + /** + * Operations for x402 cryptocurrency payment transactions. Fund your Telnyx account using + * USDC stablecoin payments via the x402 protocol. + */ + fun creditAccount(): CreditAccountServiceAsync.WithRawResponse + } +} diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/async/X402ServiceAsyncImpl.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/async/X402ServiceAsyncImpl.kt new file mode 100644 index 000000000..e3e65c0e9 --- /dev/null +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/async/X402ServiceAsyncImpl.kt @@ -0,0 +1,52 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.services.async + +import com.telnyx.sdk.core.ClientOptions +import com.telnyx.sdk.services.async.x402.CreditAccountServiceAsync +import com.telnyx.sdk.services.async.x402.CreditAccountServiceAsyncImpl +import java.util.function.Consumer + +class X402ServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + X402ServiceAsync { + + private val withRawResponse: X402ServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val creditAccount: CreditAccountServiceAsync by lazy { + CreditAccountServiceAsyncImpl(clientOptions) + } + + override fun withRawResponse(): X402ServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): X402ServiceAsync = + X402ServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + /** + * Operations for x402 cryptocurrency payment transactions. Fund your Telnyx account using USDC + * stablecoin payments via the x402 protocol. + */ + override fun creditAccount(): CreditAccountServiceAsync = creditAccount + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + X402ServiceAsync.WithRawResponse { + + private val creditAccount: CreditAccountServiceAsync.WithRawResponse by lazy { + CreditAccountServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer + ): X402ServiceAsync.WithRawResponse = + X402ServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + /** + * Operations for x402 cryptocurrency payment transactions. Fund your Telnyx account using + * USDC stablecoin payments via the x402 protocol. + */ + override fun creditAccount(): CreditAccountServiceAsync.WithRawResponse = creditAccount + } +} diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/async/recordings/ActionServiceAsync.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/async/recordings/ActionServiceAsync.kt index 01053429d..bb73a4b0b 100644 --- a/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/async/recordings/ActionServiceAsync.kt +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/async/recordings/ActionServiceAsync.kt @@ -4,8 +4,9 @@ package com.telnyx.sdk.services.async.recordings import com.telnyx.sdk.core.ClientOptions import com.telnyx.sdk.core.RequestOptions -import com.telnyx.sdk.core.http.HttpResponse +import com.telnyx.sdk.core.http.HttpResponseFor import com.telnyx.sdk.models.recordings.actions.ActionDeleteParams +import com.telnyx.sdk.models.recordings.actions.ActionDeleteResponse import java.util.concurrent.CompletableFuture import java.util.function.Consumer @@ -25,14 +26,14 @@ interface ActionServiceAsync { fun withOptions(modifier: Consumer): ActionServiceAsync /** Permanently deletes a list of call recordings. */ - fun delete(params: ActionDeleteParams): CompletableFuture = + fun delete(params: ActionDeleteParams): CompletableFuture = delete(params, RequestOptions.none()) /** @see delete */ fun delete( params: ActionDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** * A view of [ActionServiceAsync] that provides access to raw HTTP responses for each method. @@ -52,13 +53,15 @@ interface ActionServiceAsync { * Returns a raw HTTP response for `post /recordings/actions/delete`, but is otherwise the * same as [ActionServiceAsync.delete]. */ - fun delete(params: ActionDeleteParams): CompletableFuture = + fun delete( + params: ActionDeleteParams + ): CompletableFuture> = delete(params, RequestOptions.none()) /** @see delete */ fun delete( params: ActionDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture> } } diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/async/recordings/ActionServiceAsyncImpl.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/async/recordings/ActionServiceAsyncImpl.kt index bc282ad8f..eee7900b8 100644 --- a/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/async/recordings/ActionServiceAsyncImpl.kt +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/async/recordings/ActionServiceAsyncImpl.kt @@ -4,17 +4,19 @@ package com.telnyx.sdk.services.async.recordings import com.telnyx.sdk.core.ClientOptions import com.telnyx.sdk.core.RequestOptions -import com.telnyx.sdk.core.handlers.emptyHandler import com.telnyx.sdk.core.handlers.errorBodyHandler import com.telnyx.sdk.core.handlers.errorHandler +import com.telnyx.sdk.core.handlers.jsonHandler import com.telnyx.sdk.core.http.HttpMethod import com.telnyx.sdk.core.http.HttpRequest import com.telnyx.sdk.core.http.HttpResponse import com.telnyx.sdk.core.http.HttpResponse.Handler +import com.telnyx.sdk.core.http.HttpResponseFor import com.telnyx.sdk.core.http.json import com.telnyx.sdk.core.http.parseable import com.telnyx.sdk.core.prepareAsync import com.telnyx.sdk.models.recordings.actions.ActionDeleteParams +import com.telnyx.sdk.models.recordings.actions.ActionDeleteResponse import java.util.concurrent.CompletableFuture import java.util.function.Consumer @@ -34,9 +36,9 @@ class ActionServiceAsyncImpl internal constructor(private val clientOptions: Cli override fun delete( params: ActionDeleteParams, requestOptions: RequestOptions, - ): CompletableFuture = + ): CompletableFuture = // post /recordings/actions/delete - withRawResponse().delete(params, requestOptions).thenAccept {} + withRawResponse().delete(params, requestOptions).thenApply { it.parse() } class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : ActionServiceAsync.WithRawResponse { @@ -51,12 +53,13 @@ class ActionServiceAsyncImpl internal constructor(private val clientOptions: Cli clientOptions.toBuilder().apply(modifier::accept).build() ) - private val deleteHandler: Handler = emptyHandler() + private val deleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper) override fun delete( params: ActionDeleteParams, requestOptions: RequestOptions, - ): CompletableFuture { + ): CompletableFuture> { val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -70,7 +73,13 @@ class ActionServiceAsyncImpl internal constructor(private val clientOptions: Cli .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> errorHandler.handle(response).parseable { - response.use { deleteHandler.handle(it) } + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } } } diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/async/x402/CreditAccountServiceAsync.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/async/x402/CreditAccountServiceAsync.kt new file mode 100644 index 000000000..3ae3b2340 --- /dev/null +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/async/x402/CreditAccountServiceAsync.kt @@ -0,0 +1,109 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.services.async.x402 + +import com.telnyx.sdk.core.ClientOptions +import com.telnyx.sdk.core.RequestOptions +import com.telnyx.sdk.core.http.HttpResponseFor +import com.telnyx.sdk.models.x402.creditaccount.CreditAccountCreateQuoteParams +import com.telnyx.sdk.models.x402.creditaccount.CreditAccountCreateQuoteResponse +import com.telnyx.sdk.models.x402.creditaccount.CreditAccountSettleParams +import com.telnyx.sdk.models.x402.creditaccount.CreditAccountSettleResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +/** + * Operations for x402 cryptocurrency payment transactions. Fund your Telnyx account using USDC + * stablecoin payments via the x402 protocol. + */ +interface CreditAccountServiceAsync { + + /** + * 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): CreditAccountServiceAsync + + /** + * Creates a payment quote for the specified USD amount. Returns payment details including the + * x402 payment requirements, network, and expiration time. The quote must be settled before it + * expires. + */ + fun createQuote( + params: CreditAccountCreateQuoteParams + ): CompletableFuture = + createQuote(params, RequestOptions.none()) + + /** @see createQuote */ + fun createQuote( + params: CreditAccountCreateQuoteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * Settles an x402 payment using the quote ID and a signed payment authorization. The payment + * signature can be provided via the `PAYMENT-SIGNATURE` header or the `payment_signature` body + * parameter. Settlement is idempotent — submitting the same quote ID multiple times returns the + * existing transaction. + */ + fun settle(params: CreditAccountSettleParams): CompletableFuture = + settle(params, RequestOptions.none()) + + /** @see settle */ + fun settle( + params: CreditAccountSettleParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * A view of [CreditAccountServiceAsync] 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 + ): CreditAccountServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /v2/x402/credit_account/quote`, but is otherwise + * the same as [CreditAccountServiceAsync.createQuote]. + */ + fun createQuote( + params: CreditAccountCreateQuoteParams + ): CompletableFuture> = + createQuote(params, RequestOptions.none()) + + /** @see createQuote */ + fun createQuote( + params: CreditAccountCreateQuoteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `post /v2/x402/credit_account`, but is otherwise the same + * as [CreditAccountServiceAsync.settle]. + */ + fun settle( + params: CreditAccountSettleParams + ): CompletableFuture> = + settle(params, RequestOptions.none()) + + /** @see settle */ + fun settle( + params: CreditAccountSettleParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + } +} diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/async/x402/CreditAccountServiceAsyncImpl.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/async/x402/CreditAccountServiceAsyncImpl.kt new file mode 100644 index 000000000..96c5ca2b8 --- /dev/null +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/async/x402/CreditAccountServiceAsyncImpl.kt @@ -0,0 +1,130 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.services.async.x402 + +import com.telnyx.sdk.core.ClientOptions +import com.telnyx.sdk.core.RequestOptions +import com.telnyx.sdk.core.handlers.errorBodyHandler +import com.telnyx.sdk.core.handlers.errorHandler +import com.telnyx.sdk.core.handlers.jsonHandler +import com.telnyx.sdk.core.http.HttpMethod +import com.telnyx.sdk.core.http.HttpRequest +import com.telnyx.sdk.core.http.HttpResponse +import com.telnyx.sdk.core.http.HttpResponse.Handler +import com.telnyx.sdk.core.http.HttpResponseFor +import com.telnyx.sdk.core.http.json +import com.telnyx.sdk.core.http.parseable +import com.telnyx.sdk.core.prepareAsync +import com.telnyx.sdk.models.x402.creditaccount.CreditAccountCreateQuoteParams +import com.telnyx.sdk.models.x402.creditaccount.CreditAccountCreateQuoteResponse +import com.telnyx.sdk.models.x402.creditaccount.CreditAccountSettleParams +import com.telnyx.sdk.models.x402.creditaccount.CreditAccountSettleResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +/** + * Operations for x402 cryptocurrency payment transactions. Fund your Telnyx account using USDC + * stablecoin payments via the x402 protocol. + */ +class CreditAccountServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + CreditAccountServiceAsync { + + private val withRawResponse: CreditAccountServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): CreditAccountServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): CreditAccountServiceAsync = + CreditAccountServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun createQuote( + params: CreditAccountCreateQuoteParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /v2/x402/credit_account/quote + withRawResponse().createQuote(params, requestOptions).thenApply { it.parse() } + + override fun settle( + params: CreditAccountSettleParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /v2/x402/credit_account + withRawResponse().settle(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + CreditAccountServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): CreditAccountServiceAsync.WithRawResponse = + CreditAccountServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createQuoteHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun createQuote( + params: CreditAccountCreateQuoteParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v2", "x402", "credit_account", "quote") + .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 { createQuoteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val settleHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun settle( + params: CreditAccountSettleParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v2", "x402", "credit_account") + .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 { settleHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/blocking/RecordingTranscriptionService.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/blocking/RecordingTranscriptionService.kt index 6213d6bfe..412b1b790 100644 --- a/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/blocking/RecordingTranscriptionService.kt +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/blocking/RecordingTranscriptionService.kt @@ -8,8 +8,8 @@ import com.telnyx.sdk.core.RequestOptions import com.telnyx.sdk.core.http.HttpResponseFor import com.telnyx.sdk.models.recordingtranscriptions.RecordingTranscriptionDeleteParams import com.telnyx.sdk.models.recordingtranscriptions.RecordingTranscriptionDeleteResponse +import com.telnyx.sdk.models.recordingtranscriptions.RecordingTranscriptionListPage import com.telnyx.sdk.models.recordingtranscriptions.RecordingTranscriptionListParams -import com.telnyx.sdk.models.recordingtranscriptions.RecordingTranscriptionListResponse import com.telnyx.sdk.models.recordingtranscriptions.RecordingTranscriptionRetrieveParams import com.telnyx.sdk.models.recordingtranscriptions.RecordingTranscriptionRetrieveResponse import java.util.function.Consumer @@ -74,21 +74,21 @@ interface RecordingTranscriptionService { ) /** Returns a list of your recording transcriptions. */ - fun list(): RecordingTranscriptionListResponse = list(RecordingTranscriptionListParams.none()) + fun list(): RecordingTranscriptionListPage = list(RecordingTranscriptionListParams.none()) /** @see list */ fun list( params: RecordingTranscriptionListParams = RecordingTranscriptionListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): RecordingTranscriptionListResponse + ): RecordingTranscriptionListPage /** @see list */ fun list( params: RecordingTranscriptionListParams = RecordingTranscriptionListParams.none() - ): RecordingTranscriptionListResponse = list(params, RequestOptions.none()) + ): RecordingTranscriptionListPage = list(params, RequestOptions.none()) /** @see list */ - fun list(requestOptions: RequestOptions): RecordingTranscriptionListResponse = + fun list(requestOptions: RequestOptions): RecordingTranscriptionListPage = list(RecordingTranscriptionListParams.none(), requestOptions) /** Permanently deletes a recording transcription. */ @@ -209,7 +209,7 @@ interface RecordingTranscriptionService { * same as [RecordingTranscriptionService.list]. */ @MustBeClosed - fun list(): HttpResponseFor = + fun list(): HttpResponseFor = list(RecordingTranscriptionListParams.none()) /** @see list */ @@ -217,19 +217,17 @@ interface RecordingTranscriptionService { fun list( params: RecordingTranscriptionListParams = RecordingTranscriptionListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + ): HttpResponseFor /** @see list */ @MustBeClosed fun list( params: RecordingTranscriptionListParams = RecordingTranscriptionListParams.none() - ): HttpResponseFor = list(params, RequestOptions.none()) + ): HttpResponseFor = list(params, RequestOptions.none()) /** @see list */ @MustBeClosed - fun list( - requestOptions: RequestOptions - ): HttpResponseFor = + fun list(requestOptions: RequestOptions): HttpResponseFor = list(RecordingTranscriptionListParams.none(), requestOptions) /** diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/blocking/RecordingTranscriptionServiceImpl.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/blocking/RecordingTranscriptionServiceImpl.kt index 8386e68fb..98812f5a9 100644 --- a/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/blocking/RecordingTranscriptionServiceImpl.kt +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/blocking/RecordingTranscriptionServiceImpl.kt @@ -18,8 +18,9 @@ import com.telnyx.sdk.core.http.parseable import com.telnyx.sdk.core.prepare import com.telnyx.sdk.models.recordingtranscriptions.RecordingTranscriptionDeleteParams import com.telnyx.sdk.models.recordingtranscriptions.RecordingTranscriptionDeleteResponse +import com.telnyx.sdk.models.recordingtranscriptions.RecordingTranscriptionListPage +import com.telnyx.sdk.models.recordingtranscriptions.RecordingTranscriptionListPageResponse import com.telnyx.sdk.models.recordingtranscriptions.RecordingTranscriptionListParams -import com.telnyx.sdk.models.recordingtranscriptions.RecordingTranscriptionListResponse import com.telnyx.sdk.models.recordingtranscriptions.RecordingTranscriptionRetrieveParams import com.telnyx.sdk.models.recordingtranscriptions.RecordingTranscriptionRetrieveResponse import java.util.function.Consumer @@ -50,7 +51,7 @@ internal constructor(private val clientOptions: ClientOptions) : RecordingTransc override fun list( params: RecordingTranscriptionListParams, requestOptions: RequestOptions, - ): RecordingTranscriptionListResponse = + ): RecordingTranscriptionListPage = // get /recording_transcriptions withRawResponse().list(params, requestOptions).parse() @@ -104,13 +105,13 @@ internal constructor(private val clientOptions: ClientOptions) : RecordingTransc } } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) override fun list( params: RecordingTranscriptionListParams, requestOptions: RequestOptions, - ): HttpResponseFor { + ): HttpResponseFor { val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -128,6 +129,13 @@ internal constructor(private val clientOptions: ClientOptions) : RecordingTransc it.validate() } } + .let { + RecordingTranscriptionListPage.builder() + .service(RecordingTranscriptionServiceImpl(clientOptions)) + .params(params) + .response(it) + .build() + } } } diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/blocking/VoiceCloneService.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/blocking/VoiceCloneService.kt new file mode 100644 index 000000000..6a8870783 --- /dev/null +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/blocking/VoiceCloneService.kt @@ -0,0 +1,346 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.services.blocking + +import com.google.errorprone.annotations.MustBeClosed +import com.telnyx.sdk.core.ClientOptions +import com.telnyx.sdk.core.RequestOptions +import com.telnyx.sdk.core.http.HttpResponse +import com.telnyx.sdk.core.http.HttpResponseFor +import com.telnyx.sdk.models.voiceclones.VoiceCloneCreateFromUploadParams +import com.telnyx.sdk.models.voiceclones.VoiceCloneCreateFromUploadResponse +import com.telnyx.sdk.models.voiceclones.VoiceCloneCreateParams +import com.telnyx.sdk.models.voiceclones.VoiceCloneCreateResponse +import com.telnyx.sdk.models.voiceclones.VoiceCloneDeleteParams +import com.telnyx.sdk.models.voiceclones.VoiceCloneDownloadSampleParams +import com.telnyx.sdk.models.voiceclones.VoiceCloneListPage +import com.telnyx.sdk.models.voiceclones.VoiceCloneListParams +import com.telnyx.sdk.models.voiceclones.VoiceCloneUpdateParams +import com.telnyx.sdk.models.voiceclones.VoiceCloneUpdateResponse +import java.util.function.Consumer + +/** Capture and manage voice identities as clones for use in text-to-speech synthesis. */ +interface VoiceCloneService { + + /** + * 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): VoiceCloneService + + /** + * Creates a new voice clone by capturing the voice identity of an existing voice design. The + * clone can then be used for text-to-speech synthesis. + */ + fun create(params: VoiceCloneCreateParams): VoiceCloneCreateResponse = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: VoiceCloneCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): VoiceCloneCreateResponse + + /** Updates the name, language, or gender of a voice clone. */ + fun update(id: String, params: VoiceCloneUpdateParams): VoiceCloneUpdateResponse = + update(id, params, RequestOptions.none()) + + /** @see update */ + fun update( + id: String, + params: VoiceCloneUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): VoiceCloneUpdateResponse = update(params.toBuilder().id(id).build(), requestOptions) + + /** @see update */ + fun update(params: VoiceCloneUpdateParams): VoiceCloneUpdateResponse = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: VoiceCloneUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): VoiceCloneUpdateResponse + + /** Returns a paginated list of voice clones belonging to the authenticated account. */ + fun list(): VoiceCloneListPage = list(VoiceCloneListParams.none()) + + /** @see list */ + fun list( + params: VoiceCloneListParams = VoiceCloneListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): VoiceCloneListPage + + /** @see list */ + fun list(params: VoiceCloneListParams = VoiceCloneListParams.none()): VoiceCloneListPage = + list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): VoiceCloneListPage = + list(VoiceCloneListParams.none(), requestOptions) + + /** Permanently deletes a voice clone. This action cannot be undone. */ + fun delete(id: String) = delete(id, VoiceCloneDeleteParams.none()) + + /** @see delete */ + fun delete( + id: String, + params: VoiceCloneDeleteParams = VoiceCloneDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ) = delete(params.toBuilder().id(id).build(), requestOptions) + + /** @see delete */ + fun delete(id: String, params: VoiceCloneDeleteParams = VoiceCloneDeleteParams.none()) = + delete(id, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: VoiceCloneDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ) + + /** @see delete */ + fun delete(params: VoiceCloneDeleteParams) = delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete(id: String, requestOptions: RequestOptions) = + delete(id, VoiceCloneDeleteParams.none(), requestOptions) + + /** + * Creates a new voice clone by uploading an audio file directly. Supported formats: WAV, MP3, + * FLAC, OGG, M4A. For best results, provide 5–10 seconds of clear speech. Maximum file size: + * 2MB. + */ + fun createFromUpload( + params: VoiceCloneCreateFromUploadParams + ): VoiceCloneCreateFromUploadResponse = createFromUpload(params, RequestOptions.none()) + + /** @see createFromUpload */ + fun createFromUpload( + params: VoiceCloneCreateFromUploadParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): VoiceCloneCreateFromUploadResponse + + /** Downloads the WAV audio sample that was used to create the voice clone. */ + @MustBeClosed + fun downloadSample(id: String): HttpResponse = + downloadSample(id, VoiceCloneDownloadSampleParams.none()) + + /** @see downloadSample */ + @MustBeClosed + fun downloadSample( + id: String, + params: VoiceCloneDownloadSampleParams = VoiceCloneDownloadSampleParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse = downloadSample(params.toBuilder().id(id).build(), requestOptions) + + /** @see downloadSample */ + @MustBeClosed + fun downloadSample( + id: String, + params: VoiceCloneDownloadSampleParams = VoiceCloneDownloadSampleParams.none(), + ): HttpResponse = downloadSample(id, params, RequestOptions.none()) + + /** @see downloadSample */ + @MustBeClosed + fun downloadSample( + params: VoiceCloneDownloadSampleParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse + + /** @see downloadSample */ + @MustBeClosed + fun downloadSample(params: VoiceCloneDownloadSampleParams): HttpResponse = + downloadSample(params, RequestOptions.none()) + + /** @see downloadSample */ + @MustBeClosed + fun downloadSample(id: String, requestOptions: RequestOptions): HttpResponse = + downloadSample(id, VoiceCloneDownloadSampleParams.none(), requestOptions) + + /** A view of [VoiceCloneService] 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 + ): VoiceCloneService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /voice_clones`, but is otherwise the same as + * [VoiceCloneService.create]. + */ + @MustBeClosed + fun create(params: VoiceCloneCreateParams): HttpResponseFor = + create(params, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + params: VoiceCloneCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `patch /voice_clones/{id}`, but is otherwise the same as + * [VoiceCloneService.update]. + */ + @MustBeClosed + fun update( + id: String, + params: VoiceCloneUpdateParams, + ): HttpResponseFor = update(id, params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + id: String, + params: VoiceCloneUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + update(params.toBuilder().id(id).build(), requestOptions) + + /** @see update */ + @MustBeClosed + fun update(params: VoiceCloneUpdateParams): HttpResponseFor = + update(params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + params: VoiceCloneUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /voice_clones`, but is otherwise the same as + * [VoiceCloneService.list]. + */ + @MustBeClosed + fun list(): HttpResponseFor = list(VoiceCloneListParams.none()) + + /** @see list */ + @MustBeClosed + fun list( + params: VoiceCloneListParams = VoiceCloneListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see list */ + @MustBeClosed + fun list( + params: VoiceCloneListParams = VoiceCloneListParams.none() + ): HttpResponseFor = list(params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list(requestOptions: RequestOptions): HttpResponseFor = + list(VoiceCloneListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /voice_clones/{id}`, but is otherwise the same as + * [VoiceCloneService.delete]. + */ + @MustBeClosed + fun delete(id: String): HttpResponse = delete(id, VoiceCloneDeleteParams.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + id: String, + params: VoiceCloneDeleteParams = VoiceCloneDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse = delete(params.toBuilder().id(id).build(), requestOptions) + + /** @see delete */ + @MustBeClosed + fun delete( + id: String, + params: VoiceCloneDeleteParams = VoiceCloneDeleteParams.none(), + ): HttpResponse = delete(id, params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + params: VoiceCloneDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse + + /** @see delete */ + @MustBeClosed + fun delete(params: VoiceCloneDeleteParams): HttpResponse = + delete(params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete(id: String, requestOptions: RequestOptions): HttpResponse = + delete(id, VoiceCloneDeleteParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /voice_clones/from_upload`, but is otherwise the + * same as [VoiceCloneService.createFromUpload]. + */ + @MustBeClosed + fun createFromUpload( + params: VoiceCloneCreateFromUploadParams + ): HttpResponseFor = + createFromUpload(params, RequestOptions.none()) + + /** @see createFromUpload */ + @MustBeClosed + fun createFromUpload( + params: VoiceCloneCreateFromUploadParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /voice_clones/{id}/sample`, but is otherwise the + * same as [VoiceCloneService.downloadSample]. + */ + @MustBeClosed + fun downloadSample(id: String): HttpResponse = + downloadSample(id, VoiceCloneDownloadSampleParams.none()) + + /** @see downloadSample */ + @MustBeClosed + fun downloadSample( + id: String, + params: VoiceCloneDownloadSampleParams = VoiceCloneDownloadSampleParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse = downloadSample(params.toBuilder().id(id).build(), requestOptions) + + /** @see downloadSample */ + @MustBeClosed + fun downloadSample( + id: String, + params: VoiceCloneDownloadSampleParams = VoiceCloneDownloadSampleParams.none(), + ): HttpResponse = downloadSample(id, params, RequestOptions.none()) + + /** @see downloadSample */ + @MustBeClosed + fun downloadSample( + params: VoiceCloneDownloadSampleParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse + + /** @see downloadSample */ + @MustBeClosed + fun downloadSample(params: VoiceCloneDownloadSampleParams): HttpResponse = + downloadSample(params, RequestOptions.none()) + + /** @see downloadSample */ + @MustBeClosed + fun downloadSample(id: String, requestOptions: RequestOptions): HttpResponse = + downloadSample(id, VoiceCloneDownloadSampleParams.none(), requestOptions) + } +} diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/blocking/VoiceCloneServiceImpl.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/blocking/VoiceCloneServiceImpl.kt new file mode 100644 index 000000000..62979f9cb --- /dev/null +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/blocking/VoiceCloneServiceImpl.kt @@ -0,0 +1,266 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.services.blocking + +import com.telnyx.sdk.core.ClientOptions +import com.telnyx.sdk.core.RequestOptions +import com.telnyx.sdk.core.checkRequired +import com.telnyx.sdk.core.handlers.emptyHandler +import com.telnyx.sdk.core.handlers.errorBodyHandler +import com.telnyx.sdk.core.handlers.errorHandler +import com.telnyx.sdk.core.handlers.jsonHandler +import com.telnyx.sdk.core.http.HttpMethod +import com.telnyx.sdk.core.http.HttpRequest +import com.telnyx.sdk.core.http.HttpResponse +import com.telnyx.sdk.core.http.HttpResponse.Handler +import com.telnyx.sdk.core.http.HttpResponseFor +import com.telnyx.sdk.core.http.json +import com.telnyx.sdk.core.http.multipartFormData +import com.telnyx.sdk.core.http.parseable +import com.telnyx.sdk.core.prepare +import com.telnyx.sdk.models.voiceclones.VoiceCloneCreateFromUploadParams +import com.telnyx.sdk.models.voiceclones.VoiceCloneCreateFromUploadResponse +import com.telnyx.sdk.models.voiceclones.VoiceCloneCreateParams +import com.telnyx.sdk.models.voiceclones.VoiceCloneCreateResponse +import com.telnyx.sdk.models.voiceclones.VoiceCloneDeleteParams +import com.telnyx.sdk.models.voiceclones.VoiceCloneDownloadSampleParams +import com.telnyx.sdk.models.voiceclones.VoiceCloneListPage +import com.telnyx.sdk.models.voiceclones.VoiceCloneListPageResponse +import com.telnyx.sdk.models.voiceclones.VoiceCloneListParams +import com.telnyx.sdk.models.voiceclones.VoiceCloneUpdateParams +import com.telnyx.sdk.models.voiceclones.VoiceCloneUpdateResponse +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +/** Capture and manage voice identities as clones for use in text-to-speech synthesis. */ +class VoiceCloneServiceImpl internal constructor(private val clientOptions: ClientOptions) : + VoiceCloneService { + + private val withRawResponse: VoiceCloneService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): VoiceCloneService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): VoiceCloneService = + VoiceCloneServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: VoiceCloneCreateParams, + requestOptions: RequestOptions, + ): VoiceCloneCreateResponse = + // post /voice_clones + withRawResponse().create(params, requestOptions).parse() + + override fun update( + params: VoiceCloneUpdateParams, + requestOptions: RequestOptions, + ): VoiceCloneUpdateResponse = + // patch /voice_clones/{id} + withRawResponse().update(params, requestOptions).parse() + + override fun list( + params: VoiceCloneListParams, + requestOptions: RequestOptions, + ): VoiceCloneListPage = + // get /voice_clones + withRawResponse().list(params, requestOptions).parse() + + override fun delete(params: VoiceCloneDeleteParams, requestOptions: RequestOptions) { + // delete /voice_clones/{id} + withRawResponse().delete(params, requestOptions) + } + + override fun createFromUpload( + params: VoiceCloneCreateFromUploadParams, + requestOptions: RequestOptions, + ): VoiceCloneCreateFromUploadResponse = + // post /voice_clones/from_upload + withRawResponse().createFromUpload(params, requestOptions).parse() + + override fun downloadSample( + params: VoiceCloneDownloadSampleParams, + requestOptions: RequestOptions, + ): HttpResponse = + // get /voice_clones/{id}/sample + withRawResponse().downloadSample(params, requestOptions) + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + VoiceCloneService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): VoiceCloneService.WithRawResponse = + VoiceCloneServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun create( + params: VoiceCloneCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("voice_clones") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun update( + params: VoiceCloneUpdateParams, + 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.PATCH) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("voice_clones", 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 { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun list( + params: VoiceCloneListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("voice_clones") + .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() + } + } + .let { + VoiceCloneListPage.builder() + .service(VoiceCloneServiceImpl(clientOptions)) + .params(params) + .response(it) + .build() + } + } + } + + private val deleteHandler: Handler = emptyHandler() + + override fun delete( + params: VoiceCloneDeleteParams, + requestOptions: RequestOptions, + ): HttpResponse { + // 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.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("voice_clones", params._pathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response.use { deleteHandler.handle(it) } + } + } + + private val createFromUploadHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun createFromUpload( + params: VoiceCloneCreateFromUploadParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("voice_clones", "from_upload") + .body(multipartFormData(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 { createFromUploadHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + override fun downloadSample( + params: VoiceCloneDownloadSampleParams, + requestOptions: RequestOptions, + ): HttpResponse { + // 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("voice_clones", params._pathParam(0), "sample") + .putHeader("Accept", "audio/wav") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response) + } + } +} diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/blocking/VoiceDesignService.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/blocking/VoiceDesignService.kt new file mode 100644 index 000000000..f18adff1a --- /dev/null +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/blocking/VoiceDesignService.kt @@ -0,0 +1,454 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.services.blocking + +import com.google.errorprone.annotations.MustBeClosed +import com.telnyx.sdk.core.ClientOptions +import com.telnyx.sdk.core.RequestOptions +import com.telnyx.sdk.core.http.HttpResponse +import com.telnyx.sdk.core.http.HttpResponseFor +import com.telnyx.sdk.models.voicedesigns.VoiceDesignCreateParams +import com.telnyx.sdk.models.voicedesigns.VoiceDesignCreateResponse +import com.telnyx.sdk.models.voicedesigns.VoiceDesignDeleteParams +import com.telnyx.sdk.models.voicedesigns.VoiceDesignDeleteVersionParams +import com.telnyx.sdk.models.voicedesigns.VoiceDesignDownloadSampleParams +import com.telnyx.sdk.models.voicedesigns.VoiceDesignListPage +import com.telnyx.sdk.models.voicedesigns.VoiceDesignListParams +import com.telnyx.sdk.models.voicedesigns.VoiceDesignRenameParams +import com.telnyx.sdk.models.voicedesigns.VoiceDesignRenameResponse +import com.telnyx.sdk.models.voicedesigns.VoiceDesignRetrieveParams +import com.telnyx.sdk.models.voicedesigns.VoiceDesignRetrieveResponse +import java.util.function.Consumer + +/** Create and manage AI-generated voice designs using natural language prompts. */ +interface VoiceDesignService { + + /** + * 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): VoiceDesignService + + /** + * Creates a new voice design (version 1) when `voice_design_id` is omitted. When + * `voice_design_id` is provided, adds a new version to the existing design instead. A design + * can have at most 50 versions. + */ + fun create(params: VoiceDesignCreateParams): VoiceDesignCreateResponse = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: VoiceDesignCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): VoiceDesignCreateResponse + + /** + * Returns the latest version of a voice design, or a specific version when `?version=N` is + * provided. The `id` parameter accepts either a UUID or the design name. + */ + fun retrieve(id: String): VoiceDesignRetrieveResponse = + retrieve(id, VoiceDesignRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + id: String, + params: VoiceDesignRetrieveParams = VoiceDesignRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): VoiceDesignRetrieveResponse = retrieve(params.toBuilder().id(id).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + id: String, + params: VoiceDesignRetrieveParams = VoiceDesignRetrieveParams.none(), + ): VoiceDesignRetrieveResponse = retrieve(id, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: VoiceDesignRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): VoiceDesignRetrieveResponse + + /** @see retrieve */ + fun retrieve(params: VoiceDesignRetrieveParams): VoiceDesignRetrieveResponse = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve(id: String, requestOptions: RequestOptions): VoiceDesignRetrieveResponse = + retrieve(id, VoiceDesignRetrieveParams.none(), requestOptions) + + /** Returns a paginated list of voice designs belonging to the authenticated account. */ + fun list(): VoiceDesignListPage = list(VoiceDesignListParams.none()) + + /** @see list */ + fun list( + params: VoiceDesignListParams = VoiceDesignListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): VoiceDesignListPage + + /** @see list */ + fun list(params: VoiceDesignListParams = VoiceDesignListParams.none()): VoiceDesignListPage = + list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): VoiceDesignListPage = + list(VoiceDesignListParams.none(), requestOptions) + + /** Permanently deletes a voice design and all of its versions. This action cannot be undone. */ + fun delete(id: String) = delete(id, VoiceDesignDeleteParams.none()) + + /** @see delete */ + fun delete( + id: String, + params: VoiceDesignDeleteParams = VoiceDesignDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ) = delete(params.toBuilder().id(id).build(), requestOptions) + + /** @see delete */ + fun delete(id: String, params: VoiceDesignDeleteParams = VoiceDesignDeleteParams.none()) = + delete(id, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: VoiceDesignDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ) + + /** @see delete */ + fun delete(params: VoiceDesignDeleteParams) = delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete(id: String, requestOptions: RequestOptions) = + delete(id, VoiceDesignDeleteParams.none(), requestOptions) + + /** + * Permanently deletes a specific version of a voice design. The version number must be a + * positive integer. + */ + fun deleteVersion(version: Long, params: VoiceDesignDeleteVersionParams) = + deleteVersion(version, params, RequestOptions.none()) + + /** @see deleteVersion */ + fun deleteVersion( + version: Long, + params: VoiceDesignDeleteVersionParams, + requestOptions: RequestOptions = RequestOptions.none(), + ) = deleteVersion(params.toBuilder().version(version).build(), requestOptions) + + /** @see deleteVersion */ + fun deleteVersion(params: VoiceDesignDeleteVersionParams) = + deleteVersion(params, RequestOptions.none()) + + /** @see deleteVersion */ + fun deleteVersion( + params: VoiceDesignDeleteVersionParams, + requestOptions: RequestOptions = RequestOptions.none(), + ) + + /** + * Downloads the WAV audio sample for the voice design. Returns the latest version's sample by + * default, or a specific version when `?version=N` is provided. The `id` parameter accepts + * either a UUID or the design name. + */ + @MustBeClosed + fun downloadSample(id: String): HttpResponse = + downloadSample(id, VoiceDesignDownloadSampleParams.none()) + + /** @see downloadSample */ + @MustBeClosed + fun downloadSample( + id: String, + params: VoiceDesignDownloadSampleParams = VoiceDesignDownloadSampleParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse = downloadSample(params.toBuilder().id(id).build(), requestOptions) + + /** @see downloadSample */ + @MustBeClosed + fun downloadSample( + id: String, + params: VoiceDesignDownloadSampleParams = VoiceDesignDownloadSampleParams.none(), + ): HttpResponse = downloadSample(id, params, RequestOptions.none()) + + /** @see downloadSample */ + @MustBeClosed + fun downloadSample( + params: VoiceDesignDownloadSampleParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse + + /** @see downloadSample */ + @MustBeClosed + fun downloadSample(params: VoiceDesignDownloadSampleParams): HttpResponse = + downloadSample(params, RequestOptions.none()) + + /** @see downloadSample */ + @MustBeClosed + fun downloadSample(id: String, requestOptions: RequestOptions): HttpResponse = + downloadSample(id, VoiceDesignDownloadSampleParams.none(), requestOptions) + + /** Updates the name of a voice design. All versions retain their other properties. */ + fun rename(id: String, params: VoiceDesignRenameParams): VoiceDesignRenameResponse = + rename(id, params, RequestOptions.none()) + + /** @see rename */ + fun rename( + id: String, + params: VoiceDesignRenameParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): VoiceDesignRenameResponse = rename(params.toBuilder().id(id).build(), requestOptions) + + /** @see rename */ + fun rename(params: VoiceDesignRenameParams): VoiceDesignRenameResponse = + rename(params, RequestOptions.none()) + + /** @see rename */ + fun rename( + params: VoiceDesignRenameParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): VoiceDesignRenameResponse + + /** + * A view of [VoiceDesignService] 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 + ): VoiceDesignService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /voice_designs`, but is otherwise the same as + * [VoiceDesignService.create]. + */ + @MustBeClosed + fun create(params: VoiceDesignCreateParams): HttpResponseFor = + create(params, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + params: VoiceDesignCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /voice_designs/{id}`, but is otherwise the same as + * [VoiceDesignService.retrieve]. + */ + @MustBeClosed + fun retrieve(id: String): HttpResponseFor = + retrieve(id, VoiceDesignRetrieveParams.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + id: String, + params: VoiceDesignRetrieveParams = VoiceDesignRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieve(params.toBuilder().id(id).build(), requestOptions) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + id: String, + params: VoiceDesignRetrieveParams = VoiceDesignRetrieveParams.none(), + ): HttpResponseFor = + retrieve(id, params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + params: VoiceDesignRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + params: VoiceDesignRetrieveParams + ): HttpResponseFor = retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + id: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + retrieve(id, VoiceDesignRetrieveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /voice_designs`, but is otherwise the same as + * [VoiceDesignService.list]. + */ + @MustBeClosed + fun list(): HttpResponseFor = list(VoiceDesignListParams.none()) + + /** @see list */ + @MustBeClosed + fun list( + params: VoiceDesignListParams = VoiceDesignListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see list */ + @MustBeClosed + fun list( + params: VoiceDesignListParams = VoiceDesignListParams.none() + ): HttpResponseFor = list(params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list(requestOptions: RequestOptions): HttpResponseFor = + list(VoiceDesignListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /voice_designs/{id}`, but is otherwise the same + * as [VoiceDesignService.delete]. + */ + @MustBeClosed + fun delete(id: String): HttpResponse = delete(id, VoiceDesignDeleteParams.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + id: String, + params: VoiceDesignDeleteParams = VoiceDesignDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse = delete(params.toBuilder().id(id).build(), requestOptions) + + /** @see delete */ + @MustBeClosed + fun delete( + id: String, + params: VoiceDesignDeleteParams = VoiceDesignDeleteParams.none(), + ): HttpResponse = delete(id, params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + params: VoiceDesignDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse + + /** @see delete */ + @MustBeClosed + fun delete(params: VoiceDesignDeleteParams): HttpResponse = + delete(params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete(id: String, requestOptions: RequestOptions): HttpResponse = + delete(id, VoiceDesignDeleteParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /voice_designs/{id}/versions/{version}`, but is + * otherwise the same as [VoiceDesignService.deleteVersion]. + */ + @MustBeClosed + fun deleteVersion(version: Long, params: VoiceDesignDeleteVersionParams): HttpResponse = + deleteVersion(version, params, RequestOptions.none()) + + /** @see deleteVersion */ + @MustBeClosed + fun deleteVersion( + version: Long, + params: VoiceDesignDeleteVersionParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse = deleteVersion(params.toBuilder().version(version).build(), requestOptions) + + /** @see deleteVersion */ + @MustBeClosed + fun deleteVersion(params: VoiceDesignDeleteVersionParams): HttpResponse = + deleteVersion(params, RequestOptions.none()) + + /** @see deleteVersion */ + @MustBeClosed + fun deleteVersion( + params: VoiceDesignDeleteVersionParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse + + /** + * Returns a raw HTTP response for `get /voice_designs/{id}/sample`, but is otherwise the + * same as [VoiceDesignService.downloadSample]. + */ + @MustBeClosed + fun downloadSample(id: String): HttpResponse = + downloadSample(id, VoiceDesignDownloadSampleParams.none()) + + /** @see downloadSample */ + @MustBeClosed + fun downloadSample( + id: String, + params: VoiceDesignDownloadSampleParams = VoiceDesignDownloadSampleParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse = downloadSample(params.toBuilder().id(id).build(), requestOptions) + + /** @see downloadSample */ + @MustBeClosed + fun downloadSample( + id: String, + params: VoiceDesignDownloadSampleParams = VoiceDesignDownloadSampleParams.none(), + ): HttpResponse = downloadSample(id, params, RequestOptions.none()) + + /** @see downloadSample */ + @MustBeClosed + fun downloadSample( + params: VoiceDesignDownloadSampleParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse + + /** @see downloadSample */ + @MustBeClosed + fun downloadSample(params: VoiceDesignDownloadSampleParams): HttpResponse = + downloadSample(params, RequestOptions.none()) + + /** @see downloadSample */ + @MustBeClosed + fun downloadSample(id: String, requestOptions: RequestOptions): HttpResponse = + downloadSample(id, VoiceDesignDownloadSampleParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `patch /voice_designs/{id}`, but is otherwise the same as + * [VoiceDesignService.rename]. + */ + @MustBeClosed + fun rename( + id: String, + params: VoiceDesignRenameParams, + ): HttpResponseFor = rename(id, params, RequestOptions.none()) + + /** @see rename */ + @MustBeClosed + fun rename( + id: String, + params: VoiceDesignRenameParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + rename(params.toBuilder().id(id).build(), requestOptions) + + /** @see rename */ + @MustBeClosed + fun rename(params: VoiceDesignRenameParams): HttpResponseFor = + rename(params, RequestOptions.none()) + + /** @see rename */ + @MustBeClosed + fun rename( + params: VoiceDesignRenameParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + } +} diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/blocking/VoiceDesignServiceImpl.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/blocking/VoiceDesignServiceImpl.kt new file mode 100644 index 000000000..f161bf320 --- /dev/null +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/blocking/VoiceDesignServiceImpl.kt @@ -0,0 +1,305 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.services.blocking + +import com.telnyx.sdk.core.ClientOptions +import com.telnyx.sdk.core.RequestOptions +import com.telnyx.sdk.core.checkRequired +import com.telnyx.sdk.core.handlers.emptyHandler +import com.telnyx.sdk.core.handlers.errorBodyHandler +import com.telnyx.sdk.core.handlers.errorHandler +import com.telnyx.sdk.core.handlers.jsonHandler +import com.telnyx.sdk.core.http.HttpMethod +import com.telnyx.sdk.core.http.HttpRequest +import com.telnyx.sdk.core.http.HttpResponse +import com.telnyx.sdk.core.http.HttpResponse.Handler +import com.telnyx.sdk.core.http.HttpResponseFor +import com.telnyx.sdk.core.http.json +import com.telnyx.sdk.core.http.parseable +import com.telnyx.sdk.core.prepare +import com.telnyx.sdk.models.voicedesigns.VoiceDesignCreateParams +import com.telnyx.sdk.models.voicedesigns.VoiceDesignCreateResponse +import com.telnyx.sdk.models.voicedesigns.VoiceDesignDeleteParams +import com.telnyx.sdk.models.voicedesigns.VoiceDesignDeleteVersionParams +import com.telnyx.sdk.models.voicedesigns.VoiceDesignDownloadSampleParams +import com.telnyx.sdk.models.voicedesigns.VoiceDesignListPage +import com.telnyx.sdk.models.voicedesigns.VoiceDesignListPageResponse +import com.telnyx.sdk.models.voicedesigns.VoiceDesignListParams +import com.telnyx.sdk.models.voicedesigns.VoiceDesignRenameParams +import com.telnyx.sdk.models.voicedesigns.VoiceDesignRenameResponse +import com.telnyx.sdk.models.voicedesigns.VoiceDesignRetrieveParams +import com.telnyx.sdk.models.voicedesigns.VoiceDesignRetrieveResponse +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +/** Create and manage AI-generated voice designs using natural language prompts. */ +class VoiceDesignServiceImpl internal constructor(private val clientOptions: ClientOptions) : + VoiceDesignService { + + private val withRawResponse: VoiceDesignService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): VoiceDesignService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): VoiceDesignService = + VoiceDesignServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: VoiceDesignCreateParams, + requestOptions: RequestOptions, + ): VoiceDesignCreateResponse = + // post /voice_designs + withRawResponse().create(params, requestOptions).parse() + + override fun retrieve( + params: VoiceDesignRetrieveParams, + requestOptions: RequestOptions, + ): VoiceDesignRetrieveResponse = + // get /voice_designs/{id} + withRawResponse().retrieve(params, requestOptions).parse() + + override fun list( + params: VoiceDesignListParams, + requestOptions: RequestOptions, + ): VoiceDesignListPage = + // get /voice_designs + withRawResponse().list(params, requestOptions).parse() + + override fun delete(params: VoiceDesignDeleteParams, requestOptions: RequestOptions) { + // delete /voice_designs/{id} + withRawResponse().delete(params, requestOptions) + } + + override fun deleteVersion( + params: VoiceDesignDeleteVersionParams, + requestOptions: RequestOptions, + ) { + // delete /voice_designs/{id}/versions/{version} + withRawResponse().deleteVersion(params, requestOptions) + } + + override fun downloadSample( + params: VoiceDesignDownloadSampleParams, + requestOptions: RequestOptions, + ): HttpResponse = + // get /voice_designs/{id}/sample + withRawResponse().downloadSample(params, requestOptions) + + override fun rename( + params: VoiceDesignRenameParams, + requestOptions: RequestOptions, + ): VoiceDesignRenameResponse = + // patch /voice_designs/{id} + withRawResponse().rename(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + VoiceDesignService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): VoiceDesignService.WithRawResponse = + VoiceDesignServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun create( + params: VoiceDesignCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("voice_designs") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieve( + params: VoiceDesignRetrieveParams, + 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("voice_designs", 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: VoiceDesignListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("voice_designs") + .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() + } + } + .let { + VoiceDesignListPage.builder() + .service(VoiceDesignServiceImpl(clientOptions)) + .params(params) + .response(it) + .build() + } + } + } + + private val deleteHandler: Handler = emptyHandler() + + override fun delete( + params: VoiceDesignDeleteParams, + requestOptions: RequestOptions, + ): HttpResponse { + // 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.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("voice_designs", params._pathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response.use { deleteHandler.handle(it) } + } + } + + private val deleteVersionHandler: Handler = emptyHandler() + + override fun deleteVersion( + params: VoiceDesignDeleteVersionParams, + requestOptions: RequestOptions, + ): HttpResponse { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("version", params.version().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "voice_designs", + params._pathParam(0), + "versions", + params._pathParam(1), + ) + .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 { deleteVersionHandler.handle(it) } + } + } + + override fun downloadSample( + params: VoiceDesignDownloadSampleParams, + requestOptions: RequestOptions, + ): HttpResponse { + // 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("voice_designs", params._pathParam(0), "sample") + .putHeader("Accept", "audio/wav") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response) + } + + private val renameHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun rename( + params: VoiceDesignRenameParams, + 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.PATCH) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("voice_designs", 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 { renameHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/blocking/X402Service.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/blocking/X402Service.kt new file mode 100644 index 000000000..f169e5c6f --- /dev/null +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/blocking/X402Service.kt @@ -0,0 +1,45 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.services.blocking + +import com.telnyx.sdk.core.ClientOptions +import com.telnyx.sdk.services.blocking.x402.CreditAccountService +import java.util.function.Consumer + +interface X402Service { + + /** + * 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): X402Service + + /** + * Operations for x402 cryptocurrency payment transactions. Fund your Telnyx account using USDC + * stablecoin payments via the x402 protocol. + */ + fun creditAccount(): CreditAccountService + + /** A view of [X402Service] 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): X402Service.WithRawResponse + + /** + * Operations for x402 cryptocurrency payment transactions. Fund your Telnyx account using + * USDC stablecoin payments via the x402 protocol. + */ + fun creditAccount(): CreditAccountService.WithRawResponse + } +} diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/blocking/X402ServiceImpl.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/blocking/X402ServiceImpl.kt new file mode 100644 index 000000000..809beff58 --- /dev/null +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/blocking/X402ServiceImpl.kt @@ -0,0 +1,51 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.services.blocking + +import com.telnyx.sdk.core.ClientOptions +import com.telnyx.sdk.services.blocking.x402.CreditAccountService +import com.telnyx.sdk.services.blocking.x402.CreditAccountServiceImpl +import java.util.function.Consumer + +class X402ServiceImpl internal constructor(private val clientOptions: ClientOptions) : X402Service { + + private val withRawResponse: X402Service.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val creditAccount: CreditAccountService by lazy { + CreditAccountServiceImpl(clientOptions) + } + + override fun withRawResponse(): X402Service.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): X402Service = + X402ServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + /** + * Operations for x402 cryptocurrency payment transactions. Fund your Telnyx account using USDC + * stablecoin payments via the x402 protocol. + */ + override fun creditAccount(): CreditAccountService = creditAccount + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + X402Service.WithRawResponse { + + private val creditAccount: CreditAccountService.WithRawResponse by lazy { + CreditAccountServiceImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer + ): X402Service.WithRawResponse = + X402ServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + /** + * Operations for x402 cryptocurrency payment transactions. Fund your Telnyx account using + * USDC stablecoin payments via the x402 protocol. + */ + override fun creditAccount(): CreditAccountService.WithRawResponse = creditAccount + } +} diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/blocking/recordings/ActionService.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/blocking/recordings/ActionService.kt index e8f350333..5b9440be9 100644 --- a/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/blocking/recordings/ActionService.kt +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/blocking/recordings/ActionService.kt @@ -5,8 +5,9 @@ package com.telnyx.sdk.services.blocking.recordings import com.google.errorprone.annotations.MustBeClosed import com.telnyx.sdk.core.ClientOptions import com.telnyx.sdk.core.RequestOptions -import com.telnyx.sdk.core.http.HttpResponse +import com.telnyx.sdk.core.http.HttpResponseFor import com.telnyx.sdk.models.recordings.actions.ActionDeleteParams +import com.telnyx.sdk.models.recordings.actions.ActionDeleteResponse import java.util.function.Consumer /** Call Recordings operations. */ @@ -25,10 +26,14 @@ interface ActionService { fun withOptions(modifier: Consumer): ActionService /** Permanently deletes a list of call recordings. */ - fun delete(params: ActionDeleteParams) = delete(params, RequestOptions.none()) + fun delete(params: ActionDeleteParams): ActionDeleteResponse = + delete(params, RequestOptions.none()) /** @see delete */ - fun delete(params: ActionDeleteParams, requestOptions: RequestOptions = RequestOptions.none()) + fun delete( + params: ActionDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): ActionDeleteResponse /** A view of [ActionService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -45,13 +50,14 @@ interface ActionService { * same as [ActionService.delete]. */ @MustBeClosed - fun delete(params: ActionDeleteParams): HttpResponse = delete(params, RequestOptions.none()) + fun delete(params: ActionDeleteParams): HttpResponseFor = + delete(params, RequestOptions.none()) /** @see delete */ @MustBeClosed fun delete( params: ActionDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponse + ): HttpResponseFor } } diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/blocking/recordings/ActionServiceImpl.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/blocking/recordings/ActionServiceImpl.kt index c3703360e..373c923d5 100644 --- a/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/blocking/recordings/ActionServiceImpl.kt +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/blocking/recordings/ActionServiceImpl.kt @@ -4,17 +4,19 @@ package com.telnyx.sdk.services.blocking.recordings import com.telnyx.sdk.core.ClientOptions import com.telnyx.sdk.core.RequestOptions -import com.telnyx.sdk.core.handlers.emptyHandler import com.telnyx.sdk.core.handlers.errorBodyHandler import com.telnyx.sdk.core.handlers.errorHandler +import com.telnyx.sdk.core.handlers.jsonHandler import com.telnyx.sdk.core.http.HttpMethod import com.telnyx.sdk.core.http.HttpRequest import com.telnyx.sdk.core.http.HttpResponse import com.telnyx.sdk.core.http.HttpResponse.Handler +import com.telnyx.sdk.core.http.HttpResponseFor import com.telnyx.sdk.core.http.json import com.telnyx.sdk.core.http.parseable import com.telnyx.sdk.core.prepare import com.telnyx.sdk.models.recordings.actions.ActionDeleteParams +import com.telnyx.sdk.models.recordings.actions.ActionDeleteResponse import java.util.function.Consumer /** Call Recordings operations. */ @@ -30,10 +32,12 @@ class ActionServiceImpl internal constructor(private val clientOptions: ClientOp override fun withOptions(modifier: Consumer): ActionService = ActionServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - override fun delete(params: ActionDeleteParams, requestOptions: RequestOptions) { + override fun delete( + params: ActionDeleteParams, + requestOptions: RequestOptions, + ): ActionDeleteResponse = // post /recordings/actions/delete - withRawResponse().delete(params, requestOptions) - } + withRawResponse().delete(params, requestOptions).parse() class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : ActionService.WithRawResponse { @@ -48,12 +52,13 @@ class ActionServiceImpl internal constructor(private val clientOptions: ClientOp clientOptions.toBuilder().apply(modifier::accept).build() ) - private val deleteHandler: Handler = emptyHandler() + private val deleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper) override fun delete( params: ActionDeleteParams, requestOptions: RequestOptions, - ): HttpResponse { + ): HttpResponseFor { val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -65,7 +70,13 @@ class ActionServiceImpl internal constructor(private val clientOptions: ClientOp val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return errorHandler.handle(response).parseable { - response.use { deleteHandler.handle(it) } + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } } } diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/blocking/x402/CreditAccountService.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/blocking/x402/CreditAccountService.kt new file mode 100644 index 000000000..dfea8c880 --- /dev/null +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/blocking/x402/CreditAccountService.kt @@ -0,0 +1,109 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.services.blocking.x402 + +import com.google.errorprone.annotations.MustBeClosed +import com.telnyx.sdk.core.ClientOptions +import com.telnyx.sdk.core.RequestOptions +import com.telnyx.sdk.core.http.HttpResponseFor +import com.telnyx.sdk.models.x402.creditaccount.CreditAccountCreateQuoteParams +import com.telnyx.sdk.models.x402.creditaccount.CreditAccountCreateQuoteResponse +import com.telnyx.sdk.models.x402.creditaccount.CreditAccountSettleParams +import com.telnyx.sdk.models.x402.creditaccount.CreditAccountSettleResponse +import java.util.function.Consumer + +/** + * Operations for x402 cryptocurrency payment transactions. Fund your Telnyx account using USDC + * stablecoin payments via the x402 protocol. + */ +interface CreditAccountService { + + /** + * 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): CreditAccountService + + /** + * Creates a payment quote for the specified USD amount. Returns payment details including the + * x402 payment requirements, network, and expiration time. The quote must be settled before it + * expires. + */ + fun createQuote(params: CreditAccountCreateQuoteParams): CreditAccountCreateQuoteResponse = + createQuote(params, RequestOptions.none()) + + /** @see createQuote */ + fun createQuote( + params: CreditAccountCreateQuoteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CreditAccountCreateQuoteResponse + + /** + * Settles an x402 payment using the quote ID and a signed payment authorization. The payment + * signature can be provided via the `PAYMENT-SIGNATURE` header or the `payment_signature` body + * parameter. Settlement is idempotent — submitting the same quote ID multiple times returns the + * existing transaction. + */ + fun settle(params: CreditAccountSettleParams): CreditAccountSettleResponse = + settle(params, RequestOptions.none()) + + /** @see settle */ + fun settle( + params: CreditAccountSettleParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CreditAccountSettleResponse + + /** + * A view of [CreditAccountService] 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 + ): CreditAccountService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /v2/x402/credit_account/quote`, but is otherwise + * the same as [CreditAccountService.createQuote]. + */ + @MustBeClosed + fun createQuote( + params: CreditAccountCreateQuoteParams + ): HttpResponseFor = + createQuote(params, RequestOptions.none()) + + /** @see createQuote */ + @MustBeClosed + fun createQuote( + params: CreditAccountCreateQuoteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `post /v2/x402/credit_account`, but is otherwise the same + * as [CreditAccountService.settle]. + */ + @MustBeClosed + fun settle( + params: CreditAccountSettleParams + ): HttpResponseFor = settle(params, RequestOptions.none()) + + /** @see settle */ + @MustBeClosed + fun settle( + params: CreditAccountSettleParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + } +} diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/blocking/x402/CreditAccountServiceImpl.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/blocking/x402/CreditAccountServiceImpl.kt new file mode 100644 index 000000000..6b6559fca --- /dev/null +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/blocking/x402/CreditAccountServiceImpl.kt @@ -0,0 +1,123 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.services.blocking.x402 + +import com.telnyx.sdk.core.ClientOptions +import com.telnyx.sdk.core.RequestOptions +import com.telnyx.sdk.core.handlers.errorBodyHandler +import com.telnyx.sdk.core.handlers.errorHandler +import com.telnyx.sdk.core.handlers.jsonHandler +import com.telnyx.sdk.core.http.HttpMethod +import com.telnyx.sdk.core.http.HttpRequest +import com.telnyx.sdk.core.http.HttpResponse +import com.telnyx.sdk.core.http.HttpResponse.Handler +import com.telnyx.sdk.core.http.HttpResponseFor +import com.telnyx.sdk.core.http.json +import com.telnyx.sdk.core.http.parseable +import com.telnyx.sdk.core.prepare +import com.telnyx.sdk.models.x402.creditaccount.CreditAccountCreateQuoteParams +import com.telnyx.sdk.models.x402.creditaccount.CreditAccountCreateQuoteResponse +import com.telnyx.sdk.models.x402.creditaccount.CreditAccountSettleParams +import com.telnyx.sdk.models.x402.creditaccount.CreditAccountSettleResponse +import java.util.function.Consumer + +/** + * Operations for x402 cryptocurrency payment transactions. Fund your Telnyx account using USDC + * stablecoin payments via the x402 protocol. + */ +class CreditAccountServiceImpl internal constructor(private val clientOptions: ClientOptions) : + CreditAccountService { + + private val withRawResponse: CreditAccountService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): CreditAccountService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): CreditAccountService = + CreditAccountServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun createQuote( + params: CreditAccountCreateQuoteParams, + requestOptions: RequestOptions, + ): CreditAccountCreateQuoteResponse = + // post /v2/x402/credit_account/quote + withRawResponse().createQuote(params, requestOptions).parse() + + override fun settle( + params: CreditAccountSettleParams, + requestOptions: RequestOptions, + ): CreditAccountSettleResponse = + // post /v2/x402/credit_account + withRawResponse().settle(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + CreditAccountService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): CreditAccountService.WithRawResponse = + CreditAccountServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createQuoteHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun createQuote( + params: CreditAccountCreateQuoteParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v2", "x402", "credit_account", "quote") + .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 { createQuoteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val settleHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun settle( + params: CreditAccountSettleParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v2", "x402", "credit_account") + .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 { settleHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/ai/assistants/AssistantCreateParamsTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/ai/assistants/AssistantCreateParamsTest.kt index d17dd1562..3c60d087b 100644 --- a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/ai/assistants/AssistantCreateParamsTest.kt +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/ai/assistants/AssistantCreateParamsTest.kt @@ -172,6 +172,7 @@ internal class AssistantCreateParamsTest { .predefinedMediaBackgroundAudio( VoiceSettings.BackgroundAudio.PredefinedMedia.PredefinedMediaValue.SILENCE ) + .expressiveMode(true) .languageBoost(VoiceSettings.LanguageBoost.AUTO) .similarityBoost(0.0) .speed(0.0) @@ -372,6 +373,7 @@ internal class AssistantCreateParamsTest { VoiceSettings.BackgroundAudio.PredefinedMedia.PredefinedMediaValue .SILENCE ) + .expressiveMode(true) .languageBoost(VoiceSettings.LanguageBoost.AUTO) .similarityBoost(0.0) .speed(0.0) @@ -598,6 +600,7 @@ internal class AssistantCreateParamsTest { .predefinedMediaBackgroundAudio( VoiceSettings.BackgroundAudio.PredefinedMedia.PredefinedMediaValue.SILENCE ) + .expressiveMode(true) .languageBoost(VoiceSettings.LanguageBoost.AUTO) .similarityBoost(0.0) .speed(0.0) diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/ai/assistants/AssistantUpdateParamsTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/ai/assistants/AssistantUpdateParamsTest.kt index 9421736a3..f5e5a852d 100644 --- a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/ai/assistants/AssistantUpdateParamsTest.kt +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/ai/assistants/AssistantUpdateParamsTest.kt @@ -174,6 +174,7 @@ internal class AssistantUpdateParamsTest { .predefinedMediaBackgroundAudio( VoiceSettings.BackgroundAudio.PredefinedMedia.PredefinedMediaValue.SILENCE ) + .expressiveMode(true) .languageBoost(VoiceSettings.LanguageBoost.AUTO) .similarityBoost(0.0) .speed(0.0) @@ -385,6 +386,7 @@ internal class AssistantUpdateParamsTest { VoiceSettings.BackgroundAudio.PredefinedMedia.PredefinedMediaValue .SILENCE ) + .expressiveMode(true) .languageBoost(VoiceSettings.LanguageBoost.AUTO) .similarityBoost(0.0) .speed(0.0) @@ -612,6 +614,7 @@ internal class AssistantUpdateParamsTest { .predefinedMediaBackgroundAudio( VoiceSettings.BackgroundAudio.PredefinedMedia.PredefinedMediaValue.SILENCE ) + .expressiveMode(true) .languageBoost(VoiceSettings.LanguageBoost.AUTO) .similarityBoost(0.0) .speed(0.0) diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/ai/assistants/AssistantsListTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/ai/assistants/AssistantsListTest.kt index e97d42702..604228fda 100644 --- a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/ai/assistants/AssistantsListTest.kt +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/ai/assistants/AssistantsListTest.kt @@ -214,6 +214,7 @@ internal class AssistantsListTest { .PredefinedMediaValue .SILENCE ) + .expressiveMode(true) .languageBoost(VoiceSettings.LanguageBoost.AUTO) .similarityBoost(0.0) .speed(0.0) @@ -431,6 +432,7 @@ internal class AssistantsListTest { VoiceSettings.BackgroundAudio.PredefinedMedia.PredefinedMediaValue .SILENCE ) + .expressiveMode(true) .languageBoost(VoiceSettings.LanguageBoost.AUTO) .similarityBoost(0.0) .speed(0.0) @@ -668,6 +670,7 @@ internal class AssistantsListTest { .PredefinedMediaValue .SILENCE ) + .expressiveMode(true) .languageBoost(VoiceSettings.LanguageBoost.AUTO) .similarityBoost(0.0) .speed(0.0) diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/ai/assistants/InferenceEmbeddingTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/ai/assistants/InferenceEmbeddingTest.kt index 561527e17..4ae893f16 100644 --- a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/ai/assistants/InferenceEmbeddingTest.kt +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/ai/assistants/InferenceEmbeddingTest.kt @@ -188,6 +188,7 @@ internal class InferenceEmbeddingTest { VoiceSettings.BackgroundAudio.PredefinedMedia.PredefinedMediaValue .SILENCE ) + .expressiveMode(true) .languageBoost(VoiceSettings.LanguageBoost.AUTO) .similarityBoost(0.0) .speed(0.0) @@ -424,6 +425,7 @@ internal class InferenceEmbeddingTest { .predefinedMediaBackgroundAudio( VoiceSettings.BackgroundAudio.PredefinedMedia.PredefinedMediaValue.SILENCE ) + .expressiveMode(true) .languageBoost(VoiceSettings.LanguageBoost.AUTO) .similarityBoost(0.0) .speed(0.0) @@ -633,6 +635,7 @@ internal class InferenceEmbeddingTest { VoiceSettings.BackgroundAudio.PredefinedMedia.PredefinedMediaValue .SILENCE ) + .expressiveMode(true) .languageBoost(VoiceSettings.LanguageBoost.AUTO) .similarityBoost(0.0) .speed(0.0) diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/ai/assistants/VoiceSettingsTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/ai/assistants/VoiceSettingsTest.kt index 8cdb3c277..27735c24a 100644 --- a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/ai/assistants/VoiceSettingsTest.kt +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/ai/assistants/VoiceSettingsTest.kt @@ -18,6 +18,7 @@ internal class VoiceSettingsTest { .predefinedMediaBackgroundAudio( VoiceSettings.BackgroundAudio.PredefinedMedia.PredefinedMediaValue.SILENCE ) + .expressiveMode(true) .languageBoost(VoiceSettings.LanguageBoost.AUTO) .similarityBoost(0.0) .speed(0.0) @@ -40,6 +41,7 @@ internal class VoiceSettingsTest { .build() ) ) + assertThat(voiceSettings.expressiveMode()).contains(true) assertThat(voiceSettings.languageBoost()).contains(VoiceSettings.LanguageBoost.AUTO) assertThat(voiceSettings.similarityBoost()).contains(0.0) assertThat(voiceSettings.speed()).contains(0.0) @@ -59,6 +61,7 @@ internal class VoiceSettingsTest { .predefinedMediaBackgroundAudio( VoiceSettings.BackgroundAudio.PredefinedMedia.PredefinedMediaValue.SILENCE ) + .expressiveMode(true) .languageBoost(VoiceSettings.LanguageBoost.AUTO) .similarityBoost(0.0) .speed(0.0) diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/ai/assistants/versions/UpdateAssistantTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/ai/assistants/versions/UpdateAssistantTest.kt index f1bd281eb..e889dcd22 100644 --- a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/ai/assistants/versions/UpdateAssistantTest.kt +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/ai/assistants/versions/UpdateAssistantTest.kt @@ -191,6 +191,7 @@ internal class UpdateAssistantTest { VoiceSettings.BackgroundAudio.PredefinedMedia.PredefinedMediaValue .SILENCE ) + .expressiveMode(true) .languageBoost(VoiceSettings.LanguageBoost.AUTO) .similarityBoost(0.0) .speed(0.0) @@ -417,6 +418,7 @@ internal class UpdateAssistantTest { .predefinedMediaBackgroundAudio( VoiceSettings.BackgroundAudio.PredefinedMedia.PredefinedMediaValue.SILENCE ) + .expressiveMode(true) .languageBoost(VoiceSettings.LanguageBoost.AUTO) .similarityBoost(0.0) .speed(0.0) @@ -618,6 +620,7 @@ internal class UpdateAssistantTest { VoiceSettings.BackgroundAudio.PredefinedMedia.PredefinedMediaValue .SILENCE ) + .expressiveMode(true) .languageBoost(VoiceSettings.LanguageBoost.AUTO) .similarityBoost(0.0) .speed(0.0) diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/ai/assistants/versions/VersionUpdateParamsTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/ai/assistants/versions/VersionUpdateParamsTest.kt index b2341281f..62763e7af 100644 --- a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/ai/assistants/versions/VersionUpdateParamsTest.kt +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/ai/assistants/versions/VersionUpdateParamsTest.kt @@ -199,6 +199,7 @@ internal class VersionUpdateParamsTest { VoiceSettings.BackgroundAudio.PredefinedMedia.PredefinedMediaValue .SILENCE ) + .expressiveMode(true) .languageBoost(VoiceSettings.LanguageBoost.AUTO) .similarityBoost(0.0) .speed(0.0) @@ -445,6 +446,7 @@ internal class VersionUpdateParamsTest { .PredefinedMediaValue .SILENCE ) + .expressiveMode(true) .languageBoost(VoiceSettings.LanguageBoost.AUTO) .similarityBoost(0.0) .speed(0.0) @@ -656,6 +658,7 @@ internal class VersionUpdateParamsTest { VoiceSettings.BackgroundAudio.PredefinedMedia.PredefinedMediaValue .SILENCE ) + .expressiveMode(true) .languageBoost(VoiceSettings.LanguageBoost.AUTO) .similarityBoost(0.0) .speed(0.0) diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/recordings/RecordingDeleteResponseTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/recordings/RecordingDeleteResponseTest.kt index f23ff8891..ec90c12eb 100644 --- a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/recordings/RecordingDeleteResponseTest.kt +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/recordings/RecordingDeleteResponseTest.kt @@ -21,6 +21,7 @@ internal class RecordingDeleteResponseTest { .callSessionId("84a97d76-e40f-11ed-9074-02420a0daa69") .channels(RecordingResponseData.Channels.DUAL) .conferenceId("84a97d76-e40f-11ed-9074-02420a0daa69") + .connectionId("175237942907135762") .createdAt("2018-02-02T22:25:27.521Z") .downloadUrls( RecordingResponseData.DownloadUrls.builder() @@ -29,11 +30,14 @@ internal class RecordingDeleteResponseTest { .build() ) .durationMillis(60000) + .from("+15551234567") + .initiatedBy("StartCallRecordingAPI") .recordType(RecordingResponseData.RecordType.RECORDING) .recordingEndedAt("2019-01-23T18:10:02.574Z") .recordingStartedAt("2019-01-23T18:10:02.574Z") .source(RecordingResponseData.Source.CONFERENCE) .status(RecordingResponseData.Status.COMPLETED) + .to("+15557654321") .updatedAt("2018-02-02T22:25:27.521Z") .build() ) @@ -48,16 +52,20 @@ internal class RecordingDeleteResponseTest { .callSessionId("84a97d76-e40f-11ed-9074-02420a0daa69") .channels(RecordingResponseData.Channels.DUAL) .conferenceId("84a97d76-e40f-11ed-9074-02420a0daa69") + .connectionId("175237942907135762") .createdAt("2018-02-02T22:25:27.521Z") .downloadUrls( RecordingResponseData.DownloadUrls.builder().mp3("mp3").wav("wav").build() ) .durationMillis(60000) + .from("+15551234567") + .initiatedBy("StartCallRecordingAPI") .recordType(RecordingResponseData.RecordType.RECORDING) .recordingEndedAt("2019-01-23T18:10:02.574Z") .recordingStartedAt("2019-01-23T18:10:02.574Z") .source(RecordingResponseData.Source.CONFERENCE) .status(RecordingResponseData.Status.COMPLETED) + .to("+15557654321") .updatedAt("2018-02-02T22:25:27.521Z") .build() ) @@ -76,6 +84,7 @@ internal class RecordingDeleteResponseTest { .callSessionId("84a97d76-e40f-11ed-9074-02420a0daa69") .channels(RecordingResponseData.Channels.DUAL) .conferenceId("84a97d76-e40f-11ed-9074-02420a0daa69") + .connectionId("175237942907135762") .createdAt("2018-02-02T22:25:27.521Z") .downloadUrls( RecordingResponseData.DownloadUrls.builder() @@ -84,11 +93,14 @@ internal class RecordingDeleteResponseTest { .build() ) .durationMillis(60000) + .from("+15551234567") + .initiatedBy("StartCallRecordingAPI") .recordType(RecordingResponseData.RecordType.RECORDING) .recordingEndedAt("2019-01-23T18:10:02.574Z") .recordingStartedAt("2019-01-23T18:10:02.574Z") .source(RecordingResponseData.Source.CONFERENCE) .status(RecordingResponseData.Status.COMPLETED) + .to("+15557654321") .updatedAt("2018-02-02T22:25:27.521Z") .build() ) diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/recordings/RecordingListPageResponseTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/recordings/RecordingListPageResponseTest.kt index 4a4bbd1ac..a807aac58 100644 --- a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/recordings/RecordingListPageResponseTest.kt +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/recordings/RecordingListPageResponseTest.kt @@ -23,6 +23,7 @@ internal class RecordingListPageResponseTest { .callSessionId("84a97d76-e40f-11ed-9074-02420a0daa69") .channels(RecordingResponseData.Channels.DUAL) .conferenceId("84a97d76-e40f-11ed-9074-02420a0daa69") + .connectionId("175237942907135762") .createdAt("2018-02-02T22:25:27.521Z") .downloadUrls( RecordingResponseData.DownloadUrls.builder() @@ -31,11 +32,14 @@ internal class RecordingListPageResponseTest { .build() ) .durationMillis(60000) + .from("+15551234567") + .initiatedBy("StartCallRecordingAPI") .recordType(RecordingResponseData.RecordType.RECORDING) .recordingEndedAt("2019-01-23T18:10:02.574Z") .recordingStartedAt("2019-01-23T18:10:02.574Z") .source(RecordingResponseData.Source.CONFERENCE) .status(RecordingResponseData.Status.COMPLETED) + .to("+15557654321") .updatedAt("2018-02-02T22:25:27.521Z") .build() ) @@ -58,16 +62,20 @@ internal class RecordingListPageResponseTest { .callSessionId("84a97d76-e40f-11ed-9074-02420a0daa69") .channels(RecordingResponseData.Channels.DUAL) .conferenceId("84a97d76-e40f-11ed-9074-02420a0daa69") + .connectionId("175237942907135762") .createdAt("2018-02-02T22:25:27.521Z") .downloadUrls( RecordingResponseData.DownloadUrls.builder().mp3("mp3").wav("wav").build() ) .durationMillis(60000) + .from("+15551234567") + .initiatedBy("StartCallRecordingAPI") .recordType(RecordingResponseData.RecordType.RECORDING) .recordingEndedAt("2019-01-23T18:10:02.574Z") .recordingStartedAt("2019-01-23T18:10:02.574Z") .source(RecordingResponseData.Source.CONFERENCE) .status(RecordingResponseData.Status.COMPLETED) + .to("+15557654321") .updatedAt("2018-02-02T22:25:27.521Z") .build() ) @@ -95,6 +103,7 @@ internal class RecordingListPageResponseTest { .callSessionId("84a97d76-e40f-11ed-9074-02420a0daa69") .channels(RecordingResponseData.Channels.DUAL) .conferenceId("84a97d76-e40f-11ed-9074-02420a0daa69") + .connectionId("175237942907135762") .createdAt("2018-02-02T22:25:27.521Z") .downloadUrls( RecordingResponseData.DownloadUrls.builder() @@ -103,11 +112,14 @@ internal class RecordingListPageResponseTest { .build() ) .durationMillis(60000) + .from("+15551234567") + .initiatedBy("StartCallRecordingAPI") .recordType(RecordingResponseData.RecordType.RECORDING) .recordingEndedAt("2019-01-23T18:10:02.574Z") .recordingStartedAt("2019-01-23T18:10:02.574Z") .source(RecordingResponseData.Source.CONFERENCE) .status(RecordingResponseData.Status.COMPLETED) + .to("+15557654321") .updatedAt("2018-02-02T22:25:27.521Z") .build() ) diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/recordings/RecordingListParamsTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/recordings/RecordingListParamsTest.kt index b267c754c..246e1dcdc 100644 --- a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/recordings/RecordingListParamsTest.kt +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/recordings/RecordingListParamsTest.kt @@ -13,9 +13,11 @@ internal class RecordingListParamsTest { RecordingListParams.builder() .filter( RecordingListParams.Filter.builder() + .callControlId("v3:e-31OnvjEM7Y4wvxr3TKNk8M3QyLcGZPiUIzCGtwQtOtEjY-B0urkw") .callLegId("428c31b6-7af4-4bcb-b7f5-5013ef9657c1") .callSessionId("428c31b6-7af4-4bcb-b7f5-5013ef9657c1") .conferenceId("428c31b6-7af4-4bcb-b7f5-5013ef9657c1") + .conferenceRegion("us") .connectionId("175237942907135762") .createdAt( RecordingListParams.Filter.CreatedAt.builder() @@ -23,8 +25,20 @@ internal class RecordingListParamsTest { .lte("2019-03-29T11:10:00Z") .build() ) + .endTime( + RecordingListParams.Filter.EndTime.builder() + .gte("2019-03-29T11:10:00Z") + .lte("2019-03-29T11:10:00Z") + .build() + ) .from("1234567890") .sipCallId("428c31b6-7af4-4bcb-b7f5-5013ef9657c1") + .startTime( + RecordingListParams.Filter.StartTime.builder() + .gte("2019-03-29T11:10:00Z") + .lte("2019-03-29T11:10:00Z") + .build() + ) .to("1234567890") .build() ) @@ -39,9 +53,11 @@ internal class RecordingListParamsTest { RecordingListParams.builder() .filter( RecordingListParams.Filter.builder() + .callControlId("v3:e-31OnvjEM7Y4wvxr3TKNk8M3QyLcGZPiUIzCGtwQtOtEjY-B0urkw") .callLegId("428c31b6-7af4-4bcb-b7f5-5013ef9657c1") .callSessionId("428c31b6-7af4-4bcb-b7f5-5013ef9657c1") .conferenceId("428c31b6-7af4-4bcb-b7f5-5013ef9657c1") + .conferenceRegion("us") .connectionId("175237942907135762") .createdAt( RecordingListParams.Filter.CreatedAt.builder() @@ -49,8 +65,20 @@ internal class RecordingListParamsTest { .lte("2019-03-29T11:10:00Z") .build() ) + .endTime( + RecordingListParams.Filter.EndTime.builder() + .gte("2019-03-29T11:10:00Z") + .lte("2019-03-29T11:10:00Z") + .build() + ) .from("1234567890") .sipCallId("428c31b6-7af4-4bcb-b7f5-5013ef9657c1") + .startTime( + RecordingListParams.Filter.StartTime.builder() + .gte("2019-03-29T11:10:00Z") + .lte("2019-03-29T11:10:00Z") + .build() + ) .to("1234567890") .build() ) @@ -63,14 +91,23 @@ internal class RecordingListParamsTest { assertThat(queryParams) .isEqualTo( QueryParams.builder() + .put( + "filter[call_control_id]", + "v3:e-31OnvjEM7Y4wvxr3TKNk8M3QyLcGZPiUIzCGtwQtOtEjY-B0urkw", + ) .put("filter[call_leg_id]", "428c31b6-7af4-4bcb-b7f5-5013ef9657c1") .put("filter[call_session_id]", "428c31b6-7af4-4bcb-b7f5-5013ef9657c1") .put("filter[conference_id]", "428c31b6-7af4-4bcb-b7f5-5013ef9657c1") + .put("filter[conference_region]", "us") .put("filter[connection_id]", "175237942907135762") .put("filter[created_at][gte]", "2019-03-29T11:10:00Z") .put("filter[created_at][lte]", "2019-03-29T11:10:00Z") + .put("filter[end_time][gte]", "2019-03-29T11:10:00Z") + .put("filter[end_time][lte]", "2019-03-29T11:10:00Z") .put("filter[from]", "1234567890") .put("filter[sip_call_id]", "428c31b6-7af4-4bcb-b7f5-5013ef9657c1") + .put("filter[start_time][gte]", "2019-03-29T11:10:00Z") + .put("filter[start_time][lte]", "2019-03-29T11:10:00Z") .put("filter[to]", "1234567890") .put("page[number]", "0") .put("page[size]", "0") diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/recordings/RecordingResponseDataTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/recordings/RecordingResponseDataTest.kt index 3f30dbfd2..b2fb197de 100644 --- a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/recordings/RecordingResponseDataTest.kt +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/recordings/RecordingResponseDataTest.kt @@ -19,16 +19,20 @@ internal class RecordingResponseDataTest { .callSessionId("84a97d76-e40f-11ed-9074-02420a0daa69") .channels(RecordingResponseData.Channels.DUAL) .conferenceId("84a97d76-e40f-11ed-9074-02420a0daa69") + .connectionId("175237942907135762") .createdAt("2018-02-02T22:25:27.521Z") .downloadUrls( RecordingResponseData.DownloadUrls.builder().mp3("mp3").wav("wav").build() ) .durationMillis(60000) + .from("+15551234567") + .initiatedBy("StartCallRecordingAPI") .recordType(RecordingResponseData.RecordType.RECORDING) .recordingEndedAt("2019-01-23T18:10:02.574Z") .recordingStartedAt("2019-01-23T18:10:02.574Z") .source(RecordingResponseData.Source.CONFERENCE) .status(RecordingResponseData.Status.COMPLETED) + .to("+15557654321") .updatedAt("2018-02-02T22:25:27.521Z") .build() @@ -42,16 +46,20 @@ internal class RecordingResponseDataTest { assertThat(recordingResponseData.channels()).contains(RecordingResponseData.Channels.DUAL) assertThat(recordingResponseData.conferenceId()) .contains("84a97d76-e40f-11ed-9074-02420a0daa69") + assertThat(recordingResponseData.connectionId()).contains("175237942907135762") assertThat(recordingResponseData.createdAt()).contains("2018-02-02T22:25:27.521Z") assertThat(recordingResponseData.downloadUrls()) .contains(RecordingResponseData.DownloadUrls.builder().mp3("mp3").wav("wav").build()) assertThat(recordingResponseData.durationMillis()).contains(60000) + assertThat(recordingResponseData.from()).contains("+15551234567") + assertThat(recordingResponseData.initiatedBy()).contains("StartCallRecordingAPI") assertThat(recordingResponseData.recordType()) .contains(RecordingResponseData.RecordType.RECORDING) assertThat(recordingResponseData.recordingEndedAt()).contains("2019-01-23T18:10:02.574Z") assertThat(recordingResponseData.recordingStartedAt()).contains("2019-01-23T18:10:02.574Z") assertThat(recordingResponseData.source()).contains(RecordingResponseData.Source.CONFERENCE) assertThat(recordingResponseData.status()).contains(RecordingResponseData.Status.COMPLETED) + assertThat(recordingResponseData.to()).contains("+15557654321") assertThat(recordingResponseData.updatedAt()).contains("2018-02-02T22:25:27.521Z") } @@ -66,16 +74,20 @@ internal class RecordingResponseDataTest { .callSessionId("84a97d76-e40f-11ed-9074-02420a0daa69") .channels(RecordingResponseData.Channels.DUAL) .conferenceId("84a97d76-e40f-11ed-9074-02420a0daa69") + .connectionId("175237942907135762") .createdAt("2018-02-02T22:25:27.521Z") .downloadUrls( RecordingResponseData.DownloadUrls.builder().mp3("mp3").wav("wav").build() ) .durationMillis(60000) + .from("+15551234567") + .initiatedBy("StartCallRecordingAPI") .recordType(RecordingResponseData.RecordType.RECORDING) .recordingEndedAt("2019-01-23T18:10:02.574Z") .recordingStartedAt("2019-01-23T18:10:02.574Z") .source(RecordingResponseData.Source.CONFERENCE) .status(RecordingResponseData.Status.COMPLETED) + .to("+15557654321") .updatedAt("2018-02-02T22:25:27.521Z") .build() diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/recordings/RecordingRetrieveResponseTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/recordings/RecordingRetrieveResponseTest.kt index 358e01b66..0d8a5c395 100644 --- a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/recordings/RecordingRetrieveResponseTest.kt +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/recordings/RecordingRetrieveResponseTest.kt @@ -21,6 +21,7 @@ internal class RecordingRetrieveResponseTest { .callSessionId("84a97d76-e40f-11ed-9074-02420a0daa69") .channels(RecordingResponseData.Channels.DUAL) .conferenceId("84a97d76-e40f-11ed-9074-02420a0daa69") + .connectionId("175237942907135762") .createdAt("2018-02-02T22:25:27.521Z") .downloadUrls( RecordingResponseData.DownloadUrls.builder() @@ -29,11 +30,14 @@ internal class RecordingRetrieveResponseTest { .build() ) .durationMillis(60000) + .from("+15551234567") + .initiatedBy("StartCallRecordingAPI") .recordType(RecordingResponseData.RecordType.RECORDING) .recordingEndedAt("2019-01-23T18:10:02.574Z") .recordingStartedAt("2019-01-23T18:10:02.574Z") .source(RecordingResponseData.Source.CONFERENCE) .status(RecordingResponseData.Status.COMPLETED) + .to("+15557654321") .updatedAt("2018-02-02T22:25:27.521Z") .build() ) @@ -48,16 +52,20 @@ internal class RecordingRetrieveResponseTest { .callSessionId("84a97d76-e40f-11ed-9074-02420a0daa69") .channels(RecordingResponseData.Channels.DUAL) .conferenceId("84a97d76-e40f-11ed-9074-02420a0daa69") + .connectionId("175237942907135762") .createdAt("2018-02-02T22:25:27.521Z") .downloadUrls( RecordingResponseData.DownloadUrls.builder().mp3("mp3").wav("wav").build() ) .durationMillis(60000) + .from("+15551234567") + .initiatedBy("StartCallRecordingAPI") .recordType(RecordingResponseData.RecordType.RECORDING) .recordingEndedAt("2019-01-23T18:10:02.574Z") .recordingStartedAt("2019-01-23T18:10:02.574Z") .source(RecordingResponseData.Source.CONFERENCE) .status(RecordingResponseData.Status.COMPLETED) + .to("+15557654321") .updatedAt("2018-02-02T22:25:27.521Z") .build() ) @@ -76,6 +84,7 @@ internal class RecordingRetrieveResponseTest { .callSessionId("84a97d76-e40f-11ed-9074-02420a0daa69") .channels(RecordingResponseData.Channels.DUAL) .conferenceId("84a97d76-e40f-11ed-9074-02420a0daa69") + .connectionId("175237942907135762") .createdAt("2018-02-02T22:25:27.521Z") .downloadUrls( RecordingResponseData.DownloadUrls.builder() @@ -84,11 +93,14 @@ internal class RecordingRetrieveResponseTest { .build() ) .durationMillis(60000) + .from("+15551234567") + .initiatedBy("StartCallRecordingAPI") .recordType(RecordingResponseData.RecordType.RECORDING) .recordingEndedAt("2019-01-23T18:10:02.574Z") .recordingStartedAt("2019-01-23T18:10:02.574Z") .source(RecordingResponseData.Source.CONFERENCE) .status(RecordingResponseData.Status.COMPLETED) + .to("+15557654321") .updatedAt("2018-02-02T22:25:27.521Z") .build() ) diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/recordings/actions/ActionDeleteResponseTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/recordings/actions/ActionDeleteResponseTest.kt new file mode 100644 index 000000000..126a3b9de --- /dev/null +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/recordings/actions/ActionDeleteResponseTest.kt @@ -0,0 +1,34 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.recordings.actions + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.telnyx.sdk.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ActionDeleteResponseTest { + + @Test + fun create() { + val actionDeleteResponse = + ActionDeleteResponse.builder().status(ActionDeleteResponse.Status.OK).build() + + assertThat(actionDeleteResponse.status()).contains(ActionDeleteResponse.Status.OK) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val actionDeleteResponse = + ActionDeleteResponse.builder().status(ActionDeleteResponse.Status.OK).build() + + val roundtrippedActionDeleteResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(actionDeleteResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedActionDeleteResponse).isEqualTo(actionDeleteResponse) + } +} diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/recordingtranscriptions/RecordingTranscriptionListResponseTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/recordingtranscriptions/RecordingTranscriptionListPageResponseTest.kt similarity index 87% rename from telnyx-core/src/test/kotlin/com/telnyx/sdk/models/recordingtranscriptions/RecordingTranscriptionListResponseTest.kt rename to telnyx-core/src/test/kotlin/com/telnyx/sdk/models/recordingtranscriptions/RecordingTranscriptionListPageResponseTest.kt index a8872222b..e3a22e9b4 100644 --- a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/recordingtranscriptions/RecordingTranscriptionListResponseTest.kt +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/recordingtranscriptions/RecordingTranscriptionListPageResponseTest.kt @@ -9,12 +9,12 @@ import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -internal class RecordingTranscriptionListResponseTest { +internal class RecordingTranscriptionListPageResponseTest { @Test fun create() { - val recordingTranscriptionListResponse = - RecordingTranscriptionListResponse.builder() + val recordingTranscriptionListPageResponse = + RecordingTranscriptionListPageResponse.builder() .addData( RecordingTranscription.builder() .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") @@ -28,7 +28,7 @@ internal class RecordingTranscriptionListResponseTest { .build() ) .meta( - RecordingTranscriptionListResponse.Meta.builder() + RecordingTranscriptionListPageResponse.Meta.builder() .cursors( Cursor.builder() .after( @@ -49,7 +49,7 @@ internal class RecordingTranscriptionListResponseTest { ) .build() - assertThat(recordingTranscriptionListResponse.data().getOrNull()) + assertThat(recordingTranscriptionListPageResponse.data().getOrNull()) .containsExactly( RecordingTranscription.builder() .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") @@ -62,9 +62,9 @@ internal class RecordingTranscriptionListResponseTest { .updatedAt("2018-02-02T22:25:27.521Z") .build() ) - assertThat(recordingTranscriptionListResponse.meta()) + assertThat(recordingTranscriptionListPageResponse.meta()) .contains( - RecordingTranscriptionListResponse.Meta.builder() + RecordingTranscriptionListPageResponse.Meta.builder() .cursors( Cursor.builder() .after( @@ -88,8 +88,8 @@ internal class RecordingTranscriptionListResponseTest { @Test fun roundtrip() { val jsonMapper = jsonMapper() - val recordingTranscriptionListResponse = - RecordingTranscriptionListResponse.builder() + val recordingTranscriptionListPageResponse = + RecordingTranscriptionListPageResponse.builder() .addData( RecordingTranscription.builder() .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") @@ -103,7 +103,7 @@ internal class RecordingTranscriptionListResponseTest { .build() ) .meta( - RecordingTranscriptionListResponse.Meta.builder() + RecordingTranscriptionListPageResponse.Meta.builder() .cursors( Cursor.builder() .after( @@ -124,13 +124,13 @@ internal class RecordingTranscriptionListResponseTest { ) .build() - val roundtrippedRecordingTranscriptionListResponse = + val roundtrippedRecordingTranscriptionListPageResponse = jsonMapper.readValue( - jsonMapper.writeValueAsString(recordingTranscriptionListResponse), - jacksonTypeRef(), + jsonMapper.writeValueAsString(recordingTranscriptionListPageResponse), + jacksonTypeRef(), ) - assertThat(roundtrippedRecordingTranscriptionListResponse) - .isEqualTo(recordingTranscriptionListResponse) + assertThat(roundtrippedRecordingTranscriptionListPageResponse) + .isEqualTo(recordingTranscriptionListPageResponse) } } diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/recordingtranscriptions/RecordingTranscriptionListParamsTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/recordingtranscriptions/RecordingTranscriptionListParamsTest.kt index fc945c196..b97bd4bb1 100644 --- a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/recordingtranscriptions/RecordingTranscriptionListParamsTest.kt +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/recordingtranscriptions/RecordingTranscriptionListParamsTest.kt @@ -2,12 +2,70 @@ package com.telnyx.sdk.models.recordingtranscriptions +import com.telnyx.sdk.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test internal class RecordingTranscriptionListParamsTest { @Test fun create() { - RecordingTranscriptionListParams.builder().build() + RecordingTranscriptionListParams.builder() + .filter( + RecordingTranscriptionListParams.Filter.builder() + .createdAt( + RecordingTranscriptionListParams.Filter.CreatedAt.builder() + .gte("2019-03-29T11:10:00Z") + .lte("2019-03-29T11:10:00Z") + .build() + ) + .recordingId("428c31b6-7af4-4bcb-b7f5-5013ef9657c1") + .build() + ) + .pageNumber(0L) + .pageSize(0L) + .build() + } + + @Test + fun queryParams() { + val params = + RecordingTranscriptionListParams.builder() + .filter( + RecordingTranscriptionListParams.Filter.builder() + .createdAt( + RecordingTranscriptionListParams.Filter.CreatedAt.builder() + .gte("2019-03-29T11:10:00Z") + .lte("2019-03-29T11:10:00Z") + .build() + ) + .recordingId("428c31b6-7af4-4bcb-b7f5-5013ef9657c1") + .build() + ) + .pageNumber(0L) + .pageSize(0L) + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("filter[created_at][gte]", "2019-03-29T11:10:00Z") + .put("filter[created_at][lte]", "2019-03-29T11:10:00Z") + .put("filter[recording_id]", "428c31b6-7af4-4bcb-b7f5-5013ef9657c1") + .put("page[number]", "0") + .put("page[size]", "0") + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = RecordingTranscriptionListParams.builder().build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) } } diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/voiceclones/VoiceCloneCreateFromUploadParamsTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/voiceclones/VoiceCloneCreateFromUploadParamsTest.kt new file mode 100644 index 000000000..69a9aa3c6 --- /dev/null +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/voiceclones/VoiceCloneCreateFromUploadParamsTest.kt @@ -0,0 +1,91 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.voiceclones + +import com.telnyx.sdk.core.MultipartField +import java.io.InputStream +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class VoiceCloneCreateFromUploadParamsTest { + + @Test + fun create() { + VoiceCloneCreateFromUploadParams.builder() + .audioFile("Example data".byteInputStream()) + .language("lkf-Lz1vLbBu-9uDh-9AHaOS2D-Cbf") + .name("name") + .gender(VoiceCloneCreateFromUploadParams.Gender.MALE) + .label("label") + .refText("ref_text") + .build() + } + + @Test + fun body() { + val params = + VoiceCloneCreateFromUploadParams.builder() + .audioFile("Example data".byteInputStream()) + .language("lkf-Lz1vLbBu-9uDh-9AHaOS2D-Cbf") + .name("name") + .gender(VoiceCloneCreateFromUploadParams.Gender.MALE) + .label("label") + .refText("ref_text") + .build() + + val body = params._body() + + assertThat(body.filterValues { !it.value.isNull() }) + .usingRecursiveComparison() + // TODO(AssertJ): Replace this and the `mapValues` below with: + // https://github.com/assertj/assertj/issues/3165 + .withEqualsForType( + { a, b -> a.readBytes() contentEquals b.readBytes() }, + InputStream::class.java, + ) + .isEqualTo( + mapOf( + "audio_file" to MultipartField.of("Example data".byteInputStream()), + "language" to MultipartField.of("lkf-Lz1vLbBu-9uDh-9AHaOS2D-Cbf"), + "name" to MultipartField.of("name"), + "gender" to MultipartField.of(VoiceCloneCreateFromUploadParams.Gender.MALE), + "label" to MultipartField.of("label"), + "ref_text" to MultipartField.of("ref_text"), + ) + .mapValues { (_, field) -> + field.map { (it as? ByteArray)?.inputStream() ?: it } + } + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + VoiceCloneCreateFromUploadParams.builder() + .audioFile("Example data".byteInputStream()) + .language("lkf-Lz1vLbBu-9uDh-9AHaOS2D-Cbf") + .name("name") + .build() + + val body = params._body() + + assertThat(body.filterValues { !it.value.isNull() }) + .usingRecursiveComparison() + // TODO(AssertJ): Replace this and the `mapValues` below with: + // https://github.com/assertj/assertj/issues/3165 + .withEqualsForType( + { a, b -> a.readBytes() contentEquals b.readBytes() }, + InputStream::class.java, + ) + .isEqualTo( + mapOf( + "audio_file" to MultipartField.of("Example data".byteInputStream()), + "language" to MultipartField.of("lkf-Lz1vLbBu-9uDh-9AHaOS2D-Cbf"), + "name" to MultipartField.of("name"), + ) + .mapValues { (_, field) -> + field.map { (it as? ByteArray)?.inputStream() ?: it } + } + ) + } +} diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/voiceclones/VoiceCloneCreateFromUploadResponseTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/voiceclones/VoiceCloneCreateFromUploadResponseTest.kt new file mode 100644 index 000000000..37ea2e971 --- /dev/null +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/voiceclones/VoiceCloneCreateFromUploadResponseTest.kt @@ -0,0 +1,80 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.voiceclones + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.telnyx.sdk.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class VoiceCloneCreateFromUploadResponseTest { + + @Test + fun create() { + val voiceCloneCreateFromUploadResponse = + VoiceCloneCreateFromUploadResponse.builder() + .data( + VoiceCloneData.builder() + .id("660f9511-f3ac-52e5-b827-557766551111") + .createdAt(OffsetDateTime.parse("2024-01-01T00:00:00Z")) + .gender(VoiceCloneData.Gender.MALE) + .label("Speak in a warm, friendly tone") + .language("en") + .name("clone-narrator") + .recordType(VoiceCloneData.RecordType.VOICE_CLONE) + .sourceVoiceDesignId("550e8400-e29b-41d4-a716-446655440000") + .sourceVoiceDesignVersion(1L) + .updatedAt(OffsetDateTime.parse("2024-01-01T00:00:00Z")) + .build() + ) + .build() + + assertThat(voiceCloneCreateFromUploadResponse.data()) + .contains( + VoiceCloneData.builder() + .id("660f9511-f3ac-52e5-b827-557766551111") + .createdAt(OffsetDateTime.parse("2024-01-01T00:00:00Z")) + .gender(VoiceCloneData.Gender.MALE) + .label("Speak in a warm, friendly tone") + .language("en") + .name("clone-narrator") + .recordType(VoiceCloneData.RecordType.VOICE_CLONE) + .sourceVoiceDesignId("550e8400-e29b-41d4-a716-446655440000") + .sourceVoiceDesignVersion(1L) + .updatedAt(OffsetDateTime.parse("2024-01-01T00:00:00Z")) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val voiceCloneCreateFromUploadResponse = + VoiceCloneCreateFromUploadResponse.builder() + .data( + VoiceCloneData.builder() + .id("660f9511-f3ac-52e5-b827-557766551111") + .createdAt(OffsetDateTime.parse("2024-01-01T00:00:00Z")) + .gender(VoiceCloneData.Gender.MALE) + .label("Speak in a warm, friendly tone") + .language("en") + .name("clone-narrator") + .recordType(VoiceCloneData.RecordType.VOICE_CLONE) + .sourceVoiceDesignId("550e8400-e29b-41d4-a716-446655440000") + .sourceVoiceDesignVersion(1L) + .updatedAt(OffsetDateTime.parse("2024-01-01T00:00:00Z")) + .build() + ) + .build() + + val roundtrippedVoiceCloneCreateFromUploadResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(voiceCloneCreateFromUploadResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedVoiceCloneCreateFromUploadResponse) + .isEqualTo(voiceCloneCreateFromUploadResponse) + } +} diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/voiceclones/VoiceCloneCreateParamsTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/voiceclones/VoiceCloneCreateParamsTest.kt new file mode 100644 index 000000000..b9c7d8ffb --- /dev/null +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/voiceclones/VoiceCloneCreateParamsTest.kt @@ -0,0 +1,37 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.voiceclones + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class VoiceCloneCreateParamsTest { + + @Test + fun create() { + VoiceCloneCreateParams.builder() + .gender(VoiceCloneCreateParams.Gender.MALE) + .language("en") + .name("clone-narrator") + .voiceDesignId("550e8400-e29b-41d4-a716-446655440000") + .build() + } + + @Test + fun body() { + val params = + VoiceCloneCreateParams.builder() + .gender(VoiceCloneCreateParams.Gender.MALE) + .language("en") + .name("clone-narrator") + .voiceDesignId("550e8400-e29b-41d4-a716-446655440000") + .build() + + val body = params._body() + + assertThat(body.gender()).isEqualTo(VoiceCloneCreateParams.Gender.MALE) + assertThat(body.language()).isEqualTo("en") + assertThat(body.name()).isEqualTo("clone-narrator") + assertThat(body.voiceDesignId()).isEqualTo("550e8400-e29b-41d4-a716-446655440000") + } +} diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/voiceclones/VoiceCloneCreateResponseTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/voiceclones/VoiceCloneCreateResponseTest.kt new file mode 100644 index 000000000..030a2a746 --- /dev/null +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/voiceclones/VoiceCloneCreateResponseTest.kt @@ -0,0 +1,79 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.voiceclones + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.telnyx.sdk.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class VoiceCloneCreateResponseTest { + + @Test + fun create() { + val voiceCloneCreateResponse = + VoiceCloneCreateResponse.builder() + .data( + VoiceCloneData.builder() + .id("660f9511-f3ac-52e5-b827-557766551111") + .createdAt(OffsetDateTime.parse("2024-01-01T00:00:00Z")) + .gender(VoiceCloneData.Gender.MALE) + .label("Speak in a warm, friendly tone") + .language("en") + .name("clone-narrator") + .recordType(VoiceCloneData.RecordType.VOICE_CLONE) + .sourceVoiceDesignId("550e8400-e29b-41d4-a716-446655440000") + .sourceVoiceDesignVersion(1L) + .updatedAt(OffsetDateTime.parse("2024-01-01T00:00:00Z")) + .build() + ) + .build() + + assertThat(voiceCloneCreateResponse.data()) + .contains( + VoiceCloneData.builder() + .id("660f9511-f3ac-52e5-b827-557766551111") + .createdAt(OffsetDateTime.parse("2024-01-01T00:00:00Z")) + .gender(VoiceCloneData.Gender.MALE) + .label("Speak in a warm, friendly tone") + .language("en") + .name("clone-narrator") + .recordType(VoiceCloneData.RecordType.VOICE_CLONE) + .sourceVoiceDesignId("550e8400-e29b-41d4-a716-446655440000") + .sourceVoiceDesignVersion(1L) + .updatedAt(OffsetDateTime.parse("2024-01-01T00:00:00Z")) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val voiceCloneCreateResponse = + VoiceCloneCreateResponse.builder() + .data( + VoiceCloneData.builder() + .id("660f9511-f3ac-52e5-b827-557766551111") + .createdAt(OffsetDateTime.parse("2024-01-01T00:00:00Z")) + .gender(VoiceCloneData.Gender.MALE) + .label("Speak in a warm, friendly tone") + .language("en") + .name("clone-narrator") + .recordType(VoiceCloneData.RecordType.VOICE_CLONE) + .sourceVoiceDesignId("550e8400-e29b-41d4-a716-446655440000") + .sourceVoiceDesignVersion(1L) + .updatedAt(OffsetDateTime.parse("2024-01-01T00:00:00Z")) + .build() + ) + .build() + + val roundtrippedVoiceCloneCreateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(voiceCloneCreateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedVoiceCloneCreateResponse).isEqualTo(voiceCloneCreateResponse) + } +} diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/voiceclones/VoiceCloneDataTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/voiceclones/VoiceCloneDataTest.kt new file mode 100644 index 000000000..2079cb901 --- /dev/null +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/voiceclones/VoiceCloneDataTest.kt @@ -0,0 +1,69 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.voiceclones + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.telnyx.sdk.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class VoiceCloneDataTest { + + @Test + fun create() { + val voiceCloneData = + VoiceCloneData.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .gender(VoiceCloneData.Gender.MALE) + .label("label") + .language("language") + .name("name") + .recordType(VoiceCloneData.RecordType.VOICE_CLONE) + .sourceVoiceDesignId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .sourceVoiceDesignVersion(0L) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + assertThat(voiceCloneData.id()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(voiceCloneData.createdAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(voiceCloneData.gender()).contains(VoiceCloneData.Gender.MALE) + assertThat(voiceCloneData.label()).contains("label") + assertThat(voiceCloneData.language()).contains("language") + assertThat(voiceCloneData.name()).contains("name") + assertThat(voiceCloneData.recordType()).contains(VoiceCloneData.RecordType.VOICE_CLONE) + assertThat(voiceCloneData.sourceVoiceDesignId()) + .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(voiceCloneData.sourceVoiceDesignVersion()).contains(0L) + assertThat(voiceCloneData.updatedAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val voiceCloneData = + VoiceCloneData.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .gender(VoiceCloneData.Gender.MALE) + .label("label") + .language("language") + .name("name") + .recordType(VoiceCloneData.RecordType.VOICE_CLONE) + .sourceVoiceDesignId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .sourceVoiceDesignVersion(0L) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + val roundtrippedVoiceCloneData = + jsonMapper.readValue( + jsonMapper.writeValueAsString(voiceCloneData), + jacksonTypeRef(), + ) + + assertThat(roundtrippedVoiceCloneData).isEqualTo(voiceCloneData) + } +} diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/voiceclones/VoiceCloneDeleteParamsTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/voiceclones/VoiceCloneDeleteParamsTest.kt new file mode 100644 index 000000000..176044467 --- /dev/null +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/voiceclones/VoiceCloneDeleteParamsTest.kt @@ -0,0 +1,24 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.voiceclones + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class VoiceCloneDeleteParamsTest { + + @Test + fun create() { + VoiceCloneDeleteParams.builder().id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + } + + @Test + fun pathParams() { + val params = + VoiceCloneDeleteParams.builder().id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/voiceclones/VoiceCloneDownloadSampleParamsTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/voiceclones/VoiceCloneDownloadSampleParamsTest.kt new file mode 100644 index 000000000..82c52e4ec --- /dev/null +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/voiceclones/VoiceCloneDownloadSampleParamsTest.kt @@ -0,0 +1,26 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.voiceclones + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class VoiceCloneDownloadSampleParamsTest { + + @Test + fun create() { + VoiceCloneDownloadSampleParams.builder().id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + } + + @Test + fun pathParams() { + val params = + VoiceCloneDownloadSampleParams.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/voiceclones/VoiceCloneListPageResponseTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/voiceclones/VoiceCloneListPageResponseTest.kt new file mode 100644 index 000000000..66e02e400 --- /dev/null +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/voiceclones/VoiceCloneListPageResponseTest.kt @@ -0,0 +1,105 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.voiceclones + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.telnyx.sdk.core.jsonMapper +import java.time.OffsetDateTime +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class VoiceCloneListPageResponseTest { + + @Test + fun create() { + val voiceCloneListPageResponse = + VoiceCloneListPageResponse.builder() + .addData( + VoiceCloneData.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .gender(VoiceCloneData.Gender.MALE) + .label("label") + .language("language") + .name("name") + .recordType(VoiceCloneData.RecordType.VOICE_CLONE) + .sourceVoiceDesignId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .sourceVoiceDesignVersion(0L) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .meta( + VoiceCloneListPageResponse.Meta.builder() + .pageNumber(1L) + .pageSize(20L) + .totalPages(3L) + .totalResults(42L) + .build() + ) + .build() + + assertThat(voiceCloneListPageResponse.data().getOrNull()) + .containsExactly( + VoiceCloneData.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .gender(VoiceCloneData.Gender.MALE) + .label("label") + .language("language") + .name("name") + .recordType(VoiceCloneData.RecordType.VOICE_CLONE) + .sourceVoiceDesignId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .sourceVoiceDesignVersion(0L) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + assertThat(voiceCloneListPageResponse.meta()) + .contains( + VoiceCloneListPageResponse.Meta.builder() + .pageNumber(1L) + .pageSize(20L) + .totalPages(3L) + .totalResults(42L) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val voiceCloneListPageResponse = + VoiceCloneListPageResponse.builder() + .addData( + VoiceCloneData.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .gender(VoiceCloneData.Gender.MALE) + .label("label") + .language("language") + .name("name") + .recordType(VoiceCloneData.RecordType.VOICE_CLONE) + .sourceVoiceDesignId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .sourceVoiceDesignVersion(0L) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .meta( + VoiceCloneListPageResponse.Meta.builder() + .pageNumber(1L) + .pageSize(20L) + .totalPages(3L) + .totalResults(42L) + .build() + ) + .build() + + val roundtrippedVoiceCloneListPageResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(voiceCloneListPageResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedVoiceCloneListPageResponse).isEqualTo(voiceCloneListPageResponse) + } +} diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/voiceclones/VoiceCloneListParamsTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/voiceclones/VoiceCloneListParamsTest.kt new file mode 100644 index 000000000..2a86770d6 --- /dev/null +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/voiceclones/VoiceCloneListParamsTest.kt @@ -0,0 +1,52 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.voiceclones + +import com.telnyx.sdk.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class VoiceCloneListParamsTest { + + @Test + fun create() { + VoiceCloneListParams.builder() + .filterName("filter[name]") + .pageNumber(1L) + .pageSize(1L) + .sort(VoiceCloneListParams.Sort.NAME) + .build() + } + + @Test + fun queryParams() { + val params = + VoiceCloneListParams.builder() + .filterName("filter[name]") + .pageNumber(1L) + .pageSize(1L) + .sort(VoiceCloneListParams.Sort.NAME) + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("filter[name]", "filter[name]") + .put("page[number]", "1") + .put("page[size]", "1") + .put("sort", "name") + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = VoiceCloneListParams.builder().build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/voiceclones/VoiceCloneUpdateParamsTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/voiceclones/VoiceCloneUpdateParamsTest.kt new file mode 100644 index 000000000..2dc255157 --- /dev/null +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/voiceclones/VoiceCloneUpdateParamsTest.kt @@ -0,0 +1,62 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.voiceclones + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class VoiceCloneUpdateParamsTest { + + @Test + fun create() { + VoiceCloneUpdateParams.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("updated-clone") + .gender(VoiceCloneUpdateParams.Gender.MALE) + .language("language") + .build() + } + + @Test + fun pathParams() { + val params = + VoiceCloneUpdateParams.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("updated-clone") + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun body() { + val params = + VoiceCloneUpdateParams.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("updated-clone") + .gender(VoiceCloneUpdateParams.Gender.MALE) + .language("language") + .build() + + val body = params._body() + + assertThat(body.name()).isEqualTo("updated-clone") + assertThat(body.gender()).contains(VoiceCloneUpdateParams.Gender.MALE) + assertThat(body.language()).contains("language") + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + VoiceCloneUpdateParams.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("updated-clone") + .build() + + val body = params._body() + + assertThat(body.name()).isEqualTo("updated-clone") + } +} diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/voiceclones/VoiceCloneUpdateResponseTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/voiceclones/VoiceCloneUpdateResponseTest.kt new file mode 100644 index 000000000..44cf9df06 --- /dev/null +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/voiceclones/VoiceCloneUpdateResponseTest.kt @@ -0,0 +1,79 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.voiceclones + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.telnyx.sdk.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class VoiceCloneUpdateResponseTest { + + @Test + fun create() { + val voiceCloneUpdateResponse = + VoiceCloneUpdateResponse.builder() + .data( + VoiceCloneData.builder() + .id("660f9511-f3ac-52e5-b827-557766551111") + .createdAt(OffsetDateTime.parse("2024-01-01T00:00:00Z")) + .gender(VoiceCloneData.Gender.MALE) + .label("Speak in a warm, friendly tone") + .language("en") + .name("clone-narrator") + .recordType(VoiceCloneData.RecordType.VOICE_CLONE) + .sourceVoiceDesignId("550e8400-e29b-41d4-a716-446655440000") + .sourceVoiceDesignVersion(1L) + .updatedAt(OffsetDateTime.parse("2024-01-01T00:00:00Z")) + .build() + ) + .build() + + assertThat(voiceCloneUpdateResponse.data()) + .contains( + VoiceCloneData.builder() + .id("660f9511-f3ac-52e5-b827-557766551111") + .createdAt(OffsetDateTime.parse("2024-01-01T00:00:00Z")) + .gender(VoiceCloneData.Gender.MALE) + .label("Speak in a warm, friendly tone") + .language("en") + .name("clone-narrator") + .recordType(VoiceCloneData.RecordType.VOICE_CLONE) + .sourceVoiceDesignId("550e8400-e29b-41d4-a716-446655440000") + .sourceVoiceDesignVersion(1L) + .updatedAt(OffsetDateTime.parse("2024-01-01T00:00:00Z")) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val voiceCloneUpdateResponse = + VoiceCloneUpdateResponse.builder() + .data( + VoiceCloneData.builder() + .id("660f9511-f3ac-52e5-b827-557766551111") + .createdAt(OffsetDateTime.parse("2024-01-01T00:00:00Z")) + .gender(VoiceCloneData.Gender.MALE) + .label("Speak in a warm, friendly tone") + .language("en") + .name("clone-narrator") + .recordType(VoiceCloneData.RecordType.VOICE_CLONE) + .sourceVoiceDesignId("550e8400-e29b-41d4-a716-446655440000") + .sourceVoiceDesignVersion(1L) + .updatedAt(OffsetDateTime.parse("2024-01-01T00:00:00Z")) + .build() + ) + .build() + + val roundtrippedVoiceCloneUpdateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(voiceCloneUpdateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedVoiceCloneUpdateResponse).isEqualTo(voiceCloneUpdateResponse) + } +} diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/voicedesigns/VoiceDesignCreateParamsTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/voicedesigns/VoiceDesignCreateParamsTest.kt new file mode 100644 index 000000000..fea183bcc --- /dev/null +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/voicedesigns/VoiceDesignCreateParamsTest.kt @@ -0,0 +1,69 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.voicedesigns + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class VoiceDesignCreateParamsTest { + + @Test + fun create() { + VoiceDesignCreateParams.builder() + .prompt("Speak in a warm, friendly tone") + .text("Hello, welcome to our service.") + .language("Auto") + .maxNewTokens(100L) + .name("friendly-narrator") + .repetitionPenalty(1.0f) + .temperature(0.0f) + .topK(1L) + .topP(0.0f) + .voiceDesignId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + } + + @Test + fun body() { + val params = + VoiceDesignCreateParams.builder() + .prompt("Speak in a warm, friendly tone") + .text("Hello, welcome to our service.") + .language("Auto") + .maxNewTokens(100L) + .name("friendly-narrator") + .repetitionPenalty(1.0f) + .temperature(0.0f) + .topK(1L) + .topP(0.0f) + .voiceDesignId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val body = params._body() + + assertThat(body.prompt()).isEqualTo("Speak in a warm, friendly tone") + assertThat(body.text()).isEqualTo("Hello, welcome to our service.") + assertThat(body.language()).contains("Auto") + assertThat(body.maxNewTokens()).contains(100L) + assertThat(body.name()).contains("friendly-narrator") + assertThat(body.repetitionPenalty()).contains(1.0f) + assertThat(body.temperature()).contains(0.0f) + assertThat(body.topK()).contains(1L) + assertThat(body.topP()).contains(0.0f) + assertThat(body.voiceDesignId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + VoiceDesignCreateParams.builder() + .prompt("Speak in a warm, friendly tone") + .text("Hello, welcome to our service.") + .build() + + val body = params._body() + + assertThat(body.prompt()).isEqualTo("Speak in a warm, friendly tone") + assertThat(body.text()).isEqualTo("Hello, welcome to our service.") + } +} diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/voicedesigns/VoiceDesignCreateResponseTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/voicedesigns/VoiceDesignCreateResponseTest.kt new file mode 100644 index 000000000..8c641490b --- /dev/null +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/voicedesigns/VoiceDesignCreateResponseTest.kt @@ -0,0 +1,79 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.voicedesigns + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.telnyx.sdk.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class VoiceDesignCreateResponseTest { + + @Test + fun create() { + val voiceDesignCreateResponse = + VoiceDesignCreateResponse.builder() + .data( + VoiceDesignData.builder() + .id("550e8400-e29b-41d4-a716-446655440000") + .createdAt(OffsetDateTime.parse("2024-01-01T00:00:00Z")) + .name("friendly-narrator") + .prompt("Speak in a warm tone") + .recordType(VoiceDesignData.RecordType.VOICE_DESIGN) + .text("Hello, welcome.") + .updatedAt(OffsetDateTime.parse("2024-01-01T00:00:00Z")) + .version(1L) + .versionCreatedAt(OffsetDateTime.parse("2024-01-01T00:00:00Z")) + .voiceSampleSize(48000L) + .build() + ) + .build() + + assertThat(voiceDesignCreateResponse.data()) + .contains( + VoiceDesignData.builder() + .id("550e8400-e29b-41d4-a716-446655440000") + .createdAt(OffsetDateTime.parse("2024-01-01T00:00:00Z")) + .name("friendly-narrator") + .prompt("Speak in a warm tone") + .recordType(VoiceDesignData.RecordType.VOICE_DESIGN) + .text("Hello, welcome.") + .updatedAt(OffsetDateTime.parse("2024-01-01T00:00:00Z")) + .version(1L) + .versionCreatedAt(OffsetDateTime.parse("2024-01-01T00:00:00Z")) + .voiceSampleSize(48000L) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val voiceDesignCreateResponse = + VoiceDesignCreateResponse.builder() + .data( + VoiceDesignData.builder() + .id("550e8400-e29b-41d4-a716-446655440000") + .createdAt(OffsetDateTime.parse("2024-01-01T00:00:00Z")) + .name("friendly-narrator") + .prompt("Speak in a warm tone") + .recordType(VoiceDesignData.RecordType.VOICE_DESIGN) + .text("Hello, welcome.") + .updatedAt(OffsetDateTime.parse("2024-01-01T00:00:00Z")) + .version(1L) + .versionCreatedAt(OffsetDateTime.parse("2024-01-01T00:00:00Z")) + .voiceSampleSize(48000L) + .build() + ) + .build() + + val roundtrippedVoiceDesignCreateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(voiceDesignCreateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedVoiceDesignCreateResponse).isEqualTo(voiceDesignCreateResponse) + } +} diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/voicedesigns/VoiceDesignDataTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/voicedesigns/VoiceDesignDataTest.kt new file mode 100644 index 000000000..483f253f6 --- /dev/null +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/voicedesigns/VoiceDesignDataTest.kt @@ -0,0 +1,69 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.voicedesigns + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.telnyx.sdk.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class VoiceDesignDataTest { + + @Test + fun create() { + val voiceDesignData = + VoiceDesignData.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .name("name") + .prompt("prompt") + .recordType(VoiceDesignData.RecordType.VOICE_DESIGN) + .text("text") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .version(0L) + .versionCreatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .voiceSampleSize(0L) + .build() + + assertThat(voiceDesignData.id()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(voiceDesignData.createdAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(voiceDesignData.name()).contains("name") + assertThat(voiceDesignData.prompt()).contains("prompt") + assertThat(voiceDesignData.recordType()).contains(VoiceDesignData.RecordType.VOICE_DESIGN) + assertThat(voiceDesignData.text()).contains("text") + assertThat(voiceDesignData.updatedAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(voiceDesignData.version()).contains(0L) + assertThat(voiceDesignData.versionCreatedAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(voiceDesignData.voiceSampleSize()).contains(0L) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val voiceDesignData = + VoiceDesignData.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .name("name") + .prompt("prompt") + .recordType(VoiceDesignData.RecordType.VOICE_DESIGN) + .text("text") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .version(0L) + .versionCreatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .voiceSampleSize(0L) + .build() + + val roundtrippedVoiceDesignData = + jsonMapper.readValue( + jsonMapper.writeValueAsString(voiceDesignData), + jacksonTypeRef(), + ) + + assertThat(roundtrippedVoiceDesignData).isEqualTo(voiceDesignData) + } +} diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/voicedesigns/VoiceDesignDeleteParamsTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/voicedesigns/VoiceDesignDeleteParamsTest.kt new file mode 100644 index 000000000..72d712cba --- /dev/null +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/voicedesigns/VoiceDesignDeleteParamsTest.kt @@ -0,0 +1,23 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.voicedesigns + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class VoiceDesignDeleteParamsTest { + + @Test + fun create() { + VoiceDesignDeleteParams.builder().id("id").build() + } + + @Test + fun pathParams() { + val params = VoiceDesignDeleteParams.builder().id("id").build() + + assertThat(params._pathParam(0)).isEqualTo("id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/voicedesigns/VoiceDesignDeleteVersionParamsTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/voicedesigns/VoiceDesignDeleteVersionParamsTest.kt new file mode 100644 index 000000000..826ab02e4 --- /dev/null +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/voicedesigns/VoiceDesignDeleteVersionParamsTest.kt @@ -0,0 +1,24 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.voicedesigns + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class VoiceDesignDeleteVersionParamsTest { + + @Test + fun create() { + VoiceDesignDeleteVersionParams.builder().id("id").version(1L).build() + } + + @Test + fun pathParams() { + val params = VoiceDesignDeleteVersionParams.builder().id("id").version(1L).build() + + assertThat(params._pathParam(0)).isEqualTo("id") + assertThat(params._pathParam(1)).isEqualTo("1") + // out-of-bound path param + assertThat(params._pathParam(2)).isEqualTo("") + } +} diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/voicedesigns/VoiceDesignDownloadSampleParamsTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/voicedesigns/VoiceDesignDownloadSampleParamsTest.kt new file mode 100644 index 000000000..84b751a0d --- /dev/null +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/voicedesigns/VoiceDesignDownloadSampleParamsTest.kt @@ -0,0 +1,42 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.voicedesigns + +import com.telnyx.sdk.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class VoiceDesignDownloadSampleParamsTest { + + @Test + fun create() { + VoiceDesignDownloadSampleParams.builder().id("id").version(1L).build() + } + + @Test + fun pathParams() { + val params = VoiceDesignDownloadSampleParams.builder().id("id").build() + + assertThat(params._pathParam(0)).isEqualTo("id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun queryParams() { + val params = VoiceDesignDownloadSampleParams.builder().id("id").version(1L).build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().put("version", "1").build()) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = VoiceDesignDownloadSampleParams.builder().id("id").build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/voicedesigns/VoiceDesignListPageResponseTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/voicedesigns/VoiceDesignListPageResponseTest.kt new file mode 100644 index 000000000..d665983b0 --- /dev/null +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/voicedesigns/VoiceDesignListPageResponseTest.kt @@ -0,0 +1,90 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.voicedesigns + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.telnyx.sdk.core.jsonMapper +import java.time.OffsetDateTime +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class VoiceDesignListPageResponseTest { + + @Test + fun create() { + val voiceDesignListPageResponse = + VoiceDesignListPageResponse.builder() + .addData( + VoiceDesignListResponse.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .name("name") + .recordType(VoiceDesignListResponse.RecordType.VOICE_DESIGN) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .meta( + VoiceDesignListPageResponse.Meta.builder() + .pageNumber(1L) + .pageSize(20L) + .totalPages(3L) + .totalResults(42L) + .build() + ) + .build() + + assertThat(voiceDesignListPageResponse.data().getOrNull()) + .containsExactly( + VoiceDesignListResponse.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .name("name") + .recordType(VoiceDesignListResponse.RecordType.VOICE_DESIGN) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + assertThat(voiceDesignListPageResponse.meta()) + .contains( + VoiceDesignListPageResponse.Meta.builder() + .pageNumber(1L) + .pageSize(20L) + .totalPages(3L) + .totalResults(42L) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val voiceDesignListPageResponse = + VoiceDesignListPageResponse.builder() + .addData( + VoiceDesignListResponse.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .name("name") + .recordType(VoiceDesignListResponse.RecordType.VOICE_DESIGN) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .meta( + VoiceDesignListPageResponse.Meta.builder() + .pageNumber(1L) + .pageSize(20L) + .totalPages(3L) + .totalResults(42L) + .build() + ) + .build() + + val roundtrippedVoiceDesignListPageResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(voiceDesignListPageResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedVoiceDesignListPageResponse).isEqualTo(voiceDesignListPageResponse) + } +} diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/voicedesigns/VoiceDesignListParamsTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/voicedesigns/VoiceDesignListParamsTest.kt new file mode 100644 index 000000000..921a87502 --- /dev/null +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/voicedesigns/VoiceDesignListParamsTest.kt @@ -0,0 +1,52 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.voicedesigns + +import com.telnyx.sdk.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class VoiceDesignListParamsTest { + + @Test + fun create() { + VoiceDesignListParams.builder() + .filterName("filter[name]") + .pageNumber(1L) + .pageSize(1L) + .sort(VoiceDesignListParams.Sort.NAME) + .build() + } + + @Test + fun queryParams() { + val params = + VoiceDesignListParams.builder() + .filterName("filter[name]") + .pageNumber(1L) + .pageSize(1L) + .sort(VoiceDesignListParams.Sort.NAME) + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("filter[name]", "filter[name]") + .put("page[number]", "1") + .put("page[size]", "1") + .put("sort", "name") + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = VoiceDesignListParams.builder().build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/voicedesigns/VoiceDesignListResponseTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/voicedesigns/VoiceDesignListResponseTest.kt new file mode 100644 index 000000000..09bf398b5 --- /dev/null +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/voicedesigns/VoiceDesignListResponseTest.kt @@ -0,0 +1,54 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.voicedesigns + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.telnyx.sdk.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class VoiceDesignListResponseTest { + + @Test + fun create() { + val voiceDesignListResponse = + VoiceDesignListResponse.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .name("name") + .recordType(VoiceDesignListResponse.RecordType.VOICE_DESIGN) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + assertThat(voiceDesignListResponse.id()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(voiceDesignListResponse.createdAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(voiceDesignListResponse.name()).contains("name") + assertThat(voiceDesignListResponse.recordType()) + .contains(VoiceDesignListResponse.RecordType.VOICE_DESIGN) + assertThat(voiceDesignListResponse.updatedAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val voiceDesignListResponse = + VoiceDesignListResponse.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .name("name") + .recordType(VoiceDesignListResponse.RecordType.VOICE_DESIGN) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + val roundtrippedVoiceDesignListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(voiceDesignListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedVoiceDesignListResponse).isEqualTo(voiceDesignListResponse) + } +} diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/voicedesigns/VoiceDesignRenameParamsTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/voicedesigns/VoiceDesignRenameParamsTest.kt new file mode 100644 index 000000000..329397f6b --- /dev/null +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/voicedesigns/VoiceDesignRenameParamsTest.kt @@ -0,0 +1,32 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.voicedesigns + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class VoiceDesignRenameParamsTest { + + @Test + fun create() { + VoiceDesignRenameParams.builder().id("id").name("updated-narrator").build() + } + + @Test + fun pathParams() { + val params = VoiceDesignRenameParams.builder().id("id").name("updated-narrator").build() + + assertThat(params._pathParam(0)).isEqualTo("id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun body() { + val params = VoiceDesignRenameParams.builder().id("id").name("updated-narrator").build() + + val body = params._body() + + assertThat(body.name()).isEqualTo("updated-narrator") + } +} diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/voicedesigns/VoiceDesignRenameResponseTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/voicedesigns/VoiceDesignRenameResponseTest.kt new file mode 100644 index 000000000..def9964df --- /dev/null +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/voicedesigns/VoiceDesignRenameResponseTest.kt @@ -0,0 +1,64 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.voicedesigns + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.telnyx.sdk.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class VoiceDesignRenameResponseTest { + + @Test + fun create() { + val voiceDesignRenameResponse = + VoiceDesignRenameResponse.builder() + .data( + VoiceDesignRenameResponse.Data.builder() + .id("550e8400-e29b-41d4-a716-446655440000") + .createdAt(OffsetDateTime.parse("2024-01-01T00:00:00Z")) + .name("updated-narrator") + .recordType(VoiceDesignRenameResponse.Data.RecordType.VOICE_DESIGN) + .updatedAt(OffsetDateTime.parse("2024-01-02T00:00:00Z")) + .build() + ) + .build() + + assertThat(voiceDesignRenameResponse.data()) + .contains( + VoiceDesignRenameResponse.Data.builder() + .id("550e8400-e29b-41d4-a716-446655440000") + .createdAt(OffsetDateTime.parse("2024-01-01T00:00:00Z")) + .name("updated-narrator") + .recordType(VoiceDesignRenameResponse.Data.RecordType.VOICE_DESIGN) + .updatedAt(OffsetDateTime.parse("2024-01-02T00:00:00Z")) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val voiceDesignRenameResponse = + VoiceDesignRenameResponse.builder() + .data( + VoiceDesignRenameResponse.Data.builder() + .id("550e8400-e29b-41d4-a716-446655440000") + .createdAt(OffsetDateTime.parse("2024-01-01T00:00:00Z")) + .name("updated-narrator") + .recordType(VoiceDesignRenameResponse.Data.RecordType.VOICE_DESIGN) + .updatedAt(OffsetDateTime.parse("2024-01-02T00:00:00Z")) + .build() + ) + .build() + + val roundtrippedVoiceDesignRenameResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(voiceDesignRenameResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedVoiceDesignRenameResponse).isEqualTo(voiceDesignRenameResponse) + } +} diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/voicedesigns/VoiceDesignRetrieveParamsTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/voicedesigns/VoiceDesignRetrieveParamsTest.kt new file mode 100644 index 000000000..25e07cf09 --- /dev/null +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/voicedesigns/VoiceDesignRetrieveParamsTest.kt @@ -0,0 +1,42 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.voicedesigns + +import com.telnyx.sdk.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class VoiceDesignRetrieveParamsTest { + + @Test + fun create() { + VoiceDesignRetrieveParams.builder().id("id").version(1L).build() + } + + @Test + fun pathParams() { + val params = VoiceDesignRetrieveParams.builder().id("id").build() + + assertThat(params._pathParam(0)).isEqualTo("id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun queryParams() { + val params = VoiceDesignRetrieveParams.builder().id("id").version(1L).build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().put("version", "1").build()) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = VoiceDesignRetrieveParams.builder().id("id").build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/voicedesigns/VoiceDesignRetrieveResponseTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/voicedesigns/VoiceDesignRetrieveResponseTest.kt new file mode 100644 index 000000000..bb430a0c3 --- /dev/null +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/voicedesigns/VoiceDesignRetrieveResponseTest.kt @@ -0,0 +1,79 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.voicedesigns + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.telnyx.sdk.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class VoiceDesignRetrieveResponseTest { + + @Test + fun create() { + val voiceDesignRetrieveResponse = + VoiceDesignRetrieveResponse.builder() + .data( + VoiceDesignData.builder() + .id("550e8400-e29b-41d4-a716-446655440000") + .createdAt(OffsetDateTime.parse("2024-01-01T00:00:00Z")) + .name("friendly-narrator") + .prompt("Speak in a warm tone") + .recordType(VoiceDesignData.RecordType.VOICE_DESIGN) + .text("Hello, welcome.") + .updatedAt(OffsetDateTime.parse("2024-01-01T00:00:00Z")) + .version(1L) + .versionCreatedAt(OffsetDateTime.parse("2024-01-01T00:00:00Z")) + .voiceSampleSize(48000L) + .build() + ) + .build() + + assertThat(voiceDesignRetrieveResponse.data()) + .contains( + VoiceDesignData.builder() + .id("550e8400-e29b-41d4-a716-446655440000") + .createdAt(OffsetDateTime.parse("2024-01-01T00:00:00Z")) + .name("friendly-narrator") + .prompt("Speak in a warm tone") + .recordType(VoiceDesignData.RecordType.VOICE_DESIGN) + .text("Hello, welcome.") + .updatedAt(OffsetDateTime.parse("2024-01-01T00:00:00Z")) + .version(1L) + .versionCreatedAt(OffsetDateTime.parse("2024-01-01T00:00:00Z")) + .voiceSampleSize(48000L) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val voiceDesignRetrieveResponse = + VoiceDesignRetrieveResponse.builder() + .data( + VoiceDesignData.builder() + .id("550e8400-e29b-41d4-a716-446655440000") + .createdAt(OffsetDateTime.parse("2024-01-01T00:00:00Z")) + .name("friendly-narrator") + .prompt("Speak in a warm tone") + .recordType(VoiceDesignData.RecordType.VOICE_DESIGN) + .text("Hello, welcome.") + .updatedAt(OffsetDateTime.parse("2024-01-01T00:00:00Z")) + .version(1L) + .versionCreatedAt(OffsetDateTime.parse("2024-01-01T00:00:00Z")) + .voiceSampleSize(48000L) + .build() + ) + .build() + + val roundtrippedVoiceDesignRetrieveResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(voiceDesignRetrieveResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedVoiceDesignRetrieveResponse).isEqualTo(voiceDesignRetrieveResponse) + } +} diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/x402/creditaccount/CreditAccountCreateQuoteParamsTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/x402/creditaccount/CreditAccountCreateQuoteParamsTest.kt new file mode 100644 index 000000000..0495cd1f7 --- /dev/null +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/x402/creditaccount/CreditAccountCreateQuoteParamsTest.kt @@ -0,0 +1,23 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.x402.creditaccount + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CreditAccountCreateQuoteParamsTest { + + @Test + fun create() { + CreditAccountCreateQuoteParams.builder().amountUsd("50.00").build() + } + + @Test + fun body() { + val params = CreditAccountCreateQuoteParams.builder().amountUsd("50.00").build() + + val body = params._body() + + assertThat(body.amountUsd()).isEqualTo("50.00") + } +} diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/x402/creditaccount/CreditAccountCreateQuoteResponseTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/x402/creditaccount/CreditAccountCreateQuoteResponseTest.kt new file mode 100644 index 000000000..acbb26b95 --- /dev/null +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/x402/creditaccount/CreditAccountCreateQuoteResponseTest.kt @@ -0,0 +1,189 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.x402.creditaccount + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.telnyx.sdk.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CreditAccountCreateQuoteResponseTest { + + @Test + fun create() { + val creditAccountCreateQuoteResponse = + CreditAccountCreateQuoteResponse.builder() + .data( + CreditAccountCreateQuoteResponse.Data.builder() + .id("id") + .amountCrypto("amount_crypto") + .amountUsd("amount_usd") + .expiresAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .network("network") + .paymentRequirements( + CreditAccountCreateQuoteResponse.Data.PaymentRequirements.builder() + .addAccept( + CreditAccountCreateQuoteResponse.Data.PaymentRequirements.Accept + .builder() + .amount("amount") + .asset("asset") + .extra( + CreditAccountCreateQuoteResponse.Data + .PaymentRequirements + .Accept + .Extra + .builder() + .facilitatorUrl("facilitatorUrl") + .name("name") + .quoteId("quoteId") + .version("version") + .build() + ) + .maxTimeoutSeconds(0L) + .network("network") + .payTo("payTo") + .scheme("scheme") + .build() + ) + .resource( + CreditAccountCreateQuoteResponse.Data.PaymentRequirements + .Resource + .builder() + .description("description") + .mimeType("mimeType") + .url("url") + .build() + ) + .x402Version( + CreditAccountCreateQuoteResponse.Data.PaymentRequirements + .X402Version + .V2 + ) + .build() + ) + .recordType(CreditAccountCreateQuoteResponse.Data.RecordType.QUOTE) + .build() + ) + .build() + + assertThat(creditAccountCreateQuoteResponse.data()) + .contains( + CreditAccountCreateQuoteResponse.Data.builder() + .id("id") + .amountCrypto("amount_crypto") + .amountUsd("amount_usd") + .expiresAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .network("network") + .paymentRequirements( + CreditAccountCreateQuoteResponse.Data.PaymentRequirements.builder() + .addAccept( + CreditAccountCreateQuoteResponse.Data.PaymentRequirements.Accept + .builder() + .amount("amount") + .asset("asset") + .extra( + CreditAccountCreateQuoteResponse.Data.PaymentRequirements + .Accept + .Extra + .builder() + .facilitatorUrl("facilitatorUrl") + .name("name") + .quoteId("quoteId") + .version("version") + .build() + ) + .maxTimeoutSeconds(0L) + .network("network") + .payTo("payTo") + .scheme("scheme") + .build() + ) + .resource( + CreditAccountCreateQuoteResponse.Data.PaymentRequirements.Resource + .builder() + .description("description") + .mimeType("mimeType") + .url("url") + .build() + ) + .x402Version( + CreditAccountCreateQuoteResponse.Data.PaymentRequirements + .X402Version + .V2 + ) + .build() + ) + .recordType(CreditAccountCreateQuoteResponse.Data.RecordType.QUOTE) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val creditAccountCreateQuoteResponse = + CreditAccountCreateQuoteResponse.builder() + .data( + CreditAccountCreateQuoteResponse.Data.builder() + .id("id") + .amountCrypto("amount_crypto") + .amountUsd("amount_usd") + .expiresAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .network("network") + .paymentRequirements( + CreditAccountCreateQuoteResponse.Data.PaymentRequirements.builder() + .addAccept( + CreditAccountCreateQuoteResponse.Data.PaymentRequirements.Accept + .builder() + .amount("amount") + .asset("asset") + .extra( + CreditAccountCreateQuoteResponse.Data + .PaymentRequirements + .Accept + .Extra + .builder() + .facilitatorUrl("facilitatorUrl") + .name("name") + .quoteId("quoteId") + .version("version") + .build() + ) + .maxTimeoutSeconds(0L) + .network("network") + .payTo("payTo") + .scheme("scheme") + .build() + ) + .resource( + CreditAccountCreateQuoteResponse.Data.PaymentRequirements + .Resource + .builder() + .description("description") + .mimeType("mimeType") + .url("url") + .build() + ) + .x402Version( + CreditAccountCreateQuoteResponse.Data.PaymentRequirements + .X402Version + .V2 + ) + .build() + ) + .recordType(CreditAccountCreateQuoteResponse.Data.RecordType.QUOTE) + .build() + ) + .build() + + val roundtrippedCreditAccountCreateQuoteResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(creditAccountCreateQuoteResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCreditAccountCreateQuoteResponse) + .isEqualTo(creditAccountCreateQuoteResponse) + } +} diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/x402/creditaccount/CreditAccountSettleParamsTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/x402/creditaccount/CreditAccountSettleParamsTest.kt new file mode 100644 index 000000000..2f8a4e0f5 --- /dev/null +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/x402/creditaccount/CreditAccountSettleParamsTest.kt @@ -0,0 +1,67 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.x402.creditaccount + +import com.telnyx.sdk.core.http.Headers +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CreditAccountSettleParamsTest { + + @Test + fun create() { + CreditAccountSettleParams.builder() + .paymentSignatureHeader("PAYMENT-SIGNATURE") + .id("quote_abc123") + .paymentSignature("0xabc123...") + .build() + } + + @Test + fun headers() { + val params = + CreditAccountSettleParams.builder() + .paymentSignatureHeader("PAYMENT-SIGNATURE") + .id("quote_abc123") + .paymentSignature("0xabc123...") + .build() + + val headers = params._headers() + + assertThat(headers) + .isEqualTo(Headers.builder().put("PAYMENT-SIGNATURE", "PAYMENT-SIGNATURE").build()) + } + + @Test + fun headersWithoutOptionalFields() { + val params = CreditAccountSettleParams.builder().id("quote_abc123").build() + + val headers = params._headers() + + assertThat(headers).isEqualTo(Headers.builder().build()) + } + + @Test + fun body() { + val params = + CreditAccountSettleParams.builder() + .paymentSignatureHeader("PAYMENT-SIGNATURE") + .id("quote_abc123") + .paymentSignature("0xabc123...") + .build() + + val body = params._body() + + assertThat(body.id()).isEqualTo("quote_abc123") + assertThat(body.paymentSignature()).contains("0xabc123...") + } + + @Test + fun bodyWithoutOptionalFields() { + val params = CreditAccountSettleParams.builder().id("quote_abc123").build() + + val body = params._body() + + assertThat(body.id()).isEqualTo("quote_abc123") + } +} diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/x402/creditaccount/CreditAccountSettleResponseTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/x402/creditaccount/CreditAccountSettleResponseTest.kt new file mode 100644 index 000000000..7c2752277 --- /dev/null +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/x402/creditaccount/CreditAccountSettleResponseTest.kt @@ -0,0 +1,73 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.x402.creditaccount + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.telnyx.sdk.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CreditAccountSettleResponseTest { + + @Test + fun create() { + val creditAccountSettleResponse = + CreditAccountSettleResponse.builder() + .data( + CreditAccountSettleResponse.Data.builder() + .id("id") + .amount("amount") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("currency") + .quoteId("quote_id") + .recordType(CreditAccountSettleResponse.Data.RecordType.X402_TRANSACTION) + .status(CreditAccountSettleResponse.Data.Status.SETTLED) + .txHash("tx_hash") + .build() + ) + .build() + + assertThat(creditAccountSettleResponse.data()) + .contains( + CreditAccountSettleResponse.Data.builder() + .id("id") + .amount("amount") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("currency") + .quoteId("quote_id") + .recordType(CreditAccountSettleResponse.Data.RecordType.X402_TRANSACTION) + .status(CreditAccountSettleResponse.Data.Status.SETTLED) + .txHash("tx_hash") + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val creditAccountSettleResponse = + CreditAccountSettleResponse.builder() + .data( + CreditAccountSettleResponse.Data.builder() + .id("id") + .amount("amount") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("currency") + .quoteId("quote_id") + .recordType(CreditAccountSettleResponse.Data.RecordType.X402_TRANSACTION) + .status(CreditAccountSettleResponse.Data.Status.SETTLED) + .txHash("tx_hash") + .build() + ) + .build() + + val roundtrippedCreditAccountSettleResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(creditAccountSettleResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCreditAccountSettleResponse).isEqualTo(creditAccountSettleResponse) + } +} diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/async/RecordingTranscriptionServiceAsyncTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/async/RecordingTranscriptionServiceAsyncTest.kt index 2ee2e8fb8..8e1868514 100644 --- a/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/async/RecordingTranscriptionServiceAsyncTest.kt +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/async/RecordingTranscriptionServiceAsyncTest.kt @@ -27,10 +27,10 @@ internal class RecordingTranscriptionServiceAsyncTest { val client = TelnyxOkHttpClientAsync.builder().apiKey("My API Key").build() val recordingTranscriptionServiceAsync = client.recordingTranscriptions() - val recordingTranscriptionsFuture = recordingTranscriptionServiceAsync.list() + val pageFuture = recordingTranscriptionServiceAsync.list() - val recordingTranscriptions = recordingTranscriptionsFuture.get() - recordingTranscriptions.validate() + val page = pageFuture.get() + page.response().validate() } @Disabled("Mock server tests are disabled") diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/async/VoiceCloneServiceAsyncTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/async/VoiceCloneServiceAsyncTest.kt new file mode 100644 index 000000000..934297dd1 --- /dev/null +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/async/VoiceCloneServiceAsyncTest.kt @@ -0,0 +1,125 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.services.async + +import com.github.tomakehurst.wiremock.client.WireMock.anyUrl +import com.github.tomakehurst.wiremock.client.WireMock.get +import com.github.tomakehurst.wiremock.client.WireMock.ok +import com.github.tomakehurst.wiremock.client.WireMock.stubFor +import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo +import com.github.tomakehurst.wiremock.junit5.WireMockTest +import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClientAsync +import com.telnyx.sdk.models.voiceclones.VoiceCloneCreateFromUploadParams +import com.telnyx.sdk.models.voiceclones.VoiceCloneCreateParams +import com.telnyx.sdk.models.voiceclones.VoiceCloneUpdateParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.parallel.ResourceLock + +@WireMockTest +@ResourceLock("https://github.com/wiremock/wiremock/issues/169") +internal class VoiceCloneServiceAsyncTest { + + @Disabled("Mock server tests are disabled") + @Test + fun create() { + val client = TelnyxOkHttpClientAsync.builder().apiKey("My API Key").build() + val voiceCloneServiceAsync = client.voiceClones() + + val voiceCloneFuture = + voiceCloneServiceAsync.create( + VoiceCloneCreateParams.builder() + .gender(VoiceCloneCreateParams.Gender.MALE) + .language("en") + .name("clone-narrator") + .voiceDesignId("550e8400-e29b-41d4-a716-446655440000") + .build() + ) + + val voiceClone = voiceCloneFuture.get() + voiceClone.validate() + } + + @Disabled("Mock server tests are disabled") + @Test + fun update() { + val client = TelnyxOkHttpClientAsync.builder().apiKey("My API Key").build() + val voiceCloneServiceAsync = client.voiceClones() + + val voiceCloneFuture = + voiceCloneServiceAsync.update( + VoiceCloneUpdateParams.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("updated-clone") + .gender(VoiceCloneUpdateParams.Gender.MALE) + .language("language") + .build() + ) + + val voiceClone = voiceCloneFuture.get() + voiceClone.validate() + } + + @Disabled("Mock server tests are disabled") + @Test + fun list() { + val client = TelnyxOkHttpClientAsync.builder().apiKey("My API Key").build() + val voiceCloneServiceAsync = client.voiceClones() + + val pageFuture = voiceCloneServiceAsync.list() + + val page = pageFuture.get() + page.response().validate() + } + + @Disabled("Mock server tests are disabled") + @Test + fun delete() { + val client = TelnyxOkHttpClientAsync.builder().apiKey("My API Key").build() + val voiceCloneServiceAsync = client.voiceClones() + + val future = voiceCloneServiceAsync.delete("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + val response = future.get() + } + + @Disabled("Mock server tests are disabled") + @Test + fun createFromUpload() { + val client = TelnyxOkHttpClientAsync.builder().apiKey("My API Key").build() + val voiceCloneServiceAsync = client.voiceClones() + + val responseFuture = + voiceCloneServiceAsync.createFromUpload( + VoiceCloneCreateFromUploadParams.builder() + .audioFile("Example data".byteInputStream()) + .language("lkf-Lz1vLbBu-9uDh-9AHaOS2D-Cbf") + .name("name") + .gender(VoiceCloneCreateFromUploadParams.Gender.MALE) + .label("label") + .refText("ref_text") + .build() + ) + + val response = responseFuture.get() + response.validate() + } + + @Test + fun downloadSample(wmRuntimeInfo: WireMockRuntimeInfo) { + val client = + TelnyxOkHttpClientAsync.builder() + .baseUrl(wmRuntimeInfo.httpBaseUrl) + .apiKey("My API Key") + .build() + val voiceCloneServiceAsync = client.voiceClones() + stubFor(get(anyUrl()).willReturn(ok().withBody("abc"))) + + val responseFuture = + voiceCloneServiceAsync.downloadSample("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + val response = responseFuture.get() + assertThat(response.body()).hasContent("abc") + } +} diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/async/VoiceDesignServiceAsyncTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/async/VoiceDesignServiceAsyncTest.kt new file mode 100644 index 000000000..7c3d84071 --- /dev/null +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/async/VoiceDesignServiceAsyncTest.kt @@ -0,0 +1,137 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.services.async + +import com.github.tomakehurst.wiremock.client.WireMock.anyUrl +import com.github.tomakehurst.wiremock.client.WireMock.get +import com.github.tomakehurst.wiremock.client.WireMock.ok +import com.github.tomakehurst.wiremock.client.WireMock.stubFor +import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo +import com.github.tomakehurst.wiremock.junit5.WireMockTest +import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClientAsync +import com.telnyx.sdk.models.voicedesigns.VoiceDesignCreateParams +import com.telnyx.sdk.models.voicedesigns.VoiceDesignDeleteVersionParams +import com.telnyx.sdk.models.voicedesigns.VoiceDesignDownloadSampleParams +import com.telnyx.sdk.models.voicedesigns.VoiceDesignRenameParams +import com.telnyx.sdk.models.voicedesigns.VoiceDesignRetrieveParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.parallel.ResourceLock + +@WireMockTest +@ResourceLock("https://github.com/wiremock/wiremock/issues/169") +internal class VoiceDesignServiceAsyncTest { + + @Disabled("Mock server tests are disabled") + @Test + fun create() { + val client = TelnyxOkHttpClientAsync.builder().apiKey("My API Key").build() + val voiceDesignServiceAsync = client.voiceDesigns() + + val voiceDesignFuture = + voiceDesignServiceAsync.create( + VoiceDesignCreateParams.builder() + .prompt("Speak in a warm, friendly tone") + .text("Hello, welcome to our service.") + .language("Auto") + .maxNewTokens(100L) + .name("friendly-narrator") + .repetitionPenalty(1.0f) + .temperature(0.0f) + .topK(1L) + .topP(0.0f) + .voiceDesignId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val voiceDesign = voiceDesignFuture.get() + voiceDesign.validate() + } + + @Disabled("Mock server tests are disabled") + @Test + fun retrieve() { + val client = TelnyxOkHttpClientAsync.builder().apiKey("My API Key").build() + val voiceDesignServiceAsync = client.voiceDesigns() + + val voiceDesignFuture = + voiceDesignServiceAsync.retrieve( + VoiceDesignRetrieveParams.builder().id("id").version(1L).build() + ) + + val voiceDesign = voiceDesignFuture.get() + voiceDesign.validate() + } + + @Disabled("Mock server tests are disabled") + @Test + fun list() { + val client = TelnyxOkHttpClientAsync.builder().apiKey("My API Key").build() + val voiceDesignServiceAsync = client.voiceDesigns() + + val pageFuture = voiceDesignServiceAsync.list() + + val page = pageFuture.get() + page.response().validate() + } + + @Disabled("Mock server tests are disabled") + @Test + fun delete() { + val client = TelnyxOkHttpClientAsync.builder().apiKey("My API Key").build() + val voiceDesignServiceAsync = client.voiceDesigns() + + val future = voiceDesignServiceAsync.delete("id") + + val response = future.get() + } + + @Disabled("Mock server tests are disabled") + @Test + fun deleteVersion() { + val client = TelnyxOkHttpClientAsync.builder().apiKey("My API Key").build() + val voiceDesignServiceAsync = client.voiceDesigns() + + val future = + voiceDesignServiceAsync.deleteVersion( + VoiceDesignDeleteVersionParams.builder().id("id").version(1L).build() + ) + + val response = future.get() + } + + @Test + fun downloadSample(wmRuntimeInfo: WireMockRuntimeInfo) { + val client = + TelnyxOkHttpClientAsync.builder() + .baseUrl(wmRuntimeInfo.httpBaseUrl) + .apiKey("My API Key") + .build() + val voiceDesignServiceAsync = client.voiceDesigns() + stubFor(get(anyUrl()).willReturn(ok().withBody("abc"))) + + val responseFuture = + voiceDesignServiceAsync.downloadSample( + VoiceDesignDownloadSampleParams.builder().id("id").version(1L).build() + ) + + val response = responseFuture.get() + assertThat(response.body()).hasContent("abc") + } + + @Disabled("Mock server tests are disabled") + @Test + fun rename() { + val client = TelnyxOkHttpClientAsync.builder().apiKey("My API Key").build() + val voiceDesignServiceAsync = client.voiceDesigns() + + val responseFuture = + voiceDesignServiceAsync.rename( + VoiceDesignRenameParams.builder().id("id").name("updated-narrator").build() + ) + + val response = responseFuture.get() + response.validate() + } +} diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/async/ai/AssistantServiceAsyncTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/async/ai/AssistantServiceAsyncTest.kt index dcaf7ea7c..8f5f2ba2b 100644 --- a/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/async/ai/AssistantServiceAsyncTest.kt +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/async/ai/AssistantServiceAsyncTest.kt @@ -209,6 +209,7 @@ internal class AssistantServiceAsyncTest { VoiceSettings.BackgroundAudio.PredefinedMedia.PredefinedMediaValue .SILENCE ) + .expressiveMode(true) .languageBoost(VoiceSettings.LanguageBoost.AUTO) .similarityBoost(0.0) .speed(0.0) @@ -449,6 +450,7 @@ internal class AssistantServiceAsyncTest { VoiceSettings.BackgroundAudio.PredefinedMedia.PredefinedMediaValue .SILENCE ) + .expressiveMode(true) .languageBoost(VoiceSettings.LanguageBoost.AUTO) .similarityBoost(0.0) .speed(0.0) diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/async/ai/assistants/VersionServiceAsyncTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/async/ai/assistants/VersionServiceAsyncTest.kt index ff221cbdd..793654b0b 100644 --- a/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/async/ai/assistants/VersionServiceAsyncTest.kt +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/async/ai/assistants/VersionServiceAsyncTest.kt @@ -254,6 +254,7 @@ internal class VersionServiceAsyncTest { .PredefinedMediaValue .SILENCE ) + .expressiveMode(true) .languageBoost(VoiceSettings.LanguageBoost.AUTO) .similarityBoost(0.0) .speed(0.0) diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/async/recordings/ActionServiceAsyncTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/async/recordings/ActionServiceAsyncTest.kt index 2e92cdda5..ba77c0279 100644 --- a/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/async/recordings/ActionServiceAsyncTest.kt +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/async/recordings/ActionServiceAsyncTest.kt @@ -15,7 +15,7 @@ internal class ActionServiceAsyncTest { val client = TelnyxOkHttpClientAsync.builder().apiKey("My API Key").build() val actionServiceAsync = client.recordings().actions() - val future = + val actionFuture = actionServiceAsync.delete( ActionDeleteParams.builder() .addId("428c31b6-7af4-4bcb-b7f5-5013ef9657c1") @@ -23,6 +23,7 @@ internal class ActionServiceAsyncTest { .build() ) - val response = future.get() + val action = actionFuture.get() + action.validate() } } diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/async/x402/CreditAccountServiceAsyncTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/async/x402/CreditAccountServiceAsyncTest.kt new file mode 100644 index 000000000..fd1e4dbf8 --- /dev/null +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/async/x402/CreditAccountServiceAsyncTest.kt @@ -0,0 +1,46 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.services.async.x402 + +import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClientAsync +import com.telnyx.sdk.models.x402.creditaccount.CreditAccountCreateQuoteParams +import com.telnyx.sdk.models.x402.creditaccount.CreditAccountSettleParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test + +internal class CreditAccountServiceAsyncTest { + + @Disabled("Mock server tests are disabled") + @Test + fun createQuote() { + val client = TelnyxOkHttpClientAsync.builder().apiKey("My API Key").build() + val creditAccountServiceAsync = client.x402().creditAccount() + + val responseFuture = + creditAccountServiceAsync.createQuote( + CreditAccountCreateQuoteParams.builder().amountUsd("50.00").build() + ) + + val response = responseFuture.get() + response.validate() + } + + @Disabled("Mock server tests are disabled") + @Test + fun settle() { + val client = TelnyxOkHttpClientAsync.builder().apiKey("My API Key").build() + val creditAccountServiceAsync = client.x402().creditAccount() + + val responseFuture = + creditAccountServiceAsync.settle( + CreditAccountSettleParams.builder() + .paymentSignatureHeader("PAYMENT-SIGNATURE") + .id("quote_abc123") + .paymentSignature("0xabc123...") + .build() + ) + + val response = responseFuture.get() + response.validate() + } +} diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/blocking/RecordingTranscriptionServiceTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/blocking/RecordingTranscriptionServiceTest.kt index e617b4289..8eaab0d72 100644 --- a/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/blocking/RecordingTranscriptionServiceTest.kt +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/blocking/RecordingTranscriptionServiceTest.kt @@ -26,9 +26,9 @@ internal class RecordingTranscriptionServiceTest { val client = TelnyxOkHttpClient.builder().apiKey("My API Key").build() val recordingTranscriptionService = client.recordingTranscriptions() - val recordingTranscriptions = recordingTranscriptionService.list() + val page = recordingTranscriptionService.list() - recordingTranscriptions.validate() + page.response().validate() } @Disabled("Mock server tests are disabled") diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/blocking/VoiceCloneServiceTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/blocking/VoiceCloneServiceTest.kt new file mode 100644 index 000000000..e04078c83 --- /dev/null +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/blocking/VoiceCloneServiceTest.kt @@ -0,0 +1,117 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.services.blocking + +import com.github.tomakehurst.wiremock.client.WireMock.anyUrl +import com.github.tomakehurst.wiremock.client.WireMock.get +import com.github.tomakehurst.wiremock.client.WireMock.ok +import com.github.tomakehurst.wiremock.client.WireMock.stubFor +import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo +import com.github.tomakehurst.wiremock.junit5.WireMockTest +import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient +import com.telnyx.sdk.models.voiceclones.VoiceCloneCreateFromUploadParams +import com.telnyx.sdk.models.voiceclones.VoiceCloneCreateParams +import com.telnyx.sdk.models.voiceclones.VoiceCloneUpdateParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.parallel.ResourceLock + +@WireMockTest +@ResourceLock("https://github.com/wiremock/wiremock/issues/169") +internal class VoiceCloneServiceTest { + + @Disabled("Mock server tests are disabled") + @Test + fun create() { + val client = TelnyxOkHttpClient.builder().apiKey("My API Key").build() + val voiceCloneService = client.voiceClones() + + val voiceClone = + voiceCloneService.create( + VoiceCloneCreateParams.builder() + .gender(VoiceCloneCreateParams.Gender.MALE) + .language("en") + .name("clone-narrator") + .voiceDesignId("550e8400-e29b-41d4-a716-446655440000") + .build() + ) + + voiceClone.validate() + } + + @Disabled("Mock server tests are disabled") + @Test + fun update() { + val client = TelnyxOkHttpClient.builder().apiKey("My API Key").build() + val voiceCloneService = client.voiceClones() + + val voiceClone = + voiceCloneService.update( + VoiceCloneUpdateParams.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("updated-clone") + .gender(VoiceCloneUpdateParams.Gender.MALE) + .language("language") + .build() + ) + + voiceClone.validate() + } + + @Disabled("Mock server tests are disabled") + @Test + fun list() { + val client = TelnyxOkHttpClient.builder().apiKey("My API Key").build() + val voiceCloneService = client.voiceClones() + + val page = voiceCloneService.list() + + page.response().validate() + } + + @Disabled("Mock server tests are disabled") + @Test + fun delete() { + val client = TelnyxOkHttpClient.builder().apiKey("My API Key").build() + val voiceCloneService = client.voiceClones() + + voiceCloneService.delete("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + } + + @Disabled("Mock server tests are disabled") + @Test + fun createFromUpload() { + val client = TelnyxOkHttpClient.builder().apiKey("My API Key").build() + val voiceCloneService = client.voiceClones() + + val response = + voiceCloneService.createFromUpload( + VoiceCloneCreateFromUploadParams.builder() + .audioFile("Example data".byteInputStream()) + .language("lkf-Lz1vLbBu-9uDh-9AHaOS2D-Cbf") + .name("name") + .gender(VoiceCloneCreateFromUploadParams.Gender.MALE) + .label("label") + .refText("ref_text") + .build() + ) + + response.validate() + } + + @Test + fun downloadSample(wmRuntimeInfo: WireMockRuntimeInfo) { + val client = + TelnyxOkHttpClient.builder() + .baseUrl(wmRuntimeInfo.httpBaseUrl) + .apiKey("My API Key") + .build() + val voiceCloneService = client.voiceClones() + stubFor(get(anyUrl()).willReturn(ok().withBody("abc"))) + + val response = voiceCloneService.downloadSample("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + assertThat(response.body()).hasContent("abc") + } +} diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/blocking/VoiceDesignServiceTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/blocking/VoiceDesignServiceTest.kt new file mode 100644 index 000000000..d2ce27c19 --- /dev/null +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/blocking/VoiceDesignServiceTest.kt @@ -0,0 +1,127 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.services.blocking + +import com.github.tomakehurst.wiremock.client.WireMock.anyUrl +import com.github.tomakehurst.wiremock.client.WireMock.get +import com.github.tomakehurst.wiremock.client.WireMock.ok +import com.github.tomakehurst.wiremock.client.WireMock.stubFor +import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo +import com.github.tomakehurst.wiremock.junit5.WireMockTest +import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient +import com.telnyx.sdk.models.voicedesigns.VoiceDesignCreateParams +import com.telnyx.sdk.models.voicedesigns.VoiceDesignDeleteVersionParams +import com.telnyx.sdk.models.voicedesigns.VoiceDesignDownloadSampleParams +import com.telnyx.sdk.models.voicedesigns.VoiceDesignRenameParams +import com.telnyx.sdk.models.voicedesigns.VoiceDesignRetrieveParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.parallel.ResourceLock + +@WireMockTest +@ResourceLock("https://github.com/wiremock/wiremock/issues/169") +internal class VoiceDesignServiceTest { + + @Disabled("Mock server tests are disabled") + @Test + fun create() { + val client = TelnyxOkHttpClient.builder().apiKey("My API Key").build() + val voiceDesignService = client.voiceDesigns() + + val voiceDesign = + voiceDesignService.create( + VoiceDesignCreateParams.builder() + .prompt("Speak in a warm, friendly tone") + .text("Hello, welcome to our service.") + .language("Auto") + .maxNewTokens(100L) + .name("friendly-narrator") + .repetitionPenalty(1.0f) + .temperature(0.0f) + .topK(1L) + .topP(0.0f) + .voiceDesignId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + voiceDesign.validate() + } + + @Disabled("Mock server tests are disabled") + @Test + fun retrieve() { + val client = TelnyxOkHttpClient.builder().apiKey("My API Key").build() + val voiceDesignService = client.voiceDesigns() + + val voiceDesign = + voiceDesignService.retrieve( + VoiceDesignRetrieveParams.builder().id("id").version(1L).build() + ) + + voiceDesign.validate() + } + + @Disabled("Mock server tests are disabled") + @Test + fun list() { + val client = TelnyxOkHttpClient.builder().apiKey("My API Key").build() + val voiceDesignService = client.voiceDesigns() + + val page = voiceDesignService.list() + + page.response().validate() + } + + @Disabled("Mock server tests are disabled") + @Test + fun delete() { + val client = TelnyxOkHttpClient.builder().apiKey("My API Key").build() + val voiceDesignService = client.voiceDesigns() + + voiceDesignService.delete("id") + } + + @Disabled("Mock server tests are disabled") + @Test + fun deleteVersion() { + val client = TelnyxOkHttpClient.builder().apiKey("My API Key").build() + val voiceDesignService = client.voiceDesigns() + + voiceDesignService.deleteVersion( + VoiceDesignDeleteVersionParams.builder().id("id").version(1L).build() + ) + } + + @Test + fun downloadSample(wmRuntimeInfo: WireMockRuntimeInfo) { + val client = + TelnyxOkHttpClient.builder() + .baseUrl(wmRuntimeInfo.httpBaseUrl) + .apiKey("My API Key") + .build() + val voiceDesignService = client.voiceDesigns() + stubFor(get(anyUrl()).willReturn(ok().withBody("abc"))) + + val response = + voiceDesignService.downloadSample( + VoiceDesignDownloadSampleParams.builder().id("id").version(1L).build() + ) + + assertThat(response.body()).hasContent("abc") + } + + @Disabled("Mock server tests are disabled") + @Test + fun rename() { + val client = TelnyxOkHttpClient.builder().apiKey("My API Key").build() + val voiceDesignService = client.voiceDesigns() + + val response = + voiceDesignService.rename( + VoiceDesignRenameParams.builder().id("id").name("updated-narrator").build() + ) + + response.validate() + } +} diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/blocking/ai/AssistantServiceTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/blocking/ai/AssistantServiceTest.kt index 5224cf09f..9c49ed777 100644 --- a/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/blocking/ai/AssistantServiceTest.kt +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/blocking/ai/AssistantServiceTest.kt @@ -209,6 +209,7 @@ internal class AssistantServiceTest { VoiceSettings.BackgroundAudio.PredefinedMedia.PredefinedMediaValue .SILENCE ) + .expressiveMode(true) .languageBoost(VoiceSettings.LanguageBoost.AUTO) .similarityBoost(0.0) .speed(0.0) @@ -447,6 +448,7 @@ internal class AssistantServiceTest { VoiceSettings.BackgroundAudio.PredefinedMedia.PredefinedMediaValue .SILENCE ) + .expressiveMode(true) .languageBoost(VoiceSettings.LanguageBoost.AUTO) .similarityBoost(0.0) .speed(0.0) diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/blocking/ai/assistants/VersionServiceTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/blocking/ai/assistants/VersionServiceTest.kt index ab343a3f8..cc85c459a 100644 --- a/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/blocking/ai/assistants/VersionServiceTest.kt +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/blocking/ai/assistants/VersionServiceTest.kt @@ -253,6 +253,7 @@ internal class VersionServiceTest { .PredefinedMediaValue .SILENCE ) + .expressiveMode(true) .languageBoost(VoiceSettings.LanguageBoost.AUTO) .similarityBoost(0.0) .speed(0.0) diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/blocking/recordings/ActionServiceTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/blocking/recordings/ActionServiceTest.kt index e6ed9fe75..bccba7540 100644 --- a/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/blocking/recordings/ActionServiceTest.kt +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/blocking/recordings/ActionServiceTest.kt @@ -15,11 +15,14 @@ internal class ActionServiceTest { val client = TelnyxOkHttpClient.builder().apiKey("My API Key").build() val actionService = client.recordings().actions() - actionService.delete( - ActionDeleteParams.builder() - .addId("428c31b6-7af4-4bcb-b7f5-5013ef9657c1") - .addId("428c31b6-7af4-4bcb-b7f5-5013ef9657c2") - .build() - ) + val action = + actionService.delete( + ActionDeleteParams.builder() + .addId("428c31b6-7af4-4bcb-b7f5-5013ef9657c1") + .addId("428c31b6-7af4-4bcb-b7f5-5013ef9657c2") + .build() + ) + + action.validate() } } diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/blocking/x402/CreditAccountServiceTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/blocking/x402/CreditAccountServiceTest.kt new file mode 100644 index 000000000..30debf05b --- /dev/null +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/blocking/x402/CreditAccountServiceTest.kt @@ -0,0 +1,44 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.services.blocking.x402 + +import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient +import com.telnyx.sdk.models.x402.creditaccount.CreditAccountCreateQuoteParams +import com.telnyx.sdk.models.x402.creditaccount.CreditAccountSettleParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test + +internal class CreditAccountServiceTest { + + @Disabled("Mock server tests are disabled") + @Test + fun createQuote() { + val client = TelnyxOkHttpClient.builder().apiKey("My API Key").build() + val creditAccountService = client.x402().creditAccount() + + val response = + creditAccountService.createQuote( + CreditAccountCreateQuoteParams.builder().amountUsd("50.00").build() + ) + + response.validate() + } + + @Disabled("Mock server tests are disabled") + @Test + fun settle() { + val client = TelnyxOkHttpClient.builder().apiKey("My API Key").build() + val creditAccountService = client.x402().creditAccount() + + val response = + creditAccountService.settle( + CreditAccountSettleParams.builder() + .paymentSignatureHeader("PAYMENT-SIGNATURE") + .id("quote_abc123") + .paymentSignature("0xabc123...") + .build() + ) + + response.validate() + } +} diff --git a/telnyx-proguard-test/src/test/kotlin/com/telnyx/sdk/proguard/ProGuardCompatibilityTest.kt b/telnyx-proguard-test/src/test/kotlin/com/telnyx/sdk/proguard/ProGuardCompatibilityTest.kt index 1c2f2579d..65e14d76d 100644 --- a/telnyx-proguard-test/src/test/kotlin/com/telnyx/sdk/proguard/ProGuardCompatibilityTest.kt +++ b/telnyx-proguard-test/src/test/kotlin/com/telnyx/sdk/proguard/ProGuardCompatibilityTest.kt @@ -210,6 +210,9 @@ internal class ProGuardCompatibilityTest { assertThat(client.sessionAnalysis()).isNotNull() assertThat(client.whatsapp()).isNotNull() assertThat(client.whatsappMessageTemplates()).isNotNull() + assertThat(client.voiceClones()).isNotNull() + assertThat(client.voiceDesigns()).isNotNull() + assertThat(client.x402()).isNotNull() } @Test