1
|
|
|
package ses |
2
|
|
|
|
3
|
|
|
import ( |
4
|
|
|
"time" |
5
|
|
|
|
6
|
|
|
SDK "github.com/aws/aws-sdk-go-v2/service/ses" |
7
|
|
|
"github.com/evalphobia/aws-sdk-go-v2-wrapper/private/pointers" |
8
|
|
|
) |
9
|
|
|
|
10
|
|
|
type BulkEmailDestination struct { |
|
|
|
|
11
|
|
|
Destination Destination |
12
|
|
|
ReplacementTags []MessageTag |
13
|
|
|
ReplacementTemplateData string |
14
|
|
|
} |
15
|
|
|
|
16
|
|
|
func (r BulkEmailDestination) ToSDK() SDK.BulkEmailDestination { |
|
|
|
|
17
|
|
|
o := SDK.BulkEmailDestination{} |
18
|
|
|
|
19
|
|
|
o.Destination = r.Destination.ToSDK() |
20
|
|
|
|
21
|
|
|
if len(r.ReplacementTags) != 0 { |
22
|
|
|
list := make([]SDK.MessageTag, len(r.ReplacementTags)) |
23
|
|
|
for i, v := range r.ReplacementTags { |
24
|
|
|
list[i] = v.ToSDK() |
25
|
|
|
} |
26
|
|
|
o.ReplacementTags = list |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
if r.ReplacementTemplateData != "" { |
30
|
|
|
o.ReplacementTemplateData = pointers.String(r.ReplacementTemplateData) |
31
|
|
|
} |
32
|
|
|
return o |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
type BulkEmailDestinationStatus struct { |
|
|
|
|
36
|
|
|
Error string |
37
|
|
|
MessageID string |
38
|
|
|
Status BulkEmailStatus |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
func newBulkEmailDestinationStatuses(list []SDK.BulkEmailDestinationStatus) []BulkEmailDestinationStatus { |
42
|
|
|
if len(list) == 0 { |
43
|
|
|
return nil |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
results := make([]BulkEmailDestinationStatus, len(list)) |
47
|
|
|
for i, v := range list { |
48
|
|
|
results[i] = newBulkEmailDestinationStatus(v) |
49
|
|
|
} |
50
|
|
|
return results |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
func newBulkEmailDestinationStatus(o SDK.BulkEmailDestinationStatus) BulkEmailDestinationStatus { |
54
|
|
|
result := BulkEmailDestinationStatus{} |
55
|
|
|
|
56
|
|
|
if o.Error != nil { |
57
|
|
|
result.Error = *o.Error |
58
|
|
|
} |
59
|
|
|
if o.MessageId != nil { |
60
|
|
|
result.MessageID = *o.MessageId |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
result.Status = BulkEmailStatus(o.Status) |
64
|
|
|
return result |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
type Destination struct { |
|
|
|
|
68
|
|
|
BccAddresses []string |
69
|
|
|
CcAddresses []string |
70
|
|
|
ToAddresses []string |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
func (r Destination) ToSDK() *SDK.Destination { |
|
|
|
|
74
|
|
|
o := SDK.Destination{} |
75
|
|
|
|
76
|
|
|
o.BccAddresses = r.BccAddresses |
77
|
|
|
o.CcAddresses = r.CcAddresses |
78
|
|
|
o.ToAddresses = r.ToAddresses |
79
|
|
|
return &o |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
type MessageTag struct { |
|
|
|
|
83
|
|
|
Name string |
84
|
|
|
Value string |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
func (r MessageTag) ToSDK() SDK.MessageTag { |
|
|
|
|
88
|
|
|
o := SDK.MessageTag{} |
89
|
|
|
|
90
|
|
|
if r.Name != "" { |
91
|
|
|
o.Name = pointers.String(r.Name) |
92
|
|
|
} |
93
|
|
|
if r.Value != "" { |
94
|
|
|
o.Value = pointers.String(r.Value) |
95
|
|
|
} |
96
|
|
|
return o |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
type Template struct { |
|
|
|
|
100
|
|
|
TemplateName string |
101
|
|
|
|
102
|
|
|
// optional |
103
|
|
|
HTMLPart string |
104
|
|
|
SubjectPart string |
105
|
|
|
TextPart string |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
func newTemplate(o *SDK.Template) Template { |
109
|
|
|
result := Template{} |
110
|
|
|
if o == nil { |
111
|
|
|
return result |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
if o.TemplateName != nil { |
115
|
|
|
result.TemplateName = *o.TemplateName |
116
|
|
|
} |
117
|
|
|
if o.HtmlPart != nil { |
118
|
|
|
result.HTMLPart = *o.HtmlPart |
119
|
|
|
} |
120
|
|
|
if o.SubjectPart != nil { |
121
|
|
|
result.SubjectPart = *o.SubjectPart |
122
|
|
|
} |
123
|
|
|
if o.TextPart != nil { |
124
|
|
|
result.TextPart = *o.TextPart |
125
|
|
|
} |
126
|
|
|
return result |
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
func (r Template) ToSDK() *SDK.Template { |
|
|
|
|
130
|
|
|
o := SDK.Template{} |
131
|
|
|
|
132
|
|
|
if r.TemplateName != "" { |
133
|
|
|
o.TemplateName = pointers.String(r.TemplateName) |
134
|
|
|
} |
135
|
|
|
if r.HTMLPart != "" { |
136
|
|
|
o.HtmlPart = pointers.String(r.HTMLPart) |
137
|
|
|
} |
138
|
|
|
if r.SubjectPart != "" { |
139
|
|
|
o.SubjectPart = pointers.String(r.SubjectPart) |
140
|
|
|
} |
141
|
|
|
if r.TextPart != "" { |
142
|
|
|
o.TextPart = pointers.String(r.TextPart) |
143
|
|
|
} |
144
|
|
|
return &o |
145
|
|
|
} |
146
|
|
|
|
147
|
|
|
type TemplateMetadata struct { |
|
|
|
|
148
|
|
|
CreatedTimestamp time.Time |
149
|
|
|
Name string |
150
|
|
|
} |
151
|
|
|
|
152
|
|
|
func newTemplateMetadata(o *SDK.TemplateMetadata) TemplateMetadata { |
153
|
|
|
result := TemplateMetadata{} |
154
|
|
|
if o == nil { |
155
|
|
|
return result |
156
|
|
|
} |
157
|
|
|
|
158
|
|
|
if o.CreatedTimestamp != nil { |
159
|
|
|
result.CreatedTimestamp = *o.CreatedTimestamp |
160
|
|
|
} |
161
|
|
|
if o.Name != nil { |
162
|
|
|
result.Name = *o.Name |
163
|
|
|
} |
164
|
|
|
return result |
165
|
|
|
} |
166
|
|
|
|