lib/mls/models/listing.rb in mls-0.2.9.1 vs lib/mls/models/listing.rb in mls-0.2.10

- old
+ new

@@ -60,14 +60,12 @@ property :created_at, DateTime, :serialize => :false property :updated_at, DateTime, :serialize => :false property :leased_on, DateTime - property :flyer_id, Fixnum, :serialize => :if_present - property :avatar_digest, String, :serialize => false - attr_accessor :address, :agents, :account, :photos, :flyer, :floor_plan, :videos + attr_accessor :address, :agents, :account, :photos, :flyer, :floor_plan attr_writer :amenities def avatar(size='150x100', protocol='http') if avatar_digest "#{protocol}://#{MLS.asset_host}/photos/#{size}/#{avatar_digest}.jpg" @@ -133,12 +131,13 @@ # listing.request_tour('name', 'email@address.com', info) # => #<MLS::TourRequest> # # listing.request_tour('', 'emai', info) # => #<MLS::TourRequest> will have errors on account def request_tour(account, tour={}) params = {:account => account, :tour => tour} - response = MLS.post("/listings/#{id}/tour_requests", params) - return MLS::TourRequest::Parser.parse(response.body) + MLS.post("/listings/#{id}/tour_requests", params, 400) do |response, code| + return MLS::TourRequest::Parser.parse(response.body) + end end def create MLS.post('/listings', {:listing => to_hash}, 201, 400) do |response, code| @@ -162,11 +161,10 @@ def to_hash hash = super hash[:address_attributes] = address.to_hash if address hash[:agents_attributes] = agents.inject({}) { |acc, x| acc[acc.length] = x.to_hash; acc } if agents hash[:photo_ids] = photos.map(&:id) if photos - hash[:videos_attributes] = videos.map(&:to_hash) if videos hash end def to_param "#{address.to_param}/#{id}" @@ -198,23 +196,18 @@ def all_photos photos + address.photos end - def all_videos - videos + address.videos - end - def amenities MLS.listing_amenities end class << self def find(id) response = MLS.get("/listings/#{id}") - puts response.body MLS::Listing::Parser.parse(response.body) end def all(filters = {}, limit = nil, order = 'listings.id') response = MLS.get('/listings', :filters => filters, :limit => limit, :order => order) @@ -239,15 +232,9 @@ class MLS::Listing::Parser < MLS::Parser def photos=(photos) @object.photos = photos.map do |p| MLS::Photo.new(:digest => p[:digest], :id => p[:id].to_i) - end - end - - def videos=(videos) - @object.videos = videos.map do |video| - MLS::Video::Parser.build(video) end end def floor_plan=(floor_plan) @object.floor_plan = MLS::PDF.new(:digest => floor_plan[:digest], :id => floor_plan[:id].to_i,