Class: Rentlinx::Unit

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

Overview

An object that represents a Rentlinx unit.

Constant Summary collapse

ATTRIBUTES =
[:unitID, :propertyID, :name, :description, :rent, :maxRent,
:deposit, :maxDeposit, :squareFeet, :maxSquareFeet,
:bedrooms, :fullBaths, :halfBaths, :isMobilityAccessible,
:isVisionAccessible, :isHearingAccessible, :rentIsBasedOnIncome,
:isOpenToLease, :dateAvailable, :dateLeasedThrough, :numUnits,
:numAvailable, :address].freeze
REQUIRED_ATTRIBUTES =
[:unitID].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=, #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 unit with the given ID

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

Parameters:

  • id (String)

    the rentlinx id of the unit

Returns:

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



51
52
53
# File 'lib/rentlinx/models/unit.rb', line 51

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

Instance Method Details

#amenity_classObject

For internal use



27
28
29
# File 'lib/rentlinx/models/unit.rb', line 27

def amenity_class
  Rentlinx::UnitAmenity
end

For internal use



33
34
35
# File 'lib/rentlinx/models/unit.rb', line 33

def link_class
  Rentlinx::UnitLink
end

#photo_classObject

For internal use



21
22
23
# File 'lib/rentlinx/models/unit.rb', line 21

def photo_class
  Rentlinx::UnitPhoto
end

#photosObject

Gets all the photos for a unit.

Returns:

  • a list of Rentlinx::UnitPhoto objects



40
41
42
# File 'lib/rentlinx/models/unit.rb', line 40

def photos
  super.select { |p| p.unitID == unitID }
end