Class: Asana::Resources::Task

Inherits:
TasksBase show all
Includes:
AttachmentUploading, EventSubscription
Defined in:
lib/asana/resources/task.rb

Overview

The task is the basic object around which many operations in Asana are centered. In the Asana application, multiple tasks populate the middle pane according to some view parameters, and the set of selected tasks determines the more detailed information presented in the details pane.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from EventSubscription

#events

Methods included from AttachmentUploading

#attach

Methods inherited from TasksBase

add_dependencies_for_task, add_dependents_for_task, add_followers_for_task, add_project_for_task, add_tag_for_task, create_subtask_for_task, create_task, delete_task, duplicate_task, get_dependencies_for_task, get_dependents_for_task, get_subtasks_for_task, get_task, get_tasks, get_tasks_for_project, get_tasks_for_section, get_tasks_for_tag, get_tasks_for_user_task_list, inherited, remove_dependencies_for_task, remove_dependents_for_task, remove_follower_for_task, remove_project_for_task, remove_tag_for_task, search_tasks_for_workspace, set_parent_for_task, update_task

Methods inherited from Resource

#initialize, #method_missing, #refresh, #respond_to_missing?, #to_h, #to_s

Methods included from ResponseHelper

#parse

Constructor Details

This class inherits a constructor from Asana::Resources::Resource

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Asana::Resources::Resource

Instance Attribute Details

#assigneeObject (readonly)



22
23
24
# File 'lib/asana/resources/task.rb', line 22

def assignee
  @assignee
end

#assignee_statusObject (readonly)



24
25
26
# File 'lib/asana/resources/task.rb', line 24

def assignee_status
  @assignee_status
end

#completedObject (readonly)



28
29
30
# File 'lib/asana/resources/task.rb', line 28

def completed
  @completed
end

#completed_atObject (readonly)



30
31
32
# File 'lib/asana/resources/task.rb', line 30

def completed_at
  @completed_at
end

#created_atObject (readonly)



26
27
28
# File 'lib/asana/resources/task.rb', line 26

def created_at
  @created_at
end

#custom_fieldsObject (readonly)



32
33
34
# File 'lib/asana/resources/task.rb', line 32

def custom_fields
  @custom_fields
end

#dependencies(options: {}) ⇒ Object (readonly)

Returns the compact representations of all of the dependencies of a task.

Parameters:

  • options (Hash) (defaults to: {})

    the request I/O options.



283
284
285
# File 'lib/asana/resources/task.rb', line 283

def dependencies
  @dependencies
end

#dependents(options: {}) ⇒ Object (readonly)

Returns the compact representations of all of the dependents of a task.

Parameters:

  • options (Hash) (defaults to: {})

    the request I/O options.



291
292
293
# File 'lib/asana/resources/task.rb', line 291

def dependents
  @dependents
end

#due_atObject (readonly)



40
41
42
# File 'lib/asana/resources/task.rb', line 40

def due_at
  @due_at
end

#due_onObject (readonly)



38
39
40
# File 'lib/asana/resources/task.rb', line 38

def due_on
  @due_on
end

#externalObject (readonly)



42
43
44
# File 'lib/asana/resources/task.rb', line 42

def external
  @external
end

#followersObject (readonly)



44
45
46
# File 'lib/asana/resources/task.rb', line 44

def followers
  @followers
end

#gidObject (readonly)



16
17
18
# File 'lib/asana/resources/task.rb', line 16

def gid
  @gid
end

#html_notesObject (readonly)



60
61
62
# File 'lib/asana/resources/task.rb', line 60

def html_notes
  @html_notes
end

#is_rendered_as_separatorObject (readonly)



46
47
48
# File 'lib/asana/resources/task.rb', line 46

def is_rendered_as_separator
  @is_rendered_as_separator
end

#likedObject (readonly)



48
49
50
# File 'lib/asana/resources/task.rb', line 48

def liked
  @liked
end

#likesObject (readonly)



50
51
52
# File 'lib/asana/resources/task.rb', line 50

