Skip to content
Browse files

Add arbitrary attributes to tour requests.

  • Loading branch information...
1 parent 7bfa2d2 commit 875675845c742b28ce9a6569339ac517fe6f09e1 @dana11235 dana11235 committed Jan 16, 2013
Showing with 17 additions and 6 deletions.
  1. +1 −3 lib/mls/models/listing.rb
  2. +15 −2 lib/mls/models/tour_request.rb
  3. +1 −1 mls.gemspec
View
4 lib/mls/models/listing.rb
@@ -139,9 +139,7 @@ def space_name
#
# 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::TourRequest.create(id, account, tour)
end
View
17 lib/mls/models/tour_request.rb
@@ -12,12 +12,12 @@ class MLS::TourRequest < MLS::Resource
property :status, String
property :reasons_to_decline, String, :serialize => :if_present
- property :token, String, :serialize => :false
+ property :token, String, :serialize => :false
property :created_at, DateTime, :serialize => :false
property :updated_at, DateTime, :serialize => :false
- attr_accessor :account, :listing
+ attr_accessor :account, :listing, :additional_features
def claim(agent)
MLS.post("/tour_requests/#{token}/claim", {:agent_id => agent.id}) do |response, code|
@@ -50,6 +50,12 @@ def declined?
status == "declined"
end
+ def to_hash
+ hash = super
+ hash[:additional_features_attributes] = additional_features.to_hash if additional_features
+ hash
+ end
+
class << self
def get_all_for_account
response = MLS.get('/account/tour_requests')
@@ -58,8 +64,15 @@ def get_all_for_account
def find_by_token(token)
response = MLS.get("/tour_requests/#{token}")
+ puts response.body
MLS::TourRequest::Parser.parse(response.body)
end
+
+ def create(listing_id, account, tour={})
+ params = {:account => account, :tour => tour}
+ response = MLS.post("/listings/#{listing_id}/tour_requests", params)
+ return MLS::TourRequest::Parser.parse(response.body)
+ end
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.2.20'
+ s.version = '0.2.21'
s.authors = ["James R. Bracy"]
s.email = ["james@42floors.com"]
s.homepage = "http://mls.42floors.com"

0 comments on commit 8756758

Please sign in to comment.
Something went wrong with that request. Please try again.