Class: AdvancedBilling::Event
- Defined in:
- lib/advanced_billing/models/event.rb
Overview
Event Model.
Instance Attribute Summary collapse
-
#created_at ⇒ DateTime
TODO: Write general description for this method.
-
#customer_id ⇒ Integer
TODO: Write general description for this method.
-
#event_specific_data ⇒ Object
TODO: Write general description for this method.
-
#id ⇒ Integer
TODO: Write general description for this method.
-
#key ⇒ String
TODO: Write general description for this method.
-
#message ⇒ String
TODO: Write general description for this method.
-
#subscription_id ⇒ Integer
TODO: Write general description for this method.
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.
-
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
Instance Method Summary collapse
-
#initialize(id:, key:, message:, subscription_id:, customer_id:, created_at:, event_specific_data:, additional_properties: {}) ⇒ Event
constructor
A new instance of Event.
- #to_custom_created_at ⇒ Object
Methods inherited from BaseModel
Constructor Details
#initialize(id:, key:, message:, subscription_id:, customer_id:, created_at:, event_specific_data:, additional_properties: {}) ⇒ Event
Returns a new instance of Event.
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/advanced_billing/models/event.rb', line 68 def initialize(id:, key:, message:, subscription_id:, customer_id:, created_at:, event_specific_data:, additional_properties: {}) @id = id @key = key @message = @subscription_id = subscription_id @customer_id = customer_id @created_at = created_at @event_specific_data = event_specific_data # Add additional model properties to the instance. additional_properties.each do |_name, _value| instance_variable_set("@#{_name}", _value) end end |
Instance Attribute Details
#created_at ⇒ DateTime
TODO: Write general description for this method
35 36 37 |
# File 'lib/advanced_billing/models/event.rb', line 35 def created_at @created_at end |
#customer_id ⇒ Integer
TODO: Write general description for this method
31 32 33 |
# File 'lib/advanced_billing/models/event.rb', line 31 def customer_id @customer_id end |
#event_specific_data ⇒ Object
TODO: Write general description for this method
39 40 41 |
# File 'lib/advanced_billing/models/event.rb', line 39 def event_specific_data @event_specific_data end |
#id ⇒ Integer
TODO: Write general description for this method
15 16 17 |
# File 'lib/advanced_billing/models/event.rb', line 15 def id @id end |
#key ⇒ String
TODO: Write general description for this method
19 20 21 |
# File 'lib/advanced_billing/models/event.rb', line 19 def key @key end |
#message ⇒ String
TODO: Write general description for this method
23 24 25 |
# File 'lib/advanced_billing/models/event.rb', line 23 def @message end |
#subscription_id ⇒ Integer
TODO: Write general description for this method
27 28 29 |
# File 'lib/advanced_billing/models/event.rb', line 27 def subscription_id @subscription_id end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/advanced_billing/models/event.rb', line 85 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. id = hash.key?('id') ? hash['id'] : nil key = hash.key?('key') ? hash['key'] : nil = hash.key?('message') ? hash['message'] : nil subscription_id = hash.key?('subscription_id') ? hash['subscription_id'] : nil customer_id = hash.key?('customer_id') ? hash['customer_id'] : nil created_at = if hash.key?('created_at') (DateTimeHelper.from_rfc3339(hash['created_at']) if hash['created_at']) end event_specific_data = hash.key?('event_specific_data') ? APIHelper.deserialize_union_type( UnionTypeLookUp.get(:EventEventSpecificData), hash['event_specific_data'] ) : nil # Clean out expected properties from Hash. names.each_value { |k| hash.delete(k) } # Create object from extracted values. Event.new(id: id, key: key, message: , subscription_id: subscription_id, customer_id: customer_id, created_at: created_at, event_specific_data: event_specific_data, additional_properties: hash) end |
.names ⇒ Object
A mapping from model property names to API property names.
42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/advanced_billing/models/event.rb', line 42 def self.names @_hash = {} if @_hash.nil? @_hash['id'] = 'id' @_hash['key'] = 'key' @_hash['message'] = 'message' @_hash['subscription_id'] = 'subscription_id' @_hash['customer_id'] = 'customer_id' @_hash['created_at'] = 'created_at' @_hash['event_specific_data'] = 'event_specific_data' @_hash end |
.nullables ⇒ Object
An array for nullable fields
60 61 62 63 64 65 66 |
# File 'lib/advanced_billing/models/event.rb', line 60 def self.nullables %w[ subscription_id customer_id event_specific_data ] end |
.optionals ⇒ Object
An array for optional fields
55 56 57 |
# File 'lib/advanced_billing/models/event.rb', line 55 def self.optionals [] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
# File 'lib/advanced_billing/models/event.rb', line 122 def self.validate(value) if value.instance_of? self return ( APIHelper.valid_type?(value.id, ->(val) { val.instance_of? Integer }) and APIHelper.valid_type?(value.key, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value., ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.subscription_id, ->(val) { val.instance_of? Integer }) and APIHelper.valid_type?(value.customer_id, ->(val) { val.instance_of? Integer }) and APIHelper.valid_type?(value.created_at, ->(val) { val.instance_of? DateTime }) and UnionTypeLookUp.get(:EventEventSpecificData) .validate(value.event_specific_data) ) end return false unless value.instance_of? Hash ( APIHelper.valid_type?(value['id'], ->(val) { val.instance_of? Integer }) and APIHelper.valid_type?(value['key'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['message'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['subscription_id'], ->(val) { val.instance_of? Integer }) and APIHelper.valid_type?(value['customer_id'], ->(val) { val.instance_of? Integer }) and APIHelper.valid_type?(value['created_at'], ->(val) { val.instance_of? String }) and UnionTypeLookUp.get(:EventEventSpecificData) .validate(value['event_specific_data']) ) end |
Instance Method Details
#to_custom_created_at ⇒ Object
116 117 118 |
# File 'lib/advanced_billing/models/event.rb', line 116 def to_custom_created_at DateTimeHelper.to_rfc3339(created_at) end |