github.com/stripe/stripe-go/v76@v76.25.0/apps/secret/client.go (about) 1 // 2 // 3 // File generated from our OpenAPI spec 4 // 5 // 6 7 // Package secret provides the /apps/secrets APIs 8 package secret 9 10 import ( 11 "net/http" 12 13 stripe "github.com/stripe/stripe-go/v76" 14 "github.com/stripe/stripe-go/v76/form" 15 ) 16 17 // Client is used to invoke /apps/secrets APIs. 18 type Client struct { 19 B stripe.Backend 20 Key string 21 } 22 23 // New creates a new apps secret. 24 func New(params *stripe.AppsSecretParams) (*stripe.AppsSecret, error) { 25 return getC().New(params) 26 } 27 28 // New creates a new apps secret. 29 func (c Client) New(params *stripe.AppsSecretParams) (*stripe.AppsSecret, error) { 30 secret := &stripe.AppsSecret{} 31 err := c.B.Call(http.MethodPost, "/v1/apps/secrets", c.Key, params, secret) 32 return secret, err 33 } 34 35 // DeleteWhere is the method for the `POST /v1/apps/secrets/delete` API. 36 func DeleteWhere(params *stripe.AppsSecretDeleteWhereParams) (*stripe.AppsSecret, error) { 37 return getC().DeleteWhere(params) 38 } 39 40 // DeleteWhere is the method for the `POST /v1/apps/secrets/delete` API. 41 func (c Client) DeleteWhere(params *stripe.AppsSecretDeleteWhereParams) (*stripe.AppsSecret, error) { 42 secret := &stripe.AppsSecret{} 43 err := c.B.Call( 44 http.MethodPost, 45 "/v1/apps/secrets/delete", 46 c.Key, 47 params, 48 secret, 49 ) 50 return secret, err 51 } 52 53 // Find is the method for the `GET /v1/apps/secrets/find` API. 54 func Find(params *stripe.AppsSecretFindParams) (*stripe.AppsSecret, error) { 55 return getC().Find(params) 56 } 57 58 // Find is the method for the `GET /v1/apps/secrets/find` API. 59 func (c Client) Find(params *stripe.AppsSecretFindParams) (*stripe.AppsSecret, error) { 60 secret := &stripe.AppsSecret{} 61 err := c.B.Call( 62 http.MethodGet, 63 "/v1/apps/secrets/find", 64 c.Key, 65 params, 66 secret, 67 ) 68 return secret, err 69 } 70 71 // List returns a list of apps secrets. 72 func List(params *stripe.AppsSecretListParams) *Iter { 73 return getC().List(params) 74 } 75 76 // List returns a list of apps secrets. 77 func (c Client) List(listParams *stripe.AppsSecretListParams) *Iter { 78 return &Iter{ 79 Iter: stripe.GetIter(listParams, func(p *stripe.Params, b *form.Values) ([]interface{}, stripe.ListContainer, error) { 80 list := &stripe.AppsSecretList{} 81 err := c.B.CallRaw(http.MethodGet, "/v1/apps/secrets", c.Key, b, p, list) 82 83 ret := make([]interface{}, len(list.Data)) 84 for i, v := range list.Data { 85 ret[i] = v 86 } 87 88 return ret, list, err 89 }), 90 } 91 } 92 93 // Iter is an iterator for apps secrets. 94 type Iter struct { 95 *stripe.Iter 96 } 97 98 // AppsSecret returns the apps secret which the iterator is currently pointing to. 99 func (i *Iter) AppsSecret() *stripe.AppsSecret { 100 return i.Current().(*stripe.AppsSecret) 101 } 102 103 // AppsSecretList returns the current list object which the iterator is 104 // currently using. List objects will change as new API calls are made to 105 // continue pagination. 106 func (i *Iter) AppsSecretList() *stripe.AppsSecretList { 107 return i.List().(*stripe.AppsSecretList) 108 } 109 110 func getC() Client { 111 return Client{stripe.GetBackend(stripe.APIBackend), stripe.Key} 112 }