def likes
  @likes
end

#membershipsObject (readonly)



52
53
54
# File 'lib/asana/resources/task.rb', line 52

def memberships
  @memberships
end

#modified_atObject (readonly)



54
55
56
# File 'lib/asana/resources/task.rb', line 54

def modified_at
  @modified_at
end

#nameObject (readonly)



56
57
58
# File 'lib/asana/resources/task.rb', line 56

def name
  @name
end

#notesObject (readonly)



58
59
60
# File 'lib/asana/resources/task.rb', line 58

def notes
  @notes
end

#num_likesObject (readonly)



62
63
64
# File 'lib/asana/resources/task.rb', line 62

def num_likes
  @num_likes
end

#num_subtasksObject (readonly)



64
65
66
# File 'lib/asana/resources/task.rb', line 64

def num_subtasks
  @num_subtasks
end

#parentObject (readonly)



66
67
68
# File 'lib/asana/resources/task.rb', line 66

def parent
  @parent
end

#projects(per_page: 20, options: {}) ⇒ Object (readonly)

Returns a compact representation of all of the projects the task is in.

Parameters:

  • per_page (Integer) (defaults to: 20)

    the number of records to fetch per page.

  • options (Hash) (defaults to: {})

    the request I/O options.



364
365
366
# File 'lib/asana/resources/task.rb', line 364

def projects
  @projects
end

#resource_subtypeObject (readonly)



20
21
22
# File 'lib/asana/resources/task.rb', line 20

def resource_subtype
  @resource_subtype
end

#resource_typeObject (readonly)



18
19
20
# File 'lib/asana/resources/task.rb', line 18

def resource_type
  @resource_type
end

#start_onObject (readonly)



70
71
72
# File 'lib/asana/resources/task.rb', line 70

def start_on
  @start_on
end

#tags(per_page: 20, options: {}) ⇒ Object (readonly)

Returns a compact representation of all of the tags the task has.

Parameters:

  • per_page (Integer) (defaults to: 20)

    the number of records to fetch per page.

  • options (Hash) (defaults to: {})

    the request I/O options.



418
419
420
# File 'lib/asana/resources/task.rb', line 418

def tags
  @tags
end

#workspaceObject (readonly)



72
73
74
# File 'lib/asana/resources/task.rb', line 72

def workspace
  @workspace
end

Class Method Details

.create(client, workspace: nil, options: {}, **data) ⇒ Object

Creating a new task is as easy as POSTing to the ‘/tasks` endpoint with a data block containing the fields you’d like to set on the task. Any unspecified fields will take on default values.

Every task is required to be created in a specific workspace, and this workspace cannot be changed once set. The workspace need not be set explicitly if you specify ‘projects` or a `parent` task instead.

‘projects` can be a comma separated list of projects, or just a single project the task should belong to.

Parameters:

  • workspace (Gid) (defaults to: nil)

    The workspace to create a task in.

  • options (Hash) (defaults to: {})

    the request I/O options.

  • data (Hash)

    the attributes to post.



96
97
98
99
# File 'lib/asana/resources/task.rb', line 96

def create(client, workspace: nil, options: {}, **data)
  with_params = data.merge(workspace: workspace).reject { |_,v| v.nil? || Array(v).empty? }
  self.new(parse(client.post("/tasks", body: with_params, options: options)).first, client: client)
end

.create_in_workspace(client, workspace: required("workspace"), options: {}, **data) ⇒ Object

Creating a new task is as easy as POSTing to the ‘/tasks` endpoint with a data block containing the fields you’d like to set on the task. Any unspecified fields will take on default values.

