-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Gamecenter endpoints added. For boxscore, landing, play-by-play and s…
…core/now
- Loading branch information
Showing
7 changed files
with
68 additions
and
138 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
# Should this be driven by the main pyproject.toml file? yes, is it super convoluted? yes, can it wait? sure | ||
|
||
__version__ = "2.0.1" | ||
__version__ = "2.0.2" |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
from nhlpy.api import BaseNHLAPIClient | ||
|
||
|
||
class GameCenter(BaseNHLAPIClient): | ||
def boxscore(self, game_id: str) -> dict: | ||
""" | ||
Get the boxscore for the game_id. GameIds can be retrieved from the schedule endpoint. | ||
:param game_id: The game_id for the game you want the boxscore for. | ||
:return: dict | ||
""" | ||
return self._get(resource=f"gamecenter/{game_id}/boxscore").json() | ||
|
||
def play_by_play(self, game_id: str) -> dict: | ||
""" | ||
Get the play by play for the game_id. GameIds can be retrieved from the schedule endpoint. | ||
:param game_id: The game_id for the game you want the play by play for. | ||
:return: dict | ||
""" | ||
return self._get(resource=f"gamecenter/{game_id}/play-by-play").json() | ||
|
||
def landing(self, game_id: str) -> dict: | ||
""" | ||
Get verbose information about the matchup for the given game. | ||
GameIds can be retrieved from the schedule endpoint. | ||
:param game_id: The game_id for the game you want the landing page for. | ||
:return: dict | ||
""" | ||
return self._get(resource=f"gamecenter/{game_id}/landing").json() | ||
|
||
def score_now(self) -> dict: | ||
""" | ||
Get the current score of all games in progress. I think, not totally sure. | ||
:return: dict | ||
""" | ||
return self._get(resource=f"score/now").json() |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from unittest import mock | ||
|
||
|
||
@mock.patch("httpx.get") | ||
def test_boxscore(h_m, nhl_client): | ||
nhl_client.game_center.boxscore(game_id="2020020001") | ||
h_m.assert_called_once() | ||
assert h_m.call_args[1]["url"] == "https://api-web.nhle.com/v1/gamecenter/2020020001/boxscore" | ||
|
||
|
||
@mock.patch("httpx.get") | ||
def test_play_by_play(h_m, nhl_client): | ||
nhl_client.game_center.play_by_play(game_id="2020020001") | ||
h_m.assert_called_once() | ||
assert h_m.call_args[1]["url"] == "https://api-web.nhle.com/v1/gamecenter/2020020001/play-by-play" | ||
|
||
|
||
@mock.patch("httpx.get") | ||
def test_landing_page(h_m, nhl_client): | ||
nhl_client.game_center.landing(game_id="2020020001") | ||
h_m.assert_called_once() | ||
assert h_m.call_args[1]["url"] == "https://api-web.nhle.com/v1/gamecenter/2020020001/landing" | ||
|
||
@mock.patch("httpx.get") | ||
def test_score_now(h_m, nhl_client): | ||
nhl_client.game_center.score_now() | ||
h_m.assert_called_once() | ||
assert h_m.call_args[1]["url"] == "https://api-web.nhle.com/v1/score/now" |