Skip to content

Commit

Permalink
Merge pull request #1370 from stripe/yejia/codegen-misc-2
Browse files Browse the repository at this point in the history
Make more files codegen-able
  • Loading branch information
yejia-stripe authored Nov 4, 2021
2 parents 1a13972 + 93991b2 commit 5a37a40
Show file tree
Hide file tree
Showing 5 changed files with 174 additions and 103 deletions.
88 changes: 47 additions & 41 deletions issuing/authorization/client.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
// Package authorization provides API functions related to issuing authorizations.
//
// For more details, see: https://stripe.com/docs/api/go#issuing_authorizations
//
// File generated from our OpenAPI spec
//
//

// Package authorization provides the /issuing/authorizations APIs
package authorization

import (
Expand All @@ -16,53 +20,53 @@ type Client struct {
Key string
}

// Approve approves an issuing authorization.
func Approve(id string, params *stripe.IssuingAuthorizationApproveParams) (*stripe.IssuingAuthorization, error) {
return getC().Approve(id, params)
// Get returns the details of an issuing authorization.
func Get(id string, params *stripe.IssuingAuthorizationParams) (*stripe.IssuingAuthorization, error) {
return getC().Get(id, params)
}

// Approve updates an issuing authorization.
func (c Client) Approve(id string, params *stripe.IssuingAuthorizationApproveParams) (*stripe.IssuingAuthorization, error) {
path := stripe.FormatURLPath("/v1/issuing/authorizations/%s/approve", id)
// Get returns the details of an issuing authorization.
func (c Client) Get(id string, params *stripe.IssuingAuthorizationParams) (*stripe.IssuingAuthorization, error) {
path := stripe.FormatURLPath("/v1/issuing/authorizations/%s", id)
authorization := &stripe.IssuingAuthorization{}
err := c.B.Call(http.MethodPost, path, c.Key, params, authorization)
err := c.B.Call(http.MethodGet, path, c.Key, params, authorization)
return authorization, err
}

// Decline decline an issuing authorization.
func Decline(id string, params *stripe.IssuingAuthorizationDeclineParams) (*stripe.IssuingAuthorization, error) {
return getC().Decline(id, params)
// Update updates an issuing authorization's properties.
func Update(id string, params *stripe.IssuingAuthorizationParams) (*stripe.IssuingAuthorization, error) {
return getC().Update(id, params)
}

// Decline updates an issuing authorization.
func (c Client) Decline(id string, params *stripe.IssuingAuthorizationDeclineParams) (*stripe.IssuingAuthorization, error) {
path := stripe.FormatURLPath("/v1/issuing/authorizations/%s/decline", id)
// Update updates an issuing authorization's properties.
func (c Client) Update(id string, params *stripe.IssuingAuthorizationParams) (*stripe.IssuingAuthorization, error) {
path := stripe.FormatURLPath("/v1/issuing/authorizations/%s", id)
authorization := &stripe.IssuingAuthorization{}
err := c.B.Call(http.MethodPost, path, c.Key, params, authorization)
return authorization, err
}

// Get returns the details of an issuing authorization.
func Get(id string, params *stripe.IssuingAuthorizationParams) (*stripe.IssuingAuthorization, error) {
return getC().Get(id, params)
// Approve is the method for the `POST /v1/issuing/authorizations/{authorization}/approve` API.
func Approve(id string, params *stripe.IssuingAuthorizationApproveParams) (*stripe.IssuingAuthorization, error) {
return getC().Approve(id, params)
}

// Get returns the details of an issuing authorization.
func (c Client) Get(id string, params *stripe.IssuingAuthorizationParams) (*stripe.IssuingAuthorization, error) {
path := stripe.FormatURLPath("/v1/issuing/authorizations/%s", id)
// Approve is the method for the `POST /v1/issuing/authorizations/{authorization}/approve` API.
func (c Client) Approve(id string, params *stripe.IssuingAuthorizationApproveParams) (*stripe.IssuingAuthorization, error) {
path := stripe.FormatURLPath("/v1/issuing/authorizations/%s/approve", id)
authorization := &stripe.IssuingAuthorization{}
err := c.B.Call(http.MethodGet, path, c.Key, params, authorization)
err := c.B.Call(http.MethodPost, path, c.Key, params, authorization)
return authorization, err
}

// Update updates an issuing authorization.
func Update(id string, params *stripe.IssuingAuthorizationParams) (*stripe.IssuingAuthorization, error) {
return getC().Update(id, params)
// Decline is the method for the `POST /v1/issuing/authorizations/{authorization}/decline` API.
func Decline(id string, params *stripe.IssuingAuthorizationDeclineParams) (*stripe.IssuingAuthorization, error) {
return getC().Decline(id, params)
}

// Update updates an issuing authorization.
func (c Client) Update(id string, params *stripe.IssuingAuthorizationParams) (*stripe.IssuingAuthorization, error) {
path := stripe.FormatURLPath("/v1/issuing/authorizations/%s", id)
// Decline is the method for the `POST /v1/issuing/authorizations/{authorization}/decline` API.
func (c Client) Decline(id string, params *stripe.IssuingAuthorizationDeclineParams) (*stripe.IssuingAuthorization, error) {
path := stripe.FormatURLPath("/v1/issuing/authorizations/%s/decline", id)
authorization := &stripe.IssuingAuthorization{}
err := c.B.Call(http.MethodPost, path, c.Key, params, authorization)
return authorization, err
Expand All @@ -75,17 +79,19 @@ func List(params *stripe.IssuingAuthorizationListParams) *Iter {

// List returns a list of issuing authorizations.
func (c Client) List(listParams *stripe.IssuingAuthorizationListParams) *Iter {
return &Iter{stripe.GetIter(listParams, func(p *stripe.Params, b *form.Values) ([]interface{}, stripe.ListContainer, error) {
list := &stripe.IssuingAuthorizationList{}
err := c.B.CallRaw(http.MethodGet, "/v1/issuing/authorizations", c.Key, b, p, list)

ret := make([]interface{}, len(list.Data))
for i, v := range list.Data {
ret[i] = v
}

return ret, list, err
})}
return &Iter{
Iter: stripe.GetIter(listParams, func(p *stripe.Params, b *form.Values) ([]interface{}, stripe.ListContainer, error) {
list := &stripe.IssuingAuthorizationList{}
err := c.B.CallRaw(http.MethodGet, "/v1/issuing/authorizations", c.Key, b, p, list)

ret := make([]interface{}, len(list.Data))
for i, v := range list.Data {
ret[i] = v
}

return ret, list, err
}),
}
}

// Iter is an iterator for issuing authorizations.
Expand All @@ -98,8 +104,8 @@ func (i *Iter) IssuingAuthorization() *stripe.IssuingAuthorization {
return i.Current().(*stripe.IssuingAuthorization)
}

// IssuingAuthorizationList returns the current list object which the iterator
// is currently using. List objects will change as new API calls are made to
// IssuingAuthorizationList returns the current list object which the iterator is
// currently using. List objects will change as new API calls are made to
// continue pagination.
func (i *Iter) IssuingAuthorizationList() *stripe.IssuingAuthorizationList {
return i.List().(*stripe.IssuingAuthorizationList)
Expand Down
6 changes: 6 additions & 0 deletions issuing_authorization.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
//
//
// File generated from our OpenAPI spec
//
//

package stripe

import "encoding/json"
Expand Down
39 changes: 28 additions & 11 deletions setupattempt.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
//
//
// File generated from our OpenAPI spec
//
//

package stripe

import (
"encoding/json"
)
import "encoding/json"

// SetupAttemptPaymentMethodDetailsCardThreeDSecureAuthenticationFlow indicates the type of 3D Secure authentication performed.
type SetupAttemptPaymentMethodDetailsCardThreeDSecureAuthenticationFlow string
Expand Down Expand Up @@ -84,6 +88,9 @@ type SetupAttemptPaymentMethodDetailsCardThreeDSecure struct {
ResultReason SetupAttemptPaymentMethodDetailsCardThreeDSecureResultReason `json:"result_reason"`
Version string `json:"version"`
}
type SetupAttemptPaymentMethodDetailsACSSDebit struct{}
type SetupAttemptPaymentMethodDetailsAUBECSDebit struct{}
type SetupAttemptPaymentMethodDetailsBACSDebit struct{}

// SetupAttemptPaymentMethodDetailsBancontact represents details about the Bancontact PaymentMethod.
type SetupAttemptPaymentMethodDetailsBancontact struct {
Expand All @@ -101,6 +108,9 @@ type SetupAttemptPaymentMethodDetailsBancontact struct {
type SetupAttemptPaymentMethodDetailsCard struct {
ThreeDSecure *SetupAttemptPaymentMethodDetailsCardThreeDSecure `json:"three_d_secure"`
}
type SetupAttemptPaymentMethodDetailsCardPresent struct {
GeneratedCard *PaymentMethod `json:"generated_card"`
}

// SetupAttemptPaymentMethodDetailsIdeal represents details about the Bancontact PaymentMethod.
type SetupAttemptPaymentMethodDetailsIdeal struct {
Expand All @@ -111,6 +121,7 @@ type SetupAttemptPaymentMethodDetailsIdeal struct {
IbanLast4 string `json:"iban_last4"`
VerifiedName string `json:"verified_name"`
}
type SetupAttemptPaymentMethodDetailsSepaDebit struct{}

// SetupAttemptPaymentMethodDetailsSofort represents details about the Bancontact PaymentMethod.
type SetupAttemptPaymentMethodDetailsSofort struct {
Expand All @@ -126,11 +137,16 @@ type SetupAttemptPaymentMethodDetailsSofort struct {

// SetupAttemptPaymentMethodDetails represents the details about the PaymentMethod associated with the setup attempt.
type SetupAttemptPaymentMethodDetails struct {
Bancontact *SetupAttemptPaymentMethodDetailsBancontact `json:"bancontact"`
Card *SetupAttemptPaymentMethodDetailsCard `json:"card"`
Ideal *SetupAttemptPaymentMethodDetailsIdeal `json:"ideal"`
Sofort *SetupAttemptPaymentMethodDetailsSofort `json:"sofort"`
Type SetupAttemptPaymentMethodDetailsType `json:"type"`
ACSSDebit *SetupAttemptPaymentMethodDetailsACSSDebit `json:"acss_debit"`
AUBECSDebit *SetupAttemptPaymentMethodDetailsAUBECSDebit `json:"au_becs_debit"`
BACSDebit *SetupAttemptPaymentMethodDetailsBACSDebit `json:"bacs_debit"`
Bancontact *SetupAttemptPaymentMethodDetailsBancontact `json:"bancontact"`
Card *SetupAttemptPaymentMethodDetailsCard `json:"card"`
CardPresent *SetupAttemptPaymentMethodDetailsCardPresent `json:"card_present"`
Ideal *SetupAttemptPaymentMethodDetailsIdeal `json:"ideal"`
SepaDebit *SetupAttemptPaymentMethodDetailsSepaDebit `json:"sepa_debit"`
Sofort *SetupAttemptPaymentMethodDetailsSofort `json:"sofort"`
Type SetupAttemptPaymentMethodDetailsType `json:"type"`
}

// SetupAttempt is the resource representing a Stripe setup attempt.
Expand All @@ -146,6 +162,7 @@ type SetupAttempt struct {
PaymentMethod *PaymentMethod `json:"payment_method"`
PaymentMethodDetails *SetupAttemptPaymentMethodDetails `json:"payment_method_details"`
SetupError *Error `json:"setup_error"`
SetupIntent *SetupIntent `json:"setup_intent"`
Status SetupAttemptStatus `json:"status"`
Usage SetupAttemptUsage `json:"usage"`
}
Expand All @@ -160,9 +177,9 @@ type SetupAttemptList struct {
// UnmarshalJSON handles deserialization of a SetupAttempt.
// This custom unmarshaling is needed because the resulting
// property may be an id or the full struct if it was expanded.
func (p *SetupAttempt) UnmarshalJSON(data []byte) error {
func (s *SetupAttempt) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
p.ID = id
s.ID = id
return nil
}

Expand All @@ -172,6 +189,6 @@ func (p *SetupAttempt) UnmarshalJSON(data []byte) error {
return err
}

*p = SetupAttempt(v)
*s = SetupAttempt(v)
return nil
}
50 changes: 40 additions & 10 deletions setupintent.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
//
//
// File generated from our OpenAPI spec
//
//

package stripe

import (
"encoding/json"
)
import "encoding/json"

// SetupIntentCancellationReason is the list of allowed values for the cancelation reason.
type SetupIntentCancellationReason string

// List of values that SetupIntentCancellationReason can take.
const (
SetupIntentCancellationReasonAbandoned SetupIntentCancellationReason = "abandoned"
SetupIntentCancellationReasonDuplicate SetupIntentCancellationReason = "duplicate"
SetupIntentCancellationReasonFailedInvoice SetupIntentCancellationReason = "failed_invoice"
SetupIntentCancellationReasonFraudulent SetupIntentCancellationReason = "fraudulent"
SetupIntentCancellationReasonRequestedByCustomer SetupIntentCancellationReason = "requested_by_customer"
Expand All @@ -23,6 +28,15 @@ const (
SetupIntentNextActionTypeRedirectToURL SetupIntentNextActionType = "redirect_to_url"
)

// Currency supported by the bank account
type SetupIntentPaymentMethodOptionsACSSDebitCurrency string

// List of values that SetupIntentPaymentMethodOptionsACSSDebitCurrency can take
const (
SetupIntentPaymentMethodOptionsACSSDebitCurrencyCAD SetupIntentPaymentMethodOptionsACSSDebitCurrency = "cad"
SetupIntentPaymentMethodOptionsACSSDebitCurrencyUSD SetupIntentPaymentMethodOptionsACSSDebitCurrency = "usd"
)

// List of Stripe products where this mandate can be selected automatically.
type SetupIntentPaymentMethodOptionsACSSDebitMandateOptionsDefaultFor string

Expand Down Expand Up @@ -70,8 +84,9 @@ type SetupIntentPaymentMethodOptionsCardRequestThreeDSecure string

// List of values that SetupIntentNextActionType can take.
const (
SetupIntentPaymentMethodOptionsCardRequestThreeDSecureAny SetupIntentPaymentMethodOptionsCardRequestThreeDSecure = "any"
SetupIntentPaymentMethodOptionsCardRequestThreeDSecureAutomatic SetupIntentPaymentMethodOptionsCardRequestThreeDSecure = "automatic"
SetupIntentPaymentMethodOptionsCardRequestThreeDSecureAny SetupIntentPaymentMethodOptionsCardRequestThreeDSecure = "any"
SetupIntentPaymentMethodOptionsCardRequestThreeDSecureAutomatic SetupIntentPaymentMethodOptionsCardRequestThreeDSecure = "automatic"
SetupIntentPaymentMethodOptionsCardRequestThreeDSecureChallengeOnly SetupIntentPaymentMethodOptionsCardRequestThreeDSecure = "challenge_only"
)

// SetupIntentStatus is the list of allowed values for the setup intent's status.
Expand Down Expand Up @@ -113,8 +128,7 @@ type SetupIntentConfirmParams struct {

// SetupIntentMandateDataCustomerAcceptanceOfflineParams is the set of parameters for the customer
// acceptance of an offline mandate.
type SetupIntentMandateDataCustomerAcceptanceOfflineParams struct {
}
type SetupIntentMandateDataCustomerAcceptanceOfflineParams struct{}

// SetupIntentMandateDataCustomerAcceptanceOnlineParams is the set of parameters for the customer
// acceptance of an online mandate.
Expand Down Expand Up @@ -163,11 +177,20 @@ type SetupIntentPaymentMethodOptionsCardParams struct {
RequestThreeDSecure *string `form:"request_three_d_secure"`
}

// Additional fields for Mandate creation
type SetupIntentPaymentMethodOptionsSepaDebitMandateOptionsParams struct{}

// If this is a `sepa_debit` SetupIntent, this sub-hash contains details about the SEPA Debit payment method options.
type SetupIntentPaymentMethodOptionsSepaDebitParams struct {
MandateOptions *SetupIntentPaymentMethodOptionsSepaDebitMandateOptionsParams `form:"mandate_options"`
}

// SetupIntentPaymentMethodOptionsParams represents the type-specific payment method options
// applied to a SetupIntent.
type SetupIntentPaymentMethodOptionsParams struct {
ACSSDebit *SetupIntentPaymentMethodOptionsACSSDebitParams `form:"acss_debit"`
Card *SetupIntentPaymentMethodOptionsCardParams `form:"card"`
SepaDebit *SetupIntentPaymentMethodOptionsSepaDebitParams `form:"sepa_debit"`
}

// SetupIntentSingleUseParams represents the single-use mandate-specific parameters.
Expand All @@ -179,6 +202,7 @@ type SetupIntentSingleUseParams struct {
// SetupIntentParams is the set of parameters that can be used when handling a setup intent.
type SetupIntentParams struct {
Params `form:"*"`
ClientSecret *string `form:"client_secret"`
Confirm *bool `form:"confirm"`
Customer *string `form:"customer"`
Description *string `form:"description"`
Expand Down Expand Up @@ -241,6 +265,7 @@ type SetupIntentPaymentMethodOptionsACSSDebitMandateOptions struct {
// SetupIntentPaymentMethodOptionsACSSDebit represents the ACSS debit-specific options applied
// to a SetupIntent.
type SetupIntentPaymentMethodOptionsACSSDebit struct {
// See SetupIntentPaymentMethodOptionsACSSDebitCurrency for allowed values
Currency string `json:"currency"`
MandateOptions *SetupIntentPaymentMethodOptionsACSSDebitMandateOptions `json:"mandate_options"`
VerificationMethod SetupIntentPaymentMethodOptionsACSSDebitVerificationMethod `json:"verification_method"`
Expand All @@ -251,12 +276,17 @@ type SetupIntentPaymentMethodOptionsACSSDebit struct {
type SetupIntentPaymentMethodOptionsCard struct {
RequestThreeDSecure SetupIntentPaymentMethodOptionsCardRequestThreeDSecure `json:"request_three_d_secure"`
}
type SetupIntentPaymentMethodOptionsSepaDebitMandateOptions struct{}
type SetupIntentPaymentMethodOptionsSepaDebit struct {
MandateOptions *SetupIntentPaymentMethodOptionsSepaDebitMandateOptions `json:"mandate_options"`
}

// SetupIntentPaymentMethodOptions represents the type-specific payment method options applied to a
// SetupIntent.
type SetupIntentPaymentMethodOptions struct {
ACSSDebit *SetupIntentPaymentMethodOptionsACSSDebit `json:"acss_debit"`
Card *SetupIntentPaymentMethodOptionsCard `json:"card"`
SepaDebit *SetupIntentPaymentMethodOptionsSepaDebit `json:"sepa_debit"`
}

// SetupIntent is the resource representing a Stripe payout.
Expand Down Expand Up @@ -296,9 +326,9 @@ type SetupIntentList struct {
// UnmarshalJSON handles deserialization of a SetupIntent.
// This custom unmarshaling is needed because the resulting
// property may be an id or the full struct if it was expanded.
func (p *SetupIntent) UnmarshalJSON(data []byte) error {
func (s *SetupIntent) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
p.ID = id
s.ID = id
return nil
}

Expand All @@ -308,6 +338,6 @@ func (p *SetupIntent) UnmarshalJSON(data []byte) error {
return err
}

*p = SetupIntent(v)
*s = SetupIntent(v)
return nil
}
Loading

0 comments on commit 5a37a40

Please sign in to comment.