Class: Rpx::ResidentWithLease

Inherits:
Resident
  • Object
show all
Defined in:
lib/rpx/resident_with_lease.rb

Constant Summary collapse

VALID_EVENTS =
['moveout', 'movein']

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Resident

#current_lease, current_residents, #leases, #minor?, #status

Class Method Details

.find(options, client = Client.new(options)) ⇒ Object



45
46
47
48
49
50
51
52
# 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)) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# 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)) ⇒ Object

Raises:

  • (InvalidArgument)


54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# 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

Instance Method Details

#current_resident?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/rpx/resident_with_lease.rb', line 37

def current_resident?
  current_lease.leasestatus == "Current Resident"
end

#fullnameObject



73
74
75
# File 'lib/rpx/resident_with_lease.rb', line 73

def fullname
  "#{namesalutation} #{firstname} #{middlename} #{lastname} #{namegeneration}".strip
end

#moved_out?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/rpx/resident_with_lease.rb', line 41

def moved_out?
  current_lease.moved_out?
end

#residenttypeObject



77
78
79
# File 'lib/rpx/resident_with_lease.rb', line 77

def residenttype
  residentagestatus
end