openapi: 3.0.3
info:
  version: 1.0.2
  title: pmsx/core-api
  description: A set of tools to facilitate hotelier onboarding to a PmsXv2 partner
servers:
  - url: https://tpi-pmsx.preprod.siteminderlabs.com
security:
  - basicAuth: []
paths:
  "/core-api/pmses/{pmsCode}/hotels/{hotelCode}/reservation-import":
    post:
      operationId: importReservations
      description: Triggers the import active reservations job for requested hotel.
      tags:
        - Reservation Import
      parameters:
        - $ref: "#/components/parameters/traceToken"
        - $ref: "#/components/parameters/pmsCode"
        - $ref: "#/components/parameters/hotelCode"
      responses:
        202:
          description: Accepted for reservation import
          headers:
            X-SM-TRACE-TOKEN:
              $ref: "#/components/headers/X-SM-TRACE-TOKEN"
        400:
          $ref: "#/components/responses/BadRequest"
        401:
          $ref: "#/components/responses/Unauthorized"
        403:
          $ref: "#/components/responses/AccessDenied"
        404:
          $ref: "#/components/responses/NotFound"
        429:
          $ref: "#/components/responses/TooManyRequests"
        500:
          $ref: "#/components/responses/ServerError"
        503:
          $ref: "#/components/responses/ServiceUnavailableError"

  "/core-api/pmses/{pmsCode}/hotels/{hotelCode}/room-rates":
    get:
      operationId: getRoomRates
      description: Returns all configured room rates for specified hotelier.
      tags:
        - RoomRates
      parameters:
        - $ref: "#/components/parameters/traceToken"
        - $ref: "#/components/parameters/pmsCode"
        - $ref: "#/components/parameters/hotelCode"
      responses:
        "200":
          description: OK
          headers:
            X-SM-TRACE-TOKEN:
              $ref: '#/components/headers/X-SM-TRACE-TOKEN'
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/RoomRate"
        400:
          $ref: "#/components/responses/BadRequest"
        401:
          $ref: "#/components/responses/Unauthorized"
        403:
          $ref: "#/components/responses/AccessDenied"
        404:
          $ref: "#/components/responses/NotFound"
        409:
          $ref: "#/components/responses/AlreadyExistsError"
        429:
          $ref: "#/components/responses/TooManyRequests"
        500:
          $ref: "#/components/responses/ServerError"
        503:
          $ref: "#/components/responses/ServiceUnavailableError"
