39 lines
931 B
Go
39 lines
931 B
Go
package mutations
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/pkg/errors"
|
|
|
|
"git.lehouerou.net/laurent/sorare/graphql"
|
|
)
|
|
|
|
type cancelOfferInput struct {
|
|
BlockchainId string `json:"blockchainId"`
|
|
ClientMutationId string `json:"clientMutationId"`
|
|
}
|
|
|
|
type CancelOfferParams struct {
|
|
Input cancelOfferInput `graphql:"input"`
|
|
}
|
|
|
|
func (m *Mutations) newCancelOfferMutation() *graphql.Mutation[BaseMutationPayload, CancelOfferParams] {
|
|
return graphql.NewMutation[BaseMutationPayload, CancelOfferParams](m.c, "cancelOffer")
|
|
}
|
|
|
|
func (m *Mutations) CancelOffer(ctx context.Context, blockchainId string) error {
|
|
res, err := m.newCancelOfferMutation().Execute(ctx, CancelOfferParams{
|
|
Input: cancelOfferInput{
|
|
BlockchainId: blockchainId,
|
|
ClientMutationId: GetRandomId(),
|
|
},
|
|
})
|
|
if err != nil {
|
|
return errors.Wrap(err, "cancelling offer")
|
|
}
|
|
if len(res.Errors) > 0 {
|
|
return errors.New(res.Errors[0].Message)
|
|
}
|
|
return nil
|
|
}
|