Every task is required to be created in a specific workspace, and this workspace cannot be changed once set. The workspace need not be set explicitly if you specify a ‘project` or a `parent` task instead.

Parameters:

  • workspace (Gid) (defaults to: required("workspace"))

    The workspace to create a task in.

  • options (Hash) (defaults to: {})

    the request I/O options.

  • data (Hash)

    the attributes to post.



112
113
114
115
# File 'lib/asana/resources/task.rb', line 112

def create_in_workspace(client, workspace: required("workspace"), options: {}, **data)

  self.new(parse(client.post("/workspaces/#{workspace}/tasks", body: data, options: options)).first, client: client)
end

.find_all(client, assignee: nil, workspace: nil, project: nil, section: nil, tag: nil, user_task_list: nil, completed_since: nil, modified_since: nil, per_page: 20, options: {}) ⇒ Object

Returns the compact task records for some filtered set of tasks. Use one or more of the parameters provided to filter the tasks returned. You must specify a ‘project`, `section`, `tag`, or `user_task_list` if you do not specify `assignee` and `workspace`.

Parameters:

  • assignee (String) (defaults to: nil)

    The assignee to filter tasks on.

  • workspace (Gid) (defaults to: nil)

    The workspace or organization to filter tasks on.

  • project (Gid) (defaults to: nil)

    The project to filter tasks on.

  • section (Gid) (defaults to: nil)

    The section to filter tasks on.

  • tag (Gid) (defaults to: nil)

    The tag to filter tasks on.

  • user_task_list (Gid) (defaults to: nil)

    The user task list to filter tasks on.

  • completed_since (String) (defaults to: nil)

    Only return tasks that are either incomplete or that have been

  • completed

    since this time.

  • modified_since (String) (defaults to: nil)

    Only return tasks that have been modified since the given time.

  • per_page (Integer) (defaults to: 20)

    the number of records to fetch per page.

  • options (Hash) (defaults to: {})

    the request I/O options.

  • Notes:
  • If

    you specify ‘assignee`, you must also specify the `workspace` to filter on.

  • If

    you specify ‘workspace`, you must also specify the `assignee` to filter on.

  • Currently,

    this is only supported in board views.

  • A

    task is considered “modified” if any of its properties change,

  • or

    associations between it and other objects are modified (e.g.

  • a

    task being added to a project). A task is not considered modified

  • just

    because another object it is associated with (e.g. a subtask)

  • is

    modified. Actions that count as modifying the task include

  • assigning,

    renaming, completing, and adding stories.



218
219
220
221
# File 'lib/asana/resources/task.rb', line 218

def find_all(client, assignee: nil, workspace: nil, project: nil, section: nil, tag: nil, user_task_list: nil, completed_since: nil, modified_since: nil, per_page: 20, options: {})
  params = { assignee: assignee, workspace: workspace, project: project, section: section, tag: tag, user_task_list: user_task_list, completed_since: completed_since, modified_since: modified_since, limit: per_page }.reject { |_,v| v.nil? || Array(v).empty? }
  Collection.new(parse(client.get("/tasks", params: params, options: options)), type: self, client: client)
end

.find_by_id(client, id, options: {}) ⇒ Object

Returns the complete task record for a single task.

Parameters:

  • id (Gid)

    The task to get.

  • options (Hash) (defaults to: {})

    the request I/O options.



121
122
123
124
# File 'lib/asana/resources/task.rb', line 121

def find_by_id(client, id, options: {})

  self.new(parse(client.get("/tasks/#{id}", options: options)).first, client: client)
end

.find_by_project(client, project: nil, projectId: nil, per_page: 20, options: {}) ⇒ Object

Returns the compact task records for all tasks within the given project, ordered by their priority within the project.

Parameters:

  • project (Gid) (defaults to: nil)

    The project in which to search for tasks.

  • per_page (Integer) (defaults to: 20)

    the number of records to fetch per page.

  • options (Hash) (defaults to: {})

    the request I/O options.



132
133
134
135
# File 'lib/asana/resources/task.rb', line 132

def find_by_project(client, project: nil, projectId: nil, per_page: 20, options: {})
  params = { limit: per_page }.reject { |_,v| v.nil? || Array(v).empty? }
  Collection.new(parse(client.get("/projects/#{project != nil ? project : projectId}/tasks", params: params, options: options)), type: self, client: client)
