class Asana::Resources::User
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.
Attributes
Public Class Methods
Returns the user records for all users in all workspaces and organizations accessible to the authenticated user. Accepts an optional workspace ID parameter.
workspace - [Id] The workspace or organization to filter users on. per_page - [Integer] the number of records to fetch per page. options - [Hash] the request I/O options.
# File lib/asana/resources/user.rb, line 69 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: options)), type: self, client: client) end
Returns the full user record for the single user with the provided ID.
user - [String] An identifier for the user. Can be one of an email address, the globally unique identifier for the user, or the keyword `me` to indicate the current user making the request.
options - [Hash] the request I/O options.
# File lib/asana/resources/user.rb, line 46 def find_by_id(client, user: required("user"), options: {}) params = { user: user }.reject { |_,v| v.nil? || Array(v).empty? } Resource.new(parse(client.get("/users/%s", params: params, options: options)).first, client: client) end
Returns the user records for all users in the specified workspace or organization.
workspace - [Id] The workspace in which to get users. per_page - [Integer] the number of records to fetch per page. options - [Hash] the request I/O options.
# File lib/asana/resources/user.rb, line 57 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: options)), type: self, client: client) end
Returns the full user record for the currently authenticated user.
options - [Hash] the request I/O options.
# File lib/asana/resources/user.rb, line 34 def me(client, options: {}) Resource.new(parse(client.get("/users/me", options: options)).first, client: client) end
Returns the plural name of the resource.
# File lib/asana/resources/user.rb, line 27 def plural_name 'users' end