Class: RealPage::DocumentParser::GuestCards::Prospects

Inherits:
Base
  • Object
show all
Defined in:
lib/real_page/document_parser/guest_cards/prospects.rb

Overview

Parse the Prospects from a GuestCards response

Instance Attribute Summary

Attributes inherited from Base

#request_name, #request_params

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from RealPage::DocumentParser::Base

Instance Method Details

#parse(prospects_hash) ⇒ Array<RealPage::Model::Prospect>

Returns the prospects contained in this prospects_hash.

Parameters:

  • prospects_hash (Array<Hash<String, Object>>)

    a ‘Prospects’ entry of the XML response parsed into a Hash

Returns:

Raises:

  • (RealPage::Error::Base)

    if the response is invalid



15
16
17
18
19
20
21
22
23
24
25
26
27
# 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