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

email[R]
id[R]
name[R]
photo[R]
workspaces[R]

Public Class Methods

find_all(client, workspace: nil, per_page: 20, options: {}) click to toggle source

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
find_by_id(client, id, options: {}) click to toggle source

Returns the full user record for the single user with the provided ID.

id - [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, id, options: {})

  self.new(parse(client.get("/users/#{id}", options: options)).first, client: client)
end
find_by_workspace(client, workspace: required("workspace"), per_page: 20, options: {}) click to toggle source

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
me(client, options: {}) click to toggle source

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
plural_name() click to toggle source

Returns the plural name of the resource.

# File lib/asana/resources/user.rb, line 27
def plural_name
  'users'
end