feat(client): detect pagination limit at client instantiation
Closes #15
This commit is contained in:
parent
f4d69460af
commit
7e1e9eb26b
4 changed files with 25 additions and 15 deletions
|
@ -41,7 +41,7 @@ func (c *Client) UsersList(ctx context.Context) ([]User, error) {
|
|||
}
|
||||
uriRef := url.URL{Path: "api/v1/users/search"}
|
||||
query := make(url.Values)
|
||||
query.Set("limit", maxItemsPerPageStr)
|
||||
query.Set("limit", c.maxItemsPerPageStr)
|
||||
page := 1
|
||||
var users []User
|
||||
var response Response
|
||||
|
@ -56,7 +56,7 @@ func (c *Client) UsersList(ctx context.Context) ([]User, error) {
|
|||
return nil, fmt.Errorf("got a non OK status when searching users")
|
||||
}
|
||||
users = append(users, response.Data...)
|
||||
if count <= page*maxItemsPerPage {
|
||||
if count <= page*c.maxItemsPerPage {
|
||||
return users, nil
|
||||
}
|
||||
page++
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue