From ccc1847581df5f3ceaa8bd39d35191c03b08cf27 Mon Sep 17 00:00:00 2001 From: Brandon Romano Date: Tue, 12 Nov 2024 09:29:14 -0800 Subject: [PATCH] Updates User ListParams to support NameQuery (#350) --- CHANGELOG.md | 2 ++ user/client.go | 4 ++++ user/client_test.go | 2 ++ 3 files changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5144c34..e1f607f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Next release +- Add `NameQuery` to `user.ListParams`. + ## 2.1.1 - Add `EmailAddressQuery`, `PhoneNumberQuery` and `UsernameQuery` to `user.ListParams`. diff --git a/user/client.go b/user/client.go index d5c1736..1ba0b6c 100644 --- a/user/client.go +++ b/user/client.go @@ -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"` @@ -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) } diff --git a/user/client_test.go b/user/client_test.go index cba6017..fbc2d7f 100644 --- a/user/client_test.go +++ b/user/client_test.go @@ -53,6 +53,7 @@ func TestUserClientList_Request(t *testing.T) { "email_address": []string{"foo@bar.com", "baz@bar.com"}, "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"}, @@ -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)