class Yardi::DocumentParser::Residents
Constants
- SOAP_ACTION
Attributes
body[R]
property_id[R]
Public Class Methods
new(property_id)
click to toggle source
# File lib/yardi/document_parser/residents.rb, line 8 def initialize(property_id) @property_id = property_id end
Private Instance Methods
create_resident(resident)
click to toggle source
Creates a primary Resident after first creating Resident objects for roommates under `OtherOccupants`.
# File lib/yardi/document_parser/residents.rb, line 41 def create_resident(resident) roommate_nodes = resident.dig('OtherOccupants', 'OtherOccupant') roommates = roommate_nodes.nil? ? [] : create_roommates(roommate_nodes) Model::Resident.new(resident, type: 'primary', roommates: roommates) end
create_roommates(roommates)
click to toggle source
Creates roommates given `OtherOccupant` data. Note that this can either be a Hash or Array, so we cast it to an Array from the start.
# File lib/yardi/document_parser/residents.rb, line 49 def create_roommates(roommates) return unless roommates roommates = [roommates].flatten roommates.map do |r| Model::Resident.new(r, type: 'roommate') end end
parse_body(body)
click to toggle source
@param body [Hash<String, Object>] the body of the XML response parsed
into a Hash
@return [Array<Yardi::Model::Resident>] @raise [Yardi::Error::Base] if the response is invalid
# File lib/yardi/document_parser/residents.rb, line 20 def parse_body(body) @body = body residents end
residents()
click to toggle source
# File lib/yardi/document_parser/residents.rb, line 25 def residents path = %w[MITS_ResidentData PropertyResidents Residents Resident] results = [result_node.dig(*path)].flatten.compact if results.empty? raise Error::NoResults, "Failed to get residents for yardi_property_id: #{property_id}" end results.map { |r| create_resident(r) } end