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