Class: Pago::V2026_04::Models::ProductPriceMeteredUnitCreate

Inherits:
Model
  • Object
show all
Defined in:
lib/pago/v2026_04/models.rb,
sig/pago/v2026_04/generated.rbs

Overview

Schema to create a metered price with a fixed unit price.

Constant Summary collapse

JSON_KEYS =

Returns:

  • (Hash[Symbol, String])
{
  amount_type: "amount_type",
  price_currency: "price_currency",
  tax_behavior: "tax_behavior",
  meter_id: "meter_id",
  unit_amount: "unit_amount",
  cap_amount: "cap_amount"
}.freeze
REQUIRED_KEYS =

Returns:

  • (Array[String])
["amount_type", "meter_id", "unit_amount"].freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Model

#==, #[], #field_set?, #hash, #inspect, json_keys, required_json_keys, #to_json, #to_json_hash, wrap_raw

Constructor Details

#initialize(amount_type:, price_currency: ::Pago::UNSET, tax_behavior: ::Pago::UNSET, meter_id:, unit_amount:, cap_amount: ::Pago::UNSET) ⇒ ProductPriceMeteredUnitCreate

Returns a new instance of ProductPriceMeteredUnitCreate.

Parameters:

  • amount_type: (String)
  • price_currency: (String, nil) (defaults to: ::Pago::UNSET)
  • tax_behavior: (String, nil) (defaults to: ::Pago::UNSET)
  • meter_id: (String)
  • unit_amount: (Object)
  • cap_amount: (Integer, nil) (defaults to: ::Pago::UNSET)


37676
37677
37678
37679
37680
37681
37682
37683
37684
37685
37686
37687
37688
37689
37690
37691
# File 'lib/pago/v2026_04/models.rb', line 37676

def initialize(
  amount_type:,
  price_currency: ::Pago::UNSET,
  tax_behavior: ::Pago::UNSET,
  meter_id:,
  unit_amount:,
  cap_amount: ::Pago::UNSET
)
  super()
  assign(:amount_type, amount_type)
  assign(:price_currency, price_currency)
  assign(:tax_behavior, tax_behavior)
  assign(:meter_id, meter_id)
  assign(:unit_amount, unit_amount)
  assign(:cap_amount, cap_amount)
end

Instance Attribute Details

#amount_typeString (readonly)

Returns:

  • (String)


37655
37656
37657
# File 'lib/pago/v2026_04/models.rb', line 37655

def amount_type
  @amount_type
end

#cap_amountInteger? (readonly)

Optional maximum amount in cents that can be charged, regardless of the number of units consumed.

Returns:

  • (Integer, nil)


37674
37675
37676
# File 'lib/pago/v2026_04/models.rb', line 37674

def cap_amount
  @cap_amount
end

#meter_idString (readonly)

The ID of the meter associated to the price.

Returns:

  • (String)


37666
37667
37668
# File 'lib/pago/v2026_04/models.rb', line 37666

def meter_id
  @meter_id
end

#price_currencyString (readonly)

Returns:

  • (String)


37658
37659
37660
# File 'lib/pago/v2026_04/models.rb', line 37658

def price_currency
  @price_currency
end

#tax_behaviorString? (readonly)

The tax behavior of the price. If not set, it will default to the organization's default tax behavior.

Returns:

  • (String, nil)


37662
37663
37664
# File 'lib/pago/v2026_04/models.rb', line 37662

def tax_behavior
  @tax_behavior
end

#unit_amountFloat, String (readonly)

The price per unit in cents. Supports up to 12 decimal places.

Returns:

  • (Float, String)


37670
37671
37672
# File 'lib/pago/v2026_04/models.rb', line 37670

def unit_amount
  @unit_amount
end

Class Method Details

.from_json(data) ⇒ ProductPriceMeteredUnitCreate?

Parameters:

  • data (Hash, String, nil)

Returns:



37695
37696
37697
37698
37699
37700
37701
37702
37703
37704
37705
37706
37707
37708
37709
37710
37711
# File 'lib/pago/v2026_04/models.rb', line 37695

def self.from_json(data)
  data = ::JSON.parse(data) if data.is_a?(String)
  data = ::Pago::Serde.object(data)
  return nil if data.nil?

  wrap_raw(
    new(
      amount_type: (data.key?("amount_type") ? data["amount_type"] : ::Pago::UNSET),
      price_currency: (data.key?("price_currency") ? data["price_currency"] : ::Pago::UNSET),
      tax_behavior: (data.key?("tax_behavior") ? data["tax_behavior"] : ::Pago::UNSET),
      meter_id: (data.key?("meter_id") ? data["meter_id"] : ::Pago::UNSET),
      unit_amount: (data.key?("unit_amount") ? data["unit_amount"] : ::Pago::UNSET),
      cap_amount: (data.key?("cap_amount") ? data["cap_amount"] : ::Pago::UNSET)
    ),
    data
  )
end