Passed
Pull Request — master (#29)
by eval
02:10
created

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