Includables
For endpoints with List
requests, the API supports including additional objects that are attached to the selected object, you can do it by adding includes
parameter as an array
You can find out what objects can be attached by hitConstants
endpoint, this is for example if you want to know includes of orders
GET : /api/constant/order-include
For example if you want to get a list of orders with items and product information in it, You can do this by adding the includes parameter as followsincludes=products.product
, This is the example
GET : /api/v2/orders?includes=products.product
{
"id": "0001d3e0-a0c8-44db-8ecd-44553e89a303",
"market_id": "4ba00eb3-46ba-4e4d-964b-58a9779faac7",
"branch_id": "0b46bde4-e46c-4648-8887-239c671cd4a2",
"number": "0017",
"source": "ADMIN_APP",
"type": "TAKE_AWAY",
"status": "PROCESS",
...
"products": [
{
"id": 10,
"market_id": "4ba00eb3-46ba-4e4d-964b-58a9779faac7",
"branch_id": "0b46bde4-e46c-4648-8887-239c671cd4a2",
"order_id": "0001d3e0-a0c8-44db-8ecd-44553e89a303",
"product_category_id": "72",
"product_id": "5e4cdec9-7060-4660-acdb-794176c447bc",
"qty": 1,
"price": 7.83,
"discount": 0.0,
"tax": 1.17,
"subtotal": 7.83,
"total": 9.0,
...
"product": {
"id": "5e4cdec9-7060-4660-acdb-794176c447bc",
"market_id": "4ba00eb3-46ba-4e4d-964b-58a9779faac7",
"branch_id": "0b46bde4-e46c-4648-8887-239c671cd4a2",
"product_category_id": "72",
"name_en": "Cheese Burger",
"name_ar": "Cheese Burger",
"description_en": "Maiores id quas quia minus consectetur.",
"description_ar": "Maiores id quas quia minus consectetur.",
...
}
}
]
}
products.product
that means you want to attach a list of items and product information to it, so if you don't want to carry product information, just delete the product
, and the includes will be products
and this is the result
GET : /api/v2/orders?includes=products
{
"id": "0001d3e0-a0c8-44db-8ecd-44553e89a303",
"market_id": "4ba00eb3-46ba-4e4d-964b-58a9779faac7",
"branch_id": "0b46bde4-e46c-4648-8887-239c671cd4a2",
"number": "0017",
"source": "ADMIN_APP",
"type": "TAKE_AWAY",
"status": "PROCESS",
...
"products": [
{
"id": 10,
"market_id": "4ba00eb3-46ba-4e4d-964b-58a9779faac7",
"branch_id": "0b46bde4-e46c-4648-8887-239c671cd4a2",
"order_id": "0001d3e0-a0c8-44db-8ecd-44553e89a303",
"product_category_id": "72",
"product_id": "5e4cdec9-7060-4660-acdb-794176c447bc",
"qty": 1,
"price": 7.83,
"discount": 0.0,
"tax": 1.17,
"subtotal": 7.83,
"total": 9.0,
...
}
]
}
And if you don't want to attach anything, don't attach the includes
into parameters
GET : /api/v2/orders
{
"id": "0001d3e0-a0c8-44db-8ecd-44553e89a303",
"market_id": "4ba00eb3-46ba-4e4d-964b-58a9779faac7",
"branch_id": "0b46bde4-e46c-4648-8887-239c671cd4a2",
"number": "0017",
"source": "ADMIN_APP",
"type": "TAKE_AWAY",
"status": "PROCESS",
...
}