module StrawberryAPI::Client::Teams

Public Instance Methods

add_user_to_team(team_id:, user_id:) click to toggle source

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
create_team(name:, quota: nil, quota_mail_sent: false) click to toggle source

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
delete_team(id:) click to toggle source

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
remove_user_from_team(team_id:, user_id:) click to toggle source

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
team(id:) click to toggle source

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

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
update_team(id:, **options) click to toggle source

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

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