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
- #id ⇒ 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 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
#description ⇒ Object (readonly)
19 20 21 |
# File 'lib/asana/resources/team.rb', line 19 def description @description end |
#gid ⇒ Object (readonly)
13 14 15 |
# File 'lib/asana/resources/team.rb', line 13 def gid @gid end |
#html_description ⇒ Object (readonly)
21 22 23 |
# File 'lib/asana/resources/team.rb', line 21 def html_description @html_description end |
#id ⇒ Object (readonly)
11 12 13 |
# File 'lib/asana/resources/team.rb', line 11 def id @id end |
#name ⇒ Object (readonly)
17 18 19 |
# File 'lib/asana/resources/team.rb', line 17 def name @name end |
#organization ⇒ Object (readonly)
23 24 25 |
# File 'lib/asana/resources/team.rb', line 23 def organization @organization end |
#resource_type ⇒ Object (readonly)
15 16 17 |
# File 'lib/asana/resources/team.rb', line 15 def resource_type @resource_type end |
Class Method Details
.find_by_id(client, id, options: {}) ⇒ Object
Returns the full record for a single team.
36 37 38 39 |
# File 'lib/asana/resources/team.rb', line 36 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.
48 49 50 51 |
# File 'lib/asana/resources/team.rb', line 48 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.
62 63 64 65 |
# File 'lib/asana/resources/team.rb', line 62 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.
27 28 29 |
# File 'lib/asana/resources/team.rb', line 27 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.
88 89 90 91 |
# File 'lib/asana/resources/team.rb', line 88 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.
102 103 104 105 |
# File 'lib/asana/resources/team.rb', line 102 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.
72 73 74 75 |
# File 'lib/asana/resources/team.rb', line 72 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 |