Class: ModernTreasury::Event
- Defined in:
- lib/modern_treasury/models/event.rb
Overview
Event Model.
Instance Attribute Summary collapse
-
#created_at ⇒ DateTime
This field will be true if this object exists in the live environment or false if it exists in the test environment.
-
#data ⇒ Object
The body of the event.
-
#entity_id ⇒ String
The ID of the entity for the event.
-
#event_name ⇒ String
The name of the event.
-
#event_time ⇒ DateTime
The time of the event.
-
#id ⇒ UUID | String
TODO: Write general description for this method.
-
#live_mode ⇒ TrueClass | FalseClass
This field will be true if this object exists in the live environment or false if it exists in the test environment.
-
#object ⇒ String
TODO: Write general description for this method.
-
#resource ⇒ String
The type of resource for the event.
-
#updated_at ⇒ DateTime
This field will be true if this object exists in the live environment or false if it exists in the test environment.
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:, object:, live_mode:, created_at:, updated_at:, resource:, event_name:, event_time:, data:, entity_id:) ⇒ Event
constructor
A new instance of Event.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
- #to_custom_created_at ⇒ Object
- #to_custom_event_time ⇒ Object
- #to_custom_updated_at ⇒ 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:, object:, live_mode:, created_at:, updated_at:, resource:, event_name:, event_time:, data:, entity_id:) ⇒ Event
Returns a new instance of Event.
82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/modern_treasury/models/event.rb', line 82 def initialize(id:, object:, live_mode:, created_at:, updated_at:, resource:, event_name:, event_time:, data:, entity_id:) @id = id @object = object @live_mode = live_mode @created_at = created_at @updated_at = updated_at @resource = resource @event_name = event_name @event_time = event_time @data = data @entity_id = entity_id end |
Instance Attribute Details
#created_at ⇒ DateTime
This field will be true if this object exists in the live environment or false if it exists in the test environment.
29 30 31 |
# File 'lib/modern_treasury/models/event.rb', line 29 def created_at @created_at end |
#data ⇒ Object
The body of the event.
50 51 52 |
# File 'lib/modern_treasury/models/event.rb', line 50 def data @data end |
#entity_id ⇒ String
The ID of the entity for the event.
54 55 56 |
# File 'lib/modern_treasury/models/event.rb', line 54 def entity_id @entity_id end |
#event_name ⇒ String
The name of the event.
42 43 44 |
# File 'lib/modern_treasury/models/event.rb', line 42 def event_name @event_name end |
#event_time ⇒ DateTime
The time of the event.
46 47 48 |
# File 'lib/modern_treasury/models/event.rb', line 46 def event_time @event_time end |
#id ⇒ UUID | String
TODO: Write general description for this method
15 16 17 |
# File 'lib/modern_treasury/models/event.rb', line 15 def id @id end |
#live_mode ⇒ TrueClass | FalseClass
This field will be true if this object exists in the live environment or false if it exists in the test environment.
24 25 26 |
# File 'lib/modern_treasury/models/event.rb', line 24 def live_mode @live_mode end |
#object ⇒ String
TODO: Write general description for this method
19 20 21 |
# File 'lib/modern_treasury/models/event.rb', line 19 def object @object end |
#resource ⇒ String
The type of resource for the event.
38 39 40 |
# File 'lib/modern_treasury/models/event.rb', line 38 def resource @resource end |
#updated_at ⇒ DateTime
This field will be true if this object exists in the live environment or false if it exists in the test environment.
34 35 36 |
# File 'lib/modern_treasury/models/event.rb', line 34 def updated_at @updated_at end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
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 125 126 127 128 129 |
# File 'lib/modern_treasury/models/event.rb', line 97 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. id = hash.key?('id') ? hash['id'] : nil object = hash.key?('object') ? hash['object'] : nil live_mode = hash.key?('live_mode') ? hash['live_mode'] : nil created_at = if hash.key?('created_at') (DateTimeHelper.from_rfc3339(hash['created_at']) if hash['created_at']) end updated_at = if hash.key?('updated_at') (DateTimeHelper.from_rfc3339(hash['updated_at']) if hash['updated_at']) end resource = hash.key?('resource') ? hash['resource'] : nil event_name = hash.key?('event_name') ? hash['event_name'] : nil event_time = if hash.key?('event_time') (DateTimeHelper.from_rfc3339(hash['event_time']) if hash['event_time']) end data = hash.key?('data') ? hash['data'] : nil entity_id = hash.key?('entity_id') ? hash['entity_id'] : nil # Create object from extracted values. Event.new(id: id, object: object, live_mode: live_mode, created_at: created_at, updated_at: updated_at, resource: resource, event_name: event_name, event_time: event_time, data: data, entity_id: entity_id) end |
.names ⇒ Object
A mapping from model property names to API property names.
57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/modern_treasury/models/event.rb', line 57 def self.names @_hash = {} if @_hash.nil? @_hash['id'] = 'id' @_hash['object'] = 'object' @_hash['live_mode'] = 'live_mode' @_hash['created_at'] = 'created_at' @_hash['updated_at'] = 'updated_at' @_hash['resource'] = 'resource' @_hash['event_name'] = 'event_name' @_hash['event_time'] = 'event_time' @_hash['data'] = 'data' @_hash['entity_id'] = 'entity_id' @_hash end |
.nullables ⇒ Object
An array for nullable fields
78 79 80 |
# File 'lib/modern_treasury/models/event.rb', line 78 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
73 74 75 |
# File 'lib/modern_treasury/models/event.rb', line 73 def self.optionals [] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
152 153 154 155 156 157 158 159 |
# File 'lib/modern_treasury/models/event.rb', line 152 def inspect class_name = self.class.name.split('::').last "<#{class_name} id: #{@id.inspect}, object: #{@object.inspect}, live_mode:"\ " #{@live_mode.inspect}, created_at: #{@created_at.inspect}, updated_at:"\ " #{@updated_at.inspect}, resource: #{@resource.inspect}, event_name:"\ " #{@event_name.inspect}, event_time: #{@event_time.inspect}, data: #{@data.inspect},"\ " entity_id: #{@entity_id.inspect}>" end |
#to_custom_created_at ⇒ Object
131 132 133 |
# File 'lib/modern_treasury/models/event.rb', line 131 def to_custom_created_at DateTimeHelper.to_rfc3339(created_at) end |
#to_custom_event_time ⇒ Object
139 140 141 |
# File 'lib/modern_treasury/models/event.rb', line 139 def to_custom_event_time DateTimeHelper.to_rfc3339(event_time) end |
#to_custom_updated_at ⇒ Object
135 136 137 |
# File 'lib/modern_treasury/models/event.rb', line 135 def to_custom_updated_at DateTimeHelper.to_rfc3339(updated_at) end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
144 145 146 147 148 149 |
# File 'lib/modern_treasury/models/event.rb', line 144 def to_s class_name = self.class.name.split('::').last "<#{class_name} id: #{@id}, object: #{@object}, live_mode: #{@live_mode}, created_at:"\ " #{@created_at}, updated_at: #{@updated_at}, resource: #{@resource}, event_name:"\ " #{@event_name}, event_time: #{@event_time}, data: #{@data}, entity_id: #{@entity_id}>" end |