diff --git a/admin_api.go b/admin_api.go index 6e63f95..517f66a 100644 --- a/admin_api.go +++ b/admin_api.go @@ -332,10 +332,10 @@ func (a *AdminAPI) CreatePaymail(ctx context.Context, cmd *commands.CreatePaymai // DeletePaymail deletes a paymail address with via the Admin Paymails API. // It returns an error if the API request fails. A nil error indicates that the paymail // was successfully deleted. -func (a *AdminAPI) DeletePaymail(ctx context.Context, address string) error { - err := a.paymailsAPI.DeletePaymail(ctx, address) +func (a *AdminAPI) DeletePaymail(ctx context.Context, id string) error { + err := a.paymailsAPI.DeletePaymail(ctx, id) if err != nil { - msg := fmt.Sprintf("remove paymail address: %s", address) + msg := fmt.Sprintf("remove paymail address with id: %s", id) return errutil.NewHTTPErrorFormatter(constants.AdminPaymailAPI, msg, err).FormatGetErr() } diff --git a/examples/admin_remove_paymail/admin_remove_paymail.go b/examples/admin_remove_paymail/admin_remove_paymail.go index 982250b..b0ee26d 100644 --- a/examples/admin_remove_paymail/admin_remove_paymail.go +++ b/examples/admin_remove_paymail/admin_remove_paymail.go @@ -17,7 +17,7 @@ func main() { } ctx := context.Background() - err = adminAPI.DeletePaymail(ctx, examples.Paymail) + err = adminAPI.DeletePaymail(ctx, "d43ed481ba08aae1db02d880ebefe962f9796168387bb293a95024cb02b953ef") if err != nil { log.Fatalf("Failed to delete paymail: %v", err) } diff --git a/internal/api/v1/admin/paymails/paymails_api.go b/internal/api/v1/admin/paymails/paymails_api.go index b1845c4..2b36d71 100644 --- a/internal/api/v1/admin/paymails/paymails_api.go +++ b/internal/api/v1/admin/paymails/paymails_api.go @@ -24,16 +24,11 @@ type API struct { url *url.URL } -func (a *API) DeletePaymail(ctx context.Context, address string) error { - type body struct { - Address string `json:"address"` - } - +func (a *API) DeletePaymail(ctx context.Context, id string) error { _, err := a.httpClient. R(). SetContext(ctx). - SetBody(body{Address: address}). - Delete(a.url.JoinPath(address).String()) + Delete(a.url.JoinPath(id).String()) if err != nil { return fmt.Errorf("HTTP response failure: %w", err) } diff --git a/internal/api/v1/admin/paymails/paymails_api_test.go b/internal/api/v1/admin/paymails/paymails_api_test.go index 75bb747..a2c1877 100644 --- a/internal/api/v1/admin/paymails/paymails_api_test.go +++ b/internal/api/v1/admin/paymails/paymails_api_test.go @@ -20,6 +20,7 @@ import ( const ( paymailsURL = "/api/v1/admin/paymails" xpubID = "xpub22e6cba6-ef6e-432a-8612-63ac4b290ce9" + paymailID = "d43ed481ba08aae1db02d880ebefe962f9796168387bb293a95024cb02b953ef" id = "98dbafe0-4e2b-4307-8fbf-c55209214bae" ) @@ -47,7 +48,7 @@ func TestPaymailsAPI_DeletePaymail(t *testing.T) { }, } - url := testutils.FullAPIURL(t, paymailsURL, xpubID) + url := testutils.FullAPIURL(t, paymailsURL, paymailID) for name, tc := range tests { t.Run(name, func(t *testing.T) { // given: @@ -55,7 +56,7 @@ func TestPaymailsAPI_DeletePaymail(t *testing.T) { transport.RegisterResponder(http.MethodDelete, url, tc.responder) // when: - err := wallet.DeletePaymail(context.Background(), xpubID) + err := wallet.DeletePaymail(context.Background(), paymailID) // then: require.ErrorIs(t, err, tc.expectedErr) diff --git a/regression_tests/regression_workflow_test.go b/regression_tests/regression_workflow_test.go index 3be94eb..46907fc 100644 --- a/regression_tests/regression_workflow_test.go +++ b/regression_tests/regression_workflow_test.go @@ -127,6 +127,7 @@ func TestRegressionWorkflow(t *testing.T) { // then: assert.NoError(err, "Paymail record %s wasn't created successfully for %s by %s. Expect to get nil error", user.paymail, user.alias, admin.paymail) assert.NotNil(paymail, "Expected to get non-nil paymail addresss response after sending creation request by %s.", admin.paymail) + user.paymailID = paymail.ID logSuccessOp(t, err, "Paymail record %s was created successfully for %s by %s.", user.paymail, user.alias, admin.paymail) }) @@ -257,12 +258,13 @@ func TestRegressionWorkflow(t *testing.T) { // given: admin := tc.server.admin paymail := tc.server.user.paymail + paymailID := tc.server.user.paymailID // when: - err := admin.client.DeletePaymail(ctx, paymail) + err := admin.client.DeletePaymail(ctx, paymailID) // then: - assert.NoError(err, "Delete paymail %s wasn't successful by %s. Expect to get nil error, got error: %v", paymail, admin.paymail) + assert.NoError(err, "Delete paymail %s wasn't successful by %s. Expect to get nil error, got error: %v", paymail, admin.paymail, err) logSuccessOp(t, err, "Delete paymail %s was successful by %s", paymail, admin.paymail) }) } diff --git a/regression_tests/spv_wallet_user.go b/regression_tests/spv_wallet_user.go index 5120962..fc9ad09 100644 --- a/regression_tests/spv_wallet_user.go +++ b/regression_tests/spv_wallet_user.go @@ -31,11 +31,12 @@ func (tt transactionsSlice) Has(id string) bool { // The user struct also utilizes the wallet's UserAPI client to interact with the SPV Wallet API // for transaction-related operations. type user struct { - alias string // The unique alias for the user. - xPriv string // The extended private key for the user. - xPub string // The extended public key for the user. - paymail string // The paymail address associated with the user. - client *wallet.UserAPI // The API client for interacting with the SPV Wallet. + alias string // The unique alias for the user. + xPriv string // The extended private key for the user. + xPub string // The extended public key for the user. + paymail string // The paymail address associated with the user. + paymailID string //The paymail id associated with the users paymail. + client *wallet.UserAPI // The API client for interacting with the SPV Wallet. } // setPaymail sets the user's Paymail address with the given domain.