openapi: 3.0.1
info:
  title: Invia online booking API
  description: This document describes online booking API for tour operators.
  contact:
    email: petra.osickova@invia.cz
  version: 1.0.1
externalDocs:
  description: Find out more about Swagger
  url: http://swagger.io
tags:
- name: Availability
  description: availability of a term and a pricelist
- name: Booking
  description: booking of a term
- name: Additional services
  description: services as insurance, visa, transfer, ...
- name: Payment schedule
  description: paid and not paid payments
paths:
  /availability/getAvailabilityAndPrices:
    post:
      tags:
      - Availability
      summary: Returns availability of a term and a pricelist
      operationId: getAvailabilityAndPrices
      requestBody:
        description: Availability search params
        content:
          '*/*':
            schema:
              $ref: '#/components/schemas/AvailabilitySearchRequest'
        required: true
      responses:
        201:
          description: Booking availability resource created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AvailabilitySearchResponse'
        400:
          description: Invalid input
          content: {}
        404:
          description: Resource not found
          content: {}
      x-codegen-request-body-name: body
  /booking/createBooking:
    post:
      tags:
      - Booking
      summary: Creates a new booking
      operationId: createBooking
      requestBody:
        description: Booking request params
        content:
          '*/*':
            schema:
              $ref: '#/components/schemas/BookingRequest'
        required: true
      responses:
        201:
          description: Booking resource created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BookingResponse'
        400:
          description: Invalid input
          content: {}
        404:
          description: Resource not found
          content: {}
      x-codegen-request-body-name: body
  /booking/getBooking/{id}:
    get:
      tags:
      - Booking
      summary: Returns data of a booking
      operationId: getBooking
      parameters:
      - name: id
        in: path
        description: ID of a booking
        required: true
        schema:
          type: integer
          format: int64
      responses:
        200:
          description: Booking resource returned
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BookingResponse'
        404:
          description: Resource not found
          content: {}
  /booking/updatePersons/{id}:
    put:
      tags:
      - Booking
      summary: Updates passengers and customer's data
      operationId: updatePersons
      parameters:
      - name: id
        in: path
        description: ID of a booking
        required: true
        schema:
          type: integer
          format: int64
      requestBody:
        description: Availability search params
        content:
          '*/*':
            schema:
              $ref: '#/components/schemas/BookingRequest'
        required: true
      responses:
        200:
          description: Booking updated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BookingResponse'
        400:
          description: Invalid input
          content: {}
        404:
          description: Resource not found
          content: {}
      x-codegen-request-body-name: body
  /booking/confirmBooking/{id}:
    post:
      tags:
      - Booking
      summary: Confirm a booking
      operationId: confirmBooking
      parameters:
      - name: id
        in: path
        description: ID of a booking
        required: true
        schema:
          type: integer
          format: int64
      responses:
        201:
          description: Booking confirmed
          content:
            application/json:
              schema:
                type: boolean
                example: true
        400:
          description: Invalid input
          content: {}
        404:
          description: Resource not found
          content: {}
  /booking/cancelBooking/{id}:
    delete:
      tags:
      - Booking
      summary: Cancel a booking
      operationId: cancelBooking
      parameters:
      - name: id
        in: path
        description: ID of a booking
        required: true
        schema:
          type: integer
          format: int64
      responses:
        204:
          description: Booking canceled
          content:
            application/json:
              schema:
                type: boolean
                example: true
        404:
          description: Resource not found
          content: {}
  /additionalServices/getServices/{id}:
    get:
      tags:
      - Additional services
      summary: Returns a list of services to the booking
      operationId: getAdditionalServices
      parameters:
      - name: id
        in: path
        description: ID of a booking
        required: true
        schema:
          type: integer
          format: int64
      responses:
        200:
          description: Additional services list returned
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AdditionalServiceListResponse'
        404:
          description: Resource not found
          content: {}
  /additionalServices/updateServices:
    patch:
      tags:
      - Additional services
      summary: Updates a list of services to the booking
      operationId: updateAdditionalServices
      requestBody:
        description: Booking request params
        content:
          '*/*':
            schema:
              $ref: '#/components/schemas/AdditionalServiceListUpdateRequest'
        required: true
      responses:
        200:
          description: Additional services list returned
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AdditionalServiceListResponse'
        400:
          description: Invalid input
          content: {}
        404:
          description: Resource not found
          content: {}
      x-codegen-request-body-name: body
  /payments/getSchedule/{id}:
    get:
      tags:
      - Payment schedule
      summary: Returns a list of payments to the booking
      operationId: getPaymentSchedule
      parameters:
      - name: id
        in: path
        description: ID of a booking
        required: true
        schema:
          type: integer
          format: int64
      responses:
        200:
          description: Payment schedule resource returned
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaymentScheduleResponse'
        404:
          description: Resource not found
          content: {}
