// Code generated by smithy-go-codegen DO NOT EDIT.

package restxml

import (
	"context"
	"github.com/aws/aws-sdk-go-v2/internal/protocoltest/restxml/schemas"
	"github.com/aws/aws-sdk-go-v2/internal/protocoltest/restxml/types"
	smithy "github.com/aws/smithy-go"
	"github.com/aws/smithy-go/middleware"
	smithyhttp "github.com/aws/smithy-go/transport/http"
)

// This example serializes enums as top level properties, in lists, sets, and maps.
func (c *Client) XmlIntEnums(ctx context.Context, params *XmlIntEnumsInput, optFns ...func(*Options)) (*XmlIntEnumsOutput, error) {
	if params == nil {
		params = &XmlIntEnumsInput{}
	}

	result, metadata, err := c.invokeOperation(ctx, "XmlIntEnums", params, optFns, c.addOperationXmlIntEnumsMiddlewares)
	if err != nil {
		return nil, err
	}

	out := result.(*XmlIntEnumsOutput)
	out.ResultMetadata = metadata
	return out, nil
}

type XmlIntEnumsInput struct {
	IntEnum1 types.IntegerEnum

	IntEnum2 types.IntegerEnum

	IntEnum3 types.IntegerEnum

	IntEnumList []types.IntegerEnum

	IntEnumMap map[string]types.IntegerEnum

	IntEnumSet []types.IntegerEnum

	noSmithyDocumentSerde
}

func (v *XmlIntEnumsInput) Serialize(s smithy.ShapeSerializer) {
	s.WriteStruct(schemas.XmlIntEnumsRequest)
	v.SerializeMembers(s)
	s.CloseStruct()
}

func (v *XmlIntEnumsInput) SerializeMembers(s smithy.ShapeSerializer) {
	if v.IntEnum1 != 0 {
		s.WriteInt32(schemas.XmlIntEnumsRequest_intEnum1, int32(v.IntEnum1))
	}
	if v.IntEnum2 != 0 {
		s.WriteInt32(schemas.XmlIntEnumsRequest_intEnum2, int32(v.IntEnum2))
	}
	if v.IntEnum3 != 0 {
		s.WriteInt32(schemas.XmlIntEnumsRequest_intEnum3, int32(v.IntEnum3))
	}
	serializeIntegerEnumList(s, schemas.XmlIntEnumsRequest_intEnumList, v.IntEnumList)
	serializeIntegerEnumMap(s, schemas.XmlIntEnumsRequest_intEnumMap, v.IntEnumMap)
	serializeIntegerEnumSet(s, schemas.XmlIntEnumsRequest_intEnumSet, v.IntEnumSet)
}

type XmlIntEnumsOutput struct {
	IntEnum1 types.IntegerEnum

	IntEnum2 types.IntegerEnum

	IntEnum3 types.IntegerEnum

	IntEnumList []types.IntegerEnum

	IntEnumMap map[string]types.IntegerEnum

	IntEnumSet []types.IntegerEnum

	// Metadata pertaining to the operation's result.
	ResultMetadata middleware.Metadata

	noSmithyDocumentSerde
}

func (v *XmlIntEnumsOutput) Serialize(s smithy.ShapeSerializer) {
	s.WriteStruct(schemas.XmlIntEnumsResponse)
	v.SerializeMembers(s)
	s.CloseStruct()
}

