Passed
Pull Request — master (#29)
by eval
01:33
created

pinpoint/client_op_create_segment.go   A

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
cc 6
eloc 32
dl 0
loc 53
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A pinpoint.*Pinpoint.CreateSegment 0 11 2
A pinpoint.NewCreateSegmentResult 0 8 2
A pinpoint.CreateSegmentRequest.ToInput 0 8 2
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
// CreateSegment executes `CreateSegment` operation.
13
func (svc *Pinpoint) CreateSegment(ctx context.Context, r CreateSegmentRequest) (*CreateSegmentResult, error) {
14
	out, err := svc.RawCreateSegment(ctx, r.ToInput())
15
	if err != nil {
16
		err = svc.errWrap(errors.ErrorData{
17
			Err:          err,
18
			AWSOperation: "CreateSegment",
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 NewCreateSegmentResult(out), nil
24
}
25
26
// CreateSegmentRequest has parameters for `CreateSegment` operation.
27
type CreateSegmentRequest struct {
28
	ApplicationID       string
29
	WriteSegmentRequest WriteSegmentRequest
30
}
31
32
func (r CreateSegmentRequest) ToInput() *SDK.CreateSegmentInput {
0 ignored issues
show
introduced by
exported method CreateSegmentRequest.ToInput should have comment or be unexported
Loading history...
33
	in := &SDK.CreateSegmentInput{}
34
	if r.ApplicationID != "" {
35
		in.ApplicationId = pointers.String(r.ApplicationID)
36
	}
37
38
	in.WriteSegmentRequest = r.WriteSegmentRequest.ToSDK()
39
	return in
40
}
41
42
type CreateSegmentResult struct {
0 ignored issues
show
introduced by
exported type CreateSegmentResult should have comment or be unexported
Loading history...
43
	SegmentResponse
44
}
45
46
func NewCreateSegmentResult(o *SDK.CreateSegmentResponse) *CreateSegmentResult {
0 ignored issues
show
introduced by
exported function NewCreateSegmentResult should have comment or be unexported
Loading history...
47
	result := &CreateSegmentResult{}
48
	if o == nil {
49
		return result
50
	}
51
52
	result.SegmentResponse = newSegmentResponse(o.SegmentResponse)
53
	return result
54
}
55