Total Lines | 32 |
Duplicated Lines | 0 % |
Changes | 0 |
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 |