Class: ApiReference::BillableMetric
- Defined in:
- lib/api_reference/models/billable_metric.rb
Overview
The Metric resource represents a calculation of a quantity based on events. Metrics are defined by the query that transforms raw usage events into meaningful values for your customers.
Instance Attribute Summary collapse
-
#description ⇒ String
User specified key-value pairs for the resource.
-
#id ⇒ String
User specified key-value pairs for the resource.
-
#item ⇒ Item
The Item resource represents a sellable product or good.
-
#metadata ⇒ Hash[String, String]
User specified key-value pairs for the resource.
-
#name ⇒ String
User specified key-value pairs for the resource.
-
#parameter_definitions ⇒ Array[Object]
The Item resource represents a sellable product or good.
-
#status ⇒ Status
User specified key-value pairs for the resource.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
Instance Method Summary collapse
-
#initialize(metadata:, id:, name:, description:, status:, item:, parameter_definitions: SKIP, additional_properties: nil) ⇒ BillableMetric
constructor
A new instance of BillableMetric.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
Methods inherited from BaseModel
#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json
Constructor Details
#initialize(metadata:, id:, name:, description:, status:, item:, parameter_definitions: SKIP, additional_properties: nil) ⇒ BillableMetric
Returns a new instance of BillableMetric.
91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/api_reference/models/billable_metric.rb', line 91 def initialize(metadata:, id:, name:, description:, status:, item:, parameter_definitions: SKIP, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @metadata = @id = id @name = name @description = description @status = status @item = item @parameter_definitions = parameter_definitions unless parameter_definitions == SKIP @additional_properties = additional_properties end |
Instance Attribute Details
#description ⇒ String
User specified key-value pairs for the resource. If not present, this
defaults to an empty dictionary. Individual keys can be removed by setting
the value to null, and the entire metadata mapping can be cleared by
setting metadata to null.
40 41 42 |
# File 'lib/api_reference/models/billable_metric.rb', line 40 def description @description end |
#id ⇒ String
User specified key-value pairs for the resource. If not present, this
defaults to an empty dictionary. Individual keys can be removed by setting
the value to null, and the entire metadata mapping can be cleared by
setting metadata to null.
26 27 28 |
# File 'lib/api_reference/models/billable_metric.rb', line 26 def id @id end |
#item ⇒ Item
The Item resource represents a sellable product or good. Items are associated with all line items, billable metrics, and prices and are used for defining external sync behavior for invoices and tax calculation purposes.
54 55 56 |
# File 'lib/api_reference/models/billable_metric.rb', line 54 def item @item end |
#metadata ⇒ Hash[String, String]
User specified key-value pairs for the resource. If not present, this
defaults to an empty dictionary. Individual keys can be removed by setting
the value to null, and the entire metadata mapping can be cleared by
setting metadata to null.
19 20 21 |
# File 'lib/api_reference/models/billable_metric.rb', line 19 def @metadata end |
#name ⇒ String
User specified key-value pairs for the resource. If not present, this
defaults to an empty dictionary. Individual keys can be removed by setting
the value to null, and the entire metadata mapping can be cleared by
setting metadata to null.
33 34 35 |
# File 'lib/api_reference/models/billable_metric.rb', line 33 def name @name end |
#parameter_definitions ⇒ Array[Object]
The Item resource represents a sellable product or good. Items are associated with all line items, billable metrics, and prices and are used for defining external sync behavior for invoices and tax calculation purposes.
61 62 63 |
# File 'lib/api_reference/models/billable_metric.rb', line 61 def parameter_definitions @parameter_definitions end |
#status ⇒ Status
User specified key-value pairs for the resource. If not present, this
defaults to an empty dictionary. Individual keys can be removed by setting
the value to null, and the entire metadata mapping can be cleared by
setting metadata to null.
47 48 49 |
# File 'lib/api_reference/models/billable_metric.rb', line 47 def status @status end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/api_reference/models/billable_metric.rb', line 107 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. = hash.key?('metadata') ? hash['metadata'] : nil id = hash.key?('id') ? hash['id'] : nil name = hash.key?('name') ? hash['name'] : nil description = hash.key?('description') ? hash['description'] : nil status = hash.key?('status') ? hash['status'] : nil item = Item.from_hash(hash['item']) if hash['item'] parameter_definitions = hash.key?('parameter_definitions') ? hash['parameter_definitions'] : SKIP # Create a new hash for additional properties, removing known properties. new_hash = hash.reject { |k, _| names.value?(k) } additional_properties = APIHelper.get_additional_properties( new_hash, proc { |value| value } ) # Create object from extracted values. BillableMetric.new(metadata: , id: id, name: name, description: description, status: status, item: item, parameter_definitions: parameter_definitions, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/api_reference/models/billable_metric.rb', line 64 def self.names @_hash = {} if @_hash.nil? @_hash['metadata'] = 'metadata' @_hash['id'] = 'id' @_hash['name'] = 'name' @_hash['description'] = 'description' @_hash['status'] = 'status' @_hash['item'] = 'item' @_hash['parameter_definitions'] = 'parameter_definitions' @_hash end |
.nullables ⇒ Object
An array for nullable fields
84 85 86 87 88 89 |
# File 'lib/api_reference/models/billable_metric.rb', line 84 def self.nullables %w[ description parameter_definitions ] end |
.optionals ⇒ Object
An array for optional fields
77 78 79 80 81 |
# File 'lib/api_reference/models/billable_metric.rb', line 77 def self.optionals %w[ parameter_definitions ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
147 148 149 150 151 152 153 |
# File 'lib/api_reference/models/billable_metric.rb', line 147 def inspect class_name = self.class.name.split('::').last "<#{class_name} metadata: #{@metadata.inspect}, id: #{@id.inspect}, name: #{@name.inspect},"\ " description: #{@description.inspect}, status: #{@status.inspect}, item: #{@item.inspect},"\ " parameter_definitions: #{@parameter_definitions.inspect}, additional_properties:"\ " #{@additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
139 140 141 142 143 144 |
# File 'lib/api_reference/models/billable_metric.rb', line 139 def to_s class_name = self.class.name.split('::').last "<#{class_name} metadata: #{@metadata}, id: #{@id}, name: #{@name}, description:"\ " #{@description}, status: #{@status}, item: #{@item}, parameter_definitions:"\ " #{@parameter_definitions}, additional_properties: #{@additional_properties}>" end |