end

.find_by_section(client, section: required("section"), per_page: 20, options: {}) ⇒ Object

Board view only: Returns the compact section records for all tasks within the given section.

Parameters:

  • section (Gid) (defaults to: required("section"))

    The section in which to search for tasks.

  • per_page (Integer) (defaults to: 20)

    the number of records to fetch per page.

  • options (Hash) (defaults to: {})

    the request I/O options.



152
153
154
155
# File 'lib/asana/resources/task.rb', line 152

def find_by_section(client, section: required("section"), per_page: 20, options: {})
  params = { limit: per_page }.reject { |_,v| v.nil? || Array(v).empty? }
  Collection.new(parse(client.get("/sections/#{section}/tasks", params: params, options: options)), type: self, client: client)
end

.find_by_tag(client, tag: required("tag"), per_page: 20, options: {}) ⇒ Object

Returns the compact task records for all tasks with the given tag.

Parameters:

  • tag (Gid) (defaults to: required("tag"))

    The tag in which to search for tasks.

  • per_page (Integer) (defaults to: 20)

    the number of records to fetch per page.

  • options (Hash) (defaults to: {})

    the request I/O options.



142
143
144
145
# File 'lib/asana/resources/task.rb', line 142

def find_by_tag(client, tag: required("tag"), per_page: 20, options: {})
  params = { limit: per_page }.reject { |_,v| v.nil? || Array(v).empty? }
  Collection.new(parse(client.get("/tags/#{tag}/tasks", params: params, options: options)), type: self, client: client)
end

.find_by_user_task_list(client, user_task_list: required("user_task_list"), completed_since: nil, per_page: 20, options: {}) ⇒ Object

Returns the compact list of tasks in a user’s My Tasks list. The returned tasks will be in order within each assignee status group of ‘Inbox`, `Today`, and `Upcoming`.

Note: tasks in ‘Later` have a different ordering in the Asana web app than the other assignee status groups; this endpoint will still return them in list order in `Later` (differently than they show up in Asana, but the same order as in Asana’s mobile apps).

Note: Access control is enforced for this endpoint as with all Asana API endpoints, meaning a user’s private tasks will be filtered out if the API-authenticated user does not have access to them.

