Sha256: a8130a7d3f09c039a9d8ab7d84a8115ae88a399c37c9a8591b65439b07059464

Contents?: true

Size: 1.02 KB

Versions: 5

Compression:

Stored size: 1.02 KB

Contents

module Whatser
  class Review < Whatser::Resource
    attr_accessor :id,:user_id,:poi_id
    attr_accessor :body,:created_at
    
    class << self
      def list(poi_id, opts={})
        api_request :get, "/api/poi/#{poi_id}/reviews", {:query => opts}
      end
              
      def find(poi_id, id, opts={})
        api_request :get, "/api/poi/#{poi_id}/reviews/#{id}", {:query => opts}
      end
      
      def create(poi_id, params={})
        api_request :post, "/api/poi/#{poi_id}/reviews", {:body => {'review' => params} }
      end
      
      def delete(poi_id, id)
        api_request :delete, "/api/poi/#{poi_id}/reviews/#{id}"
      end               
    end      
    
    def save
      if id.blank?
        self.class.create(poi_id, to_params)
      else
        api_request :put, "/api/poi/#{poi_id}/reviews/#{id}", {:body => {'review' => to_params} }
      end
    end           
    
    def delete
      self.class.delete(poi_id, id)
    end       
    
    def to_params
      {:body => body}
    end      
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
whatser-0.4.0 lib/whatser/resources/review.rb
whatser-0.3.2 lib/whatser/resources/review.rb
whatser-0.3.1 lib/whatser/resources/review.rb
whatser-0.3.0 lib/whatser/resources/review.rb
whatser-0.2.0 lib/whatser/resources/review.rb