create one client to use between commands
This commit is contained in:
parent
bc91e86648
commit
3a217181b4
|
@ -19,8 +19,28 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"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 {
|
func keys[V any](m map[string]V) []string {
|
||||||
keys := make([]string, len(m))
|
keys := make([]string, len(m))
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,6 @@ import (
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"scm.dairydemon.net/filifa/mlbstats/api"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var date string
|
var date string
|
||||||
|
@ -33,12 +32,7 @@ var sport = sportAbbr("mlb")
|
||||||
func schedule(cmd *cobra.Command, args []string) {
|
func schedule(cmd *cobra.Command, args []string) {
|
||||||
sportId := int32(sportIDs[string(sport)])
|
sportId := int32(sportIDs[string(sport)])
|
||||||
|
|
||||||
cfg := api.NewConfiguration()
|
req := statsAPIClient.ScheduleAPI.Schedule(context.Background())
|
||||||
cfg.Host = "statsapi.mlb.com"
|
|
||||||
cfg.Scheme = "https"
|
|
||||||
|
|
||||||
client := api.NewAPIClient(cfg)
|
|
||||||
req := client.ScheduleAPI.Schedule(context.Background())
|
|
||||||
|
|
||||||
req = req.SportId(sportId)
|
req = req.SportId(sportId)
|
||||||
req = req.Date(date)
|
req = req.Date(date)
|
||||||
|
|
|
@ -23,7 +23,6 @@ import (
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"scm.dairydemon.net/filifa/mlbstats/api"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var league leagueAbbr
|
var league leagueAbbr
|
||||||
|
@ -32,12 +31,7 @@ func standings(cmd *cobra.Command, args []string) {
|
||||||
var leagueIds []int32
|
var leagueIds []int32
|
||||||
leagueIds = append(leagueIds, leagueIDs[string(league)])
|
leagueIds = append(leagueIds, leagueIDs[string(league)])
|
||||||
|
|
||||||
cfg := api.NewConfiguration()
|
req := statsAPIClient.StandingsAPI.Standings1(context.Background(), "regularSeason")
|
||||||
cfg.Host = "statsapi.mlb.com"
|
|
||||||
cfg.Scheme = "https"
|
|
||||||
|
|
||||||
client := api.NewAPIClient(cfg)
|
|
||||||
req := client.StandingsAPI.Standings1(context.Background(), "regularSeason")
|
|
||||||
|
|
||||||
req = req.LeagueId(leagueIds)
|
req = req.LeagueId(leagueIds)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue