Skip to content

Commit

Permalink
Adding Listing amenities property
Browse files Browse the repository at this point in the history
  • Loading branch information
waratuman committed Jul 26, 2013
1 parent 61dcd60 commit 61a15ed
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 25 deletions.
12 changes: 1 addition & 11 deletions lib/mls.rb
Expand Up @@ -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
Expand Down Expand Up @@ -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',
Expand Down
10 changes: 5 additions & 5 deletions lib/mls/models/address.rb
Expand Up @@ -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)
Expand All @@ -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
Expand Down
13 changes: 6 additions & 7 deletions lib/mls/models/listing.rb
Expand Up @@ -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'
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion 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
2 changes: 1 addition & 1 deletion mls.gemspec
Expand Up @@ -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"
Expand Down

0 comments on commit 61a15ed

Please sign in to comment.