Permalink
Browse files

Add token, and add ability to mark as viewed.

  • Loading branch information...
1 parent 373bbc6 commit 01db67edbe02041b69348324eb175538514942fe @dana11235 dana11235 committed Jan 14, 2013
Showing with 17 additions and 7 deletions.
  1. +17 −7 lib/mls/models/tour_request.rb
@@ -12,32 +12,42 @@ class MLS::TourRequest < MLS::Resource
property :status, String
property :reasons_to_decline, String, :serialize => :if_present
- property :random_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
def claim(agent)
- MLS.post("/tour_requests/#{id}/claim", {:agent_id => agent.id}) do |response, code|
+ MLS.post("/tour_requests/#{token}/claim", {:agent_id => agent.id}) do |response, code|
return code == 200
end
end
def decline(agent, reasons=nil)
- MLS.post("/tour_requests/#{id}/decline",
+ MLS.post("/tour_requests/#{token}/decline",
{:agent_id => agent.id, :reasons_to_decline => reasons}) do |response, code|
return code == 200
end
end
+ def mark_viewed(agent)
+ MLS.post("/tour_requests/#{token}/mark_viewed", {:agent_id => agent.id}) do |response, code|
+ return code == 200
+ end
+ end
+
+ def viewed?
+ status != "new"
+ end
+
def claimed?
- status == "CLAIMED"
+ status == "claimed"
end
def declined?
- status == "DECLINED"
+ status == "declined"
end
class << self
@@ -46,8 +56,8 @@ def get_all_for_account
MLS::TourRequest::Parser.parse_collection(response.body)
end
- def find(id)
- response = MLS.get("/tour_requests/#{id}")
+ def find_by_token(token)
+ response = MLS.get("/tour_requests/#{token}")
MLS::TourRequest::Parser.parse(response.body)
end
end

0 comments on commit 01db67e

Please sign in to comment.