# This open api service interface is implemented by API rest controllers.
openapi: "3.0.1"
info:
  title: "Ondemand industry services api"
  version: "1.0.0"
  description: Ondemand API services to be consumed by external users

paths:

  /v1/hello:
    get:
      summary: temporary method
      tags:
        - endpoint
      responses:
        '200':
          description: OK
          headers:
            Access-Control-Allow-Origin:
              schema:
                type: string
          content:
            text/plain:
              schema:
                $ref: "#/components/schemas/String"
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
        - IndustryPartnerApiAuthorizer:
            - Fn::Sub: '${ResourceServerIdParameter}/driversubscription.read'
      x-amazon-apigateway-integration:
        uri:
          "Fn::Join":
            - ''
            - - 'http://'
              - Fn::ImportValue:
                  Fn::Sub: '${CommonResourcesStackNameParameter}-EcsNlb-dns'
              - ':8052'
              - '/v1/hello'
        responses:
          default:
            statusCode: "200"
            responseParameters:
              method.response.header.Access-Control-Allow-Origin: "'*'"
        requestParameters:
          integration.request.header.caller-arn: "context.identity.userArn"
        passthroughBehavior: when_no_match
        connectionType: VPC_LINK
        connectionId: '${stageVariables.vpcLinkId}'
        httpMethod: GET
        type: http_proxy
    options:
      responses:
        200:
          description: "200 response"
          headers:
            Access-Control-Allow-Origin:
              schema:
                type: "string"
            Access-Control-Allow-Methods:
              schema:
                type: "string"
            Access-Control-Allow-Headers:
              schema:
                type: "string"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Empty"
      x-amazon-apigateway-integration:
        responses:
          default:
            statusCode: "200"
            responseParameters:
              method.response.header.Access-Control-Allow-Methods: "'GET,OPTIONS'"
              method.response.header.Access-Control-Allow-Headers: "'Content-Type,X-Amz-Date,Authorization,X-Api-Key'"
              method.response.header.Access-Control-Allow-Origin: "'*'"
        passthroughBehavior: "when_no_match"
        requestTemplates:
          application/json: "{\"statusCode\": 200}"
        type: "mock"

  /v1/ondemand-industry-api/drivers/{driver_licence_number}/ptd-status:
    get:
      description: Returns PTD status for the given API access subscribed driver.
      parameters:
      - name: driver_licence_number
        in : path
        required: true
        schema:
          type: string
          minLength: 1
          maxLength: 7
      - name: driver_surname
        in : query
        required: true
        schema:
          type: string
          minLength: 1
          maxLength: 40
      - name: date_of_birth
        in : query
        required: true
        schema:
          type: string
          format: date

      responses:
        "200":
          description: 200 response
          headers:
            Access-Control-Allow-Origin:
              schema:
                type: "string"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/GetPTDDetailsForDriverResponse"
        "400":
          description: 400 response - bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/BadRequestResponse"
        "401":
          description: 401 response - Unauthorised, including when the authenticated
            user is not authorised to query online applications for the specified user.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/UnauthorizedErrorResponse"
      security:
        - IndustryPartnerApiAuthorizer:
            - Fn::Sub: "${ResourceServerIdParameter}/driversubscription.read"
      x-amazon-apigateway-integration:
          uri:
            "Fn::Join":
                - ''
                - - 'http://'
                  - Fn::ImportValue:
                      Fn::Sub: '${CommonResourcesStackNameParameter}-EcsNlb-dns'
                  - ':8052'
                  - '/v1/ondemand-industry-api/drivers/{driver_licence_number}/ptd-status'
          responses:
            default:
              statusCode: "200"
              responseParameters:
                method.response.header.Access-Control-Allow-Origin: "'*'"
          requestParameters:
            integration.request.path.driver_licence_number: "method.request.path.driver_licence_number"
          passthroughBehavior: "when_no_match"
          connectionType: "VPC_LINK"
          connectionId: "${stageVariables.vpcLinkId}"
          httpMethod: "GET"
          type: "http_proxy"
    options:
      parameters:
      - name: driver_licence_number
        in : path
        required: true
        schema:
          type: string
      responses:
        200:
          description: "200 response"
          headers:
            Access-Control-Allow-Origin:
              schema:
                type: "string"
            Access-Control-Allow-Methods:
              schema:
                type: "string"
            Access-Control-Allow-Headers:
              schema:
                type: "string"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Empty"
      x-amazon-apigateway-integration:
        responses:
          default:
            statusCode: "200"
            responseParameters:
              method.response.header.Access-Control-Allow-Methods: "'GET,OPTIONS'"
              method.response.header.Access-Control-Allow-Headers: "'Content-Type,X-Amz-Date,Authorization,X-Api-Key'"
              method.response.header.Access-Control-Allow-Origin: "'*'"
        passthroughBehavior: "when_no_match"
        requestTemplates:
          application/json: "{\"statusCode\": 200}"
        type: "mock"

  /v1/ondemand-industry-api/drivers/{driver_licence_number}:
    post:
      description: Add the driver to the driver dashboard
      parameters:
      - name: driver_licence_number
        in : path
        required: true
        schema:
          type: string
          minLength: 1
          maxLength: 7
      - name: driver_surname
        in : query
        required: true
        schema:
          type: string
          minLength: 1
          maxLength: 40
      - name: date_of_birth
        in : query
        required: true
        schema:
          type: string
      responses:
        "200":
          description: 200 response
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AddDriverSubscriptionResponse"
          headers:
            Access-Control-Allow-Origin:
              schema:
                type: "string"
        "400":
          description: 400 response - bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/BadRequestResponse"
        "401":
          description: 401 response - Unauthorised, including when the authenticated
            user is not authorised to query online applications for the specified user.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/UnauthorizedErrorResponse"
      security:
        - IndustryPartnerApiAuthorizer:
            - Fn::Sub: "${ResourceServerIdParameter}/driversubscription.write"
      x-amazon-apigateway-integration:
          uri:
            "Fn::Join":
                - ''
                - - 'http://'
                  - Fn::ImportValue:
                      Fn::Sub: '${CommonResourcesStackNameParameter}-EcsNlb-dns'
                  - ':8052'
                  - '/v1/ondemand-industry-api/drivers/{driver_licence_number}'
          responses:
            default:
              statusCode: "200"
              responseParameters:
                method.response.header.Access-Control-Allow-Origin: "'*'"
          requestParameters:
            integration.request.path.driver_licence_number: "method.request.path.driver_licence_number"
          passthroughBehavior: "when_no_match"
          connectionType: "VPC_LINK"
          connectionId: "${stageVariables.vpcLinkId}"
          httpMethod: "POST"
          type: "http_proxy"
    options:
      parameters:
        - name: driver_licence_number
          in: path
          required: true
          description: The driver's licence number.
          schema:
            type: string
      responses:
        200:
          description: "200 response"
          headers:
            Access-Control-Allow-Origin:
              schema:
                type: "string"
            Access-Control-Allow-Methods:
              schema:
                type: "string"
            Access-Control-Allow-Headers:
              schema:
                type: "string"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Empty"
      x-amazon-apigateway-integration:
        responses:
          default:
            statusCode: "200"
            responseParameters:
              method.response.header.Access-Control-Allow-Methods: "'POST,OPTIONS'"
              method.response.header.Access-Control-Allow-Headers: "'Content-Type,X-Amz-Date,Authorization,X-Api-Key'"
              method.response.header.Access-Control-Allow-Origin: "'*'"
        passthroughBehavior: "when_no_match"
        requestTemplates:
          application/json: "{\"statusCode\": 200}"
        type: "mock"

  /v1/ondemand-industry-api/drivers/{driver_licence_number}/remove:
    post:
      description: Remove the driver from the driver dashboard
      parameters:
      - name: driver_licence_number
        in : path
        required: true
        schema:
          type: string
          minLength: 1
          maxLength: 7
      - name: driver_surname
        in : query
        required: true
        schema:
          type: string
          minLength: 1
          maxLength: 40
      - name: date_of_birth
        in : query
        required: true
        schema:
          type: string
          format: date
      responses:
        "200":
          description: 200 response
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/RemoveDriverSubscriptionResponse"
          headers:
            Access-Control-Allow-Origin:
              schema:
                type: "string"
        "400":
          description: 400 response - bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/BadRequestResponse"
        "401":
          description: 401 response - Unauthorised, including when the authenticated
            user is not authorised to query online applications for the specified user.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/UnauthorizedErrorResponse"
      security:
        - IndustryPartnerApiAuthorizer:
            - Fn::Sub: "${ResourceServerIdParameter}/driversubscription.write"
      x-amazon-apigateway-integration:
          uri:
            "Fn::Join":
                - ''
                - - 'http://'
                  - Fn::ImportValue:
                      Fn::Sub: '${CommonResourcesStackNameParameter}-EcsNlb-dns'
                  - ':8052'
                  - '/v1/ondemand-industry-api/drivers/{driver_licence_number}/remove'
          responses:
            default:
              statusCode: "200"
              responseParameters:
                method.response.header.Access-Control-Allow-Origin: "'*'"
          requestParameters:
            integration.request.path.driver_licence_number: "method.request.path.driver_licence_number"
          passthroughBehavior: "when_no_match"
          connectionType: "VPC_LINK"
          connectionId: "${stageVariables.vpcLinkId}"
          httpMethod: "POST"
          type: "http_proxy"
    options:
      parameters:
      - name: driver_licence_number
        in : path
        required: true
        schema:
          type: string
      responses:
        200:
          description: "200 response"
          headers:
            Access-Control-Allow-Origin:
              schema:
                type: "string"
            Access-Control-Allow-Methods:
              schema:
                type: "string"
            Access-Control-Allow-Headers:
              schema:
                type: "string"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Empty"
      x-amazon-apigateway-integration:
        responses:
          default:
            statusCode: "200"
            responseParameters:
              method.response.header.Access-Control-Allow-Methods: "'POST,OPTIONS'"
              method.response.header.Access-Control-Allow-Headers: "'Content-Type,X-Amz-Date,Authorization,X-Api-Key'"
              method.response.header.Access-Control-Allow-Origin: "'*'"
        passthroughBehavior: "when_no_match"
        requestTemplates:
          application/json: "{\"statusCode\": 200}"
        type: "mock"

  /v1/ondemand-industry-api/drivers/subscription-export:
    get:
      description: Export a list of driver subscriptions for given parameters
      parameters:
      - name: filter_status
        in : query
        required: true
        schema:
          type: string
          minLength: 1
          maxLength: 20
      - name: export_type
        in : query
        required: true
        schema:
          type: string
          minLength: 1
          maxLength: 20

      responses:
        "200":
          description: 200 response
          headers:
            Access-Control-Allow-Origin:
              schema:
                type: "string"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/GetDriverSubscriptionExportContentResponse"
        "400":
          description: 400 response - bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/BadRequestResponse"
        "401":
          description: 401 response - Unauthorised, including when the authenticated
            user is not authorised to query online applications for the specified user.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/UnauthorizedErrorResponse"
      security:
        - IndustryPartnerApiAuthorizer:
          - Fn::Sub: '${ResourceServerIdParameter}/driversubscription.read'
      x-amazon-apigateway-integration:
          uri:
            "Fn::Join":
                - ''
                - - 'http://'
                  - Fn::ImportValue:
                      Fn::Sub: '${CommonResourcesStackNameParameter}-EcsNlb-dns'
                  - ':8052'
                  - '/v1/ondemand-industry-api/drivers/subscription-export'
          responses:
            default:
              statusCode: "200"
              responseParameters:
                method.response.header.Access-Control-Allow-Origin: "'*'"
          passthroughBehavior: "when_no_match"
          connectionType: "VPC_LINK"
          connectionId: "${stageVariables.vpcLinkId}"
          httpMethod: "GET"
          type: "http_proxy"
    options:
      responses:
        200:
          description: "200 response"
          headers:
            Access-Control-Allow-Origin:
              schema:
                type: "string"
            Access-Control-Allow-Methods:
              schema:
                type: "string"
            Access-Control-Allow-Headers:
              schema:
                type: "string"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Empty"
      x-amazon-apigateway-integration:
        responses:
          default:
            statusCode: "200"
            responseParameters:
              method.response.header.Access-Control-Allow-Methods: "'GET,OPTIONS'"
              method.response.header.Access-Control-Allow-Headers: "'Content-Type,X-Amz-Date,Authorization,X-Api-Key'"
              method.response.header.Access-Control-Allow-Origin: "'*'"
        passthroughBehavior: "when_no_match"
        requestTemplates:
          application/json: "{\"statusCode\": 200}"
        type: "mock"

  /v1/ondemand-industry-api/vehicles/ptv-status:
    get:
      description: Returns the current PTV status for a given vehicle
      parameters:
      - name: plate_number
        in : query
        required: true
        schema:
          type: string
          minLength: 1
          maxLength: 12
      - name: vin_number
        in : query
        required: false
        schema:
          type: string
          minLength: 1
          maxLength: 25
      responses:
        "200":
          description: 200 response
          headers:
            Access-Control-Allow-Origin:
              schema:
                type: "string"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/GetPTVDetailsForVehicleResponse"
        "400":
          description: 400 response - bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/BadRequestResponse"
        "401":
          description: 401 response - Unauthorised, including when the authenticated
            user is not authorised to query online applications for the specified user.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/UnauthorizedErrorResponse"
      security:
        - IndustryPartnerApiAuthorizer:
            - Fn::Sub: "${ResourceServerIdParameter}/vehiclesubscription.read"
      x-amazon-apigateway-integration:
          uri:
            "Fn::Join":
                - ''
                - - 'http://'
                  - Fn::ImportValue:
                      Fn::Sub: '${CommonResourcesStackNameParameter}-EcsNlb-dns'
                  - ':8052'
                  - '/v1/ondemand-industry-api/vehicles/ptv-status'
          responses:
            default:
              statusCode: "200"
              responseParameters:
                method.response.header.Access-Control-Allow-Origin: "'*'"
          passthroughBehavior: "when_no_match"
          connectionType: "VPC_LINK"
          connectionId: "${stageVariables.vpcLinkId}"
          httpMethod: "GET"
          type: "http_proxy"
    options:
      responses:
        200:
          description: "200 response"
          headers:
            Access-Control-Allow-Origin:
              schema:
                type: "string"
            Access-Control-Allow-Methods:
              schema:
                type: "string"
            Access-Control-Allow-Headers:
              schema:
                type: "string"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Empty"
      x-amazon-apigateway-integration:
        responses:
          default:
            statusCode: "200"
            responseParameters:
              method.response.header.Access-Control-Allow-Methods: "'GET,OPTIONS'"
              method.response.header.Access-Control-Allow-Headers: "'Content-Type,X-Amz-Date,Authorization,X-Api-Key'"
              method.response.header.Access-Control-Allow-Origin: "'*'"
        passthroughBehavior: "when_no_match"
        requestTemplates:
          application/json: "{\"statusCode\": 200}"
        type: "mock"

  /v1/ondemand-industry-api/vehicles/{plate_number}:
    post:
      description: Add the vehicle to the vehicle dashboard
      parameters:
      - name: plate_number
        in : path
        required: true
        schema:
          type: string
          minLength: 1
          maxLength: 12
      - name: vin_number
        in : query
        required: false
        schema:
          type: string
          minLength: 1
          maxLength: 25
      responses:
        "200":
          description: 200 response
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AddVehicleSubscriptionResponse"
          headers:
            Access-Control-Allow-Origin:
              schema:
                type: "string"
        "400":
          description: 400 response - bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/BadRequestResponse"
        "401":
          description: 401 response - Unauthorised, including when the authenticated
            user is not authorised to query online applications for the specified user.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/UnauthorizedErrorResponse"
      security:
        - IndustryPartnerApiAuthorizer:
            - Fn::Sub: "${ResourceServerIdParameter}/vehiclesubscription.write"
      x-amazon-apigateway-integration:
          uri:
            "Fn::Join":
                - ''
                - - 'http://'
                  - Fn::ImportValue:
                      Fn::Sub: '${CommonResourcesStackNameParameter}-EcsNlb-dns'
                  - ':8052'
                  - '/v1/ondemand-industry-api/vehicles/{plate_number}'
          responses:
            default:
              statusCode: "200"
              responseParameters:
                method.response.header.Access-Control-Allow-Origin: "'*'"
          requestParameters:
            integration.request.path.plate_number: "method.request.path.plate_number"
          passthroughBehavior: "when_no_match"
          connectionType: "VPC_LINK"
          connectionId: "${stageVariables.vpcLinkId}"
          httpMethod: "POST"
          type: "http_proxy"
    options:
      parameters:
        - name: plate_number
          in: path
          required: true
          description: The plate number.
          schema:
            type: string
      responses:
        200:
          description: "200 response"
          headers:
            Access-Control-Allow-Origin:
              schema:
                type: "string"
            Access-Control-Allow-Methods:
              schema:
                type: "string"
            Access-Control-Allow-Headers:
              schema:
                type: "string"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Empty"
      x-amazon-apigateway-integration:
        responses:
          default:
            statusCode: "200"
            responseParameters:
              method.response.header.Access-Control-Allow-Methods: "'POST,OPTIONS'"
              method.response.header.Access-Control-Allow-Headers: "'Content-Type,X-Amz-Date,Authorization,X-Api-Key'"
              method.response.header.Access-Control-Allow-Origin: "'*'"
        passthroughBehavior: "when_no_match"
        requestTemplates:
          application/json: "{\"statusCode\": 200}"
        type: "mock"

  /v1/ondemand-industry-api/vehicles/{plate_number}/remove:
    post:
      description: Remove the vehicle to the vehicle dashboard
      parameters:
      - name: plate_number
        in : path
        required: true
        schema:
          type: string
          minLength: 1
          maxLength: 12
      - name: vin_number
        in : query
        required: false
        schema:
          type: string
          minLength: 1
          maxLength: 25
      responses:
        "200":
          description: 200 response
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/RemoveVehicleSubscriptionResponse"
          headers:
            Access-Control-Allow-Origin:
              schema:
                type: "string"
        "400":
          description: 400 response - bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/BadRequestResponse"
        "401":
          description: 401 response - Unauthorised, including when the authenticated
            user is not authorised to query online applications for the specified user.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/UnauthorizedErrorResponse"
      security:
        - IndustryPartnerApiAuthorizer:
            - Fn::Sub: "${ResourceServerIdParameter}/vehiclesubscription.write"
      x-amazon-apigateway-integration:
          uri:
            "Fn::Join":
                - ''
                - - 'http://'
                  - Fn::ImportValue:
                      Fn::Sub: '${CommonResourcesStackNameParameter}-EcsNlb-dns'
                  - ':8052'
                  - '/v1/ondemand-industry-api/vehicles/{plate_number}/remove'
          responses:
            default:
              statusCode: "200"
              responseParameters:
                method.response.header.Access-Control-Allow-Origin: "'*'"
          requestParameters:
            integration.request.path.plate_number: "method.request.path.plate_number"
          passthroughBehavior: "when_no_match"
          connectionType: "VPC_LINK"
          connectionId: "${stageVariables.vpcLinkId}"
          httpMethod: "POST"
          type: "http_proxy"
    options:
      parameters:
        - name: plate_number
          in: path
          required: true
          description: The plate number.
          schema:
            type: string
      responses:
        200:
          description: "200 response"
          headers:
            Access-Control-Allow-Origin:
              schema:
                type: "string"
            Access-Control-Allow-Methods:
              schema:
                type: "string"
            Access-Control-Allow-Headers:
              schema:
                type: "string"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Empty"
      x-amazon-apigateway-integration:
        responses:
          default:
            statusCode: "200"
            responseParameters:
              method.response.header.Access-Control-Allow-Methods: "'POST,OPTIONS'"
              method.response.header.Access-Control-Allow-Headers: "'Content-Type,X-Amz-Date,Authorization,X-Api-Key'"
              method.response.header.Access-Control-Allow-Origin: "'*'"
        passthroughBehavior: "when_no_match"
        requestTemplates:
          application/json: "{\"statusCode\": 200}"
        type: "mock"

  /v1/ondemand-industry-api/vehicles/export:
    get:
      description: Export a list of vehicle subscriptions for given parameters
      parameters:
      - name: filter_status
        in : query
        required: true
        schema:
          type: string
          minLength: 1
          maxLength: 20
      - name: export_type
        in : query
        required: true
        schema:
          type: string
          minLength: 1
          maxLength: 20

      responses:
        "200":
          description: 200 response
          headers:
            Access-Control-Allow-Origin:
              schema:
                type: "string"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/GetVehicleSubscriptionExportContentResponse"
        "400":
          description: 400 response - bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/BadRequestResponse"
        "401":
          description: 401 response - Unauthorised, including when the authenticated
            user is not authorised to query online applications for the specified user.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/UnauthorizedErrorResponse"
      security:
        - IndustryPartnerApiAuthorizer:
          - Fn::Sub: '${ResourceServerIdParameter}/vehiclesubscription.read'
      x-amazon-apigateway-integration:
          uri:
            "Fn::Join":
                - ''
                - - 'http://'
                  - Fn::ImportValue:
                      Fn::Sub: '${CommonResourcesStackNameParameter}-EcsNlb-dns'
                  - ':8052'
                  - '/v1/ondemand-industry-api/vehicles/export'
          responses:
            default:
              statusCode: "200"
              responseParameters:
                method.response.header.Access-Control-Allow-Origin: "'*'"
          passthroughBehavior: "when_no_match"
          connectionType: "VPC_LINK"
          connectionId: "${stageVariables.vpcLinkId}"
          httpMethod: "GET"
          type: "http_proxy"
    options:
      responses:
        200:
          description: "200 response"
          headers:
            Access-Control-Allow-Origin:
              schema:
                type: "string"
            Access-Control-Allow-Methods:
              schema:
                type: "string"
            Access-Control-Allow-Headers:
              schema:
                type: "string"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Empty"
      x-amazon-apigateway-integration:
        responses:
          default:
            statusCode: "200"
            responseParameters:
              method.response.header.Access-Control-Allow-Methods: "'GET,OPTIONS'"
              method.response.header.Access-Control-Allow-Headers: "'Content-Type,X-Amz-Date,Authorization,X-Api-Key'"
              method.response.header.Access-Control-Allow-Origin: "'*'"
        passthroughBehavior: "when_no_match"
        requestTemplates:
          application/json: "{\"statusCode\": 200}"
        type: "mock"

  /v1/ondemand-industry-api/passenger-transport-subsidy-scheme/participant-status:
    get:
      description: Returns a list of subsidy levels for the participant at a given point-in-time
      parameters:
        - name: participantCardNumber
          in: query
          description: Unique PTSS participant card number.
          required: true
          schema:
            $ref: '#/components/schemas/ParticipantCardNumber'
        - name: cardExpiryDate
          in: query
          description: Date of birth of the participant
          required: true
          schema:
            $ref: '#/components/schemas/ParticipantCardExpiryDate'
        - name: bookingServiceAuthorisationNumber
          in: query
          description: The booking service authorisation number for the booking service customer
          required: true
          schema:
            $ref: '#/components/schemas/BookingServiceAuthorisationNumber'
      responses:
        "200":
          description: 200 response
          headers:
            Access-Control-Allow-Origin:
              schema:
                type: "string"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/FindSubsidyLevelResponse"
        "400":
          description: 400 response - bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/BadRequestResponse"
        "401":
          description: 401 response - Unauthorised, including when the authenticated
            user is not authorised to query online applications for the specified user.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/UnauthorizedErrorResponse"
      security:
        - IndustryPartnerApiAuthorizer:
          - Fn::Sub: '${ResourceServerIdParameter}/ptsssubscription.read'
      x-amazon-apigateway-integration:
          uri:
            "Fn::Join":
                - ''
                - - 'http://'
                  - Fn::ImportValue:
                      Fn::Sub: '${CommonResourcesStackNameParameter}-EcsNlb-dns'
                  - ':8052'
                  - '/v1/ondemand-industry-api/passenger-transport-subsidy-scheme/participant-status'
          responses:
            default:
              statusCode: "200"
              responseParameters:
                method.response.header.Access-Control-Allow-Origin: "'*'"
          passthroughBehavior: "when_no_match"
          connectionType: "VPC_LINK"
          connectionId: "${stageVariables.vpcLinkId}"
          httpMethod: "GET"
          type: "http_proxy"
    options:
      responses:
        200:
          description: "200 response"
          headers:
            Access-Control-Allow-Origin:
              schema:
                type: "string"
            Access-Control-Allow-Methods:
              schema:
                type: "string"
            Access-Control-Allow-Headers:
              schema:
                type: "string"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Empty"
      x-amazon-apigateway-integration:
        responses:
          default:
            statusCode: "200"
            responseParameters:
              method.response.header.Access-Control-Allow-Methods: "'GET,OPTIONS'"
              method.response.header.Access-Control-Allow-Headers: "'Content-Type,X-Amz-Date,Authorization,X-Api-Key'"
              method.response.header.Access-Control-Allow-Origin: "'*'"
        passthroughBehavior: "when_no_match"
        requestTemplates:
          application/json: "{\"statusCode\": 200}"
        type: "mock"

  /v1/ondemand-industry-api/passenger-transport-subsidy-scheme/booking-service-payments:
    get:
      description: Returns a list of Booking Service Payments for a given time period
      parameters:
        - name: startDate
          in: query
          description: The date from which Booking Service Payments for this booking service is to be retrieved.
          required: true
          schema:
            $ref: '#/components/schemas/PaymentDate'
        - name: endDate
          in: query
          description: The date up until for which Booking Service Payments for this booking service is to be retrieved.
          required: true
          schema:
            $ref: '#/components/schemas/PaymentDate'
      responses:
        "200":
          description: 200 response
          headers:
            Access-Control-Allow-Origin:
              schema:
                type: "string"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/FindPtssPaymentResponse"
        "400":
          description: 400 response - bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/BadRequestResponse"
        "401":
          description: 401 response - Unauthorised, including when the authenticated
            user is not authorised to query online applications for the specified user.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/UnauthorizedErrorResponse"
      security:
        - IndustryPartnerApiAuthorizer:
          - Fn::Sub: '${ResourceServerIdParameter}/ptsssubscription.read'
      x-amazon-apigateway-integration:
          uri:
            "Fn::Join":
                - ''
                - - 'http://'
                  - Fn::ImportValue:
                      Fn::Sub: '${CommonResourcesStackNameParameter}-EcsNlb-dns'
                  - ':8052'
                  - '/v1/ondemand-industry-api/passenger-transport-subsidy-scheme/ptss-paymnets'
          responses:
            default:
              statusCode: "200"
              responseParameters:
                method.response.header.Access-Control-Allow-Origin: "'*'"
          passthroughBehavior: "when_no_match"
          connectionType: "VPC_LINK"
          connectionId: "${stageVariables.vpcLinkId}"
          httpMethod: "GET"
          type: "http_proxy"
    options:
      responses:
        200:
          description: "200 response"
          headers:
            Access-Control-Allow-Origin:
              schema:
                type: "string"
            Access-Control-Allow-Methods:
              schema:
                type: "string"
            Access-Control-Allow-Headers:
              schema:
                type: "string"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Empty"
      x-amazon-apigateway-integration:
        responses:
          default:
            statusCode: "200"
            responseParameters:
              method.response.header.Access-Control-Allow-Methods: "'GET,OPTIONS'"
              method.response.header.Access-Control-Allow-Headers: "'Content-Type,X-Amz-Date,Authorization,X-Api-Key'"
              method.response.header.Access-Control-Allow-Origin: "'*'"
        passthroughBehavior: "when_no_match"
        requestTemplates:
          application/json: "{\"statusCode\": 200}"
        type: "mock"

  /v1/ondemand-industry-api/passenger-transport-subsidy-scheme/start-journey:
    post:
      description: Start a journey for a participant
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/StartJourneyRequest'
      responses:
        "200":
          description: 200 response
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/StartJourneyResponse"
          headers:
            Access-Control-Allow-Origin:
              schema:
                type: "string"
        "400":
          description: 400 response - bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/BadRequestResponse"
        "401":
          description: 401 response - Unauthorised, including when the authenticated
            user is not authorised to query online applications for the specified user.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/UnauthorizedErrorResponse"
      security:
        - IndustryPartnerApiAuthorizer:
            - Fn::Sub: "${ResourceServerIdParameter}/ptsssubscription.write"
      x-amazon-apigateway-integration:
          uri:
            "Fn::Join":
                - ''
                - - 'http://'
                  - Fn::ImportValue:
                      Fn::Sub: '${CommonResourcesStackNameParameter}-EcsNlb-dns'
                  - ':8052'
                  - '/v1/ondemand-industry-api/passenger-transport-subsidy-scheme/start-journey'
          responses:
            default:
              statusCode: "200"
              responseParameters:
                method.response.header.Access-Control-Allow-Origin: "'*'"
          passthroughBehavior: "when_no_match"
          connectionType: "VPC_LINK"
          connectionId: "${stageVariables.vpcLinkId}"
          httpMethod: "POST"
          type: "http_proxy"
    options:
      responses:
        200:
          description: "200 response"
          headers:
            Access-Control-Allow-Origin:
              schema:
                type: "string"
            Access-Control-Allow-Methods:
              schema:
                type: "string"
            Access-Control-Allow-Headers:
              schema:
                type: "string"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Empty"
      x-amazon-apigateway-integration:
        responses:
          default:
            statusCode: "200"
            responseParameters:
              method.response.header.Access-Control-Allow-Methods: "'POST,OPTIONS'"
              method.response.header.Access-Control-Allow-Headers: "'Content-Type,X-Amz-Date,Authorization,X-Api-Key'"
              method.response.header.Access-Control-Allow-Origin: "'*'"
        passthroughBehavior: "when_no_match"
        requestTemplates:
          application/json: "{\"statusCode\": 200}"
        type: "mock"

  /v1/ondemand-industry-api/passenger-transport-subsidy-scheme/complete-journey:
    post:
      description: Complete a journey for a participant
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CompleteJourneyRequest'
      responses:
        "200":
          description: 200 response
          headers:
            Access-Control-Allow-Origin:
              schema:
                type: "string"
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Empty'
        "400":
          description: 400 response - bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/BadRequestResponse"
        "401":
          description: 401 response - Unauthorised, including when the authenticated
            user is not authorised to query online applications for the specified user.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/UnauthorizedErrorResponse"
      security:
        - IndustryPartnerApiAuthorizer:
            - Fn::Sub: "${ResourceServerIdParameter}/ptsssubscription.write"
      x-amazon-apigateway-integration:
          uri:
            "Fn::Join":
                - ''
                - - 'http://'
                  - Fn::ImportValue:
                      Fn::Sub: '${CommonResourcesStackNameParameter}-EcsNlb-dns'
                  - ':8052'
                  - '/v1/ondemand-industry-api/passenger-transport-subsidy-scheme/complete-journey'
          responses:
            default:
              statusCode: "200"
              responseParameters:
                method.response.header.Access-Control-Allow-Origin: "'*'"
          passthroughBehavior: "when_no_match"
          connectionType: "VPC_LINK"
          connectionId: "${stageVariables.vpcLinkId}"
          httpMethod: "POST"
          type: "http_proxy"
    options:
      responses:
        200:
          description: "200 response"
          headers:
            Access-Control-Allow-Origin:
              schema:
                type: "string"
            Access-Control-Allow-Methods:
              schema:
                type: "string"
            Access-Control-Allow-Headers:
              schema:
                type: "string"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Empty"
      x-amazon-apigateway-integration:
        responses:
          default:
            statusCode: "200"
            responseParameters:
              method.response.header.Access-Control-Allow-Methods: "'POST,OPTIONS'"
              method.response.header.Access-Control-Allow-Headers: "'Content-Type,X-Amz-Date,Authorization,X-Api-Key'"
              method.response.header.Access-Control-Allow-Origin: "'*'"
        passthroughBehavior: "when_no_match"
        requestTemplates:
          application/json: "{\"statusCode\": 200}"
        type: "mock"

  /v1/ondemand-industry-api/passenger-transport-subsidy-scheme/locations:
    post:
      description: Saves locations for a given journey
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SaveLocationPointsRequest'
      responses:
        "200":
          description: 200 response
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/SaveLocationPointsResponse"
          headers:
            Access-Control-Allow-Origin:
              schema:
                type: "string"
        "400":
          description: 400 response - bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/BadRequestResponse"
        "401":
          description: 401 response - Unauthorised, including when the authenticated
            user is not authorised to query online applications for the specified user.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/UnauthorizedErrorResponse"
      security:
        - IndustryPartnerApiAuthorizer:
            - Fn::Sub: "${ResourceServerIdParameter}/ptsssubscription.write"
      x-amazon-apigateway-integration:
          uri:
            "Fn::Join":
                - ''
                - - 'http://'
                  - Fn::ImportValue:
                      Fn::Sub: '${CommonResourcesStackNameParameter}-EcsNlb-dns'
                  - ':8052'
                  - '/v1/ondemand-industry-api/passenger-transport-subsidy-scheme/locations'
          responses:
            default:
              statusCode: "200"
              responseParameters:
                method.response.header.Access-Control-Allow-Origin: "'*'"
          passthroughBehavior: "when_no_match"
          connectionType: "VPC_LINK"
          connectionId: "${stageVariables.vpcLinkId}"
          httpMethod: "POST"
          type: "http_proxy"
    options:
      responses:
        200:
          description: "200 response"
          headers:
            Access-Control-Allow-Origin:
              schema:
                type: "string"
            Access-Control-Allow-Methods:
              schema:
                type: "string"
            Access-Control-Allow-Headers:
              schema:
                type: "string"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Empty"
      x-amazon-apigateway-integration:
        responses:
          default:
            statusCode: "200"
            responseParameters:
              method.response.header.Access-Control-Allow-Methods: "'POST,OPTIONS'"
              method.response.header.Access-Control-Allow-Headers: "'Content-Type,X-Amz-Date,Authorization,X-Api-Key'"
              method.response.header.Access-Control-Allow-Origin: "'*'"
        passthroughBehavior: "when_no_match"
        requestTemplates:
          application/json: "{\"statusCode\": 200}"
        type: "mock"

