commonMain.aws.sdk.kotlin.services.pinpointsmsvoicev2.serde.SendDestinationNumberVerificationCodeOperationSerializer.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pinpointsmsvoicev2-jvm Show documentation
Show all versions of pinpointsmsvoicev2-jvm Show documentation
The AWS SDK for Kotlin client for Pinpoint SMS Voice V2
// Code generated by smithy-kotlin-codegen. DO NOT EDIT!
package aws.sdk.kotlin.services.pinpointsmsvoicev2.serde
import aws.sdk.kotlin.services.pinpointsmsvoicev2.model.DestinationCountryParameterKey
import aws.sdk.kotlin.services.pinpointsmsvoicev2.model.LanguageCode
import aws.sdk.kotlin.services.pinpointsmsvoicev2.model.SendDestinationNumberVerificationCodeRequest
import aws.sdk.kotlin.services.pinpointsmsvoicev2.model.VerificationChannel
import aws.smithy.kotlin.runtime.http.HttpBody
import aws.smithy.kotlin.runtime.http.HttpMethod
import aws.smithy.kotlin.runtime.http.operation.HttpSerializer
import aws.smithy.kotlin.runtime.http.request.HttpRequestBuilder
import aws.smithy.kotlin.runtime.http.request.url
import aws.smithy.kotlin.runtime.operation.ExecutionContext
import aws.smithy.kotlin.runtime.serde.SdkFieldDescriptor
import aws.smithy.kotlin.runtime.serde.SdkObjectDescriptor
import aws.smithy.kotlin.runtime.serde.SerialKind
import aws.smithy.kotlin.runtime.serde.asSdkSerializable
import aws.smithy.kotlin.runtime.serde.deserializeList
import aws.smithy.kotlin.runtime.serde.deserializeMap
import aws.smithy.kotlin.runtime.serde.deserializeStruct
import aws.smithy.kotlin.runtime.serde.field
import aws.smithy.kotlin.runtime.serde.json.JsonDeserializer
import aws.smithy.kotlin.runtime.serde.json.JsonSerialName
import aws.smithy.kotlin.runtime.serde.json.JsonSerializer
import aws.smithy.kotlin.runtime.serde.serializeList
import aws.smithy.kotlin.runtime.serde.serializeMap
import aws.smithy.kotlin.runtime.serde.serializeStruct
internal class SendDestinationNumberVerificationCodeOperationSerializer: HttpSerializer.NonStreaming {
override fun serialize(context: ExecutionContext, input: SendDestinationNumberVerificationCodeRequest): HttpRequestBuilder {
val builder = HttpRequestBuilder()
builder.method = HttpMethod.POST
builder.url {
path.encoded = "/"
}
val payload = serializeSendDestinationNumberVerificationCodeOperationBody(context, input)
builder.body = HttpBody.fromBytes(payload)
if (builder.body !is HttpBody.Empty) {
builder.headers.setMissing("Content-Type", "application/x-amz-json-1.0")
}
return builder
}
}
private fun serializeSendDestinationNumberVerificationCodeOperationBody(context: ExecutionContext, input: SendDestinationNumberVerificationCodeRequest): ByteArray {
val serializer = JsonSerializer()
val CONFIGURATIONSETNAME_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("ConfigurationSetName"))
val CONTEXT_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Map, JsonSerialName("Context"))
val DESTINATIONCOUNTRYPARAMETERS_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Map, JsonSerialName("DestinationCountryParameters"))
val LANGUAGECODE_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("LanguageCode"))
val ORIGINATIONIDENTITY_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("OriginationIdentity"))
val VERIFICATIONCHANNEL_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("VerificationChannel"))
val VERIFIEDDESTINATIONNUMBERID_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("VerifiedDestinationNumberId"))
val OBJ_DESCRIPTOR = SdkObjectDescriptor.build {
field(CONFIGURATIONSETNAME_DESCRIPTOR)
field(CONTEXT_DESCRIPTOR)
field(DESTINATIONCOUNTRYPARAMETERS_DESCRIPTOR)
field(LANGUAGECODE_DESCRIPTOR)
field(ORIGINATIONIDENTITY_DESCRIPTOR)
field(VERIFICATIONCHANNEL_DESCRIPTOR)
field(VERIFIEDDESTINATIONNUMBERID_DESCRIPTOR)
}
serializer.serializeStruct(OBJ_DESCRIPTOR) {
input.configurationSetName?.let { field(CONFIGURATIONSETNAME_DESCRIPTOR, it) }
if (input.context != null) {
mapField(CONTEXT_DESCRIPTOR) {
input.context.forEach { (key, value) ->
entry(key, value)
}
}
}
if (input.destinationCountryParameters != null) {
mapField(DESTINATIONCOUNTRYPARAMETERS_DESCRIPTOR) {
input.destinationCountryParameters.forEach { (key, value) ->
entry(key.value, value)
}
}
}
input.languageCode?.let { field(LANGUAGECODE_DESCRIPTOR, it.value) }
input.originationIdentity?.let { field(ORIGINATIONIDENTITY_DESCRIPTOR, it) }
input.verificationChannel?.let { field(VERIFICATIONCHANNEL_DESCRIPTOR, it.value) }
input.verifiedDestinationNumberId?.let { field(VERIFIEDDESTINATIONNUMBERID_DESCRIPTOR, it) }
}
return serializer.toByteArray()
}