Class: AdvancedBilling::RefundInvoiceEvent
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- AdvancedBilling::RefundInvoiceEvent
- Defined in:
- lib/advanced_billing/models/refund_invoice_event.rb
Overview
RefundInvoiceEvent Model.
Instance Attribute Summary collapse
-
#event_data ⇒ RefundInvoiceEventData
Example schema for an ‘refund_invoice` event.
-
#event_type ⇒ InvoiceEventType
TODO: Write general description for this method.
-
#id ⇒ Integer
TODO: Write general description for this method.
-
#invoice ⇒ Invoice
TODO: Write general description for this method.
-
#timestamp ⇒ DateTime
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:, timestamp:, invoice:, event_type: InvoiceEventType::REFUND_INVOICE, event_data:, additional_properties: {}) ⇒ RefundInvoiceEvent
constructor
A new instance of RefundInvoiceEvent.
- #to_custom_timestamp ⇒ Object
Methods inherited from BaseModel
Constructor Details
#initialize(id:, timestamp:, invoice:, event_type: InvoiceEventType::REFUND_INVOICE, event_data:, additional_properties: {}) ⇒ RefundInvoiceEvent
Returns a new instance of RefundInvoiceEvent.
54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/advanced_billing/models/refund_invoice_event.rb', line 54 def initialize(id:, timestamp:, invoice:, event_type: InvoiceEventType::REFUND_INVOICE, event_data:, additional_properties: {}) @id = id @timestamp = @invoice = invoice @event_type = event_type @event_data = event_data # Add additional model properties to the instance. additional_properties.each do |_name, _value| instance_variable_set("@#{_name}", _value) end end |
Instance Attribute Details
#event_data ⇒ RefundInvoiceEventData
Example schema for an ‘refund_invoice` event
31 32 33 |
# File 'lib/advanced_billing/models/refund_invoice_event.rb', line 31 def event_data @event_data end |
#event_type ⇒ InvoiceEventType
TODO: Write general description for this method
27 28 29 |
# File 'lib/advanced_billing/models/refund_invoice_event.rb', line 27 def event_type @event_type end |
#id ⇒ Integer
TODO: Write general description for this method
15 16 17 |
# File 'lib/advanced_billing/models/refund_invoice_event.rb', line 15 def id @id end |
#invoice ⇒ Invoice
TODO: Write general description for this method
23 24 25 |
# File 'lib/advanced_billing/models/refund_invoice_event.rb', line 23 def invoice @invoice end |
#timestamp ⇒ DateTime
TODO: Write general description for this method
19 20 21 |
# File 'lib/advanced_billing/models/refund_invoice_event.rb', line 19 def @timestamp end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/advanced_billing/models/refund_invoice_event.rb', line 70 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. id = hash.key?('id') ? hash['id'] : nil = if hash.key?('timestamp') (DateTimeHelper.from_rfc3339(hash['timestamp']) if hash['timestamp']) end invoice = Invoice.from_hash(hash['invoice']) if hash['invoice'] event_type = hash['event_type'] ||= InvoiceEventType::REFUND_INVOICE event_data = RefundInvoiceEventData.from_hash(hash['event_data']) if hash['event_data'] # Clean out expected properties from Hash. names.each_value { |k| hash.delete(k) } # Create object from extracted values. RefundInvoiceEvent.new(id: id, timestamp: , invoice: invoice, event_type: event_type, event_data: event_data, additional_properties: hash) end |
.names ⇒ Object
A mapping from model property names to API property names.
34 35 36 37 38 39 40 41 42 |
# File 'lib/advanced_billing/models/refund_invoice_event.rb', line 34 def self.names @_hash = {} if @_hash.nil? @_hash['id'] = 'id' @_hash['timestamp'] = 'timestamp' @_hash['invoice'] = 'invoice' @_hash['event_type'] = 'event_type' @_hash['event_data'] = 'event_data' @_hash end |
.nullables ⇒ Object
An array for nullable fields
50 51 52 |
# File 'lib/advanced_billing/models/refund_invoice_event.rb', line 50 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
45 46 47 |
# File 'lib/advanced_billing/models/refund_invoice_event.rb', line 45 def self.optionals [] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
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 130 131 132 133 134 |
# File 'lib/advanced_billing/models/refund_invoice_event.rb', line 100 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., ->(val) { val.instance_of? DateTime }) and APIHelper.valid_type?(value.invoice, ->(val) { Invoice.validate(val) }, is_model_hash: true) and APIHelper.valid_type?(value.event_type, ->(val) { InvoiceEventType.validate(val) }) and APIHelper.valid_type?(value.event_data, ->(val) { RefundInvoiceEventData.validate(val) }, is_model_hash: true) ) end return false unless value.instance_of? Hash ( APIHelper.valid_type?(value['id'], ->(val) { val.instance_of? Integer }) and APIHelper.valid_type?(value['timestamp'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['invoice'], ->(val) { Invoice.validate(val) }, is_model_hash: true) and APIHelper.valid_type?(value['event_type'], ->(val) { InvoiceEventType.validate(val) }) and APIHelper.valid_type?(value['event_data'], ->(val) { RefundInvoiceEventData.validate(val) }, is_model_hash: true) ) end |
Instance Method Details
#to_custom_timestamp ⇒ Object
94 95 96 |
# File 'lib/advanced_billing/models/refund_invoice_event.rb', line 94 def DateTimeHelper.to_rfc3339() end |