Skip to content

Commit

Permalink
Merge pull request #188 from recurly/v3-v2021-02-25-1681256205
Browse files Browse the repository at this point in the history
Generated Latest Changes for v2021-02-25 (External Accounts)
  • Loading branch information
amandamfielding authored Apr 12, 2023
2 parents 83781a9 + 4a6cdc0 commit de27c5a
Show file tree
Hide file tree
Showing 8 changed files with 608 additions and 0 deletions.
3 changes: 3 additions & 0 deletions account.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ type Account struct {
// The tax exemption certificate number for the account. If the merchant has an integration for the Vertex tax provider, this optional value will be sent in any tax calculation requests for the account.
ExemptionCertificate string `json:"exemption_certificate,omitempty"`

// The external accounts belonging to this account
ExternalAccounts []ExternalAccount `json:"external_accounts,omitempty"`

// The UUID of the parent account associated with this account.
ParentAccountId string `json:"parent_account_id,omitempty"`

Expand Down
3 changes: 3 additions & 0 deletions account_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ type AccountCreate struct {

Acquisition *AccountAcquisitionUpdate `json:"acquisition,omitempty"`

// External Accounts
ExternalAccounts []ExternalAccountCreate `json:"external_accounts,omitempty"`

ShippingAddresses []ShippingAddressCreate `json:"shipping_addresses,omitempty"`

// A secondary value for the account.
Expand Down
144 changes: 144 additions & 0 deletions client_operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,20 @@ type ClientInterface interface {

ListAccountCreditPayments(accountId string, params *ListAccountCreditPaymentsParams, opts ...Option) (CreditPaymentLister, error)

ListAccountExternalAccount(accountId string, opts ...Option) (ExternalAccountLister, error)

CreateAccountExternalAccount(accountId string, body *ExternalAccountCreate, opts ...Option) (*ExternalAccount, error)
CreateAccountExternalAccountWithContext(ctx context.Context, accountId string, body *ExternalAccountCreate, opts ...Option) (*ExternalAccount, error)

GetAccountExternalAccount(accountId string, externalAccountId string, opts ...Option) (*ExternalAccount, error)
GetAccountExternalAccountWithContext(ctx context.Context, accountId string, externalAccountId string, opts ...Option) (*ExternalAccount, error)

UpdateAccountExternalAccount(accountId string, externalAccountId string, body *ExternalAccountUpdate, opts ...Option) (*ExternalAccount, error)
UpdateAccountExternalAccountWithContext(ctx context.Context, accountId string, externalAccountId string, body *ExternalAccountUpdate, opts ...Option) (*ExternalAccount, error)

DeleteAccountExternalAccount(accountId string, externalAccountId string, opts ...Option) (*ExternalAccount, error)
DeleteAccountExternalAccountWithContext(ctx context.Context, accountId string, externalAccountId string, opts ...Option) (*ExternalAccount, error)

ListAccountExternalInvoices(accountId string, params *ListAccountExternalInvoicesParams, opts ...Option) (ExternalInvoiceLister, error)

ListAccountInvoices(accountId string, params *ListAccountInvoicesParams, opts ...Option) (InvoiceLister, error)
Expand Down Expand Up @@ -1437,6 +1451,136 @@ func (c *Client) ListAccountCreditPayments(accountId string, params *ListAccount
return NewCreditPaymentList(c, path, requestOptions), nil
}

// ListAccountExternalAccount List external accounts for an account
//
// API Documentation: https://developers.recurly.com/api/v2021-02-25#operation/list_account_external_account
//
// Returns: A list of external accounts on an account.
func (c *Client) ListAccountExternalAccount(accountId string, opts ...Option) (ExternalAccountLister, error) {
path, err := c.InterpolatePath("/accounts/{account_id}/external_accounts", accountId)
if err != nil {
return nil, err
}
requestOptions := NewRequestOptions(opts...)
return NewExternalAccountList(c, path, requestOptions), nil
}

// CreateAccountExternalAccount wraps CreateAccountExternalAccountWithContext using the background context
func (c *Client) CreateAccountExternalAccount(accountId string, body *ExternalAccountCreate, opts ...Option) (*ExternalAccount, error) {
ctx := context.Background()
return c.createAccountExternalAccount(ctx, accountId, body, opts...)
}

// CreateAccountExternalAccountWithContext Create an external account
//
// API Documentation: https://developers.recurly.com/api/v2021-02-25#operation/create_account_external_account
//
// Returns: A representation of the created external_account.
func (c *Client) CreateAccountExternalAccountWithContext(ctx context.Context, accountId string, body *ExternalAccountCreate, opts ...Option) (*ExternalAccount, error) {
return c.createAccountExternalAccount(ctx, accountId, body, opts...)
}

func (c *Client) createAccountExternalAccount(ctx context.Context, accountId string, body *ExternalAccountCreate, opts ...Option) (*ExternalAccount, error) {
path, err := c.InterpolatePath("/accounts/{account_id}/external_accounts", accountId)
if err != nil {
return nil, err
}
requestOptions := NewRequestOptions(opts...)
result := &ExternalAccount{}
err = c.Call(ctx, http.MethodPost, path, body, nil, requestOptions, result)
if err != nil {
return nil, err
}
return result, err
}

// GetAccountExternalAccount wraps GetAccountExternalAccountWithContext using the background context
func (c *Client) GetAccountExternalAccount(accountId string, externalAccountId string, opts ...Option) (*ExternalAccount, error) {
ctx := context.Background()
return c.getAccountExternalAccount(ctx, accountId, externalAccountId, opts...)
}

// GetAccountExternalAccountWithContext Get an external account for an account
//
// API Documentation: https://developers.recurly.com/api/v2021-02-25#operation/get_account_external_account
//
// Returns: A external account on an account.
func (c *Client) GetAccountExternalAccountWithContext(ctx context.Context, accountId string, externalAccountId string, opts ...Option) (*ExternalAccount, error) {
return c.getAccountExternalAccount(ctx, accountId, externalAccountId, opts...)
}

func (c *Client) getAccountExternalAccount(ctx context.Context, accountId string, externalAccountId string, opts ...Option) (*ExternalAccount, error) {
path, err := c.InterpolatePath("/accounts/{account_id}/external_accounts/{external_account_id}", accountId, externalAccountId)
if err != nil {
return nil, err
}
requestOptions := NewRequestOptions(opts...)
result := &ExternalAccount{}
err = c.Call(ctx, http.MethodGet, path, nil, nil, requestOptions, result)
if err != nil {
return nil, err
}
return result, err
}

// UpdateAccountExternalAccount wraps UpdateAccountExternalAccountWithContext using the background context
func (c *Client) UpdateAccountExternalAccount(accountId string, externalAccountId string, body *ExternalAccountUpdate, opts ...Option) (*ExternalAccount, error) {
ctx := context.Background()
return c.updateAccountExternalAccount(ctx, accountId, externalAccountId, body, opts...)
}

// UpdateAccountExternalAccountWithContext Update an external account
//
// API Documentation: https://developers.recurly.com/api/v2021-02-25#operation/update_account_external_account
//
// Returns: A representation of the updated external_account.
func (c *Client) UpdateAccountExternalAccountWithContext(ctx context.Context, accountId string, externalAccountId string, body *ExternalAccountUpdate, opts ...Option) (*ExternalAccount, error) {
return c.updateAccountExternalAccount(ctx, accountId, externalAccountId, body, opts...)
}

func (c *Client) updateAccountExternalAccount(ctx context.Context, accountId string, externalAccountId string, body *ExternalAccountUpdate, opts ...Option) (*ExternalAccount, error) {
path, err := c.InterpolatePath("/accounts/{account_id}/external_accounts/{external_account_id}", accountId, externalAccountId)
if err != nil {
return nil, err
}
requestOptions := NewRequestOptions(opts...)
result := &ExternalAccount{}
err = c.Call(ctx, http.MethodPut, path, body, nil, requestOptions, result)
if err != nil {
return nil, err
}
return result, err
}

// DeleteAccountExternalAccount wraps DeleteAccountExternalAccountWithContext using the background context
func (c *Client) DeleteAccountExternalAccount(accountId string, externalAccountId string, opts ...Option) (*ExternalAccount, error) {
ctx := context.Background()
return c.deleteAccountExternalAccount(ctx, accountId, externalAccountId, opts...)
}

// DeleteAccountExternalAccountWithContext Delete an external account for an account
//
// API Documentation: https://developers.recurly.com/api/v2021-02-25#operation/delete_account_external_account
//
// Returns: Successful Delete
func (c *Client) DeleteAccountExternalAccountWithContext(ctx context.Context, accountId string, externalAccountId string, opts ...Option) (*ExternalAccount, error) {
return c.deleteAccountExternalAccount(ctx, accountId, externalAccountId, opts...)
}

func (c *Client) deleteAccountExternalAccount(ctx context.Context, accountId string, externalAccountId string, opts ...Option) (*ExternalAccount, error) {
path, err := c.InterpolatePath("/accounts/{account_id}/external_accounts/{external_account_id}", accountId, externalAccountId)
if err != nil {
return nil, err
}
requestOptions := NewRequestOptions(opts...)
result := &ExternalAccount{}
err = c.Call(ctx, http.MethodDelete, path, nil, nil, requestOptions, result)
if err != nil {
return nil, err
}
return result, err
}

type ListAccountExternalInvoicesParams struct {

// Sort - Sort field. You *really* only want to sort by `updated_at` in ascending
Expand Down
134 changes: 134 additions & 0 deletions external_account.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
// This file is automatically created by Recurly's OpenAPI generation process
// and thus any edits you make by hand will be lost. If you wish to make a
// change to this file, please create a Github issue explaining the changes you
// need and we will usher them to the appropriate places.
package recurly

import (
"context"
"net/http"
"time"
)

type ExternalAccount struct {
recurlyResponse *ResponseMetadata

Object string `json:"object,omitempty"`

// UUID of the external_account .
Id string `json:"id,omitempty"`

// Represents the account code for the external account.
ExternalAccountCode string `json:"external_account_code,omitempty"`

// Represents the connection type. `AppleAppStore` or `GooglePlayStore`
ExternalConnectionType string `json:"external_connection_type,omitempty"`

// Created at
CreatedAt time.Time `json:"created_at,omitempty"`

// Last updated at
UpdatedAt time.Time `json:"updated_at,omitempty"`
}

// GetResponse returns the ResponseMetadata that generated this resource
func (resource *ExternalAccount) GetResponse() *ResponseMetadata {
return resource.recurlyResponse
}

// setResponse sets the ResponseMetadata that generated this resource
func (resource *ExternalAccount) setResponse(res *ResponseMetadata) {
resource.recurlyResponse = res
}

// internal struct for deserializing accounts
type externalAccountList struct {
ListMetadata
Data []ExternalAccount `json:"data"`
recurlyResponse *ResponseMetadata
}

// GetResponse returns the ResponseMetadata that generated this resource
func (resource *externalAccountList) GetResponse() *ResponseMetadata {
return resource.recurlyResponse
}

// setResponse sets the ResponseMetadata that generated this resource
func (resource *externalAccountList) setResponse(res *ResponseMetadata) {
resource.recurlyResponse = res
}

// ExternalAccountList allows you to paginate ExternalAccount objects
type ExternalAccountList struct {
client HTTPCaller
requestOptions *RequestOptions
nextPagePath string
hasMore bool
data []ExternalAccount
}

func NewExternalAccountList(client HTTPCaller, nextPagePath string, requestOptions *RequestOptions) *ExternalAccountList {
return &ExternalAccountList{
client: client,
requestOptions: requestOptions,
nextPagePath: nextPagePath,
hasMore: true,
}
}

type ExternalAccountLister interface {
Fetch() error
FetchWithContext(ctx context.Context) error
Count() (*int64, error)
CountWithContext(ctx context.Context) (*int64, error)
Data() []ExternalAccount
HasMore() bool
Next() string
}

func (list *ExternalAccountList) HasMore() bool {
return list.hasMore
}

func (list *ExternalAccountList) Next() string {
return list.nextPagePath
}

func (list *ExternalAccountList) Data() []ExternalAccount {
return list.data
}

// Fetch fetches the next page of data into the `Data` property
func (list *ExternalAccountList) FetchWithContext(ctx context.Context) error {
resources := &externalAccountList{}
err := list.client.Call(ctx, http.MethodGet, list.nextPagePath, nil, nil, list.requestOptions, resources)
if err != nil {
return err
}
// copy over properties from the response
list.nextPagePath = resources.Next
list.hasMore = resources.HasMore
list.data = resources.Data
return nil
}

// Fetch fetches the next page of data into the `Data` property
func (list *ExternalAccountList) Fetch() error {
return list.FetchWithContext(context.Background())
}

// Count returns the count of items on the server that match this pager
func (list *ExternalAccountList) CountWithContext(ctx context.Context) (*int64, error) {
resources := &externalAccountList{}
err := list.client.Call(ctx, http.MethodHead, list.nextPagePath, nil, nil, list.requestOptions, resources)
if err != nil {
return nil, err
}
resp := resources.GetResponse()
return resp.TotalRecords, nil
}

// Count returns the count of items on the server that match this pager
func (list *ExternalAccountList) Count() (*int64, error) {
return list.CountWithContext(context.Background())
}
16 changes: 16 additions & 0 deletions external_account_create.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// This file is automatically created by Recurly's OpenAPI generation process
// and thus any edits you make by hand will be lost. If you wish to make a
// change to this file, please create a Github issue explaining the changes you
// need and we will usher them to the appropriate places.
package recurly

import ()

type ExternalAccountCreate struct {

// Represents the account code for the external account.
ExternalAccountCode *string `json:"external_account_code,omitempty"`

// Represents the connection type. `AppleAppStore` or `GooglePlayStore`
ExternalConnectionType *string `json:"external_connection_type,omitempty"`
}
16 changes: 16 additions & 0 deletions external_account_update.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// This file is automatically created by Recurly's OpenAPI generation process
// and thus any edits you make by hand will be lost. If you wish to make a
// change to this file, please create a Github issue explaining the changes you
// need and we will usher them to the appropriate places.
package recurly

import ()

type ExternalAccountUpdate struct {

// Represents the account code for the external account.
ExternalAccountCode *string `json:"external_account_code,omitempty"`

// Represents the connection type. `AppleAppStore` or `GooglePlayStore`
ExternalConnectionType *string `json:"external_connection_type,omitempty"`
}
Loading

0 comments on commit de27c5a

Please sign in to comment.