From 7758f12bc10b20b0acad97b33acd29d7fd21a0f8 Mon Sep 17 00:00:00 2001 From: Mary Zhong Date: Wed, 23 Oct 2024 17:00:09 -0400 Subject: [PATCH] fix: Only update list endpoint --- organization/api.go | 4 ++-- organization/client.go | 20 +------------------- organization/client_test.go | 25 +++---------------------- 3 files changed, 6 insertions(+), 43 deletions(-) diff --git a/organization/api.go b/organization/api.go index 557fe326..fa942759 100644 --- a/organization/api.go +++ b/organization/api.go @@ -15,8 +15,8 @@ func Create(ctx context.Context, params *CreateParams) (*clerk.Organization, err // Get retrieves details for an organization. // The organization can be fetched by either the ID or its slug. -func Get(ctx context.Context, idOrSlug string, params *GetParams) (*clerk.Organization, error) { - return getClient().Get(ctx, idOrSlug, params) +func Get(ctx context.Context, idOrSlug string) (*clerk.Organization, error) { + return getClient().Get(ctx, idOrSlug) } // Update updates an organization. diff --git a/organization/client.go b/organization/client.go index 328fb756..85f0ef75 100644 --- a/organization/client.go +++ b/organization/client.go @@ -48,32 +48,14 @@ func (c *Client) Create(ctx context.Context, params *CreateParams) (*clerk.Organ return organization, err } -type GetParams struct { - clerk.APIParams - IncludeMembersCount *bool `json:"include_members_count,omitempty"` - IncludeHasMemberWithElevatedPermissions *bool `json:"include_has_member_with_elevated_permissions,omitempty"` -} - -func (params *GetParams) ToQuery() url.Values { - q := url.Values{} - if params.IncludeMembersCount != nil { - q.Set("include_members_count", strconv.FormatBool(*params.IncludeMembersCount)) - } - if params.IncludeHasMemberWithElevatedPermissions != nil { - q.Set("include_has_member_with_elevated_permissions", strconv.FormatBool(*params.IncludeHasMemberWithElevatedPermissions)) - } - return q -} - // Get retrieves details for an organization. // The organization can be fetched by either the ID or its slug. -func (c *Client) Get(ctx context.Context, idOrSlug string, params *GetParams) (*clerk.Organization, error) { +func (c *Client) Get(ctx context.Context, idOrSlug string) (*clerk.Organization, error) { path, err := clerk.JoinPath(path, idOrSlug) if err != nil { return nil, err } req := clerk.NewAPIRequest(http.MethodGet, path) - req.SetParams(params) organization := &clerk.Organization{} err = c.Backend.Call(ctx, req, organization) return organization, err diff --git a/organization/client_test.go b/organization/client_test.go index cf96ae3a..13932b47 100644 --- a/organization/client_test.go +++ b/organization/client_test.go @@ -66,39 +66,20 @@ func TestOrganizationClientGet(t *testing.T) { t.Parallel() id := "org_123" name := "Acme Inc" - membersCount := int64(1) - hasMemberWithElevatedPermissions := true config := &clerk.ClientConfig{} config.HTTPClient = &http.Client{ Transport: &clerktest.RoundTripper{ - T: t, - Out: json.RawMessage(fmt.Sprintf( - `{"id":"%s","name":"%s","members_count":%d,"has_member_with_elevated_permissions":%t}`, - id, - name, - membersCount, - hasMemberWithElevatedPermissions, - )), + T: t, + Out: json.RawMessage(fmt.Sprintf(`{"id":"%s","name":"%s"}`, id, name)), Method: http.MethodGet, Path: "/v1/organizations/" + id, - Query: &url.Values{ - "include_members_count": []string{"true"}, - "include_has_member_with_elevated_permissions": []string{"true"}, - }, }, } - params := &GetParams{ - IncludeMembersCount: clerk.Bool(true), - IncludeHasMemberWithElevatedPermissions: clerk.Bool(true), - } client := NewClient(config) - organization, err := client.Get(context.Background(), id, params) + organization, err := client.Get(context.Background(), id) require.NoError(t, err) require.Equal(t, id, organization.ID) require.Equal(t, name, organization.Name) - require.Equal(t, membersCount, *organization.MembersCount) - require.NotNil(t, organization.HasMemberWithElevatedPermissions) - require.Equal(t, hasMemberWithElevatedPermissions, *organization.HasMemberWithElevatedPermissions) }