Add method to get blocked users

Signed-off-by: Vartan Benohanian <vartanbeno@gmail.com>
This commit is contained in:
Vartan Benohanian
2020-07-02 20:47:46 -04:00
parent 8424b2ac49
commit 12e801f83c
3 changed files with 63 additions and 3 deletions
+25
View File
@@ -367,3 +367,28 @@ func (s *AccountService) Friends(ctx context.Context) ([]Relationship, *Response
return root.Friends, resp, nil
}
type rootBlockedListing struct {
Kind string `json:"kind,omitempty"`
Data struct {
Blocked []Relationship `json:"children"`
} `json:"data"`
}
// Blocked returns a list of your blocked users.
func (s *AccountService) Blocked(ctx context.Context) ([]Relationship, *Response, error) {
path := "prefs/blocked"
req, err := s.client.NewRequest(http.MethodGet, path, nil)
if err != nil {
return nil, nil, err
}
root := new(rootBlockedListing)
resp, err := s.client.Do(ctx, req, root)
if err != nil {
return nil, resp, err
}
return root.Data.Blocked, resp, nil
}