Class: Rentlinx::Property

Inherits:
Base
  • Object
show all
Includes:
Amenityable, Linkable, Photoable
Defined in:
lib/rentlinx/models/property.rb

Overview

An object that represents a Rentlinx property.

Constant Summary collapse

ATTRIBUTES =
[:companyID, :propertyID, :description, :address, :city, :state,
:zip, :marketingName, :hideAddress, :latitude, :longitude,
:website, :yearBuilt, :numUnits, :phoneNumber, :extension,
:faxNumber, :emailAddress, :acceptsHcv, :propertyType,
:activeURL, :companyName, :leadsURL,
:premium, :capAmount, :rentlinxID].freeze
REQUIRED_ATTRIBUTES =
[:propertyID, :address, :city, :state, :zip,
:phoneNumber, :emailAddress].freeze

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Linkable

#add_link, #links, #links=, #post_links, #post_with_links

Methods included from Amenityable

#add_amenity, #amenities, #amenities=, #post_amenities, #post_with_amenities

Methods included from Photoable

#add_photo, #photos, #photos=, #post_photos, #post_with_photos

Methods inherited from Base

#attributes, get_from_id, #initialize, #patch, #patch_valid?, #post, #required_attributes, #to_hash, type, #unpost, unpost, #valid?, #validate

Constructor Details

This class inherits a constructor from Rentlinx::Base

Class Method Details

.from_id(id) ⇒ Object

Queries rentlinx and builds a property with the given ID.

The returned property will have all the attributes Rentlinx has for the property on their end.

Parameters:

  • id (String)

    the rentlinx id of the property

Returns:

  • a Rentlinx::Property that is up to date with the remote one



57
58
59
# File 'lib/rentlinx/models/property.rb', line 57

def self.from_id(id)
  get_from_id(:property, id)
end

.websites(id) ⇒ Object

Asks rentlinx for a list of places where the property is posted

Parameters:

  • id (String)

    the rentlinx id of the property

Returns:

  • a list of hashes



65
66
67
# File 'lib/rentlinx/models/property.rb', line 65

def self.websites(id)
  Rentlinx.client.get_websites(id)
end

Instance Method Details

#amenity_classObject

For internal use.



77
78
79
# File 'lib/rentlinx/models/property.rb', line 77

def amenity_class
  Rentlinx::PropertyAmenity
end

For internal use.



83
84
85
# File 'lib/rentlinx/models/property.rb', line 83

def link_class
  Rentlinx::PropertyLink
end

#photo_classObject

For internal use.



71
72
73
# File 'lib/rentlinx/models/property.rb', line 71

def photo_class
  Rentlinx::PropertyPhoto
end

#post_with_unitsObject

Posts the property with all of its attached units.

TODO: Discuss whether or not these kinds of methods are needed, or whether we should have post do everything every time.



24
25
26
27
# File 'lib/rentlinx/models/property.rb', line 24

def post_with_units
  post
  units.each(&:post) unless units.nil? || units.empty?
end

#unitsObject

The list of units attached to the property.

If the units list is empty, it will query Rentlinx for the list of units stored on their end.

Returns:

  • a list of Rentlinx::Unit objects



35
36
37
# File 'lib/rentlinx/models/property.rb', line 35

def units
  @units ||= get_units_for_property_id(propertyID)
end

#units=(unit_list) ⇒ Object

Allows assigning a list of units to the property.

Parameters:

  • unit_list (Array)

    a list of Rentlinx::Unit objects

Returns:

  • the updated list of Rentlinx::Unit objects



43
44
45
46
47
48
# File 'lib/rentlinx/models/property.rb', line 43

def units=(unit_list)
  @units = unit_list.map do |unit|
    unit.propertyID = propertyID
    unit
  end
end