Sha256: 486724fc31492b84542936e8f322ea10368e30610c655c50f3782ba6b28f31db

Contents?: true

Size: 1.21 KB

Versions: 7

Compression:

Stored size: 1.21 KB

Contents

module Todoist
  module Misc
    class Templates < Todoist::Service
        include Todoist::Util  
        
        # Given a project and a File object (Ruby) imports the content onto the
        # server.  Critically, if the file is a CSV file make sure that the 
        # suffix is CSV.  Otherwise, the file will be parsed as one item per line
        # and ignore the formatting altogether.
        def import_into_project(project, file)
          multipart_file = @client.api_helper.multipart_file(file)
          params = {project_id: project.id, file: multipart_file}
          @client.api_helper.get_multipart_response(Config::TODOIST_TEMPLATES_IMPORT_INTO_PROJECT_COMMAND, params)
        end
        
        # Export the project as a CSV string
        def export_as_file(project)
          params = {project_id: project.id}
          @client.api_helper.get_response(Config::TODOIST_TEMPLATES_EXPORT_AS_FILE_COMMAND, params)
        end
        
        # Export the project as a url that can be accessed over HTTP
        def export_as_url(project)
          params = {project_id: project.id}
          @client.api_helper.get_response(Config::TODOIST_TEMPLATES_EXPORT_AS_URL_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/templates.rb
todoist-ruby-0.2.6 lib/todoist/misc/templates.rb
todoist-ruby-0.2.5 lib/todoist/misc/templates.rb
todoist-ruby-0.2.4 lib/todoist/misc/templates.rb
todoist-ruby-0.2.3 lib/todoist/misc/templates.rb
todoist-ruby-0.2.2 lib/todoist/misc/templates.rb
todoist-ruby-0.2.1 lib/todoist/misc/templates.rb