Skip to content

Commit

Permalink
feat(SPV-1296): add method to create contact by admin (#307)
Browse files Browse the repository at this point in the history
  • Loading branch information
wregulski authored Dec 17, 2024
1 parent fa54f9f commit 155281c
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions http.go
Original file line number Diff line number Diff line change
Expand Up @@ -1086,6 +1086,22 @@ func (wc *WalletClient) AdminUpdateContact(ctx context.Context, id, fullName str
return &contact, WrapError(err)
}

// AdminCreateContact executes an HTTP POST request to create a new contact using the specified paymail, creator paymail, full name, and metadata.
func (wc *WalletClient) AdminCreateContact(ctx context.Context, contactPaymail, creatorPaymail, fullName string, metadata map[string]any) (*models.Contact, error) {
jsonStr, err := json.Marshal(map[string]interface{}{
"creatorPaymail": creatorPaymail,
"fullName": fullName,
FieldMetadata: metadata,
})
if err != nil {
return nil, WrapError(err)
}

var contact models.Contact
err = wc.doHTTPRequest(ctx, http.MethodPost, fmt.Sprintf("/admin/contact/%s", contactPaymail), jsonStr, wc.adminXPriv, true, &contact)
return &contact, WrapError(err)
}

// AdminDeleteContact executes an HTTP DELETE request to remove a contact using their ID.
func (wc *WalletClient) AdminDeleteContact(ctx context.Context, id string) error {
err := wc.doHTTPRequest(ctx, http.MethodDelete, fmt.Sprintf("/admin/contact/%s", id), nil, wc.adminXPriv, true, nil)
Expand Down

0 comments on commit 155281c

Please sign in to comment.