|
| 1 | +--- |
| 2 | +title: Orders |
| 3 | +nav_order: 11 |
| 4 | +--- |
| 5 | + |
| 6 | +## Attributes |
| 7 | + |
| 8 | +<table> |
| 9 | + <tr><th>Name</th><th>Type</th><th>Description</th></tr> |
| 10 | + <tr><td>id</td><td>Integer</td><td>Automatically set</td></tr> |
| 11 | + <tr><td>created_at</td><td>Datetime</td><td>Automatically set</td></tr> |
| 12 | + <tr><td>updated_at</td><td>Datetime</td><td>Automatically set</td></tr> |
| 13 | + <tr><td>person_id</td><td>Integer</td><td></td></tr> |
| 14 | + <tr><td>state</td><td>String</td><td>pending, confirmed or cancelled</td></tr> |
| 15 | + <tr><td>total</td><td>Decimal</td><td>Total amount before discount</td></tr> |
| 16 | + <tr><td>discount_amount</td><td>Decimal</td><td>Discount from applied coupon</td></tr> |
| 17 | + <tr><td>coupon_id</td><td>Integer</td><td>Applied coupon</td></tr> |
| 18 | + <tr><td>paid_amount</td><td>Decimal</td><td>Total amount paid</td></tr> |
| 19 | + <tr><td>settled_at</td><td>Datetime</td><td>Set when order is fully paid</td></tr> |
| 20 | + <tr><td>balance</td><td>Decimal</td><td>Calculated. payable_amount - paid_amount</td></tr> |
| 21 | + <tr><td>payable_amount</td><td>Decimal</td><td>Calculated. total - discount_amount</td></tr> |
| 22 | +</table> |
| 23 | + |
| 24 | +The response includes nested `person` and `order_line_items`. |
| 25 | + |
| 26 | +### Person |
| 27 | + |
| 28 | +<table> |
| 29 | + <tr><th>Name</th><th>Type</th><th>Description</th></tr> |
| 30 | + <tr><td>id</td><td>Integer</td><td></td></tr> |
| 31 | + <tr><td>name</td><td>String</td><td></td></tr> |
| 32 | + <tr><td>email</td><td>String</td><td></td></tr> |
| 33 | +</table> |
| 34 | + |
| 35 | +### Order line items |
| 36 | + |
| 37 | +<table> |
| 38 | + <tr><th>Name</th><th>Type</th><th>Description</th></tr> |
| 39 | + <tr><td>id</td><td>Integer</td><td></td></tr> |
| 40 | + <tr><td>service_id</td><td>Integer</td><td></td></tr> |
| 41 | + <tr><td>quantity</td><td>Integer</td><td></td></tr> |
| 42 | + <tr><td>amount</td><td>Decimal</td><td>Unit price</td></tr> |
| 43 | + <tr><td>gift_card_id</td><td>Integer</td><td>Associated gift card if applicable</td></tr> |
| 44 | + <tr><td>booking_id</td><td>Integer</td><td>Associated booking if applicable</td></tr> |
| 45 | +</table> |
| 46 | + |
| 47 | +## Listing |
| 48 | + |
| 49 | +`GET /orders` will return all orders. |
| 50 | + |
| 51 | +Response |
| 52 | + |
| 53 | +```json |
| 54 | +[ |
| 55 | + { |
| 56 | + "order": { |
| 57 | + "id": 1, |
| 58 | + "person_id": 38, |
| 59 | + "state": "confirmed", |
| 60 | + "total": "1000.0", |
| 61 | + "discount_amount": "0.0", |
| 62 | + "coupon_id": null, |
| 63 | + "paid_amount": "0.0", |
| 64 | + "settled_at": null, |
| 65 | + "created_at": "2026-03-26T10:00:00+02:00", |
| 66 | + "updated_at": "2026-03-26T10:00:00+02:00", |
| 67 | + "balance": "1000.0", |
| 68 | + "payable_amount": "1000.0", |
| 69 | + "person": { |
| 70 | + "id": 38, |
| 71 | + "name": "Espen Antonsen", |
| 72 | + "email": "espen@example.com" |
| 73 | + }, |
| 74 | + "order_line_items": [ |
| 75 | + { |
| 76 | + "id": 1, |
| 77 | + "service_id": 37, |
| 78 | + "quantity": 1, |
| 79 | + "amount": "1000.0", |
| 80 | + "gift_card_id": null, |
| 81 | + "booking_id": null |
| 82 | + } |
| 83 | + ] |
| 84 | + } |
| 85 | + } |
| 86 | +] |
| 87 | +``` |
| 88 | + |
| 89 | +### Query Parameters |
| 90 | + |
| 91 | +<table> |
| 92 | + <tr><th>Name</th><th>Type</th><th>Description</th></tr> |
| 93 | + <tr><td>state</td><td>String</td><td>Filter by state: pending, confirmed or cancelled</td></tr> |
| 94 | + <tr><td>person_id</td><td>Integer</td><td>Filter by person</td></tr> |
| 95 | +</table> |
| 96 | + |
| 97 | +## Get order |
| 98 | + |
| 99 | +`GET /orders/{order_id}` will get an order with id `{order_id}`. |
0 commit comments