Class: Todoist::Misc::Templates
- Includes:
- Util
- Defined in:
- lib/todoist/misc/templates.rb
Instance Method Summary collapse
-
#export_as_file(project) ⇒ Object
Export the project as a CSV string.
-
#export_as_url(project) ⇒ Object
Export the project as a url that can be accessed over HTTP.
-
#import_into_project(project, file) ⇒ Object
Given a project and a File object (Ruby) imports the content onto the server.
Methods inherited from Service
Constructor Details
This class inherits a constructor from Todoist::Service
Instance Method Details
#export_as_file(project) ⇒ Object
Export the project as a CSV string
17 18 19 20 |
# File 'lib/todoist/misc/templates.rb', line 17 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_as_url(project) ⇒ Object
Export the project as a url that can be accessed over HTTP
23 24 25 26 |
# File 'lib/todoist/misc/templates.rb', line 23 def export_as_url(project) params = {project_id: project.id} @client.api_helper.get_response(Config::TODOIST_TEMPLATES_EXPORT_AS_URL_COMMAND, params) end |
#import_into_project(project, file) ⇒ Object
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.
10 11 12 13 14 |
# File 'lib/todoist/misc/templates.rb', line 10 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 |