sorare/cmd/console/main.go

88 lines
1.9 KiB
Go

package main
import (
"context"
"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()
api.SetJWTToken(
graphql.JwtToken{
Token: token,
ExpiredAt: time.Time{},
},
audience,
)
ctx := context.Background()
p, err := api.Football.Player.Get(ctx, graphql.SlugParams{Slug: "joshua-kimmich"})
if err != nil {
panic(err)
}
log.Printf("%+v", p)
// si, err := api.ShopItems.Get(ctx, sorare.ShopItemsParams{
// Types: []sorare.ShopItemType{sorare.ShopItemTypeLevelUp},
// UnlockedOnly: true,
// })
// if err != nil {
// panic(err)
// }
// for _, item := range si {
// log.Printf(
// "%s %d %d %s %s",
// item.TypeName,
// item.ShopItemInterface.MyBalance,
// item.ShopItemInterface.Price,
// item.LevelUpShopItem.Rarity,
// time.Until(item.ShopItemInterface.MyLimitResetAt).String(),
// )
// }
// cu, err := api.Users.CurrentUser.Get(ctx, graphql.EmptyParams{})
// if err != nil {
// panic(err)
// }
// log.Printf("%d", cu.CoinBalance)
// cards, err := api.Users.FootballCards("gigiz22").Get(ctx, football.CardsParams{
// Rarities: []types.Rarity{types.RarityLimited},
// })
// if err != nil {
// panic(err)
// }
// sort.Slice(cards, func(i, j int) bool {
// return cards[i].XpNeededForNextGrade-cards[i].Xp > cards[j].XpNeededForNextGrade-cards[j].Xp
// })
// for _, card := range cards {
// if !card.InSeasonEligible {
// continue
// }
// log.Printf(
// "%60s %2d %6d %6d %6d (%d/%d)",
// card.Token.Name,
// card.Grade,
// card.Xp-card.XpNeededForCurrentGrade,
// card.Xp,
// card.XpNeededForNextGrade-card.Xp,
// card.LevelUpAppliedCount,
// card.MaxLevelUpAppliedCount,
// )
// }
}