Class: Pago::V2026_04::Models::Meter

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

Constant Summary collapse

JSON_KEYS =

Returns:

  • (Hash[Symbol, String])
{
  metadata: "metadata",
  created_at: "created_at",
  modified_at: "modified_at",
  id: "id",
  name: "name",
  unit: "unit",
  custom_label: "custom_label",
  custom_multiplier: "custom_multiplier",
  filter: "filter",
  aggregation: "aggregation",
  organization_id: "organization_id",
  archived_at: "archived_at"
}.freeze
REQUIRED_KEYS =

Returns:

  • (Array[String])
["metadata", "created_at", "modified_at", "id", "name", "unit", "filter", "aggregation", "organization_id"].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(metadata:, created_at:, modified_at:, id:, name:, unit:, custom_label: ::Pago::UNSET, custom_multiplier: ::Pago::UNSET, filter:, aggregation:, organization_id:, archived_at: ::Pago::UNSET) ⇒ Meter

Returns a new instance of Meter.

Parameters:

  • metadata: (Hash[String, untyped])
  • created_at: (String)
  • modified_at: (String, nil)
  • id: (String)
  • name: (String)
  • unit: (String)
  • custom_label: (String, nil) (defaults to: ::Pago::UNSET)
  • custom_multiplier: (Integer, nil) (defaults to: ::Pago::UNSET)
  • filter: (Models::Filter)
  • aggregation: (Object)
  • organization_id: (String)
  • archived_at: (String, nil) (defaults to: ::Pago::UNSET)


29067
29068
29069
29070
29071
29072
29073
29074
29075
29076
29077
29078
29079
29080
29081
29082
29083
29084
29085
29086
29087
29088
29089
29090
29091
29092
29093
29094
# File 'lib/pago/v2026_04/models.rb', line 29067

def initialize(
  metadata:,
  created_at:,
  modified_at:,
  id:,
  name:,
  unit:,
  custom_label: ::Pago::UNSET,
  custom_multiplier: ::Pago::UNSET,
  filter:,
  aggregation:,
  organization_id:,
  archived_at: ::Pago::UNSET
)
  super()
  assign(:metadata, )
  assign(:created_at, created_at)
  assign(:modified_at, modified_at)
  assign(:id, id)
  assign(:name, name)
  assign(:unit, unit)
  assign(:custom_label, custom_label)
  assign(:custom_multiplier, custom_multiplier)
  assign(:filter, filter)
  assign(:aggregation, aggregation)
  assign(:organization_id, organization_id)
  assign(:archived_at, archived_at)
end

Instance Attribute Details

#aggregationModels::CountAggregation, ... (readonly)

The aggregation to apply on the filtered events to calculate the meter.



29057
29058
29059
# File 'lib/pago/v2026_04/models.rb', line 29057

def aggregation
  @aggregation
end

#archived_atString? (readonly)

Whether the meter is archived and the time it was archived.

Returns:

  • (String, nil)


29065
29066
29067
# File 'lib/pago/v2026_04/models.rb', line 29065

def archived_at
  @archived_at
end

#created_atString (readonly)

Creation timestamp of the object.

Returns:

  • (String)


29027
29028
29029
# File 'lib/pago/v2026_04/models.rb', line 29027

def created_at
  @created_at
end

#custom_labelString? (readonly)

The label for the custom unit.

Returns:

  • (String, nil)


29046
29047
29048
# File 'lib/pago/v2026_04/models.rb', line 29046

def custom_label
  @custom_label
end

#custom_multiplierInteger? (readonly)

The multiplier to convert from base unit to display scale.

Returns:

  • (Integer, nil)


29050
29051
29052
# File 'lib/pago/v2026_04/models.rb', line 29050

def custom_multiplier
  @custom_multiplier
end

#filterModels::Filter (readonly)

Returns:



29053
29054
29055
# File 'lib/pago/v2026_04/models.rb', line 29053

def filter
  @filter
end

#idString (readonly)

The ID of the object.

Returns:

  • (String)


29035
29036
29037
# File 'lib/pago/v2026_04/models.rb', line 29035

def id
  @id
end

#metadataHash{String => String, Integer, Float, Boolean} (readonly)

Returns:

  • (Hash{String => String, Integer, Float, Boolean})


29023
29024
29025
# File 'lib/pago/v2026_04/models.rb', line 29023

def 
  @metadata
end

#modified_atString? (readonly)

Last modification timestamp of the object.

Returns:

  • (String, nil)


29031
29032
29033
# File 'lib/pago/v2026_04/models.rb', line 29031

def modified_at
  @modified_at
end

#nameString (readonly)

The name of the meter. Will be shown on customer's invoices and usage.

Returns:

  • (String)


29039
29040
29041
# File 'lib/pago/v2026_04/models.rb', line 29039

def name
  @name
end

#organization_idString (readonly)

The ID of the organization owning the meter.

Returns:

  • (String)


29061
29062
29063
# File 'lib/pago/v2026_04/models.rb', line 29061

def organization_id
  @organization_id
end

#unitString (readonly)

Returns:

  • (String)


29042
29043
29044
# File 'lib/pago/v2026_04/models.rb', line 29042

def unit
  @unit
end

Class Method Details

.from_json(data) ⇒ Meter?

Parameters:

  • data (Hash, String, nil)

Returns:



29098
29099
29100
29101
29102
29103
29104
29105
29106
29107
29108
29109
29110
29111
29112
29113
29114
29115
29116
29117
29118
29119
29120
# File 'lib/pago/v2026_04/models.rb', line 29098

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(
      metadata: (data.key?("metadata") ? data["metadata"] : ::Pago::UNSET),
      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),
      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),
      filter: (data.key?("filter") ? Models::Filter.from_json(data["filter"]) : ::Pago::UNSET),
      aggregation: (data.key?("aggregation") ? ::Pago::Serde.union(data["aggregation"], discriminator: "func", mapping: { "avg" => Models::PropertyAggregation, "count" => Models::CountAggregation, "max" => Models::PropertyAggregation, "min" => Models::PropertyAggregation, "sum" => Models::PropertyAggregation, "unique" => Models::UniqueAggregation }, variants: [Models::CountAggregation, Models::PropertyAggregation, Models::UniqueAggregation]) : ::Pago::UNSET),
      organization_id: (data.key?("organization_id") ? data["organization_id"] : ::Pago::UNSET),
      archived_at: (data.key?("archived_at") ? data["archived_at"] : ::Pago::UNSET)
    ),
    data
  )
end