Class: Pago::V2026_04::Models::MeterCreate
- Defined in:
- lib/pago/v2026_04/models.rb,
sig/pago/v2026_04/generated.rbs
Constant Summary collapse
- JSON_KEYS =
{ 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 =
["name", "filter", "aggregation"].freeze
Instance Attribute Summary collapse
-
#aggregation ⇒ Models::CountAggregation, ...
readonly
The aggregation to apply on the filtered events to calculate the meter.
-
#custom_label ⇒ String?
readonly
The label for the custom unit, e.g.
-
#custom_multiplier ⇒ Integer?
readonly
The multiplier to convert from the base unit to display scale, e.g.
- #filter ⇒ Models::Filter readonly
-
#metadata ⇒ Hash{String => String, Integer, Float, Boolean}
readonly
Key-value object allowing you to store additional information.
-
#name ⇒ String
readonly
The name of the meter.
-
#organization_id ⇒ String?
readonly
The ID of the organization owning the meter.
- #unit ⇒ String readonly
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(metadata: ::Pago::UNSET, name:, unit: ::Pago::UNSET, custom_label: ::Pago::UNSET, custom_multiplier: ::Pago::UNSET, filter:, aggregation:, organization_id: ::Pago::UNSET) ⇒ MeterCreate
constructor
A new instance of MeterCreate.
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.
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
#aggregation ⇒ Models::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_label ⇒ String? (readonly)
The label for the custom unit, e.g. 'request'. Required when unit is 'custom'.
29159 29160 29161 |
# File 'lib/pago/v2026_04/models.rb', line 29159 def custom_label @custom_label end |
#custom_multiplier ⇒ Integer? (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.
29163 29164 29165 |
# File 'lib/pago/v2026_04/models.rb', line 29163 def custom_multiplier @custom_multiplier end |
#filter ⇒ Models::Filter (readonly)
29166 29167 29168 |
# File 'lib/pago/v2026_04/models.rb', line 29166 def filter @filter end |
#metadata ⇒ Hash{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.
29148 29149 29150 |
# File 'lib/pago/v2026_04/models.rb', line 29148 def @metadata end |
#name ⇒ String (readonly)
The name of the meter. Will be shown on customer's invoices and usage.
29152 29153 29154 |
# File 'lib/pago/v2026_04/models.rb', line 29152 def name @name end |
#organization_id ⇒ String? (readonly)
The ID of the organization owning the meter. Required unless you use an organization token.
29174 29175 29176 |
# File 'lib/pago/v2026_04/models.rb', line 29174 def organization_id @organization_id end |
#unit ⇒ String (readonly)
29155 29156 29157 |
# File 'lib/pago/v2026_04/models.rb', line 29155 def unit @unit end |
Class Method Details
.from_json(data) ⇒ MeterCreate?
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 |