module StrawberryAPI::Client::Teams
Public Instance Methods
Adds a user to a team
@param [Integer] team_id Id of the team the user should be added to @param [Integer] user_id Id of the user to add the team to
@return [Boolean] Success
# File lib/strawberry_api/client/teams.rb, line 90 def add_user_to_team(team_id:, user_id:) post("/users/#{team_id}/teams/#{user_id}").success? end
Creates a new team
@param [String] name Name of the team to create @option [Integer] quota: nil Quota to assign to the team @option [Boolean] quota_mail_sent: false Enable quota email notification
@return [StrawberryAPI::Team] The created team
# File lib/strawberry_api/client/teams.rb, line 46 def create_team(name:, quota: nil, quota_mail_sent: false) body = { name: name, quota: quota, quota_mail_sent: quota_mail_sent }.to_json data = post("/teams", body: body).parse['teams'] data.nil? ? nil : Team.new(data) end
Deletes a team
@param [Integer] id Id of the team to delete
@return [Boolean] Success
# File lib/strawberry_api/client/teams.rb, line 79 def delete_team(id:) delete("/teams/#{id}").success? end
Removes a user from a team
@param [Integer] team_id Id of the team the user should be removed from @param [Integer] user_id Id of the user to remove from the team
@return [Boolean] Success
# File lib/strawberry_api/client/teams.rb, line 101 def remove_user_from_team(team_id:, user_id:) delete("/users/#{team_id}/teams/#{user_id}").success? end
Fetches a team
@param [Integer] id Id of the team to retrieve
@return [StrawberryAPI::Team] The fetched team
# File lib/strawberry_api/client/teams.rb, line 22 def team(id:) data = get("/teams/#{id}").parse['team'] data.nil? ? nil : Team.new(data) end
Fetches all teams
@return [Array<StrawberryAPI::Team>] A list of teams
# File lib/strawberry_api/client/teams.rb, line 10 def teams get("/teams").parse['teams']&.map do |team| Team.new(team) end end
Updates a team
@param [Integer] id Id of the user to update @option options [String] :name @option options [String] :quota @option options [String] :quota_mail_sent
@return [StrawberryAPI::Team] The updated team
# File lib/strawberry_api/client/teams.rb, line 66 def update_team(id:, **options) body = args.to_json data = put("/teams/#{id}", body: body).parse['team'] data.nil? ? nil : Team.new(data) end
Featches the current user team
@return [Array<StrawberryAPI::Team>] The fetched current user teams
# File lib/strawberry_api/client/teams.rb, line 32 def user_owned_teams get("/teams/user_owned").parse['teams']&.map do |team| Team.new(team) end end