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