Class: MLS::Listing
Defined Under Namespace
Classes: Parser
Constant Summary collapse
- STATES =
%w(processing listed leased expired)
- TYPES =
%w(lease sublease coworking_space)
- SPACE_TYPES =
%w(unit floor building)
- LEASE_TERMS =
['Full Service', 'NNN', 'Modified Gross']
- RATE_UNITS =
['/sqft/yr', '/sqft/mo', '/mo', '/yr', '/desk/mo']
- USES =
["Office", "Creative", "Loft", "Medical Office", "Flex Space", "R&D", "Office Showroom", "Industrial", "Retail"]
- SOURCE_TYPES =
%w(website flyer)
- CHANNELS =
%w(excavator mls staircase broker_dashboard)
Instance Attribute Summary collapse
-
#account ⇒ Object
Returns the value of attribute account.
-
#address ⇒ Object
Returns the value of attribute address.
-
#agents ⇒ Object
Returns the value of attribute agents.
-
#floorplan ⇒ Object
Returns the value of attribute floorplan.
-
#flyer ⇒ Object
Returns the value of attribute flyer.
-
#photos ⇒ Object
Returns the value of attribute photos.
-
#videos ⇒ Object
Returns the value of attribute videos.
Attributes inherited from Resource
Class Method Summary collapse
-
.all(options = {}) ⇒ Object
currently supported options are filters, page, per_page, offset, order.
- .amenities ⇒ Object
- .calculate(filters = {}, operation = nil, column = nil, group = nil) ⇒ Object
- .find(id) ⇒ Object
- .import(attrs) ⇒ Object
Instance Method Summary collapse
-
#all_photos ⇒ Object
TODO: Remove.
-
#all_videos ⇒ Object
TODO: Remove.
- #avatar(size = '150x100#', protocol = 'http') ⇒ Object
- #coworking? ⇒ Boolean
- #create ⇒ Object
-
#import ⇒ Object
TODO test me.
- #lease? ⇒ Boolean
- #leased? ⇒ Boolean
-
#request_tour(account, tour = {}) ⇒ Object
Creates a tour request for the listing.
- #save ⇒ Object
- #similar ⇒ Object
- #space_name ⇒ Object
- #sublease? ⇒ Boolean
- #to_hash ⇒ Object
- #to_param ⇒ Object
Methods inherited from Resource
#==, #create!, inherited, #initialize, #new_record?, #persisted?, #properties, #properties_excluded_from_comparison, #properties_for_comparison, #save!, #set_default_values, #to_key, #update!, #update_attributes
Constructor Details
This class inherits a constructor from MLS::Resource
Instance Attribute Details
#account ⇒ Object
Returns the value of attribute account.
88 89 90 |
# File 'lib/mls/models/listing.rb', line 88 def account @account end |
#address ⇒ Object
Returns the value of attribute address.
88 89 90 |
# File 'lib/mls/models/listing.rb', line 88 def address @address end |
#agents ⇒ Object
Returns the value of attribute agents.
88 89 90 |
# File 'lib/mls/models/listing.rb', line 88 def agents @agents end |
#floorplan ⇒ Object
Returns the value of attribute floorplan.
88 89 90 |
# File 'lib/mls/models/listing.rb', line 88 def floorplan @floorplan end |
#flyer ⇒ Object
Returns the value of attribute flyer.
88 89 90 |
# File 'lib/mls/models/listing.rb', line 88 def flyer @flyer end |
#photos ⇒ Object
Returns the value of attribute photos.
88 89 90 |
# File 'lib/mls/models/listing.rb', line 88 def photos @photos end |
#videos ⇒ Object
Returns the value of attribute videos.
88 89 90 |
# File 'lib/mls/models/listing.rb', line 88 def videos @videos end |
Class Method Details
.all(options = {}) ⇒ Object
currently supported options are filters, page, per_page, offset, order
242 243 244 245 |
# File 'lib/mls/models/listing.rb', line 242 def all(={}) response = MLS.get('/listings', ) MLS::Listing::Parser.parse_collection(response.body) end |
.amenities ⇒ Object
257 258 259 |
# File 'lib/mls/models/listing.rb', line 257 def amenities @amenities ||= Yajl::Parser.new(:symbolize_keys => true).parse(MLS.get('/listings/amenities').body) end |
.calculate(filters = {}, operation = nil, column = nil, group = nil) ⇒ Object
252 253 254 255 |
# File 'lib/mls/models/listing.rb', line 252 def calculate(filters = {}, operation = nil, column = nil, group = nil) response = MLS.get("/listings/calculate", :filters => filters, :operation => operation, :column => column, :group => group) MLS::Parser.extract_attributes(response.body)[:listings] end |
.find(id) ⇒ Object
236 237 238 239 |
# File 'lib/mls/models/listing.rb', line 236 def find(id) response = MLS.get("/listings/#{id}") MLS::Listing::Parser.parse(response.body) end |
.import(attrs) ⇒ Object
247 248 249 250 |
# File 'lib/mls/models/listing.rb', line 247 def import(attrs) model = self.new(attrs) {:status => model.import, :model => model} end |
Instance Method Details
#all_photos ⇒ Object
TODO: Remove
219 220 221 222 |
# File 'lib/mls/models/listing.rb', line 219 def all_photos warn "Listing#all_photos is deprecated" photos + address.photos end |
#all_videos ⇒ Object
TODO: Remove
225 226 227 228 |
# File 'lib/mls/models/listing.rb', line 225 def all_videos warn "Listing#all_videos is deprecated" videos + address.videos end |
#avatar(size = '150x100#', protocol = 'http') ⇒ Object
90 91 92 93 94 95 96 |
# File 'lib/mls/models/listing.rb', line 90 def avatar(size='150x100#', protocol='http') if avatar_digest "#{protocol}://#{MLS.image_host}/#{avatar_digest}.jpg?s=#{URI.escape(size)}" else address.avatar(size, protocol) end end |
#coworking? ⇒ Boolean
104 105 106 |
# File 'lib/mls/models/listing.rb', line 104 def coworking? type == 'coworking_space' end |
#create ⇒ Object
166 167 168 169 170 171 |
# File 'lib/mls/models/listing.rb', line 166 def create MLS.post('/listings', {:listing => to_hash}, 201, 400) do |response, code| raise MLS::Exception::UnexpectedResponse if ![201, 400].include?(code) MLS::Listing::Parser.update(self, response.body) end end |
#import ⇒ Object
TODO test me
198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 |
# File 'lib/mls/models/listing.rb', line 198 def import #TODO test me result = :failure MLS.post('/import', {:listing => to_hash}, 400) do |response, code| case code when 200 result = :duplicate when 201 result = :created when 202 result = :updated when 400 result = :failure else raise MLS::Exception::UnexpectedResponse, code end MLS::Listing::Parser.update(self, response.body) end result end |
#lease? ⇒ Boolean
98 99 100 |
# File 'lib/mls/models/listing.rb', line 98 def lease? type == 'lease' end |
#leased? ⇒ Boolean
108 109 110 |
# File 'lib/mls/models/listing.rb', line 108 def leased? state == 'leased' end |
#request_tour(account, tour = {}) ⇒ Object
Creates a tour request for the listing.
- Paramaters
-
account
- AHash
of the user account. Valid keys are:-
:name
- Name of the User requesting the tour (Required) -
:email
- Email of the User requesting the tour (Required) -
:phone
- Phone of the User requesting the tour
-
-
info
- A optionalHash
of company info. Valid keys are:-
:message
- Overrides the default message on the email sent to the broker -
:company
- The name of the company that is interested in the space -
:population
- The current number of employees at the company -
:growing
- A boolean of weather or not the company is expecting to grow
-
Examples:
#!ruby
listing = MLS::Listing.find(@id)
info => {:company => 'name', :population => 10, :funding => 'string', :move_id => '2012-09-12'}
listing.request_tour('name', '[email protected]', info) # => #<MLS::Tour>
listing.request_tour('', 'emai', info) # => #<MLS::Tour> will have errors on account
161 162 163 |
# File 'lib/mls/models/listing.rb', line 161 def request_tour(account, tour={}) MLS::Tour.create(id, account, tour) end |
#save ⇒ Object
173 174 175 176 177 178 179 180 181 182 183 |
# File 'lib/mls/models/listing.rb', line 173 def save return create unless id MLS.put("/listings/#{id}", {:listing => to_hash}, 400) do |response, code| if code == 200 || code == 400 MLS::Listing::Parser.update(self, response.body) code == 200 else raise MLS::Exception::UnexpectedResponse, code end end end |
#similar ⇒ Object
230 231 232 |
# File 'lib/mls/models/listing.rb', line 230 def similar [] # Similar Listings not supported for now end |
#space_name ⇒ Object
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
# File 'lib/mls/models/listing.rb', line 112 def space_name return name if !name.nil? case space_type when 'unit' if unit "Unit #{unit}" elsif floor "#{floor.ordinalize} Floor" else "Unit Lease" end when 'building' "Entire Building" when 'floor' if floor "#{floor.ordinalize} Floor" elsif unit "Unit #{unit}" else "Floor Lease" end end end |
#sublease? ⇒ Boolean
101 102 103 |
# File 'lib/mls/models/listing.rb', line 101 def sublease? type == 'sublease' end |
#to_hash ⇒ Object
185 186 187 188 189 190 191 192 |
# File 'lib/mls/models/listing.rb', line 185 def to_hash hash = super hash[:address_attributes] = address.to_hash if address hash[:agents_attributes] = agents.inject([]) { |acc, x| acc << x.to_hash; acc } if agents hash[:photo_ids] = photos.map(&:id) if photos hash[:videos_attributes] = videos.map(&:to_hash) unless videos.blank? hash end |
#to_param ⇒ Object
194 195 196 |
# File 'lib/mls/models/listing.rb', line 194 def to_param "#{address.to_param}/#{id}" end |