diff -r 0a1f493588ee -r 0684ac8b6634 account.go --- a/account.go Thu Apr 13 22:23:31 2017 +0200 +++ b/account.go Thu Apr 13 23:43:10 2017 +0200 @@ -20,7 +20,8 @@ // getSingleAccount returns an account entity // The target can be "account", "verify_credentials", "follow", "unfollow", -// "block", "unblock", "mute" or "unmute". +// "block", "unblock", "mute", "unmute", "follow_requests/authorize" or +// "follow_requests/reject". // The id is optional and depends on the target. func (g *Client) getSingleAccount(target string, id int) (*Account, error) { var endPoint string @@ -35,12 +36,18 @@ case "follow", "unfollow", "block", "unblock", "mute", "unmute": endPoint = "accounts/" + strID + "/" + target method = rest.Post + case "follow_requests/authorize", "follow_requests/reject": + // The documentation is incorrect, the endpoint actually + // is "follow_requests/:id/{authorize|reject}" + endPoint = target[:16] + strID + "/" + target[16:] + method = rest.Post default: return nil, ErrInvalidParameter } req := g.prepareRequest(endPoint) req.Method = method + r, err := rest.API(req) if err != nil { return nil, fmt.Errorf("getAccount (%s): %s", target, err.Error()) @@ -371,3 +378,13 @@ } return sl, nil } + +// FollowRequestAuthorize authorizes or rejects an account follow-request +func (g *Client) FollowRequestAuthorize(accountID int, authorize bool) error { + endPoint := "follow_requests/reject" + if authorize { + endPoint = "follow_requests/authorize" + } + _, err := g.getSingleAccount(endPoint, accountID) + return err +}