Sha256: cc5ff2d4b28633ac74417a10327eccf939a744dfa2ce1c9de7787842b0daa9bc

Contents?: true

Size: 981 Bytes

Versions: 3

Compression:

Stored size: 981 Bytes

Contents

module Todoist
  module Misc
    class Uploads
        include Todoist::Util  
        
        # Uploads a file given a Ruby File.
        def add(file)
          multipart_file = NetworkHelper.multipart_file(file)
          params = {file_name: File.basename(file), file: multipart_file}
          NetworkHelper.getMultipartResponse(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
          NetworkHelper.getResponse(Config::TODOIST_UPLOADS_GET_COMMAND, params)
        end
        
        # Deletes an upload given a file URL.
        def delete(file_url)
          params = {file_url: file_url}
          NetworkHelper.getResponse(Config::TODOIST_UPLOADS_DELETE_COMMAND, params)
        end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
todoist-ruby-0.1.3 lib/todoist/misc/uploads.rb
todoist-ruby-0.1.2 lib/todoist/misc/uploads.rb
todoist-ruby-0.1.1 lib/todoist/misc/uploads.rb