Passed
Push — master ( 715886...74726c )
by eval
06:41 queued 04:58
created

ses/client_op_send_templated_email.go   A

Size/Duplication

Total Lines 100
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
cc 16
eloc 62
dl 0
loc 100
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
C ses.SendTemplatedEmailRequest.ToInput 0 43 11
A ses.NewSendTemplatedEmailResult 0 10 3
A ses.*SES.SendTemplatedEmail 0 11 2
1
package ses
2
3
import (
4
	"context"
5
6
	SDK "github.com/aws/aws-sdk-go-v2/service/ses"
7
8
	"github.com/evalphobia/aws-sdk-go-v2-wrapper/errors"
9
	"github.com/evalphobia/aws-sdk-go-v2-wrapper/private/pointers"
10
)
11
12
// SendTemplatedEmail executes `SendTemplatedEmail` operation.
13
func (svc *SES) SendTemplatedEmail(ctx context.Context, r SendTemplatedEmailRequest) (*SendTemplatedEmailResult, error) {
14
	out, err := svc.RawSendTemplatedEmail(ctx, r.ToInput())
15
	if err != nil {
16
		err = svc.errWrap(errors.ErrorData{
17
			Err:          err,
18
			AWSOperation: "SendTemplatedEmail",
19
		})
20
		svc.Errorf(err.Error())
0 ignored issues
show
introduced by
can't check non-constant format in call to Errorf
Loading history...
21
		return nil, err
22
	}
23
	return NewSendTemplatedEmailResult(out), nil
24
}
25
26
// SendTemplatedEmailRequest has parameters for `SendTemplatedEmail` operation.
27
type SendTemplatedEmailRequest struct {
28
	Destination  Destination
29
	Source       string
30
	Template     string
31
	TemplateData string
32
33
	ConfigurationSetName string
34
	ReplyToAddresses     []string
35
	ReturnPath           string
36
	ReturnPathARN        string
37
	SourceARN            string
38
	Tags                 []MessageTag
39
	TemplateARN          string
40
}
41
42
func (r SendTemplatedEmailRequest) ToInput() *SDK.SendTemplatedEmailInput {
0 ignored issues
show
introduced by
exported method SendTemplatedEmailRequest.ToInput should have comment or be unexported
Loading history...
43
	in := &SDK.SendTemplatedEmailInput{}
44
45
	in.Destination = r.Destination.ToSDK()
46
47
	if r.Source != "" {
48
		in.Source = pointers.String(r.Source)
49
	}
50
	if r.Template != "" {
51
		in.Template = pointers.String(r.Template)
52
	}
53
	if r.TemplateData != "" {
54
		in.TemplateData = pointers.String(r.TemplateData)
55
	}
56
57
	if r.ConfigurationSetName != "" {
58
		in.ConfigurationSetName = pointers.String(r.ConfigurationSetName)
59
	}
60
61
	in.ReplyToAddresses = r.ReplyToAddresses
62
63
	if r.ReturnPath != "" {
64
		in.ReturnPath = pointers.String(r.ReturnPath)
65
	}
66
	if r.ReturnPathARN != "" {
67
		in.ReturnPathArn = pointers.String(r.ReturnPathARN)
68
	}
69
	if r.SourceARN != "" {
70
		in.SourceArn = pointers.String(r.SourceARN)
71
	}
72
73
	if len(r.Tags) != 0 {
74
		list := make([]SDK.MessageTag, len(r.Tags))
75
		for i, v := range r.Tags {
76
			list[i] = v.ToSDK()
77
		}
78
		in.Tags = list
79
	}
80
81
	if r.TemplateARN != "" {
82
		in.TemplateArn = pointers.String(r.TemplateARN)
83
	}
84
	return in
85
}
86
87
type SendTemplatedEmailResult struct {
0 ignored issues
show
introduced by
exported type SendTemplatedEmailResult should have comment or be unexported
Loading history...
88
	MessageID string
89
}
90
91
func NewSendTemplatedEmailResult(o *SDK.SendTemplatedEmailResponse) *SendTemplatedEmailResult {
0 ignored issues
show
introduced by
exported function NewSendTemplatedEmailResult should have comment or be unexported
Loading history...
92
	result := &SendTemplatedEmailResult{}
93
	if o == nil {
94
		return result
95
	}
96
97
	if o.MessageId != nil {
98
		result.MessageID = *o.MessageId
99
	}
100
	return result
101
}
102