Class: MLS::Tour

Inherits:
Resource show all
Defined in:
lib/mls/models/tour.rb

Defined Under Namespace

Classes: Parser

Instance Attribute Summary collapse

Attributes inherited from Resource

#errors, #persisted

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Resource

#==, #create!, inherited, #initialize, #new_record?, #persisted?, #properties, #properties_excluded_from_comparison, #properties_for_comparison, #save, #save!, #set_default_values, #to_hash, #to_key, #update!, #update_attributes

Constructor Details

This class inherits a constructor from MLS::Resource

Instance Attribute Details

#clientObject

Returns the value of attribute client.



13
14
15
# File 'lib/mls/models/tour.rb', line 13

def client
  @client
end

#listingObject

Returns the value of attribute listing.



13
14
15
# File 'lib/mls/models/tour.rb', line 13

def listing
  @listing
end

Class Method Details

.create(listing_id, account, tour = {}) ⇒ Object



52
53
54
55
56
# File 'lib/mls/models/tour.rb', line 52

def create(listing_id, , tour={})
  params = {:account => , :tour => tour}
  response = MLS.post("/listings/#{listing_id}/tours", params)
  return MLS::Tour::Parser.parse(response.body)
end

.find_by_token(token) ⇒ Object



47
48
49
50
# File 'lib/mls/models/tour.rb', line 47

def find_by_token(token)
  response = MLS.get("/tours/#{token}")
  MLS::Tour::Parser.parse(response.body)
end

.get_all_for_accountObject



42
43
44
45
# File 'lib/mls/models/tour.rb', line 42

def 
  response = MLS.get('/account/tours')
  MLS::Tour::Parser.parse_collection(response.body)
end

Instance Method Details

#claim(agent) ⇒ Object



15
16
17
18
# File 'lib/mls/models/tour.rb', line 15

def claim(agent)
  self.agent_id = agent.id
  MLS.post("/tours/#{token}/claim", {:agent_id => agent.id})
end

#claimed?Boolean

Returns:



33
34
35
# File 'lib/mls/models/tour.rb', line 33

def claimed?
  status == "claimed"
end

#decline(notes = nil) ⇒ Object



20
21
22
23
# File 'lib/mls/models/tour.rb', line 20

def decline(notes=nil)
  self.agent_comments = notes
  MLS.post("/tours/#{token}/decline", {:agent_comments => notes})
end

#declined?Boolean

Returns:



37
38
39
# File 'lib/mls/models/tour.rb', line 37

def declined?
  status == "declined"
end

#viewObject



25
26
27
# File 'lib/mls/models/tour.rb', line 25

def view
  MLS.post("/tours/#{token}/view")
end

#viewed?Boolean

Returns:



29
30
31
# File 'lib/mls/models/tour.rb', line 29

def viewed?
  status != "new"
end