class RealPage::DocumentParser::GuestCards::Prospects

Parse the Prospects from a GuestCards response

Public Instance Methods

parse(prospects_hash) click to toggle source

@param prospects_hash [Array<Hash<String, Object>>] a 'Prospects'

entry of the XML response parsed into a Hash

@return [Array<RealPage::Model::Prospect>] the prospects contained

in this prospects_hash

@raise [RealPage::Error::Base] if the response is invalid

# File lib/real_page/document_parser/guest_cards/prospects.rb, line 15
def parse(prospects_hash)
  prospects(prospects_hash).map do |prospect|
    attrs = prospect.merge(
      'PhoneNumbers' => phone_numbers(prospect['Numbers'])
    )
    if prospect['Address']
      attrs['Address'] = Model::Address.new(prospect['Address'])
    end
    # RealPage is inconsistent about Number vs PhoneNumber
    attrs.delete('Numbers')
    Model::Prospect.new(attrs)
  end
end

Private Instance Methods

phone_numbers(phone_numbers_hash) click to toggle source
# File lib/real_page/document_parser/guest_cards/prospects.rb, line 31
def phone_numbers(phone_numbers_hash)
  Utils::ArrayFetcher.new(
    hash: phone_numbers_hash,
    key: 'PhoneNumber',
    model: Model::PhoneNumber
  ).fetch
end
prospects(prospects_hash) click to toggle source
# File lib/real_page/document_parser/guest_cards/prospects.rb, line 39
def prospects(prospects_hash)
  Utils::ArrayFetcher.new(hash: prospects_hash, key: 'Prospect').fetch
end