fix standings
This commit is contained in:
parent
d584d66d86
commit
7338e7ae35
|
@ -18,8 +18,8 @@ package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io"
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
@ -30,24 +30,28 @@ var league leagueAbbr
|
||||||
|
|
||||||
func standings(cmd *cobra.Command, args []string) {
|
func standings(cmd *cobra.Command, args []string) {
|
||||||
var leagueIds []int32
|
var leagueIds []int32
|
||||||
leagueIds = append(leagueIds, int32(leagueIDs[string(league)]))
|
leagueIds = append(leagueIds, leagueIDs[string(league)])
|
||||||
|
|
||||||
client := api.NewAPIClient(api.NewConfiguration())
|
cfg := api.NewConfiguration()
|
||||||
|
cfg.Host = "statsapi.mlb.com"
|
||||||
|
cfg.Scheme = "https"
|
||||||
|
|
||||||
|
client := api.NewAPIClient(cfg)
|
||||||
req := client.StandingsAPI.Standings1(context.Background(), "regularSeason")
|
req := client.StandingsAPI.Standings1(context.Background(), "regularSeason")
|
||||||
|
|
||||||
req.LeagueId(leagueIDs[string(league)])
|
req = req.LeagueId(leagueIds)
|
||||||
|
|
||||||
resp, err := req.Execute()
|
resp, err := req.Execute()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
json, err := json.Marshal(resp.Body)
|
body, err := io.ReadAll(resp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println(string(json))
|
fmt.Println(string(body))
|
||||||
}
|
}
|
||||||
|
|
||||||
// standingsCmd represents the standings command
|
// standingsCmd represents the standings command
|
||||||
|
|
Loading…
Reference in New Issue