sorare/mutations/reject_offer.go

41 lines
1010 B
Go

package mutations
import (
"context"
"github.com/pkg/errors"
"git.lehouerou.net/laurent/sorare/graphql"
)
type rejectOfferInput struct {
BlockchainId string `json:"blockchainId"`
ClientMutationId string `json:"clientMutationId"`
Block bool `json:"block"`
}
type RejectOfferParams struct {
Input rejectOfferInput `graphql:"input"`
}
func (m *Mutations) newRejectOfferMutation() *graphql.Mutation[BaseMutationPayload, RejectOfferParams] {
return graphql.NewMutation[BaseMutationPayload, RejectOfferParams](m.c, "rejectOffer")
}
func (m *Mutations) RejectOffer(ctx context.Context, blockchainId string, block bool) error {
res, err := m.newRejectOfferMutation().Execute(ctx, RejectOfferParams{
Input: rejectOfferInput{
BlockchainId: blockchainId,
ClientMutationId: GetRandomId(),
Block: block,
},
})
if err != nil {
return errors.Wrap(err, "rejecting offer")
}
if len(res.Errors) > 0 {
return errors.New(res.Errors[0].Message)
}
return nil
}