openapi: 3.0.3
info:
  version: 1.0.0
  title: MAN DataPackage TiGR
  description: |- 
    The MAN DataPackage TiGR is the component that connects the MAN back-end to the customers Telediagnostic back-office. This connector is responsible to provide the TiGR signals to all the customers in a standardized way.
  contact:
    email: man-data-provisioning@man.eu
servers:
  - url: https://api.example.com
tags:
  - name: tigr
    description: TiGR connector
  - name: auth
    description: Authentication to obtain JWT token
paths:
  /get-jwt-token:
    post:
      tags: 
        - auth
      summary: Obtain the token
      description: |
        In order to provide the TiGR information (Triggers with payload) to the customer side, according to the official documentation, the connector consisting of a RESTful Web Service Client implemented in the MAN data provisioning app and a server on the customer side.
          
          The client credentials is provided in the header with Basic Authentication format with client_id:client_secret and Base64 encoded.
        
          Example: 
        
          Authorization: Basic base64(mycompany_id:mycompany_secret)
      operationId: authorization
      security:
        - BasicAuth: []
      responses: 
        '200':
          description: OK 
          content:
            'application/json':
              schema:
                $ref: '#/components/schemas/AuthSuccessResponse'
        '401':
          description: Unauthorized - Access token is missing or invalid
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AuthUnauthorizedResponse'
        '500':
          description: Internal Server Error - An unexpected error occurred on the server
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AuthInternalErrorResponse'
  /submit-data:
    post:
      tags:
        - tigr
      summary: Retrieve Vehicle Data
      description: This API endpoint allows users to submit data to the customer API. It uses OAuth for authentication and expects a JSON payload.
      operationId: vehicleData
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Payload'
      responses: 
        '200':
          description: OK 
          content:
            'application/json':
              schema:
                $ref: '#/components/schemas/SuccessResponse'
        '400':
          description: Bad request - Invalid parameters provided
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Unauthorized - Access token is missing or invalid
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UnauthorizedResponse'
        '500':
          description: Internal Server Error - An unexpected error occurred on the server
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InternalErrorResponse'
components:
  schemas:
    Payload:
      type: object
      properties:
        data:
          type: string
          example: "TiGR trigger data"
          description: TiGR trigger data
          
    SuccessResponse:
      type: object
      properties:
        message:
          type: string
          example: "Data submitted successfully"
          description: "Message indicating the state of the request"
          
    ErrorResponse:
      type: object
      properties:
        error:
          type: string
          example: "Bad request"
          description: "Error identification"
        message:
          type: string
          example: "Invalid request payload. Please provide a valid JSON payload with a 'data' field."
          description: "Message indicating the state of the request"

    UnauthorizedResponse:
      type: object
      properties:
        error:
          type: string
          example: "Unauthorized"
          description: "Error identification"
        message:
          type: string
          example: "Authentication failed. Please provide a valid access token."
          description: "Message indicating the state of the request"
          
    InternalErrorResponse:
      type: object
      properties:
        error:
          type: string
          example: "Internal Server Error"
          description: "Error identification"
        message:
          type: string
          example: "An error occurred while processing your request. Please try again later."
          description: "Message indicating the state of the request"
          
    AuthSuccessResponse:
      type: object
      properties:
        access_token:
          type: string
          example: "Your.JWT.Token.Here"
          description: "The JWT token"
        token_type:
          type: string
          example: "Bearer"
          description: "The type of token"
          
    AuthUnauthorizedResponse:
      type: object
      properties:
        error:
          type: string
          example: "Unauthorized"
          description: "Error identification"
        message:
          type: string
          example: "Authentication failed. Please provide a valid access token."
          description: "Message indicating the state of the request"
          
    AuthInternalErrorResponse:
      type: object
      properties:
        error:
          type: string
          example: "Internal Server Error"
          description: "Error identification"
        message:
          type: string
          example: "An error occurred while processing your request. Please try again later."
          description: "Message indicating the state of the request"      
  securitySchemes:
    BasicAuth:
      type: http
      scheme: basic
      description: | 
        The client credentials is provided in the header with Basic Authentication format with client_id:client_secret and Base64 encoded.
        
        Example: 
      
        Authorization: Basic base64(mycompany_id:mycompany_secret)
      