Skip to content

Commit

Permalink
- Fix child user pagination parameters (#231)
Browse files Browse the repository at this point in the history
  • Loading branch information
nwithan8 committed Aug 8, 2024
1 parent 0dede49 commit be4503f
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 22 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Next Release

- Update HTTP logic to use query for GET/DELETE requests and body for POST/PUT/PATCH requests
- Fix parameters for retrieving next page of child users

## v4.5.0 (2024-07-24)

Expand Down
16 changes: 16 additions & 0 deletions list_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,19 @@ func nextPageParameters(hasMore bool, lastID string, pageSize int) (out *ListOpt
}
return
}

// nextChildUserPageParameters returns the next page of a paginated collection of child users.
// If pageSize is 0, it will use the default page size
func nextChildUserPageParameters(hasMore bool, lastID string, pageSize int) (out *ListOptions, err error) {
if !hasMore {
err = EndOfPaginationError
return
}
out = &ListOptions{
AfterID: lastID,
}
if pageSize > 0 {
out.PageSize = pageSize
}
return
}
37 changes: 16 additions & 21 deletions tests/cassettes/TestUserGetNextChildUserPage.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion user.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ func (c *Client) GetNextChildUserPageWithPageSizeWithContext(ctx context.Context
return
}
lastID := collection.Children[len(collection.Children)-1].ID
params, err := nextPageParameters(collection.HasMore, lastID, pageSize)
params, err := nextChildUserPageParameters(collection.HasMore, lastID, pageSize)
if err != nil {
return
}
Expand Down

0 comments on commit be4503f

Please sign in to comment.