2024-03-08 10:48:21 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"log"
|
|
|
|
"os"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"git.lehouerou.net/laurent/sorare"
|
|
|
|
"git.lehouerou.net/laurent/sorare/graphql"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
|
2024-03-25 08:40:29 +00:00
|
|
|
token := os.Getenv("JWTTOKEN")
|
|
|
|
audience := os.Getenv("JWTAUDIENCE")
|
2024-03-08 10:48:21 +00:00
|
|
|
if token == "" {
|
|
|
|
log.Fatal("No token provided")
|
|
|
|
}
|
|
|
|
if audience == "" {
|
|
|
|
log.Fatal("No audience provided")
|
|
|
|
}
|
2024-04-16 11:01:11 +00:00
|
|
|
api := sorare.New()
|
2024-03-08 10:48:21 +00:00
|
|
|
api.SetJWTToken(
|
|
|
|
graphql.JwtToken{
|
|
|
|
Token: token,
|
|
|
|
ExpiredAt: time.Time{},
|
|
|
|
},
|
|
|
|
audience,
|
|
|
|
)
|
|
|
|
|
|
|
|
ctx := context.Background()
|
|
|
|
|
2024-04-16 11:01:11 +00:00
|
|
|
si, err := api.ShopItems.Get(ctx, sorare.ShopItemsParams{
|
|
|
|
Types: []sorare.ShopItemType{sorare.ShopItemTypeLevelUp},
|
|
|
|
UnlockedOnly: true,
|
|
|
|
})
|
2024-03-08 10:48:21 +00:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2024-04-16 11:01:11 +00:00
|
|
|
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)
|
2024-03-27 16:54:06 +00:00
|
|
|
}
|
2024-04-16 11:01:11 +00:00
|
|
|
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,
|
|
|
|
// )
|
|
|
|
// }
|
2024-03-08 10:48:21 +00:00
|
|
|
}
|