-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from coreyjs/enhance/4
Enhance/4
- Loading branch information
Showing
7 changed files
with
163 additions
and
37 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
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 |
---|---|---|
@@ -1,14 +1,26 @@ | ||
from typing import Optional | ||
from typing import Optional, List | ||
from nhlpy.api import BaseNHLAPIClient | ||
|
||
|
||
class Schedule(BaseNHLAPIClient): | ||
def get_schedule(self, season: Optional[str] = None) -> dict: | ||
def get_schedule( | ||
self, season: str, game_type: str = "R", team_ids: Optional[List[int]] = None | ||
) -> dict: | ||
""" | ||
Returns a list of all games for the current season if no season is supplied. Otherwise returns the | ||
schedule for the season defined in the season: param. | ||
:param season: Season in format of 20202021 | ||
:return: | ||
:param season: str - Season in format of 20202021 | ||
:param game_type: str - Game type, R (default) for regular season, P for playoffs, PR for preseason, A for all-star | ||
:param team_ids: List[int] - List of team ids | ||
example: c.schedule.get_schedule(season="20222023", team_ids=[7], game_type='PR') | ||
:return: dict | ||
""" | ||
query = f"?season={season}" if season else "" | ||
return self._get(resource=f"schedule{query}").json() | ||
q: str = f"?season={season}" | ||
team_q: str = ( | ||
f"&teamId={','.join(str(t) for t in team_ids)}" if team_ids else "" | ||
) | ||
type_q: str = f"&gameType={game_type}" | ||
|
||
return self._get(resource=f"schedule{q}{type_q}{team_q}").json() |
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 |
---|---|---|
|
@@ -4,8 +4,8 @@ build-backend = "poetry.core.masonry.api" | |
|
||
[tool.poetry] | ||
name = "nhl-api-py" | ||
version = "0.3.0" | ||
description = "NHL API Wrapper. For standings, team stats, outcomes and player information." | ||
version = "0.4.1" | ||
description = "NHL API. For standings, team stats, outcomes, player information. Contains each individual API endpoint as well as convience methods for easy data loading in Pandas or any ML applications." | ||
authors = ["Corey Schaf <[email protected]>"] | ||
readme = "README.md" | ||
packages = [{include = "nhlpy"}] | ||
|