Compare commits
4 Commits
8041f6835f
...
da774aa910
Author | SHA1 | Date | |
---|---|---|---|
da774aa910 | |||
b8981ad8ec | |||
be3f38e715 | |||
546d610e4e |
@ -2,7 +2,6 @@ package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"time"
|
||||
@ -21,7 +20,7 @@ func main() {
|
||||
if audience == "" {
|
||||
log.Fatal("No audience provided")
|
||||
}
|
||||
api := sorare.New().Debug()
|
||||
api := sorare.New()
|
||||
api.SetJWTToken(
|
||||
graphql.JwtToken{
|
||||
Token: token,
|
||||
@ -32,18 +31,48 @@ func main() {
|
||||
|
||||
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,
|
||||
)
|
||||
si, err := api.ShopItems.Get(ctx, sorare.ShopItemsParams{
|
||||
Types: []sorare.ShopItemType{sorare.ShopItemTypeLevelUp},
|
||||
UnlockedOnly: true,
|
||||
})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
for _, game := range cu {
|
||||
log.Println(game.Game.Id.Value + " " + game.Player.Slug + " " + fmt.Sprintf("%s", game.Score))
|
||||
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,
|
||||
// )
|
||||
// }
|
||||
}
|
||||
|
@ -9,13 +9,19 @@ import (
|
||||
)
|
||||
|
||||
type Card struct {
|
||||
Token tokens.Token `graphql:"token"`
|
||||
Power decimal.Decimal `graphql:"power"`
|
||||
PowerMalusAfterTransfer decimal.Decimal `graphql:"powerMalusAfterTransfer"`
|
||||
RivalsPower decimal.Decimal `graphql:"rivalsPower"`
|
||||
Grade int `graphql:"grade"`
|
||||
GradeAfterTransfer int `graphql:"gradeAfterTransfer"`
|
||||
Xp int `graphql:"xp"`
|
||||
Token tokens.Token `graphql:"token"`
|
||||
XpAfterTransfer int `graphql:"xpAfterTransfer"`
|
||||
XpNeededForNextGrade int `graphql:"xpNeededForNextGrade"`
|
||||
XpNeededForCurrentGrade int `graphql:"xpNeededForCurrentGrade"`
|
||||
InSeasonEligible bool `graphql:"inSeasonEligible"`
|
||||
LevelUpAppliedCount int `graphql:"levelUpAppliedCount"`
|
||||
MaxLevelUpAppliedCount int `graphql:"maxLevelUpAppliedCount"`
|
||||
}
|
||||
|
||||
type CardsParams struct {
|
||||
|
12
go.mod
12
go.mod
@ -9,17 +9,17 @@ require (
|
||||
github.com/llehouerou/go-graphql-client v0.9.7
|
||||
github.com/pkg/errors v0.9.1
|
||||
github.com/rs/zerolog v1.32.0
|
||||
github.com/shopspring/decimal v1.3.1
|
||||
github.com/shopspring/decimal v1.4.0
|
||||
github.com/xlzd/gotp v0.1.0
|
||||
golang.org/x/crypto v0.21.0
|
||||
golang.org/x/crypto v0.22.0
|
||||
golang.org/x/time v0.5.0
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
|
||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||
github.com/mattn/go-isatty v0.0.19 // indirect
|
||||
golang.org/x/net v0.21.0 // indirect
|
||||
golang.org/x/sys v0.18.0 // indirect
|
||||
nhooyr.io/websocket v1.8.10 // indirect
|
||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||
golang.org/x/net v0.24.0 // indirect
|
||||
golang.org/x/sys v0.19.0 // indirect
|
||||
nhooyr.io/websocket v1.8.11 // indirect
|
||||
)
|
||||
|
12
go.sum
12
go.sum
@ -22,6 +22,8 @@ github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovk
|
||||
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
|
||||
github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA=
|
||||
github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
||||
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
@ -30,19 +32,29 @@ github.com/rs/zerolog v1.32.0 h1:keLypqrlIjaFsbmJOBdB/qvyF8KEtCWHwobLp5l/mQ0=
|
||||
github.com/rs/zerolog v1.32.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss=
|
||||
github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8=
|
||||
github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
|
||||
github.com/shopspring/decimal v1.4.0 h1:bxl37RwXBklmTi0C79JfXCEBD1cqqHt0bbgBAGFp81k=
|
||||
github.com/shopspring/decimal v1.4.0/go.mod h1:gawqmDU56v4yIKSwfBSFip1HdCCXN8/+DMd9qYNcwME=
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/xlzd/gotp v0.1.0 h1:37blvlKCh38s+fkem+fFh7sMnceltoIEBYTVXyoa5Po=
|
||||
github.com/xlzd/gotp v0.1.0/go.mod h1:ndLJ3JKzi3xLmUProq4LLxCuECL93dG9WASNLpHz8qg=
|
||||
golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA=
|
||||
golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs=
|
||||
golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30=
|
||||
golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M=
|
||||
golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4=
|
||||
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
|
||||
golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w=
|
||||
golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8=
|
||||
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4=
|
||||
golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o=
|
||||
golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk=
|
||||
golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
|
||||
nhooyr.io/websocket v1.8.10 h1:mv4p+MnGrLDcPlBoWsvPP7XCzTYMXP9F9eIGoKbgx7Q=
|
||||
nhooyr.io/websocket v1.8.10/go.mod h1:rN9OFWIUwuxg4fR5tELlYC04bXYowCP9GX47ivo2l+c=
|
||||
nhooyr.io/websocket v1.8.11 h1:f/qXNc2/3DpoSZkHt1DQu6rj4zGC8JmkkLkWss0MgN0=
|
||||
nhooyr.io/websocket v1.8.11/go.mod h1:rN9OFWIUwuxg4fR5tELlYC04bXYowCP9GX47ivo2l+c=
|
||||
|
52
mutations/buy_shop_item.go
Normal file
52
mutations/buy_shop_item.go
Normal file
@ -0,0 +1,52 @@
|
||||
package mutations
|
||||
|
||||
package mutations
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
gql "github.com/llehouerou/go-graphql-client"
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"git.lehouerou.net/laurent/sorare/graphql"
|
||||
)
|
||||
|
||||
type buyShopItemInput struct {
|
||||
ClientMutationId string `json:"clientMutationId"`
|
||||
ShopItemId gql.ID `json:"shopItemId"`
|
||||
}
|
||||
|
||||
type BuyShopItemParams struct {
|
||||
Input buyDeliverableShopItemInput `graphql:"input"`
|
||||
}
|
||||
|
||||
func (m *Mutations) newBuyShopItemMutation() *graphql.Mutation[BaseMutationPayload, BuyShopItemParams] {
|
||||
return graphql.NewMutation[BaseMutationPayload, BuyShopItemParams](
|
||||
m.c,
|
||||
"buyShopItem",
|
||||
)
|
||||
}
|
||||
|
||||
func (m *Mutations) BuyShopItem(
|
||||
ctx context.Context,
|
||||
shopItemId string,
|
||||
) error {
|
||||
res, err := m.newBuyShopItemMutation().Execute(ctx, BuyShopItemParams{
|
||||
Input: buyShopItemInput{
|
||||
ClientMutationId: GetRandomId(),
|
||||
ShopItemId: gql.ID(shopItemId),
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "executing buyShopItem mutation")
|
||||
}
|
||||
if res.Errors != nil {
|
||||
return errors.Wrap(
|
||||
errors.New(res.Errors[0].Message),
|
||||
"executing buyShopItem mutation",
|
||||
)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
}
|
19
shop_item.go
19
shop_item.go
@ -1,16 +1,27 @@
|
||||
package sorare
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
type ShopItem struct {
|
||||
TypeName string `graphql:"__typename"`
|
||||
ShopItemInterface struct {
|
||||
Id string `graphql:"id"`
|
||||
Name string `graphql:"name"`
|
||||
Price int `graphql:"price"`
|
||||
Id string `graphql:"id"`
|
||||
Name string `graphql:"name"`
|
||||
Price int `graphql:"price"`
|
||||
MyBalance int `graphql:"myBalance"`
|
||||
LimitPerUser int `graphql:"limitPerUser"`
|
||||
MyLimitResetAt time.Time `graphql:"myLimitResetAt"`
|
||||
MyPurchasesCount int `graphql:"myPurchasesCount"`
|
||||
} `graphql:"... on ShopItemInterface"`
|
||||
JerseyShopItem struct {
|
||||
CurrentStockCount int `graphql:"currentStockCount"`
|
||||
InitialStockCount int `graphql:"initialStockCount"`
|
||||
LimitPerUser int `graphql:"limitPerUser"`
|
||||
} `graphql:"... on JerseyShopItem"`
|
||||
LevelUpShopItem struct {
|
||||
Rarity string `graphql:"rarity"`
|
||||
} `graphql:"... on LevelUpShopItem"`
|
||||
}
|
||||
|
||||
type ShopItemType string
|
||||
|
Loading…
Reference in New Issue
Block a user