diff --git a/CHANGELOG.md b/CHANGELOG.md index cabfeea..6e41125 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## Next release + +- Add `EmailAddressQuery`, `PhoneNumberQuery` and `UsernameQuery` to `user.ListParams`. + ## 2.1.0 - Add support for sign in tokens API operations. @@ -15,6 +19,7 @@ ## 2.0.9 ## 2.0.4 + - Add `IgnoreDotsForGmailAddresses` field to `InstanceRestrictions` and `instancesettings.UpdateRestrictionsParams` (#293). ## 2.0.0 diff --git a/user/client.go b/user/client.go index efb132e..d5c1736 100644 --- a/user/client.go +++ b/user/client.go @@ -223,8 +223,14 @@ type ListParams struct { // OrganizationIDs filters users that have memberships to the given organizations. For each organization ID, the // + and - can be prepended to the ID, which denote whether the respective organization should be included or // excluded from the result set. Accepts up to 100 organization IDs. - OrganizationIDs []string `json:"organization_id,omitempty"` - LastActiveAtSince *int64 `json:"last_active_at_since,omitempty"` + OrganizationIDs []string `json:"organization_id,omitempty"` + // Deprecated: Prefer using the LastActiveAtAfter parameter, which has + // identical functionality. This parameter is just being renamed. + LastActiveAtSince *int64 `json:"last_active_at_since,omitempty"` + CreatedAtBefore *int64 `json:"created_at_before,omitempty"` + CreatedAtAfter *int64 `json:"created_at_after,omitempty"` + LastActiveAtBefore *int64 `json:"last_active_at_before,omitempty"` + LastActiveAtAfter *int64 `json:"last_active_at_after,omitempty"` } // ToQuery returns url.Values from the params. @@ -269,6 +275,18 @@ func (params *ListParams) ToQuery() url.Values { if params.LastActiveAtSince != nil { q.Add("last_active_at_since", strconv.FormatInt(*params.LastActiveAtSince, 10)) } + if params.CreatedAtBefore != nil { + q.Add("created_at_before", strconv.FormatInt(*params.CreatedAtBefore, 10)) + } + if params.CreatedAtAfter != nil { + q.Add("created_at_after", strconv.FormatInt(*params.CreatedAtAfter, 10)) + } + if params.LastActiveAtBefore != nil { + q.Add("last_active_at_before", strconv.FormatInt(*params.LastActiveAtBefore, 10)) + } + if params.LastActiveAtAfter != nil { + q.Add("last_active_at_after", strconv.FormatInt(*params.LastActiveAtAfter, 10)) + } return q } diff --git a/user/client_test.go b/user/client_test.go index b4ed174..cba6017 100644 --- a/user/client_test.go +++ b/user/client_test.go @@ -47,12 +47,16 @@ func TestUserClientList_Request(t *testing.T) { T: t, Method: http.MethodGet, Query: &url.Values{ - "limit": []string{"1"}, - "offset": []string{"2"}, - "order_by": []string{"-created_at"}, - "email_address": []string{"foo@bar.com", "baz@bar.com"}, - "organization_id": []string{"org_123", "org_456"}, - "email_address_query": []string{"@bar.com"}, + "limit": []string{"1"}, + "offset": []string{"2"}, + "order_by": []string{"-created_at"}, + "email_address": []string{"foo@bar.com", "baz@bar.com"}, + "organization_id": []string{"org_123", "org_456"}, + "email_address_query": []string{"@bar.com"}, + "created_at_before": []string{"1730333164378"}, + "created_at_after": []string{"1730333164378"}, + "last_active_at_before": []string{"1730333164378"}, + "last_active_at_after": []string{"1730333164378"}, }, }, } @@ -65,6 +69,10 @@ func TestUserClientList_Request(t *testing.T) { } params.Limit = clerk.Int64(1) params.Offset = clerk.Int64(2) + params.CreatedAtBefore = clerk.Int64(1730333164378) + params.CreatedAtAfter = clerk.Int64(1730333164378) + params.LastActiveAtBefore = clerk.Int64(1730333164378) + params.LastActiveAtAfter = clerk.Int64(1730333164378) _, err := client.List(context.Background(), params) require.NoError(t, err) }