github.com/stripe/stripe-go/v76@v76.25.0/paymentmethoddomain/client.go (about) 1 // 2 // 3 // File generated from our OpenAPI spec 4 // 5 // 6 7 // Package paymentmethoddomain provides the /payment_method_domains APIs 8 package paymentmethoddomain 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 /payment_method_domains APIs. 18 type Client struct { 19 B stripe.Backend 20 Key string 21 } 22 23 // New creates a new payment method domain. 24 func New(params *stripe.PaymentMethodDomainParams) (*stripe.PaymentMethodDomain, error) { 25 return getC().New(params) 26 } 27 28 // New creates a new payment method domain. 29 func (c Client) New(params *stripe.PaymentMethodDomainParams) (*stripe.PaymentMethodDomain, error) { 30 paymentmethoddomain := &stripe.PaymentMethodDomain{} 31 err := c.B.Call( 32 http.MethodPost, 33 "/v1/payment_method_domains", 34 c.Key, 35 params, 36 paymentmethoddomain, 37 ) 38 return paymentmethoddomain, err 39 } 40 41 // Get returns the details of a payment method domain. 42 func Get(id string, params *stripe.PaymentMethodDomainParams) (*stripe.PaymentMethodDomain, error) { 43 return getC().Get(id, params) 44 } 45 46 // Get returns the details of a payment method domain. 47 func (c Client) Get(id string, params *stripe.PaymentMethodDomainParams) (*stripe.PaymentMethodDomain, error) { 48 path := stripe.FormatURLPath("/v1/payment_method_domains/%s", id) 49 paymentmethoddomain := &stripe.PaymentMethodDomain{} 50 err := c.B.Call(http.MethodGet, path, c.Key, params, paymentmethoddomain) 51 return paymentmethoddomain, err 52 } 53 54 // Update updates a payment method domain's properties. 55 func Update(id string, params *stripe.PaymentMethodDomainParams) (*stripe.PaymentMethodDomain, error) { 56 return getC().Update(id, params) 57 } 58 59 // Update updates a payment method domain's properties. 60 func (c Client) Update(id string, params *stripe.PaymentMethodDomainParams) (*stripe.PaymentMethodDomain, error) { 61 path := stripe.FormatURLPath("/v1/payment_method_domains/%s", id) 62 paymentmethoddomain := &stripe.PaymentMethodDomain{} 63 err := c.B.Call(http.MethodPost, path, c.Key, params, paymentmethoddomain) 64 return paymentmethoddomain, err 65 } 66 67 // Validate is the method for the `POST /v1/payment_method_domains/{payment_method_domain}/validate` API. 68 func Validate(id string, params *stripe.PaymentMethodDomainValidateParams) (*stripe.PaymentMethodDomain, error) { 69 return getC().Validate(id, params) 70 } 71 72 // Validate is the method for the `POST /v1/payment_method_domains/{payment_method_domain}/validate` API. 73 func (c Client) Validate(id string, params *stripe.PaymentMethodDomainValidateParams) (*stripe.PaymentMethodDomain, error) { 74 path := stripe.FormatURLPath("/v1/payment_method_domains/%s/validate", id) 75 paymentmethoddomain := &stripe.PaymentMethodDomain{} 76 err := c.B.Call(http.MethodPost, path, c.Key, params, paymentmethoddomain) 77 return paymentmethoddomain, err 78 } 79 80 // List returns a list of payment method domains. 81 func List(params *stripe.PaymentMethodDomainListParams) *Iter { 82 return getC().List(params) 83 } 84 85 // List returns a list of payment method domains. 86 func (c Client) List(listParams *stripe.PaymentMethodDomainListParams) *Iter { 87 return &Iter{ 88 Iter: stripe.GetIter(listParams, func(p *stripe.Params, b *form.Values) ([]interface{}, stripe.ListContainer, error) { 89 list := &stripe.PaymentMethodDomainList{} 90 err := c.B.CallRaw(http.MethodGet, "/v1/payment_method_domains", c.Key, b, p, list) 91 92 ret := make([]interface{}, len(list.Data)) 93 for i, v := range list.Data { 94 ret[i] = v 95 } 96 97 return ret, list, err 98 }), 99 } 100 } 101 102 // Iter is an iterator for payment method domains. 103 type Iter struct { 104 *stripe.Iter 105 } 106 107 // PaymentMethodDomain returns the payment method domain which the iterator is currently pointing to. 108 func (i *Iter) PaymentMethodDomain() *stripe.PaymentMethodDomain { 109 return i.Current().(*stripe.PaymentMethodDomain) 110 } 111 112 // PaymentMethodDomainList returns the current list object which the iterator is 113 // currently using. List objects will change as new API calls are made to 114 // continue pagination. 115 func (i *Iter) PaymentMethodDomainList() *stripe.PaymentMethodDomainList { 116 return i.List().(*stripe.PaymentMethodDomainList) 117 } 118 119 func getC() Client { 120 return Client{stripe.GetBackend(stripe.APIBackend), stripe.Key} 121 }