Class: Asana::Resources::Team
- Defined in:
- lib/asana/resources/team.rb
Overview
A team is used to group related projects and people together within an organization. Each project in an organization is associated with a team.
Instance Attribute Summary collapse
- #description ⇒ Object readonly
- #gid ⇒ Object readonly
- #html_description ⇒ Object readonly
- #name ⇒ Object readonly
- #organization ⇒ Object readonly
- #resource_type ⇒ Object readonly
Class Method Summary collapse
-
.find_by_id(client, id, options: {}) ⇒ Object
Returns the full record for a single team.
-
.find_by_organization(client, organization: required("organization"), per_page: 20, options: {}) ⇒ Object
Returns the compact records for all teams in the organization visible to the authorized user.
-
.find_by_user(client, user: required("user"), organization: nil, per_page: 20, options: {}) ⇒ Object
Returns the compact records for all teams to which user is assigned.
-
.plural_name ⇒ Object
Returns the plural name of the resource.
Instance Method Summary collapse
-
#add_user(user: required("user"), options: {}, **data) ⇒ Object
The user making this call must be a member of the team in order to add others.
-
#remove_user(user: required("user"), options: {}, **data) ⇒ Object
The user to remove can be referenced by their globally unique user ID or their email address.
-
#users(per_page: 20, options: {}) ⇒ Object
Returns the compact records for all users that are members of the team.
Methods inherited from TeamsBase
add_user_for_team, create_team, get_team, get_teams_for_user, get_teams_for_workspace, inherited, remove_user_for_team, update_team
Methods inherited from Resource
#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
#description ⇒ Object (readonly)
16 17 18 |
# File 'lib/asana/resources/team.rb', line 16 def description @description end |
#gid ⇒ Object (readonly)
10 11 12 |
# File 'lib/asana/resources/team.rb', line 10 def gid @gid end |
#html_description ⇒ Object (readonly)
18 19 20 |
# File 'lib/asana/resources/team.rb', line 18 def html_description @html_description end |
#name ⇒ Object (readonly)
14 15 16 |
# File 'lib/asana/resources/team.rb', line 14 def name @name end |
#organization ⇒ Object (readonly)
20 21 22 |
# File 'lib/asana/resources/team.rb', line 20 def organization @organization end |
#resource_type ⇒ Object (readonly)
12 13 14 |
# File 'lib/asana/resources/team.rb', line 12 def resource_type @resource_type end |
Class Method Details
.find_by_id(client, id, options: {}) ⇒ Object
Returns the full record for a single team.
33 34 35 36 |
# File 'lib/asana/resources/team.rb', line 33 def find_by_id(client, id, options: {}) self.new(parse(client.get("/teams/#{id}", options: )).first, client: client) end |
.find_by_organization(client, organization: required("organization"), per_page: 20, options: {}) ⇒ Object
Returns the compact records for all teams in the organization visible to the authorized user.
45 46 47 48 |
# File 'lib/asana/resources/team.rb', line 45 def find_by_organization(client, organization: required("organization"), per_page: 20, options: {}) params = { limit: per_page }.reject { |_,v| v.nil? || Array(v).empty? } Collection.new(parse(client.get("/organizations/#{organization}/teams", params: params, options: )), type: self, client: client) end |
.find_by_user(client, user: required("user"), organization: nil, per_page: 20, options: {}) ⇒ Object
Returns the compact records for all teams to which user is assigned.
59 60 61 62 |
# File 'lib/asana/resources/team.rb', line 59 def find_by_user(client, user: required("user"), organization: nil, per_page: 20, options: {}) params = { organization: organization, limit: per_page }.reject { |_,v| v.nil? || Array(v).empty? } Collection.new(parse(client.get("/users/#{user}/teams", params: params, options: )), type: self, client: client) end |
.plural_name ⇒ Object
Returns the plural name of the resource.
24 25 26 |
# File 'lib/asana/resources/team.rb', line 24 def plural_name 'teams' end |
Instance Method Details
#add_user(user: required("user"), options: {}, **data) ⇒ Object
The user making this call must be a member of the team in order to add others. The user to add must exist in the same organization as the team in order to be added. The user to add can be referenced by their globally unique user ID or their email address.
85 86 87 88 |
# File 'lib/asana/resources/team.rb', line 85 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("/teams/#{gid}/addUser", body: with_params, options: )).first, client: client) end |
#remove_user(user: required("user"), options: {}, **data) ⇒ Object
The user to remove can be referenced by their globally unique user ID or their email address. Removes the user from the specified team. Returns an empty data record.
99 100 101 102 |
# File 'lib/asana/resources/team.rb', line 99 def remove_user(user: required("user"), options: {}, **data) with_params = data.merge(user: user).reject { |_,v| v.nil? || Array(v).empty? } client.post("/teams/#{gid}/removeUser", body: with_params, options: ) && true end |
#users(per_page: 20, options: {}) ⇒ Object
Returns the compact records for all users that are members of the team.
69 70 71 72 |
# File 'lib/asana/resources/team.rb', line 69 def users(per_page: 20, options: {}) params = { limit: per_page }.reject { |_,v| v.nil? || Array(v).empty? } Collection.new(parse(client.get("/teams/#{gid}/users", params: params, options: )), type: User, client: client) end |