Sha256: 2b194923172c90378acbf929ca73746109e0841ab418c42814184b2aa2c0eef6

Contents?: true

Size: 1 KB

Versions: 7

Compression:

Stored size: 1 KB

Contents

module Todoist
  module Misc
    class Uploads < Todoist::Service
        include Todoist::Util  
        
        # Uploads a file given a Ruby File.
        def add(file)
          multipart_file = @client.api_helper.multipart_file(file)
          params = {file_name: File.basename(file), file: multipart_file}
          @client.api_helper.get_multipart_response(Config::TODOIST_UPLOADS_ADD_COMMAND, params)
        end
        
        # Get uploads up to limit.  If last_id is entered, then the results list 
        # everything from that ID forward.
        def get(limit = 30, last_id = 0)
          params = {limit: limit}
          params["last_id"] = last_id if last_id
          @client.api_helper.get_response(Config::TODOIST_UPLOADS_GET_COMMAND, params)
        end
        
        # Deletes an upload given a file URL.
        def delete(file_url)
          params = {file_url: file_url}
          @client.api_helper.get_response(Config::TODOIST_UPLOADS_DELETE_COMMAND, params)
        end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
todoist-ruby-0.2.7 lib/todoist/misc/uploads.rb
todoist-ruby-0.2.6 lib/todoist/misc/uploads.rb
todoist-ruby-0.2.5 lib/todoist/misc/uploads.rb
todoist-ruby-0.2.4 lib/todoist/misc/uploads.rb
todoist-ruby-0.2.3 lib/todoist/misc/uploads.rb
todoist-ruby-0.2.2 lib/todoist/misc/uploads.rb
todoist-ruby-0.2.1 lib/todoist/misc/uploads.rb