Passed
Push — master ( dd6fe7...ccccae )
by eval
02:05
created

sqs/client_op_delete_message.go   A

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
cc 7
eloc 31
dl 0
loc 52
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A sqs.NewDeleteMessageResult 0 7 2
A sqs.DeleteMessageRequest.ToInput 0 10 3
A sqs.*SQS.DeleteMessage 0 11 2
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
// DeleteMessage executes `DeleteMessage` operation.
13
func (svc *SQS) DeleteMessage(ctx context.Context, r DeleteMessageRequest) (*DeleteMessageResult, error) {
14
	out, err := svc.RawDeleteMessage(ctx, r.ToInput())
15
	if err != nil {
16
		err = svc.errWrap(errors.ErrorData{
17
			Err:          err,
18
			AWSOperation: "DeleteMessage",
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 NewDeleteMessageResult(out), nil
24
}
25
26
// DeleteMessageRequest has parameters for `DeleteMessage` operation.
27
type DeleteMessageRequest struct {
28
	QueueURL      string
29
	ReceiptHandle string
30
}
31
32
func (r DeleteMessageRequest) ToInput() *SDK.DeleteMessageInput {
0 ignored issues
show
introduced by
exported method DeleteMessageRequest.ToInput should have comment or be unexported
Loading history...
33
	in := &SDK.DeleteMessageInput{}
34
35
	if r.QueueURL != "" {
36
		in.QueueUrl = pointers.String(r.QueueURL)
37
	}
38
	if r.ReceiptHandle != "" {
39
		in.ReceiptHandle = pointers.String(r.ReceiptHandle)
40
	}
41
	return in
42
}
43
44
type DeleteMessageResult struct{}
0 ignored issues
show
introduced by
exported type DeleteMessageResult should have comment or be unexported
Loading history...
45
46
func NewDeleteMessageResult(o *SDK.DeleteMessageResponse) *DeleteMessageResult {
0 ignored issues
show
introduced by
exported function NewDeleteMessageResult should have comment or be unexported
Loading history...
47
	result := &DeleteMessageResult{}
48
	if o == nil {
49
		return result
50
	}
51
52
	return result
53
}
54