Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nicolas/dash 342 dapi delete web3 wallet #321

Merged
merged 1 commit into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions user/api.go

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

12 changes: 12 additions & 0 deletions user/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -440,3 +440,15 @@ func (c *Client) DeletePasskey(ctx context.Context, userID, identificationID str
err = c.Backend.Call(ctx, req, resource)
return resource, err
}

// DeleteWeb3Wallet deletes a web3 wallet by its identification ID.
func (c *Client) DeleteWeb3Wallet(ctx context.Context, userID, identificationID string) (*clerk.DeletedResource, error) {
path, err := clerk.JoinPath(path, userID, "/web3_wallets", identificationID)
if err != nil {
return nil, err
}
req := clerk.NewAPIRequest(http.MethodDelete, path)
resource := &clerk.DeletedResource{}
err = c.Backend.Call(ctx, req, resource)
return resource, err
}
19 changes: 19 additions & 0 deletions user/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -441,3 +441,22 @@ func TestUserClientDeletePasskey(t *testing.T) {
require.NoError(t, err)
require.Equal(t, passkeyIdentificationID, passkey.ID)
}

func TestUserClientDeleteWeb3Wallet(t *testing.T) {
t.Parallel()
userID := "user_123"
web3WalletIdentificationID := "idn_345"
config := &clerk.ClientConfig{}
config.HTTPClient = &http.Client{
Transport: &clerktest.RoundTripper{
T: t,
Out: json.RawMessage(fmt.Sprintf(`{"id":"%s"}`, web3WalletIdentificationID)),
Method: http.MethodDelete,
Path: "/v1/users/" + userID + "/web3_wallets/" + web3WalletIdentificationID,
},
}
client := NewClient(config)
web3Wallet, err := client.DeleteWeb3Wallet(context.Background(), userID, web3WalletIdentificationID)
require.NoError(t, err)
require.Equal(t, web3WalletIdentificationID, web3Wallet.ID)
}
Loading