All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.aws.sdk.kotlin.services.pinpointsmsvoicev2.serde.SendTextMessageOperationSerializer.kt Maven / Gradle / Ivy

There is a newer version: 1.3.78
Show newest version
// 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.MessageType
import aws.sdk.kotlin.services.pinpointsmsvoicev2.model.SendTextMessageRequest
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 SendTextMessageOperationSerializer: HttpSerializer.NonStreaming {
    override fun serialize(context: ExecutionContext, input: SendTextMessageRequest): HttpRequestBuilder {
        val builder = HttpRequestBuilder()
        builder.method = HttpMethod.POST

        builder.url {
            path.encoded = "/"
        }

        val payload = serializeSendTextMessageOperationBody(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 serializeSendTextMessageOperationBody(context: ExecutionContext, input: SendTextMessageRequest): 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 DESTINATIONPHONENUMBER_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("DestinationPhoneNumber"))
    val DRYRUN_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Boolean, JsonSerialName("DryRun"))
    val KEYWORD_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("Keyword"))
    val MAXPRICE_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("MaxPrice"))
    val MESSAGEBODY_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("MessageBody"))
    val MESSAGETYPE_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("MessageType"))
    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 OBJ_DESCRIPTOR = SdkObjectDescriptor.build {
        field(CONFIGURATIONSETNAME_DESCRIPTOR)
        field(CONTEXT_DESCRIPTOR)
        field(DESTINATIONCOUNTRYPARAMETERS_DESCRIPTOR)
        field(DESTINATIONPHONENUMBER_DESCRIPTOR)
        field(DRYRUN_DESCRIPTOR)
        field(KEYWORD_DESCRIPTOR)
        field(MAXPRICE_DESCRIPTOR)
        field(MESSAGEBODY_DESCRIPTOR)
        field(MESSAGETYPE_DESCRIPTOR)
        field(ORIGINATIONIDENTITY_DESCRIPTOR)
        field(PROTECTCONFIGURATIONID_DESCRIPTOR)
        field(TIMETOLIVE_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.destinationPhoneNumber?.let { field(DESTINATIONPHONENUMBER_DESCRIPTOR, it) }
        input.dryRun?.let { field(DRYRUN_DESCRIPTOR, it) }
        input.keyword?.let { field(KEYWORD_DESCRIPTOR, it) }
        input.maxPrice?.let { field(MAXPRICE_DESCRIPTOR, it) }
        input.messageBody?.let { field(MESSAGEBODY_DESCRIPTOR, it) }
        input.messageType?.let { field(MESSAGETYPE_DESCRIPTOR, it.value) }
        input.originationIdentity?.let { field(ORIGINATIONIDENTITY_DESCRIPTOR, it) }
        input.protectConfigurationId?.let { field(PROTECTCONFIGURATIONID_DESCRIPTOR, it) }
        input.timeToLive?.let { field(TIMETOLIVE_DESCRIPTOR, it) }
    }
    return serializer.toByteArray()
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy