Class: AdvancedBilling::InvoicePreviousBalance
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- AdvancedBilling::InvoicePreviousBalance
- Defined in:
- lib/advanced_billing/models/invoice_previous_balance.rb
Overview
InvoicePreviousBalance Model.
Instance Attribute Summary collapse
-
#captured_at ⇒ DateTime
TODO: Write general description for this method.
-
#invoices ⇒ Array[InvoiceBalanceItem]
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(captured_at: SKIP, invoices: SKIP, additional_properties: {}) ⇒ InvoicePreviousBalance
constructor
A new instance of InvoicePreviousBalance.
- #to_custom_captured_at ⇒ Object
Methods inherited from BaseModel
Constructor Details
#initialize(captured_at: SKIP, invoices: SKIP, additional_properties: {}) ⇒ InvoicePreviousBalance
Returns a new instance of InvoicePreviousBalance.
42 43 44 45 46 47 48 49 50 |
# File 'lib/advanced_billing/models/invoice_previous_balance.rb', line 42 def initialize(captured_at: SKIP, invoices: SKIP, additional_properties: {}) @captured_at = captured_at unless captured_at == SKIP @invoices = invoices unless invoices == SKIP # Add additional model properties to the instance. additional_properties.each do |_name, _value| instance_variable_set("@#{_name}", _value) end end |
Instance Attribute Details
#captured_at ⇒ DateTime
TODO: Write general description for this method
15 16 17 |
# File 'lib/advanced_billing/models/invoice_previous_balance.rb', line 15 def captured_at @captured_at end |
#invoices ⇒ Array[InvoiceBalanceItem]
TODO: Write general description for this method
19 20 21 |
# File 'lib/advanced_billing/models/invoice_previous_balance.rb', line 19 def invoices @invoices end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/advanced_billing/models/invoice_previous_balance.rb', line 53 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. captured_at = if hash.key?('captured_at') (DateTimeHelper.from_rfc3339(hash['captured_at']) if hash['captured_at']) else SKIP end # Parameter is an array, so we need to iterate through it invoices = nil unless hash['invoices'].nil? invoices = [] hash['invoices'].each do |structure| invoices << (InvoiceBalanceItem.from_hash(structure) if structure) end end invoices = SKIP unless hash.key?('invoices') # Clean out expected properties from Hash. names.each_value { |k| hash.delete(k) } # Create object from extracted values. InvoicePreviousBalance.new(captured_at: captured_at, invoices: invoices, additional_properties: hash) end |
.names ⇒ Object
A mapping from model property names to API property names.
22 23 24 25 26 27 |
# File 'lib/advanced_billing/models/invoice_previous_balance.rb', line 22 def self.names @_hash = {} if @_hash.nil? @_hash['captured_at'] = 'captured_at' @_hash['invoices'] = 'invoices' @_hash end |
.nullables ⇒ Object
An array for nullable fields
38 39 40 |
# File 'lib/advanced_billing/models/invoice_previous_balance.rb', line 38 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
30 31 32 33 34 35 |
# File 'lib/advanced_billing/models/invoice_previous_balance.rb', line 30 def self.optionals %w[ captured_at invoices ] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
88 89 90 91 92 93 94 |
# File 'lib/advanced_billing/models/invoice_previous_balance.rb', line 88 def self.validate(value) return true if value.instance_of? self return false unless value.instance_of? Hash true end |
Instance Method Details
#to_custom_captured_at ⇒ Object
82 83 84 |
# File 'lib/advanced_billing/models/invoice_previous_balance.rb', line 82 def to_custom_captured_at DateTimeHelper.to_rfc3339(captured_at) end |