.. _book_products: Book Products ============= Current Version: 0.1.0 Global Overview --------------- This API is closely related to the :ref:`product availability ` API Create Booking -------------- .. http:post:: /api2/book_products This endpoint allows to create a booking based on a list of products. It requires the ``createBoeking`` permission. Modifying the status of a booking after it has been created requires the ``editBoeking`` permission. **Example request**: .. sourcecode:: http POST /api2/book_products HTTP/1.1 Host: demo.recras.nl Content-Type: application/json { "status": "reservering", "customer": { "email": "foo@bar.nl", "company_id:" 2, "first_name": "foo", "last_name": "bar", "phone_number": "050-2112222" }, "products":[ {"amount":1,"product_id":2,"datetime":"2030-01-01 10:00:00"}, {"amount":1,"product_id":4,"datetime":"2030-01-01 10:00:00", "location_id": 4} ], "should_invoice": true } :json string status: **required** Either ``reservering`` or ``definitief``. :json object customer: **required** Customer object :json string customer.email: **required** Email :json int customer.company_id: Company id (will be used for the booking as well) :json string customer.first_name: First Name :json string customer.last_name: Last Name :json string customer.phone_number: Phone Number :json array products: **required** A list of products :json int products[].amount: **required** The amount to book of this product :json int products[].product_id: **required** The id of the product to book :json datetime products[].datetime: **required** ISO8601 or RFC3339 formatted datetime for the start of this product. Should be a valid "startmoment" :json int products[].location_id: Optional location_id for the product :json boolean should_invoice: Defaults to ``true``, and can only be set to ``false`` if the global Recras setting permits this. **Example response**: .. sourcecode:: http HTTP/1.1 201 OK Content-Type: application/json { "id": 51, "ref": "67-1", "qr_code": "B:67-1:1:8bfbcfef8aecbb20cb881f1596efd59d9d746ce51cf6008868f19a4528073361", "_links": { "recras:booking:set_status:confirmed": { "href": "/api2/boekingen/51/set_status/definitief", "method": "POST" }, "recras:booking:set_status:cancelled": { "href": "/api2/boekingen/51/set_status/geannuleerd", "method": "POST" } } } :statuscode 201: Booking created :json int id: The id of the created booking :json string ref: The booking reference :json string qr_code: String for a QR-code to scan in the POS :json object _links: An object with HATEOAS Links HATEOAS Links ------------- Each booking resource should have a ``_links`` map. The following relations may be present: ``recras:booking:set_status:confirmed`` .. _link-confirmed: If this link is present, you may follow it to set the status of the booking to *confirmed* (``definitief``). The Recras Point-of-Sale uses this link to set bookings to *confirmed*. ``recras:booking:set_status:cancelled`` .. _link-cancelled: If this link is present, you may follow it to set the status of the booking to *cancelled* (``geannuleerd``).