lib/ruby_lokalise_api/rest/tasks.rb in ruby-lokalise-api-7.2.0 vs lib/ruby_lokalise_api/rest/tasks.rb in ruby-lokalise-api-8.0.0.rc1

- old
+ new

@@ -1,58 +1,80 @@ # frozen_string_literal: true module RubyLokaliseApi module Rest module Tasks - # Returns all tasks for the given project + # Returns project tasks # # @see https://developers.lokalise.com/reference/list-all-tasks - # @return [RubyLokaliseApi::Collection::Task<RubyLokaliseApi::Resources::Task>] + # @return [RubyLokaliseApi::Collections::Tasks] # @param project_id [String] - # @param params [Hash] - def tasks(project_id, params = {}) - c_r RubyLokaliseApi::Collections::Task, :all, project_id, params + # @param req_params [Hash] + def tasks(project_id, req_params = {}) + name = 'Tasks' + params = { query: project_id, req: req_params } + + data = endpoint(name: name, params: params).do_get + + collection name, data end - # Returns a single task for the given project + # Returns a single task # # @see https://developers.lokalise.com/reference/retrieve-a-task # @return [RubyLokaliseApi::Resources::Task] # @param project_id [String] # @param task_id [String, Integer] - def task(project_id, task_id) - c_r RubyLokaliseApi::Resources::Task, :find, [project_id, task_id] + # @param req_params[Hash] + def task(project_id, task_id, req_params = {}) + params = { query: [project_id, task_id], req: req_params } + + data = endpoint(name: 'Tasks', params: params).do_get + + resource 'Task', data end - # Creates task for the given project + # Creates a new task # # @see https://developers.lokalise.com/reference/create-a-task # @return [RubyLokaliseApi::Resources::Task] # @param project_id [String] - # @param params [Hash] - def create_task(project_id, params) - c_r RubyLokaliseApi::Resources::Task, :create, project_id, params + # @param req_params [Hash, Array] + def create_task(project_id, req_params) + params = { query: project_id, req: req_params } + + data = endpoint(name: 'Tasks', params: params).do_post + + resource 'Task', data end - # Updates task for the given project + # Updates a task # # @see https://developers.lokalise.com/reference/update-a-task # @return [RubyLokaliseApi::Resources::Task] # @param project_id [String] # @param task_id [String, Integer] - # @param params [Hash] - def update_task(project_id, task_id, params = {}) - c_r RubyLokaliseApi::Resources::Task, :update, [project_id, task_id], params + # @param req_params [Hash] + def update_task(project_id, task_id, req_params = {}) + params = { query: [project_id, task_id], req: req_params } + + data = endpoint(name: 'Tasks', params: params).do_put + + resource 'Task', data end - # Deletes task for the given project + # Deletes a task # # @see https://developers.lokalise.com/reference/delete-a-task - # @return [Hash] + # @return [RubyLokaliseApi::Generics::DeletedResource] # @param project_id [String] # @param task_id [String, Integer] def destroy_task(project_id, task_id) - c_r RubyLokaliseApi::Resources::Task, :destroy, [project_id, task_id] + params = { query: [project_id, task_id] } + + data = endpoint(name: 'Tasks', params: params).do_delete + + RubyLokaliseApi::Generics::DeletedResource.new data.content end end end end