---
/bookings:
  get:
    x-mojo-to: Bookings#list
    operationId: listBookings
    parameters:
      - description: Case insensative search on booking biblio_id
        in: query
        name: biblio_id
        required: false
        type: string
      - description: Case insensative search on booking item_id
        in: query
        name: item_id
        required: false
        type: string
      - description: Case insensative search on booking patron_id
        in: query
        name: patron_id
        required: false
        type: string
      - description: Case Insensative search on booking start_date
        in: query
        name: start_date
        required: false
        type: string
      - description: Case Insensative search on booking end_date
        in: query
        name: end_date
        required: false
        type: string
      - $ref: "../swagger.yaml#/parameters/match"
      - $ref: "../swagger.yaml#/parameters/order_by"
      - $ref: "../swagger.yaml#/parameters/page"
      - $ref: "../swagger.yaml#/parameters/per_page"
      - $ref: "../swagger.yaml#/parameters/q_param"
      - $ref: "../swagger.yaml#/parameters/q_body"
      - name: x-koha-embed
        in: header
        required: false
        description: Embed list sent as a request header
        type: array
        items:
          type: string
          enum:
            - biblio
            - item
            - patron
        collectionFormat: csv
    produces:
      - application/json
    responses:
      200:
        description: A list of bookings
        schema:
          items:
            $ref: ../swagger.yaml#/definitions/booking
          type: array
      400:
        description: |
          Bad request. Possible `error_code` attribute values:

            * `invalid_query`
        schema:
          $ref: "../swagger.yaml#/definitions/error"
      403:
        description: Access forbidden
        schema:
          $ref: ../swagger.yaml#/definitions/error
      500:
        description: Internal error
        schema:
          $ref: ../swagger.yaml#/definitions/error
      503:
        description: Under maintenance
        schema:
          $ref: ../swagger.yaml#/definitions/error
    summary: List bookings
    tags:
      - bookings
    x-koha-authorization:
      permissions:
        catalogue: 1
  post:
    operationId: addBooking
    parameters:
      - description: A JSON object containing informations about the new booking
        in: body
        name: body
        required: true
        schema:
          $ref: ../swagger.yaml#/definitions/booking
    produces:
      - application/json
    responses:
      201:
        description: Booking added
        schema:
          $ref: ../swagger.yaml#/definitions/booking
      400:
        description: Bad request
        schema:
          $ref: ../swagger.yaml#/definitions/error
      401:
        description: Authentication required
        schema:
          $ref: ../swagger.yaml#/definitions/error
      403:
        description: Access forbidden
        schema:
          $ref: ../swagger.yaml#/definitions/error
      409:
        description: Conflict
        schema:
          $ref: ../swagger.yaml#/definitions/error
      500:
        description: Internal error
        schema:
          $ref: ../swagger.yaml#/definitions/error
      503:
        description: Under maintenance
        schema:
          $ref: ../swagger.yaml#/definitions/error
    summary: Add booking
    tags:
      - bookings
    x-koha-authorization:
      permissions:
        circulate: manage_bookings
    x-mojo-to: Bookings#add
'/bookings/{booking_id}':
  delete:
    operationId: deleteBooking
    parameters:
      - $ref: "../swagger.yaml#/parameters/booking_id_pp"
    produces:
      - application/json
    responses:
      204:
        description: Booking deleted
      400:
        description: Bad request
        schema:
          $ref: "../swagger.yaml#/definitions/error"
      401:
        description: Authentication required
        schema:
          $ref: ../swagger.yaml#/definitions/error
      403:
        description: Access forbidden
        schema:
          $ref: ../swagger.yaml#/definitions/error
      404:
        description: Booking not found
        schema:
          $ref: ../swagger.yaml#/definitions/error
      500:
        description: Internal error
        schema:
          $ref: ../swagger.yaml#/definitions/error
      503:
        description: Under maintenance
        schema:
          $ref: ../swagger.yaml#/definitions/error
    summary: Delete booking
    tags:
      - bookings
    x-koha-authorization:
      permissions:
        circulate: manage_bookings
    x-mojo-to: Bookings#delete
  get:
    operationId: getBooking
    parameters:
      - $ref: "../swagger.yaml#/parameters/booking_id_pp"
    produces:
      - application/json
    responses:
      200:
        description: A booking
        schema:
          $ref: ../swagger.yaml#/definitions/booking
      400:
        description: Bad request
        schema:
          $ref: "../swagger.yaml#/definitions/error"
      404:
        description: Booking not found
        schema:
          $ref: ../swagger.yaml#/definitions/error
      500:
        description: Internal error
        schema:
          $ref: ../swagger.yaml#/definitions/error
      503:
        description: Under maintenance
        schema:
          $ref: ../swagger.yaml#/definitions/error
    summary: Get booking
    tags:
      - bookings
    x-koha-authorization:
      permissions:
        catalogue: 1
    x-mojo-to: Bookings#get
  put:
    operationId: updateBooking
    parameters:
      - $ref: "../swagger.yaml#/parameters/booking_id_pp"
      - description: A booking object
        in: body
        name: body
        required: true
        schema:
          $ref: ../swagger.yaml#/definitions/booking
    produces:
      - application/json
    responses:
      200:
        description: A booking
        schema:
          $ref: ../swagger.yaml#/definitions/booking
      400:
        description: Bad request
        schema:
          $ref: ../swagger.yaml#/definitions/error
      401:
        description: Authentication required
        schema:
          $ref: ../swagger.yaml#/definitions/error
      403:
        description: Access forbidden
        schema:
          $ref: ../swagger.yaml#/definitions/error
      404:
        description: Booking not found
        schema:
          $ref: ../swagger.yaml#/definitions/error
      500:
        description: Internal error
        schema:
          $ref: ../swagger.yaml#/definitions/error
      503:
        description: Under maintenance
        schema:
          $ref: ../swagger.yaml#/definitions/error
    summary: Update booking
    tags:
      - bookings
    x-koha-authorization:
      permissions:
        circulate: manage_bookings
    x-mojo-to: Bookings#update
