Method: AdvancedBilling::PaymentForAllocation.from_hash

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

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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/payment_for_allocation.rb', line 67

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  id = hash.key?('id') ? hash['id'] : SKIP
  amount_in_cents =
    hash.key?('amount_in_cents') ? hash['amount_in_cents'] : SKIP
  success = hash.key?('success') ? hash['success'] : SKIP
  memo = hash.key?('memo') ? hash['memo'] : SKIP

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

  # Create object from extracted values.
  PaymentForAllocation.new(id: id,
                           amount_in_cents: amount_in_cents,
                           success: success,
                           memo: memo,
                           additional_properties: hash)
end