components:
  securitySchemes:
    IndustryPartnerApiAuthorizer:
      type: apiKey
      name: Authorization
      in: header
      x-amazon-apigateway-authtype: cognito_user_pools
      x-amazon-apigateway-authorizer:
        type: cognito_user_pools
        providerARNs:
          - Fn::Sub: '${UserPoolArnParameter}'
  parameters:
    correlationIdHeader:
      name: X-Correlation-ID
      in: header
      description: The unique identifier of the request
      required: false
      schema:
        type: string
        format: uuid

  schemas:
    Empty:
      type: "object"

    String:
      type: "string"

    # For HelloWorld test method
    ErrorDetail:
      title: ErrorDetail
      type: object
      x-examples:
        example-1:
          id: String
          detail: No actor could be found with the provided details
          code: NOT_FOUND_ACTOR
          source:
            pointer: /application/address
            parameter: customerNumber
      description: The details of an error. Conforming to national API standards.
      properties:
        id:
          type: string
          description: |
            Identifier of the specific error
        detail:
          type: string
          description: A human-readable explanation specific to this occurrence of the problem.
        code:
          type: string
          description: An application-specific error code
        source:
          $ref: '#/components/schemas/ErrorSource'
      required:
        - detail
        - code
    ErrorSource:
      title: ErrorSource
      type: object
      x-examples:
        example-1:
          pointer: /application/address
          parameter: customerNumber
      description: Details of the source of the error
      properties:
        pointer:
          type: string
          description: 'JSON Pointer [RFC6901] to the associated entity in the request document [e.g. "/data" for a primary data object, or "/data/attributes/title" for a specific attribute].'
        parameter:
          type: string
          description: A string indicating which URI query parameter caused the error.
    Error:
      type: array
      title: Error
      description: A collection of errors
      minItems: 1
      items:
        $ref: '#/components/schemas/ErrorDetail'

    UnauthorizedErrorResponse:
      title: UnauthorizedErrorResponse
      type: object
      description: Access token is missing or invalid.
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/ErrorDetailsData"
          description: Access token is missing or invalid.

    BadRequestResponse:
      title: BadRequestResponse
      type: object
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/ErrorDetailsData"
          description: A list of messages indicating why the request was bad.

    ErrorDetailsData:
      title: ErrorDetailsData
      type: object
      description: The details of the error.
      properties:
        fieldName:
          type: string
          description: The identifier name of the field containing the error. Can be 'N/A'.
        message:
          type: string
          description: The error message.

    GetPTDDetailsForDriverResponse:
      title: GetPTDDetailsForDriverResponse
      type: object
      description: Response class which encapsulates the properties which are result of getting ptd details for a driver
      properties:
        driverStatus:
          type: string
          description: indicates whether the driver was found or not
        hrStatus:
          type: string
          description: H and R status of the driver subscribed
        ptdNumber:
          type: integer
          format: int64
          description: The PTD Authorisation number if found else null

    AddDriverSubscriptionResponse:
      title: AddDriverSubscriptionResponse
      type: object
      properties:
        resultStatus:
          type: string
          nullable: false
          minLength: 1
          maxLength: 100
          description: The result of the add driver subscription.
      required:
        - resultStatus

    AddVehicleSubscriptionResponse:
      title: AddVehicleSubscriptionResponse
      type: object
      properties:
        resultStatus:
          type: string
          nullable: false
          minLength: 1
          maxLength: 100
          description: The result of the add vehicle subscription.
      required:
        - resultStatus

    RemoveVehicleSubscriptionResponse:
      title: RemoveVehicleSubscriptionResponse
      type: object
      properties:
        resultStatus:
          type: string
          nullable: false
          minLength: 1
          maxLength: 100
          description: The result of the remove vehicle subscription.
      required:
        - resultStatus

    RemoveDriverSubscriptionResponse:
      title: RemoveDriverSubscriptionResponse
      type: object
      properties:
        resultStatus:
          type: string
          nullable: false
          minLength: 1
          maxLength: 100
          description: The result of the remove driver subscription.
      required:
        - resultStatus

    GetDriverSubscriptionExportContentResponse:
      title: GetDriverSubscriptionExportContentResponse
      type: object
      description: The details of the exports document returned
      properties:
        mimeFileType:
          type: string
        fileType:
          type: string
          nullable: false
          enum:
            - CSV
        content:
          type: string
          format: byte
          nullable: false

    GetVehicleSubscriptionExportContentResponse:
      title: GetVehicleSubscriptionExportContentResponse
      type: object
      description: The details of the export vehicles
      properties:
        mimeFileType:
          type: string
        fileType:
          type: string
          nullable: false
          enum:
            - CSV
        content:
          type: string
          format: byte
          nullable: false

    GetPTVDetailsForVehicleResponse:
      title: GetPTVDetailsForVehicleResponse
      type: object
      description: Response class which encapsulates the properties which are result of getting ptv details for a vehicle
      properties:
        vehicleStatus:
          type: string
          description: indicates whether the vehicle was found or not
        ptvStatus:
          type: string
          description: The PTV status of the vehicles
        ptvDefectStatus:
          type: string
          description: The PTV defect status of the vehicle

    FindSubsidyLevelResponse:
      title: FindSubsidyLevelResponse
      type: object
      properties:
        data:
          $ref: "#/components/schemas/SubsidyLevelData"
      required:
        - data

    ODIPaymentResponse:
      title: ODIPaymentResponse
      type: object
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/ODIPaymentsData"
      required:
        - data

    SubsidyLevelData:
      title: SubsidyLevelData
      type: object
      properties:
        participantStatus:
          type: string
          description: The status of the participant
        code:
          type: string
          maxLength: 30
          description: A short name for this subsidy level
        description:
          type: string
          maxLength: 100
          description: A description of this subsidy level
        percentageWAVWC:
          $ref: '#/components/schemas/Percentage'
        percentageWAVNoWC:
          $ref: '#/components/schemas/Percentage'
        percentageNonWAVWC:
          $ref: '#/components/schemas/Percentage'
        percentageNonWAVNoWC:
          $ref: '#/components/schemas/Percentage'
        subsidyCapWAVWC:
          $ref: '#/components/schemas/SubsidyCapAmount'
        subsidyCapWAVNoWC:
          $ref: '#/components/schemas/SubsidyCapAmount'
        subsidyCapNonWAVWC:
          $ref: '#/components/schemas/SubsidyCapAmount'
        subsidyCapNonWAVNoWC:
          $ref: '#/components/schemas/SubsidyCapAmount'

    ODIPaymentsData:
      title: ODIPaymentsData
      type: object
      properties:
        dotPaymentNumber:
         type: integer
         format: int32
         minimum: 0
         maximum: 9
        remittanceDate:
          $ref: '#/components/schemas/PaymentDate'
        numberOfRecords:
          type: integer
          format: int32
          minimum: 0
          maximum: 99999
        subsidy:
          $ref: '#/components/schemas/Amount'
        coPayment:
          $ref: '#/components/schemas/Amount'
        adjustments :
          $ref: '#/components/schemas/Amount'
        total:
          $ref: '#/components/schemas/Amount'
        bankReference:
          type: string
          minLength: 1
          maxLength: 40

    Percentage:
      type: integer
      format: int32
      minimum: 0
      maximum: 100

    SubsidyCapAmount:
      type: integer
      format: int32
      minimum: 0
      maximum: 99999

    ParticipantNumber:
      type: integer
      format: int32
      description: When a customer is granted their first PTSS application, a participant number is allocated.
      minimum: 1
      maximum: 9999999

    ParticipantCardNumber:
      type: string
      minLength: 10
      maxLength: 10
      format: regex
      description: The number allocated to a participants card.
      pattern: '^P[123]\d{8}$'
      example: "P155555555"

    ParticipantCardExpiryDate:
      type: string
      format: date
      description: The date of the card expiry
      example: '2023-02-18'

    PaymentDate:
      type: string
      format: date
      description: The date of the payment
      example: '2023-02-18'

    Surname:
      type: string
      minLength: 1
      maxLength: 40
      description: Surname of the person associated with the record.
      pattern: "^[a-zA-Z0-9-`' ]*$"
      example: 'Parker'

    WheelchairCarriedFlag:
      type: boolean
      description: A flag to indicate that the participant travelled with a wheelchair.
      example: true

    Distance:
      type: integer
      format: int32
      maximum: 999999
      description: The distance travelled for the journey in metres
      example: '170000'

    Amount:
      type: integer
      format: int32
      maximum: 999999
      description: The money amount in cents
      example: '999999'

    PercentageAmount:
      type: string
      format: regex
      pattern: '^\d{1,3}\.?\d{0,2}'
      x-pattern-message: "Invalid Percentage Amount format"
      example: '100.00'

    StartJourneyRequest:
      title: StartJourneyRequest
      description: The request to start a journey for a participant
      type: object
      properties:
        bookingId:
          $ref: '#/components/schemas/BookingId'
        bookingServiceAuthorisationNumber:
          $ref: '#/components/schemas/BookingServiceAuthorisationNumber'
        ptdNumber:
          $ref: '#/components/schemas/PTDNumber'
        plateNumber:
          $ref: '#/components/schemas/PlateNumber'
        participantNumber:
          $ref: '#/components/schemas/ParticipantNumber'
        participantCardNumber:
          $ref: '#/components/schemas/ParticipantCardNumber'
        participantCardExpiryDate:
            $ref: '#/components/schemas/ParticipantCardExpiryDate'
        pickupDateTime:
          $ref: '#/components/schemas/OffsetDateTime'
        pickupLatitude:
          $ref: '#/components/schemas/LatLongConstraint'
        pickupLongitude:
          $ref: '#/components/schemas/LatLongConstraint'
      required:
        - bookingId
        - bookingServiceAuthorisationNumber
        - ptdNumber
        - plateNumber
        - participantNumber
        - participantCardNumber
        - participantCardExpiryDate
        - pickupDateTime
        - pickupLatitude
        - pickupLongitude

    StartJourneyResponse:
      title: StartJourneyResponse
      description: The response to starting a journey for a participant
      type: object
      properties:
        data:
          $ref: "#/components/schemas/StartJourneyResponseData"        
      required:
        - data

    StartJourneyResponseData:
      title: StartJourneyResponseData
      description: The data of the response to starting a journey for a participant
      type: object
      properties:
        externalJourneyReferenceId:
          $ref: '#/components/schemas/ExternalJourneyReferenceId'
      required:
        - externalJourneyReferenceId

    CompleteJourneyRequest:
      title: CompleteJourneyRequest
      description: The request to complete a journey for a primary participant
      type: object
      properties:
        externalJourneyReferenceId:
          $ref: '#/components/schemas/ExternalJourneyReferenceId'
          description: The journey reference ID returned by the API service StartJourney
        dropOffDateTime:
          $ref: '#/components/schemas/OffsetDateTime'
          description: Date and time the journey ended
        dropOffLatitude:
          $ref: '#/components/schemas/LatLongConstraint'
          description: Latitude reading of GPS at the end of journey
        dropOffLongitude:
          $ref: '#/components/schemas/LatLongConstraint'
          description: Longitude reading of GPS at the end of journey
        wheelchairCarriedFlag:
          $ref: '#/components/schemas/WheelchairCarriedFlag'
          description: A flag to indicate that the participant travelled with a wheelchair
        distance:
          $ref: '#/components/schemas/Distance'
          description: The distance traveled for the journey in meters
        totalFare:
          $ref: '#/components/schemas/Amount'
          description: The total fare charged for the journey in cents
        passengerPaymentAmount:
          $ref: '#/components/schemas/Amount'
          description: The amount of the total fare in cents that the passenger is required to pay. This is the value claimed
        subsidyAmountClaimed:
          $ref: '#/components/schemas/Amount'
          description: The amount of the subsidy claimed for the trip in cents. This is the value claimed
        subsidyPercentageClaimed:
          $ref: '#/components/schemas/PercentageAmount'
          description: The subsidy percentage that was used to calculate the subsidy amount
        subsidyCapClaimed:
          $ref: '#/components/schemas/SubsidyCapAmount'
          description: The subsidy cap in cents that was used to calculate the subsidy amount
        additionalParticipants:
          type: array
          items:
            $ref: "#/components/schemas/AdditionalParticipantData"
          description: Additional participants
      required:
        - externalJourneyReferenceId
        - dropOffDateTime
        - dropOffLatitude
        - dropOffLongitude
        - distance
        - totalFare
        - passengerPaymentAmount
        - subsidyAmountClaimed
        - subsidyPercentageClaimed
        - subsidyCapClaimed

    AdditionalParticipantData:
      title: AdditionalParticipantData
      type: object
      description: The PTSS participant details of the additional passenger who undertook the journey. A journey can have an additional PTSS participant
      properties:
        participantNumber:
          $ref: '#/components/schemas/ParticipantNumber'
          description: The PTSS participant number of the additional passenger who undertook the journey
        participantCardNumber:
          $ref: '#/components/schemas/ParticipantCardNumber'
          description: Card number presented by the additional passenger
        participantCardExpiryDate:
          $ref: '#/components/schemas/ParticipantCardExpiryDate'
          description: Card expiry date of the additional participant card used on the journey
        pickupDateTime:
          $ref: '#/components/schemas/OffsetDateTime'
          description: Date and time the journey commenced for this participant
        pickupLatitude:
          $ref: '#/components/schemas/LatLongConstraint'
          description: Latitude reading of GPS at the commencement of journey
        pickupLongitude:
          $ref: '#/components/schemas/LatLongConstraint'
          description: Longitude reading of GPS at the commencement of journey
        dropOffDateTime:
          $ref: '#/components/schemas/OffsetDateTime'
          description: Date and time the journey ended for this participant
        dropOffLatitude:
          $ref: '#/components/schemas/LatLongConstraint'
          description: Latitude reading of GPS at the end of journey
        dropOffLongitude:
          $ref: '#/components/schemas/LatLongConstraint'
          description: Longitude reading of GPS at the end of journey
        wheelchairCarriedFlag:
          $ref: '#/components/schemas/WheelchairCarriedFlag'
          description: A flag to indicate that the participant travelled with a wheelchair
        distance:
          $ref: '#/components/schemas/Distance'
          description: The distance travelled for the journey in metres
        totalFare:
          $ref: '#/components/schemas/Amount'
          description: The total fare charged for the journey in cents
        passengerPaymentAmount:
          $ref: '#/components/schemas/Amount'
          description: The amount of the total fare in cents that the passenger is required to pay. This is the value claimed
        subsidyAmountClaimed:
          $ref: '#/components/schemas/Amount'
          description: The amount of the subsidy claimed for the trip in cents. This is the value claimed
        subsidyPercentageClaimed:
          $ref: '#/components/schemas/PercentageAmount'
          description: The subsidy percentage that was used to calculate the subsidy amount
        subsidyCapClaimed:
          $ref: '#/components/schemas/SubsidyCapAmount'
          description: The subsidy cap in cents that was used to calculate the subsidy amount
      required:
        - participantNumber
        - participantCardNumber
        - participantCardExpiryDate
        - pickupDateTime
        - pickupLatitude
        - pickupLongitude
        - dropOffDateTime
        - dropOffLatitude
        - dropOffLongitude
        - distance
        - totalFare
        - passengerPaymentAmount
        - subsidyAmountClaimed

    SaveLocationPointsRequest:
      title: SaveLocationPointsRequest
      description: The request to save locations for a journey
      type: object
      properties:
        externalJourneyReferenceId:
          $ref: '#/components/schemas/ExternalJourneyReferenceId'
        finalLocationDetails:
          type: boolean
          description: A flag to indicate if this is the last set of location details for this journey
        locationPoints:
          description: list of location points to be saved for the journey.
          type: array
          items:
            $ref: "#/components/schemas/LocationPointData"
      required:
        - externalJourneyReferenceId
        - finalLocationDetails
        - locationPoints

    LocationPointData:
      title: LocationPointData
      description: Details of the location
      type: object
      properties:
        latitude:
          $ref: '#/components/schemas/LatLongConstraint'
        longitude:
          $ref: '#/components/schemas/LatLongConstraint'
        locationDeterminedTime:
          $ref: '#/components/schemas/OffsetDateTime'
        horizontalAccuracyMeters:
          $ref: '#/components/schemas/PrecisionEightScaleFour'
        altitudeMeters:
          $ref: '#/components/schemas/PrecisionEightScaleFour'
        verticalAccuracyMeters:
          $ref: '#/components/schemas/PrecisionEightScaleFour'
        speedMeterPerSecond:
          $ref: '#/components/schemas/PrecisionEightScaleFour'
        speedAccuracyMeterPerSecond:
          $ref: '#/components/schemas/PrecisionEightScaleFour'
        bearingDegrees:
          $ref: '#/components/schemas/PrecisionEightScaleFour'
        bearingAccuracyDegrees:
          $ref: '#/components/schemas/PrecisionEightScaleFour'
      required:
        - latitude
        - logitude
        - locationDeterminedTime

    SaveLocationPointsResponse:
      title: SaveLocationPointsResponse
      description: The response after saving location points
      type: object
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/SaveLocationPointsResponseData"
      required:
        - data

    SaveLocationPointsResponseData:
      title: SaveLocationPointsResponseData
      description: The data of the response after saving locations
      type: object
      properties:
        locationDeterminedTime:
          $ref: '#/components/schemas/OffsetDateTime'
        locationReferenceNumber:
          $ref: '#/components/schemas/LocationReferenceNumber'
      required:
        - locationDeterminedTime
        - locationReferenceNumber

    BookingId:
      type: string
      minLength: 1
      maxLength: 50
      description: The unique identifier of the booking
      example: '123456'

    BookingServiceAuthorisationNumber:
      type: number
      format: int64
      description: The unique identifier of the booking service authorisation number
      example: 12345678901234567890
      maximum: 99999999999999999999

    PTDNumber:
      type: number
      format: int32
      description: The unique identifier of the PTD number
      example: 1234567
      maximum: 9999999

    PlateNumber:
      type: string
      minLength: 1
      maxLength: 12
      description: The unique identifier of the plate number
      example: '1ABC777'

    ExternalJourneyReferenceId:
      type: string
      format: uuid
      description: The unique identifier of the external journey reference
      example: '123e4567-e89b-12d3-a456-426614174000'

    OffsetDateTime:
      type: string
      format: offset-date-time
      description: The date and time of the journey
      example: '2023-02-18T12:05:26+08:00'

    LatLongConstraint:
      type: string
      format: regex
      pattern: '^-?\d{1,3}\.\d{5,10}$'
      example: '123.1234567890'
      description: The latitude and longitude of the journey

    PrecisionEightScaleFour:
      type: string
      format: regex
      pattern: '^\d{0,4}(\.\d{0,4})?$'
      x-pattern-message: "Numeric with 4 digits and 4 decimals is only accepted"

    LocationReferenceNumber:
      type: number
      format: int64
      description: The unique identifier of the PTD number
      example: 1234567
