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

Make some clients codegen-able #1350

Merged
merged 1 commit into from
Oct 7, 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
44 changes: 24 additions & 20 deletions invoice/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,17 +161,19 @@ func List(params *stripe.InvoiceListParams) *Iter {

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

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

return ret, list, err
})}
return ret, list, err
}),
}
}

// Iter is an iterator for invoices.
Expand Down Expand Up @@ -202,17 +204,19 @@ func (c Client) ListLines(listParams *stripe.InvoiceLineListParams) *LineIter {
"/v1/invoices/%s/lines",
stripe.StringValue(listParams.ID),
)
return &LineIter{stripe.GetIter(listParams, func(p *stripe.Params, b *form.Values) ([]interface{}, stripe.ListContainer, error) {
list := &stripe.InvoiceLineList{}
err := c.B.CallRaw(http.MethodGet, path, 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 &LineIter{
Iter: stripe.GetIter(listParams, func(p *stripe.Params, b *form.Values) ([]interface{}, stripe.ListContainer, error) {
list := &stripe.InvoiceLineList{}
err := c.B.CallRaw(http.MethodGet, path, c.Key, b, p, list)

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

return ret, list, err
}),
}
}

// LineIter is an iterator for invoice line items.
Expand Down
24 changes: 13 additions & 11 deletions promotioncode/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,19 @@ func List(params *stripe.PromotionCodeListParams) *Iter {

// List returns a list of promotion codes.
func (c Client) List(listParams *stripe.PromotionCodeListParams) *Iter {
return &Iter{stripe.GetIter(listParams, func(p *stripe.Params, b *form.Values) ([]interface{}, stripe.ListContainer, error) {
list := &stripe.PromotionCodeList{}
err := c.B.CallRaw(http.MethodGet, "/v1/promotion_codes", 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.PromotionCodeList{}
err := c.B.CallRaw(http.MethodGet, "/v1/promotion_codes", 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 promotion codes.
Expand Down
25 changes: 14 additions & 11 deletions radar/valuelistitem/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
//

// Package valuelistitem provides the /radar/value_list_items APIs
// For more details, see: https://stripe.com/docs/api/radar/list_items?lang=go
package valuelistitem

import (
Expand Down Expand Up @@ -71,17 +72,19 @@ func List(params *stripe.RadarValueListItemListParams) *Iter {

// List returns a list of radar value list items.
func (c Client) List(listParams *stripe.RadarValueListItemListParams) *Iter {
return &Iter{stripe.GetIter(listParams, func(p *stripe.Params, b *form.Values) ([]interface{}, stripe.ListContainer, error) {
list := &stripe.RadarValueListItemList{}
err := c.B.CallRaw(http.MethodGet, "/v1/radar/value_list_items", 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.RadarValueListItemList{}
err := c.B.CallRaw(http.MethodGet, "/v1/radar/value_list_items", 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 radar value list items.
Expand Down
24 changes: 13 additions & 11 deletions reversal/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,17 +87,19 @@ func (c Client) List(listParams *stripe.ReversalListParams) *Iter {
"/v1/transfers/%s/reversals",
stripe.StringValue(listParams.Transfer),
)
return &Iter{stripe.GetIter(listParams, func(p *stripe.Params, b *form.Values) ([]interface{}, stripe.ListContainer, error) {
list := &stripe.ReversalList{}
err := c.B.CallRaw(http.MethodGet, path, 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.ReversalList{}
err := c.B.CallRaw(http.MethodGet, path, 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 reversals.
Expand Down