Module: StrawberryAPI::Client::Teams

Included in:
StrawberryAPI::Client
Defined in:
lib/strawberry_api/client/teams.rb

Instance Method Summary collapse

Instance Method Details

#add_user_to_team(team_id:, user_id:) ⇒ Boolean

Adds a user to a team

Parameters:

  • team_id (Integer)

    Id of the team the user should be added to

  • user_id (Integer)

    Id of the user to add the team to

Returns:

  • (Boolean)

    Success



90
91
92
# 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) ⇒ StrawberryAPI::Team

Creates a new team

Parameters:

  • name (String)

    Name of the team to create

  • [Integer] (Hash)

    a customizable set of options

  • [Boolean] (Hash)

    a customizable set of options

Returns:



46
47
48
49
50
51
52
53
54
55
# 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:) ⇒ Boolean

Deletes a team

Parameters:

  • id (Integer)

    Id of the team to delete

Returns:

  • (Boolean)

    Success



79
80
81
# 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:) ⇒ Boolean

Removes a user from a team

Parameters:

  • team_id (Integer)

    Id of the team the user should be removed from

  • user_id (Integer)

    Id of the user to remove from the team

Returns:

  • (Boolean)

    Success



101
102
103
# 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:) ⇒ StrawberryAPI::Team

Fetches a team

Parameters:

  • id (Integer)

    Id of the team to retrieve

Returns:



22
23
24
25
# 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

#teamsArray<StrawberryAPI::Team>

Fetches all teams

Returns:



10
11
12
13
14
# 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) ⇒ StrawberryAPI::Team

Updates a team

Parameters:

  • id (Integer)

    Id of the user to update

  • options (Hash)

    a customizable set of options

Options Hash (**options):

  • :name (String)
  • :quota (String)
  • :quota_mail_sent (String)

Returns:



66
67
68
69
70
71
# 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_teamsArray<StrawberryAPI::Team>

Featches the current user team

Returns:



32
33
34
35
36
# 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