From a795c596a746f1ac9a78063f54675b8634f5c271 Mon Sep 17 00:00:00 2001 From: nicolas lopes <57234795+NicolasLopes7@users.noreply.github.com> Date: Wed, 2 Oct 2024 14:51:15 -0300 Subject: [PATCH] fix: organization invitation revoke (#334) --- organizationinvitation/client.go | 7 +++++-- organizationinvitation/client_test.go | 6 ++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/organizationinvitation/client.go b/organizationinvitation/client.go index d5154eb..923027f 100644 --- a/organizationinvitation/client.go +++ b/organizationinvitation/client.go @@ -97,8 +97,10 @@ func (c *Client) Get(ctx context.Context, params *GetParams) (*clerk.Organizatio } type RevokeParams struct { - OrganizationID string - ID string + clerk.APIParams + RequestingUserID *string `json:"requesting_user_id,omitempty"` + OrganizationID string `json:"-"` + ID string `json:"-"` } // Revoke marks the organization invitation as revoked. @@ -108,6 +110,7 @@ func (c *Client) Revoke(ctx context.Context, params *RevokeParams) (*clerk.Organ return nil, err } req := clerk.NewAPIRequest(http.MethodPost, path) + req.SetParams(params) invitation := &clerk.OrganizationInvitation{} err = c.Backend.Call(ctx, req, invitation) return invitation, err diff --git a/organizationinvitation/client_test.go b/organizationinvitation/client_test.go index 2078c7d..867cd99 100644 --- a/organizationinvitation/client_test.go +++ b/organizationinvitation/client_test.go @@ -184,6 +184,7 @@ func TestOrganizationInvitationClientRevoke(t *testing.T) { config.HTTPClient = &http.Client{ Transport: &clerktest.RoundTripper{ T: t, + In: json.RawMessage(`{"requesting_user_id": "user_123"}`), Out: json.RawMessage(fmt.Sprintf(`{"id":"%s","object":"organization_invitation","email_address":"string","role":"string","organization_id":"%s","status":"string","public_metadata":{},"private_metadata":{},"created_at":0,"updated_at":0}`, id, organizationID)), Method: http.MethodPost, Path: "/v1/organizations/" + organizationID + "/invitations/" + id + "/revoke", @@ -191,8 +192,9 @@ func TestOrganizationInvitationClientRevoke(t *testing.T) { } client := NewClient(config) response, err := client.Revoke(context.Background(), &RevokeParams{ - OrganizationID: organizationID, - ID: id, + OrganizationID: organizationID, + RequestingUserID: clerk.String("user_123"), + ID: id, }) require.NoError(t, err) require.Equal(t, id, response.ID)