
from nba import enums
from nba.utils import clean_locals
from nba.endpoints.baseendpoint import BaseEndpoint


class PlayByPlay(BaseEndpoint):

    def play_by_play(self, game_id, start_period=enums.StartPeriod.AllQuarters, end_period=enums.EndPeriod.AllQuarters):
        """
        Play by play data for a given game, comments from home, away and neutral perspective.
    
        :param game_id: ID of the game to get data for.
        :type game_id: str
        :param start_period: starting period filter on the data.
        :type start_period: nba.enums.StartPeriod
        :param end_period: ending period filter on the data.
        :type end_period: nba.enums.EndPeriod
        :returns: play by play event descriptions and details of players involved
        :rtype: DataFrame
    
        """
        params = clean_locals(locals())
        endpoint = 'playbyplayv2'
        r = self.request(endpoint, params)
        df = self.process_response(r, 0, 'resultSets')
        return df

@@ -1,16 +1,33 @@
+%0Aimport requests%0A
 %0Afrom nba import
@@ -67,16 +67,35 @@
 n_locals
+, check_status_code
 %0Afrom nb
@@ -1026,8 +1026,769 @@
 turn df%0A
+%0A    def play_by_play_detailed(self, game_id, locale='en', period='all'):%0A        %22%22%22%0A        Get detailed play by play including location data from nba stats2.%0A        %0A        :param game_id: ID of the game to get data for.%0A        :param locale: language to return data in.%0A        :param period: %0A        :return: %0A        %22%22%22%0A        params = clean_locals(locals())%0A        response = requests.get('http://uk.global.nba.com/stats2/game/playbyplay.json',%0A                                %7B'gameId': game_id, 'locale': locale, 'period': period%7D)%0A        check_status_code(response)%0A        data = %5Bevents for period in response.json().get('payload', %7B%7D).get('playByPlays', %7B%7D) for events in%0A                period.get('events', %5B%5D)%5D%0A        return data%5B::-1%5D%0A

Add detailed playbyplay from stats2 endpoint