Class: Pago::V2026_04::Models::CustomerMeter

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

Overview

An active customer meter, with current consumed and credited units.

Constant Summary collapse

JSON_KEYS =

Returns:

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

Returns:

  • (Array[String])
["id", "created_at", "modified_at", "customer_id", "meter_id", "consumed_units", "credited_units", "balance", "customer", "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(id:, created_at:, modified_at:, customer_id:, meter_id:, consumed_units:, credited_units:, balance:, customer:, meter:) ⇒ CustomerMeter

Returns a new instance of CustomerMeter.

Parameters:

  • id: (String)
  • created_at: (String)
  • modified_at: (String, nil)
  • customer_id: (String)
  • meter_id: (String)
  • consumed_units: (Float)
  • credited_units: (Integer)
  • balance: (Float)
  • customer: (Object)
  • meter: (Models::Meter)


17197
17198
17199
17200
17201
17202
17203
17204
17205
17206
17207
17208
17209
17210
17211
17212
17213
17214
17215
17216
17217
17218
17219
17220
# File 'lib/pago/v2026_04/models.rb', line 17197

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

Instance Attribute Details

#balanceFloat (readonly)

The balance of the meter, i.e. the difference between credited and consumed units.

Returns:

  • (Float)


17189
17190
17191
# File 'lib/pago/v2026_04/models.rb', line 17189

def balance
  @balance
end

#consumed_unitsFloat (readonly)

The number of consumed units.

Returns:

  • (Float)


17181
17182
17183
# File 'lib/pago/v2026_04/models.rb', line 17181

def consumed_units
  @consumed_units
end

#created_atString (readonly)

Creation timestamp of the object.

Returns:

  • (String)


17165
17166
17167
# File 'lib/pago/v2026_04/models.rb', line 17165

def created_at
  @created_at
end

#credited_unitsInteger (readonly)

The number of credited units.

Returns:

  • (Integer)


17185
17186
17187
# File 'lib/pago/v2026_04/models.rb', line 17185

def credited_units
  @credited_units
end

#customerObject (readonly)

Returns:

  • (Object)


17192
17193
17194
# File 'lib/pago/v2026_04/models.rb', line 17192

def customer
  @customer
end

#customer_idString (readonly)

The ID of the customer.

Returns:

  • (String)


17173
17174
17175
# File 'lib/pago/v2026_04/models.rb', line 17173

def customer_id
  @customer_id
end

#idString (readonly)

The ID of the object.

Returns:

  • (String)


17161
17162
17163
# File 'lib/pago/v2026_04/models.rb', line 17161

def id
  @id
end

#meterModels::Meter (readonly)

Returns:



17195
17196
17197
# File 'lib/pago/v2026_04/models.rb', line 17195

def meter
  @meter
end

#meter_idString (readonly)

The ID of the meter.

Returns:

  • (String)


17177
17178
17179
# File 'lib/pago/v2026_04/models.rb', line 17177

def meter_id
  @meter_id
end

#modified_atString? (readonly)

Last modification timestamp of the object.

Returns:

  • (String, nil)


17169
17170
17171
# File 'lib/pago/v2026_04/models.rb', line 17169

def modified_at
  @modified_at
end

Class Method Details

.from_json(data) ⇒ CustomerMeter?

Parameters:

  • data (Hash, String, nil)

Returns:



17224
17225
17226
17227
17228
17229
17230
17231
17232
17233
17234
17235
17236
17237
17238
17239
17240
17241
17242
17243
17244
# File 'lib/pago/v2026_04/models.rb', line 17224

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),
      created_at: (data.key?("created_at") ? data["created_at"] : ::Pago::UNSET),
      modified_at: (data.key?("modified_at") ? data["modified_at"] : ::Pago::UNSET),
      customer_id: (data.key?("customer_id") ? data["customer_id"] : ::Pago::UNSET),
      meter_id: (data.key?("meter_id") ? data["meter_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),
      balance: (data.key?("balance") ? data["balance"] : ::Pago::UNSET),
      customer: (data.key?("customer") ? Unions::Customer.from_json(data["customer"]) : ::Pago::UNSET),
      meter: (data.key?("meter") ? Models::Meter.from_json(data["meter"]) : ::Pago::UNSET)
    ),
    data
  )
end