package mutations import ( "context" gql "github.com/llehouerou/go-graphql-client" "github.com/pkg/errors" "git.lehouerou.net/laurent/sorare/graphql" ) type PostalAddressInput struct { AdditionalAddress string `graphql:"additionalAddress"` Company string `graphql:"company"` FirstName string `graphql:"firstName"` LastName string `graphql:"lastName"` StreetAddress string `graphql:"streetAddress"` ZipCode string `graphql:"zipcode"` City string `graphql:"city"` CountryCode string `graphql:"countryCode"` } type ShirtSize string const ( ShirtSizeS ShirtSize = "S" ShirtSizeM ShirtSize = "M" ShirtSizeL ShirtSize = "L" ShirtSizeXL ShirtSize = "XL" ShirtSizeXS ShirtSize = "XS" ShirtSizeXXL ShirtSize = "XXL" ) type buyDeliverableShopItemInput struct { ClientMutationId string `json:"clientMutationId"` ShopItemId gql.ID `json:"shopItemId"` ShirtSize ShirtSize `json:"shirtSize"` PostalAddress PostalAddressInput `json:"postalAddress"` } type BuyDeliverableShoptItemParams struct { Input buyDeliverableShopItemInput `graphql:"input"` } func (m *Mutations) newBuyDeliverableShopItemMutation() *graphql.Mutation[BaseMutationPayload, BuyDeliverableShoptItemParams] { return graphql.NewMutation[BaseMutationPayload, BuyDeliverableShoptItemParams]( m.c, "buyDeliverableShopItem", ) } func (m *Mutations) BuyDeliverableShopItem( ctx context.Context, shopItemId string, size string, address PostalAddressInput, ) error { res, err := m.newBuyDeliverableShopItemMutation().Execute(ctx, BuyDeliverableShoptItemParams{ Input: buyDeliverableShopItemInput{ ClientMutationId: GetRandomId(), ShopItemId: gql.ID(shopItemId), ShirtSize: ShirtSize(size), PostalAddress: address, }, }) if err != nil { return errors.Wrap(err, "executing buyDeliverableShopItem mutation") } if res.Errors != nil { return errors.Wrap( errors.New(res.Errors[0].Message), "executing buyDeliverableShopItem mutation", ) } return nil }