fix standings

This commit is contained in:
filifa 2025-04-06 21:32:38 -04:00
parent 4f1114f297
commit a2c1d2fb15
1 changed files with 10 additions and 6 deletions

View File

@ -18,8 +18,8 @@ package cmd
import (
"context"
"encoding/json"
"fmt"
"io"
"log"
"github.com/spf13/cobra"
@ -30,24 +30,28 @@ var league leagueAbbr
func standings(cmd *cobra.Command, args []string) {
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.LeagueId(leagueIDs[string(league)])
req = req.LeagueId(leagueIds)
resp, err := req.Execute()
if err != nil {
log.Fatal(err)
}
json, err := json.Marshal(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
log.Fatal(err)
}
fmt.Println(string(json))
fmt.Println(string(body))
}
// standingsCmd represents the standings command