swagger: '2.0'
info:
  contact:
    name: vincent.lemonnier@thalesgroup.com
  description: |
    Incoming requests from TSP

    Copyright (c) 2020 Thales. All Rights Reserved
  title: TSH Token Requestor Incoming API
  version: 2.2.2
schemes:
  - https
host: api.dbp.thalescloud.io
basePath: /gtep/tsh/trapi/v2.0
consumes:
  - application/json
produces:
  - application/json
parameters:
  tokenIdPath:
    description: Identifier of the token to update
    in: path
    maxLength: 48
    minLength: 1
    name: tokenId
    required: true
    type: string
  x-request-id-header:
    description: Unique identifier of the request
    in: header
    maxLength: 64
    minLength: 1
    name: x-request-id
    required: true
    type: string
  x-correlation-id-header:
    description: Unique identifier used to trace function calls across systems
    in: header
    maxLength: 64
    minLength: 1
    name: x-correlation-id
    required: true
    type: string
paths:
  '/tokens/{tokenId}/data':
    put:
      x-swagger-router-controller: tokenRequestorDispatcher
      summary: 'PUT /tokens/{tokenId}/data'
      description: This method is used by TSP to send the partial or complete data preparation used to personalize the payment application.
      operationId: submitTokenData
      produces:
        - application/json
      parameters:
        - $ref: '#/parameters/x-correlation-id-header'
        - $ref: '#/parameters/tokenIdPath'
        - name: body
          in: body
          description: submitTokenData request payload
          required: true
          schema:
            $ref: '#/definitions/submitTokenDataReq'
      responses:
        '204':
          description: successful
        '400':
          description: 'Bad Request, Invalid request URI or header, or unsupported nonstandard parameter.<br/> Possible error codes are 111, 112, 113, 119, 321, 322, 431, 432, 911, 921'
          schema:
            $ref: '#/definitions/errorRes'
        '500':
          $ref: '#/responses/500'
        '503':
          $ref: '#/responses/503'
      tags:
        - Submit Token Data
  '/tokens/{tokenId}/newData':
    put:
      x-swagger-router-controller: tokenRequestorDispatcher
      summary: 'PUT /tokens/{tokenId}/newData'
      description: This method is used by TSP to send the partial or complete data preparation used in order to re-personalize the payment application.
      operationId: submitNewTokenData
      produces:
        - application/json
      parameters:
        - $ref: '#/parameters/x-correlation-id-header'
        - $ref: '#/parameters/tokenIdPath'
        - name: body
          in: body
          description: submitNewTokenData request payload
          required: true
          schema:
            $ref: '#/definitions/submitNewTokenDataReq'
      responses:
        '204':
          description: successful
        '400':
          description: 'Bad Request, Invalid request URI or header, or unsupported nonstandard parameter.</br> Possible error codes are 111, 112, 113, 119, 321, 431, 432, 911, 921'
          schema:
            $ref: '#/definitions/errorRes'
        '500':
          $ref: '#/responses/500'
        '503':
          $ref: '#/responses/503'
      tags:
        - Submit New Token Data
  /healthCheck:
    get:
      x-swagger-router-controller: tokenRequestorDispatcher
      summary: GET /healthCheck
      description: This method is used by TSP to monitor TSH health. It should be used every 30 seconds in production environment.
      operationId: healthCheck
      produces:
        - application/json
      parameters:
        - $ref: '#/parameters/x-request-id-header'
      responses:
        '204':
          description: successful
        '400':
          description: 'Bad Request, Invalid request URI or header, or unsupported nonstandard parameter.</br> Possible error codes are 111, 112, 911, 921'
        '500':
          $ref: '#/responses/500'
        '503':
          $ref: '#/responses/503'
      tags:
        - Healthcheck
responses:
  '500':
    description: |
      Internal Server Error
      Retry possible
  '503':
    description: |
      Service Unavailable
      Retry possible
                
definitions:
  submitTokenDataReq:
    type: object
    required:
      - issuerId
      - tokenPersoInfo
    properties:
      issuerId:
        $ref: '#/definitions/issuerId'
      tokenPersoInfo:
        $ref: '#/definitions/tokenPersoInfo'
  submitNewTokenDataReq:
    type: object
    required:
      - issuerId
    properties:
      issuerId:
        $ref: '#/definitions/issuerId'
      tokenInfo:
        $ref: '#/definitions/tokenInfo'
      tokenPersoInfo:
        $ref: '#/definitions/tokenPersoInfo'
  issuerId:
    maxLength: 10
    minLength: 10
    type: string
    description: Unique Identifier of Issuer<br/>
  tokenPersoInfo:
    type: array
    maxItems: 200
    description: |
      Token Data to be used for personalizing the Card.<br/>
      The list of data element sent by the TSP is defined during the project.<br/>
      The length of all the values concatenated together shall not exceed 100k characters. 
    items:
      type: object
      properties:
        name:
          type: string
          description: 'Data element name (for example, the DGI code)'
          maxLength: 32
          minLength: 1
        value:
          type: string
          description: Data element value
          minLength: 1
        keyIndex:
          type: string
          description: |
            Index of the key used to encrypt the data element value 
            This is optional, the value could be encrypted even if key index is not provided
          maxLength: 32
          minLength: 1
  errorRes:
    type: object
    description: Error Information Response
    required:
      - responseCode
    properties:
      responseCode:
        type: number
        description: |
          Error Response code to the request
          |Error code | Description| Retryable|
          |-------|-------|-------|
          |111|Missing mandatory parameter|N|
          |112|Bad parameter format|N|
          |113|Unknown issuer|N|
          |115|Unknown product|N|
          |119|Unknown Token|N|
          |163|Product not supported for mobile payment|N|
          |164|FPAN Provisioning Count Exceeded|N|
          |166|Invalid FPAN|N|
          |167|Card already enrolled|N|
          |321|Operation on token already on-going|N|
          |322|Time to live of the operation expired|N|
          |431|Invalid perso data|N|
          |432|Current token state does not allow this operation|N|
          |911|Operation failed|N|
          |921|Unexpected server error|Y|
      errorMessage:
        type: string
        description: Textual error message
  tokenInfo:
    type: object
    description: Token related information
    properties:
      exp:
        type: string
        maxLength: 4
        minLength: 4
        description: Token expiry date in format MMYY to display in the wallet.
        example: '1220'
      last4:
        type: string
        maxLength: 10
        minLength: 2
        description: Last digits of the token pan value to display in the wallet.
        example: '1234'
tags:
  - name: SubmitTokenData
  - name: Healthcheck
  - name: SubmitNewTokenData
  - name: Submit Token Data
  - name: Submit Token New Data
  - name: Submit New Token Data
