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 }