Skip to content

Commit

Permalink
Codegen next major version
Browse files Browse the repository at this point in the history
  • Loading branch information
yejia-stripe committed Jul 22, 2022
1 parent 3194c1a commit 15fafde
Show file tree
Hide file tree
Showing 91 changed files with 2,364 additions and 1,996 deletions.
305 changes: 165 additions & 140 deletions account.go

Large diffs are not rendered by default.

9 changes: 3 additions & 6 deletions balance.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ const (
BalanceSourceTypeFPX BalanceSourceType = "fpx"
)

// BalanceTransactionStatus is the list of allowed values for the balance transaction's status.
type BalanceTransactionStatus string

// Retrieves the current account balance, based on the authentication that was used to make the request.
// For a sample request, see [Accounting for negative balances](https://stripe.com/docs/connect/account-balances#accounting-for-negative-balances).
type BalanceParams struct {
Expand All @@ -28,12 +25,12 @@ type BalanceParams struct {
// Funds that are available to be transferred or paid out, whether automatically by Stripe or explicitly via the [Transfers API](https://stripe.com/docs/api#transfers) or [Payouts API](https://stripe.com/docs/api#payouts). The available balance for each currency and payment type can be found in the `source_types` property.
type Amount struct {
// Balance amount.
Value int64 `json:"amount"`
Amount int64 `json:"amount"`
// Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies).
Currency Currency `json:"currency"`
SourceTypes map[BalanceSourceType]int64 `json:"source_types"`
}
type BalanceDetails struct {
type BalanceIssuing struct {
// Funds that are available for use.
Available []*Amount `json:"available"`
}
Expand All @@ -57,7 +54,7 @@ type Balance struct {
ConnectReserved []*Amount `json:"connect_reserved"`
// Funds that can be paid out using Instant Payouts.
InstantAvailable []*Amount `json:"instant_available"`
Issuing *BalanceDetails `json:"issuing"`
Issuing *BalanceIssuing `json:"issuing"`
// Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
Livemode bool `json:"livemode"`
// String representing the object's type. Objects of the same type share the same value.
Expand Down
10 changes: 0 additions & 10 deletions balance/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,6 @@ func (c Client) Get(params *stripe.BalanceParams) (*stripe.Balance, error) {
return balance, err
}

// Iter is an iterator for balance transactions.
type Iter struct {
*stripe.Iter
}

// BalanceTransaction returns the balance transaction which the iterator is currently pointing to.
func (i *Iter) BalanceTransaction() *stripe.BalanceTransaction {
return i.Current().(*stripe.BalanceTransaction)
}

func getC() Client {
return Client{stripe.GetBackend(stripe.APIBackend), stripe.Key}
}
83 changes: 43 additions & 40 deletions balancetransaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,14 @@ const (
BalanceTransactionSourceTypeIssuingTransaction BalanceTransactionSourceType = "issuing.transaction"
BalanceTransactionSourceTypePayout BalanceTransactionSourceType = "payout"
BalanceTransactionSourceTypeRefund BalanceTransactionSourceType = "refund"
BalanceTransactionSourceTypeReversal BalanceTransactionSourceType = "reversal"
BalanceTransactionSourceTypeTopup BalanceTransactionSourceType = "topup"
BalanceTransactionSourceTypeTransfer BalanceTransactionSourceType = "transfer"
BalanceTransactionSourceTypeTransferReversal BalanceTransactionSourceType = "transfer_reversal"
)

// If the transaction's net funds are available in the Stripe balance yet. Either `available` or `pending`.
type BalanceTransactionStatus string

// List of values that BalanceTransactionStatus can take
const (
BalanceTransactionStatusAvailable BalanceTransactionStatus = "available"
Expand All @@ -71,38 +74,38 @@ type BalanceTransactionType string

// List of values that BalanceTransactionType can take
const (
BalanceTransactionTypeAdjustment BalanceTransactionType = "adjustment"
BalanceTransactionTypeAdvance BalanceTransactionType = "advance"
BalanceTransactionTypeAdvanceFunding BalanceTransactionType = "advance_funding"
BalanceTransactionTypeAnticipationRepayment BalanceTransactionType = "anticipation_repayment"
BalanceTransactionTypeApplicationFee BalanceTransactionType = "application_fee"
BalanceTransactionTypeApplicationFeeRefund BalanceTransactionType = "application_fee_refund"
BalanceTransactionTypeCharge BalanceTransactionType = "charge"
BalanceTransactionTypeConnectCollectionTransfer BalanceTransactionType = "connect_collection_transfer"
BalanceTransactionTypeContribution BalanceTransactionType = "contribution"
BalanceTransactionTypeIssuingAuthorizationHold BalanceTransactionType = "issuing_authorization_hold"
BalanceTransactionTypeIssuingAuthorizationRelease BalanceTransactionType = "issuing_authorization_release"
BalanceTransactionTypeIssuingAuthorizationDispute BalanceTransactionType = "issuing_dispute"
BalanceTransactionTypeIssuingAuthorizationTransaction BalanceTransactionType = "issuing_transaction"
BalanceTransactionTypePayment BalanceTransactionType = "payment"
BalanceTransactionTypePaymentFailureRefund BalanceTransactionType = "payment_failure_refund"
BalanceTransactionTypePaymentRefund BalanceTransactionType = "payment_refund"
BalanceTransactionTypePayout BalanceTransactionType = "payout"
BalanceTransactionTypePayoutCancel BalanceTransactionType = "payout_cancel"
BalanceTransactionTypePayoutFailure BalanceTransactionType = "payout_failure"
BalanceTransactionTypeRefund BalanceTransactionType = "refund"
BalanceTransactionTypeRefundFailure BalanceTransactionType = "refund_failure"
BalanceTransactionTypeReserveTransaction BalanceTransactionType = "reserve_transaction"
BalanceTransactionTypeReservedFunds BalanceTransactionType = "reserved_funds"
BalanceTransactionTypeStripeFee BalanceTransactionType = "stripe_fee"
BalanceTransactionTypeStripeFxFee BalanceTransactionType = "stripe_fx_fee"
BalanceTransactionTypeTaxFee BalanceTransactionType = "tax_fee"
BalanceTransactionTypeTopup BalanceTransactionType = "topup"
BalanceTransactionTypeTopupReversal BalanceTransactionType = "topup_reversal"
BalanceTransactionTypeTransfer BalanceTransactionType = "transfer"
BalanceTransactionTypeTransferCancel BalanceTransactionType = "transfer_cancel"
BalanceTransactionTypeTransferFailure BalanceTransactionType = "transfer_failure"
BalanceTransactionTypeTransferRefund BalanceTransactionType = "transfer_refund"
BalanceTransactionTypeAdjustment BalanceTransactionType = "adjustment"
BalanceTransactionTypeAdvance BalanceTransactionType = "advance"
BalanceTransactionTypeAdvanceFunding BalanceTransactionType = "advance_funding"
BalanceTransactionTypeAnticipationRepayment BalanceTransactionType = "anticipation_repayment"
BalanceTransactionTypeApplicationFee BalanceTransactionType = "application_fee"
BalanceTransactionTypeApplicationFeeRefund BalanceTransactionType = "application_fee_refund"
BalanceTransactionTypeCharge BalanceTransactionType = "charge"
BalanceTransactionTypeConnectCollectionTransfer BalanceTransactionType = "connect_collection_transfer"
BalanceTransactionTypeContribution BalanceTransactionType = "contribution"
BalanceTransactionTypeIssuingAuthorizationHold BalanceTransactionType = "issuing_authorization_hold"
BalanceTransactionTypeIssuingAuthorizationRelease BalanceTransactionType = "issuing_authorization_release"
BalanceTransactionTypeIssuingDispute BalanceTransactionType = "issuing_dispute"
BalanceTransactionTypeIssuingTransaction BalanceTransactionType = "issuing_transaction"
BalanceTransactionTypePayment BalanceTransactionType = "payment"
BalanceTransactionTypePaymentFailureRefund BalanceTransactionType = "payment_failure_refund"
BalanceTransactionTypePaymentRefund BalanceTransactionType = "payment_refund"
BalanceTransactionTypePayout BalanceTransactionType = "payout"
BalanceTransactionTypePayoutCancel BalanceTransactionType = "payout_cancel"
BalanceTransactionTypePayoutFailure BalanceTransactionType = "payout_failure"
BalanceTransactionTypeRefund BalanceTransactionType = "refund"
BalanceTransactionTypeRefundFailure BalanceTransactionType = "refund_failure"
BalanceTransactionTypeReserveTransaction BalanceTransactionType = "reserve_transaction"
BalanceTransactionTypeReservedFunds BalanceTransactionType = "reserved_funds"
BalanceTransactionTypeStripeFee BalanceTransactionType = "stripe_fee"
BalanceTransactionTypeStripeFxFee BalanceTransactionType = "stripe_fx_fee"
BalanceTransactionTypeTaxFee BalanceTransactionType = "tax_fee"
BalanceTransactionTypeTopup BalanceTransactionType = "topup"
BalanceTransactionTypeTopupReversal BalanceTransactionType = "topup_reversal"
BalanceTransactionTypeTransfer BalanceTransactionType = "transfer"
BalanceTransactionTypeTransferCancel BalanceTransactionType = "transfer_cancel"
BalanceTransactionTypeTransferFailure BalanceTransactionType = "transfer_failure"
BalanceTransactionTypeTransferRefund BalanceTransactionType = "transfer_refund"
)

// Returns a list of transactions that have contributed to the Stripe account balance (e.g., charges, transfers, and so forth). The transactions are returned in sorted order, with the most recent transactions appearing first.
Expand Down Expand Up @@ -133,8 +136,8 @@ type BalanceTransactionParams struct {
Params `form:"*"`
}

// Fees (in %s) paid for this transaction.
type BalanceTransactionFee struct {
// Detailed breakdown of fees (in %s) paid for this transaction.
type BalanceTransactionFeeDetail struct {
// Amount of the fee, in cents.
Amount int64 `json:"amount"`
// ID of the Connect application that earned the fee.
Expand Down Expand Up @@ -168,7 +171,7 @@ type BalanceTransaction struct {
// Fees (in %s) paid for this transaction.
Fee int64 `json:"fee"`
// Detailed breakdown of fees (in %s) paid for this transaction.
FeeDetails []*BalanceTransactionFee `json:"fee_details"`
FeeDetails []*BalanceTransactionFeeDetail `json:"fee_details"`
// Unique identifier for the object.
ID string `json:"id"`
// Net amount of the transaction, in %s.
Expand All @@ -195,12 +198,12 @@ type BalanceTransactionSource struct {
FeeRefund *FeeRefund `json:"-"`
IssuingAuthorization *IssuingAuthorization `json:"-"`
IssuingDispute *IssuingDispute `json:"-"`
IssuingTransaction *IssuingAuthorization `json:"-"`
IssuingTransaction *IssuingTransaction `json:"-"`
Payout *Payout `json:"-"`
Refund *Refund `json:"-"`
Reversal *Reversal `json:"-"`
Topup *Topup `json:"-"`
Transfer *Transfer `json:"-"`
TransferReversal *TransferReversal `json:"-"`
}

// BalanceTransactionList is a list of BalanceTransactions as retrieved from a list endpoint.
Expand Down Expand Up @@ -268,12 +271,12 @@ func (b *BalanceTransactionSource) UnmarshalJSON(data []byte) error {
err = json.Unmarshal(data, &b.Payout)
case BalanceTransactionSourceTypeRefund:
err = json.Unmarshal(data, &b.Refund)
case BalanceTransactionSourceTypeReversal:
err = json.Unmarshal(data, &b.Reversal)
case BalanceTransactionSourceTypeTopup:
err = json.Unmarshal(data, &b.Topup)
case BalanceTransactionSourceTypeTransfer:
err = json.Unmarshal(data, &b.Transfer)
case BalanceTransactionSourceTypeTransferReversal:
err = json.Unmarshal(data, &b.TransferReversal)
}
return err
}
12 changes: 8 additions & 4 deletions bankaccount.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ type BankAccountParams struct {
AccountHolderName *string `form:"account_holder_name"`
// The type of entity that holds the account. This can be either `individual` or `company`.
AccountHolderType *string `form:"account_holder_type"`
AccountNumber *string `form:"account_number"`
// The account number for the bank account, in string form. Must be a checking account.
AccountNumber *string `form:"account_number"`
// The bank account type. This can only be `checking` or `savings` in most countries. In Japan, this can only be `futsu` or `toza`.
AccountType *string `form:"account_type"`
// City/District/Suburb/Town/Village.
Expand All @@ -75,16 +76,19 @@ type BankAccountParams struct {
AddressState *string `form:"address_state"`
// ZIP or postal code.
AddressZip *string `form:"address_zip"`
Country *string `form:"country"`
Currency *string `form:"currency"`
// The country in which the bank account is located.
Country *string `form:"country"`
// The currency the bank account is in. This must be a country/currency pairing that [Stripe supports](https://stripe.com/docs/payouts).
Currency *string `form:"currency"`
// When set to true, this becomes the default external account for its currency.
DefaultForCurrency *bool `form:"default_for_currency"`
// Two digit number representing the card's expiration month.
ExpMonth *string `form:"exp_month"`
// Four digit number representing the card's expiration year.
ExpYear *string `form:"exp_year"`
// Cardholder name.
Name *string `form:"name"`
Name *string `form:"name"`
// The routing number, sort code, or other country-appropriate institution number for the bank account. For US bank accounts, this is required and should be the ACH routing number, not the wire routing number. If you are providing an IBAN for `account_number`, this field is not required.
RoutingNumber *string `form:"routing_number"`
// ID is used when tokenizing a bank account for shared customers
ID *string `form:"*"`
Expand Down
44 changes: 22 additions & 22 deletions bankaccount/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ func (c Client) New(params *stripe.BankAccountParams) (*stripe.BankAccount, erro
}

var path string
if params.Customer != nil {
path = stripe.FormatURLPath("/v1/customers/%s/sources", stripe.StringValue(params.Customer))
if (params.Account == nil) == (params.Customer == nil) {
return nil, fmt.Errorf("Invalid bank account params: exactly one of Account or Customer need to be set")
} else if params.Account != nil {
path = stripe.FormatURLPath("/v1/accounts/%s/external_accounts", stripe.StringValue(params.Account))
} else {
return nil, fmt.Errorf("Invalid bank account params: either Customer or Account need to be set")
} else if params.Customer != nil {
path = stripe.FormatURLPath("/v1/customers/%s/sources", stripe.StringValue(params.Customer))
}

body := &form.Values{}
Expand Down Expand Up @@ -68,12 +68,12 @@ func (c Client) Get(id string, params *stripe.BankAccountParams) (*stripe.BankAc
}

var path string
if params != nil && params.Customer != nil {
path = stripe.FormatURLPath("/v1/customers/%s/sources/%s", stripe.StringValue(params.Customer), id)
} else if params != nil && params.Account != nil {
if (params.Account == nil) == (params.Customer == nil) {
return nil, fmt.Errorf("Invalid bank account params: exactly one of Account or Customer need to be set")
} else if params.Account != nil {
path = stripe.FormatURLPath("/v1/accounts/%s/external_accounts/%s", stripe.StringValue(params.Account), id)
} else {
return nil, fmt.Errorf("Invalid bank account params: either Customer or Account need to be set")
} else if params.Customer != nil {
path = stripe.FormatURLPath("/v1/customers/%s/sources/%s", stripe.StringValue(params.Customer), id)
}

bankaccount := &stripe.BankAccount{}
Expand All @@ -93,12 +93,12 @@ func (c Client) Update(id string, params *stripe.BankAccountParams) (*stripe.Ban
}

var path string
if params.Customer != nil {
path = stripe.FormatURLPath("/v1/customers/%s/sources/%s", stripe.StringValue(params.Customer), id)
if (params.Account == nil) == (params.Customer == nil) {
return nil, fmt.Errorf("Invalid bank account params: exactly one of Account or Customer need to be set")
} else if params.Account != nil {
path = stripe.FormatURLPath("/v1/accounts/%s/external_accounts/%s", stripe.StringValue(params.Account), id)
} else {
return nil, fmt.Errorf("Invalid bank account params: either Customer or Account need to be set")
} else if params.Customer != nil {
path = stripe.FormatURLPath("/v1/customers/%s/sources/%s", stripe.StringValue(params.Customer), id)
}

bankaccount := &stripe.BankAccount{}
Expand All @@ -118,12 +118,12 @@ func (c Client) Del(id string, params *stripe.BankAccountParams) (*stripe.BankAc
}

var path string
if params.Customer != nil {
path = stripe.FormatURLPath("/v1/customers/%s/sources/%s", stripe.StringValue(params.Customer), id)
if (params.Account == nil) == (params.Customer == nil) {
return nil, fmt.Errorf("Invalid bank account params: exactly one of Account or Customer need to be set")
} else if params.Account != nil {
path = stripe.FormatURLPath("/v1/accounts/%s/external_accounts/%s", stripe.StringValue(params.Account), id)
} else {
return nil, fmt.Errorf("Invalid bank account params: either Customer or Account need to be set")
} else if params.Customer != nil {
path = stripe.FormatURLPath("/v1/customers/%s/sources/%s", stripe.StringValue(params.Customer), id)
}

bankaccount := &stripe.BankAccount{}
Expand All @@ -147,14 +147,14 @@ func (c Client) List(listParams *stripe.BankAccountListParams) *Iter {
// back with the response.
if listParams == nil {
outerErr = fmt.Errorf("params should not be nil")
} else if listParams.Customer != nil {
path = stripe.FormatURLPath("/v1/customers/%s/sources",
stripe.StringValue(listParams.Customer))
} else if (listParams.Account == nil) == (listParams.Customer == nil) {
return nil, fmt.Errorf("Invalid bank account params: exactly one of Account or Customer need to be set")
} else if listParams.Account != nil {
path = stripe.FormatURLPath("/v1/accounts/%s/external_accounts",
stripe.StringValue(listParams.Account))
} else {
outerErr = fmt.Errorf("Invalid bank account params: either Customer or Account need to be set")
} else if listParams.Customer != nil {
path = stripe.FormatURLPath("/v1/customers/%s/sources",
stripe.StringValue(listParams.Customer))
}
return &Iter{
Iter: stripe.GetIter(listParams, func(p *stripe.Params, b *form.Values) ([]interface{}, stripe.ListContainer, error) {
Expand Down
2 changes: 1 addition & 1 deletion billingportal_configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ type BillingPortalConfiguration struct {
// Whether the configuration is active and can be used to create portal sessions.
Active bool `json:"active"`
// ID of the Connect Application that created the configuration.
Application string `json:"application"`
Application *Application `json:"application"`
BusinessProfile *BillingPortalConfigurationBusinessProfile `json:"business_profile"`
// Time at which the object was created. Measured in seconds since the Unix epoch.
Created int64 `json:"created"`
Expand Down
21 changes: 0 additions & 21 deletions billingportal_session.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

package stripe

import "encoding/json"

// Creates a session of the customer portal.
type BillingPortalSessionParams struct {
Params `form:"*"`
Expand Down Expand Up @@ -60,22 +58,3 @@ type BillingPortalSession struct {
// The short-lived URL of the session that gives customers access to the customer portal.
URL string `json:"url"`
}

// UnmarshalJSON handles deserialization of a BillingPortalSession.
// This custom unmarshaling is needed because the resulting
// property may be an id or the full struct if it was expanded.
func (b *BillingPortalSession) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
b.ID = id
return nil
}

type billingPortalSession BillingPortalSession
var v billingPortalSession
if err := json.Unmarshal(data, &v); err != nil {
return err
}

*b = BillingPortalSession(v)
return nil
}
Loading

0 comments on commit 15fafde

Please sign in to comment.