diff --git a/lib/mls.rb b/lib/mls.rb index 2f6f72b..afc7d53 100644 --- a/lib/mls.rb +++ b/lib/mls.rb @@ -24,7 +24,7 @@ class MLS API_VERSION = '0.1.0' attr_reader :url, :user_agent - attr_writer :asset_host, :image_host, :agent_profile, :listing_amenities, :address_amenities + attr_writer :asset_host, :image_host, :agent_profile attr_accessor :api_key, :auth_key, :logger # Sets the API Token and Host of the MLS Server @@ -67,21 +67,11 @@ def raw_image_host @image_host ||= get('/image_host').body end - def listing_amenities - @listing_amenities ||= Yajl::Parser.new(:symbolize_keys => true) - .parse(MLS.get('/listings/amenities').body) - end - def agent_profile(id) @agent_profile = Yajl::Parser.new(:symbolize_keys => true) .parse(MLS.get("/agents/#{id}").body) end - def address_amenities - @address_amenities ||= Yajl::Parser.new(:symbolize_keys => true) - .parse(MLS.get('/addresses/amenities').body) - end - def headers # TODO: testme h = { 'Content-Type' => 'application/json', diff --git a/lib/mls/models/address.rb b/lib/mls/models/address.rb index 692b03f..bd34a21 100644 --- a/lib/mls/models/address.rb +++ b/lib/mls/models/address.rb @@ -108,10 +108,6 @@ def url "http://#{host}/#{slug}" end - 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) @@ -135,7 +131,11 @@ def all(options={}) response = MLS.get('/addresses', options) MLS::Address::Parser.parse_collection(response.body) end - + + def amenities + @amenities ||= Yajl::Parser.new(:symbolize_keys => true).parse(MLS.get('/addresses/amenities').body) + end + end end diff --git a/lib/mls/models/listing.rb b/lib/mls/models/listing.rb index 07d30a4..bf5a088 100644 --- a/lib/mls/models/listing.rb +++ b/lib/mls/models/listing.rb @@ -32,7 +32,8 @@ class MLS::Listing < MLS::Resource property :size, Fixnum property :maximum_contiguous_size, Fixnum property :minimum_divisible_size, Fixnum - + + property :amenities, Hash property :lease_terms, String property :rate, Decimal property :rate_units, String, :default => '/sqft/mo' @@ -85,7 +86,6 @@ class MLS::Listing < MLS::Resource property :photos_count, Fixnum, :serialize => :false attr_accessor :address, :agents, :account, :photos, :flyer, :floorplan, :videos - attr_writer :amenities def avatar(size='150x100#', protocol='http') if avatar_digest @@ -227,11 +227,6 @@ def all_videos videos + address.videos end - # TODO: Remove / What does this function do? - def amenities - MLS.listing_amenities - end - def similar [] # Similar Listings not supported for now end @@ -259,6 +254,10 @@ def calculate(filters = {}, operation = nil, column = nil, group = nil) MLS::Parser.extract_attributes(response.body)[:listings] end + def amenities + @amenities ||= Yajl::Parser.new(:symbolize_keys => true).parse(MLS.get('/listings/amenities').body) + end + end end diff --git a/lib/mls/properties/hash.rb b/lib/mls/properties/hash.rb index ae38813..105b282 100644 --- a/lib/mls/properties/hash.rb +++ b/lib/mls/properties/hash.rb @@ -1,7 +1,7 @@ class MLS::Property::Hash < MLS::Property def load(value) # from_json - value + value.with_indifferent_access end end diff --git a/mls.gemspec b/mls.gemspec index 4c347f1..8102ab5 100644 --- a/mls.gemspec +++ b/mls.gemspec @@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__) Gem::Specification.new do |s| s.name = "mls" - s.version = '0.5.10' + s.version = '0.5.11' s.authors = ["James R. Bracy", "Jon Bracy"] s.email = ["james@42floors.com"] s.homepage = "http://mls.42floors.com"