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
The schema varies based on the event key.
-
#id ⇒ Integer
TODO: Write general description for this method.
-
#key ⇒ EventKey
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.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
- #to_custom_created_at ⇒ Object
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
Methods inherited from BaseModel
#check_for_conflict, #get_additional_properties, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json
Constructor Details
#initialize(id:, key:, message:, subscription_id:, customer_id:, created_at:, event_specific_data:, additional_properties: {}) ⇒ Event
Returns a new instance of Event.
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
# File 'lib/advanced_billing/models/event.rb', line 130 def initialize(id:, key:, message:, subscription_id:, customer_id:, created_at:, event_specific_data:, additional_properties: {}) # Add additional model properties to the instance. additional_properties.each do |_name, _value| instance_variable_set("@#{_name}", _value) end @id = id @key = key @message = @subscription_id = subscription_id @customer_id = customer_id @created_at = created_at @event_specific_data = event_specific_data 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
The schema varies based on the event key. The key-to-event data mapping is as follows:
-
‘subscription_product_change` - SubscriptionProductChange
-
‘subscription_state_change` - SubscriptionStateChange
-
‘signup_success`, `delayed_signup_creation_success`, `payment_success`,
‘payment_failure`, `renewal_success`, `renewal_failure`, `chargeback_lost`, `chargeback_accepted`, `chargeback_closed` - PaymentRelatedEvents
-
‘refund_success` - RefundSuccess
-
‘component_allocation_change` - ComponentAllocationChange
-
‘metered_usage` - MeteredUsage
-
‘prepaid_usage` - PrepaidUsage
-
‘dunning_step_reached` - DunningStepReached
-
‘invoice_issued` - InvoiceIssued
-
‘pending_cancellation_change` - PendingCancellationChange
-
‘prepaid_subscription_balance_changed` -
PrepaidSubscriptionBalanceChanged
-
‘subscription_group_signup_success` and
‘subscription_group_signup_failure` - SubscriptionGroupSignupEventData
-
‘proforma_invoice_issued` - ProformaInvoiceIssued
-
‘subscription_prepayment_account_balance_changed` -
PrepaymentAccountBalanceChanged
-
‘payment_collection_method_changed` - PaymentCollectionMethodChanged
-
‘subscription_service_credit_account_balance_changed` -
CreditAccountBalanceChanged
-
‘item_price_point_changed` - ItemPricePointChanged
-
‘custom_field_value_change` - CustomFieldValueChange
-
‘chjs_tokenization_success` - ChjsTokenizationSuccess
-
‘chjs_tokenization_failure` - ChjsTokenizationFailure
-
The rest, that is ‘delayed_signup_creation_failure`,
‘billing_date_change`, `expiration_date_change`, `expiring_card`, `customer_update`, `customer_create`, `customer_delete`, `upgrade_downgrade_success`, `upgrade_downgrade_failure`, `statement_closed`, `statement_settled`, `subscription_card_update`, `subscription_group_card_update`, `subscription_bank_account_update`, `refund_failure`, `upcoming_renewal_notice`, `trial_end_notice`, `direct_debit_payment_paid_out`, `direct_debit_payment_rejected`, `direct_debit_payment_pending`, `pending_payment_created`, `pending_payment_failed`, `pending_payment_completed`, don’t have event_specific_data defined, ‘renewal_success_recreated`, `renewal_failure_recreated`, `payment_success_recreated`, `payment_failure_recreated`, `subscription_deletion`, `subscription_group_bank_account_update`, `subscription_paypal_account_update`, `subscription_group_paypal_account_update`, `subscription_customer_change`, `account_transaction_changed`, `go_cardless_payment_paid_out`, `go_cardless_payment_rejected`, `go_cardless_payment_pending`, `stripe_direct_debit_payment_paid_out`, `stripe_direct_debit_payment_rejected`, `stripe_direct_debit_payment_pending`, `maxio_payments_direct_debit_payment_paid_out`, `maxio_payments_direct_debit_payment_rejected`, `maxio_payments_direct_debit_payment_pending`, `invoice_in_collections_canceled`, `subscription_added_to_group`, `subscription_removed_from_group`, `chargeback_opened`, `chargeback_lost`, `chargeback_accepted`, `chargeback_closed`, `chargeback_won`, `payment_collection_method_changed`, `component_billing_date_changed`, `subscription_term_renewal_scheduled`, `subscription_term_renewal_pending`, `subscription_term_renewal_activated`, `subscription_term_renewal_removed`
they map to ‘null` instead.
101 102 103 |
# File 'lib/advanced_billing/models/event.rb', line 101 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 ⇒ EventKey
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.
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 |
# File 'lib/advanced_billing/models/event.rb', line 147 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. additional_properties = hash.reject { |k, _| names.value?(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: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/advanced_billing/models/event.rb', line 104 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
122 123 124 125 126 127 128 |
# File 'lib/advanced_billing/models/event.rb', line 122 def self.nullables %w[ subscription_id customer_id event_specific_data ] end |
.optionals ⇒ Object
An array for optional fields
117 118 119 |
# File 'lib/advanced_billing/models/event.rb', line 117 def self.optionals [] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 |
# File 'lib/advanced_billing/models/event.rb', line 184 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) { EventKey.validate(val) }) 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) { EventKey.validate(val) }) 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
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
234 235 236 237 238 239 240 |
# File 'lib/advanced_billing/models/event.rb', line 234 def inspect class_name = self.class.name.split('::').last "<#{class_name} id: #{@id.inspect}, key: #{@key.inspect}, message: #{@message.inspect},"\ " subscription_id: #{@subscription_id.inspect}, customer_id: #{@customer_id.inspect},"\ " created_at: #{@created_at.inspect}, event_specific_data: #{@event_specific_data.inspect},"\ " additional_properties: #{get_additional_properties}>" end |
#to_custom_created_at ⇒ Object
178 179 180 |
# File 'lib/advanced_billing/models/event.rb', line 178 def to_custom_created_at DateTimeHelper.to_rfc3339(created_at) end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
225 226 227 228 229 230 231 |
# File 'lib/advanced_billing/models/event.rb', line 225 def to_s class_name = self.class.name.split('::').last "<#{class_name} id: #{@id}, key: #{@key}, message: #{@message}, subscription_id:"\ " #{@subscription_id}, customer_id: #{@customer_id}, created_at: #{@created_at},"\ " event_specific_data: #{@event_specific_data}, additional_properties:"\ " #{get_additional_properties}>" end |