class Rpx::ResidentWithLease

Constants

VALID_EVENTS

Public Class Methods

find(options, client=Client.new(options)) click to toggle source
# File lib/rpx/resident_with_lease.rb, line 45
def self.find(options, client=Client.new(options))
  resident_hash = client.api_call :getresidentbyresidentid, options do |xml|
    xml.tem :residentid, options.fetch(:resident_id)
  end

  site_properties = {siteid: options.fetch(:siteid), pmcid: options.fetch(:pmcid)}
  new(resident_hash.merge(site_properties))
end
where(options, client=Client.new(options)) click to toggle source
# File lib/rpx/resident_with_lease.rb, line 16
def self.where(options, client=Client.new(options))
  resident_hashs = client.api_call :residentsearchbyinfo, options do |xml|
    xml.tem :residentsearch do |xml|
      xml.tem :extensionData
      client.add_attributes_if_present(xml, options, ResidentWithLease.properties.to_a)

      if options[:leaselist]
        xml.tem :leaselist do |xml|
          xml.tem :leases do |xml|
            client.add_attributes_if_present(xml, options, options.fetch(:leaselist).keys)
          end
        end
      end
    end
  end

  site_properties = {siteid: options.fetch(:siteid), pmcid: options.fetch(:pmcid)}
  [resident_hashs].flatten.map{ |resident_hash| ResidentWithLease.new(resident_hash.merge(site_properties))  }
end
with_events(options, client=Client.new(options)) click to toggle source
# File lib/rpx/resident_with_lease.rb, line 54
def self.with_events(options, client=Client.new(options))
  events = [*options.fetch(:events)]
  raise InvalidArgument.new(":events must be included in #{VALID_EVENTS.join(', ')}") unless !events.blank? && events.all?{|event| VALID_EVENTS.include? event}

  resident_hashs = client.api_call :residentsearchbydate, options do |xml|
    xml.tem :residentsearch do |xml|
      xml.tem :extensionData
      xml.tem :startdate, options.fetch(:startdate) #start date to retrieve active residents
      xml.tem :enddate, options.fetch(:enddate) #end date to retrieve active residents
      xml.tem :events do |xml|
        events.each{|event| xml.tem :string, event}
      end
      client.add_attributes_if_present(xml, options, :headofhousehold)
    end
  end
  site_properties = {siteid: options.fetch(:siteid), pmcid: options.fetch(:pmcid)}
  [resident_hashs].flatten.map{ |resident_hash| new(resident_hash.merge(site_properties)) }
end

Public Instance Methods

current_resident?() click to toggle source
# File lib/rpx/resident_with_lease.rb, line 37
def current_resident?
  current_lease.leasestatus == "Current Resident"
end
fullname() click to toggle source
# File lib/rpx/resident_with_lease.rb, line 73
def fullname
  "#{namesalutation} #{firstname} #{middlename} #{lastname} #{namegeneration}".strip
end
moved_out?() click to toggle source
# File lib/rpx/resident_with_lease.rb, line 41
def moved_out?
  current_lease.moved_out?
end
residenttype() click to toggle source
# File lib/rpx/resident_with_lease.rb, line 77
def residenttype
  residentagestatus
end