commonMain.aws.sdk.kotlin.services.pinpointsmsvoicev2.serde.SendVoiceMessageOperationSerializer.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.SendVoiceMessageRequest
import aws.sdk.kotlin.services.pinpointsmsvoicev2.model.VoiceId
import aws.sdk.kotlin.services.pinpointsmsvoicev2.model.VoiceMessageBodyTextType
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 SendVoiceMessageOperationSerializer: HttpSerializer.NonStreaming {
override fun serialize(context: ExecutionContext, input: SendVoiceMessageRequest): HttpRequestBuilder {
val builder = HttpRequestBuilder()
builder.method = HttpMethod.POST
builder.url {
path.encoded = "/"
}
val payload = serializeSendVoiceMessageOperationBody(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 serializeSendVoiceMessageOperationBody(context: ExecutionContext, input: SendVoiceMessageRequest): ByteArray {
val serializer = JsonSerializer()
val CONFIGURATIONSETNAME_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("ConfigurationSetName"))
val CONTEXT_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Map, JsonSerialName("Context"))
val DESTINATIONPHONENUMBER_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("DestinationPhoneNumber"))
val DRYRUN_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Boolean, JsonSerialName("DryRun"))
val MAXPRICEPERMINUTE_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("MaxPricePerMinute"))
val MESSAGEBODY_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("MessageBody"))
val MESSAGEBODYTEXTTYPE_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("MessageBodyTextType"))
val ORIGINATIONIDENTITY_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("OriginationIdentity"))
val PROTECTCONFIGURATIONID_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("ProtectConfigurationId"))
val TIMETOLIVE_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Integer, JsonSerialName("TimeToLive"))
val VOICEID_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("VoiceId"))
val OBJ_DESCRIPTOR = SdkObjectDescriptor.build {
field(CONFIGURATIONSETNAME_DESCRIPTOR)
field(CONTEXT_DESCRIPTOR)
field(DESTINATIONPHONENUMBER_DESCRIPTOR)
field(DRYRUN_DESCRIPTOR)
field(MAXPRICEPERMINUTE_DESCRIPTOR)
field(MESSAGEBODY_DESCRIPTOR)
field(MESSAGEBODYTEXTTYPE_DESCRIPTOR)
field(ORIGINATIONIDENTITY_DESCRIPTOR)
field(PROTECTCONFIGURATIONID_DESCRIPTOR)
field(TIMETOLIVE_DESCRIPTOR)
field(VOICEID_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)
}
}
}
input.destinationPhoneNumber?.let { field(DESTINATIONPHONENUMBER_DESCRIPTOR, it) }
input.dryRun?.let { field(DRYRUN_DESCRIPTOR, it) }
input.maxPricePerMinute?.let { field(MAXPRICEPERMINUTE_DESCRIPTOR, it) }
input.messageBody?.let { field(MESSAGEBODY_DESCRIPTOR, it) }
input.messageBodyTextType?.let { field(MESSAGEBODYTEXTTYPE_DESCRIPTOR, it.value) }
input.originationIdentity?.let { field(ORIGINATIONIDENTITY_DESCRIPTOR, it) }
input.protectConfigurationId?.let { field(PROTECTCONFIGURATIONID_DESCRIPTOR, it) }
input.timeToLive?.let { field(TIMETOLIVE_DESCRIPTOR, it) }
input.voiceId?.let { field(VOICEID_DESCRIPTOR, it.value) }
}
return serializer.toByteArray()
}