Create and send an order with custom items
Let's assume that we need catering for a flight from Zurich. We don't have any preference regarding the caterer, so we let DeliSky choose a caterer for us. Also, we will not select items from the caterer's menu. Instead we will just add our own custom menu items.
Preparing the categories
Since every order item must be assigned to a category, we must first fetch the categories.
We achieve this by making a GET
request to the /Categories
endpoint.
Request
This will return all categories (response shortened for readabilitym try it here to get the real output):
Response
Note: The categories are structured in a tree format, so each category has a
parentId
value which indicates the parent category. Categories with a
level
property of 1
are the main categories, such with a level
of 2
are subcategories. You should assign your order items only to subcategories.
Creating the order
Now, that everything is in place, we can create the order. This is done by sending a
POST
request to the /Orders
endpoint:
Request
Note: Read more about creating an order.
The API returns a 201 Created
response and the following body (shortened for
readability):
Response
Setting handling agent and payment option
As you can see, the DeliSky system chose "Fantastic Catering" as your caterer - fantastic! You may
notice, that
handlingAgentId
/handlingAgentName
and
paymentOptionId
/paymentOptionName
,
which are required, are not set yet. Since these depend on the selected caterer, we have to call the
/Caterers/{catererId}/HandlingAgents
and
/Caterers/{catererId}/paymentOptions
endpoints, to
retrieve the available options. We can get the caterer's id from the created order, in this case
6
.
Request
200 OK
Request
200 OK
We now can update the order with a PUT
request to the /Orders/{orderId}
endpoint.
We take the orderId
from the POST /Orders
response, 12345.
The API responds with a 200 OK
and now the order is ready to be sent. We can verify it
by
calling
the GET /Orders/{orderId}/Validate
endpoint.
Sending the order
Now that the order is complete, we can send it to the caterer. This is done by sending a
POST
request
to the /Orders/{orderId}/Send
endpoint. If everything runs smoothly and no validation
errors occur, the
API responds with a 200 OK
status and returns the order.
200 OK
That's it. The caterer will confirm the order and then process it.