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



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



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



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



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



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



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

Options Hash (**options):

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


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



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