|
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()) |
|
|
|
|
|
|
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 { |
|
|
|
|
|
|
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 { |
|
|
|
|
|
|
88
|
|
|
MessageID string |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
func NewSendTemplatedEmailResult(o *SDK.SendTemplatedEmailResponse) *SendTemplatedEmailResult { |
|
|
|
|
|
|
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
|
|
|
|