func (v *XmlIntEnumsOutput) SerializeMembers(s smithy.ShapeSerializer) {
	if v.IntEnum1 != 0 {
		s.WriteInt32(schemas.XmlIntEnumsResponse_intEnum1, int32(v.IntEnum1))
	}
	if v.IntEnum2 != 0 {
		s.WriteInt32(schemas.XmlIntEnumsResponse_intEnum2, int32(v.IntEnum2))
	}
	if v.IntEnum3 != 0 {
		s.WriteInt32(schemas.XmlIntEnumsResponse_intEnum3, int32(v.IntEnum3))
	}
	serializeIntegerEnumList(s, schemas.XmlIntEnumsResponse_intEnumList, v.IntEnumList)
	serializeIntegerEnumMap(s, schemas.XmlIntEnumsResponse_intEnumMap, v.IntEnumMap)
	serializeIntegerEnumSet(s, schemas.XmlIntEnumsResponse_intEnumSet, v.IntEnumSet)
}
func (v *XmlIntEnumsOutput) Deserialize(d smithy.ShapeDeserializer) error {
	return smithy.ReadStruct(d, schemas.XmlIntEnumsResponse, func(s *smithy.Schema) error {
		switch s {
		case schemas.XmlIntEnumsResponse_intEnum1:
			var ev int32
			if err := d.ReadInt32(schemas.XmlIntEnumsResponse_intEnum1, &ev); err != nil {
				return err
			}
			v.IntEnum1 = types.IntegerEnum(ev)
			return nil
		case schemas.XmlIntEnumsResponse_intEnum2:
			var ev int32
			if err := d.ReadInt32(schemas.XmlIntEnumsResponse_intEnum2, &ev); err != nil {
				return err
			}
			v.IntEnum2 = types.IntegerEnum(ev)
			return nil
		case schemas.XmlIntEnumsResponse_intEnum3:
			var ev int32
			if err := d.ReadInt32(schemas.XmlIntEnumsResponse_intEnum3, &ev); err != nil {
				return err
			}
			v.IntEnum3 = types.IntegerEnum(ev)
			return nil
		case schemas.XmlIntEnumsResponse_intEnumList:
			return deserializeIntegerEnumList(d, schemas.XmlIntEnumsResponse_intEnumList, &v.IntEnumList)
		case schemas.XmlIntEnumsResponse_intEnumMap:
			return deserializeIntegerEnumMap(d, schemas.XmlIntEnumsResponse_intEnumMap, &v.IntEnumMap)
		case schemas.XmlIntEnumsResponse_intEnumSet:
			return deserializeIntegerEnumSet(d, schemas.XmlIntEnumsResponse_intEnumSet, &v.IntEnumSet)
		}
		return nil
	})
}
func (c *Client) addOperationXmlIntEnumsMiddlewares(stack *middleware.Stack, options Options) (err error) {
	if err := stack.Serialize.Add(&serializeRequestMiddleware{options: &options, operationSchema: smithy.NewOperationSchema(schemas.XmlIntEnums, schemas.XmlIntEnumsRequest, schemas.XmlIntEnumsResponse)}, middleware.After); err != nil {
		return err
	}
	if err := stack.Deserialize.Add(&deserializeResponseMiddleware{options: &options, operationSchema: smithy.NewOperationSchema(schemas.XmlIntEnums, schemas.XmlIntEnumsRequest, schemas.XmlIntEnumsResponse), output: &XmlIntEnumsOutput{}}, middleware.After); err != nil {
		return err
	}

	if err = addlegacyEndpointContextSetter(stack, options); err != nil {
		return err
	}
	if err = addComputeContentLength(stack); err != nil {
		return err
	}
	if err = addResolveEndpointMiddleware(stack, options); err != nil {
		return err
	}
	if err = addComputePayloadSHA256(stack); err != nil {
		return err
	}
	if err = addRecordResponseTiming(stack, options); err != nil {
		return err
	}
	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
		return err
	}
	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
		return err
	}
	if err = addCredentialSource(stack, options); err != nil {
		return err
	}
	if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "XmlIntEnums"), middleware.Before); err != nil {
		return err
	}
	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
		return err
	}
	if err = addResponseErrorMiddleware(stack); err != nil {
		return err
	}
	if err = addRequestResponseLogging(stack, options); err != nil {
		return err
	}
	if err = addDisableHTTPSMiddleware(stack, options); err != nil {
		return err
	}
	if err = addInterceptors(stack, options); err != nil {
		return err
	}
	return nil
}
