Sha256: 758b5c4ae12c6a21a031eb333797e91e6708f8ab70b5f5314f62e3fc5e2728e2

Contents?: true

Size: 1.15 KB

Versions: 8

Compression:

Stored size: 1.15 KB

Contents

module Whatser
  class Media < Whatser::Resource
    attr_accessor :id,:user_id,:poi_id
    attr_accessor :name,:thumb_pic,:small_pic,:mid_pic,:url,:mime,:created_at
    attr_writer   :resource,:remote_resource
    
    class << self
      def list(poi_id, opts={})
        api_request :get, "/api/poi/#{poi_id}/media", {:query => opts}
      end
              
      def find(poi_id, id, opts={})
        api_request :get, "/api/poi/#{poi_id}/media/#{id}", {:query => opts}
      end
      
      def create(poi_id, params={})
        api_request :post, "/api/poi/#{poi_id}/media", {:body => {'media' => params} }
      end  
      
      def delete(poi_id, id)
        api_request :delete, "/api/poi/#{poi_id}/media/#{id}"
      end              
    end
    
    def save
      if id.blank?
        Whatser::Media.create(poi_id, to_params)
      else
        api_request :put, "/api/poi/#{poi_id}/media/#{id}", {:body => {'media' => to_params} }
      end
    end           
    
    def delete
      Whatser::Media.delete(poi_id, id)
    end       
    
    def to_params
      {:name=>name,:resource=>@resource,:remote_resource=>@remote_resource}
    end      
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
whatser-0.6.1 lib/whatser/resources/media.rb
whatser-0.6.0 lib/whatser/resources/media.rb
whatser-0.5.0 lib/whatser/resources/media.rb
whatser-0.4.0 lib/whatser/resources/media.rb
whatser-0.3.2 lib/whatser/resources/media.rb
whatser-0.3.1 lib/whatser/resources/media.rb
whatser-0.3.0 lib/whatser/resources/media.rb
whatser-0.2.0 lib/whatser/resources/media.rb