diff --git a/cmd/internal/statsapi/client.go b/cmd/internal/statsapi/client.go index b57dcc0..f1bbf09 100644 --- a/cmd/internal/statsapi/client.go +++ b/cmd/internal/statsapi/client.go @@ -26,8 +26,8 @@ import ( var DefaultClient = NewClient(http.DefaultClient) -func RequestSchedule(sportId, teamId string) ([]byte, error) { - return DefaultClient.RequestSchedule(sportId, teamId) +func RequestSchedule(sportId, teamId, date string) ([]byte, error) { + return DefaultClient.RequestSchedule(sportId, teamId, date) } func RequestFeed(gamePk string) ([]byte, error) { @@ -76,11 +76,12 @@ func (resp *DiffPatchResponse) ExtractPatches() ([]jsonpatch.Patch, error) { return patches, err } -func (c *Client) RequestSchedule(sportId, teamId string) ([]byte, error) { +func (c *Client) RequestSchedule(sportId, teamId, date string) ([]byte, error) { endpoint := url.URL{Path: "api/v1/schedule"} query := endpoint.Query() query.Add("sportId", sportId) query.Add("teamId", teamId) + query.Add("date", date) endpoint.RawQuery = query.Encode() return c.get(&endpoint) diff --git a/cmd/schedule.go b/cmd/schedule.go index ac9a161..f438eca 100644 --- a/cmd/schedule.go +++ b/cmd/schedule.go @@ -26,6 +26,7 @@ import ( ) var team teamFlag +var date string var teamIDs = map[string]statsapi.TeamID{ "laa": statsapi.LAA, "az": statsapi.AZ, @@ -67,7 +68,7 @@ func schedule(cmd *cobra.Command, args []string) { id = strconv.Itoa(int(teamIDs[string(team)])) } - sched, err := statsapi.RequestSchedule("1", id) + sched, err := statsapi.RequestSchedule("1", id, date) if err != nil { log.Fatal(err) } @@ -95,5 +96,6 @@ func init() { // Cobra supports local flags which will only run when this command // is called directly, e.g.: - scheduleCmd.Flags().VarP(&team, "team", "t", "team to get updates for (atl, az, bal, bos, chc, cin, cle, col, cws, det, hou, kc, laa, lad, mia, mil, min, nym, nyy, oak, phi, pit, sd, sea, sf, stl, tb, tex, tor, wsh)") + scheduleCmd.Flags().VarP(&team, "team", "t", "team to get schedule for (atl, az, bal, bos, chc, cin, cle, col, cws, det, hou, kc, laa, lad, mia, mil, min, nym, nyy, oak, phi, pit, sd, sea, sf, stl, tb, tex, tor, wsh)") + scheduleCmd.Flags().StringVarP(&date, "date", "d", "", "date to get schedule for (YYYY-MM-DD)") }