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

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