Skip to content

Commit

Permalink
Updates User ListParams to support NameQuery
Browse files Browse the repository at this point in the history
  • Loading branch information
BrandonRomano committed Nov 7, 2024
1 parent a2346ff commit 28295dc
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Next release

- Add `NameQuery` to `user.ListParams`.

## 2.1.1

- Add `EmailAddressQuery`, `PhoneNumberQuery` and `UsernameQuery` to `user.ListParams`.
Expand Down
4 changes: 4 additions & 0 deletions user/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ type ListParams struct {
EmailAddressQuery *string `json:"email_address_query,omitempty"`
PhoneNumberQuery *string `json:"phone_number_query,omitempty"`
UsernameQuery *string `json:"username_query,omitempty"`
NameQuery *string `json:"name_query,omitempty"`
EmailAddresses []string `json:"email_address,omitempty"`
ExternalIDs []string `json:"external_id,omitempty"`
PhoneNumbers []string `json:"phone_number,omitempty"`
Expand Down Expand Up @@ -251,6 +252,9 @@ func (params *ListParams) ToQuery() url.Values {
if params.UsernameQuery != nil {
q.Add("username_query", *params.UsernameQuery)
}
if params.NameQuery != nil {
q.Add("name_query", *params.NameQuery)
}
for _, v := range params.EmailAddresses {
q.Add("email_address", v)
}
Expand Down
2 changes: 2 additions & 0 deletions user/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ func TestUserClientList_Request(t *testing.T) {
"email_address": []string{"[email protected]", "[email protected]"},
"organization_id": []string{"org_123", "org_456"},
"email_address_query": []string{"@bar.com"},
"name_query": []string{"foobar"},
"created_at_before": []string{"1730333164378"},
"created_at_after": []string{"1730333164378"},
"last_active_at_before": []string{"1730333164378"},
Expand All @@ -66,6 +67,7 @@ func TestUserClientList_Request(t *testing.T) {
OrderBy: clerk.String("-created_at"),
OrganizationIDs: []string{"org_123", "org_456"},
EmailAddressQuery: clerk.String("@bar.com"),
NameQuery: clerk.String("foobar"),
}
params.Limit = clerk.Int64(1)
params.Offset = clerk.Int64(2)
Expand Down

0 comments on commit 28295dc

Please sign in to comment.