Skip to content

Commit fa80930

Browse files
authored
Fix URL to delete coupon redemptions (#137)
1 parent 9cc01b2 commit fa80930

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

mock/redemptions.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ type RedemptionsService struct {
2222
OnRedeem func(ctx context.Context, code string, r recurly.CouponRedemption) (*recurly.Redemption, error)
2323
RedeemInvoked bool
2424

25-
OnDelete func(ctx context.Context, accountCode string) error
25+
OnDelete func(ctx context.Context, accountCode, couponCode string) error
2626
DeleteInvoked bool
2727
}
2828

@@ -46,7 +46,7 @@ func (m *RedemptionsService) Redeem(ctx context.Context, code string, r recurly.
4646
return m.OnRedeem(ctx, code, r)
4747
}
4848

49-
func (m *RedemptionsService) Delete(ctx context.Context, accountCode string) error {
49+
func (m *RedemptionsService) Delete(ctx context.Context, accountCode, couponCode string) error {
5050
m.DeleteInvoked = true
51-
return m.OnDelete(ctx, accountCode)
51+
return m.OnDelete(ctx, accountCode, couponCode)
5252
}

redemptions.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ type RedemptionsService interface {
4343
// of the coupon. See Recurly's documentation for details.
4444
//
4545
// https://dev.recurly.com/docs/remove-a-coupon-from-an-account
46-
Delete(ctx context.Context, accountCode string) error
46+
Delete(ctx context.Context, accountCode, couponCode string) error
4747
}
4848

4949
// Redemptions constants.
@@ -148,8 +148,8 @@ func (s *redemptionsImpl) Redeem(ctx context.Context, code string, r CouponRedem
148148
return &dst, nil
149149
}
150150

151-
func (s *redemptionsImpl) Delete(ctx context.Context, accountCode string) error {
152-
path := fmt.Sprintf("/accounts/%s/redemption", accountCode)
151+
func (s *redemptionsImpl) Delete(ctx context.Context, accountCode, couponCode string) error {
152+
path := fmt.Sprintf("/accounts/%s/redemptions/%s", accountCode, couponCode)
153153
req, err := s.client.newRequest("DELETE", path, nil)
154154
if err != nil {
155155
return err

redemptions_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,11 +156,11 @@ func TestRedemptions_Delete(t *testing.T) {
156156
client, s := recurly.NewTestServer()
157157
defer s.Close()
158158

159-
s.HandleFunc("DELETE", "/v2/accounts/1/redemption", func(w http.ResponseWriter, r *http.Request) {
159+
s.HandleFunc("DELETE", "/v2/accounts/1/redemptions/30_off", func(w http.ResponseWriter, r *http.Request) {
160160
w.WriteHeader(http.StatusNoContent)
161161
}, t)
162162

163-
if err := client.Redemptions.Delete(context.Background(), "1"); !s.Invoked {
163+
if err := client.Redemptions.Delete(context.Background(), "1", "30_off"); !s.Invoked {
164164
t.Fatal("expected fn invocation")
165165
} else if err != nil {
166166
t.Fatal(err)

0 commit comments

Comments
 (0)