Note: Both complete and incomplete tasks are returned by default unless they are filtered out (for example, setting ‘completed_since=now` will return only incomplete tasks, which is the default view for “My Tasks” in Asana.)

Parameters:

  • user_task_list (Gid) (defaults to: required("user_task_list"))

    The user task list in which to search for tasks.

  • completed_since (String) (defaults to: nil)

    Only return tasks that are either incomplete or that have been

  • completed

    since this time.

  • per_page (Integer) (defaults to: 20)

    the number of records to fetch per page.

  • options (Hash) (defaults to: {})

    the request I/O options.



181
182
183
184
# File 'lib/asana/resources/task.rb', line 181

def find_by_user_task_list(client, user_task_list: required("user_task_list"), completed_since: nil, per_page: 20, options: {})
  params = { completed_since: completed_since, limit: per_page }.reject { |_,v| v.nil? || Array(v).empty? }
  Collection.new(parse(client.get("/user_task_lists/#{user_task_list}/tasks", params: params, options: options)), type: self, client: client)
end

.plural_nameObject

Returns the plural name of the resource.



78
79
80
# File 'lib/asana/resources/task.rb', line 78

def plural_name
  'tasks'
end

.search_in_workspace(client, workspace: required("workspace"), resource_subtype: nil, per_page: 20, options: {}) ⇒ Object Also known as: search

The search endpoint allows you to build complex queries to find and fetch exactly the data you need from Asana. For a more comprehensive description of all the query parameters and limitations of this endpoint, see our [long-form documentation](/developers/documentation/getting-started/search-api) for this feature.

Parameters:

  • workspace (Gid) (defaults to: required("workspace"))

    The workspace or organization in which to search for tasks.

  • resource_subtype (Enum) (defaults to: nil)

    Filters results by the task’s resource_subtype.

  • per_page (Integer) (defaults to: 20)

    the number of records to fetch per page.

  • options (Hash) (defaults to: {})

    the request I/O options.



230
231
232
233
234
235
236
# File 'lib/asana/resources/task.rb', line 230

def search_in_workspace(client, workspace: required("workspace"), resource_subtype: nil, per_page: 20, options: {})
  params = { resource_subtype: resource_subtype, limit: per_page }.reject { |_,v| v.nil? || Array(v).empty? }
  if options[:params]
    params.merge!(options[:params])
  end
  Collection.new(parse(client.get("/workspaces/#{workspace}/tasks/search", params: params, options: options)), type: Resource, client: client)
end

Instance Method Details

#add_comment(text: required("text"), options: {}, **data) ⇒ Object

Adds a comment to a task. The comment will be authored by the currently authenticated user, and timestamped when the server receives the request.

Parameters:

  • Returns

    the full record for the new story added to the task.

  • text (String) (defaults to: required("text"))

    The plain text of the comment to add.

  • options (Hash) (defaults to: {})

    the request I/O options.

  • data (Hash)

    the attributes to post.



499
500
501
502
# File 'lib/asana/resources/task.rb', line 499

def add_comment(text: required("text"), options: {}, **data)
  with_params = data.merge(text: text).reject { |_,v| v.nil? || Array(v).empty? }
  Story.new(parse(client.post("/tasks/#{gid}/stories", body: with_params, options: options)).first, client: client)
end

#add_dependencies(dependencies: required("dependencies"), options: {}, **data) ⇒ Object

Marks a set of tasks as dependencies of this task, if they are not already dependencies. *A task can have at most 15 dependencies.*

Parameters:

  • dependencies (Array) (defaults to: required("dependencies"))

    An array of task IDs that this task should depend on.

  • options (Hash) (defaults to: {})

    the request I/O options.

  • data (Hash)

    the attributes to post.



302
303
304
305
# File 'lib/asana/resources/task.rb', line 302

def add_dependencies(dependencies: required("dependencies"), options: {}, **data)
  with_params = data.merge(dependencies: dependencies).reject { |_,v| v.nil? || Array(v).empty? }
  Collection.new(parse(client.post("/tasks/#{gid}/addDependencies", body: with_params, options: options)), type: self.class, client: client)
end

#add_dependents(dependents: required("dependents"), options: {}, **data) ⇒ Object

Marks a set of tasks as dependents of this task, if they are not already dependents. *A task can have at most 30 dependents.*

Parameters:

  • dependents (Array) (defaults to: required("dependents"))

    An array of task IDs that should depend on this task.

  • options (Hash) (defaults to: {})

    the request I/O options.

  • data (Hash)

    the attributes to post.



313
314
315
316
# File 'lib/asana/resources/task.rb', line 313

def add_dependents(dependents: required("dependents"), options: {}, **data)
  with_params = data.merge(dependents: dependents).reject { |_,v| v.nil? || Array(v).empty? }
  Collection.new(parse(client.post("/tasks/#{gid}/addDependents", body: with_params, options: options)), type: self.class, client: client)
end

#add_followers(followers: required("followers"), options: {}, **data) ⇒ Object

Adds each of the specified followers to the task, if they are not already following. Returns the complete, updated record for the affected task.

Parameters:

  • followers (Array) (defaults to: required("followers"))

    An array of followers to add to the task.

  • options (Hash) (defaults to: {})

    the request I/O options.

  • data (Hash)

    the attributes to post.



344
345
346
347
# File 'lib/asana/resources/task.rb', line 344

def add_followers(followers: required("followers"), options: {}, **data)
  with_params = data.merge(followers: followers).reject { |_,v| v.nil? || Array(v).empty? }
  refresh_with(parse(client.post("/tasks/#{gid}/addFollowers", body: with_params, options: options)).first)
end

#add_project(project: required("project"), insert_after: nil, insert_before: nil, section: nil, options: {}, **data) ⇒ Object

Adds the task to the specified project, in the optional location specified. If no location arguments are given, the task will be added to the end of the project.

‘addProject` can also be used to reorder a task within a project or section that already contains it.

At most one of ‘insert_before`, `insert_after`, or `section` should be specified. Inserting into a section in an non-order-dependent way can be done by specifying `section`, otherwise, to insert within a section in a particular place, specify `insert_before` or `insert_after` and a task within the section to anchor the position of this task.

Parameters:

  • Returns

    an empty data block.

  • project (Gid) (defaults to: required("project"))

    The project to add the task to.

  • insert_after (Gid) (defaults to: nil)

    A task in the project to insert the task after, or ‘null` to

  • insert

    at the beginning of the list.

  • insert_before (Gid) (defaults to: nil)

    A task in the project to insert the task before, or ‘null` to

  • insert

    at the end of the list.

  • section (Gid) (defaults to: nil)

    A section in the project to insert the task into. The task will be

  • inserted

    at the bottom of the section.

  • options (Hash) (defaults to: {})

    the request I/O options.

  • data (Hash)

    the attributes to post.



396
397
398
399
# File 'lib/asana/resources/task.rb', line 396

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? }
  client.post("/tasks/#{gid}/addProject", body: with_params, options: options) && true
end

#add_subtask(options: {}, **data) ⇒ Object

Creates a new subtask and adds it to the parent task. Returns the full record for the newly created subtask.

Parameters:

  • options (Hash) (defaults to: {})

    the request I/O options.

  • data (Hash)

    the attributes to post.



457
458
459
460
# File 'lib/asana/resources/task.rb', line 457

def add_subtask(options: {}, **data)

  self.class.new(parse(client.post("/tasks/#{gid}/subtasks", body: data, options: options)).first, client: client)
end

#add_tag(tag: required("tag"), options: {}, **data) ⇒ Object

Adds a tag to a task. Returns an empty data block.

Parameters:

  • tag (Gid) (defaults to: required("tag"))

    The tag to add to the task.

  • options (Hash) (defaults to: {})

    the request I/O options.

  • data (Hash)

    the attributes to post.



428
429
430
431
# File 'lib/asana/resources/task.rb', line 428

def add_tag(tag: required("tag"), options: {}, **data)
  with_params = data.merge(tag: tag).reject { |_,v| v.nil? || Array(v).empty? }
  client.post("/tasks/#{gid}/addTag", body: with_params, options: options) && true
end

#deleteObject

A specific, existing task can be deleted by making a DELETE request on the URL for that task. Deleted tasks go into the “trash” of the user making the delete request. Tasks can be recovered from the trash within a period of 30 days; afterward they are completely removed from the system.

Returns:

  • an empty data record.



263
264
265
266
# File 'lib/asana/resources/task.rb', line 263

def delete()

  client.delete("/tasks/#{gid}") && true
end

#duplicate_task(name: required("name"), include: nil, options: {}, **data) ⇒ Object

Creates and returns a job that will asynchronously handle the duplication.

Parameters:

  • name (String) (defaults to: required("name"))

    The name of the new task.

  • include (Array) (defaults to: nil)

    The fields that will be duplicated to the new task.

  • options (Hash) (defaults to: {})

    the request I/O options.

  • data (Hash)

    the attributes to post.



275
276
277
278
# File 'lib/asana/resources/task.rb', line 275

def duplicate_task(name: required("name"), include: nil, options: {}, **data)
  with_params = data.merge(name: name, include: include).reject { |_,v| v.nil? || Array(v).empty? }
  Resource.new(parse(client.post("/tasks/#{gid}/duplicate", body: with_params, options: options)).first, client: client)
end

#insert_in_user_task_list(user_task_list: required("user_task_list"), insert_before: nil, insert_after: nil, options: {}, **data) ⇒ Object

Insert or reorder tasks in a user’s My Tasks list. If the task was not assigned to the owner of the user task list it will be reassigned when this endpoint is called. If neither ‘insert_before` nor `insert_after` are provided the task will be inserted at the top of the assignee’s inbox.

Parameters:

  • Returns

    an empty data block.

  • user_task_list (Gid) (defaults to: required("user_task_list"))

    Globally unique identifier for the user task list.

  • insert_before (Gid) (defaults to: nil)

    Insert the task before the task specified by this field. The inserted

  • task

    will inherit the ‘assignee_status` of this task. `insert_before`

  • and

    ‘insert_after` parameters cannot both be specified.

  • insert_after (Gid) (defaults to: nil)

    Insert the task after the task specified by this field. The inserted

  • task

    will inherit the ‘assignee_status` of this task. `insert_before`

  • and

    ‘insert_after` parameters cannot both be specified.

  • options (Hash) (defaults to: {})

    the request I/O options.

  • data (Hash)

    the attributes to post.



524
525
526
527
# File 'lib/asana/resources/task.rb', line 524

def insert_in_user_task_list(user_task_list: required("user_task_list"), insert_before: nil, insert_after: nil, options: {}, **data)
  with_params = data.merge(insert_before: insert_before, insert_after: insert_after).reject { |_,v| v.nil? || Array(v).empty? }
  client.post("/user_task_lists/#{user_task_list}/tasks/insert", body: with_params, options: options) && true
end

#remove_dependencies(dependencies: required("dependencies"), options: {}, **data) ⇒ Object

Unlinks a set of dependencies from this task.

Parameters:

  • dependencies (Array) (defaults to: required("dependencies"))

    An array of task IDs to remove as dependencies.

  • options (Hash) (defaults to: {})

    the request I/O options.

  • data (Hash)

    the attributes to post.



323
324
325
326
# File 'lib/asana/resources/task.rb', line 323

def remove_dependencies(dependencies: required("dependencies"), options: {}, **data)
  with_params = data.merge(dependencies: dependencies).reject { |_,v| v.nil? || Array(v).empty? }
  Collection.new(parse(client.post("/tasks/#{gid}/removeDependencies", body: with_params, options: options)), type: self.class, client: client)
end

#remove_dependents(dependents: required("dependents"), options: {}, **data) ⇒ Object

Unlinks a set of dependents from this task.

Parameters:

  • dependents (Array) (defaults to: required("dependents"))

    An array of task IDs to remove as dependents.

  • options (Hash) (defaults to: {})

    the request I/O options.

  • data (Hash)

    the attributes to post.



333
334
335
336
# File 'lib/asana/resources/task.rb', line 333

def remove_dependents(dependents: required("dependents"), options: {}, **data)
  with_params = data.merge(dependents: dependents).reject { |_,v| v.nil? || Array(v).empty? }
  Collection.new(parse(client.post("/tasks/#{gid}/removeDependents", body: with_params, options: options)), type: self.class, client: client)
end

#remove_followers(followers: required("followers"), options: {}, **data) ⇒ Object

Removes each of the specified followers from the task if they are following. Returns the complete, updated record for the affected task.

Parameters:

  • followers (Array) (defaults to: required("followers"))

    An array of followers to remove from the task.

  • options (Hash) (defaults to: {})

    the request I/O options.

  • data (Hash)

    the attributes to post.



355
356
357
358
# File 'lib/asana/resources/task.rb', line 355

def remove_followers(followers: required("followers"), options: {}, **data)
  with_params = data.merge(followers: followers).reject { |_,v| v.nil? || Array(v).empty? }
  refresh_with(parse(client.post("/tasks/#{gid}/removeFollowers", body: with_params, options: options)).first)
end

#remove_project(project: required("project"), options: {}, **data) ⇒ Object

Removes the task from the specified project. The task will still exist in the system, but it will not be in the project anymore.

Parameters:

  • Returns

    an empty data block.

  • project (Gid) (defaults to: required("project"))

    The project to remove the task from.

  • options (Hash) (defaults to: {})

    the request I/O options.

  • data (Hash)

    the attributes to post.



409
410
411
412
# File 'lib/asana/resources/task.rb', line 409

def remove_project(project: required("project"), options: {}, **data)
  with_params = data.merge(project: project).reject { |_,v| v.nil? || Array(v).empty? }
  client.post("/tasks/#{gid}/removeProject", body: with_params, options: options) && true
end

#remove_tag(tag: required("tag"), options: {}, **data) ⇒ Object

Removes a tag from the task. Returns an empty data block.

Parameters:

  • tag (Gid) (defaults to: required("tag"))

    The tag to remove from the task.

  • options (Hash) (defaults to: {})

    the request I/O options.

  • data (Hash)

    the attributes to post.



438
439
440
441
# File 'lib/asana/resources/task.rb', line 438

def remove_tag(tag: required("tag"), options: {}, **data)
  with_params = data.merge(tag: tag).reject { |_,v| v.nil? || Array(v).empty? }
  client.post("/tasks/#{gid}/removeTag", body: with_params, options: options) && true
end

#set_parent(parent: required("parent"), insert_after: nil, insert_before: nil, options: {}, **data) ⇒ Object

Changes the parent of a task. Each task may only be a subtask of a single parent, or no parent task at all. Returns an empty data block. When using ‘insert_before` and `insert_after`, at most one of those two options can be specified, and they must already be subtasks of the parent.

Parameters:

  • parent (Gid) (defaults to: required("parent"))

    The new parent of the task, or ‘null` for no parent.

  • insert_after (Gid) (defaults to: nil)

    A subtask of the parent to insert the task after, or ‘null` to

  • insert

    at the beginning of the list.

  • insert_before (Gid) (defaults to: nil)

    A subtask of the parent to insert the task before, or ‘null` to

  • insert

    at the end of the list.

  • options (Hash) (defaults to: {})

    the request I/O options.

  • data (Hash)

    the attributes to post.



476
477
478
479
# File 'lib/asana/resources/task.rb', line 476

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? }
  client.post("/tasks/#{gid}/setParent", body: with_params, options: options) && true
