teams = $gateway; $this->members = $members; $this->users = $users; } /** * @param string $name * @param string $picture * @param string $mainColor * @param string $secondColor * @return int */ public function createTeam(string $name, string $picture, string $mainColor, string $secondColor): int { return $this->teams->insert($name, $picture, $mainColor, $secondColor); } /** * adds a member to a team * @param string $mail * @param int $teamId * @param string $role * @return void */ public function addMember(string $mail, int $teamId, string $role): void { $userId = $this->users->getAccountFromMail($mail)->getId(); $this->members->insert($teamId, $userId, $role); } /** * @param string $name * @return TeamInfo[] */ public function listByName(string $name): array { return $this->teams->listByName($name); } /** * @param int $id * @return Team */ public function getTeam(int $id): Team { $teamInfo = $this->teams->getTeamById($id); $members = $this->members->getMembersOfTeam($id); return new Team($teamInfo, $members); } /** * delete a member from given team identifier * @param string $mail * @param int $teamId * @return int */ public function deleteMember(string $mail, int $teamId): int { $userId = $this->users->getAccountFromMail($mail)->getId(); $this->members->remove($teamId, $userId); return $teamId; } }