Skip to content

Commit

Permalink
Merge pull request #1709 from stripe/richardm-better-hoisting
Browse files Browse the repository at this point in the history
Add .AddExpand helper to individual param structs
  • Loading branch information
richardm-stripe authored Aug 15, 2023
2 parents eae93c5 + 7ba5293 commit ab336a2
Show file tree
Hide file tree
Showing 106 changed files with 1,380 additions and 16 deletions.
15 changes: 15 additions & 0 deletions account.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,11 @@ type AccountParams struct {
Type *string `form:"type"`
}

// AddExpand appends a new field to expand.
func (p *AccountParams) AddExpand(f string) {
p.Expand = append(p.Expand, &f)
}

// AddMetadata adds a new key-value pair to the Metadata.
func (p *AccountParams) AddMetadata(key string, value string) {
if p.Metadata == nil {
Expand Down Expand Up @@ -821,6 +826,11 @@ type AccountListParams struct {
Expand []*string `form:"expand"`
}

// AddExpand appends a new field to expand.
func (p *AccountListParams) AddExpand(f string) {
p.Expand = append(p.Expand, &f)
}

// With [Connect](https://stripe.com/docs/connect), you may flag accounts as suspicious.
//
// Test-mode Custom and Express accounts can be rejected at any time. Accounts created using live-mode keys may only be rejected once all balances are zero.
Expand Down Expand Up @@ -857,6 +867,11 @@ func (p *AccountExternalAccountParams) AppendTo(body *form.Values, keyParts []st
}
}

// AddExpand appends a new field to expand.
func (p *AccountRejectParams) AddExpand(f string) {
p.Expand = append(p.Expand, &f)
}

type AccountBusinessProfileMonthlyEstimatedRevenue struct {
// A non-negative integer representing how much to charge in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal).
Amount int64 `json:"amount"`
Expand Down
5 changes: 5 additions & 0 deletions accountlink.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ type AccountLinkParams struct {
Type *string `form:"type"`
}

// AddExpand appends a new field to expand.
func (p *AccountLinkParams) AddExpand(f string) {
p.Expand = append(p.Expand, &f)
}

// Account Links are the means by which a Connect platform grants a connected account permission to access
// Stripe-hosted applications, such as Connect Onboarding.
//
Expand Down
11 changes: 11 additions & 0 deletions applepaydomain.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,24 @@ type ApplePayDomainListParams struct {
Expand []*string `form:"expand"`
}

// AddExpand appends a new field to expand.
func (p *ApplePayDomainListParams) AddExpand(f string) {
p.Expand = append(p.Expand, &f)
}

// Create an apple pay domain.
type ApplePayDomainParams struct {
Params `form:"*"`
DomainName *string `form:"domain_name"`
// Specifies which fields in the response should be expanded.
Expand []*string `form:"expand"`
}

// AddExpand appends a new field to expand.
func (p *ApplePayDomainParams) AddExpand(f string) {
p.Expand = append(p.Expand, &f)
}

type ApplePayDomain struct {
APIResource
// Time at which the object was created. Measured in seconds since the Unix epoch.
Expand Down
11 changes: 11 additions & 0 deletions applicationfee.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,23 @@ type ApplicationFeeListParams struct {
Expand []*string `form:"expand"`
}

// AddExpand appends a new field to expand.
func (p *ApplicationFeeListParams) AddExpand(f string) {
p.Expand = append(p.Expand, &f)
}

// Retrieves the details of an application fee that your account has collected. The same information is returned when refunding the application fee.
type ApplicationFeeParams struct {
Params `form:"*"`
// Specifies which fields in the response should be expanded.
Expand []*string `form:"expand"`
}

// AddExpand appends a new field to expand.
func (p *ApplicationFeeParams) AddExpand(f string) {
p.Expand = append(p.Expand, &f)
}

type ApplicationFee struct {
APIResource
// ID of the Stripe account this fee was taken from.
Expand Down
21 changes: 21 additions & 0 deletions apps_secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ type AppsSecretFindParams struct {
Scope *AppsSecretFindScopeParams `form:"scope"`
}

// AddExpand appends a new field to expand.
func (p *AppsSecretFindParams) AddExpand(f string) {
p.Expand = append(p.Expand, &f)
}

// Specifies the scoping of the secret. Requests originating from UI extensions can only access account-scoped secrets or secrets scoped to their own user.
type AppsSecretScopeParams struct {
// The secret scope type.
Expand All @@ -57,6 +62,11 @@ type AppsSecretParams struct {
Scope *AppsSecretScopeParams `form:"scope"`
}

// AddExpand appends a new field to expand.
func (p *AppsSecretParams) AddExpand(f string) {
p.Expand = append(p.Expand, &f)
}

// Specifies the scoping of the secret. Requests originating from UI extensions can only access account-scoped secrets or secrets scoped to their own user.
type AppsSecretListScopeParams struct {
// The secret scope type.
Expand All @@ -74,6 +84,11 @@ type AppsSecretListParams struct {
Scope *AppsSecretListScopeParams `form:"scope"`
}

// AddExpand appends a new field to expand.
func (p *AppsSecretListParams) AddExpand(f string) {
p.Expand = append(p.Expand, &f)
}

// Specifies the scoping of the secret. Requests originating from UI extensions can only access account-scoped secrets or secrets scoped to their own user.
type AppsSecretDeleteWhereScopeParams struct {
// The secret scope type.
Expand All @@ -92,6 +107,12 @@ type AppsSecretDeleteWhereParams struct {
// Specifies the scoping of the secret. Requests originating from UI extensions can only access account-scoped secrets or secrets scoped to their own user.
Scope *AppsSecretDeleteWhereScopeParams `form:"scope"`
}

// AddExpand appends a new field to expand.
func (p *AppsSecretDeleteWhereParams) AddExpand(f string) {
p.Expand = append(p.Expand, &f)
}

type AppsSecretScope struct {
// The secret scope type.
Type AppsSecretScopeType `json:"type"`
Expand Down
5 changes: 5 additions & 0 deletions balance.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ type BalanceParams struct {
Expand []*string `form:"expand"`
}

// AddExpand appends a new field to expand.
func (p *BalanceParams) AddExpand(f string) {
p.Expand = append(p.Expand, &f)
}

// 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.
Expand Down
10 changes: 10 additions & 0 deletions balancetransaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,11 @@ type BalanceTransactionListParams struct {
Type *string `form:"type"`
}

// AddExpand appends a new field to expand.
func (p *BalanceTransactionListParams) AddExpand(f string) {
p.Expand = append(p.Expand, &f)
}

// Retrieves the balance transaction with the given ID.
//
// Note that this endpoint previously used the path /v1/balance/history/:id.
Expand All @@ -143,6 +148,11 @@ type BalanceTransactionParams struct {
Expand []*string `form:"expand"`
}

// AddExpand appends a new field to expand.
func (p *BalanceTransactionParams) AddExpand(f string) {
p.Expand = append(p.Expand, &f)
}

// Detailed breakdown of fees (in cents (or local equivalent)) paid for this transaction.
type BalanceTransactionFeeDetail struct {
// Amount of the fee, in cents.
Expand Down
5 changes: 5 additions & 0 deletions bankaccount.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,11 @@ func (p *BankAccountParams) AppendToAsSourceOrExternalAccount(body *form.Values)
}
}

// AddExpand appends a new field to expand.
func (p *BankAccountParams) AddExpand(f string) {
p.Expand = append(p.Expand, &f)
}

// AddMetadata adds a new key-value pair to the Metadata.
func (p *BankAccountParams) AddMetadata(key string, value string) {
if p.Metadata == nil {
Expand Down
10 changes: 10 additions & 0 deletions billingportal_configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ type BillingPortalConfigurationListParams struct {
IsDefault *bool `form:"is_default"`
}

// AddExpand appends a new field to expand.
func (p *BillingPortalConfigurationListParams) AddExpand(f string) {
p.Expand = append(p.Expand, &f)
}

// The business information shown to customers in the portal.
type BillingPortalConfigurationBusinessProfileParams struct {
// The messaging shown to customers in the portal.
Expand Down Expand Up @@ -205,6 +210,11 @@ type BillingPortalConfigurationParams struct {
Metadata map[string]string `form:"metadata"`
}

// AddExpand appends a new field to expand.
func (p *BillingPortalConfigurationParams) AddExpand(f string) {
p.Expand = append(p.Expand, &f)
}

// AddMetadata adds a new key-value pair to the Metadata.
func (p *BillingPortalConfigurationParams) AddMetadata(key string, value string) {
if p.Metadata == nil {
Expand Down
5 changes: 5 additions & 0 deletions billingportal_session.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,11 @@ type BillingPortalSessionParams struct {
ReturnURL *string `form:"return_url"`
}

// AddExpand appends a new field to expand.
func (p *BillingPortalSessionParams) AddExpand(f string) {
p.Expand = append(p.Expand, &f)
}

// Configuration when `after_completion.type=hosted_confirmation`.
type BillingPortalSessionFlowAfterCompletionHostedConfirmation struct {
// A custom message to display to the customer after the flow is completed.
Expand Down
10 changes: 10 additions & 0 deletions capability.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ type CapabilityListParams struct {
Expand []*string `form:"expand"`
}

// AddExpand appends a new field to expand.
func (p *CapabilityListParams) AddExpand(f string) {
p.Expand = append(p.Expand, &f)
}

// Retrieves information about the specified Account Capability.
type CapabilityParams struct {
Params `form:"*"`
Expand All @@ -55,6 +60,11 @@ type CapabilityParams struct {
Requested *bool `form:"requested"`
}

// AddExpand appends a new field to expand.
func (p *CapabilityParams) AddExpand(f string) {
p.Expand = append(p.Expand, &f)
}

// Fields that are due and can be satisfied by providing the corresponding alternative fields instead.
type CapabilityFutureRequirementsAlternative struct {
// Fields that can be provided to satisfy all fields in `original_fields_due`.
Expand Down
5 changes: 5 additions & 0 deletions card.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,11 @@ func (p *CardParams) AppendToAsCardSourceOrExternalAccount(body *form.Values, ke
}
}

// AddExpand appends a new field to expand.
func (p *CardParams) AddExpand(f string) {
p.Expand = append(p.Expand, &f)
}

// AddMetadata adds a new key-value pair to the Metadata.
func (p *CardParams) AddMetadata(key string, value string) {
if p.Metadata == nil {
Expand Down
5 changes: 5 additions & 0 deletions cashbalance.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ type CashBalanceParams struct {
Customer *string `form:"-"` // Included in URL
}

// AddExpand appends a new field to expand.
func (p *CashBalanceParams) AddExpand(f string) {
p.Expand = append(p.Expand, &f)
}

// A hash of settings for this cash balance.
type CashBalanceSettingsParams struct {
// Controls how funds transferred by the customer are applied to payment intents and invoices. Valid options are `automatic`, `manual`, or `merchant_default`. For more information about these reconciliation modes, see [Reconciliation](https://stripe.com/docs/payments/customer-balance/reconciliation).
Expand Down
22 changes: 22 additions & 0 deletions charge.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,11 @@ type ChargeSearchParams struct {
Page *string `form:"page"`
}

// AddExpand appends a new field to expand.
func (p *ChargeSearchParams) AddExpand(f string) {
p.Expand = append(p.Expand, &f)
}

// Returns a list of charges you've previously created. The charges are returned in sorted order, with the most recent charges appearing first.
type ChargeListParams struct {
ListParams `form:"*"`
Expand All @@ -268,6 +273,12 @@ type ChargeListParams struct {
// Only return charges for this transfer group.
TransferGroup *string `form:"transfer_group"`
}

// AddExpand appends a new field to expand.
func (p *ChargeListParams) AddExpand(f string) {
p.Expand = append(p.Expand, &f)
}

type ChargeDestinationParams struct {
// ID of an existing, connected Stripe account.
Account *string `form:"account"`
Expand Down Expand Up @@ -360,6 +371,11 @@ func (p *ChargeParams) SetSource(sp interface{}) error {
return err
}

// AddExpand appends a new field to expand.
func (p *ChargeParams) AddExpand(f string) {
p.Expand = append(p.Expand, &f)
}

// AddMetadata adds a new key-value pair to the Metadata.
func (p *ChargeParams) AddMetadata(key string, value string) {
if p.Metadata == nil {
Expand Down Expand Up @@ -408,6 +424,12 @@ type ChargeCaptureParams struct {
// A string that identifies this transaction as part of a group. `transfer_group` may only be provided if it has not been set. See the [Connect documentation](https://stripe.com/docs/connect/separate-charges-and-transfers#transfer-options) for details.
TransferGroup *string `form:"transfer_group"`
}

// AddExpand appends a new field to expand.
func (p *ChargeCaptureParams) AddExpand(f string) {
p.Expand = append(p.Expand, &f)
}

type ChargeBillingDetails struct {
// Billing address.
Address *Address `json:"address"`
Expand Down
20 changes: 20 additions & 0 deletions checkout_session.go
Original file line number Diff line number Diff line change
Expand Up @@ -704,6 +704,11 @@ type CheckoutSessionListParams struct {
Subscription *string `form:"subscription"`
}

// AddExpand appends a new field to expand.
func (p *CheckoutSessionListParams) AddExpand(f string) {
p.Expand = append(p.Expand, &f)
}

// Configure a Checkout Session that can be used to recover an expired session.
type CheckoutSessionAfterExpirationRecoveryParams struct {
// Enables user redeemable promotion codes on the recovered Checkout Sessions. Defaults to `false`
Expand Down Expand Up @@ -1769,6 +1774,11 @@ type CheckoutSessionParams struct {
TaxIDCollection *CheckoutSessionTaxIDCollectionParams `form:"tax_id_collection"`
}

// AddExpand appends a new field to expand.
func (p *CheckoutSessionParams) AddExpand(f string) {
p.Expand = append(p.Expand, &f)
}

// AddMetadata adds a new key-value pair to the Metadata.
func (p *CheckoutSessionParams) AddMetadata(key string, value string) {
if p.Metadata == nil {
Expand All @@ -1786,6 +1796,11 @@ type CheckoutSessionListLineItemsParams struct {
Expand []*string `form:"expand"`
}

// AddExpand appends a new field to expand.
func (p *CheckoutSessionListLineItemsParams) AddExpand(f string) {
p.Expand = append(p.Expand, &f)
}

// A Session can be expired when it is in one of these statuses: open
//
// After it expires, a customer can't complete a Session and customers loading the Session see a message saying the Session is expired.
Expand All @@ -1795,6 +1810,11 @@ type CheckoutSessionExpireParams struct {
Expand []*string `form:"expand"`
}

// AddExpand appends a new field to expand.
func (p *CheckoutSessionExpireParams) AddExpand(f string) {
p.Expand = append(p.Expand, &f)
}

// When set, configuration used to recover the Checkout Session on expiry.
type CheckoutSessionAfterExpirationRecovery struct {
// Enables user redeemable promotion codes on the recovered Checkout Sessions. Defaults to `false`
Expand Down
10 changes: 10 additions & 0 deletions countryspec.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ type CountrySpecListParams struct {
Expand []*string `form:"expand"`
}

// AddExpand appends a new field to expand.
func (p *CountrySpecListParams) AddExpand(f string) {
p.Expand = append(p.Expand, &f)
}

// Country is the list of supported countries
type Country string

Expand All @@ -23,6 +28,11 @@ type CountrySpecParams struct {
Expand []*string `form:"expand"`
}

// AddExpand appends a new field to expand.
func (p *CountrySpecParams) AddExpand(f string) {
p.Expand = append(p.Expand, &f)
}

// VerificationFieldsList lists the fields needed for an account verification.
// For more details see https://stripe.com/docs/api#country_spec_object-verification_fields.
type VerificationFieldsList struct {
Expand Down
Loading

0 comments on commit ab336a2

Please sign in to comment.