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

     1  //
     2  //
     3  // File generated from our OpenAPI spec
     4  //
     5  //
     6  
     7  package stripe
     8  
     9  import "encoding/json"
    10  
    11  // Lists all available Climate product objects.
    12  type ClimateProductListParams 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 *ClimateProductListParams) AddExpand(f string) {
    20  	p.Expand = append(p.Expand, &f)
    21  }
    22  
    23  // Retrieves the details of a Climate product with the given ID.
    24  type ClimateProductParams 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 *ClimateProductParams) AddExpand(f string) {
    32  	p.Expand = append(p.Expand, &f)
    33  }
    34  
    35  // Current prices for a metric ton of carbon removal in a currency's smallest unit.
    36  type ClimateProductCurrentPricesPerMetricTon struct {
    37  	// Fees for one metric ton of carbon removal in the currency's smallest unit.
    38  	AmountFees int64 `json:"amount_fees"`
    39  	// Subtotal for one metric ton of carbon removal (excluding fees) in the currency's smallest unit.
    40  	AmountSubtotal int64 `json:"amount_subtotal"`
    41  	// Total for one metric ton of carbon removal (including fees) in the currency's smallest unit.
    42  	AmountTotal int64 `json:"amount_total"`
    43  }
    44  
    45  // A Climate product represents a type of carbon removal unit available for reservation.
    46  // You can retrieve it to see the current price and availability.
    47  type ClimateProduct struct {
    48  	APIResource
    49  	// Time at which the object was created. Measured in seconds since the Unix epoch.
    50  	Created int64 `json:"created"`
    51  	// Current prices for a metric ton of carbon removal in a currency's smallest unit.
    52  	CurrentPricesPerMetricTon map[string]*ClimateProductCurrentPricesPerMetricTon `json:"current_prices_per_metric_ton"`
    53  	// The year in which the carbon removal is expected to be delivered.
    54  	DeliveryYear int64 `json:"delivery_year"`
    55  	// Unique identifier for the object. For convenience, Climate product IDs are human-readable strings
    56  	// that start with `climsku_`. See [carbon removal inventory](https://stripe.com/docs/climate/orders/carbon-removal-inventory)
    57  	// for a list of available carbon removal products.
    58  	ID string `json:"id"`
    59  	// Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
    60  	Livemode bool `json:"livemode"`
    61  	// The quantity of metric tons available for reservation.
    62  	MetricTonsAvailable float64 `json:"metric_tons_available,string"`
    63  	// The Climate product's name.
    64  	Name string `json:"name"`
    65  	// String representing the object's type. Objects of the same type share the same value.
    66  	Object string `json:"object"`
    67  	// The carbon removal suppliers that fulfill orders for this Climate product.
    68  	Suppliers []*ClimateSupplier `json:"suppliers"`
    69  }
    70  
    71  // ClimateProductList is a list of Products as retrieved from a list endpoint.
    72  type ClimateProductList struct {
    73  	APIResource
    74  	ListMeta
    75  	Data []*ClimateProduct `json:"data"`
    76  }
    77  
    78  // UnmarshalJSON handles deserialization of a ClimateProduct.
    79  // This custom unmarshaling is needed because the resulting
    80  // property may be an id or the full struct if it was expanded.
    81  func (c *ClimateProduct) UnmarshalJSON(data []byte) error {
    82  	if id, ok := ParseID(data); ok {
    83  		c.ID = id
    84  		return nil
    85  	}
    86  
    87  	type climateProduct ClimateProduct
    88  	var v climateProduct
    89  	if err := json.Unmarshal(data, &v); err != nil {
    90  		return err
    91  	}
    92  
    93  	*c = ClimateProduct(v)
    94  	return nil
    95  }