add date param
This commit is contained in:
parent
6a8e39a431
commit
366e55146a
|
@ -26,8 +26,8 @@ import (
|
||||||
|
|
||||||
var DefaultClient = NewClient(http.DefaultClient)
|
var DefaultClient = NewClient(http.DefaultClient)
|
||||||
|
|
||||||
func RequestSchedule(sportId, teamId string) ([]byte, error) {
|
func RequestSchedule(sportId, teamId, date string) ([]byte, error) {
|
||||||
return DefaultClient.RequestSchedule(sportId, teamId)
|
return DefaultClient.RequestSchedule(sportId, teamId, date)
|
||||||
}
|
}
|
||||||
|
|
||||||
func RequestFeed(gamePk string) ([]byte, error) {
|
func RequestFeed(gamePk string) ([]byte, error) {
|
||||||
|
@ -76,11 +76,12 @@ func (resp *DiffPatchResponse) ExtractPatches() ([]jsonpatch.Patch, error) {
|
||||||
return patches, err
|
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"}
|
endpoint := url.URL{Path: "api/v1/schedule"}
|
||||||
query := endpoint.Query()
|
query := endpoint.Query()
|
||||||
query.Add("sportId", sportId)
|
query.Add("sportId", sportId)
|
||||||
query.Add("teamId", teamId)
|
query.Add("teamId", teamId)
|
||||||
|
query.Add("date", date)
|
||||||
endpoint.RawQuery = query.Encode()
|
endpoint.RawQuery = query.Encode()
|
||||||
|
|
||||||
return c.get(&endpoint)
|
return c.get(&endpoint)
|
||||||
|
|
|
@ -26,6 +26,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var team teamFlag
|
var team teamFlag
|
||||||
|
var date string
|
||||||
var teamIDs = map[string]statsapi.TeamID{
|
var teamIDs = map[string]statsapi.TeamID{
|
||||||
"laa": statsapi.LAA,
|
"laa": statsapi.LAA,
|
||||||
"az": statsapi.AZ,
|
"az": statsapi.AZ,
|
||||||
|
@ -67,7 +68,7 @@ func schedule(cmd *cobra.Command, args []string) {
|
||||||
id = strconv.Itoa(int(teamIDs[string(team)]))
|
id = strconv.Itoa(int(teamIDs[string(team)]))
|
||||||
}
|
}
|
||||||
|
|
||||||
sched, err := statsapi.RequestSchedule("1", id)
|
sched, err := statsapi.RequestSchedule("1", id, date)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -95,5 +96,6 @@ func init() {
|
||||||
|
|
||||||
// Cobra supports local flags which will only run when this command
|
// Cobra supports local flags which will only run when this command
|
||||||
// is called directly, e.g.:
|
// 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)")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue