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() 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) // cu, err := api.Users.FootballCards("gigiz22").Get(ctx, football.CardsParams{ // Rarities: []types.Rarity{types.RarityLimited}, // }) // if err != nil { // panic(err) // } // sort.Slice(cu, func(i, j int) bool { // return cu[i].XpNeededForNextGrade-cu[i].Xp > cu[j].XpNeededForNextGrade-cu[j].Xp // }) // for _, card := range cu { // 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, // ) // } }