openapi: 3.0.1
info:
  title: Bozen Parking Service
  description: |
    API that allows Parking System providers to integrate with the Bozen Ticketing system.

    This integration allows 
    [Südtirol Pass](https://www.suedtirolmobil.info/en/tickets/ticket-finder/suedtirol-pass) 
    (SPASS) owners to park a car on supported parking lots and pay with the SPASS. When using
    public transport at a nearby station the parking fee might even be discounted.

    ## Common Flows
    The following scenarios describe common sequences of steps for using a parking with a
    SPASS:
    ### Südtirol Pass only
    This describes the *'happy path'* of using a parking via the Südtirol Pass and paying via it.
    1. Car approaches the gate of a supported parking.
    2. Driver presents the SPASS at a smartcard reader of the gate:
        1. The parking system sends a request to the 'access' endpoint of the Ticketing system.
        2. The Ticketing system responds whether the SPASS is valid to be used for parking usage
        and payment.
    3. On successful response the gate opens.
    4. The car passes the gate and the gate registers this:
        1. The parking system sends a request to the 'entry' endpoint of the Ticketing system.
        2. The Ticketing system records the begin of a parking transaction and returns a
        transaction ID.
        3. The parking system saves the transaction ID for later usage.
    5. A while later the driver wants to leave and approaches an exit gate.
    6. Driver presents the SPASS at a smartcard reader of the gate:
        1. The parking system sends a request to the 'exit' endpoint of the Ticketing system.
        Apart other details, this includes the transaction ID and the regular parking fee
        calculated by the parking system.
        2. The Ticketing system records the end of the parking transaction.
    7. The gate opens and the car leaves.
    8. After the parking transaction is closed, the Ticketing system calculates and charges
      the actual price for the parking, including discounts. Starting point is the regular
      parking fee that the parking system provided.

    ### License Plate Scanning
    This describes the *'happy path'* of using a parking by scanning a license plate,
    resolving it to a Südtirol Pass and paying via the pass.
    1. Car approaches the gate of a supported parking.
    2. The gate scans the license plate and attemps to resolve it:
        1. The parking system sends a request to the 'plate number resolve' endpoint of
        the Ticketing system.
        2. The Ticketing system checks whether a SPASS is configured for this license plate
        and whether it is valid to be used for parking usage and payment. It returns the
        SPASS's UID.
    3. On successful response the gate opens.
    4. The car passes the gate and the gate registers this: It sends the same request as
    in the flow above on entry.
    5. A while later the driver wants to leave, approaches an exit gate and the gate scans
    the license plate.
    6. With the scanned license plate the parking system has two options:
        * The parking system saved the mapping between license plate and SPASS UID before
          and reuses the UID. (**recommended!**)
        * The parking system sends a request to the 'plate number resolve' endpoint of the
          Ticketing system. The Ticketing system resolves the license plate again (and checks
          the validity again) and returns it. **Note**: This might result in a different
          response than before as the SPASS account might have been changed. If the parking
          system chooses to use this option, it must take care of this scenario.
    7. The parking system proceeds as described above in the other example: It opens the gate
      and sends the 'exit' request to the Ticketing system.
    8. After the parking transaction is closed, the Ticketing system calculates and charges
      the actual price for the parking, including discounts. Starting point is the regular
      parking fee that the parking system provided.

  contact:
    email: ptcibo@scheidt-bachmann.sk
  version: v1
servers:
  - url: https://boz-fat-qa-api.fare-collection-systems.com:30563
    description: Test environment for external integration tests  
tags:
  - name: Parking
paths:
  /parking/api/v1/{ticket_id}/exit:
    post:
      tags:
        - Parking
      summary: API-810101 - Inform Ticketing system about a car leaving the parking lot 
      security:
        - OAuthAuthorization:
            - parking
      description: |-
        Via this endpoint a parking system informs the Ticketing system about the end of
        the parking usage and the final price. The caller refers to a previous entry
        to the parking via the transaction ID that was returned by the Ticketing system
        on entry.

        Call this endpoint when a car leaves the parking lot and the parking fee has been calculated.
        In case of a successful response, the caller can assume that the payment will be handled
        by the Ticketing system. **Note**: After the call succeeded for a transaction ID,
        any subsequent call for the same ID will fail.
        
        If the call doesn't succeed, it's in the responsibility of
        the caller to deal with the situation (retry later, ask driver to pay with other
        payment method, accept loss of payment, etc).
      operationId: exit_1
      parameters:
        - name: ticket_id
          $ref: '#/components/parameters/ticket_id'
      requestBody:
        description: Details of the parking transaction, such as entry (optional), exit and the
          regular costs for this parking event.
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ExitRequest'
            examples:
              Minimal-Example:
                value:
                  location:
                    parking_system_id: "99999"
                    parking_location_id: "o23p01"
                    parking_area_id: "A1"
                  transaction_id: 5593aeeb-1d45-4d39-95a4-dcdccb312345
                  exit_time: '2023-11-03T15:50:21.9082054+01:00'
                  exit_gate: '9'
                  normal_fare_cost: 25.6
              Full-Example:
                value:
                  location:
                    parking_system_id: "99999"
                    parking_location_id: "o23p01"
                    parking_area_id: "A1"
                  transaction_id: 5593aeeb-1d45-4d39-95a4-dcdccb312346
                  entry_time: '2023-11-02T15:50:21.9082054+01:00'
                  entry_gate: 'g4'
                  exit_time: '2023-11-03T15:50:21.9082054+01:00'
                  exit_gate: 'g9'
                  normal_fare_cost: 10.0
        required: true
      responses:
        '200':
          description: |
            Success

            The parking transaction was recorded as 'ended' by the Ticketing system.
            The caller can now be sure that the payment will be handled by the
            Ticketing system.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EmptyJsonResponse'
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                code: 1401
                message: 'Some message (cause: another message in detail) (referenceId: f6ada619-fd8d-4dae-81a1-f622a263ca05)'
                errorMessage:
                  referenceId: f6ada619-fd8d-4dae-81a1-f622a263ca05
                  message: 'Some message (cause: another message in detail)'
                businessExceptions:
                  - code: PSSTA1401
                    message: Account Provider processing error
                fieldValidations: []
        '401':
          description: Authentication required.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                code: 1401
                message: 'Some message (cause: another message in detail) (referenceId: f6ada619-fd8d-4dae-81a1-f622a263ca05)'
                errorMessage:
                  referenceId: f6ada619-fd8d-4dae-81a1-f622a263ca05
                  message: 'Some message (cause: another message in detail)'
                businessExceptions:
                  - code: PSSTA1401
                    message: Account Provider processing error
                fieldValidations: []
        '403':
          description: Forbidden.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                code: 1401
                message: 'Some message (cause: another message in detail) (referenceId: f6ada619-fd8d-4dae-81a1-f622a263ca05)'
                errorMessage:
                  referenceId: f6ada619-fd8d-4dae-81a1-f622a263ca05
                  message: 'Some message (cause: another message in detail)'
                businessExceptions:
                  - code: PSSTA1401
                    message: Account Provider processing error
                fieldValidations: []
        '404':
          description: |-
            Not found

            No matching SPASS was found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                code: 1701
                message: 'Card not found (referenceId: f6ada619-fd8d-4dae-81a1-f622a263ca05)'
                errorMessage:
                  referenceId: f6ada619-fd8d-4dae-81a1-f622a263ca05
                  message: 'Card not found'
                businessExceptions:
                  - code: PSSTA1701
                    message: Card not found
                fieldValidations: []
        '406':
          description: |-
            Not acceptable / The customer (AltoAdige Pass) is not allowed to enter the
            parking lot 
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                code: 1401
                message: 'Some message (cause: another message in detail) (referenceId: f6ada619-fd8d-4dae-81a1-f622a263ca05)'
                errorMessage:
                  referenceId: f6ada619-fd8d-4dae-81a1-f622a263ca05
                  message: 'Some message (cause: another message in detail)'
                businessExceptions:
                  - code: PSSTA1401
                    message: Account Provider processing error
                fieldValidations: []
        '500':
          description: Internal server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                code: 1401
                message: 'Some message (cause: another message in detail) (referenceId: f6ada619-fd8d-4dae-81a1-f622a263ca05)'
                errorMessage:
                  referenceId: f6ada619-fd8d-4dae-81a1-f622a263ca05
                  message: 'Some message (cause: another message in detail)'
                businessExceptions:
                  - code: PSSTA1401
                    message: Account Provider processing error
                fieldValidations: []
  /parking/api/v1/{ticket_id}/entry:
    post:
      tags:
        - Parking
      summary: API-810201 - Inform Ticketing system about a car entering the parking lot
      security:
        - OAuthAuthorization:
            - parking
      description: |-
        Via this endpoint a parking system informs the Ticketing system about the start of
        the parking usage.

        Call this endpoint when a car has entered the parking lot as it starts a new
        transaction directly. The unique ID for this transaction is part of the success
        response and is to be saved until the transaction is closed (via an 'exit' request).

        **Note**: Make sure to verify the validitiy of the Südtirol Pass first, either
        via an 'access' request or while resolving a license plate.

        **Note**: If the request fails (not a 200 response), then the transaction was
        *not* started and its the responsibility of the caller to handle this situation.
        The Ticketing system will not be able to charge any payment without such a
        successful start of the parking transaction.
      operationId: entry_1
      parameters:
        - name: ticket_id
          $ref: '#/components/parameters/ticket_id'
      requestBody:
        description: Details of for new parking transaction (entry time, etc).
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/EntryRequest'
        required: true
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EntryResponse'
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                code: 1401
                message: 'Some message (cause: another message in detail) (referenceId: f6ada619-fd8d-4dae-81a1-f622a263ca05)'
                errorMessage:
                  referenceId: f6ada619-fd8d-4dae-81a1-f622a263ca05
                  message: 'Some message (cause: another message in detail)'
                businessExceptions:
                  - code: PSSTA1401
                    message: Account Provider processing error
                fieldValidations: []
        '401':
          description: Authentication required.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                code: 1401
                message: 'Some message (cause: another message in detail) (referenceId: f6ada619-fd8d-4dae-81a1-f622a263ca05)'
                errorMessage:
                  referenceId: f6ada619-fd8d-4dae-81a1-f622a263ca05
                  message: 'Some message (cause: another message in detail)'
                businessExceptions:
                  - code: PSSTA1401
                    message: Account Provider processing error
                fieldValidations: []
        '403':
          description: Forbidden.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                code: 1401
                message: 'Some message (cause: another message in detail) (referenceId: f6ada619-fd8d-4dae-81a1-f622a263ca05)'
                errorMessage:
                  referenceId: f6ada619-fd8d-4dae-81a1-f622a263ca05
                  message: 'Some message (cause: another message in detail)'
                businessExceptions:
                  - code: PSSTA1401
                    message: Account Provider processing error
                fieldValidations: []
        '404':
          description: |-
            Not found

            No matching SPASS was found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                code: 1701
                message: 'Card not found (referenceId: f6ada619-fd8d-4dae-81a1-f622a263ca05)'
                errorMessage:
                  referenceId: f6ada619-fd8d-4dae-81a1-f622a263ca05
                  message: 'Card not found'
                businessExceptions:
                  - code: PSSTA1701
                    message: Card not found
                fieldValidations: []
        '406':
          description: |-
            **This response is to be removed! We don't want to check the validity
            (again) during the 'entry' call.**

            Not acceptable / The customer (AltoAdige Pass) is not allowed to enter the
            parking lot 
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                code: 1401
                message: 'Some message (cause: another message in detail) (referenceId: f6ada619-fd8d-4dae-81a1-f622a263ca05)'
                errorMessage:
                  referenceId: f6ada619-fd8d-4dae-81a1-f622a263ca05
                  message: 'Some message (cause: another message in detail)'
                businessExceptions:
                  - code: PSSTA1401
                    message: Account Provider processing error
                fieldValidations: []
        '500':
          description: Internal server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                code: 1401
                message: 'Some message (cause: another message in detail) (referenceId: f6ada619-fd8d-4dae-81a1-f622a263ca05)'
                errorMessage:
                  referenceId: f6ada619-fd8d-4dae-81a1-f622a263ca05
                  message: 'Some message (cause: another message in detail)'
                businessExceptions:
                  - code: PSSTA1401
                    message: Account Provider processing error
                fieldValidations: []
  /parking/api/v1/{plate_number}/UID:
    get:
      tags:
        - Parking
      summary: API-810401 -  Resolve a license plate to a Südtirol Pass ID
      security:
        - OAuthAuthorization:
            - parking
      description: |-
        This endpoint looks for a Südtirol Pass that has the given license
        plate assigned to it. If such a SPASS is found, its UID is returned
        and can be used for subsequent 'access', 'entry' or 'exit' requests.

        Scenario that this endpoint is intended for: A car approaches a gate,
        the gate scans its license plate and resolves the plate to a
        Südtirol Pass UID. Afterwards the gate can decide to open or not by
        using this UID and the driver doesn't need to present the physical
        pass at the gate's smartcard reader.

        **Note**: The endpoint also checks whether the found Südtirol Pass
        is valid to be used for parking purposes, i.e. for parking payments.
        A successful response means, that a Südtirol Pass is assigned for
        this license plate and it is valid for parking payments.
        This allows you to skip the 'access' request in such a case.

        Common responses:
        * 200 - Success: SPASS found and it's valid for parking
        * 404 - Not found: No appropriate license plate & SPASS combination found. Can have several reasons.
        * 406 - Not acceptable: A SPASS was found but it's not valid for parking payments. Can have several reasons.
      operationId: getUUIDforTicketNumber
      parameters:
        - name: plate_number
          in: path
          description: License plate string
          required: true
          schema:
            type: string
          example: 'AB 123CD'
      responses:
        '200':
          description: |-
            Success

            For this license plate a Südtirol Pass assignment was found for
            parking purposes and it may be used for parking payments.

            **Note**: The endpoint also checks whether the found Südtirol Pass
            is valid to be used for parking purposes, i.e. for parking payments.
            A successful response means, that a Südtirol Pass is assigned for
            this license plate and it is valid for parking payments.
            This allows you to skip the 'access' request in such a case.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UUIDForTicketNumberResponse'
              example:
                uuid: 447442bad42a80
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                code: 1401
                message: 'Some message (cause: another message in detail) (referenceId: f6ada619-fd8d-4dae-81a1-f622a263ca05)'
                errorMessage:
                  referenceId: f6ada619-fd8d-4dae-81a1-f622a263ca05
                  message: 'Some message (cause: another message in detail)'
                businessExceptions:
                  - code: PSSTA1401
                    message: Account Provider processing error
                fieldValidations: []
        '401':
          description: Authentication required
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                code: 1401
                message: 'Some message (cause: another message in detail) (referenceId: f6ada619-fd8d-4dae-81a1-f622a263ca05)'
                errorMessage:
                  referenceId: f6ada619-fd8d-4dae-81a1-f622a263ca05
                  message: 'Some message (cause: another message in detail)'
                businessExceptions:
                  - code: PSSTA1401
                    message: Account Provider processing error
                fieldValidations: []
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                code: 1401
                message: 'Some message (cause: another message in detail) (referenceId: f6ada619-fd8d-4dae-81a1-f622a263ca05)'
                errorMessage:
                  referenceId: f6ada619-fd8d-4dae-81a1-f622a263ca05
                  message: 'Some message (cause: another message in detail)'
                businessExceptions:
                  - code: PSSTA1401
                    message: Account Provider processing error
                fieldValidations: []
        '404':
          description: |-
            Not found

            No appropriate license plate assignment or SPASS was found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                code: 1511
                message: 'Plate number not assigned to account (referenceId: f6ada619-fd8d-4dae-81a1-f622a263ca05)'
                errorMessage:
                  referenceId: f6ada619-fd8d-4dae-81a1-f622a263ca05
                  message: 'Plate number not assigned to account'
                businessExceptions:
                  - code: PSSTA1511
                    message: Plate number AB-1234 not assigned to transit account!
                fieldValidations: []
        '406':
          description: |-
            Not acceptable
            
            The Südtirol Pass is not allowed to used for parking payments. 
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                code: 1402
                message: 'Not acceptable / The customer (AltoAdige Pass) is not allowed to enter the parking lot due to ... (referenceId: f6ada619-fd8d-4dae-81a1-f622a263ca05)'
                errorMessage:
                  referenceId: f6ada619-fd8d-4dae-81a1-f622a263ca05
                  message: 'Not acceptable / The customer (AltoAdige Pass) is not allowed to enter the parking lot due to ...'
                businessExceptions:
                  - code: PSSTA1402
                    message: Not acceptable / The customer (AltoAdige Pass) is not allowed to enter the parking lot due to ...
                fieldValidations: []
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                code: 1401
                message: 'Some message (cause: another message in detail) (referenceId: f6ada619-fd8d-4dae-81a1-f622a263ca05)'
                errorMessage:
                  referenceId: f6ada619-fd8d-4dae-81a1-f622a263ca05
                  message: 'Some message (cause: another message in detail)'
                businessExceptions:
                  - code: PSSTA1401
                    message: Account Provider processing error
                fieldValidations: []
  /parking/api/v1/{ticket_id}/access:
    get:
      tags:
        - Parking
      summary: API-810301 - Check validity of a Südtirol Pass for parking payments
      security:
        - OAuthAuthorization:
            - parking
      description: |-
        This endpoint checks the validitiy of a SPASS for parking payments.
        
        This involves checks of multiple aspects, such as active/blocked, registered
        payment method, etc.

        **Note**: For several reasons the 'entry' and 'exit' endpoints don't check
        the validitiy. Therefore, it's the responsibility of the parking system to
        first check the validitiy of a SPASS before granting access to the parking.

        Common responses:
        * 200 - Success: SPASS found and it's valid for parking
        * 404 - Not found: No matching SPASS found. Can have several reasons.
        * 406 - Not acceptable: A SPASS was found but it's not valid for parking payments. Can have several reasons.
      operationId: accessVerification_1
      parameters:
        - name: ticket_id
          $ref: '#/components/parameters/ticket_id'
      responses:
        '200':
          description: |-
            Success

            This Südtirol Pass may be used for parking purposes.
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                code: 1401
                message: 'Some message (cause: another message in detail) (referenceId: f6ada619-fd8d-4dae-81a1-f622a263ca05)'
                errorMessage:
                  referenceId: f6ada619-fd8d-4dae-81a1-f622a263ca05
                  message: 'Some message (cause: another message in detail)'
                businessExceptions:
                  - code: PSSTA1401
                    message: Account Provider processing error
                fieldValidations: []
        '401':
          description: Authentication required.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                code: 1401
                message: 'Some message (cause: another message in detail) (referenceId: f6ada619-fd8d-4dae-81a1-f622a263ca05)'
                errorMessage:
                  referenceId: f6ada619-fd8d-4dae-81a1-f622a263ca05
                  message: 'Some message (cause: another message in detail)'
                businessExceptions:
                  - code: PSSTA1401
                    message: Account Provider processing error
                fieldValidations: []
        '403':
          description: Forbidden.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                code: 1401
                message: 'Some message (cause: another message in detail) (referenceId: f6ada619-fd8d-4dae-81a1-f622a263ca05)'
                errorMessage:
                  referenceId: f6ada619-fd8d-4dae-81a1-f622a263ca05
                  message: 'Some message (cause: another message in detail)'
                businessExceptions:
                  - code: PSSTA1401
                    message: Account Provider processing error
                fieldValidations: []
        '404':
          description: |-
            Not found

            No matching SPASS was found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                code: 1701
                message: 'Card not found (referenceId: f6ada619-fd8d-4dae-81a1-f622a263ca05)'
                errorMessage:
                  referenceId: f6ada619-fd8d-4dae-81a1-f622a263ca05
                  message: 'Card not found'
                businessExceptions:
                  - code: PSSTA1701
                    message: Card not found
                fieldValidations: []
        '406':
          description: |-
            Not acceptable
            
            The Südtirol Pass is not allowed to used for parking payments. 
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                code: 1402
                message: 'Not acceptable / The customer (AltoAdige Pass) is not allowed to enter the parking lot due to ... (referenceId: f6ada619-fd8d-4dae-81a1-f622a263ca05)'
                errorMessage:
                  referenceId: f6ada619-fd8d-4dae-81a1-f622a263ca05
                  message: 'Not acceptable / The customer (AltoAdige Pass) is not allowed to enter the parking lot due to ...'
                businessExceptions:
                  - code: PSSTA1402
                    message: Not acceptable / The customer (AltoAdige Pass) is not allowed to enter the parking lot due to ...
                fieldValidations: []
        '500':
          description: Internal server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                code: 1401
                message: 'Some message (cause: another message in detail) (referenceId: f6ada619-fd8d-4dae-81a1-f622a263ca05)'
                errorMessage:
                  referenceId: f6ada619-fd8d-4dae-81a1-f622a263ca05
                  message: 'Some message (cause: another message in detail)'
                businessExceptions:
                  - code: PSSTA1401
                    message: Account Provider processing error
                fieldValidations: []
  /parking/api/v1/open_transactions:
    get:
      tags:
        - Parking
      summary: API-810501 - List open transactions for a parking lot (currently NOT SUPPORTED)
      security:
        - OAuthAuthorization:
            - parking
      description: |-
        **This endpoint is currently NOT supported!**

        Will always answer with response code 501 - Not supported / Not implemented.
      operationId: listOpenTransactions_1
      responses:
        '501':
          description: Not supported / Not implemented

components:
  schemas:

    # ###########################
    # Exit request + response
    # ###########################
    ExitRequest:
      required:
        - location
        - exit_gate
        - exit_time
        - transaction_id
      type: object
      properties:
        location:
          $ref: '#/components/schemas/ParkingLocation'
        transaction_id:
          type: string
          description: |-
            The UID assigned to this parking transaction by the Ticketing system.
            This ID is returned via the 'entry' endpoint when the parking starts.
          example: 5593aeeb-1d45-4d39-95a4-dcdccb312346
        entry_time:
          type: string
          description: |-
            The date and time when entering the parking, in ISO_8601 format
            with timezone (format: yyyy-MM-dd'T'HH:mm:ss.SSSSSSSXXX).

            Optional field: In regular use cases this can be ommitted.
          format: date-time
          example: '2022-01-01 12:00:00'
        entry_gate:
          type: string
          description: |-
            An identifier for the gate that was used for entering the parking.
            Can be chosen by the parking provider.
            Recommendation is that this ID is unique for a parking location or
            parking area. The ID might be used for error analysis and alike.

            Optional field: In regular use cases this can be ommitted.
          example: 'g4'
        exit_time:
          type: string
          description: |-
            The date and time when leaving the parking, in ISO_8601 format
            with timezone (format: yyyy-MM-dd'T'HH:mm:ss.SSSSSSSXXX).
          format: date-time
          example: '2023-11-03T15:50:21.9082054+01:00'
        exit_gate:
          type: string
          description: |-
            An identifier for the gate that was used for leaving the parking.
            Can be chosen by the parking provider.
            Recommendation is that this ID is unique for a parking location or
            parking area. The ID might be used for error analysis and alike.
          example: 'g9'
        normal_fare_cost:
          type: number
          description: |-
            The regular cost due for the usage of the parking lot, in EUR.

            Discounts for Südtirol Pass owners (or public transport usage) are
            not to be applied to this price. This type of discounting will be
            handled by the Ticketing system.
          example: 25.6

    # ###########################
    # Errors
    # ###########################
    BusinessExceptionDetail:
      type: object
      properties:
        code:
          type: string
          example: PSSTAXXXX
        message:
          type: string
          example: Error message

    ErrorMessage:
      type: object
      properties:
        referenceId:
          type: string
          example: 5153c9b9-151d-47e5-93ef-a67ac8660000
        message:
          type: string
          example: 'Error message (cause: Cause of this error if available)'

    ErrorResponse:
      required:
        - businessExceptions
        - errorMessage
        - fieldValidations
      type: object
      properties:
        code:
          type: integer
          format: int32
        message:
          type: string
          example: String
        errorMessage:
          $ref: '#/components/schemas/ErrorMessage'
        businessExceptions:
          type: array
          items:
            $ref: '#/components/schemas/BusinessExceptionDetail'
        fieldValidations:
          type: array
          items:
            $ref: '#/components/schemas/FieldValidation'

    FieldValidation:
      type: object
      properties:
        field:
          type: string
          example: Field name
        message:
          type: string
          example: Reason why field validation failed
    EmptyJsonResponse:
      type: object

    # ###########################
    # Entry request + response
    # ###########################
    EntryRequest:
      required:
        - location
        - entry_gate
        - entry_time
      type: object
      properties:
        location:
          $ref: '#/components/schemas/ParkingLocation'
        entry_time:
          type: string
          description: |-
            The date and time when entering the parking, in ISO_8601 format
            with timezone (format: yyyy-MM-dd'T'HH:mm:ss.SSSSSSSXXX).
          example: '2023-11-03T15:50:21.9082054+01:00'
        entry_gate:
          type: string
          description: |-
            An identifier for the gate that was used for entering the parking.
            Can be chosen by the parking provider.
            Recommendation is that this ID is unique for a parking location or
            parking area. The ID might be used for error analysis and alike.
          example: 'gate-4'

    EntryResponse:
      type: object
      properties:
        transaction_id:
          type: string
          description: |-
            Unique ID for the parking transaction

            This ID is generated by the Ticketing system and uniquely
            identifies the parking transaction that was started by this
            'entry' request.

            To close the transaction later, this ID must be passed to the
            Ticketing system with the 'exit' request.
          example: 5593aeeb-1d45-4d39-95a4-dcdccb3a1aea

    # #################################
    # License plate response
    # #################################
    UUIDForTicketNumberResponse:
      type: object
      properties:
        uuid:
          type: string
          description: |-
            The UID of the Südtirol Pass that the license plate is assigned transaction.
            It can be used for upcoming 'access', 'entry' or 'exit' requests.

    # ###########################
    # Parking Location
    # ###########################
    ParkingLocation:
      type: object
      required:
        - parking_system_id
        - parking_location_id
        - parking_area_id
      properties:
        parking_system_id:
          type: string
          description: The parking lot's hardware/software system.
            This ID is handed out by S&B and it is unique in the ticketing system.
          example: '99999'
        parking_location_id:
          type: string
          description: The ID of an individual parking lot location, which can consist of multiple areas
            or individual parking lots. The ID is set by the parking system and must be unique within
            the parking system. It is unique in the ticketing system only in combination with the parking_system_id.
          example: 'o23p01'
        parking_area_id:
          type: string
          description: The ID of an individual parking lot at a location or the area inside a parking. The ID
            is set by the parking system and must be unique within a parking_location_id. It is unique in
            the ticketing system only in combination with the parking_system_id + parking_location_id.
          example: 'A1'

  parameters:
    # #################################
    # SPASS/Ticket UID
    # #################################
    ticket_id:
      name: ticket_id
      in: path
      required: true
      schema:
        type: string
      description: |-
            The UID of the Südtirol Pass that shall be used for payment. In hexadecimal format.
            
            This is the UID that was read from the SPASS that the driver presented at a smartcard reader
            at the gate or the UID that was resolved via license plate reading.
      example: 04595422654D80

  securitySchemes:
    OAuthAuthorization:
      type: oauth2
      description: >
        API security used for securing machine-to-machine communication using
        the OAuth2.0 protocol

        For now users will *not be* authorized with OAuth2.0
      flows:
        clientCredentials:
          tokenUrl: https://auth-fat.fcshosting.scheidt-bachmann.de/auth/realms/STA/protocol/openid-connect/token
          scopes:
            parking: Access to Parking APIs