Permalink
Browse files

Support for videos

Updated Gemspec.
  • Loading branch information...
1 parent db50de5 commit cf87d07c1892a90b5cef20239b0c01391fe38719 @dana11235 dana11235 committed Dec 31, 2012
Showing with 41 additions and 3 deletions.
  1. +1 −0 lib/mls.rb
  2. +14 −1 lib/mls/models/address.rb
  3. +13 −1 lib/mls/models/listing.rb
  4. +12 −0 lib/mls/models/video.rb
  5. +1 −1 mls.gemspec
View
@@ -419,6 +419,7 @@ def self.parse(json) # TODO: testme
require 'mls/models/listing'
require 'mls/models/address'
require 'mls/models/photo'
+require 'mls/models/video'
require 'mls/models/pdf'
require 'mls/models/tour_request'
require 'mls/models/flyer'
@@ -48,7 +48,7 @@ class MLS::Address < MLS::Resource
property :avatar_digest, String, :serialize => false
- attr_accessor :listings, :listing_kinds, :photos
+ attr_accessor :listings, :listing_kinds, :photos, :videos
# should include an optional use address or no_image image
def avatar(size='100x200', protocol='http')
@@ -81,6 +81,7 @@ def save
def to_hash
hash = super
hash[:photo_ids] = photos.map(&:id) if photos
+ hash[:videos_attributes] = videos.map(&:to_hash) if videos
hash
end
@@ -114,6 +115,12 @@ def amenities
MLS.address_amenities
end
+ def find_listings(space_available, floor, unit)
+ response = MLS.get("/addresses/#{id}/find_listings",
+ :floor => floor, :unit => unit, :space_available => space_available)
+ MLS::Listing::Parser.parse_collection(response.body)
+ end
+
class << self
def query(q)
@@ -161,4 +168,10 @@ def photos=(photos)
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
end
@@ -65,7 +65,7 @@ class MLS::Listing < MLS::Resource
property :flyer_id, Fixnum, :serialize => :if_present
property :avatar_digest, String, :serialize => false
- attr_accessor :address, :agents, :account, :photos, :flyer, :floor_plan
+ attr_accessor :address, :agents, :account, :photos, :flyer, :floor_plan, :videos
attr_writer :amenities
def avatar(size='150x100', protocol='http')
@@ -164,6 +164,7 @@ def to_hash
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
@@ -199,6 +200,10 @@ def all_photos
photos + address.photos
end
+ def all_videos
+ videos + address.videos
+ end
+
def amenities
MLS.listing_amenities
end
@@ -207,6 +212,7 @@ class << self
def find(id)
response = MLS.get("/listings/#{id}")
+ puts response.body
MLS::Listing::Parser.parse(response.body)
end
@@ -238,6 +244,12 @@ def photos=(photos)
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,
:file_url => floor_plan[:file_url], :type => :floor_plan)
@@ -0,0 +1,12 @@
+class MLS::Video < MLS::Resource
+ property :id, Fixnum
+ property :vts_key, String
+ property :video_type, String
+ property :subject_type, String
+ property :created_at, DateTime, :serialize => :if_present
+ property :updated_at, DateTime, :serialize => :if_present
+end
+
+class MLS::Video::Parser < MLS::Parser
+
+end
View
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
Gem::Specification.new do |s|
s.name = "mls"
- s.version = '0.2.9'
+ s.version = '0.2.9.1'
s.authors = ["James R. Bracy"]
s.email = ["james@42floors.com"]
s.homepage = "http://mls.42floors.com"

0 comments on commit cf87d07

Please sign in to comment.