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(BUX-184): add DeletePaymail function #159

Merged
merged 1 commit into from
Sep 29, 2023
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
6 changes: 6 additions & 0 deletions transports/graphql.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,12 @@ func (g *TransportGraphQL) NewPaymail(_ context.Context, _, _, _, _ string, _ *b
return nil
}

// DeletePaymail will delete a paymail address
func (g *TransportGraphQL) DeletePaymail(_ context.Context, _ string) ResponseError {
// TODO: Implement this
return nil
}

// GetXpub will get an xPub
func (g *TransportGraphQL) GetXpub(_ context.Context, _ string) (*buxmodels.Xpub, ResponseError) {
// TODO: Implement this
Expand Down
21 changes: 21 additions & 0 deletions transports/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,27 @@ func (h *TransportHTTP) NewPaymail(ctx context.Context, rawXpub, paymailAddress,
)
}

// DeletePaymail will delete a paymail address
func (h *TransportHTTP) DeletePaymail(ctx context.Context, paymailAddress string) ResponseError {
jsonStr, err := json.Marshal(map[string]interface{}{
FieldAddress: paymailAddress,
})
if err != nil {
return WrapError(err)
}

if err := h.doHTTPRequest(
ctx, http.MethodDelete, "/paymail", jsonStr, h.xPriv, true, nil,
); err != nil {
return WrapError(err)
}
if h.debug {
log.Printf("delete paymail: %v\n", paymailAddress)
}

return nil
}

// GetXPub will get the xpub of the current xpub
func (h *TransportHTTP) GetXPub(ctx context.Context) (*buxmodels.Xpub, ResponseError) {
var xPub buxmodels.Xpub
Expand Down
1 change: 1 addition & 0 deletions transports/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ type TransactionService interface {
// PaymailService is the paymail related requests
type PaymailService interface {
NewPaymail(ctx context.Context, rawXpub, paymailAddress, avatar, publicName string, metadata *buxmodels.Metadata) ResponseError
DeletePaymail(ctx context.Context, paymailAddress string) ResponseError
}

// AdminService is the admin related requests
Expand Down
Loading