end

#stories(per_page: 20, options: {}) ⇒ Object

Returns a compact representation of all of the stories on the task.

Parameters:

  • per_page (Integer) (defaults to: 20)

    the number of records to fetch per page.

  • options (Hash) (defaults to: {})

    the request I/O options.



485
486
487
488
# File 'lib/asana/resources/task.rb', line 485

def stories(per_page: 20, options: {})
  params = { limit: per_page }.reject { |_,v| v.nil? || Array(v).empty? }
  Collection.new(parse(client.get("/tasks/#{gid}/stories", params: params, options: options)), type: Story, client: client)
end

#subtasks(per_page: 20, options: {}) ⇒ Object

Returns a compact representation of all of the subtasks of a task.

Parameters:

  • per_page (Integer) (defaults to: 20)

    the number of records to fetch per page.

  • options (Hash) (defaults to: {})

    the request I/O options.



447
448
449
450
# File 'lib/asana/resources/task.rb', line 447

def subtasks(per_page: 20, options: {})
  params = { limit: per_page }.reject { |_,v| v.nil? || Array(v).empty? }
  Collection.new(parse(client.get("/tasks/#{gid}/subtasks", params: params, options: options)), type: self.class, client: client)
end

#update(options: {}, **data) ⇒ Object

A specific, existing task can be updated by making a PUT request on the URL for that task. Only the fields provided in the ‘data` block will be updated; any unspecified fields will remain unchanged.

When using this method, it is best to specify only those fields you wish to change, or else you may overwrite changes made by another user since you last retrieved the task.

Parameters:

  • Returns

    the complete updated task record.

  • options (Hash) (defaults to: {})

    the request I/O options.

  • data (Hash)

    the attributes to post.



252
253
254
255
# File 'lib/asana/resources/task.rb', line 252

def update(options: {}, **data)

  refresh_with(parse(client.put("/tasks/#{gid}", body: data, options: options)).first)
end