Method: AdvancedBilling::SubscriptionGroupPaymentProfile.from_hash

Defined in:
lib/advanced_billing/models/subscription_group_payment_profile.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/subscription_group_payment_profile.rb', line 67

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  id = hash.key?('id') ? hash['id'] : SKIP
  first_name = hash.key?('first_name') ? hash['first_name'] : SKIP
  last_name = hash.key?('last_name') ? hash['last_name'] : SKIP
  masked_card_number =
    hash.key?('masked_card_number') ? hash['masked_card_number'] : SKIP

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

  # Create object from extracted values.
  SubscriptionGroupPaymentProfile.new(id: id,
                                      first_name: first_name,
                                      last_name: last_name,
                                      masked_card_number: masked_card_number,
                                      additional_properties: hash)
end