Method: Verizon::AccountLeadsResult.from_hash

Defined in:
lib/verizon/models/account_leads_result.rb

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/verizon/models/account_leads_result.rb', line 48

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.

  has_more_data = hash.key?('hasMoreData') ? hash['hasMoreData'] : SKIP
  # Parameter is an array, so we need to iterate through it

  leads = nil
  unless hash['leads'].nil?
    leads = []
    hash['leads'].each do |structure|
      leads << (AccountLead.from_hash(structure) if structure)
    end
  end

  leads = SKIP unless hash.key?('leads')

  # Create object from extracted values.

  AccountLeadsResult.new(has_more_data,
                         leads)
end