Sha256: 79a59efc206bc801262597a351debd404b8164cc0f6b29f54ea5847771836eec

Contents?: true

Size: 1.16 KB

Versions: 3

Compression:

Stored size: 1.16 KB

Contents

module Todoist
  module Misc
    class Templates
        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 = NetworkHelper.multipart_file(file)
          params = {project_id: project.id, file: multipart_file}
          NetworkHelper.getMultipartResponse(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}
          NetworkHelper.getResponse(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}
          NetworkHelper.getResponse(Config::TODOIST_TEMPLATES_EXPORT_AS_URL_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/templates.rb
todoist-ruby-0.1.2 lib/todoist/misc/templates.rb
todoist-ruby-0.1.1 lib/todoist/misc/templates.rb