Passed
Pull Request — master (#34)
by eval
01:54
created

sqs.DeleteMessageBatchRequest.ToInput   A

Complexity

Conditions 4

Size

Total Lines 14
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 10
nop 0
dl 0
loc 14
rs 9.9
c 0
b 0
f 0
1
package sqs
2
3
import (
4
	"context"
5
6
	SDK "github.com/aws/aws-sdk-go-v2/service/sqs"
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
// DeleteMessageBatch executes `DeleteMessageBatch` operation.
13
func (svc *SQS) DeleteMessageBatch(ctx context.Context, r DeleteMessageBatchRequest) (*DeleteMessageBatchResult, error) {
14
	out, err := svc.RawDeleteMessageBatch(ctx, r.ToInput())
15
	if err != nil {
16
		err = svc.errWrap(errors.ErrorData{
17
			Err:          err,
18
			AWSOperation: "DeleteMessageBatch",
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 NewDeleteMessageBatchResult(out), nil
24
}
25
26
// DeleteMessageBatchRequest has parameters for `DeleteMessageBatch` operation.
27
type DeleteMessageBatchRequest struct {
28
	Entries  []DeleteMessageBatchRequestEntry
29
	QueueURL string
30
}
31
32
func (r DeleteMessageBatchRequest) ToInput() *SDK.DeleteMessageBatchInput {
0 ignored issues
show
introduced by
exported method DeleteMessageBatchRequest.ToInput should have comment or be unexported
Loading history...
33
	in := &SDK.DeleteMessageBatchInput{}
34
35
	if len(r.Entries) != 0 {
36
		list := make([]SDK.DeleteMessageBatchRequestEntry, len(r.Entries))
37
		for i, v := range r.Entries {
38
			list[i] = v.ToSDK()
39
		}
40
		in.Entries = list
41
	}
42
	if r.QueueURL != "" {
43
		in.QueueUrl = pointers.String(r.QueueURL)
44
	}
45
	return in
46
}
47
48
type DeleteMessageBatchResult struct {
0 ignored issues
show
introduced by
exported type DeleteMessageBatchResult should have comment or be unexported
Loading history...
49
	Failed     []BatchResultErrorEntry
50
	Successful []DeleteMessageBatchResultEntry
51
}
52
53
func NewDeleteMessageBatchResult(o *SDK.DeleteMessageBatchResponse) *DeleteMessageBatchResult {
0 ignored issues
show
introduced by
exported function NewDeleteMessageBatchResult should have comment or be unexported
Loading history...
54
	result := &DeleteMessageBatchResult{}
55
	if o == nil {
56
		return result
57
	}
58
59
	result.Failed = newBatchResultErrorEntryList(o.Failed)
60
	result.Successful = newDeleteMessageBatchResultEntryList(o.Successful)
61
	return result
62
}
63