Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix inserting task at top/bottom of project #113

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
8 changes: 6 additions & 2 deletions lib/asana/resources/task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,7 @@ def projects(per_page: 20, options: {})
#
# Returns an empty data block.
#

# project - [Gid] The project to add the task to.
# insert_after - [Gid] A task in the project to insert the task after, or `null` to
# insert at the beginning of the list.
Expand All @@ -393,8 +394,10 @@ def projects(per_page: 20, options: {})
#
# options - [Hash] the request I/O options.
# data - [Hash] the attributes to post.
def add_project(project: required("project"), insert_after: nil, insert_before: nil, section: nil, options: {}, **data)
with_params = data.merge(project: project, insert_after: insert_after, insert_before: insert_before, section: section).reject { |_,v| v.nil? || Array(v).empty? }
def add_project(project: required("project"), insert_after: :not_provided, insert_before: :not_provided, section: nil, options: {}, **data)
with_params = data.merge(project: project, insert_after: insert_after, insert_before: insert_before, section: section).reject { |_,v| v.nil? || Array(v).empty? || v == :not_provided }
with_params[:insert_after] = nil if insert_after.nil?
with_params[:insert_before] = nil if insert_before.nil?
client.post("/tasks/#{gid}/addProject", body: with_params, options: options) && true
end

Expand Down Expand Up @@ -475,6 +478,7 @@ def add_subtask(options: {}, **data)
# data - [Hash] the attributes to post.
def set_parent(parent: required("parent"), insert_after: nil, insert_before: nil, options: {}, **data)
with_params = data.merge(parent: parent, insert_after: insert_after, insert_before: insert_before).reject { |_,v| v.nil? || Array(v).empty? }
with_params[:parent] = nil if parent.nil?
client.post("/tasks/#{gid}/setParent", body: with_params, options: options) && true
end

Expand Down