Skip to content

Commit

Permalink
Fix #92: Add pagination support for SuggestAccount
Browse files Browse the repository at this point in the history
  • Loading branch information
andygrunwald committed Sep 19, 2021
1 parent 5a2c9c2 commit 67c9345
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions accounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,19 @@ type AccountsService struct {
}

// AccountInfo entity contains information about an account.
//
// TODO Add field secondary_emails
// TODO Add field status
// TODO Add field inactive
// TODO Add field tags
//
// Gerrit API docs: https://gerrit-review.googlesource.com/Documentation/rest-api-accounts.html#account-info
type AccountInfo struct {
AccountID int `json:"_account_id,omitempty"`
Name string `json:"name,omitempty"`
Email string `json:"email,omitempty"`
Username string `json:"username,omitempty"`
AccountID int `json:"_account_id,omitempty"`
Name string `json:"name,omitempty"`
DisplayName string `json:"display_name,omitempty"`
Email string `json:"email,omitempty"`
Username string `json:"username,omitempty"`

// Avatars lists avatars of various sizes for the account.
// This field is only populated if the avatars plugin is enabled.
Expand All @@ -27,6 +35,14 @@ type AccountInfo struct {
MoreAccounts bool `json:"_more_accounts,omitempty"`
}

// QueryAccountOptions queries accounts visible to the caller.
type QueryAccountOptions struct {
QueryOptions

// The `S` or `start` query parameter can be supplied to skip a number of accounts from the list.
Start int `url:"S,omitempty"`
}

// SSHKeyInfo entity contains information about an SSH key of a user.
type SSHKeyInfo struct {
Seq int `json:"seq"`
Expand Down Expand Up @@ -519,7 +535,7 @@ func (s *AccountsService) GetStarredChanges(accountID string) (*[]ChangeInfo, *R
// Returns a list of matching AccountInfo entities.
//
// Gerrit API docs: https://gerrit-review.googlesource.com/Documentation/rest-api-accounts.html#query-account
func (s *AccountsService) SuggestAccount(opt *QueryOptions) (*[]AccountInfo, *Response, error) {
func (s *AccountsService) SuggestAccount(opt *QueryAccountOptions) (*[]AccountInfo, *Response, error) {
u := "accounts/"

u, err := addOptions(u, opt)
Expand Down

0 comments on commit 67c9345

Please sign in to comment.