Sha256: 39fa8da18a607201d3c02663f5bb64b4ee3be8abbc8fafd51e1d62a941e109da

Contents?: true

Size: 1.53 KB

Versions: 16

Compression:

Stored size: 1.53 KB

Contents

class MLS::Tour < MLS::Resource
  property :id,                           Fixnum
  property :declined,                     Boolean
  property :client_id,                    Fixnum
  property :agent_id,                     Fixnum
  property :listing_id,                   Fixnum
  property :comments,                     String
  property :agent_comments,               String,    :serialize => :if_present
  property :token,                        String,    :serialize => :false
  property :created_at,                   DateTime,  :serialize => :false
  property :updated_at,                   DateTime,  :serialize => :false

  attr_accessor :client, :listing

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

  def declined?
    declined
  end

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

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

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

end

class MLS::Tour::Parser < MLS::Parser
  
  def listing=(listing)
    @object.listing = MLS::Listing::Parser.build(listing)
  end
  
  def client=(account)
    @object.client = MLS::Account::Parser.build(account)
  end

end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
mls-0.11.3 lib/mls/models/tour.rb
mls-0.11.2 lib/mls/models/tour.rb
mls-0.11.1 lib/mls/models/tour.rb
mls-0.11.0 lib/mls/models/tour.rb
mls-0.9.9 lib/mls/models/tour.rb
mls-0.9.8 lib/mls/models/tour.rb
mls-0.9.6 lib/mls/models/tour.rb
mls-0.9.5 lib/mls/models/tour.rb
mls-0.9.4 lib/mls/models/tour.rb
mls-0.9.3 lib/mls/models/tour.rb
mls-0.9.2 lib/mls/models/tour.rb
mls-0.9.1 lib/mls/models/tour.rb
mls-0.9.0 lib/mls/models/tour.rb
mls-0.8.2 lib/mls/models/tour.rb
mls-0.8.1 lib/mls/models/tour.rb
mls-0.8.0 lib/mls/models/tour.rb