Permalink
Browse files

Adding Listing amenities property

  • Loading branch information...
1 parent 61dcd60 commit 61a15ed98839f38dcc866cfc30274e8138581198 @waratuman waratuman committed Jul 26, 2013
Showing with 14 additions and 25 deletions.
  1. +1 −11 lib/mls.rb
  2. +5 −5 lib/mls/models/address.rb
  3. +6 −7 lib/mls/models/listing.rb
  4. +1 −1 lib/mls/properties/hash.rb
  5. +1 −1 mls.gemspec
View
12 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',
View
10 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
View
13 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
View
2 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
View
2 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"

0 comments on commit 61a15ed

Please sign in to comment.