Class: ApiReference::Event
- Defined in:
- lib/api_reference/models/event.rb
Overview
The Event resource represents a usage event that has been created for a customer. Events are the core of Orb's usage-based billing model, and are used to calculate the usage charges for a given billing period.
Instance Attribute Summary collapse
-
#customer_id ⇒ String
The Orb Customer identifier.
-
#deprecated ⇒ TrueClass | FalseClass
A boolean indicating whether the event is currently deprecated.
-
#event_name ⇒ String
A name to meaningfully identify the action or event type.
-
#external_customer_id ⇒ String
An alias for the Orb customer, whose mapping is specified when creating the customer.
-
#id ⇒ String
A unique value, generated by the client, that is used to de-duplicate events.
-
#properties ⇒ Object
A dictionary of custom properties.
-
#timestamp ⇒ DateTime
An ISO 8601 format date with no timezone offset (i.e. UTC).
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(id:, customer_id:, external_customer_id:, event_name:, properties:, timestamp:, deprecated:, additional_properties: nil) ⇒ Event
constructor
A new instance of Event.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
- #to_custom_timestamp ⇒ Object
-
#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(id:, customer_id:, external_customer_id:, event_name:, properties:, timestamp:, deprecated:, additional_properties: nil) ⇒ Event
Returns a new instance of Event.
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/api_reference/models/event.rb', line 76 def initialize(id:, customer_id:, external_customer_id:, event_name:, properties:, timestamp:, deprecated:, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @id = id @customer_id = customer_id @external_customer_id = external_customer_id @event_name = event_name @properties = properties @timestamp = @deprecated = deprecated @additional_properties = additional_properties end |
Instance Attribute Details
#customer_id ⇒ String
The Orb Customer identifier
24 25 26 |
# File 'lib/api_reference/models/event.rb', line 24 def customer_id @customer_id end |
#deprecated ⇒ TrueClass | FalseClass
A boolean indicating whether the event is currently deprecated.
48 49 50 |
# File 'lib/api_reference/models/event.rb', line 48 def deprecated @deprecated end |
#event_name ⇒ String
A name to meaningfully identify the action or event type.
33 34 35 |
# File 'lib/api_reference/models/event.rb', line 33 def event_name @event_name end |
#external_customer_id ⇒ String
An alias for the Orb customer, whose mapping is specified when creating the customer
29 30 31 |
# File 'lib/api_reference/models/event.rb', line 29 def external_customer_id @external_customer_id end |
#id ⇒ String
A unique value, generated by the client, that is used to de-duplicate events. Exactly one event with a given idempotency key will be ingested, which allows for safe request retries.
20 21 22 |
# File 'lib/api_reference/models/event.rb', line 20 def id @id end |
#properties ⇒ Object
A dictionary of custom properties. Values in this dictionary must be numeric, boolean, or strings. Nested dictionaries are disallowed.
38 39 40 |
# File 'lib/api_reference/models/event.rb', line 38 def properties @properties end |
#timestamp ⇒ DateTime
An ISO 8601 format date with no timezone offset (i.e. UTC). This should represent the time that usage was recorded, and is particularly important to attribute usage to a given billing period.
44 45 46 |
# File 'lib/api_reference/models/event.rb', line 44 def @timestamp end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/api_reference/models/event.rb', line 93 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. id = hash.key?('id') ? hash['id'] : nil customer_id = hash.key?('customer_id') ? hash['customer_id'] : nil external_customer_id = hash.key?('external_customer_id') ? hash['external_customer_id'] : nil event_name = hash.key?('event_name') ? hash['event_name'] : nil properties = hash.key?('properties') ? hash['properties'] : nil = if hash.key?('timestamp') (DateTimeHelper.from_rfc3339(hash['timestamp']) if hash['timestamp']) end deprecated = hash.key?('deprecated') ? hash['deprecated'] : nil # 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. Event.new(id: id, customer_id: customer_id, external_customer_id: external_customer_id, event_name: event_name, properties: properties, timestamp: , deprecated: deprecated, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/api_reference/models/event.rb', line 51 def self.names @_hash = {} if @_hash.nil? @_hash['id'] = 'id' @_hash['customer_id'] = 'customer_id' @_hash['external_customer_id'] = 'external_customer_id' @_hash['event_name'] = 'event_name' @_hash['properties'] = 'properties' @_hash['timestamp'] = 'timestamp' @_hash['deprecated'] = 'deprecated' @_hash end |
.nullables ⇒ Object
An array for nullable fields
69 70 71 72 73 74 |
# File 'lib/api_reference/models/event.rb', line 69 def self.nullables %w[ customer_id external_customer_id ] end |
.optionals ⇒ Object
An array for optional fields
64 65 66 |
# File 'lib/api_reference/models/event.rb', line 64 def self.optionals [] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
140 141 142 143 144 145 146 147 |
# File 'lib/api_reference/models/event.rb', line 140 def inspect class_name = self.class.name.split('::').last "<#{class_name} id: #{@id.inspect}, customer_id: #{@customer_id.inspect},"\ " external_customer_id: #{@external_customer_id.inspect}, event_name:"\ " #{@event_name.inspect}, properties: #{@properties.inspect}, timestamp:"\ " #{@timestamp.inspect}, deprecated: #{@deprecated.inspect}, additional_properties:"\ " #{@additional_properties}>" end |
#to_custom_timestamp ⇒ Object
126 127 128 |
# File 'lib/api_reference/models/event.rb', line 126 def DateTimeHelper.to_rfc3339() end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
131 132 133 134 135 136 137 |
# File 'lib/api_reference/models/event.rb', line 131 def to_s class_name = self.class.name.split('::').last "<#{class_name} id: #{@id}, customer_id: #{@customer_id}, external_customer_id:"\ " #{@external_customer_id}, event_name: #{@event_name}, properties: #{@properties},"\ " timestamp: #{@timestamp}, deprecated: #{@deprecated}, additional_properties:"\ " #{@additional_properties}>" end |