Class: 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
- #due_date ⇒ Object readonly
- #followers ⇒ Object readonly
- #id ⇒ Object readonly
- #layout ⇒ Object readonly
- #members ⇒ Object readonly
- #modified_at ⇒ Object readonly
- #name ⇒ Object readonly
- #notes ⇒ Object readonly
- #owner ⇒ Object readonly
- #public ⇒ 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, 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"), 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"), 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.
-
#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 Resource
inherited, #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)
36 37 38 |
# File 'lib/asana/resources/project.rb', line 36 def archived @archived end |
#color ⇒ Object (readonly)
46 47 48 |
# File 'lib/asana/resources/project.rb', line 46 def color @color end |
#created_at ⇒ Object (readonly)
32 33 34 |
# File 'lib/asana/resources/project.rb', line 32 def created_at @created_at end |
#current_status ⇒ Object (readonly)
26 27 28 |
# File 'lib/asana/resources/project.rb', line 26 def current_status @current_status end |
#custom_field_settings ⇒ Object (readonly)
44 45 46 |
# File 'lib/asana/resources/project.rb', line 44 def custom_field_settings @custom_field_settings end |
#due_date ⇒ Object (readonly)
28 29 30 |
# File 'lib/asana/resources/project.rb', line 28 def due_date @due_date end |
#followers ⇒ Object (readonly)
42 43 44 |
# File 'lib/asana/resources/project.rb', line 42 def followers @followers end |
#id ⇒ Object (readonly)
22 23 24 |
# File 'lib/asana/resources/project.rb', line 22 def id @id end |
#layout ⇒ Object (readonly)
54 55 56 |
# File 'lib/asana/resources/project.rb', line 54 def layout @layout end |
#members ⇒ Object (readonly)
40 41 42 |
# File 'lib/asana/resources/project.rb', line 40 def members @members end |
#modified_at ⇒ Object (readonly)
34 35 36 |
# File 'lib/asana/resources/project.rb', line 34 def modified_at @modified_at end |
#name ⇒ Object (readonly)
20 21 22 |
# File 'lib/asana/resources/project.rb', line 20 def name @name end |
#notes ⇒ Object (readonly)
48 49 50 |
# File 'lib/asana/resources/project.rb', line 48 def notes @notes end |
#owner ⇒ Object (readonly)
24 25 26 |
# File 'lib/asana/resources/project.rb', line 24 def owner @owner end |
#public ⇒ Object (readonly)
38 39 40 |
# File 'lib/asana/resources/project.rb', line 38 def public @public end |
#start_on ⇒ Object (readonly)
30 31 32 |
# File 'lib/asana/resources/project.rb', line 30 def start_on @start_on end |
#team ⇒ Object (readonly)
52 53 54 |
# File 'lib/asana/resources/project.rb', line 52 def team @team end |
#workspace ⇒ Object (readonly)
50 51 52 |
# File 'lib/asana/resources/project.rb', line 50 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.
80 81 82 83 |
# File 'lib/asana/resources/project.rb', line 80 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.
105 106 107 108 |
# File 'lib/asana/resources/project.rb', line 105 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.
93 94 95 96 |
# File 'lib/asana/resources/project.rb', line 93 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, 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.
129 130 131 132 |
# File 'lib/asana/resources/project.rb', line 129 def find_all(client, workspace: nil, team: nil, archived: nil, per_page: 20, options: {}) params = { workspace: workspace, team: team, 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.
114 115 116 117 |
# File 'lib/asana/resources/project.rb', line 114 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"), archived: nil, per_page: 20, options: {}) ⇒ Object
Returns the compact project records for all projects in the team.
155 156 157 158 |
# File 'lib/asana/resources/project.rb', line 155 def find_by_team(client, team: required("team"), archived: nil, per_page: 20, options: {}) params = { 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"), archived: nil, per_page: 20, options: {}) ⇒ Object
Returns the compact project records for all projects in the workspace.
142 143 144 145 |
# File 'lib/asana/resources/project.rb', line 142 def find_by_workspace(client, workspace: required("workspace"), archived: nil, per_page: 20, options: {}) params = { 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.
58 59 60 |
# File 'lib/asana/resources/project.rb', line 58 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.
253 254 255 256 |
# File 'lib/asana/resources/project.rb', line 253 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/#{id}/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.
204 205 206 207 |
# File 'lib/asana/resources/project.rb', line 204 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/#{id}/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.
225 226 227 228 |
# File 'lib/asana/resources/project.rb', line 225 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/#{id}/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.
182 183 184 185 |
# File 'lib/asana/resources/project.rb', line 182 def delete() client.delete("/projects/#{id}") && true end |
#remove_custom_field_setting(custom_field: nil, options: {}, **data) ⇒ Object
Remove a custom field setting on the project.
263 264 265 266 |
# File 'lib/asana/resources/project.rb', line 263 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/#{id}/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.
215 216 217 218 |
# File 'lib/asana/resources/project.rb', line 215 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/#{id}/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.
235 236 237 238 |
# File 'lib/asana/resources/project.rb', line 235 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/#{id}/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.
192 193 194 195 |
# File 'lib/asana/resources/project.rb', line 192 def tasks(per_page: 20, options: {}) params = { limit: per_page }.reject { |_,v| v.nil? || Array(v).empty? } Collection.new(parse(client.get("/projects/#{id}/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.
173 174 175 176 |
# File 'lib/asana/resources/project.rb', line 173 def update(options: {}, **data) refresh_with(parse(client.put("/projects/#{id}", body: data, options: )).first) end |