Passed
Push — master ( 74726c...b4fc5f )
by eval
02:05
created

pinpoint.*Pinpoint.ListTemplates   A

Complexity

Conditions 2

Size

Total Lines 11
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 9
nop 2
dl 0
loc 11
rs 9.95
c 0
b 0
f 0
1
package pinpoint
2
3
import (
4
	"context"
5
6
	SDK "github.com/aws/aws-sdk-go-v2/service/pinpoint"
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 *Pinpoint) 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
	NextToken    string
29
	PageSize     string
30
	Prefix       string
31
	TemplateType string
32
}
33
34
func (r ListTemplatesRequest) ToInput() *SDK.ListTemplatesInput {
0 ignored issues
show
introduced by
exported method ListTemplatesRequest.ToInput should have comment or be unexported
Loading history...
35
	in := &SDK.ListTemplatesInput{}
36
	if r.NextToken != "" {
37
		in.NextToken = pointers.String(r.NextToken)
38
	}
39
	if r.PageSize != "" {
40
		in.PageSize = pointers.String(r.PageSize)
41
	}
42
	if r.Prefix != "" {
43
		in.Prefix = pointers.String(r.Prefix)
44
	}
45
	if r.TemplateType != "" {
46
		in.TemplateType = pointers.String(r.TemplateType)
47
	}
48
	return in
49
}
50
51
type ListTemplatesResult struct {
0 ignored issues
show
introduced by
exported type ListTemplatesResult should have comment or be unexported
Loading history...
52
	TemplatesResponse
53
}
54
55
func NewListTemplatesResult(o *SDK.ListTemplatesResponse) *ListTemplatesResult {
0 ignored issues
show
introduced by
exported function NewListTemplatesResult should have comment or be unexported
Loading history...
56
	result := &ListTemplatesResult{}
57
	if o == nil {
58
		return result
59
	}
60
61
	result.TemplatesResponse = newTemplatesResponse(o.TemplatesResponse)
62
	return result
63
}
64