github.com/stripe/stripe-go/v76@v76.25.0/setupattempt/client.go (about) 1 // 2 // 3 // File generated from our OpenAPI spec 4 // 5 // 6 7 // Package setupattempt provides the /setup_attempts APIs 8 // For more details, see: https://stripe.com/docs/api/?lang=go#setup_attempts 9 package setupattempt 10 11 import ( 12 "net/http" 13 14 stripe "github.com/stripe/stripe-go/v76" 15 "github.com/stripe/stripe-go/v76/form" 16 ) 17 18 // Client is used to invoke /setup_attempts APIs. 19 type Client struct { 20 B stripe.Backend 21 Key string 22 } 23 24 // List returns a list of setup attempts. 25 func List(params *stripe.SetupAttemptListParams) *Iter { 26 return getC().List(params) 27 } 28 29 // List returns a list of setup attempts. 30 func (c Client) List(listParams *stripe.SetupAttemptListParams) *Iter { 31 return &Iter{ 32 Iter: stripe.GetIter(listParams, func(p *stripe.Params, b *form.Values) ([]interface{}, stripe.ListContainer, error) { 33 list := &stripe.SetupAttemptList{} 34 err := c.B.CallRaw(http.MethodGet, "/v1/setup_attempts", c.Key, b, p, list) 35 36 ret := make([]interface{}, len(list.Data)) 37 for i, v := range list.Data { 38 ret[i] = v 39 } 40 41 return ret, list, err 42 }), 43 } 44 } 45 46 // Iter is an iterator for setup attempts. 47 type Iter struct { 48 *stripe.Iter 49 } 50 51 // SetupAttempt returns the setup attempt which the iterator is currently pointing to. 52 func (i *Iter) SetupAttempt() *stripe.SetupAttempt { 53 return i.Current().(*stripe.SetupAttempt) 54 } 55 56 // SetupAttemptList returns the current list object which the iterator is 57 // currently using. List objects will change as new API calls are made to 58 // continue pagination. 59 func (i *Iter) SetupAttemptList() *stripe.SetupAttemptList { 60 return i.List().(*stripe.SetupAttemptList) 61 } 62 63 func getC() Client { 64 return Client{stripe.GetBackend(stripe.APIBackend), stripe.Key} 65 }