Class: Pago::V2026_04::Models::MeterUpdate

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",
  name: "name",
  unit: "unit",
  custom_label: "custom_label",
  custom_multiplier: "custom_multiplier",
  filter: "filter",
  aggregation: "aggregation",
  is_archived: "is_archived"
}.freeze
REQUIRED_KEYS =

Returns:

  • (Array[String])
[].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: ::Pago::UNSET, name: ::Pago::UNSET, unit: ::Pago::UNSET, custom_label: ::Pago::UNSET, custom_multiplier: ::Pago::UNSET, filter: ::Pago::UNSET, aggregation: ::Pago::UNSET, is_archived: ::Pago::UNSET) ⇒ MeterUpdate

Returns a new instance of MeterUpdate.

Parameters:

  • metadata: (Hash[String, untyped], nil) (defaults to: ::Pago::UNSET)
  • name: (String, nil) (defaults to: ::Pago::UNSET)
  • unit: (String, nil) (defaults to: ::Pago::UNSET)
  • custom_label: (String, nil) (defaults to: ::Pago::UNSET)
  • custom_multiplier: (Integer, nil) (defaults to: ::Pago::UNSET)
  • filter: (Models::Filter, nil) (defaults to: ::Pago::UNSET)
  • aggregation: (Object) (defaults to: ::Pago::UNSET)
  • is_archived: (Boolean, nil) (defaults to: ::Pago::UNSET)


29708
29709
29710
29711
29712
29713
29714
29715
29716
29717
29718
29719
29720
29721
29722
29723
29724
29725
29726
29727
# File 'lib/pago/v2026_04/models.rb', line 29708

def initialize(
  metadata: ::Pago::UNSET,
  name: ::Pago::UNSET,
  unit: ::Pago::UNSET,
  custom_label: ::Pago::UNSET,
  custom_multiplier: ::Pago::UNSET,
  filter: ::Pago::UNSET,
  aggregation: ::Pago::UNSET,
  is_archived: ::Pago::UNSET
)
  super()
  assign(:metadata, )
  assign(:name, name)
  assign(:unit, unit)
  assign(:custom_label, custom_label)
  assign(:custom_multiplier, custom_multiplier)
  assign(:filter, filter)
  assign(:aggregation, aggregation)
  assign(:is_archived, is_archived)
end

Instance Attribute Details

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

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



29702
29703
29704
# File 'lib/pago/v2026_04/models.rb', line 29702

def aggregation
  @aggregation
end

#custom_labelString? (readonly)

The label for the custom unit. Required when unit is 'custom'.

Returns:

  • (String, nil)


29690
29691
29692
# File 'lib/pago/v2026_04/models.rb', line 29690

def custom_label
  @custom_label
end

#custom_multiplierInteger? (readonly)

The multiplier to convert from base unit to display scale. Required when unit is 'custom'.

Returns:

  • (Integer, nil)


29694
29695
29696
# File 'lib/pago/v2026_04/models.rb', line 29694

def custom_multiplier
  @custom_multiplier
end

#filterModels::Filter? (readonly)

The filter to apply on events that'll be used to calculate the meter.

Returns:



29698
29699
29700
# File 'lib/pago/v2026_04/models.rb', line 29698

def filter
  @filter
end

#is_archivedBoolean? (readonly)

Whether the meter is archived. Archived meters are no longer used for billing.

Returns:

  • (Boolean, nil)


29706
29707
29708
# File 'lib/pago/v2026_04/models.rb', line 29706

def is_archived
  @is_archived
end

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

Key-value object allowing you to store additional information.

The key must be a string with a maximum length of 40 characters. The value must be either:

  • A string with a maximum length of 500 characters
  • An integer
  • A floating-point number
  • A boolean

You can store up to 50 key-value pairs.

Returns:

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


29678
29679
29680
# File 'lib/pago/v2026_04/models.rb', line 29678

def 
  @metadata
end

#nameString? (readonly)

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

Returns:

  • (String, nil)


29682
29683
29684
# File 'lib/pago/v2026_04/models.rb', line 29682

def name
  @name
end

#unitString? (readonly)

The unit of the meter.

Returns:

  • (String, nil)


29686
29687
29688
# File 'lib/pago/v2026_04/models.rb', line 29686

def unit
  @unit
end

Class Method Details

.from_json(data) ⇒ MeterUpdate?

Parameters:

  • data (Hash, String, nil)

Returns:



29731
29732
29733
29734
29735
29736
29737
29738
29739
29740
29741
29742
29743
29744
29745
29746
29747
29748
29749
# File 'lib/pago/v2026_04/models.rb', line 29731

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),
      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),
      is_archived: (data.key?("is_archived") ? data["is_archived"] : ::Pago::UNSET)
    ),
    data
  )
end