Class: Asana::Resources::Project
- Includes:
- EventSubscription
- Defined in:
- lib/asana/resources/project.rb
Overview
A project represents a prioritized list of tasks in Asana. 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
- #followers ⇒ Object readonly
- #id ⇒ Object readonly
- #modified_at ⇒ Object readonly
- #name ⇒ Object readonly
- #notes ⇒ 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
-
#delete ⇒ Object
A specific, existing project can be deleted by making a DELETE request on the URL for that project.
-
#sections(per_page: 20, options: {}) ⇒ Object
Returns compact records for all sections in the specified 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)
21 22 23 |
# File 'lib/asana/resources/project.rb', line 21 def archived @archived end |
#color ⇒ Object (readonly)
31 32 33 |
# File 'lib/asana/resources/project.rb', line 31 def color @color end |
#created_at ⇒ Object (readonly)
23 24 25 |
# File 'lib/asana/resources/project.rb', line 23 def created_at @created_at end |
#followers ⇒ Object (readonly)
25 26 27 |
# File 'lib/asana/resources/project.rb', line 25 def followers @followers end |
#id ⇒ Object (readonly)
19 20 21 |
# File 'lib/asana/resources/project.rb', line 19 def id @id end |
#modified_at ⇒ Object (readonly)
27 28 29 |
# File 'lib/asana/resources/project.rb', line 27 def modified_at @modified_at end |
#name ⇒ Object (readonly)
29 30 31 |
# File 'lib/asana/resources/project.rb', line 29 def name @name end |
#notes ⇒ Object (readonly)
33 34 35 |
# File 'lib/asana/resources/project.rb', line 33 def notes @notes end |
#team ⇒ Object (readonly)
37 38 39 |
# File 'lib/asana/resources/project.rb', line 37 def team @team end |
#workspace ⇒ Object (readonly)
35 36 37 |
# File 'lib/asana/resources/project.rb', line 35 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.
63 64 65 66 |
# File 'lib/asana/resources/project.rb', line 63 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.
88 89 90 91 |
# File 'lib/asana/resources/project.rb', line 88 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.
76 77 78 79 |
# File 'lib/asana/resources/project.rb', line 76 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.
112 113 114 115 |
# File 'lib/asana/resources/project.rb', line 112 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.
97 98 99 100 |
# File 'lib/asana/resources/project.rb', line 97 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.
138 139 140 141 |
# File 'lib/asana/resources/project.rb', line 138 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.
125 126 127 128 |
# File 'lib/asana/resources/project.rb', line 125 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.
41 42 43 |
# File 'lib/asana/resources/project.rb', line 41 def plural_name 'projects' end |
Instance Method Details
#delete ⇒ Object
A specific, existing project can be deleted by making a DELETE request on the URL for that project.
165 166 167 168 |
# File 'lib/asana/resources/project.rb', line 165 def delete() client.delete("/projects/#{id}") && true end |
#sections(per_page: 20, options: {}) ⇒ Object
Returns compact records for all sections in the specified project.
174 175 176 177 |
# File 'lib/asana/resources/project.rb', line 174 def sections(per_page: 20, options: {}) params = { limit: per_page }.reject { |_,v| v.nil? || Array(v).empty? } Collection.new(parse(client.get("/projects/#{id}/sections", params: params, options: )), type: Resource, client: client) 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.
184 185 186 187 |
# File 'lib/asana/resources/project.rb', line 184 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.
156 157 158 159 |
# File 'lib/asana/resources/project.rb', line 156 def update(options: {}, **data) refresh_with(parse(client.put("/projects/#{id}", body: data, options: )).first) end |