Method: AdvancedBilling::VoidRemainderEventData.from_hash

Defined in:
lib/advanced_billing/models/void_remainder_event_data.rb

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/advanced_billing/models/void_remainder_event_data.rb', line 64

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  credit_note_attributes = CreditNote.from_hash(hash['credit_note_attributes']) if
    hash['credit_note_attributes']
  memo = hash.key?('memo') ? hash['memo'] : nil
  applied_amount =
    hash.key?('applied_amount') ? hash['applied_amount'] : nil
  transaction_time = if hash.key?('transaction_time')
                       (DateTimeHelper.from_rfc3339(hash['transaction_time']) if hash['transaction_time'])
                     end

  # Clean out expected properties from Hash.
  names.each_value { |k| hash.delete(k) }

  # Create object from extracted values.
  VoidRemainderEventData.new(credit_note_attributes: credit_note_attributes,
                             memo: memo,
                             applied_amount: applied_amount,
                             transaction_time: transaction_time,
                             additional_properties: hash)
end