Class: Asana::Resources::User
- Defined in:
- lib/asana/resources/user.rb
Overview
A user object represents an account in Asana that can be given access to various workspaces, projects, and tasks.
Like other objects in the system, users are referred to by numerical IDs. However, the special string identifier ‘me` can be used anywhere a user ID is accepted, to refer to the current authenticated user.
Instance Attribute Summary collapse
- #email ⇒ Object readonly
- #gid ⇒ Object readonly
- #id ⇒ Object readonly
- #name ⇒ Object readonly
- #photo ⇒ Object readonly
- #resource_type ⇒ Object readonly
- #workspaces ⇒ Object readonly
Class Method Summary collapse
-
.find_all(client, workspace: nil, per_page: 20, options: {}) ⇒ Object
Returns the user records for all users in all workspaces and organizations accessible to the authenticated user.
-
.find_by_id(client, id, options: {}) ⇒ Object
Returns the full user record for the single user with the provided ID.
-
.find_by_workspace(client, workspace: required("workspace"), per_page: 20, options: {}) ⇒ Object
Returns the user records for all users in the specified workspace or organization.
-
.me(client, options: {}) ⇒ Object
Returns the full user record for the currently authenticated user.
-
.plural_name ⇒ Object
Returns the plural name of the resource.
Instance Method Summary collapse
-
#get_user_favorites(workspace: required("workspace"), resource_type: required("resource_type"), options: {}) ⇒ Object
Returns all of a user’s favorites in the given workspace, of the given type.
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
#email ⇒ Object (readonly)
23 24 25 |
# File 'lib/asana/resources/user.rb', line 23 def email @email end |
#gid ⇒ Object (readonly)
17 18 19 |
# File 'lib/asana/resources/user.rb', line 17 def gid @gid end |
#id ⇒ Object (readonly)
15 16 17 |
# File 'lib/asana/resources/user.rb', line 15 def id @id end |
#name ⇒ Object (readonly)
21 22 23 |
# File 'lib/asana/resources/user.rb', line 21 def name @name end |
#photo ⇒ Object (readonly)
25 26 27 |
# File 'lib/asana/resources/user.rb', line 25 def photo @photo end |
#resource_type ⇒ Object (readonly)
19 20 21 |
# File 'lib/asana/resources/user.rb', line 19 def resource_type @resource_type end |
#workspaces ⇒ Object (readonly)
27 28 29 |
# File 'lib/asana/resources/user.rb', line 27 def workspaces @workspaces end |
Class Method Details
.find_all(client, workspace: nil, per_page: 20, options: {}) ⇒ Object
Returns the user records for all users in all workspaces and organizations accessible to the authenticated user. Accepts an optional workspace ID parameter.
73 74 75 76 |
# File 'lib/asana/resources/user.rb', line 73 def find_all(client, workspace: nil, per_page: 20, options: {}) params = { workspace: workspace, limit: per_page }.reject { |_,v| v.nil? || Array(v).empty? } Collection.new(parse(client.get("/users", params: params, options: )), type: self, client: client) end |
.find_by_id(client, id, options: {}) ⇒ Object
Returns the full user record for the single user with the provided ID.
50 51 52 53 |
# File 'lib/asana/resources/user.rb', line 50 def find_by_id(client, id, options: {}) self.new(parse(client.get("/users/#{id}", options: )).first, client: client) end |
.find_by_workspace(client, workspace: required("workspace"), per_page: 20, options: {}) ⇒ Object
Returns the user records for all users in the specified workspace or organization.
61 62 63 64 |
# File 'lib/asana/resources/user.rb', line 61 def find_by_workspace(client, workspace: required("workspace"), per_page: 20, options: {}) params = { limit: per_page }.reject { |_,v| v.nil? || Array(v).empty? } Collection.new(parse(client.get("/workspaces/#{workspace}/users", params: params, options: )), type: self, client: client) end |
.me(client, options: {}) ⇒ Object
Returns the full user record for the currently authenticated user.
38 39 40 41 |
# File 'lib/asana/resources/user.rb', line 38 def me(client, options: {}) Resource.new(parse(client.get("/users/me", options: )).first, client: client) end |
.plural_name ⇒ Object
Returns the plural name of the resource.
31 32 33 |
# File 'lib/asana/resources/user.rb', line 31 def plural_name 'users' end |
Instance Method Details
#get_user_favorites(workspace: required("workspace"), resource_type: required("resource_type"), options: {}) ⇒ Object
Returns all of a user’s favorites in the given workspace, of the given type. Results are given in order (The same order as Asana’s sidebar).
85 86 87 88 |
# File 'lib/asana/resources/user.rb', line 85 def get_user_favorites(workspace: required("workspace"), resource_type: required("resource_type"), options: {}) params = { workspace: workspace, resource_type: resource_type }.reject { |_,v| v.nil? || Array(v).empty? } Collection.new(parse(client.get("/users/#{gid}/favorites", params: params, options: )), type: Resource, client: client) end |