Class: Pago::V2026_04::Models::SubscriptionMeter

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

Overview

Current consumption and spending for a subscription meter.

Constant Summary collapse

JSON_KEYS =

Returns:

  • (Hash[Symbol, String])
{
  created_at: "created_at",
  modified_at: "modified_at",
  id: "id",
  consumed_units: "consumed_units",
  credited_units: "credited_units",
  amount: "amount",
  meter_id: "meter_id",
  meter: "meter"
}.freeze
REQUIRED_KEYS =

Returns:

  • (Array[String])
["created_at", "modified_at", "id", "consumed_units", "credited_units", "amount", "meter_id", "meter"].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(created_at:, modified_at:, id:, consumed_units:, credited_units:, amount:, meter_id:, meter:) ⇒ SubscriptionMeter

Returns a new instance of SubscriptionMeter.

Parameters:

  • created_at: (String)
  • modified_at: (String, nil)
  • id: (String)
  • consumed_units: (Float)
  • credited_units: (Integer)
  • amount: (Integer)
  • meter_id: (String)
  • meter: (Models::Meter)


40834
40835
40836
40837
40838
40839
40840
40841
40842
40843
40844
40845
40846
40847
40848
40849
40850
40851
40852
40853
# File 'lib/pago/v2026_04/models.rb', line 40834

def initialize(
  created_at:,
  modified_at:,
  id:,
  consumed_units:,
  credited_units:,
  amount:,
  meter_id:,
  meter:
)
  super()
  assign(:created_at, created_at)
  assign(:modified_at, modified_at)
  assign(:id, id)
  assign(:consumed_units, consumed_units)
  assign(:credited_units, credited_units)
  assign(:amount, amount)
  assign(:meter_id, meter_id)
  assign(:meter, meter)
end

Instance Attribute Details

#amountInteger (readonly)

The amount due in cents so far in this billing period.

Returns:

  • (Integer)


40825
40826
40827
# File 'lib/pago/v2026_04/models.rb', line 40825

def amount
  @amount
end

#consumed_unitsFloat (readonly)

The number of consumed units so far in this billing period.

Returns:

  • (Float)


40817
40818
40819
# File 'lib/pago/v2026_04/models.rb', line 40817

def consumed_units
  @consumed_units
end

#created_atString (readonly)

Creation timestamp of the object.

Returns:

  • (String)


40805
40806
40807
# File 'lib/pago/v2026_04/models.rb', line 40805

def created_at
  @created_at
end

#credited_unitsInteger (readonly)

The number of credited units so far in this billing period.

Returns:

  • (Integer)


40821
40822
40823
# File 'lib/pago/v2026_04/models.rb', line 40821

def credited_units
  @credited_units
end

#idString (readonly)

The ID of the object.

Returns:

  • (String)


40813
40814
40815
# File 'lib/pago/v2026_04/models.rb', line 40813

def id
  @id
end

#meterModels::Meter (readonly)

Returns:



40832
40833
40834
# File 'lib/pago/v2026_04/models.rb', line 40832

def meter
  @meter
end

#meter_idString (readonly)

The ID of the meter.

Returns:

  • (String)


40829
40830
40831
# File 'lib/pago/v2026_04/models.rb', line 40829

def meter_id
  @meter_id
end

#modified_atString? (readonly)

Last modification timestamp of the object.

Returns:

  • (String, nil)


40809
40810
40811
# File 'lib/pago/v2026_04/models.rb', line 40809

def modified_at
  @modified_at
end

Class Method Details

.from_json(data) ⇒ SubscriptionMeter?

Parameters:

  • data (Hash, String, nil)

Returns:



40857
40858
40859
40860
40861
40862
40863
40864
40865
40866
40867
40868
40869
40870
40871
40872
40873
40874
40875
# File 'lib/pago/v2026_04/models.rb', line 40857

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(
      created_at: (data.key?("created_at") ? data["created_at"] : ::Pago::UNSET),
      modified_at: (data.key?("modified_at") ? data["modified_at"] : ::Pago::UNSET),
      id: (data.key?("id") ? data["id"] : ::Pago::UNSET),
      consumed_units: (data.key?("consumed_units") ? data["consumed_units"] : ::Pago::UNSET),
      credited_units: (data.key?("credited_units") ? data["credited_units"] : ::Pago::UNSET),
      amount: (data.key?("amount") ? data["amount"] : ::Pago::UNSET),
      meter_id: (data.key?("meter_id") ? data["meter_id"] : ::Pago::UNSET),
      meter: (data.key?("meter") ? Models::Meter.from_json(data["meter"]) : ::Pago::UNSET)
    ),
    data
  )
end