Sha256: 1e8bafc15ccd198e22c04057dc004fbbd3fb6c6a3363efcd3a46525c704f33df

Contents?: true

Size: 1.11 KB

Versions: 2

Compression:

Stored size: 1.11 KB

Contents

class MLS::TourRequest < MLS::Resource
  property :message,                         String

  attr_accessor :listing

  class << self
    def get_all_for_account
      MLS.get('/account/tour_requests') do |code, response|
        case code
        when 400
          @errors = MLS.parse(response.body)[:errors]
          return false
        else
          MLS.handle_response(response)
          return MLS::TourRequest::Parser.parse_collection(response.body)
        end
      end
    end

    def create(listing_id, message, account_params={})
      params = account_params
      params[:id] = listing_id
      params[:message] = message
      MLS.post('/account/tour_requests', params) do |code, response|
        case code
        when 400
          @errors = MLS.parse(response.body)[:errors]
          return false
        else
          MLS.handle_response(response)
          return true
        end
      end
    end
  end
end

class MLS::TourRequest::Parser < MLS::Parser
  
  def listing=(listing)
    @object.listing = MLS::Listing::Parser.build(listing)
  end

  def self.collection_root_element
    :tour_requests
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mls-0.2.2 lib/mls/models/tour_request.rb
mls-0.2.1 lib/mls/models/tour_request.rb