Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

codegen: add several client.go files #1271

Merged
merged 2 commits into from
Apr 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions accountlink/client.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
// Package accountlink provides API functions related to account links.
//
// For more details, see: https://stripe.com/docs/api/go#account_links.
//
// File generated from our OpenAPI spec
//
//

// Package accountlink provides the /account_links APIs
package accountlink

import (
Expand All @@ -9,7 +13,7 @@ import (
stripe "github.com/stripe/stripe-go/v72"
)

// Client is used to invoke APIs related to account links.
// Client is used to invoke /account_links APIs.
type Client struct {
B stripe.Backend
Key string
Expand All @@ -22,9 +26,15 @@ func New(params *stripe.AccountLinkParams) (*stripe.AccountLink, error) {

// New creates a new account link.
func (c Client) New(params *stripe.AccountLinkParams) (*stripe.AccountLink, error) {
link := &stripe.AccountLink{}
err := c.B.Call(http.MethodPost, "/v1/account_links", c.Key, params, link)
return link, err
accountlink := &stripe.AccountLink{}
err := c.B.Call(
http.MethodPost,
"/v1/account_links",
c.Key,
params,
accountlink,
)
return accountlink, err
}

func getC() Client {
Expand Down
52 changes: 32 additions & 20 deletions applepaydomain/client.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
//
//
// File generated from our OpenAPI spec
//
//

// Package applepaydomain provides the /apple_pay/domains APIs
package applepaydomain

Expand All @@ -8,56 +14,62 @@ import (
"github.com/stripe/stripe-go/v72/form"
)

// Client is used to invoke /apple_pay/domains and Apple Pay domain-related APIs.
// Client is used to invoke /apple_pay/domains APIs.
type Client struct {
B stripe.Backend
Key string
}

// New creates a new Apple Pay domain.
// New creates a new apple pay domain.
func New(params *stripe.ApplePayDomainParams) (*stripe.ApplePayDomain, error) {
return getC().New(params)
}

// New creates a new Apple Pay domain.
// New creates a new apple pay domain.
func (c Client) New(params *stripe.ApplePayDomainParams) (*stripe.ApplePayDomain, error) {
domain := &stripe.ApplePayDomain{}
err := c.B.Call(http.MethodPost, "/v1/apple_pay/domains", c.Key, params, domain)
return domain, err
applepaydomain := &stripe.ApplePayDomain{}
err := c.B.Call(
http.MethodPost,
"/v1/apple_pay/domains",
c.Key,
params,
applepaydomain,
)
return applepaydomain, err
}

// Get retrieves an Apple Pay domain.
// Get returns the details of an apple pay domain.
func Get(id string, params *stripe.ApplePayDomainParams) (*stripe.ApplePayDomain, error) {
return getC().Get(id, params)
}

// Get retrieves an Apple Pay domain.
// Get returns the details of an apple pay domain.
func (c Client) Get(id string, params *stripe.ApplePayDomainParams) (*stripe.ApplePayDomain, error) {
path := stripe.FormatURLPath("/v1/apple_pay/domains/%s", id)
domain := &stripe.ApplePayDomain{}
err := c.B.Call(http.MethodGet, path, c.Key, params, domain)
return domain, err
applepaydomain := &stripe.ApplePayDomain{}
err := c.B.Call(http.MethodGet, path, c.Key, params, applepaydomain)
return applepaydomain, err
}

// Del removes an Apple Pay domain.
// Del removes an apple pay domain.
func Del(id string, params *stripe.ApplePayDomainParams) (*stripe.ApplePayDomain, error) {
return getC().Del(id, params)
}

// Del removes an Apple Pay domain.
// Del removes an apple pay domain.
func (c Client) Del(id string, params *stripe.ApplePayDomainParams) (*stripe.ApplePayDomain, error) {
path := stripe.FormatURLPath("/v1/apple_pay/domains/%s", id)
domain := &stripe.ApplePayDomain{}
err := c.B.Call(http.MethodDelete, path, c.Key, params, domain)
return domain, err
applepaydomain := &stripe.ApplePayDomain{}
err := c.B.Call(http.MethodDelete, path, c.Key, params, applepaydomain)
return applepaydomain, err
}

// List lists available Apple Pay domains.
// List returns a list of apple pay domains.
func List(params *stripe.ApplePayDomainListParams) *Iter {
return getC().List(params)
}

// List lists available Apple Pay domains.
// List returns a list of apple pay domains.
func (c Client) List(listParams *stripe.ApplePayDomainListParams) *Iter {
return &Iter{stripe.GetIter(listParams, func(p *stripe.Params, b *form.Values) ([]interface{}, stripe.ListContainer, error) {
list := &stripe.ApplePayDomainList{}
Expand All @@ -72,12 +84,12 @@ func (c Client) List(listParams *stripe.ApplePayDomainListParams) *Iter {
})}
}

// Iter is an iterator for Apple Pay domains.
// Iter is an iterator for apple pay domains.
type Iter struct {
*stripe.Iter
}

// ApplePayDomain returns the Apple Pay domain which the iterator is currently pointing to.
// ApplePayDomain returns the apple pay domain which the iterator is currently pointing to.
func (i *Iter) ApplePayDomain() *stripe.ApplePayDomain {
return i.Current().(*stripe.ApplePayDomain)
}
Expand Down
12 changes: 9 additions & 3 deletions balancetransaction/client.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
//
//
// File generated from our OpenAPI spec
//
//

// Package balancetransaction provides the /balance_transactions APIs
package balancetransaction

Expand All @@ -22,9 +28,9 @@ func Get(id string, params *stripe.BalanceTransactionParams) (*stripe.BalanceTra
// Get returns the details of a balance transaction.
func (c Client) Get(id string, params *stripe.BalanceTransactionParams) (*stripe.BalanceTransaction, error) {
path := stripe.FormatURLPath("/v1/balance_transactions/%s", id)
transaction := &stripe.BalanceTransaction{}
err := c.B.Call(http.MethodGet, path, c.Key, params, transaction)
return transaction, err
balancetransaction := &stripe.BalanceTransaction{}
err := c.B.Call(http.MethodGet, path, c.Key, params, balancetransaction)
return balancetransaction, err
}

// List returns a list of balance transactions.
Expand Down
16 changes: 14 additions & 2 deletions billingportal/configuration/client.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
// Package configuration provides API functions related to billing portal configurations.
//
//
// File generated from our OpenAPI spec
//
//

// Package configuration provides the /billing_portal/configurations APIs
package configuration

import (
Expand All @@ -22,7 +28,13 @@ func New(params *stripe.BillingPortalConfigurationParams) (*stripe.BillingPortal
// New creates a new billing portal configuration.
func (c Client) New(params *stripe.BillingPortalConfigurationParams) (*stripe.BillingPortalConfiguration, error) {
configuration := &stripe.BillingPortalConfiguration{}
err := c.B.Call(http.MethodPost, "/v1/billing_portal/configurations", c.Key, params, configuration)
err := c.B.Call(
http.MethodPost,
"/v1/billing_portal/configurations",
c.Key,
params,
configuration,
)
return configuration, err
}

Expand Down
20 changes: 16 additions & 4 deletions billingportal/session/client.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
// Package session provides API functions related to billing portal sessions.
//
//
// File generated from our OpenAPI spec
//
//

// Package session provides the /billing_portal/sessions APIs
package session

import (
Expand All @@ -13,15 +19,21 @@ type Client struct {
Key string
}

// New creates a new session.
// New creates a new billing portal session.
func New(params *stripe.BillingPortalSessionParams) (*stripe.BillingPortalSession, error) {
return getC().New(params)
}

// New creates a new session.
// New creates a new billing portal session.
func (c Client) New(params *stripe.BillingPortalSessionParams) (*stripe.BillingPortalSession, error) {
session := &stripe.BillingPortalSession{}
err := c.B.Call(http.MethodPost, "/v1/billing_portal/sessions", c.Key, params, session)
err := c.B.Call(
http.MethodPost,
"/v1/billing_portal/sessions",
c.Key,
params,
session,
)
return session, err
}

Expand Down
34 changes: 20 additions & 14 deletions countryspec/client.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
//
//
// File generated from our OpenAPI spec
//
//

// Package countryspec provides the /country_specs APIs
package countryspec

Expand All @@ -8,31 +14,31 @@ import (
"github.com/stripe/stripe-go/v72/form"
)

// Client is used to invoke /country_specs and countryspec-related APIs.
// Client is used to invoke /country_specs APIs.
type Client struct {
B stripe.Backend
Key string
}

// Get returns a Country Spec for a given country code.
func Get(country string, params *stripe.CountrySpecParams) (*stripe.CountrySpec, error) {
return getC().Get(country, params)
// Get returns the details of a country spec.
func Get(id string, params *stripe.CountrySpecParams) (*stripe.CountrySpec, error) {
return getC().Get(id, params)
}

// Get returns a Country Spec for a given country code.
func (c Client) Get(country string, params *stripe.CountrySpecParams) (*stripe.CountrySpec, error) {
path := stripe.FormatURLPath("/v1/country_specs/%s", country)
countrySpec := &stripe.CountrySpec{}
err := c.B.Call(http.MethodGet, path, c.Key, params, countrySpec)
return countrySpec, err
// Get returns the details of a country spec.
func (c Client) Get(id string, params *stripe.CountrySpecParams) (*stripe.CountrySpec, error) {
path := stripe.FormatURLPath("/v1/country_specs/%s", id)
countryspec := &stripe.CountrySpec{}
err := c.B.Call(http.MethodGet, path, c.Key, params, countryspec)
return countryspec, err
}

// List lists available Country Specs.
// List returns a list of country specs.
func List(params *stripe.CountrySpecListParams) *Iter {
return getC().List(params)
}

// List lists available Country Specs.
// List returns a list of country specs.
func (c Client) List(listParams *stripe.CountrySpecListParams) *Iter {
return &Iter{stripe.GetIter(listParams, func(p *stripe.Params, b *form.Values) ([]interface{}, stripe.ListContainer, error) {
list := &stripe.CountrySpecList{}
Expand All @@ -47,12 +53,12 @@ func (c Client) List(listParams *stripe.CountrySpecListParams) *Iter {
})}
}

// Iter is an iterator for Country Specs.
// Iter is an iterator for country specs.
type Iter struct {
*stripe.Iter
}

// CountrySpec returns the Country Spec which the iterator is currently pointing to.
// CountrySpec returns the country spec which the iterator is currently pointing to.
func (i *Iter) CountrySpec() *stripe.CountrySpec {
return i.Current().(*stripe.CountrySpec)
}
Expand Down
6 changes: 6 additions & 0 deletions coupon/client.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
//
//
// File generated from our OpenAPI spec
//
//

// Package coupon provides the /coupons APIs
package coupon

Expand Down
12 changes: 9 additions & 3 deletions event/client.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
//
//
// File generated from our OpenAPI spec
//
//

// Package event provides the /events APIs
package event

Expand Down Expand Up @@ -57,9 +63,9 @@ func (i *Iter) Event() *stripe.Event {
return i.Current().(*stripe.Event)
}

// EventList returns the current list object which the iterator is currently
// using. List objects will change as new API calls are made to continue
// pagination.
// EventList 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) EventList() *stripe.EventList {
return i.List().(*stripe.EventList)
}
Expand Down
Loading