lib/mls/models/listing.rb in mls-0.2.3 vs lib/mls/models/listing.rb in mls-0.2.4
- old
+ new
@@ -3,20 +3,24 @@
KINDS = %w(lease sublease coworking)
SPACE_TYPES = %w(unit floor building)
LEASE_TYPES = ['Full Service', 'NNN', 'Gross', 'Industrial Gross', 'Modified Gross', 'Triple Net', 'Modified Net']
RATE_UNITS = ['ft^2/year', 'ft^2/month', 'desk/month']
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)
property :id, Fixnum, :serialize => :false
property :address_id, Fixnum, :serialize => :false
property :use_id, Fixnum
property :use, String, :serialize => :if_present
property :account_id, Fixnum
property :hidden, Boolean, :default => false
property :source, String
property :source_url, String
property :flyer_url, String, :serialize => false
+ property :source_type, String, :serialize => :if_present
+ property :channel, String, :serialize => :if_present
property :name, String
property :kind, String, :default => 'lease'
property :space_type, String, :default => 'unit'
property :unit, String
@@ -100,15 +104,27 @@
def space_name
return name if !name.nil?
case space_type
when 'unit'
- "Unit #{unit || 'Lease'}"
+ if unit
+ "Unit #{unit}"
+ elsif floor
+ "#{floor.ordinalize} Floor"
+ else
+ "Unit Lease"
+ end
when 'building'
"Entire Building"
when 'floor'
- "Floor #{floor || 'Lease'}"
+ if floor
+ "#{floor.ordinalize} Floor"
+ elsif unit
+ "Unit #{unit}"
+ else
+ "Floor Lease"
+ end
end
end
@@ -168,11 +184,11 @@
hash[:photo_ids] = photos.map(&:id) if photos
hash
end
def to_param
- [address.state, address.city, address.name, id.to_s].map(&:parameterize).join('/')
+ "#{address.to_param}/#{id}"
end
def import #TODO test me
result = :failure
MLS.post('/import', {:listing => to_hash}, 400) do |response, code|
@@ -195,17 +211,21 @@
def url
"#{address.url}/#{id}"
end
+ def all_photos
+ photos + address.photos
+ end
+
class << self
def find(id)
response = MLS.get("/listings/#{id}")
MLS::Listing::Parser.parse(response.body)
end
- def all(filters = {}, limit = nil, order = nil)
+ def all(filters = {}, limit = nil, order = 'listings.id')
response = MLS.get('/listings', :filters => filters, :limit => limit, :order => order)
MLS::Listing::Parser.parse_collection(response.body)
end
def import(attrs)