github.com/stripe/stripe-go/v76@v76.25.0/radar/valuelistitem/client.go (about) 1 // 2 // 3 // File generated from our OpenAPI spec 4 // 5 // 6 7 // Package valuelistitem provides the /radar/value_list_items APIs 8 // For more details, see: https://stripe.com/docs/api/radar/list_items?lang=go 9 package valuelistitem 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 /radar/value_list_items APIs. 19 type Client struct { 20 B stripe.Backend 21 Key string 22 } 23 24 // New creates a new radar value list item. 25 func New(params *stripe.RadarValueListItemParams) (*stripe.RadarValueListItem, error) { 26 return getC().New(params) 27 } 28 29 // New creates a new radar value list item. 30 func (c Client) New(params *stripe.RadarValueListItemParams) (*stripe.RadarValueListItem, error) { 31 valuelistitem := &stripe.RadarValueListItem{} 32 err := c.B.Call( 33 http.MethodPost, 34 "/v1/radar/value_list_items", 35 c.Key, 36 params, 37 valuelistitem, 38 ) 39 return valuelistitem, err 40 } 41 42 // Get returns the details of a radar value list item. 43 func Get(id string, params *stripe.RadarValueListItemParams) (*stripe.RadarValueListItem, error) { 44 return getC().Get(id, params) 45 } 46 47 // Get returns the details of a radar value list item. 48 func (c Client) Get(id string, params *stripe.RadarValueListItemParams) (*stripe.RadarValueListItem, error) { 49 path := stripe.FormatURLPath("/v1/radar/value_list_items/%s", id) 50 valuelistitem := &stripe.RadarValueListItem{} 51 err := c.B.Call(http.MethodGet, path, c.Key, params, valuelistitem) 52 return valuelistitem, err 53 } 54 55 // Del removes a radar value list item. 56 func Del(id string, params *stripe.RadarValueListItemParams) (*stripe.RadarValueListItem, error) { 57 return getC().Del(id, params) 58 } 59 60 // Del removes a radar value list item. 61 func (c Client) Del(id string, params *stripe.RadarValueListItemParams) (*stripe.RadarValueListItem, error) { 62 path := stripe.FormatURLPath("/v1/radar/value_list_items/%s", id) 63 valuelistitem := &stripe.RadarValueListItem{} 64 err := c.B.Call(http.MethodDelete, path, c.Key, params, valuelistitem) 65 return valuelistitem, err 66 } 67 68 // List returns a list of radar value list items. 69 func List(params *stripe.RadarValueListItemListParams) *Iter { 70 return getC().List(params) 71 } 72 73 // List returns a list of radar value list items. 74 func (c Client) List(listParams *stripe.RadarValueListItemListParams) *Iter { 75 return &Iter{ 76 Iter: stripe.GetIter(listParams, func(p *stripe.Params, b *form.Values) ([]interface{}, stripe.ListContainer, error) { 77 list := &stripe.RadarValueListItemList{} 78 err := c.B.CallRaw(http.MethodGet, "/v1/radar/value_list_items", c.Key, b, p, list) 79 80 ret := make([]interface{}, len(list.Data)) 81 for i, v := range list.Data { 82 ret[i] = v 83 } 84 85 return ret, list, err 86 }), 87 } 88 } 89 90 // Iter is an iterator for radar value list items. 91 type Iter struct { 92 *stripe.Iter 93 } 94 95 // RadarValueListItem returns the radar value list item which the iterator is currently pointing to. 96 func (i *Iter) RadarValueListItem() *stripe.RadarValueListItem { 97 return i.Current().(*stripe.RadarValueListItem) 98 } 99 100 // RadarValueListItemList returns the current list object which the iterator is 101 // currently using. List objects will change as new API calls are made to 102 // continue pagination. 103 func (i *Iter) RadarValueListItemList() *stripe.RadarValueListItemList { 104 return i.List().(*stripe.RadarValueListItemList) 105 } 106 107 func getC() Client { 108 return Client{stripe.GetBackend(stripe.APIBackend), stripe.Key} 109 }