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

pinpoint/client_xapi_endpoint.go   A

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 21
dl 0
loc 32
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A pinpoint.*Pinpoint.XUpdateEndpointEmail 0 24 3
1
package pinpoint
2
3
import (
4
	"context"
5
)
6
7
// XUpdateEndpointEmail updates email endpoint.
8
// (attrs[0]=Attributes, attrs[1]=UserAttributes)
9
func (svc *Pinpoint) XUpdateEndpointEmail(ctx context.Context, appID, endpointID, userID, email string, attrs ...map[string][]string) error {
10
	req := UpdateEndpointRequest{
11
		ApplicationID: appID,
12
		EndpointID:    endpointID,
13
		EndpointRequest: EndpointRequest{
14
			Address:     email,
15
			ChannelType: ChannelTypeEmail,
16
			User: EndpointUser{
17
				UserID: userID,
18
			},
19
		},
20
	}
21
22
	attrSize := len(attrs)
23
	switch {
24
	case attrSize >= 2:
25
		req.EndpointRequest.Attributes = attrs[0]
26
		req.EndpointRequest.User.UserAttributes = attrs[1]
27
	case attrSize == 1:
28
		req.EndpointRequest.Attributes = attrs[0]
29
	}
30
31
	_, err := svc.UpdateEndpoint(ctx, req)
32
	return err
33
}
34