Skip to content

Commit

Permalink
Refactor nil check pre-codegen
Browse files Browse the repository at this point in the history
  • Loading branch information
richardm-stripe committed Dec 8, 2021
1 parent 57d69b2 commit 1a2e463
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions sourcetransaction/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
package sourcetransaction

import (
"errors"
"fmt"
"net/http"

stripe "github.com/stripe/stripe-go/v72"
Expand All @@ -22,23 +22,20 @@ func List(params *stripe.SourceTransactionListParams) *Iter {

// List returns a list of source transactions.
func (c Client) List(listParams *stripe.SourceTransactionListParams) *Iter {
var outerErr error
var path string

if listParams == nil || listParams.Source == nil {
outerErr = errors.New("Invalid source transaction params: Source needs to be set")
} else {
path = stripe.FormatURLPath("/v1/sources/%s/source_transactions",
stripe.StringValue(listParams.Source))
return &Iter{
Iter: stripe.GetIter(listParams, func(p *stripe.Params, b *form.Values) ([]interface{}, stripe.ListContainer, error) {
list := &stripe.SourceTransactionList{}
return nil, list, fmt.Errorf("Invalid source transaction params: Source needs to be set")
}),
}
}
path := stripe.FormatURLPath("/v1/sources/%s/source_transactions",
stripe.StringValue(listParams.Source))

return &Iter{stripe.GetIter(listParams, func(p *stripe.Params, b *form.Values) ([]interface{}, stripe.ListContainer, error) {
return &Iter{Iter: stripe.GetIter(listParams, func(p *stripe.Params, b *form.Values) ([]interface{}, stripe.ListContainer, error) {
list := &stripe.SourceTransactionList{}

if outerErr != nil {
return nil, list, outerErr
}

err := c.B.CallRaw(http.MethodGet, path, c.Key, b, p, list)

ret := make([]interface{}, len(list.Data))
Expand Down

0 comments on commit 1a2e463

Please sign in to comment.