sorare/cmd/console/main.go

50 lines
1.0 KiB
Go

package main
import (
"context"
"fmt"
"log"
"os"
"time"
"git.lehouerou.net/laurent/sorare"
"git.lehouerou.net/laurent/sorare/graphql"
)
func main() {
token := os.Getenv("JWTTOKEN")
audience := os.Getenv("JWTAUDIENCE")
if token == "" {
log.Fatal("No token provided")
}
if audience == "" {
log.Fatal("No audience provided")
}
api := sorare.New().Debug()
api.SetJWTToken(
graphql.JwtToken{
Token: token,
ExpiredAt: time.Time{},
},
audience,
)
ctx := context.Background()
//cu, err := api.Country.Get(ctx, graphql.SlugParams{Slug: "fr"})
params := make(map[string][]string)
params["0c7d5f17-7c01-4427-90b8-a736a44ea632"] = []string{"joshua-kimmich", "leon-goretzka"}
params["0d641a1d-c64a-40c9-85b0-7ddeca428abf"] = []string{"joshua-kimmich", "leon-goretzka"}
cu, err := api.Football.GamesScores.Get(
ctx,
params,
)
if err != nil {
panic(err)
}
for _, game := range cu {
log.Println(game.Game.Id.Value + " " + game.Player.Slug + " " + fmt.Sprintf("%s", game.Score))
}
}