add standings subcommand

This commit is contained in:
filifa
2024-07-28 19:07:59 -05:00
parent 5366cea515
commit 30d52f5f25
2 changed files with 95 additions and 0 deletions

View File

@@ -42,6 +42,10 @@ func RequestContent(gamePk string) ([]byte, error) {
return DefaultClient.RequestContent(gamePk)
}
func RequestStandings(leagueId string) ([]byte, error) {
return DefaultClient.RequestStandings(leagueId)
}
type DiffPatchResponse []byte
type Client struct {
@@ -108,6 +112,15 @@ func (c *Client) RequestContent(gamePk string) ([]byte, error) {
return c.get(&endpoint)
}
func (c *Client) RequestStandings(leagueId string) ([]byte, error) {
endpoint := url.URL{Path: "api/v1/standings"}
query := endpoint.Query()
query.Add("leagueId", leagueId)
endpoint.RawQuery = query.Encode()
return c.get(&endpoint)
}
func (c *Client) get(endpoint *url.URL) ([]byte, error) {
url := c.baseURL.ResolveReference(endpoint)