Class: Pago::V2026_04::Models::ProductPriceMeter

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

Overview

A meter associated to a metered price.

Constant Summary collapse

JSON_KEYS =

Returns:

  • (Hash[Symbol, String])
{
  id: "id",
  name: "name",
  unit: "unit",
  custom_label: "custom_label",
  custom_multiplier: "custom_multiplier"
}.freeze
REQUIRED_KEYS =

Returns:

  • (Array[String])
["id", "name", "unit", "custom_label", "custom_multiplier"].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(id:, name:, unit:, custom_label:, custom_multiplier:) ⇒ ProductPriceMeter

Returns a new instance of ProductPriceMeter.

Parameters:

  • id: (String)
  • name: (String)
  • unit: (String)
  • custom_label: (String, nil)
  • custom_multiplier: (Integer, nil)


37480
37481
37482
37483
37484
37485
37486
37487
37488
37489
37490
37491
37492
37493
# File 'lib/pago/v2026_04/models.rb', line 37480

def initialize(
  id:,
  name:,
  unit:,
  custom_label:,
  custom_multiplier:
)
  super()
  assign(:id, id)
  assign(:name, name)
  assign(:unit, unit)
  assign(:custom_label, custom_label)
  assign(:custom_multiplier, custom_multiplier)
end

Instance Attribute Details

#custom_labelString? (readonly)

The label for the custom unit.

Returns:

  • (String, nil)


37474
37475
37476
# File 'lib/pago/v2026_04/models.rb', line 37474

def custom_label
  @custom_label
end

#custom_multiplierInteger? (readonly)

The multiplier to convert from base unit to display scale.

Returns:

  • (Integer, nil)


37478
37479
37480
# File 'lib/pago/v2026_04/models.rb', line 37478

def custom_multiplier
  @custom_multiplier
end

#idString (readonly)

The ID of the object.

Returns:

  • (String)


37463
37464
37465
# File 'lib/pago/v2026_04/models.rb', line 37463

def id
  @id
end

#nameString (readonly)

The name of the meter.

Returns:

  • (String)


37467
37468
37469
# File 'lib/pago/v2026_04/models.rb', line 37467

def name
  @name
end

#unitString (readonly)

Returns:

  • (String)


37470
37471
37472
# File 'lib/pago/v2026_04/models.rb', line 37470

def unit
  @unit
end

Class Method Details

.from_json(data) ⇒ ProductPriceMeter?

Parameters:

  • data (Hash, String, nil)

Returns:



37497
37498
37499
37500
37501
37502
37503
37504
37505
37506
37507
37508
37509
37510
37511
37512
# File 'lib/pago/v2026_04/models.rb', line 37497

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(
      id: (data.key?("id") ? data["id"] : ::Pago::UNSET),
      name: (data.key?("name") ? data["name"] : ::Pago::UNSET),
      unit: (data.key?("unit") ? data["unit"] : ::Pago::UNSET),
      custom_label: (data.key?("custom_label") ? data["custom_label"] : ::Pago::UNSET),
      custom_multiplier: (data.key?("custom_multiplier") ? data["custom_multiplier"] : ::Pago::UNSET)
    ),
    data
  )
end