components:
  headers:
    X-SM-TRACE-TOKEN:
      schema:
        type: string
      description: trace token
  responses:
    Success:
      description: Success response
      headers:
        X-SM-TRACE-TOKEN:
          $ref: '#/components/headers/X-SM-TRACE-TOKEN'
    BadRequest:
      description: Invalid request
      headers:
        X-SM-TRACE-TOKEN:
          $ref: '#/components/headers/X-SM-TRACE-TOKEN'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Errors'
    Unauthorized:
      description: Unauthorized
      headers:
        X-SM-TRACE-TOKEN:
          $ref: '#/components/headers/X-SM-TRACE-TOKEN'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Errors'
    TooManyRequests:
      description: Too Many Requests
      headers:
        X-SM-TRACE-TOKEN:
          $ref: '#/components/headers/X-SM-TRACE-TOKEN'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Errors'
    ServerError:
      description: Unexpected error occurred
      headers:
        X-SM-TRACE-TOKEN:
          $ref: '#/components/headers/X-SM-TRACE-TOKEN'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Errors'
    NotFound:
      description: Not Found
      headers:
        X-SM-TRACE-TOKEN:
          schema:
            type: string
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/Errors"
    AccessDenied:
      description: Access denied
      headers:
        x-sm-trace-token:
          schema:
            type: string
      content:
        "application/json":
          schema:
            $ref: "#/components/schemas/Error"
    AlreadyExistsError:
      description: Conflict, record already exists
      headers:
        X-SM-TRACE-TOKEN:
          schema:
            type: string
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/Errors"
    ServiceUnavailableError:
      description: Service Unavailable
      headers:
        X-SM-TRACE-TOKEN:
          schema:
            type: string
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/Errors"
  schemas:
    RoomRate:
      type: object
      allOf:
        - type: object
          properties:
            ratePlanName:
              type: string
              description: The name of the Rate Plan
            ratePlanCode:
              type: string
              description: The rate plan mapping code of the room rate
            roomTypeName:
              type: string
              description: The name of the Room Type
            roomTypeCode:
              type: string
              description: The room type mapping code of the room rate
            includedAdultOccupancy:
              type: integer
              description: The number of guests included for the price for the room
    Errors:
      type: object
      properties:
        errors:
          type: array
          items:
            $ref: "#/components/schemas/Error"
    Error:
      type: object
      additionalProperties: false
      properties:
        code:
          type: string
          description: |2-
            - `invalid` is a generic code indicating an integration property does not match the constraints required by an integration. For more details on the specific property consult `meta.field` and `meta.propertyName`
            - `min` indicates either the field value (numeric) or string length is too small for given integration property. For more details on the specific property consult `meta.field` and `meta.propertyName`
            - `max` indicates either the field value (numeric) or string length is too large for given integration property. For more details on the specific property consult `meta.field` and `meta.propertyName`
            - `required` indicates that a given property that was required, was not specified in the request. Typically used for integration properties. For more details on the specific property consult `meta.field` and `meta.propertyName`
            - `conflict` indicates you are trying to create a resource e.g. pmsHotel which is already present. You will typically have `meta.entity` populated which takes on values `pms`, `pmsHotel`. The `meta.code` field is populated when `meta.entity` is pms and the `meta.uuid` field is populated when `meta.entity` is `pmsHotel`
            - `too-many-requests` indicates that the client has exceeded its API quota. It should wait for at least the specified time in seconds which is provided in the `Retry-After` HTTP header
            - `server` generic error
            - `UnauthorizedError` happens when we cannot authenticate the user
            - `AccessDenied` happens when we know who the user is, but they do not have required permissions to perform the action
          example:
            - invalid
            - not-found
            - conflict
            - too-many-requests
            - server
            - UnauthorizedError
            - AccessDeniedError
            - min
            - max
            - required
        message:
          description: additional information on the error
          type: string
        meta:
          description: |-2
            Contains any additional information to enrich the error.
            All properties are optional.
          additionalProperties: true
          type: object
          properties:
            code:
              type: string
              description: Typically populated with we get a conflict error for the entity pms or when pms or integration is not found
            uuid:
              type: string
              description: Typically populated when we get a conflict error for the entity pmsHotel or when pmsHotel or pmsRoomRate is not found
            entity:
              type: string
              example:
                - pmsHotel
                - pmsRoomRate
              description: typically populated when a conflict error is raised. Also present in not found errors too
            field:
              type: string
              description: name of the field which typically has a validation error.
            propertyName:
              type: string
              description: populated when the `meta.field` is set the `integrationProperties`. This tells us the property name in question that the error is for.
            dataPath:
              type: string
              description: returned when there is a syntactic error in the request. That is the request is not compliant with the route.
  parameters:
    traceToken:
      name: X-SM-TRACE-TOKEN
      in: header
      description: traceToken is logged with every log messages for this request
      required: true
      schema:
        type: string
    hotelCode:
      in: path
      name: hotelCode
      description: hotelCode used to identify the hotelier
      required: true
      schema:
        type: string
        minLength: 1
        maxLength: 255
    pmsCode:
      in: path
      name: pmsCode
      description: pmsCode used to identify the pmsx partner
      schema:
        type: string
        minLength: 1
        maxLength: 255
      required: true
  securitySchemes:
    basicAuth:
      type: http
      scheme: basic
