Class: Pago::V2026_04::Models::MeterCreate

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",
  organization_id: "organization_id"
}.freeze
REQUIRED_KEYS =

Returns:

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

Returns a new instance of MeterCreate.

Parameters:

  • metadata: (Hash[String, untyped], nil) (defaults to: ::Pago::UNSET)
  • name: (String)
  • 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)
  • aggregation: (Object)
  • organization_id: (String, nil) (defaults to: ::Pago::UNSET)


29176
29177
29178
29179
29180
29181
29182
29183
29184
29185
29186
29187
29188
29189
29190
29191
29192
29193
29194
29195
# File 'lib/pago/v2026_04/models.rb', line 29176

def initialize(
  metadata: ::Pago::UNSET,
  name:,
  unit: ::Pago::UNSET,
  custom_label: ::Pago::UNSET,
  custom_multiplier: ::Pago::UNSET,
  filter:,
  aggregation:,
  organization_id: ::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(:organization_id, organization_id)
end

Instance Attribute Details

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

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



29170
29171
29172
# File 'lib/pago/v2026_04/models.rb', line 29170

def aggregation
  @aggregation
end

#custom_labelString? (readonly)

The label for the custom unit, e.g. 'request'. Required when unit is 'custom'.

Returns:

  • (String, nil)


29159
29160
29161
# File 'lib/pago/v2026_04/models.rb', line 29159

def custom_label
  @custom_label
end

#custom_multiplierInteger? (readonly)

The multiplier to convert from the base unit to display scale, e.g. 1000 to display per 1000 units. Defaults to 1 when not provided.

Returns:

  • (Integer, nil)


29163
29164
29165
# File 'lib/pago/v2026_04/models.rb', line 29163

def custom_multiplier
  @custom_multiplier
end

#filterModels::Filter (readonly)

Returns:



29166
29167
29168
# File 'lib/pago/v2026_04/models.rb', line 29166

def filter
  @filter
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})


29148
29149
29150
# File 'lib/pago/v2026_04/models.rb', line 29148

def 
  @metadata
end

#nameString (readonly)

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

Returns:

  • (String)


29152
29153
29154
# File 'lib/pago/v2026_04/models.rb', line 29152

def name
  @name
end

#organization_idString? (readonly)

The ID of the organization owning the meter. Required unless you use an organization token.

Returns:

  • (String, nil)


29174
29175
29176
# File 'lib/pago/v2026_04/models.rb', line 29174

def organization_id
  @organization_id
end

#unitString (readonly)

Returns:

  • (String)


29155
29156
29157
# File 'lib/pago/v2026_04/models.rb', line 29155

def unit
  @unit
end

Class Method Details

.from_json(data) ⇒ MeterCreate?

Parameters:

  • data (Hash, String, nil)

Returns:



29199
29200
29201
29202
29203
29204
29205
29206
29207
29208
29209
29210
29211
29212
29213
29214
29215
29216
29217
# File 'lib/pago/v2026_04/models.rb', line 29199

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