Class: Asana::Resources::Portfolio
- Defined in:
- lib/asana/resources/portfolio.rb
Overview
A portfolio gives a high-level overview of the status of multiple initiatives in Asana. Portfolios provide a dashboard overview of the state of multiple items, including a progress report and the most recent [project status](/developers/api-reference/project_statuses) update.
Portfolios have some restrictions on size. Each portfolio has a maximum of 250 items and, like projects, a maximum of 20 custom fields.
Instance Attribute Summary collapse
- #color ⇒ Object readonly
- #created_at ⇒ Object readonly
- #created_by ⇒ Object readonly
-
#custom_field_settings(options: {}) ⇒ Object
readonly
Get the custom field settings on a portfolio.
- #gid ⇒ Object readonly
- #id ⇒ Object readonly
- #members ⇒ Object readonly
- #name ⇒ Object readonly
- #owner ⇒ Object readonly
- #resource_type ⇒ Object readonly
- #workspace ⇒ Object readonly
Class Method Summary collapse
-
.create(client, workspace: required("workspace"), name: required("name"), color: nil, options: {}, **data) ⇒ Object
Creates a new portfolio in the given workspace with the supplied name.
-
.find_all(client, workspace: required("workspace"), owner: required("owner"), per_page: 20, options: {}) ⇒ Object
Returns a list of the portfolios in compact representation that are owned by the current API user.
-
.find_by_id(client, id, options: {}) ⇒ Object
Returns the complete record for a single portfolio.
-
.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 portfolio.
-
#add_item(item: required("item"), insert_before: nil, insert_after: nil, options: {}, **data) ⇒ Object
Add an item to a portfolio.
-
#add_members(members: required("members"), options: {}, **data) ⇒ Object
Adds the specified list of users as members of the portfolio.
-
#delete ⇒ Object
An existing portfolio can be deleted by making a DELETE request on the URL for that portfolio.
-
#get_items(options: {}) ⇒ Object
Get a list of the items in compact form in a portfolio.
-
#remove_custom_field_setting(custom_field: required("custom_field"), options: {}, **data) ⇒ Object
Remove a custom field setting on the portfolio.
-
#remove_item(item: required("item"), options: {}, **data) ⇒ Object
Remove an item to a portfolio.
-
#remove_members(members: required("members"), options: {}, **data) ⇒ Object
Removes the specified list of members from the portfolio.
-
#update(options: {}, **data) ⇒ Object
An existing portfolio can be updated by making a PUT request on the URL for that portfolio.
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
#color ⇒ Object (readonly)
32 33 34 |
# File 'lib/asana/resources/portfolio.rb', line 32 def color @color end |
#created_at ⇒ Object (readonly)
26 27 28 |
# File 'lib/asana/resources/portfolio.rb', line 26 def created_at @created_at end |
#created_by ⇒ Object (readonly)
28 29 30 |
# File 'lib/asana/resources/portfolio.rb', line 28 def created_by @created_by end |
#custom_field_settings(options: {}) ⇒ Object (readonly)
Get the custom field settings on a portfolio.
169 170 171 |
# File 'lib/asana/resources/portfolio.rb', line 169 def custom_field_settings @custom_field_settings end |
#gid ⇒ Object (readonly)
18 19 20 |
# File 'lib/asana/resources/portfolio.rb', line 18 def gid @gid end |
#id ⇒ Object (readonly)
16 17 18 |
# File 'lib/asana/resources/portfolio.rb', line 16 def id @id end |
#members ⇒ Object (readonly)
36 37 38 |
# File 'lib/asana/resources/portfolio.rb', line 36 def members @members end |
#name ⇒ Object (readonly)
22 23 24 |
# File 'lib/asana/resources/portfolio.rb', line 22 def name @name end |
#owner ⇒ Object (readonly)
24 25 26 |
# File 'lib/asana/resources/portfolio.rb', line 24 def owner @owner end |
#resource_type ⇒ Object (readonly)
20 21 22 |
# File 'lib/asana/resources/portfolio.rb', line 20 def resource_type @resource_type end |
#workspace ⇒ Object (readonly)
34 35 36 |
# File 'lib/asana/resources/portfolio.rb', line 34 def workspace @workspace end |
Class Method Details
.create(client, workspace: required("workspace"), name: required("name"), color: nil, options: {}, **data) ⇒ Object
Creates a new portfolio in the given workspace with the supplied name.
Note that portfolios created in the Asana UI may have some state (like the “Priority” custom field) which is automatically added to the portfolio when it is created. Portfolios created via our API will not be created with the same initial state to allow integrations to create their own starting state on a portfolio.
57 58 59 60 |
# File 'lib/asana/resources/portfolio.rb', line 57 def create(client, workspace: required("workspace"), name: required("name"), color: nil, options: {}, **data) with_params = data.merge(workspace: workspace, name: name, color: color).reject { |_,v| v.nil? || Array(v).empty? } self.new(parse(client.post("/portfolios", body: with_params, options: )).first, client: client) end |
.find_all(client, workspace: required("workspace"), owner: required("owner"), per_page: 20, options: {}) ⇒ Object
Returns a list of the portfolios in compact representation that are owned by the current API user.
80 81 82 83 |
# File 'lib/asana/resources/portfolio.rb', line 80 def find_all(client, workspace: required("workspace"), owner: required("owner"), per_page: 20, options: {}) params = { workspace: workspace, owner: owner, limit: per_page }.reject { |_,v| v.nil? || Array(v).empty? } Collection.new(parse(client.get("/portfolios", params: params, options: )), type: self, client: client) end |
.find_by_id(client, id, options: {}) ⇒ Object
Returns the complete record for a single portfolio.
66 67 68 69 |
# File 'lib/asana/resources/portfolio.rb', line 66 def find_by_id(client, id, options: {}) self.new(parse(client.get("/portfolios/#{id}", options: )).first, client: client) end |
.plural_name ⇒ Object
Returns the plural name of the resource.
40 41 42 |
# File 'lib/asana/resources/portfolio.rb', line 40 def plural_name 'portfolios' 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 portfolio. Returns the full record for the new custom field setting.
188 189 190 191 |
# File 'lib/asana/resources/portfolio.rb', line 188 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("/portfolios/#{gid}/addCustomFieldSetting", body: with_params, options: )).first, client: client) end |
#add_item(item: required("item"), insert_before: nil, insert_after: nil, options: {}, **data) ⇒ Object
Add an item to a portfolio.
129 130 131 132 |
# File 'lib/asana/resources/portfolio.rb', line 129 def add_item(item: required("item"), insert_before: nil, insert_after: nil, options: {}, **data) with_params = data.merge(item: item, insert_before: insert_before, insert_after: insert_after).reject { |_,v| v.nil? || Array(v).empty? } client.post("/portfolios/#{gid}/addItem", body: with_params, options: ) && true end |
#add_members(members: required("members"), options: {}, **data) ⇒ Object
Adds the specified list of users as members of the portfolio. Returns the updated portfolio record.
151 152 153 154 |
# File 'lib/asana/resources/portfolio.rb', line 151 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("/portfolios/#{gid}/addMembers", body: with_params, options: )).first) end |
#delete ⇒ Object
An existing portfolio can be deleted by making a DELETE request on the URL for that portfolio.
103 104 105 106 |
# File 'lib/asana/resources/portfolio.rb', line 103 def delete() client.delete("/portfolios/#{gid}") && true end |
#get_items(options: {}) ⇒ Object
Get a list of the items in compact form in a portfolio.
111 112 113 114 |
# File 'lib/asana/resources/portfolio.rb', line 111 def get_items(options: {}) Collection.new(parse(client.get("/portfolios/#{gid}/items", options: )), type: self, client: client) end |
#remove_custom_field_setting(custom_field: required("custom_field"), options: {}, **data) ⇒ Object
Remove a custom field setting on the portfolio. Returns an empty data block.
199 200 201 202 |
# File 'lib/asana/resources/portfolio.rb', line 199 def remove_custom_field_setting(custom_field: required("custom_field"), options: {}, **data) with_params = data.merge(custom_field: custom_field).reject { |_,v| v.nil? || Array(v).empty? } client.post("/portfolios/#{gid}/removeCustomFieldSetting", body: with_params, options: ) && true end |
#remove_item(item: required("item"), options: {}, **data) ⇒ Object
Remove an item to a portfolio.
141 142 143 144 |
# File 'lib/asana/resources/portfolio.rb', line 141 def remove_item(item: required("item"), options: {}, **data) with_params = data.merge(item: item).reject { |_,v| v.nil? || Array(v).empty? } client.post("/portfolios/#{gid}/removeItem", body: with_params, options: ) && true end |
#remove_members(members: required("members"), options: {}, **data) ⇒ Object
Removes the specified list of members from the portfolio. Returns the updated portfolio record.
161 162 163 164 |
# File 'lib/asana/resources/portfolio.rb', line 161 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("/portfolios/#{gid}/removeMembers", body: with_params, options: )).first) end |
#update(options: {}, **data) ⇒ Object
An existing portfolio can be updated by making a PUT request on the URL for that portfolio. Only the fields provided in the ‘data` block will be updated; any unspecified fields will remain unchanged.
94 95 96 97 |
# File 'lib/asana/resources/portfolio.rb', line 94 def update(options: {}, **data) refresh_with(parse(client.put("/portfolios/#{gid}", body: data, options: )).first) end |