BOOKING API

Import Bookings API

Technical documentation for the method that builds and sends booking data as JSON.

Summary

Purpose
Retrieve bookings from the database for a specific property and send them as JSON to an external endpoint.
Entry Method
POST /getBookingsFromAllbookers
Input
propertyId as a numeric value in the request body.
Output
Response from the external API, or a helper object for debugging/validation.

Description

This endpoint is used to retrieve all bookings related to a property, map them into a shared structure called CombinedDataObject, and then send them as JSON in a POST request to an external service.

Endpoint

POST /getBookingsFromAllbookers

Request

Content-Type: application/json

Authorization: Bearer <token>

Field Type Description
propertyId Long Property identifier
Request Body Example
15

Process

  • The Property is retrieved from the database using propertyId.
  • All Room entities of the property are iterated.
  • From each Room, the related Reservation entities are retrieved, and from them the Booking.
  • Bookings are stored in a Set to avoid duplicates.
  • For each Booking, a BookingDataObject is created.
  • Inside it, a CustomerDataObject is built using the customer data.
  • For each reservation of the booking, a ReservationDataObject is created.
  • All bookings are added to CombinedDataObject.
  • CombinedDataObject is serialized into JSON and sent with a POST request to the external API.

JSON Structure Sent

The final object sent contains a list of bookings. Each booking includes the basic reservation information, customer data, and the list of daily reservations / rooms.

Field Type Description
bookingDataObjectList Array Main list of bookings to be sent.
id Long Booking ID.
version Integer Booking object version.
start_date Date Check-in date.
end_date Date Check-out date.
status String Booking status.
commision Float Commission; if missing, 0 is sent.
createdDate DateTime Booking creation date.
totalPrice Decimal Total booking price.
customerDataObject Object Customer information.
reservationDataObjectList Array List of reservations linked to the booking.

Example JSON Sent

{
  "bookingDataObjectList": [
    {
      "id": 101,
      "version": 1,
      "start_date": "2026-03-15",
      "end_date": "2026-03-20",
      "status": "CONFIRMED",
      "commision": 15.0,
      "createdDate": "2026-03-10T10:30:00",
      "totalPrice": 450.0,
      "customerDataObject": {
        "id": 55,
        "version": 0,
        "first_name": "Ardit",
        "last_name": "Hoxha",
        "mobile_phone": "+355691112233",
        "address": "",
        "zip": "",
        "telephone": "+355691112233",
        "city": "",
        "note": "",
        "email": "[email protected]",
        "guest_type": "",
        "region": "",
        "languageId": 1
      },
      "reservationDataObjectList": [
        {
          "id": 9001,
          "roomId": 12,
          "occupancy": 2,
          "date": "2026-03-15",
          "status": "BOOKED",
          "price": 90.0
        },
        {
          "id": 9002,
          "roomId": 12,
          "occupancy": 2,
          "date": "2026-03-16",
          "status": "BOOKED",
          "price": 90.0
        }
      ]
    }
  ]
}

Headers

  • Content-Type: application/json
  • Accept: application/json

Example Response

{
  "success": true,
  "message": "Bookings imported successfully"
}

Notes

  • If the provided property identifier does not exist, the situation should be handled through a controlled error response rather than being silently accepted.
  • When certain customer details are missing, they are automatically replaced with empty values.
  • Bookings that do not contain a start date or end date are ignored and excluded from the resulting data.
  • To transmit the actual payload to an external API, a suitable HTTP communication mechanism should be used, such as a client designed for sending requests and receiving responses.