components:
  schemas:
    AvailabilitySearchRequest:
      type: object
      properties:
        termId:
          type: integer
          example: 123456
        passengers:
          $ref: '#/components/schemas/PassengerList'
        transportation:
          $ref: '#/components/schemas/Transportation'  
      xml:
        name: AvailabilitySearchRequest
    AvailabilitySearchResponse:
      type: object
      properties:
        available:
          type: boolean
          description: Bool info, whether booking is available
          example: true
        type:
          type: string
          description: Type of availability
          enum:
          - available
          - on_request
          - unavailable
        totalPrice:
          $ref: '#/components/schemas/Price'
        board:
          $ref: '#/components/schemas/Board'
        room:
          $ref: '#/components/schemas/Room'
        transportation:
          $ref: '#/components/schemas/Transportation'
        offerId:
          type: integer
          description: Optionally reference to the offer
          example: 12345
        basicService:
          $ref: '#/components/schemas/BasicService'
        additionalServices:
          type: array
          items:
            $ref: '#/components/schemas/AdditionalService'
      xml:
        name: AvailabilitySearchResponse
    BookingRequest:
      type: object
      properties:
        termId:
          type: integer
          example: 123456
        offerId:
          type: integer
          description: Optionally reference to the offer
          example: 555555
        passengers:
          $ref: '#/components/schemas/PassengerList'
        customer:
          $ref: '#/components/schemas/Customer'
        note:
          type: string
          example: We would appreciate a sea view, please
      xml:
        name: BookingRequest
    BookingResponse:
      type: object
      properties:
        id:
          type: integer
          description: Booking ID
          example: 123456
        status:
          type: string
          enum:
          - new
          - confirmed
          - canceled
        dateExpiration:
          type: string
          format: date-time
          example: "2021-06-01T16:00:00+00:00"
        totalPrice:
          $ref: '#/components/schemas/Price'
        passengers:
          $ref: '#/components/schemas/PassengerList'
        customer:
          $ref: '#/components/schemas/Customer'
        basicService:
          $ref: '#/components/schemas/BasicService'
        additionalServices:
          type: array
          items:
            $ref: '#/components/schemas/AdditionalService'
        accommodations:
          type: array
          items:
            $ref: '#/components/schemas/Accommodation'
        flight:
          $ref: '#/components/schemas/FlightSummary'
        note:
          type: string
          example: You will have a sea view, enjoy!
      xml:
        name: BookingResponse
    AdditionalServiceListUpdateRequest:
      type: object
      properties:
        id:
          type: integer
          description: Booking ID
          example: 123456
        services:
          type: array
          items:
            $ref: '#/components/schemas/ServiceUpdate'
      xml:
        name: AdditionalServiceListRequest
    AdditionalServiceListResponse:
      type: object
      properties:
        services:
          type: array
          items:
            $ref: '#/components/schemas/AdditionalService'
      xml:
        name: AdditionalServiceListResponse
    PaymentScheduleResponse:
      type: object
      properties:
        payments:
          type: array
          items:
            $ref: '#/components/schemas/Payment'
      xml:
        name: PaymentScheduleResponse
    Passenger:
      type: object
      properties:
        id:
          type: integer
          example: 1
        firstName:
          type: string
          example: John
        lastName:
          type: string
          example: Doe
        dateBirth:
          type: string
          format: date
          example: "1989-11-17"
        type:
          type: string
          enum:
          - A
          - C
          - I
        gender:
          type: string
          enum:
          - M
          - F
        nationality:
          $ref: '#/components/schemas/Country'
      xml:
        name: Passenger
    PassengerList:
      type: array
      items:
        $ref: '#/components/schemas/Passenger'
    Customer:
      type: object
      properties:
        id:
          type: integer
          example: 1
        firstName:
          type: string
          example: John
        lastName:
          type: string
          example: Doe
        email:
          type: string
          example: john.doe@gmail.com
        phoneNumber:
          type: string
          example: "+420777888999"
        dateBirth:
          type: string
          format: date
          example: "1989-11-17"
        nationality:
          $ref: '#/components/schemas/Country'
        gender:
          type: string
          enum:
          - M
          - F
        address:
          $ref: '#/components/schemas/Address'
      xml:
        name: Customer
    Price:
      type: object
      properties:
        value:
          type: number
          example: 1500.0
        currencyCode:
          type: string
          example: CZK
      xml:
        name: Price
    BasicService:
      type: object
      properties:
        priceItems:
          type: array
          items:
            $ref: '#/components/schemas/PriceItem'
    AdditionalService:
      type: object
      properties:
        type:
          type: string
          example: travel_insurance
        priceItems:
          type: array
          items:
            allOf:
            - $ref: '#/components/schemas/PriceItem'
            - example:
                id: 100
                code: "INSURANCE"
                status: "available"
                unitPrice:
                  value: 200
                  currencyCode: "CZK"
                quantity: 1
                discount: 
                  value: 0
                  currencyCode: "CZK"
                description: "travel insurance"
                passengerIdList: 
                - 1
                - 2
    ServiceUpdate:
      type: object
      properties:
        type:
          type: string
          example: travel_insurance
        priceItems:
          type: array
          items:
            $ref: '#/components/schemas/PriceItemUpdate'
    PriceItem:
      type: object
      properties:
        id:
          type: integer
          example: 1
        code:
          type: string
          example: ADULT
        status:
          type: string
          enum:
          - available
          - selected
          - canceled
        unitPrice:
          $ref: '#/components/schemas/Price'
        quantity:
          type: integer
          example: 2
          description: "Number of this price item to count (item total price = unitPrice * quantity)"
        discount:
          allOf:
          - $ref: '#/components/schemas/Price'
          - example:
              value: 100.0
              currencyCode: "CZK"
        description:
          type: string
          example: "price for adult/night"
        passengerIdList:
          type: array
          description: "List of passenger IDs with this price item"
          example:
          - 1
          - 2
          - 3
          items:
            type: integer
      xml:
        name: PriceItem
    PriceItemUpdate:
      type: object
      properties:
        id:
          type: integer
          example: 1
        status:
          type: string
          enum:
          - new
          - canceled
        passengerIdList:
          type: array
          description: List of passenger IDs with this price item
          example:
          - 1
          - 2
          - 3
          items:
            type: integer
      xml:
        name: PriceItemUpdate
    Country:
      type: object
      properties:
        name:
          type: string
          example: Czech Republic
        isoAlpha2Code:
          type: string
          example: CZ
        isoAlpha3Code:
          type: string
          example: CZE
    Board:
      type: object
      properties:
        code:
          type: string
          example: AI
        description:
          type: string
          example: all inclusive
    Room:
      type: object
      properties:
        code:
          type: string
          example: DBL
        description:
          type: string
          example: double room
    Transportation:
      type: object
      properties:
        id:
          type: integer
          example: 1
        title:
          type: string
          example: by air
        dateDeparture:
          type: string
          format: date
          example: "2021-08-11"
        airport:
          $ref: '#/components/schemas/Airport'
    Airport:
      type: object
      properties:
        id:
          type: integer
          example: 1
        iataCode:
          type: string
          example: PRG
    Address:
      type: object
      properties:
        street:
          type: string
          example: Spodni
        houseNumber:
          type: string
          example: 124/15b
        city:
          type: string
          example: Brno
        postCode:
          type: string
          example: "60200"
        country:
          $ref: '#/components/schemas/Country'
    Accommodation:
      type: object
      properties:
        name:
          type: string
          example: Two weeks in paradise
        hotel:
          $ref: '#/components/schemas/Hotel'
        board:
          $ref: '#/components/schemas/Board'
        room:
          $ref: '#/components/schemas/Room'
        dateCheckIn:
          type: string
          format: date-time
          example: "2021-08-11T14:00:00+00:00"
        dateCheckOut:
          type: string
          format: date-time
          example: "2021-08-13T10:00:00+00:00"
    Hotel:
      type: object
      properties:
        name:
          type: string
          example: Royal Magic Beach Star Resort
        code:
          type: string
          example: RMBSR
        rating:
          type: number
          example: 4.5
    FlightSummary:
      type: object
      properties:
        flightThere:
          allOf:
            - $ref: '#/components/schemas/FlightOverallInfo'
            - example:
                airlineIataCode: "UI"
                flightNumber: "ABC123"
                departureAirport:
                  id: 1
                  iataCode: "PRG"
                dateDeparture: "2021-08-11T10:00:00+00:00"
                arrivalAirport:
                  id: 2
                  iataCode: "HRG"
                dateArrival: "2021-08-11T12:00:00+00:00"
        flightBack:
          allOf:
            - $ref: '#/components/schemas/FlightOverallInfo'
            - example:
                airlineIataCode: "UI"
                flightNumber: "DEF456"
                departureAirport:
                  id: 2
                  iataCode: "HRG"
                dateDeparture: "2021-08-13T16:00:00+00:00"
                arrivalAirport:
                  id: 1
                  iataCode: "PRG"
                dateArrival: "2021-08-13T18:00:00+00:00"

    FlightOverallInfo:
      type: object
      properties:
        departureAirport:
          $ref: '#/components/schemas/Airport'
        dateDeparture:
          type: string
          format: date-time
          example: "2021-08-11T08:00:00+00:00"
        arrivalAirport:
          $ref: '#/components/schemas/Airport'
        dateArrival:
          type: string
          format: date-time
          example: "2021-08-11T12:00:00+00:00"
        flights:
          type: array
          items:
            $ref: '#/components/schemas/Flight'
    Flight:
      type: object
      properties:
        order:
          type: integer
          example: 1
        airlineIataCode:
          type: string
          example: UI
        flightNumber:
          type: string
          example: ABC123
        departureAirport:
          $ref: '#/components/schemas/Airport'
        dateDeparture:
          type: string
          format: date-time
          example: "2021-08-11T08:00:00+00:00"
        arrivalAirport:
          $ref: '#/components/schemas/Airport'
        dateArrival:
          type: string
          format: date-time
          example: "2021-08-11T12:00:00+00:00"
    Payment:
      type: object
      properties:
        id:
          type: integer
          example: 1
        price:
          $ref: '#/components/schemas/Price'
        discount:
          $ref: '#/components/schemas/Price'
        paid:
          $ref: '#/components/schemas/Price'
        dueDate:
          type: string
          format: date
          example: "2021-08-11"
        status:
          type: string
          enum:
          - to_pay
          - partly_paid
          - paid
