Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Add arbitrary attributes to tour requests.

  • Loading branch information...
commit 875675845c742b28ce9a6569339ac517fe6f09e1 1 parent 7bfa2d2
Dana Levine dana11235 authored
4 lib/mls/models/listing.rb
@@ -139,9 +139,7 @@ def space_name
139 139 #
140 140 # listing.request_tour('', 'emai', info) # => #<MLS::TourRequest> will have errors on account
141 141 def request_tour(account, tour={})
142   - params = {:account => account, :tour => tour}
143   - response = MLS.post("/listings/#{id}/tour_requests", params)
144   - return MLS::TourRequest::Parser.parse(response.body)
  142 + MLS::TourRequest.create(id, account, tour)
145 143 end
146 144
147 145
17 lib/mls/models/tour_request.rb
@@ -12,12 +12,12 @@ class MLS::TourRequest < MLS::Resource
12 12 property :status, String
13 13 property :reasons_to_decline, String, :serialize => :if_present
14 14
15   - property :token, String, :serialize => :false
  15 + property :token, String, :serialize => :false
16 16
17 17 property :created_at, DateTime, :serialize => :false
18 18 property :updated_at, DateTime, :serialize => :false
19 19
20   - attr_accessor :account, :listing
  20 + attr_accessor :account, :listing, :additional_features
21 21
22 22 def claim(agent)
23 23 MLS.post("/tour_requests/#{token}/claim", {:agent_id => agent.id}) do |response, code|
@@ -50,6 +50,12 @@ def declined?
50 50 status == "declined"
51 51 end
52 52
  53 + def to_hash
  54 + hash = super
  55 + hash[:additional_features_attributes] = additional_features.to_hash if additional_features
  56 + hash
  57 + end
  58 +
53 59 class << self
54 60 def get_all_for_account
55 61 response = MLS.get('/account/tour_requests')
@@ -58,8 +64,15 @@ def get_all_for_account
58 64
59 65 def find_by_token(token)
60 66 response = MLS.get("/tour_requests/#{token}")
  67 + puts response.body
61 68 MLS::TourRequest::Parser.parse(response.body)
62 69 end
  70 +
  71 + def create(listing_id, account, tour={})
  72 + params = {:account => account, :tour => tour}
  73 + response = MLS.post("/listings/#{listing_id}/tour_requests", params)
  74 + return MLS::TourRequest::Parser.parse(response.body)
  75 + end
63 76 end
64 77 end
65 78
2  mls.gemspec
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
3 3
4 4 Gem::Specification.new do |s|
5 5 s.name = "mls"
6   - s.version = '0.2.20'
  6 + s.version = '0.2.21'
7 7 s.authors = ["James R. Bracy"]
8 8 s.email = ["james@42floors.com"]
9 9 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.