Order Reject
Rejecting Orders
Rejecting an Order requires a call to a mutation with the order uuid that is being rejected and some information about the reason why it is being rejecting. To be automatically be informed when an order has been submitted and can be rejected please see Subscribing to Order Notifications .
Mutation
mutation RejectOrder($orderId: ID!, $rejectOrderInput: RejectOrderInput!) {
rejectOrder(orderId: $orderId, rejectOrderInput: $rejectOrderInput) {
order {
uuid
lifecycle {
orderIsCurrently
}
}
}
}Variables
{
"orderId": "your-ezcater-order-id",
"rejectOrderInput": {
"explanation": "This location can't accept any more orders for that delivery date",
"reason": "AT_DAILY_CAPACITY"
}
}Arguments
Argument Name | Description |
|---|---|
orderId: ID! | The ezCater order UUID that is provided within the payload of Order subscription notifications. |
rejectOrderInput: RejectOrderInput! | A object providing an explanation for the rejection and the reason. |
Return Type
Returns a RejectOrderPayload.
Success Response
When the rejectOrder mutation succeeds you can expect the response payload to look like:
{
"data": {
"rejectOrder": {
"order": {
"uuid": "your-ezcater-order-id",
"lifecycle": {
"orderIsCurrently": "rejected"
}
}
}
}
}We have also created a new rejected order event notification which you will receive shortly afterwards, if you choose to subscribe to it via Subscription Create.
Failure Responses
RejectOrder calls may fail for a variety of reasons, such a: the order not being found, or the feature not being enabled for your brand. In the event that a RejectOrder call fails, one of the below errors will be returned.
404 Couldn’t find Order
You will get a 404 error when the specified order couldn’t be found.
{
"data": {
"rejectOrder": null
},
"errors": [
{
"message": "Couldn't find Order",
"locations": [
{
"line": 6,
"column": 3
}
],
"path": [
"rejectOrder"
],
"extensions": {
"type": "request",
"statusCode": 404
}
}
]
}
403 Unauthorized
You will get a 403 error when the API user account doesn’t have permission to perform this action for this caterer location.
{
"data": {
"rejectOrder": null
},
"errors": [
{
"message": "You are not authorized to access this data",
"locations": [
{
"line": 6,
"column": 3
}
],
"path": [
"rejectOrder"
],
"extensions": {
"type": "request",
"statusCode": 403
}
}
]
}Feature Not Enabled (feature_not_enabled)
You will get this error if this API feature has not yet been enabled for your brand.
{
"data": {
"rejectOrder": null
},
"errors": [
{
"message": "Feature not enabled for this caterer",
"locations": [
{
"line": 6,
"column": 3
}
],
"path": [
"rejectOrder"
],
"extensions": {
"type": "summary",
"code": "feature_not_enabled"
}
}
]
}Invalid State Transition (invalid_state_transition)
You will get this error when the order is no longer in a valid state to be rejected (the order hasn’t been submitted yet, the customer may have canceled it, it may have already been accepted or rejected by API or one of the other channels for accepting / rejecting orders).
{
"data": {
"rejectOrder": null
},
"errors": [
{
"message": "Sorry, we were unable to reject this order.",
"locations": [
{
"line": 6,
"column": 3
}
],
"path": [
"rejectOrder"
],
"extensions": {
"type": "summary",
"code": "invalid_state_transition"
}
}
]
}