Skip to content

Commit

Permalink
fix: organization invitation revoke (#334)
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolasLopes7 authored Oct 2, 2024
1 parent 6eac7fa commit a795c59
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
7 changes: 5 additions & 2 deletions organizationinvitation/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand Down
6 changes: 4 additions & 2 deletions organizationinvitation/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,15 +184,17 @@ 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",
},
}
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)
Expand Down

0 comments on commit a795c59

Please sign in to comment.