Documentation
¶
Overview ¶
Package mock provides mocks attached to the Recurly client for testing code using the Recurly API client.
This package makes it easy to test code using the Recurly API by focusing on the arguments passed into each function and returning the expected result as structs from the Recurly package. There is no need to deal with XML or make any HTTP requests.
Simple Setup ¶
The basic setup for a test involves creating a new mock client, attaching mocks, and returning expected results.
func TestFoo(t *testing.T) {
client := mock.NewClient("subdomain", "key")
client.Billing.OnGet = func(ctx context.Context, accountCode string) (*recurly.Billing, error) {
if accountCode != "10" {
t.Fatalf("unexpected account code: %s", accountCode)
}
return &recurly.Billing{
FirstName: "Foo",
LastName: "Bar",
}
}
if b, err := client.Billing.Get(context.Background(), "10"); err != nil {
t.Fatal(err)
} else if diff := cmp.Diff(b, &recurly.Billing{
FirstName: "Foo",
LastName: "Bar",
}); diff != "" {
t.Fatal(diff)
} else if !client.Billing.GetInvoked {
t.Fatal("expected Get() to be invoked")
}
}
More Common Setup ¶
If you created your own wrapper type to the library, let's call it PaymentsProvider:
// MyBillingInfo is a custom billing holder. *recurly.Billing is converted to
// *MyBillingInfo by combining FirstName and LastName into a single Name field.
type MyBillingInfo{
Name string
}
type PaymentsProvider interface {
GetBilling(ctx context.Context, id int) (*MyBillingInfo, error)
}
// Provider implements PaymentsProvider.
type Provider struct {
Client *recurly.Client
}
func New(subdomain, key string) *Provider {
return &Provider{Client: recurly.NewClient(subdomain, key)}
}
// GetBilling calls Recurly and converts *recurly.BillingInfo to *MyBillingInfo.
func (p *Provider) GetBilling(ctx context.Context, id int) (*MyBillingInfo, error) {
// Retrieve billing info from Recurly.
b, err := p.Client.Billing.Get(ctx, strconv.Atoi(id))
if err != nil {
return nil, err
} else if b == nil {
return nil, nil
}
// Convert to MyBillingInfo.
return &MyBillingInfo{
Name: fmt.Sprintf("%s %s", b.FirstName, b.LastName),
}
}
Then in your test suite you might configure your own wrapper similar to mock.Client
package foo_test
import (
"context"
"github.com/your-project/foo"
"github.com/autopilot3/recurly/mock"
)
// Provider is a test wrapper for foo.Provider.
type Provider struct {
*foo.Provider
Billing mock.Billing
}
// NewProvider returns a new test provider.
func NewProvider() *Provider {
// Init Provider.
p := &Provider{Provider: foo.New("foo", "bar")}
// Point Recurly Client's Billing Service to your mock
// attached to p.
p.Provider.Client.Billing = &p.Billing
return p
}
func TestBilling(t *testing.T) {
// Init test Provider.
p := NewProvider()
// Mock Recurly's response
p.Billing.OnGet = func(ctx context.Context, id int) (*recurly.Billing, error) {
return &recurly.Billing{
FirstName: "Verena",
LastName: "Example",
}
}
// Call your provider and assert *MyBillingInfo
if b, err := p.GetBilling(context.Background(), 10); err != nil {
t.Fatal(err)
} else if diff := cmp.Diff(b, &foo.MyBillingInfo{
Name: "Verena Example",
}); diff != "" {
t.Fatal(diff)
} else if !p.Billing.GetInvoked {
t.Fatal("expected Get() to be invoked")
}
}
See examples for more.
Index ¶
- type AccountsService
- func (m *AccountsService) Balance(ctx context.Context, code string) (*recurly.AccountBalance, error)
- func (m *AccountsService) Close(ctx context.Context, code string) error
- func (m *AccountsService) Create(ctx context.Context, a recurly.Account) (*recurly.Account, error)
- func (m *AccountsService) Get(ctx context.Context, code string) (*recurly.Account, error)
- func (m *AccountsService) List(opts *recurly.PagerOptions) recurly.Pager
- func (m *AccountsService) ListNotes(code string, opts *recurly.PagerOptions) recurly.Pager
- func (m *AccountsService) Reopen(ctx context.Context, code string) error
- func (m *AccountsService) Update(ctx context.Context, code string, a recurly.Account) (*recurly.Account, error)
- type AddOnsService
- func (m *AddOnsService) Create(ctx context.Context, planCode string, a recurly.AddOn) (*recurly.AddOn, error)
- func (m *AddOnsService) Delete(ctx context.Context, planCode string, code string) error
- func (m *AddOnsService) Get(ctx context.Context, planCode string, code string) (*recurly.AddOn, error)
- func (m *AddOnsService) List(planCode string, opts *recurly.PagerOptions) recurly.Pager
- func (m *AddOnsService) Update(ctx context.Context, planCode string, code string, a recurly.AddOn) (*recurly.AddOn, error)
- type AdjustmentsService
- func (m *AdjustmentsService) Create(ctx context.Context, accountCode string, a recurly.Adjustment) (*recurly.Adjustment, error)
- func (m *AdjustmentsService) Delete(ctx context.Context, uuid string) error
- func (m *AdjustmentsService) Get(ctx context.Context, uuid string) (*recurly.Adjustment, error)
- func (m *AdjustmentsService) ListAccount(accountCode string, opts *recurly.PagerOptions) recurly.Pager
- type BillingService
- func (m *BillingService) Clear(ctx context.Context, accountCode string) error
- func (m *BillingService) Create(ctx context.Context, accountCode string, b recurly.Billing) (*recurly.Billing, error)
- func (m *BillingService) Get(ctx context.Context, accountCode string) (*recurly.Billing, error)
- func (m *BillingService) Update(ctx context.Context, accountCode string, b recurly.Billing) (*recurly.Billing, error)
- type Client
- type CouponsService
- func (m *CouponsService) Create(ctx context.Context, c recurly.Coupon) (*recurly.Coupon, error)
- func (m *CouponsService) Delete(ctx context.Context, code string) error
- func (m *CouponsService) Generate(ctx context.Context, code string, n int) (recurly.Pager, error)
- func (m *CouponsService) Get(ctx context.Context, code string) (*recurly.Coupon, error)
- func (m *CouponsService) List(opts *recurly.PagerOptions) recurly.Pager
- func (m *CouponsService) Restore(ctx context.Context, code string, c recurly.Coupon) (*recurly.Coupon, error)
- func (m *CouponsService) Update(ctx context.Context, code string, c recurly.Coupon) (*recurly.Coupon, error)
- type CreditPaymentsService
- type InvoicesService
- func (m *InvoicesService) Collect(ctx context.Context, invoiceNumber int) (*recurly.Invoice, error)
- func (m *InvoicesService) Create(ctx context.Context, accountCode string, invoice recurly.Invoice) (*recurly.Invoice, error)
- func (m *InvoicesService) Get(ctx context.Context, invoiceNumber int) (*recurly.Invoice, error)
- func (m *InvoicesService) GetPDF(ctx context.Context, invoiceNumber int, language string) (*bytes.Buffer, error)
- func (m *InvoicesService) List(opts *recurly.PagerOptions) recurly.Pager
- func (m *InvoicesService) ListAccount(accountCode string, opts *recurly.PagerOptions) recurly.Pager
- func (m *InvoicesService) MarkFailed(ctx context.Context, invoiceNumber int) (*recurly.Invoice, error)
- func (m *InvoicesService) MarkPaid(ctx context.Context, invoiceNumber int) (*recurly.Invoice, error)
- func (m *InvoicesService) Preview(ctx context.Context, accountCode string) (*recurly.Invoice, error)
- func (m *InvoicesService) RecordPayment(ctx context.Context, pmt recurly.OfflinePayment) (*recurly.Transaction, error)
- func (m *InvoicesService) RefundVoidLineItems(ctx context.Context, invoiceNumber int, refund recurly.InvoiceLineItemsRefund) (*recurly.Invoice, error)
- func (m *InvoicesService) RefundVoidOpenAmount(ctx context.Context, invoiceNumber int, refund recurly.InvoiceRefund) (*recurly.Invoice, error)
- func (m *InvoicesService) VoidCreditInvoice(ctx context.Context, invoiceNumber int) (*recurly.Invoice, error)
- type Pager
- type PlansService
- func (m *PlansService) Create(ctx context.Context, p recurly.Plan) (*recurly.Plan, error)
- func (m *PlansService) Delete(ctx context.Context, code string) error
- func (m *PlansService) Get(ctx context.Context, code string) (*recurly.Plan, error)
- func (m *PlansService) List(opts *recurly.PagerOptions) recurly.Pager
- func (m *PlansService) Update(ctx context.Context, code string, p recurly.Plan) (*recurly.Plan, error)
- type PurchasesService
- func (m *PurchasesService) Authorize(ctx context.Context, p recurly.Purchase) (*recurly.Purchase, error)
- func (m *PurchasesService) Cancel(ctx context.Context, transactionUUID string) (*recurly.InvoiceCollection, error)
- func (m *PurchasesService) Capture(ctx context.Context, transactionUUID string) (*recurly.InvoiceCollection, error)
- func (m *PurchasesService) Create(ctx context.Context, p recurly.Purchase) (*recurly.InvoiceCollection, error)
- func (m *PurchasesService) Pending(ctx context.Context, p recurly.Purchase) (*recurly.Purchase, error)
- func (m *PurchasesService) Preview(ctx context.Context, p recurly.Purchase) (*recurly.InvoiceCollection, error)
- type RedemptionsService
- func (m *RedemptionsService) Delete(ctx context.Context, accountCode string) error
- func (m *RedemptionsService) ListAccount(accountCode string, opts *recurly.PagerOptions) recurly.Pager
- func (m *RedemptionsService) ListInvoice(invoiceNumber int, opts *recurly.PagerOptions) recurly.Pager
- func (m *RedemptionsService) ListSubscription(uuid string, opts *recurly.PagerOptions) recurly.Pager
- func (m *RedemptionsService) Redeem(ctx context.Context, code string, r recurly.CouponRedemption) (*recurly.Redemption, error)
- type ShippingAddressesService
- func (s *ShippingAddressesService) Create(ctx context.Context, accountCode string, address recurly.ShippingAddress) (*recurly.ShippingAddress, error)
- func (s *ShippingAddressesService) Delete(ctx context.Context, accountCode string, shippingAddressID int) error
- func (s *ShippingAddressesService) ListAccount(accountCode string, opts *recurly.PagerOptions) recurly.Pager
- func (s *ShippingAddressesService) Update(ctx context.Context, accountCode string, shippingAddressID int, ...) (*recurly.ShippingAddress, error)
- type ShippingMethodsService
- type SubscriptionsService
- func (m *SubscriptionsService) Cancel(ctx context.Context, uuid string) (*recurly.Subscription, error)
- func (m *SubscriptionsService) Create(ctx context.Context, sub recurly.NewSubscription) (*recurly.Subscription, error)
- func (m *SubscriptionsService) Get(ctx context.Context, uuid string) (*recurly.Subscription, error)
- func (m *SubscriptionsService) List(opts *recurly.PagerOptions) recurly.Pager
- func (m *SubscriptionsService) ListAccount(accountCode string, opts *recurly.PagerOptions) recurly.Pager
- func (m *SubscriptionsService) Pause(ctx context.Context, uuid string, cycles int) (*recurly.Subscription, error)
- func (m *SubscriptionsService) Postpone(ctx context.Context, uuid string, dt time.Time, bulk bool) (*recurly.Subscription, error)
- func (m *SubscriptionsService) Preview(ctx context.Context, sub recurly.NewSubscription) (*recurly.Subscription, error)
- func (m *SubscriptionsService) PreviewChange(ctx context.Context, uuid string, sub recurly.UpdateSubscription) (*recurly.Subscription, error)
- func (m *SubscriptionsService) Reactivate(ctx context.Context, uuid string) (*recurly.Subscription, error)
- func (m *SubscriptionsService) Resume(ctx context.Context, uuid string) (*recurly.Subscription, error)
- func (m *SubscriptionsService) Terminate(ctx context.Context, uuid string, refundType string) (*recurly.Subscription, error)
- func (m *SubscriptionsService) Update(ctx context.Context, uuid string, sub recurly.UpdateSubscription) (*recurly.Subscription, error)
- func (m *SubscriptionsService) UpdateNotes(ctx context.Context, uuid string, n recurly.SubscriptionNotes) (*recurly.Subscription, error)
- type TransactionsService
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AccountsService ¶
type AccountsService struct {
OnList func(opts *recurly.PagerOptions) recurly.Pager
ListInvoked bool
OnGet func(ctx context.Context, code string) (*recurly.Account, error)
GetInvoked bool
OnBalance func(ctx context.Context, code string) (*recurly.AccountBalance, error)
BalanceInvoked bool
OnCreate func(ctx context.Context, a recurly.Account) (*recurly.Account, error)
CreateInvoked bool
OnUpdate func(ctx context.Context, code string, a recurly.Account) (*recurly.Account, error)
UpdateInvoked bool
OnClose func(ctx context.Context, code string) error
CloseInvoked bool
OnReopen func(ctx context.Context, code string) error
ReopenInvoked bool
OnListNotes func(code string, opts *recurly.PagerOptions) recurly.Pager
ListNotesInvoked bool
}
AccountsService manages the interactions for accounts.
func (*AccountsService) Balance ¶
func (m *AccountsService) Balance(ctx context.Context, code string) (*recurly.AccountBalance, error)
func (*AccountsService) Close ¶
func (m *AccountsService) Close(ctx context.Context, code string) error
func (*AccountsService) List ¶
func (m *AccountsService) List(opts *recurly.PagerOptions) recurly.Pager
func (*AccountsService) ListNotes ¶
func (m *AccountsService) ListNotes(code string, opts *recurly.PagerOptions) recurly.Pager
type AddOnsService ¶
type AddOnsService struct {
OnList func(planCode string, opts *recurly.PagerOptions) recurly.Pager
ListInvoked bool
OnGet func(ctx context.Context, planCode string, code string) (*recurly.AddOn, error)
GetInvoked bool
OnCreate func(ctx context.Context, planCode string, a recurly.AddOn) (*recurly.AddOn, error)
CreateInvoked bool
OnUpdate func(ctx context.Context, planCode string, code string, a recurly.AddOn) (*recurly.AddOn, error)
UpdateInvoked bool
OnDelete func(ctx context.Context, planCode string, code string) error
DeleteInvoked bool
}
AddOnsService manages the interactions for add ons.
func (*AddOnsService) List ¶
func (m *AddOnsService) List(planCode string, opts *recurly.PagerOptions) recurly.Pager
type AdjustmentsService ¶
type AdjustmentsService struct {
OnListAccount func(accountCode string, opts *recurly.PagerOptions) recurly.Pager
ListAccountInvoked bool
OnGet func(ctx context.Context, uuid string) (*recurly.Adjustment, error)
GetInvoked bool
OnCreate func(ctx context.Context, accountCode string, a recurly.Adjustment) (*recurly.Adjustment, error)
CreateInvoked bool
OnDelete func(ctx context.Context, uuid string) error
DeleteInvoked bool
}
AdjustmentsService manages the interactions for adjustments.
func (*AdjustmentsService) Create ¶
func (m *AdjustmentsService) Create(ctx context.Context, accountCode string, a recurly.Adjustment) (*recurly.Adjustment, error)
func (*AdjustmentsService) Delete ¶
func (m *AdjustmentsService) Delete(ctx context.Context, uuid string) error
func (*AdjustmentsService) Get ¶
func (m *AdjustmentsService) Get(ctx context.Context, uuid string) (*recurly.Adjustment, error)
func (*AdjustmentsService) ListAccount ¶
func (m *AdjustmentsService) ListAccount(accountCode string, opts *recurly.PagerOptions) recurly.Pager
type BillingService ¶
type BillingService struct {
OnGet func(ctx context.Context, accountCode string) (*recurly.Billing, error)
GetInvoked bool
OnCreate func(ctx context.Context, accountCode string, b recurly.Billing) (*recurly.Billing, error)
CreateInvoked bool
OnUpdate func(ctx context.Context, accountCode string, b recurly.Billing) (*recurly.Billing, error)
UpdateInvoked bool
OnClear func(ctx context.Context, accountCode string) error
ClearInvoked bool
}
BillingService manages the interactions for billing.
func (*BillingService) Clear ¶
func (m *BillingService) Clear(ctx context.Context, accountCode string) error
type Client ¶
type Client struct {
*recurly.Client
Accounts AccountsService
AddOns AddOnsService
Adjustments AdjustmentsService
Billing BillingService
Coupons CouponsService
CreditPayments CreditPaymentsService
Redemptions RedemptionsService
Invoices InvoicesService
Plans PlansService
Purchases PurchasesService
ShippingAddresses ShippingAddressesService
ShippingMethods ShippingMethodsService
Subscriptions SubscriptionsService
Transactions TransactionsService
}
Client is a test wrapper for recurly.Client holding mocks for all of the services.
type CouponsService ¶
type CouponsService struct {
OnList func(opts *recurly.PagerOptions) recurly.Pager
ListInvoked bool
OnGet func(ctx context.Context, code string) (*recurly.Coupon, error)
GetInvoked bool
OnCreate func(ctx context.Context, c recurly.Coupon) (*recurly.Coupon, error)
CreateInvoked bool
OnUpdate func(ctx context.Context, code string, c recurly.Coupon) (*recurly.Coupon, error)
UpdateInvoked bool
OnRestore func(ctx context.Context, code string, c recurly.Coupon) (*recurly.Coupon, error)
RestoreInvoked bool
OnDelete func(ctx context.Context, code string) error
DeleteInvoked bool
OnGenerate func(ctx context.Context, code string, n int) (recurly.Pager, error)
GenerateInvoked bool
}
CouponsService manages the interactions for coupons.
func (*CouponsService) Delete ¶
func (m *CouponsService) Delete(ctx context.Context, code string) error
func (*CouponsService) List ¶
func (m *CouponsService) List(opts *recurly.PagerOptions) recurly.Pager
type CreditPaymentsService ¶
type CreditPaymentsService struct {
OnList func(opts *recurly.PagerOptions) recurly.Pager
ListInvoked bool
OnListAccount func(code string, opts *recurly.PagerOptions) recurly.Pager
ListAccountInvoked bool
OnGet func(ctx context.Context, uuid string) (*recurly.CreditPayment, error)
GetInvoked bool
}
CreditPaymentsService manages the interactions for credit payments.
func (*CreditPaymentsService) Get ¶
func (m *CreditPaymentsService) Get(ctx context.Context, uuid string) (*recurly.CreditPayment, error)
func (*CreditPaymentsService) List ¶
func (m *CreditPaymentsService) List(opts *recurly.PagerOptions) recurly.Pager
func (*CreditPaymentsService) ListAccount ¶
func (m *CreditPaymentsService) ListAccount(code string, opts *recurly.PagerOptions) recurly.Pager
type InvoicesService ¶
type InvoicesService struct {
OnList func(opts *recurly.PagerOptions) recurly.Pager
ListInvoked bool
OnListAccount func(accountCode string, opts *recurly.PagerOptions) recurly.Pager
ListAccountInvoked bool
OnGet func(ctx context.Context, invoiceNumber int) (*recurly.Invoice, error)
GetInvoked bool
OnGetPDF func(ctx context.Context, invoiceNumber int, language string) (*bytes.Buffer, error)
GetPDFInvoked bool
OnPreview func(ctx context.Context, accountCode string) (*recurly.Invoice, error)
PreviewInvoked bool
OnCreate func(ctx context.Context, accountCode string, invoice recurly.Invoice) (*recurly.Invoice, error)
CreateInvoked bool
OnCollect func(ctx context.Context, invoiceNumber int) (*recurly.Invoice, error)
CollectInvoked bool
OnMarkPaid func(ctx context.Context, invoiceNumber int) (*recurly.Invoice, error)
MarkPaidInvoked bool
OnMarkFailed func(ctx context.Context, invoiceNumber int) (*recurly.Invoice, error)
MarkFailedInvoked bool
OnRefundVoidLineItems func(ctx context.Context, invoiceNumber int, refund recurly.InvoiceLineItemsRefund) (*recurly.Invoice, error)
RefundVoidLineItemsInvoked bool
OnRefundVoidOpenAmount func(ctx context.Context, invoiceNumber int, refund recurly.InvoiceRefund) (*recurly.Invoice, error)
RefundVoidOpenAmountInvoked bool
OnVoidCreditInvoice func(ctx context.Context, invoiceNumber int) (*recurly.Invoice, error)
VoidCreditInvoiceInvoked bool
OnRecordPayment func(ctx context.Context, pmt recurly.OfflinePayment) (*recurly.Transaction, error)
RecordPaymentInvoked bool
}
InvoicesService manages the interactions for invoices.
func (*InvoicesService) List ¶
func (m *InvoicesService) List(opts *recurly.PagerOptions) recurly.Pager
func (*InvoicesService) ListAccount ¶
func (m *InvoicesService) ListAccount(accountCode string, opts *recurly.PagerOptions) recurly.Pager
func (*InvoicesService) MarkFailed ¶
func (*InvoicesService) RecordPayment ¶
func (m *InvoicesService) RecordPayment(ctx context.Context, pmt recurly.OfflinePayment) (*recurly.Transaction, error)
func (*InvoicesService) RefundVoidLineItems ¶
func (m *InvoicesService) RefundVoidLineItems(ctx context.Context, invoiceNumber int, refund recurly.InvoiceLineItemsRefund) (*recurly.Invoice, error)
func (*InvoicesService) RefundVoidOpenAmount ¶
func (m *InvoicesService) RefundVoidOpenAmount(ctx context.Context, invoiceNumber int, refund recurly.InvoiceRefund) (*recurly.Invoice, error)
func (*InvoicesService) VoidCreditInvoice ¶
type Pager ¶
type Pager struct {
OnCount func(ctx context.Context) (int, error)
CountInvoked bool
OnNext func() bool
NextInvoked bool
OnCursor func() string
CursorInvoked bool
OnFetch func(ctx context.Context, dst interface{}) error
FetchInvoked bool
OnFetchAll func(ctx context.Context, dst interface{}) error
FetchAllInvoked bool
}
type PlansService ¶
type PlansService struct {
OnList func(opts *recurly.PagerOptions) recurly.Pager
ListInvoked bool
OnGet func(ctx context.Context, code string) (*recurly.Plan, error)
GetInvoked bool
OnCreate func(ctx context.Context, p recurly.Plan) (*recurly.Plan, error)
CreateInvoked bool
OnUpdate func(ctx context.Context, code string, p recurly.Plan) (*recurly.Plan, error)
UpdateInvoked bool
OnDelete func(ctx context.Context, code string) error
DeleteInvoked bool
}
PlansService manages the interactions for plans.
func (*PlansService) List ¶
func (m *PlansService) List(opts *recurly.PagerOptions) recurly.Pager
type PurchasesService ¶
type PurchasesService struct {
OnCreate func(ctx context.Context, p recurly.Purchase) (*recurly.InvoiceCollection, error)
CreateInvoked bool
OnPreview func(ctx context.Context, p recurly.Purchase) (*recurly.InvoiceCollection, error)
PreviewInvoked bool
OnAuthorize func(ctx context.Context, p recurly.Purchase) (*recurly.Purchase, error)
AuthorizeInvoked bool
OnPending func(ctx context.Context, p recurly.Purchase) (*recurly.Purchase, error)
PendingInvoked bool
OnCapture func(ctx context.Context, transactionUUID string) (*recurly.InvoiceCollection, error)
CaptureInvoked bool
OnCancel func(ctx context.Context, transactionUUID string) (*recurly.InvoiceCollection, error)
CancelInvoked bool
}
func (*PurchasesService) Cancel ¶
func (m *PurchasesService) Cancel(ctx context.Context, transactionUUID string) (*recurly.InvoiceCollection, error)
func (*PurchasesService) Capture ¶
func (m *PurchasesService) Capture(ctx context.Context, transactionUUID string) (*recurly.InvoiceCollection, error)
func (*PurchasesService) Create ¶
func (m *PurchasesService) Create(ctx context.Context, p recurly.Purchase) (*recurly.InvoiceCollection, error)
func (*PurchasesService) Preview ¶
func (m *PurchasesService) Preview(ctx context.Context, p recurly.Purchase) (*recurly.InvoiceCollection, error)
type RedemptionsService ¶
type RedemptionsService struct {
OnListAccount func(accountCode string, opts *recurly.PagerOptions) recurly.Pager
ListAccountInvoked bool
OnListInvoice func(invoiceNumber int, opts *recurly.PagerOptions) recurly.Pager
ListInvoiceInvoked bool
OnListSubscription func(uuid string, opts *recurly.PagerOptions) recurly.Pager
ListSubscriptionInvoked bool
OnRedeem func(ctx context.Context, code string, r recurly.CouponRedemption) (*recurly.Redemption, error)
RedeemInvoked bool
OnDelete func(ctx context.Context, accountCode string) error
DeleteInvoked bool
}
RedemptionsService manages the interactions for redemptions.
func (*RedemptionsService) Delete ¶
func (m *RedemptionsService) Delete(ctx context.Context, accountCode string) error
func (*RedemptionsService) ListAccount ¶
func (m *RedemptionsService) ListAccount(accountCode string, opts *recurly.PagerOptions) recurly.Pager
func (*RedemptionsService) ListInvoice ¶
func (m *RedemptionsService) ListInvoice(invoiceNumber int, opts *recurly.PagerOptions) recurly.Pager
func (*RedemptionsService) ListSubscription ¶
func (m *RedemptionsService) ListSubscription(uuid string, opts *recurly.PagerOptions) recurly.Pager
func (*RedemptionsService) Redeem ¶
func (m *RedemptionsService) Redeem(ctx context.Context, code string, r recurly.CouponRedemption) (*recurly.Redemption, error)
type ShippingAddressesService ¶
type ShippingAddressesService struct {
OnListAccount func(accountCode string, opts *recurly.PagerOptions) recurly.Pager
ListAccountInvoked bool
OnCreate func(ctx context.Context, accountCode string, address recurly.ShippingAddress) (*recurly.ShippingAddress, error)
CreateInvoked bool
OnUpdate func(ctx context.Context, accountCode string, shippingAddressID int, address recurly.ShippingAddress) (*recurly.ShippingAddress, error)
UpdateInvoked bool
OnDelete func(ctx context.Context, accountCode string, shippingAddressID int) error
DeleteInvoked bool
}
func (*ShippingAddressesService) Create ¶
func (s *ShippingAddressesService) Create(ctx context.Context, accountCode string, address recurly.ShippingAddress) (*recurly.ShippingAddress, error)
func (*ShippingAddressesService) ListAccount ¶
func (s *ShippingAddressesService) ListAccount(accountCode string, opts *recurly.PagerOptions) recurly.Pager
func (*ShippingAddressesService) Update ¶
func (s *ShippingAddressesService) Update(ctx context.Context, accountCode string, shippingAddressID int, address recurly.ShippingAddress) (*recurly.ShippingAddress, error)
type ShippingMethodsService ¶
type ShippingMethodsService struct {
OnList func(opts *recurly.PagerOptions) recurly.Pager
ListInvoked bool
OnGet func(ctx context.Context, code string) (*recurly.ShippingMethod, error)
GetInvoked bool
}
func (*ShippingMethodsService) Get ¶
func (s *ShippingMethodsService) Get(ctx context.Context, code string) (*recurly.ShippingMethod, error)
func (*ShippingMethodsService) List ¶
func (s *ShippingMethodsService) List(opts *recurly.PagerOptions) recurly.Pager
type SubscriptionsService ¶
type SubscriptionsService struct {
OnList func(opts *recurly.PagerOptions) recurly.Pager
ListInvoked bool
OnListAccount func(accountCode string, opts *recurly.PagerOptions) recurly.Pager
ListAccountInvoked bool
OnGet func(ctx context.Context, uuid string) (*recurly.Subscription, error)
GetInvoked bool
OnCreate func(ctx context.Context, sub recurly.NewSubscription) (*recurly.Subscription, error)
CreateInvoked bool
OnPreview func(ctx context.Context, sub recurly.NewSubscription) (*recurly.Subscription, error)
PreviewInvoked bool
OnUpdate func(ctx context.Context, uuid string, sub recurly.UpdateSubscription) (*recurly.Subscription, error)
UpdateInvoked bool
OnUpdateNotes func(ctx context.Context, uuid string, n recurly.SubscriptionNotes) (*recurly.Subscription, error)
UpdateNotesInvoked bool
OnPreviewChange func(ctx context.Context, uuid string, sub recurly.UpdateSubscription) (*recurly.Subscription, error)
PreviewChangeInvoked bool
OnCancel func(ctx context.Context, uuid string) (*recurly.Subscription, error)
CancelInvoked bool
OnReactivate func(ctx context.Context, uuid string) (*recurly.Subscription, error)
ReactivateInvoked bool
OnTerminate func(ctx context.Context, uuid string, refundType string) (*recurly.Subscription, error)
TerminateInvoked bool
OnPostpone func(ctx context.Context, uuid string, dt time.Time, bulk bool) (*recurly.Subscription, error)
PostponeInvoked bool
OnPause func(ctx context.Context, uuid string, cycles int) (*recurly.Subscription, error)
PauseInvoked bool
OnResume func(ctx context.Context, uuid string) (*recurly.Subscription, error)
ResumeInvoked bool
}
SubscriptionsService mocks the subscription service.
func (*SubscriptionsService) Cancel ¶
func (m *SubscriptionsService) Cancel(ctx context.Context, uuid string) (*recurly.Subscription, error)
func (*SubscriptionsService) Create ¶
func (m *SubscriptionsService) Create(ctx context.Context, sub recurly.NewSubscription) (*recurly.Subscription, error)
func (*SubscriptionsService) Get ¶
func (m *SubscriptionsService) Get(ctx context.Context, uuid string) (*recurly.Subscription, error)
func (*SubscriptionsService) List ¶
func (m *SubscriptionsService) List(opts *recurly.PagerOptions) recurly.Pager
func (*SubscriptionsService) ListAccount ¶
func (m *SubscriptionsService) ListAccount(accountCode string, opts *recurly.PagerOptions) recurly.Pager
func (*SubscriptionsService) Pause ¶
func (m *SubscriptionsService) Pause(ctx context.Context, uuid string, cycles int) (*recurly.Subscription, error)
func (*SubscriptionsService) Postpone ¶
func (m *SubscriptionsService) Postpone(ctx context.Context, uuid string, dt time.Time, bulk bool) (*recurly.Subscription, error)
func (*SubscriptionsService) Preview ¶
func (m *SubscriptionsService) Preview(ctx context.Context, sub recurly.NewSubscription) (*recurly.Subscription, error)
func (*SubscriptionsService) PreviewChange ¶
func (m *SubscriptionsService) PreviewChange(ctx context.Context, uuid string, sub recurly.UpdateSubscription) (*recurly.Subscription, error)
func (*SubscriptionsService) Reactivate ¶
func (m *SubscriptionsService) Reactivate(ctx context.Context, uuid string) (*recurly.Subscription, error)
func (*SubscriptionsService) Resume ¶
func (m *SubscriptionsService) Resume(ctx context.Context, uuid string) (*recurly.Subscription, error)
func (*SubscriptionsService) Terminate ¶
func (m *SubscriptionsService) Terminate(ctx context.Context, uuid string, refundType string) (*recurly.Subscription, error)
func (*SubscriptionsService) Update ¶
func (m *SubscriptionsService) Update(ctx context.Context, uuid string, sub recurly.UpdateSubscription) (*recurly.Subscription, error)
func (*SubscriptionsService) UpdateNotes ¶
func (m *SubscriptionsService) UpdateNotes(ctx context.Context, uuid string, n recurly.SubscriptionNotes) (*recurly.Subscription, error)
type TransactionsService ¶
type TransactionsService struct {
OnList func(opts *recurly.PagerOptions) recurly.Pager
ListInvoked bool
OnListAccount func(accountCode string, opts *recurly.PagerOptions) recurly.Pager
ListAccountInvoked bool
OnGet func(ctx context.Context, uuid string) (*recurly.Transaction, error)
GetInvoked bool
}
TransactionsService mocks the transaction service.
func (*TransactionsService) Get ¶
func (m *TransactionsService) Get(ctx context.Context, uuid string) (*recurly.Transaction, error)
func (*TransactionsService) List ¶
func (m *TransactionsService) List(opts *recurly.PagerOptions) recurly.Pager
func (*TransactionsService) ListAccount ¶
func (m *TransactionsService) ListAccount(accountCode string, opts *recurly.PagerOptions) recurly.Pager