github.com/stripe/stripe-go/v76@v76.25.0/taxcode.go (about)

     1  //
     2  //
     3  // File generated from our OpenAPI spec
     4  //
     5  //
     6  
     7  package stripe
     8  
     9  import "encoding/json"
    10  
    11  // A list of [all tax codes available](https://stripe.com/docs/tax/tax-categories) to add to Products in order to allow specific tax calculations.
    12  type TaxCodeListParams struct {
    13  	ListParams `form:"*"`
    14  	// Specifies which fields in the response should be expanded.
    15  	Expand []*string `form:"expand"`
    16  }
    17  
    18  // AddExpand appends a new field to expand.
    19  func (p *TaxCodeListParams) AddExpand(f string) {
    20  	p.Expand = append(p.Expand, &f)
    21  }
    22  
    23  // Retrieves the details of an existing tax code. Supply the unique tax code ID and Stripe will return the corresponding tax code information.
    24  type TaxCodeParams struct {
    25  	Params `form:"*"`
    26  	// Specifies which fields in the response should be expanded.
    27  	Expand []*string `form:"expand"`
    28  }
    29  
    30  // AddExpand appends a new field to expand.
    31  func (p *TaxCodeParams) AddExpand(f string) {
    32  	p.Expand = append(p.Expand, &f)
    33  }
    34  
    35  // [Tax codes](https://stripe.com/docs/tax/tax-categories) classify goods and services for tax purposes.
    36  type TaxCode struct {
    37  	APIResource
    38  	// A detailed description of which types of products the tax code represents.
    39  	Description string `json:"description"`
    40  	// Unique identifier for the object.
    41  	ID string `json:"id"`
    42  	// A short name for the tax code.
    43  	Name string `json:"name"`
    44  	// String representing the object's type. Objects of the same type share the same value.
    45  	Object string `json:"object"`
    46  }
    47  
    48  // TaxCodeList is a list of TaxCodes as retrieved from a list endpoint.
    49  type TaxCodeList struct {
    50  	APIResource
    51  	ListMeta
    52  	Data []*TaxCode `json:"data"`
    53  }
    54  
    55  // UnmarshalJSON handles deserialization of a TaxCode.
    56  // This custom unmarshaling is needed because the resulting
    57  // property may be an id or the full struct if it was expanded.
    58  func (t *TaxCode) UnmarshalJSON(data []byte) error {
    59  	if id, ok := ParseID(data); ok {
    60  		t.ID = id
    61  		return nil
    62  	}
    63  
    64  	type taxCode TaxCode
    65  	var v taxCode
    66  	if err := json.Unmarshal(data, &v); err != nil {
    67  		return err
    68  	}
    69  
    70  	*t = TaxCode(v)
    71  	return nil
    72  }