Class: Asana::Resources::Project
- Inherits:
-
ProjectsBase
- Object
- Resource
- ProjectsBase
- Asana::Resources::Project
- Includes:
- EventSubscription
- Defined in:
- lib/asana/resources/project.rb
Overview
A project represents a prioritized list of tasks in Asana or a board with columns of tasks represented as cards. It exists in a single workspace or organization and is accessible to a subset of users in that workspace or organization, depending on its permissions.
Projects in organizations are shared with a single team. You cannot currently change the team of a project via the API. Non-organization workspaces do not have teams and so you should not specify the team of project in a regular workspace.
Instance Attribute Summary collapse
- #archived ⇒ Object readonly
- #color ⇒ Object readonly
- #created_at ⇒ Object readonly
- #current_status ⇒ Object readonly
- #custom_field_settings ⇒ Object readonly
- #custom_fields ⇒ Object readonly
- #due_date ⇒ Object readonly
- #due_on ⇒ Object readonly
- #followers ⇒ Object readonly
- #gid ⇒ Object readonly
- #html_notes ⇒ Object readonly
- #layout ⇒ Object readonly
- #members ⇒ Object readonly
- #modified_at ⇒ Object readonly
- #name ⇒ Object readonly
- #notes ⇒ Object readonly
- #owner ⇒ Object readonly
- #public ⇒ Object readonly
- #resource_type ⇒ Object readonly
- #start_on ⇒ Object readonly
- #team ⇒ Object readonly
- #workspace ⇒ Object readonly
Class Method Summary collapse
-
.create(client, workspace: required("workspace"), team: nil, options: {}, **data) ⇒ Object
Creates a new project in a workspace or team.
-
.create_in_team(client, team: required("team"), options: {}, **data) ⇒ Object
Creates a project shared with the given team.
-
.create_in_workspace(client, workspace: required("workspace"), options: {}, **data) ⇒ Object
If the workspace for your project is an organization, you must also supply a ‘team` to share the project with.
-
.find_all(client, workspace: nil, team: nil, is_template: nil, archived: nil, per_page: 20, options: {}) ⇒ Object
Returns the compact project records for some filtered set of projects.
-
.find_by_id(client, id, options: {}) ⇒ Object
Returns the complete project record for a single project.
-
.find_by_team(client, team: required("team"), is_template: nil, archived: nil, per_page: 20, options: {}) ⇒ Object
Returns the compact project records for all projects in the team.
-
.find_by_workspace(client, workspace: required("workspace"), is_template: nil, archived: nil, per_page: 20, options: {}) ⇒ Object
Returns the compact project records for all projects in the workspace.
-
.plural_name ⇒ Object
Returns the plural name of the resource.
Instance Method Summary collapse
-
#add_custom_field_setting(custom_field: required("custom_field"), is_important: nil, insert_before: nil, insert_after: nil, options: {}, **data) ⇒ Object
Create a new custom field setting on the project.
-
#add_followers(followers: required("followers"), options: {}, **data) ⇒ Object
Adds the specified list of users as followers to the project.
-
#add_members(members: required("members"), options: {}, **data) ⇒ Object
Adds the specified list of users as members of the project.
-
#delete ⇒ Object
A specific, existing project can be deleted by making a DELETE request on the URL for that project.
-
#duplicate_project(name: required("name"), team: nil, include: nil, schedule_dates: nil, options: {}, **data) ⇒ Object
Creates and returns a job that will asynchronously handle the duplication.
-
#remove_custom_field_setting(custom_field: nil, options: {}, **data) ⇒ Object
Remove a custom field setting on the project.
-
#remove_followers(followers: required("followers"), options: {}, **data) ⇒ Object
Removes the specified list of users from following the project, this will not affect project membership status.
-
#remove_members(members: required("members"), options: {}, **data) ⇒ Object
Removes the specified list of members from the project.
-
#tasks(per_page: 20, options: {}) ⇒ Object
Returns the compact task records for all tasks within the given project, ordered by their priority within the project.
-
#update(options: {}, **data) ⇒ Object
A specific, existing project can be updated by making a PUT request on the URL for that project.
Methods included from EventSubscription
Methods inherited from ProjectsBase
add_custom_field_setting_for_project, add_followers_for_project, add_members_for_project, create_project, create_project_for_team, create_project_for_workspace, delete_project, duplicate_project, get_project, get_projects, get_projects_for_task, get_projects_for_team, get_projects_for_workspace, get_task_counts_for_project, inherited, project_save_as_template, remove_custom_field_setting_for_project, remove_followers_for_project, remove_members_for_project, update_project
Methods inherited from Resource
#initialize, #method_missing, #refresh, #respond_to_missing?, #to_h, #to_s
Methods included from ResponseHelper
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
#archived ⇒ Object (readonly)
39 40 41 |
# File 'lib/asana/resources/project.rb', line 39 def archived @archived end |
#color ⇒ Object (readonly)
51 52 53 |
# File 'lib/asana/resources/project.rb', line 51 def color @color end |
#created_at ⇒ Object (readonly)
35 36 37 |
# File 'lib/asana/resources/project.rb', line 35 def created_at @created_at end |
#current_status ⇒ Object (readonly)
27 28 29 |
# File 'lib/asana/resources/project.rb', line 27 def current_status @current_status end |
#custom_field_settings ⇒ Object (readonly)
49 50 51 |
# File 'lib/asana/resources/project.rb', line 49 def custom_field_settings @custom_field_settings end |
#custom_fields ⇒ Object (readonly)
47 48 49 |
# File 'lib/asana/resources/project.rb', line 47 def custom_fields @custom_fields end |
#due_date ⇒ Object (readonly)
29 30 31 |
# File 'lib/asana/resources/project.rb', line 29 def due_date @due_date end |
#due_on ⇒ Object (readonly)
31 32 33 |
# File 'lib/asana/resources/project.rb', line 31 def due_on @due_on end |
#followers ⇒ Object (readonly)
45 46 47 |
# File 'lib/asana/resources/project.rb', line 45 def followers @followers end |
#gid ⇒ Object (readonly)
19 20 21 |
# File 'lib/asana/resources/project.rb', line 19 def gid @gid end |
#html_notes ⇒ Object (readonly)
55 56 57 |
# File 'lib/asana/resources/project.rb', line 55 def html_notes @html_notes end |
#layout ⇒ Object (readonly)
61 62 63 |
# File 'lib/asana/resources/project.rb', line 61 def layout @layout end |
#members ⇒ Object (readonly)
43 44 45 |
# File 'lib/asana/resources/project.rb', line 43 def members @members end |
#modified_at ⇒ Object (readonly)
37 38 39 |
# File 'lib/asana/resources/project.rb', line 37 def modified_at @modified_at end |
#name ⇒ Object (readonly)
23 24 25 |
# File 'lib/asana/resources/project.rb', line 23 def name @name end |
#notes ⇒ Object (readonly)
53 54 55 |
# File 'lib/asana/resources/project.rb', line 53 def notes @notes end |
#owner ⇒ Object (readonly)
25 26 27 |
# File 'lib/asana/resources/project.rb', line 25 def owner @owner end |
#public ⇒ Object (readonly)
41 42 43 |
# File 'lib/asana/resources/project.rb', line 41 def public @public end |
#resource_type ⇒ Object (readonly)
21 22 23 |
# File 'lib/asana/resources/project.rb', line 21 def resource_type @resource_type end |
#start_on ⇒ Object (readonly)
33 34 35 |
# File 'lib/asana/resources/project.rb', line 33 def start_on @start_on end |
#team ⇒ Object (readonly)
59 60 61 |
# File 'lib/asana/resources/project.rb', line 59 def team @team end |
#workspace ⇒ Object (readonly)
57 58 59 |
# File 'lib/asana/resources/project.rb', line 57 def workspace @workspace end |
Class Method Details
.create(client, workspace: required("workspace"), team: nil, options: {}, **data) ⇒ Object
Creates a new project in a workspace or team.
Every project is required to be created in a specific workspace or organization, and this cannot be changed once set. Note that you can use the ‘workspace` parameter regardless of whether or not it is an organization.
If the workspace for your project is an organization, you must also supply a ‘team` to share the project with.
87 88 89 90 |
# File 'lib/asana/resources/project.rb', line 87 def create(client, workspace: required("workspace"), team: nil, options: {}, **data) with_params = data.merge(workspace: workspace, team: team).reject { |_,v| v.nil? || Array(v).empty? } self.new(parse(client.post("/projects", body: with_params, options: )).first, client: client) end |
.create_in_team(client, team: required("team"), options: {}, **data) ⇒ Object
Creates a project shared with the given team.
112 113 114 115 |
# File 'lib/asana/resources/project.rb', line 112 def create_in_team(client, team: required("team"), options: {}, **data) self.new(parse(client.post("/teams/#{team}/projects", body: data, options: )).first, client: client) end |
.create_in_workspace(client, workspace: required("workspace"), options: {}, **data) ⇒ Object
If the workspace for your project is an organization, you must also supply a ‘team` to share the project with.
100 101 102 103 |
# File 'lib/asana/resources/project.rb', line 100 def create_in_workspace(client, workspace: required("workspace"), options: {}, **data) self.new(parse(client.post("/workspaces/#{workspace}/projects", body: data, options: )).first, client: client) end |
.find_all(client, workspace: nil, team: nil, is_template: nil, archived: nil, per_page: 20, options: {}) ⇒ Object
Returns the compact project records for some filtered set of projects. Use one or more of the parameters provided to filter the projects returned.
139 140 141 142 |
# File 'lib/asana/resources/project.rb', line 139 def find_all(client, workspace: nil, team: nil, is_template: nil, archived: nil, per_page: 20, options: {}) params = { workspace: workspace, team: team, is_template: is_template, archived: archived, limit: per_page }.reject { |_,v| v.nil? || Array(v).empty? } Collection.new(parse(client.get("/projects", params: params, options: )), type: self, client: client) end |
.find_by_id(client, id, options: {}) ⇒ Object
Returns the complete project record for a single project.
121 122 123 124 |
# File 'lib/asana/resources/project.rb', line 121 def find_by_id(client, id, options: {}) self.new(parse(client.get("/projects/#{id}", options: )).first, client: client) end |
.find_by_team(client, team: required("team"), is_template: nil, archived: nil, per_page: 20, options: {}) ⇒ Object
Returns the compact project records for all projects in the team.
170 171 172 173 |
# File 'lib/asana/resources/project.rb', line 170 def find_by_team(client, team: required("team"), is_template: nil, archived: nil, per_page: 20, options: {}) params = { is_template: is_template, archived: archived, limit: per_page }.reject { |_,v| v.nil? || Array(v).empty? } Collection.new(parse(client.get("/teams/#{team}/projects", params: params, options: )), type: self, client: client) end |
.find_by_workspace(client, workspace: required("workspace"), is_template: nil, archived: nil, per_page: 20, options: {}) ⇒ Object
Returns the compact project records for all projects in the workspace.
155 156 157 158 |
# File 'lib/asana/resources/project.rb', line 155 def find_by_workspace(client, workspace: required("workspace"), is_template: nil, archived: nil, per_page: 20, options: {}) params = { is_template: is_template, archived: archived, limit: per_page }.reject { |_,v| v.nil? || Array(v).empty? } Collection.new(parse(client.get("/workspaces/#{workspace}/projects", params: params, options: )), type: self, client: client) end |
.plural_name ⇒ Object
Returns the plural name of the resource.
65 66 67 |
# File 'lib/asana/resources/project.rb', line 65 def plural_name 'projects' end |
Instance Method Details
#add_custom_field_setting(custom_field: required("custom_field"), is_important: nil, insert_before: nil, insert_after: nil, options: {}, **data) ⇒ Object
Create a new custom field setting on the project.
292 293 294 295 |
# File 'lib/asana/resources/project.rb', line 292 def add_custom_field_setting(custom_field: required("custom_field"), is_important: nil, insert_before: nil, insert_after: nil, options: {}, **data) with_params = data.merge(custom_field: custom_field, is_important: is_important, insert_before: insert_before, insert_after: insert_after).reject { |_,v| v.nil? || Array(v).empty? } Resource.new(parse(client.post("/projects/#{gid}/addCustomFieldSetting", body: with_params, options: )).first, client: client) end |
#add_followers(followers: required("followers"), options: {}, **data) ⇒ Object
Adds the specified list of users as followers to the project. Followers are a subset of members, therefore if the users are not already members of the project they will also become members as a result of this operation.
243 244 245 246 |
# File 'lib/asana/resources/project.rb', line 243 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("/projects/#{gid}/addFollowers", body: with_params, options: )).first) end |
#add_members(members: required("members"), options: {}, **data) ⇒ Object
Adds the specified list of users as members of the project. Returns the updated project record.
264 265 266 267 |
# File 'lib/asana/resources/project.rb', line 264 def add_members(members: required("members"), options: {}, **data) with_params = data.merge(members: members).reject { |_,v| v.nil? || Array(v).empty? } refresh_with(parse(client.post("/projects/#{gid}/addMembers", body: with_params, options: )).first) end |
#delete ⇒ Object
A specific, existing project can be deleted by making a DELETE request on the URL for that project.
197 198 199 200 |
# File 'lib/asana/resources/project.rb', line 197 def delete() client.delete("/projects/#{gid}") && true end |
#duplicate_project(name: required("name"), team: nil, include: nil, schedule_dates: nil, options: {}, **data) ⇒ Object
Creates and returns a job that will asynchronously handle the duplication.
221 222 223 224 |
# File 'lib/asana/resources/project.rb', line 221 def duplicate_project(name: required("name"), team: nil, include: nil, schedule_dates: nil, options: {}, **data) with_params = data.merge(name: name, team: team, include: include, schedule_dates: schedule_dates).reject { |_,v| v.nil? || Array(v).empty? } Resource.new(parse(client.post("/projects/#{gid}/duplicate", body: with_params, options: )).first, client: client) end |
#remove_custom_field_setting(custom_field: nil, options: {}, **data) ⇒ Object
Remove a custom field setting on the project.
302 303 304 305 |
# File 'lib/asana/resources/project.rb', line 302 def remove_custom_field_setting(custom_field: nil, options: {}, **data) with_params = data.merge(custom_field: custom_field).reject { |_,v| v.nil? || Array(v).empty? } Resource.new(parse(client.post("/projects/#{gid}/removeCustomFieldSetting", body: with_params, options: )).first, client: client) end |
#remove_followers(followers: required("followers"), options: {}, **data) ⇒ Object
Removes the specified list of users from following the project, this will not affect project membership status.
254 255 256 257 |
# File 'lib/asana/resources/project.rb', line 254 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("/projects/#{gid}/removeFollowers", body: with_params, options: )).first) end |
#remove_members(members: required("members"), options: {}, **data) ⇒ Object
Removes the specified list of members from the project. Returns the updated project record.
274 275 276 277 |
# File 'lib/asana/resources/project.rb', line 274 def remove_members(members: required("members"), options: {}, **data) with_params = data.merge(members: members).reject { |_,v| v.nil? || Array(v).empty? } refresh_with(parse(client.post("/projects/#{gid}/removeMembers", body: with_params, options: )).first) end |
#tasks(per_page: 20, options: {}) ⇒ Object
Returns the compact task records for all tasks within the given project, ordered by their priority within the project. Tasks can exist in more than one project at a time.
231 232 233 234 |
# File 'lib/asana/resources/project.rb', line 231 def tasks(per_page: 20, options: {}) params = { limit: per_page }.reject { |_,v| v.nil? || Array(v).empty? } Collection.new(parse(client.get("/projects/#{gid}/tasks", params: params, options: )), type: Task, client: client) end |
#update(options: {}, **data) ⇒ Object
A specific, existing project can be updated by making a PUT request on the URL for that project. 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.
188 189 190 191 |
# File 'lib/asana/resources/project.rb', line 188 def update(options: {}, **data) refresh_with(parse(client.put("/projects/#{gid}", body: data, options: )).first) end |