feat(client): add pagination support

Closes #11
This commit is contained in:
Julien Dessaux 2025-05-20 21:45:08 +02:00
parent f04d7b341d
commit 412bbe0b37
Signed by: adyxax
GPG key ID: F92E51B86E07177E
5 changed files with 98 additions and 50 deletions

View file

@ -21,14 +21,8 @@ type Organization struct {
func (c *Client) OrganizationsList(ctx context.Context) ([]Organization, error) {
var response []Organization
query := make(url.Values)
query.Set("limit", "50")
query.Set("page", "1")
uriRef := url.URL{
Path: "api/v1/orgs",
RawQuery: query.Encode(),
}
if err := c.Send(ctx, "GET", &uriRef, nil, &response); err != nil {
uriRef := url.URL{Path: "api/v1/orgs"}
if err := c.sendPaginated(ctx, "GET", &uriRef, nil, &response); err != nil {
return nil, fmt.Errorf("failed to get organizations: %w", err)
}
return response, nil