from fastapi import HTTPException, status

from models.team import Team
from utils.dynamo_db import DynamoDB


class TeamService:
    def __init__(self):
        self.db = DynamoDB()

    def get_team_by_id(self, team_id: str) -> Team:
        """Get team by ID"""
        team_data = self.db.get_item(self.db.team, team_id)
        if not team_data:
            return None
        return Team(**team_data)

    def update_team(self, team: Team):
        """Update team in database"""
        team.update_modify()
        self.db.upload_to_dynamodb(self.db.team, team.model_dump())
        return team
