Sha256: bb6c181edd00bed82cbc56a20c20a5c697a1224c31df779be99f77ddc49b44c0
Contents?: true
Size: 1.39 KB
Versions: 7
Compression:
Stored size: 1.39 KB
Contents
require 'real_page/utils/array_fetcher' require_relative '../guest_cards' module RealPage module DocumentParser class GuestCards # Parse the Prospects from a GuestCards response class Prospects < Base # @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 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 def phone_numbers(phone_numbers_hash) Utils::ArrayFetcher.new( hash: phone_numbers_hash, key: 'PhoneNumber', model: Model::PhoneNumber ).fetch end def prospects(prospects_hash) Utils::ArrayFetcher.new(hash: prospects_hash, key: 'Prospect').fetch end end end end end
Version data entries
7 entries across 7 versions & 1 rubygems