Passed
Push — master ( b5915d...a6ac05 )
by eval
01:23
created

ses.ListTemplatesRequest.ToInput   A

Complexity

Conditions 3

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 7
nop 0
dl 0
loc 10
rs 10
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
// ListTemplates executes `ListTemplates` operation.
13
func (svc *SES) ListTemplates(ctx context.Context, r ListTemplatesRequest) (*ListTemplatesResult, error) {
14
	out, err := svc.RawListTemplates(ctx, r.ToInput())
15
	if err != nil {
16
		err = svc.errWrap(errors.ErrorData{
17
			Err:          err,
18
			AWSOperation: "ListTemplates",
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 NewListTemplatesResult(out), nil
24
}
25
26
// ListTemplatesRequest has parameters for `ListTemplates` operation.
27
type ListTemplatesRequest struct {
28
	MaxItems  int64
29
	NextToken string
30
}
31
32
func (r ListTemplatesRequest) ToInput() *SDK.ListTemplatesInput {
0 ignored issues
show
introduced by
exported method ListTemplatesRequest.ToInput should have comment or be unexported
Loading history...
33
	in := &SDK.ListTemplatesInput{}
34
35
	if r.MaxItems != 0 {
36
		in.MaxItems = pointers.Long64(r.MaxItems)
37
	}
38
	if r.NextToken != "" {
39
		in.NextToken = pointers.String(r.NextToken)
40
	}
41
	return in
42
}
43
44
type ListTemplatesResult struct {
0 ignored issues
show
introduced by
exported type ListTemplatesResult should have comment or be unexported
Loading history...
45
	NextToken         string
46
	TemplatesMetadata []TemplateMetadata
47
}
48
49
func NewListTemplatesResult(o *SDK.ListTemplatesResponse) *ListTemplatesResult {
0 ignored issues
show
introduced by
exported function NewListTemplatesResult should have comment or be unexported
Loading history...
50
	result := &ListTemplatesResult{}
51
	if o == nil {
52
		return result
53
	}
54
55
	if o.NextToken != nil {
56
		result.NextToken = *o.NextToken
57
	}
58
59
	if len(o.TemplatesMetadata) != 0 {
60
		list := make([]TemplateMetadata, len(o.TemplatesMetadata))
61
		for i, v := range o.TemplatesMetadata {
62
			v := v
63
			list[i] = newTemplateMetadata(&v)
64
		}
65
		result.TemplatesMetadata = list
66
	}
67
	return result
68
}
69