Total Lines | 53 |
Duplicated Lines | 0 % |
Changes | 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 | // 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()) |
||
|
|||
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 { |
||
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 { |
||
43 | SegmentResponse |
||
44 | } |
||
45 | |||
46 | func NewCreateSegmentResult(o *SDK.CreateSegmentResponse) *CreateSegmentResult { |
||
47 | result := &CreateSegmentResult{} |
||
48 | if o == nil { |
||
49 | return result |
||
50 | } |
||
51 | |||
52 | result.SegmentResponse = newSegmentResponse(o.SegmentResponse) |
||
53 | return result |
||
54 | } |
||
55 |