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

pinpoint.NewCreateCampaignResult   A

Complexity

Conditions 2

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 6
nop 1
dl 0
loc 8
rs 10
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
// CreateCampaign executes `CreateCampaign` operation.
13
func (svc *Pinpoint) CreateCampaign(ctx context.Context, r CreateCampaignRequest) (*CreateCampaignResult, error) {
14
	out, err := svc.RawCreateCampaign(ctx, r.ToInput())
15
	if err != nil {
16
		err = svc.errWrap(errors.ErrorData{
17
			Err:          err,
18
			AWSOperation: "CreateCampaign",
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 NewCreateCampaignResult(out), nil
24
}
25
26
// CreateCampaignRequest has parameters for `CreateCampaign` operation.
27
type CreateCampaignRequest struct {
28
	ApplicationID        string
29
	WriteCampaignRequest WriteCampaignRequest
30
}
31
32
func (r CreateCampaignRequest) ToInput() *SDK.CreateCampaignInput {
0 ignored issues
show
introduced by
exported method CreateCampaignRequest.ToInput should have comment or be unexported
Loading history...
33
	in := &SDK.CreateCampaignInput{}
34
35
	if r.ApplicationID != "" {
36
		in.ApplicationId = pointers.String(r.ApplicationID)
37
	}
38
	in.WriteCampaignRequest = r.WriteCampaignRequest.ToSDK()
39
	return in
40
}
41
42
type CreateCampaignResult struct {
0 ignored issues
show
introduced by
exported type CreateCampaignResult should have comment or be unexported
Loading history...
43
	CampaignResponse
44
}
45
46
func NewCreateCampaignResult(o *SDK.CreateCampaignResponse) *CreateCampaignResult {
0 ignored issues
show
introduced by
exported function NewCreateCampaignResult should have comment or be unexported
Loading history...
47
	result := &CreateCampaignResult{}
48
	if o == nil {
49
		return result
50
	}
51
52
	result.CampaignResponse = newCampaignResponse(o.CampaignResponse)
53
	return result
54
}
55