Skip to content

Commit

Permalink
fix: User list memberships id
Browse files Browse the repository at this point in the history
Changed the user.ListOrganizationMemberships API operation so that the
user ID is provided as a separate parameter, avoiding confusion as to
which resource the ID refers to (user, organization or organization
membership).
  • Loading branch information
gkats committed Apr 2, 2024
1 parent cb09c0b commit f6e4231
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
4 changes: 2 additions & 2 deletions user/api.go

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

5 changes: 2 additions & 3 deletions user/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,6 @@ func (c *Client) Unlock(ctx context.Context, id string) (*clerk.User, error) {
type ListOrganizationMembershipsParams struct {
clerk.APIParams
clerk.ListParams
ID string `json:"-"`
}

// ToQuery returns url.Values from the params.
Expand All @@ -356,8 +355,8 @@ func (params *ListOrganizationMembershipsParams) ToQuery() url.Values {
}

// ListOrganizationMemberships lists all the user's organization memberships.
func (c *Client) ListOrganizationMemberships(ctx context.Context, params *ListOrganizationMembershipsParams) (*clerk.OrganizationMembershipList, error) {
path, err := clerk.JoinPath(path, params.ID, "/organization_memberships")
func (c *Client) ListOrganizationMemberships(ctx context.Context, id string, params *ListOrganizationMembershipsParams) (*clerk.OrganizationMembershipList, error) {
path, err := clerk.JoinPath(path, id, "/organization_memberships")
if err != nil {
return nil, err
}
Expand Down
6 changes: 2 additions & 4 deletions user/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -364,12 +364,10 @@ func TestUserClientListOrganizationMemberships(t *testing.T) {
},
}
client := NewClient(config)
params := &ListOrganizationMembershipsParams{
ID: userID,
}
params := &ListOrganizationMembershipsParams{}
params.Limit = clerk.Int64(1)
params.Offset = clerk.Int64(2)
list, err := client.ListOrganizationMemberships(context.Background(), params)
list, err := client.ListOrganizationMemberships(context.Background(), userID, params)
require.NoError(t, err)
require.Equal(t, membershipID, list.OrganizationMemberships[0].ID)
require.Equal(t, organizationID, list.OrganizationMemberships[0].Organization.ID)
Expand Down

0 comments on commit f6e4231

Please sign in to comment.