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

feat(SPV-1296): add method to create contact by admin #307

Merged
merged 1 commit into from
Dec 17, 2024
Merged
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
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
Loading