Method: AdvancedBilling::PrepaidConfiguration.from_hash

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

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/advanced_billing/models/prepaid_configuration.rb', line 87

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  id = hash.key?('id') ? hash['id'] : SKIP
  initial_funding_amount_in_cents =
    hash.key?('initial_funding_amount_in_cents') ? hash['initial_funding_amount_in_cents'] : SKIP
  replenish_to_amount_in_cents =
    hash.key?('replenish_to_amount_in_cents') ? hash['replenish_to_amount_in_cents'] : SKIP
  auto_replenish =
    hash.key?('auto_replenish') ? hash['auto_replenish'] : SKIP
  replenish_threshold_amount_in_cents =
    hash.key?('replenish_threshold_amount_in_cents') ? hash['replenish_threshold_amount_in_cents'] : SKIP

  # Clean out expected properties from Hash.
  additional_properties = hash.reject { |k, _| names.value?(k) }

  # Create object from extracted values.
  PrepaidConfiguration.new(id: id,
                           initial_funding_amount_in_cents: initial_funding_amount_in_cents,
                           replenish_to_amount_in_cents: replenish_to_amount_in_cents,
                           auto_replenish: auto_replenish,
                           replenish_threshold_amount_in_cents: replenish_threshold_amount_in_cents,
                           additional_properties: additional_properties)
end