Class: Asana::Resources::Workspace
- Defined in:
- lib/asana/resources/workspace.rb
Overview
A workspace is the highest-level organizational unit in Asana. All projects and tasks have an associated workspace.
An organization is a special kind of workspace that represents a company. In an organization, you can group your projects into teams. You can read more about how organizations work on the Asana Guide. To tell if your workspace is an organization or not, check its ‘is_organization` property.
Over time, we intend to migrate most workspaces into organizations and to release more organization-specific functionality. We may eventually deprecate using workspace-based APIs for organizations. Currently, and until after some reasonable grace period following any further announcements, you can still reference organizations in any ‘workspace` parameter.
Instance Attribute Summary collapse
- #id ⇒ Object readonly
- #is_organization ⇒ Object readonly
- #name ⇒ Object readonly
Class Method Summary collapse
-
.find_all(client, per_page: 20, options: {}) ⇒ Object
Returns the compact records for all workspaces visible to the authorized user.
-
.find_by_id(client, id, options: {}) ⇒ Object
Returns the full workspace record for a single workspace.
-
.plural_name ⇒ Object
Returns the plural name of the resource.
Instance Method Summary collapse
-
#add_user(user: required("user"), options: {}, **data) ⇒ Object
The user can be referenced by their globally unique user ID or their email address.
-
#remove_user(user: required("user"), options: {}, **data) ⇒ Object
The user making this call must be an admin in the workspace.
-
#typeahead(type: required("type"), query: nil, count: nil, per_page: 20, options: {}) ⇒ Object
Retrieves objects in the workspace based on an auto-completion/typeahead search algorithm.
-
#update(options: {}, **data) ⇒ Object
A specific, existing workspace can be updated by making a PUT request on the URL for that workspace.
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
#id ⇒ Object (readonly)
23 24 25 |
# File 'lib/asana/resources/workspace.rb', line 23 def id @id end |
#is_organization ⇒ Object (readonly)
27 28 29 |
# File 'lib/asana/resources/workspace.rb', line 27 def is_organization @is_organization end |
#name ⇒ Object (readonly)
25 26 27 |
# File 'lib/asana/resources/workspace.rb', line 25 def name @name end |
Class Method Details
.find_all(client, per_page: 20, options: {}) ⇒ Object
Returns the compact records for all workspaces visible to the authorized user.
49 50 51 52 |
# File 'lib/asana/resources/workspace.rb', line 49 def find_all(client, per_page: 20, options: {}) params = { limit: per_page }.reject { |_,v| v.nil? || Array(v).empty? } Collection.new(parse(client.get("/workspaces", params: params, options: )), type: self, client: client) end |
.find_by_id(client, id, options: {}) ⇒ Object
Returns the full workspace record for a single workspace.
40 41 42 43 |
# File 'lib/asana/resources/workspace.rb', line 40 def find_by_id(client, id, options: {}) self.new(parse(client.get("/workspaces/#{id}", options: )).first, client: client) end |
.plural_name ⇒ Object
Returns the plural name of the resource.
31 32 33 |
# File 'lib/asana/resources/workspace.rb', line 31 def plural_name 'workspaces' end |
Instance Method Details
#add_user(user: required("user"), options: {}, **data) ⇒ Object
The user can be referenced by their globally unique user ID or their email address.
105 106 107 108 |
# File 'lib/asana/resources/workspace.rb', line 105 def add_user(user: required("user"), options: {}, **data) with_params = data.merge(user: user).reject { |_,v| v.nil? || Array(v).empty? } User.new(parse(client.post("/workspaces/#{id}/addUser", body: with_params, options: )).first, client: client) end |
#remove_user(user: required("user"), options: {}, **data) ⇒ Object
The user making this call must be an admin in the workspace.
119 120 121 122 |
# File 'lib/asana/resources/workspace.rb', line 119 def remove_user(user: required("user"), options: {}, **data) with_params = data.merge(user: user).reject { |_,v| v.nil? || Array(v).empty? } client.post("/workspaces/#{id}/removeUser", body: with_params, options: ) && true end |
#typeahead(type: required("type"), query: nil, count: nil, per_page: 20, options: {}) ⇒ Object
Retrieves objects in the workspace based on an auto-completion/typeahead search algorithm. This feature is meant to provide results quickly, so do not rely on this API to provide extremely accurate search results. The result set is limited to a single page of results with a maximum size, so you won’t be able to fetch large numbers of results.
91 92 93 94 |
# File 'lib/asana/resources/workspace.rb', line 91 def typeahead(type: required("type"), query: nil, count: nil, per_page: 20, options: {}) params = { type: type, query: query, count: count, limit: per_page }.reject { |_,v| v.nil? || Array(v).empty? } Collection.new(parse(client.get("/workspaces/#{id}/typeahead", params: params, options: )), type: Resource, client: client) end |
#update(options: {}, **data) ⇒ Object
A specific, existing workspace can be updated by making a PUT request on the URL for that workspace. Only the fields provided in the data block will be updated; any unspecified fields will remain unchanged.
Currently the only field that can be modified for a workspace is its ‘name`.
65 66 67 68 |
# File 'lib/asana/resources/workspace.rb', line 65 def update(options: {}, **data) refresh_with(parse(client.put("/workspaces/#{id}", body: data, options: )).first) end |