Passed
Push — master ( 2c9229...fa7da2 )
by eval
01:47
created

ses.SendRawEmailRequest.ToInput   C

Complexity

Conditions 9

Size

Total Lines 34
Code Lines 22

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 9
eloc 22
nop 0
dl 0
loc 34
rs 6.6666
c 0
b 0
f 0
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
// SendRawEmail executes `SendRawEmail` operation.
13
func (svc *SES) SendRawEmail(ctx context.Context, r SendRawEmailRequest) (*SendRawEmailResult, error) {
14
	out, err := svc.RawSendRawEmail(ctx, r.ToInput())
15
	if err != nil {
16
		err = svc.errWrap(errors.ErrorData{
17
			Err:          err,
18
			AWSOperation: "SendRawEmail",
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 NewSendRawEmailResult(out), nil
24
}
25
26
// SendRawEmailRequest has parameters for `SendRawEmail` operation.
27
type SendRawEmailRequest struct {
28
	RawMessageData []byte
29
30
	// optional
31
	ConfigurationSetName string
32
	Destinations         []string
33
	FromArn              string
34
	ReturnPathArn        string
35
	Source               string
36
	SourceArn            string
37
	Tags                 []MessageTag
38
}
39
40
func (r SendRawEmailRequest) ToInput() *SDK.SendRawEmailInput {
0 ignored issues
show
introduced by
exported method SendRawEmailRequest.ToInput should have comment or be unexported
Loading history...
41
	in := &SDK.SendRawEmailInput{}
42
43
	if len(r.RawMessageData) != 0 {
44
		in.RawMessage = &SDK.RawMessage{
45
			Data: r.RawMessageData,
46
		}
47
	}
48
49
	if r.ConfigurationSetName != "" {
50
		in.ConfigurationSetName = pointers.String(r.ConfigurationSetName)
51
	}
52
	if r.FromArn != "" {
53
		in.FromArn = pointers.String(r.FromArn)
54
	}
55
	if r.ReturnPathArn != "" {
56
		in.ReturnPathArn = pointers.String(r.ReturnPathArn)
57
	}
58
	if r.Source != "" {
59
		in.Source = pointers.String(r.Source)
60
	}
61
	if r.SourceArn != "" {
62
		in.SourceArn = pointers.String(r.SourceArn)
63
	}
64
65
	if len(r.Tags) != 0 {
66
		list := make([]SDK.MessageTag, len(r.Tags))
67
		for i, v := range r.Tags {
68
			list[i] = v.ToSDK()
69
		}
70
		in.Tags = list
71
	}
72
	in.Destinations = r.Destinations
73
	return in
74
}
75
76
type SendRawEmailResult struct {
0 ignored issues
show
introduced by
exported type SendRawEmailResult should have comment or be unexported
Loading history...
77
	MessageID string
78
}
79
80
func NewSendRawEmailResult(o *SDK.SendRawEmailResponse) *SendRawEmailResult {
0 ignored issues
show
introduced by
exported function NewSendRawEmailResult should have comment or be unexported
Loading history...
81
	result := &SendRawEmailResult{}
82
	if o == nil {
83
		return result
84
	}
85
86
	if o.MessageId != nil {
87
		result.MessageID = *o.MessageId
88
	}
89
	return result
90
}
91