Support pagination

This commit is contained in:
Ian Gulliver
2021-09-22 03:22:04 +00:00
parent 3d7d06e9b0
commit 31985ee5c6
2 changed files with 39 additions and 11 deletions

View File

@@ -23,6 +23,8 @@ type workspacesResponse struct {
Data []*workspace `json:"data"`
}
const perPage = 100
func NewClient(token string) *Client {
c := &Client{
client: &http.Client{},
@@ -81,7 +83,7 @@ func (c *Client) get(path string, values *url.Values, out interface{}) error {
if values == nil {
values = &url.Values{}
}
values.Add("limit", "100")
values.Set("limit", fmt.Sprintf("%d", perPage))
url := fmt.Sprintf("%s%s?%s", baseURL, path, values.Encode())