Add Pagination Options for List Requests #205

Merged
lunny merged 36 commits from spawn2kill/go-sdk:pagination into master 2020-02-05 08:00:00 +00:00
Showing only changes of commit ed84b63333 - Show all commits

View File

@ -31,11 +31,11 @@ type ListAccessTokensOptions struct {
ListOptions ListOptions
} }
// ListAccessTokensOptions lists all the access tokens of user // ListAccessTokens lists all the access tokens of user
func (c *Client) ListAccessTokens(user, pass string, opt ListAccessTokensOptions) ([]*AccessToken, error) { func (c *Client) ListAccessTokens(user, pass string, opts ListAccessTokensOptions) ([]*AccessToken, error) {
opt.setDefaults() opts.setDefaults()
tokens := make([]*AccessToken, 0, opt.PageSize) tokens := make([]*AccessToken, 0, opts.PageSize)
return tokens, c.getParsedResponse("GET", fmt.Sprintf("/users/%s/tokens?%s", user, opt.getURLQuery().Encode()), return tokens, c.getParsedResponse("GET", fmt.Sprintf("/users/%s/tokens?%s", user, opts.getURLQuery().Encode()),
http.Header{"Authorization": []string{"Basic " + basicAuthEncode(user, pass)}}, nil, &tokens) http.Header{"Authorization": []string{"Basic " + basicAuthEncode(user, pass)}}, nil, &tokens)
} }