Skip to content

Commit

Permalink
Updated schedule by week to optionally pass a date (#31)
Browse files Browse the repository at this point in the history
* Updates schedule.py

Adds optional selection of which week's schedule is pulled.
  • Loading branch information
azaroth08 authored Feb 13, 2024
1 parent ee4a581 commit 3a74735
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions nhlpy/api/schedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,16 @@ def get_schedule_by_team_by_month(self, team_abbr: str, month: Optional[str] = N
resource = f"club-schedule/{team_abbr}/month/{month if month else 'now'}"
return self.client.get(resource=resource).json()["games"]

def get_schedule_by_team_by_week(self, team_abbr: str) -> List[dict]:
def get_schedule_by_team_by_week(self, team_abbr: str, date: Optional[str] = None) -> List[dict]:
"""
This returns the schedule for the team (team_abbr) for the current week.
This returns the schedule for the team (team_abbr) for the week set or the current week if no week is specified.
:param date: Optional date, in which to search the week of. In format YYYY-MM-DD. Example "2024-02-10".
:param team_abbr: The 3 letter abbreviation of the team. BUF, TOR, etc
:return:
"""
resource = f"club-schedule/{team_abbr}/week/now"
resource = f"club-schedule/{team_abbr}/week/{date if date else 'now'}"
return self.client.get(resource=resource).json()["games"]

def get_season_schedule(self, team_abbr: str, season: str) -> dict:
Expand Down

0 comments on commit 3a74735

Please sign in to comment.