from nba_api.stats.endpoints._base import Endpoint
from nba_api.stats.library.http import NBAStatsHTTP
from nba_api.stats.library.parameters import ConferenceNullable, DivisionSimpleNullable, LeagueIDNullable, LocationNullable, OutcomeNullable, SeasonNullable, SeasonSegmentNullable, SeasonTypeNullable, DivisionNullable


class TeamGameStreakFinder(Endpoint):
    endpoint = 'teamgamestreakfinder'
    expected_data = {'TeamGameStreakFinderParametersResults': ['TEAM_NAME', 'TEAM_ID', 'GAMESTREAK', 'STARTDATE', 'ENDDATE', 'ACTIVESTREAK', 'NUMSEASONS', 'LASTSEASON', 'FIRSTSEASON', 'ABBREVIATION']}

    nba_response = None
    data_sets = None
    player_stats = None
    team_stats = None
    headers = None

    def __init__(self,
                 active_streaks_only_nullable='',
                 active_teams_only_nullable='',
                 btr_opp_ast_nullable='',
                 btr_opp_blk_nullable='',
                 btr_opp_dreb_nullable='',
                 btr_opp_fg3a_nullable='',
                 btr_opp_fg3m_nullable='',
                 btr_opp_fg3_pct_nullable='',
                 btr_opp_fga_nullable='',
                 btr_opp_fgm_nullable='',
                 btr_opp_fg_pct_nullable='',
                 btr_opp_fta_nullable='',
                 btr_opp_ftm_nullable='',
                 btr_opp_ft_pct_nullable='',
                 btr_opp_oreb_nullable='',
                 btr_opp_pf_nullable='',
                 btr_opp_pts_nullable='',
                 btr_opp_pts2nd_chance_nullable='',
                 btr_opp_pts_fb_nullable='',
                 btr_opp_pts_off_tov_nullable='',
                 btr_opp_pts_paint_nullable='',
                 btr_opp_reb_nullable='',
                 btr_opp_stl_nullable='',
                 btr_opp_tov_nullable='',
                 conference_nullable=ConferenceNullable.default,
                 date_from_nullable='',
                 date_to_nullable='',
                 division_simple_nullable=DivisionSimpleNullable.default,
                 eq_ast_nullable='',
                 eq_blk_nullable='',
                 eq_dd_nullable='',
                 eq_dreb_nullable='',
                 eq_fg3a_nullable='',
                 eq_fg3m_nullable='',
                 eq_fg3_pct_nullable='',
                 eq_fga_nullable='',
                 eq_fgm_nullable='',
                 eq_fg_pct_nullable='',
                 eq_fta_nullable='',
                 eq_ftm_nullable='',
                 eq_ft_pct_nullable='',
                 eq_minutes_nullable='',
                 eq_opp_pts2nd_chance_nullable='',
                 eq_opp_pts_fb_nullable='',
                 eq_opp_pts_off_tov_nullable='',
                 eq_opp_pts_paint_nullable='',
                 eq_oreb_nullable='',
                 eq_pf_nullable='',
                 eq_pts_nullable='',
                 eq_pts2nd_chance_nullable='',
                 eq_pts_fb_nullable='',
                 eq_pts_off_tov_nullable='',
                 eq_pts_paint_nullable='',
                 eq_reb_nullable='',
                 eq_stl_nullable='',
                 eq_td_nullable='',
                 eq_tov_nullable='',
                 game_id_nullable='',
                 gt_ast_nullable='',
                 gt_blk_nullable='',
                 gt_dd_nullable='',
                 gt_dreb_nullable='',
                 gt_fg3a_nullable='',
                 gt_fg3m_nullable='',
                 gt_fg3_pct_nullable='',
                 gt_fga_nullable='',
                 gt_fgm_nullable='',
                 gt_fg_pct_nullable='',
                 gt_fta_nullable='',
                 gt_ftm_nullable='',
                 gt_ft_pct_nullable='',
                 gt_minutes_nullable='',
                 gt_opp_ast_nullable='',
                 gt_opp_blk_nullable='',
                 gt_opp_dreb_nullable='',
                 gt_opp_fg3a_nullable='',
                 gt_opp_fg3m_nullable='',
                 gt_opp_fg3_pct_nullable='',
                 gt_opp_fga_nullable='',
                 gt_opp_fgm_nullable='',
                 gt_opp_fg_pct_nullable='',
                 gt_opp_fta_nullable='',
                 gt_opp_ftm_nullable='',
                 gt_opp_ft_pct_nullable='',
                 gt_opp_oreb_nullable='',
                 gt_opp_pf_nullable='',
                 gt_opp_pts_nullable='',
                 gt_opp_pts2nd_chance_nullable='',
                 gt_opp_pts_fb_nullable='',
                 gt_opp_pts_off_tov_nullable='',
                 gt_opp_pts_paint_nullable='',
                 gt_opp_reb_nullable='',
                 gt_opp_stl_nullable='',
                 gt_opp_tov_nullable='',
                 gt_oreb_nullable='',
                 gt_pf_nullable='',
                 gt_pts_nullable='',
                 gt_pts2nd_chance_nullable='',
                 gt_pts_fb_nullable='',
                 gt_pts_off_tov_nullable='',
                 gt_pts_paint_nullable='',
                 gt_reb_nullable='',
                 gt_stl_nullable='',
                 gt_td_nullable='',
                 gt_tov_nullable='',
                 lstreak_nullable='',
                 league_id_nullable=LeagueIDNullable.default,
                 location_nullable=LocationNullable.default,
                 lt_ast_nullable='',
                 lt_blk_nullable='',
                 lt_dd_nullable='',
                 lt_dreb_nullable='',
                 lt_fg3a_nullable='',
                 lt_fg3m_nullable='',
                 lt_fg3_pct_nullable='',
                 lt_fga_nullable='',
                 lt_fgm_nullable='',
                 lt_fg_pct_nullable='',
                 lt_fta_nullable='',
                 lt_ftm_nullable='',
                 lt_ft_pct_nullable='',
                 lt_minutes_nullable='',
                 lt_opp_ast_nullable='',
                 lt_opp_blk_nullable='',
                 lt_opp_dreb_nullable='',
                 lt_opp_fg3a_nullable='',
                 lt_opp_fg3m_nullable='',
                 lt_opp_fg3_pct_nullable='',
                 lt_opp_fga_nullable='',
                 lt_opp_fgm_nullable='',
                 lt_opp_fg_pct_nullable='',
                 lt_opp_fta_nullable='',
                 lt_opp_ftm_nullable='',
                 lt_opp_ft_pct_nullable='',
                 lt_opp_oreb_nullable='',
                 lt_opp_pf_nullable='',
                 lt_opp_pts_nullable='',
                 lt_opp_pts2nd_chance_nullable='',
                 lt_opp_pts_fb_nullable='',
                 lt_opp_pts_off_tov_nullable='',
                 lt_opp_pts_paint_nullable='',
                 lt_opp_reb_nullable='',
                 lt_opp_stl_nullable='',
                 lt_opp_tov_nullable='',
                 lt_oreb_nullable='',
                 lt_pf_nullable='',
                 lt_pts_nullable='',
                 lt_pts2nd_chance_nullable='',
                 lt_pts_fb_nullable='',
                 lt_pts_off_tov_nullable='',
                 lt_pts_paint_nullable='',
                 lt_reb_nullable='',
                 lt_stl_nullable='',
                 lt_td_nullable='',
                 lt_tov_nullable='',
                 min_games_nullable='',
                 outcome_nullable=OutcomeNullable.default,
                 po_round_nullable='',
                 season_nullable=SeasonNullable.default,
                 season_segment_nullable=SeasonSegmentNullable.default,
                 season_type_nullable=SeasonTypeNullable.default,
                 team_id_nullable='',
                 vs_conference_nullable=ConferenceNullable.default,
                 vs_division_nullable=DivisionNullable.default,
                 vs_team_id_nullable='',
                 wstreak_nullable='',
                 wrs_opp_ast_nullable='',
                 wrs_opp_blk_nullable='',
                 wrs_opp_dreb_nullable='',
                 wrs_opp_fg3a_nullable='',
                 wrs_opp_fg3m_nullable='',
                 wrs_opp_fg3_pct_nullable='',
                 wrs_opp_fga_nullable='',
                 wrs_opp_fgm_nullable='',
                 wrs_opp_fg_pct_nullable='',
                 wrs_opp_fta_nullable='',
                 wrs_opp_ftm_nullable='',
                 wrs_opp_ft_pct_nullable='',
                 wrs_opp_oreb_nullable='',
                 wrs_opp_pf_nullable='',
                 wrs_opp_pts_nullable='',
                 wrs_opp_pts2nd_chance_nullable='',
                 wrs_opp_pts_fb_nullable='',
                 wrs_opp_pts_off_tov_nullable='',
                 wrs_opp_pts_paint_nullable='',
                 wrs_opp_reb_nullable='',
                 wrs_opp_stl_nullable='',
                 wrs_opp_tov_nullable='',
                 proxy=None,
                 headers=None,
                 timeout=30,
                 get_request=True):
        self.proxy = proxy
        if headers is not None:
            self.headers = headers
        self.timeout = timeout
        self.parameters = {
                'ActiveStreaksOnly': active_streaks_only_nullable,
                'ActiveTeamsOnly': active_teams_only_nullable,
                'BtrOPPAST': btr_opp_ast_nullable,
                'BtrOPPBLK': btr_opp_blk_nullable,
                'BtrOPPDREB': btr_opp_dreb_nullable,
                'BtrOPPFG3A': btr_opp_fg3a_nullable,
                'BtrOPPFG3M': btr_opp_fg3m_nullable,
                'BtrOPPFG3PCT': btr_opp_fg3_pct_nullable,
                'BtrOPPFGA': btr_opp_fga_nullable,
                'BtrOPPFGM': btr_opp_fgm_nullable,
                'BtrOPPFG_PCT': btr_opp_fg_pct_nullable,
                'BtrOPPFTA': btr_opp_fta_nullable,
                'BtrOPPFTM': btr_opp_ftm_nullable,
                'BtrOPPFT_PCT': btr_opp_ft_pct_nullable,
                'BtrOPPOREB': btr_opp_oreb_nullable,
                'BtrOPPPF': btr_opp_pf_nullable,
                'BtrOPPPTS': btr_opp_pts_nullable,
                'BtrOPPPTS2NDCHANCE': btr_opp_pts2nd_chance_nullable,
                'BtrOPPPTSFB': btr_opp_pts_fb_nullable,
                'BtrOPPPTSOFFTOV': btr_opp_pts_off_tov_nullable,
                'BtrOPPPTSPAINT': btr_opp_pts_paint_nullable,
                'BtrOPPREB': btr_opp_reb_nullable,
                'BtrOPPSTL': btr_opp_stl_nullable,
                'BtrOPPTOV': btr_opp_tov_nullable,
                'Conference': conference_nullable,
                'DateFrom': date_from_nullable,
                'DateTo': date_to_nullable,
                'Division': division_simple_nullable,
                'EqAST': eq_ast_nullable,
                'EqBLK': eq_blk_nullable,
                'EqDD': eq_dd_nullable,
                'EqDREB': eq_dreb_nullable,
                'EqFG3A': eq_fg3a_nullable,
                'EqFG3M': eq_fg3m_nullable,
                'EqFG3_PCT': eq_fg3_pct_nullable,
                'EqFGA': eq_fga_nullable,
                'EqFGM': eq_fgm_nullable,
                'EqFG_PCT': eq_fg_pct_nullable,
                'EqFTA': eq_fta_nullable,
                'EqFTM': eq_ftm_nullable,
                'EqFT_PCT': eq_ft_pct_nullable,
                'EqMINUTES': eq_minutes_nullable,
                'EqOPPPTS2NDCHANCE': eq_opp_pts2nd_chance_nullable,
                'EqOPPPTSFB': eq_opp_pts_fb_nullable,
                'EqOPPPTSOFFTOV': eq_opp_pts_off_tov_nullable,
                'EqOPPPTSPAINT': eq_opp_pts_paint_nullable,
                'EqOREB': eq_oreb_nullable,
                'EqPF': eq_pf_nullable,
                'EqPTS': eq_pts_nullable,
                'EqPTS2NDCHANCE': eq_pts2nd_chance_nullable,
                'EqPTSFB': eq_pts_fb_nullable,
                'EqPTSOFFTOV': eq_pts_off_tov_nullable,
                'EqPTSPAINT': eq_pts_paint_nullable,
                'EqREB': eq_reb_nullable,
                'EqSTL': eq_stl_nullable,
                'EqTD': eq_td_nullable,
                'EqTOV': eq_tov_nullable,
                'GameID': game_id_nullable,
                'GtAST': gt_ast_nullable,
                'GtBLK': gt_blk_nullable,
                'GtDD': gt_dd_nullable,
                'GtDREB': gt_dreb_nullable,
                'GtFG3A': gt_fg3a_nullable,
                'GtFG3M': gt_fg3m_nullable,
                'GtFG3_PCT': gt_fg3_pct_nullable,
                'GtFGA': gt_fga_nullable,
                'GtFGM': gt_fgm_nullable,
                'GtFG_PCT': gt_fg_pct_nullable,
                'GtFTA': gt_fta_nullable,
                'GtFTM': gt_ftm_nullable,
                'GtFT_PCT': gt_ft_pct_nullable,
                'GtMINUTES': gt_minutes_nullable,
                'GtOPPAST': gt_opp_ast_nullable,
                'GtOPPBLK': gt_opp_blk_nullable,
                'GtOPPDREB': gt_opp_dreb_nullable,
                'GtOPPFG3A': gt_opp_fg3a_nullable,
                'GtOPPFG3M': gt_opp_fg3m_nullable,
                'GtOPPFG3PCT': gt_opp_fg3_pct_nullable,
                'GtOPPFGA': gt_opp_fga_nullable,
                'GtOPPFGM': gt_opp_fgm_nullable,
                'GtOPPFG_PCT': gt_opp_fg_pct_nullable,
                'GtOPPFTA': gt_opp_fta_nullable,
                'GtOPPFTM': gt_opp_ftm_nullable,
                'GtOPPFT_PCT': gt_opp_ft_pct_nullable,
                'GtOPPOREB': gt_opp_oreb_nullable,
                'GtOPPPF': gt_opp_pf_nullable,
                'GtOPPPTS': gt_opp_pts_nullable,
                'GtOPPPTS2NDCHANCE': gt_opp_pts2nd_chance_nullable,
                'GtOPPPTSFB': gt_opp_pts_fb_nullable,
                'GtOPPPTSOFFTOV': gt_opp_pts_off_tov_nullable,
                'GtOPPPTSPAINT': gt_opp_pts_paint_nullable,
                'GtOPPREB': gt_opp_reb_nullable,
                'GtOPPSTL': gt_opp_stl_nullable,
                'GtOPPTOV': gt_opp_tov_nullable,
                'GtOREB': gt_oreb_nullable,
                'GtPF': gt_pf_nullable,
                'GtPTS': gt_pts_nullable,
                'GtPTS2NDCHANCE': gt_pts2nd_chance_nullable,
                'GtPTSFB': gt_pts_fb_nullable,
                'GtPTSOFFTOV': gt_pts_off_tov_nullable,
                'GtPTSPAINT': gt_pts_paint_nullable,
                'GtREB': gt_reb_nullable,
                'GtSTL': gt_stl_nullable,
                'GtTD': gt_td_nullable,
                'GtTOV': gt_tov_nullable,
                'LStreak': lstreak_nullable,
                'LeagueID': league_id_nullable,
                'Location': location_nullable,
                'LtAST': lt_ast_nullable,
                'LtBLK': lt_blk_nullable,
                'LtDD': lt_dd_nullable,
                'LtDREB': lt_dreb_nullable,
                'LtFG3A': lt_fg3a_nullable,
                'LtFG3M': lt_fg3m_nullable,
                'LtFG3_PCT': lt_fg3_pct_nullable,
                'LtFGA': lt_fga_nullable,
                'LtFGM': lt_fgm_nullable,
                'LtFG_PCT': lt_fg_pct_nullable,
                'LtFTA': lt_fta_nullable,
                'LtFTM': lt_ftm_nullable,
                'LtFT_PCT': lt_ft_pct_nullable,
                'LtMINUTES': lt_minutes_nullable,
                'LtOPPAST': lt_opp_ast_nullable,
                'LtOPPBLK': lt_opp_blk_nullable,
                'LtOPPDREB': lt_opp_dreb_nullable,
                'LtOPPFG3A': lt_opp_fg3a_nullable,
                'LtOPPFG3M': lt_opp_fg3m_nullable,
                'LtOPPFG3PCT': lt_opp_fg3_pct_nullable,
                'LtOPPFGA': lt_opp_fga_nullable,
                'LtOPPFGM': lt_opp_fgm_nullable,
                'LtOPPFG_PCT': lt_opp_fg_pct_nullable,
                'LtOPPFTA': lt_opp_fta_nullable,
                'LtOPPFTM': lt_opp_ftm_nullable,
                'LtOPPFT_PCT': lt_opp_ft_pct_nullable,
                'LtOPPOREB': lt_opp_oreb_nullable,
                'LtOPPPF': lt_opp_pf_nullable,
                'LtOPPPTS': lt_opp_pts_nullable,
                'LtOPPPTS2NDCHANCE': lt_opp_pts2nd_chance_nullable,
                'LtOPPPTSFB': lt_opp_pts_fb_nullable,
                'LtOPPPTSOFFTOV': lt_opp_pts_off_tov_nullable,
                'LtOPPPTSPAINT': lt_opp_pts_paint_nullable,
                'LtOPPREB': lt_opp_reb_nullable,
                'LtOPPSTL': lt_opp_stl_nullable,
                'LtOPPTOV': lt_opp_tov_nullable,
                'LtOREB': lt_oreb_nullable,
                'LtPF': lt_pf_nullable,
                'LtPTS': lt_pts_nullable,
                'LtPTS2NDCHANCE': lt_pts2nd_chance_nullable,
                'LtPTSFB': lt_pts_fb_nullable,
                'LtPTSOFFTOV': lt_pts_off_tov_nullable,
                'LtPTSPAINT': lt_pts_paint_nullable,
                'LtREB': lt_reb_nullable,
                'LtSTL': lt_stl_nullable,
                'LtTD': lt_td_nullable,
                'LtTOV': lt_tov_nullable,
                'MinGames': min_games_nullable,
                'Outcome': outcome_nullable,
                'PORound': po_round_nullable,
                'Season': season_nullable,
                'SeasonSegment': season_segment_nullable,
                'SeasonType': season_type_nullable,
                'TeamID': team_id_nullable,
                'VsConference': vs_conference_nullable,
                'VsDivision': vs_division_nullable,
                'VsTeamID': vs_team_id_nullable,
                'WStreak': wstreak_nullable,
                'WrsOPPAST': wrs_opp_ast_nullable,
                'WrsOPPBLK': wrs_opp_blk_nullable,
                'WrsOPPDREB': wrs_opp_dreb_nullable,
                'WrsOPPFG3A': wrs_opp_fg3a_nullable,
                'WrsOPPFG3M': wrs_opp_fg3m_nullable,
                'WrsOPPFG3PCT': wrs_opp_fg3_pct_nullable,
                'WrsOPPFGA': wrs_opp_fga_nullable,
                'WrsOPPFGM': wrs_opp_fgm_nullable,
                'WrsOPPFG_PCT': wrs_opp_fg_pct_nullable,
                'WrsOPPFTA': wrs_opp_fta_nullable,
                'WrsOPPFTM': wrs_opp_ftm_nullable,
                'WrsOPPFT_PCT': wrs_opp_ft_pct_nullable,
                'WrsOPPOREB': wrs_opp_oreb_nullable,
                'WrsOPPPF': wrs_opp_pf_nullable,
                'WrsOPPPTS': wrs_opp_pts_nullable,
                'WrsOPPPTS2NDCHANCE': wrs_opp_pts2nd_chance_nullable,
                'WrsOPPPTSFB': wrs_opp_pts_fb_nullable,
                'WrsOPPPTSOFFTOV': wrs_opp_pts_off_tov_nullable,
                'WrsOPPPTSPAINT': wrs_opp_pts_paint_nullable,
                'WrsOPPREB': wrs_opp_reb_nullable,
                'WrsOPPSTL': wrs_opp_stl_nullable,
                'WrsOPPTOV': wrs_opp_tov_nullable
        }
        if get_request:
            self.get_request()
    
    def get_request(self):
        self.nba_response = NBAStatsHTTP().send_api_request(
            endpoint=self.endpoint,
            parameters=self.parameters,
            proxy=self.proxy,
            headers=self.headers,
            timeout=self.timeout,
        )
        self.load_response()
        
    def load_response(self):
        data_sets = self.nba_response.get_data_sets()
        self.data_sets = [Endpoint.DataSet(data=data_set) for data_set_name, data_set in data_sets.items()]
        self.team_game_streak_finder_parameters_results = Endpoint.DataSet(data=data_sets['TeamGameStreakFinderParametersResults'])
