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

     1  //
     2  //
     3  // File generated from our OpenAPI spec
     4  //
     5  //
     6  
     7  package stripe
     8  
     9  import "encoding/json"
    10  
    11  type ReserveTransaction struct {
    12  	Amount int64 `json:"amount"`
    13  	// Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies).
    14  	Currency Currency `json:"currency"`
    15  	// An arbitrary string attached to the object. Often useful for displaying to users.
    16  	Description string `json:"description"`
    17  	// Unique identifier for the object.
    18  	ID string `json:"id"`
    19  	// String representing the object's type. Objects of the same type share the same value.
    20  	Object string `json:"object"`
    21  }
    22  
    23  // UnmarshalJSON handles deserialization of a ReserveTransaction.
    24  // This custom unmarshaling is needed because the resulting
    25  // property may be an id or the full struct if it was expanded.
    26  func (r *ReserveTransaction) UnmarshalJSON(data []byte) error {
    27  	if id, ok := ParseID(data); ok {
    28  		r.ID = id
    29  		return nil
    30  	}
    31  
    32  	type reserveTransaction ReserveTransaction
    33  	var v reserveTransaction
    34  	if err := json.Unmarshal(data, &v); err != nil {
    35  		return err
    36  	}
    37  
    38  	*r = ReserveTransaction(v)
    39  	return nil
    40  }