create one client to use between commands
This commit is contained in:
parent
892a2a3827
commit
e5f859cdfc
|
@ -19,8 +19,28 @@ import (
|
|||
"errors"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"scm.dairydemon.net/filifa/mlbstats/api"
|
||||
)
|
||||
|
||||
var statsAPIConfiguration = &api.Configuration{
|
||||
Host: "statsapi.mlb.com",
|
||||
Scheme: "https",
|
||||
DefaultHeader: make(map[string]string),
|
||||
UserAgent: "OpenAPI-Generator/1.0.0/go",
|
||||
Debug: false,
|
||||
Servers: api.ServerConfigurations{
|
||||
{
|
||||
URL: "",
|
||||
Description: "No description provided",
|
||||
},
|
||||
},
|
||||
OperationServers: map[string]api.ServerConfigurations{
|
||||
},
|
||||
}
|
||||
|
||||
var statsAPIClient = api.NewAPIClient(statsAPIConfiguration)
|
||||
|
||||
func keys[V any](m map[string]V) []string {
|
||||
keys := make([]string, len(m))
|
||||
|
||||
|
|
|
@ -23,7 +23,6 @@ import (
|
|||
"log"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"scm.dairydemon.net/filifa/mlbstats/api"
|
||||
)
|
||||
|
||||
var date string
|
||||
|
@ -33,12 +32,7 @@ var sport = sportAbbr("mlb")
|
|||
func schedule(cmd *cobra.Command, args []string) {
|
||||
sportId := int32(sportIDs[string(sport)])
|
||||
|
||||
cfg := api.NewConfiguration()
|
||||
cfg.Host = "statsapi.mlb.com"
|
||||
cfg.Scheme = "https"
|
||||
|
||||
client := api.NewAPIClient(cfg)
|
||||
req := client.ScheduleAPI.Schedule(context.Background())
|
||||
req := statsAPIClient.ScheduleAPI.Schedule(context.Background())
|
||||
|
||||
req = req.SportId(sportId)
|
||||
req = req.Date(date)
|
||||
|
|
|
@ -23,7 +23,6 @@ import (
|
|||
"log"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"scm.dairydemon.net/filifa/mlbstats/api"
|
||||
)
|
||||
|
||||
var league leagueAbbr
|
||||
|
@ -32,12 +31,7 @@ func standings(cmd *cobra.Command, args []string) {
|
|||
var leagueIds []int32
|
||||
leagueIds = append(leagueIds, leagueIDs[string(league)])
|
||||
|
||||
cfg := api.NewConfiguration()
|
||||
cfg.Host = "statsapi.mlb.com"
|
||||
cfg.Scheme = "https"
|
||||
|
||||
client := api.NewAPIClient(cfg)
|
||||
req := client.StandingsAPI.Standings1(context.Background(), "regularSeason")
|
||||
req := statsAPIClient.StandingsAPI.Standings1(context.Background(), "regularSeason")
|
||||
|
||||
req = req.LeagueId(leagueIds)
|
||||
|
||||
|
|
Loading…
Reference in New Issue