// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.

package connect

import (
	"context"

	"github.com/aws/aws-sdk-go-v2/aws"
	"github.com/aws/aws-sdk-go-v2/internal/awsutil"
	"github.com/aws/aws-sdk-go-v2/private/protocol"
)

// Please also see https://docs.aws.amazon.com/goto/WebAPI/connect-2017-08-08/StopContactRequest
type StopContactInput struct {
	_ struct{} `type:"structure"`

	// The unique identifier of the contact to end.
	//
	// ContactId is a required field
	ContactId *string `min:"1" type:"string" required:"true"`

	// The identifier for your Amazon Connect instance. To find the ID of your instance,
	// open the AWS console and select Amazon Connect. Select the alias of the instance
	// in the Instance alias column. The instance ID is displayed in the Overview
	// section of your instance settings. For example, the instance ID is the set
	// of characters at the end of the instance ARN, after instance/, such as 10a4c4eb-f57e-4d4c-b602-bf39176ced07.
	//
	// InstanceId is a required field
	InstanceId *string `min:"1" type:"string" required:"true"`
}

// String returns the string representation
func (s StopContactInput) String() string {
	return awsutil.Prettify(s)
}

// Validate inspects the fields of the type to determine if they are valid.
func (s *StopContactInput) Validate() error {
	invalidParams := aws.ErrInvalidParams{Context: "StopContactInput"}

	if s.ContactId == nil {
		invalidParams.Add(aws.NewErrParamRequired("ContactId"))
	}
	if s.ContactId != nil && len(*s.ContactId) < 1 {
		invalidParams.Add(aws.NewErrParamMinLen("ContactId", 1))
	}

	if s.InstanceId == nil {
		invalidParams.Add(aws.NewErrParamRequired("InstanceId"))
	}
	if s.InstanceId != nil && len(*s.InstanceId) < 1 {
		invalidParams.Add(aws.NewErrParamMinLen("InstanceId", 1))
	}

	if invalidParams.Len() > 0 {
		return invalidParams
	}
	return nil
}

// MarshalFields encodes the AWS API shape using the passed in protocol encoder.
func (s StopContactInput) MarshalFields(e protocol.FieldEncoder) error {
	e.SetValue(protocol.HeaderTarget, "Content-Type", protocol.StringValue("application/x-amz-json-1.1"), protocol.Metadata{})

	if s.ContactId != nil {
		v := *s.ContactId

		metadata := protocol.Metadata{}
		e.SetValue(protocol.BodyTarget, "ContactId", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata)
	}
	if s.InstanceId != nil {
		v := *s.InstanceId

		metadata := protocol.Metadata{}
		e.SetValue(protocol.BodyTarget, "InstanceId", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata)
	}
	return nil
}

// Please also see https://docs.aws.amazon.com/goto/WebAPI/connect-2017-08-08/StopContactResponse
type StopContactOutput struct {
	_ struct{} `type:"structure"`
}

// String returns the string representation
func (s StopContactOutput) String() string {
	return awsutil.Prettify(s)
}

// MarshalFields encodes the AWS API shape using the passed in protocol encoder.
func (s StopContactOutput) MarshalFields(e protocol.FieldEncoder) error {
	return nil
}

const opStopContact = "StopContact"

// StopContactRequest returns a request value for making API operation for
// Amazon Connect Service.
//
// Ends the contact initiated by the StartOutboundVoiceContact operation.
//
// If you are using an IAM account, it must have permission to the connect:StopContact
// action.
//
//    // Example sending a request using StopContactRequest.
//    req := client.StopContactRequest(params)
//    resp, err := req.Send(context.TODO())
//    if err == nil {
//        fmt.Println(resp)
//    }
//
// Please also see https://docs.aws.amazon.com/goto/WebAPI/connect-2017-08-08/StopContact
func (c *Client) StopContactRequest(input *StopContactInput) StopContactRequest {
	op := &aws.Operation{
		Name:       opStopContact,
		HTTPMethod: "POST",
		HTTPPath:   "/contact/stop",
	}

	if input == nil {
		input = &StopContactInput{}
	}

	req := c.newRequest(op, input, &StopContactOutput{})
	return StopContactRequest{Request: req, Input: input, Copy: c.StopContactRequest}
}

// StopContactRequest is the request type for the
// StopContact API operation.
type StopContactRequest struct {
	*aws.Request
	Input *StopContactInput
	Copy  func(*StopContactInput) StopContactRequest
}

// Send marshals and sends the StopContact API request.
func (r StopContactRequest) Send(ctx context.Context) (*StopContactResponse, error) {
	r.Request.SetContext(ctx)
	err := r.Request.Send()
	if err != nil {
		return nil, err
	}

	resp := &StopContactResponse{
		StopContactOutput: r.Request.Data.(*StopContactOutput),
		response:          &aws.Response{Request: r.Request},
	}

	return resp, nil
}

// StopContactResponse is the response type for the
// StopContact API operation.
type StopContactResponse struct {
	*StopContactOutput

	response *aws.Response
}

// SDKResponseMetdata returns the response metadata for the
// StopContact request.
func (r *StopContactResponse) SDKResponseMetdata() *aws.Response {
	return r.response
}
