equal
deleted
inserted
replaced
|
1 /* |
|
2 Copyright 2018 Mikael Berthe |
|
3 |
|
4 Licensed under the MIT license. Please see the LICENSE file is this directory. |
|
5 */ |
|
6 |
|
7 package madon |
|
8 |
|
9 import ( |
|
10 "github.com/sendgrid/rest" |
|
11 ) |
|
12 |
|
13 // GetEndorsements returns the list of user's endorsements |
|
14 func (mc *Client) GetEndorsements(lopt *LimitParams) ([]Account, error) { |
|
15 endPoint := "endorsements" |
|
16 method := rest.Get |
|
17 var accountList []Account |
|
18 if err := mc.apiCall("v1/"+endPoint, method, nil, lopt, nil, &accountList); err != nil { |
|
19 return nil, err |
|
20 } |
|
21 return accountList, nil |
|
22 } |
|
23 |
|
24 // PinAccount adds the account to the endorsement list |
|
25 func (mc *Client) PinAccount(accountID int64) (*Relationship, error) { |
|
26 rel, err := mc.updateRelationship("pin", accountID, nil) |
|
27 if err != nil { |
|
28 return nil, err |
|
29 } |
|
30 if rel == nil { |
|
31 return nil, ErrEntityNotFound |
|
32 } |
|
33 return rel, nil |
|
34 } |
|
35 |
|
36 // UnpinAccount removes the account from the endorsement list |
|
37 func (mc *Client) UnpinAccount(accountID int64) (*Relationship, error) { |
|
38 rel, err := mc.updateRelationship("unpin", accountID, nil) |
|
39 if err != nil { |
|
40 return nil, err |
|
41 } |
|
42 if rel == nil { |
|
43 return nil, ErrEntityNotFound |
|
44 } |
|
45 return rel, nil |
|
46 } |