openapi: 3.0.1
info:
  title: CATCH
  description: ''
  contact: { }
  version: '2.29.0'
paths:
  /enquiries/gkp/initialize:
    post:
      tags:
        - EnquiryQueue
      summary: 'GKP: KPIs request for the full subjects'' portfolio'
      description: The method triggers the KPIs calculation for the declared `PackageId`. The KPIs are calculated for all the subjects of the User portfolio.
      operationId: insertEnquiryGKP
      parameters:
        - name: Authorization
          in: header
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/GkpDto'
        required: true
      responses:
        '202':
          description: Successful response - returns the identifier of the submitted request (`RequestId`) and the corrisponding `status`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EnquiryQueueDto'
        '403':
          description: Forbidden - invalid bank or package
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CustomErrorResponse'
        '404':
          description: Not found - the request refers to one or more resources that were not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CustomErrorResponse'
        '422':
          description: Unprocessable request - the system is unable to process the contained instructions
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CustomErrorResponse'
        '500':
          description: Generic Internal Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CustomErrorResponse'
  /enquiries/gku/initialize:
    post:
      tags:
        - EnquiryQueue
      summary: 'GKU: KPIs request for all the updated subjects'
      description: The method triggers the KPIs calculation for the declared `PackageId`. The KPIs are calculated for all the subjects that have at least one transaction whose transaction date is equal or greater than the `dateFrom`.
      operationId: insertEnquiryGKU
      parameters:
        - name: Authorization
          in: header
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/GkuDto'
        required: true
      responses:
        '202':
          description: Successful response - returns the identifier of the submitted request (`RequestId`) and the corrisponding `status`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EnquiryQueueDto'
        '403':
          description: Forbidden - invalid bank or package
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CustomErrorResponse'
        '404':
          description: Not found - the request refers to one or more resources that were not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CustomErrorResponse'
        '422':
          description: Unprocessable request - the system is unable to process the contained instructions
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CustomErrorResponse'
        '500':
          description: Generic Internal Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CustomErrorResponse'
  /enquiries/gtd/initialize:
    post:
      tags:
        - EnquiryQueue
      summary: 'GTD: transactions category request'
      description: 'The method triggers the retrieval of the categorized transactions. The transactions are returned filtered either by `latRequestId`, or by date interval lying between the `dateFrom` and `dateTo`.'
      operationId: insertEnquiryGTD
      parameters:
        - name: Authorization
          in: header
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CategorizedTransactionDto'
        required: true
      responses:
        '202':
          description: Successful response - returns the identifier of the submitted request (`RequestId`) and the corrisponding `status`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EnquiryQueueDto'
        '403':
          description: Forbidden - invalid bank or package
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CustomErrorResponse'
        '404':
          description: Not found - the request refers to one or more resources that were not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CustomErrorResponse'
        '422':
          description: Unprocessable request - the system is unable to process the contained instructions
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CustomErrorResponse'
        '500':
          description: Generic Internal Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CustomErrorResponse'
  /enquiries/gtf/initialize:
    post:
      tags:
        - EnquiryQueue
      summary: 'GTF: transactions category request - full detailed'
      description: 'The method triggers the retrieval of the categorized transactions. The transactions are returned filtered either by `latRequestId`, or by date interval lying between the `dateFrom` and `dateTo`. All transaction attributes are returned together with the category.'
      operationId: insertEnquiryGTF
      parameters:
        - name: Authorization
          in: header
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CategorizedTransactionDto'
        required: true
      responses:
        '202':
          description: Accepted
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EnquiryQueueDto'
        '404':
          description: User entity Not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CustomErrorResponse'
        '422':
          description: Unprocessable request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CustomErrorResponse'
        '500':
          description: Generic Internal Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CustomErrorResponse'
  '/enquiries/{requestId}':
    get:
      tags:
        - EnquiryQueue
      summary: Get the status of an enquiry in the queue
      description: The method is used to know the status of a previously submitted request. The method requires in input the `RequestId` of the submitted request.
      operationId: getStatusByRequestId_1
      parameters:
        - name: Authorization
          in: header
          required: true
          schema:
            type: string
        - name: requestId
          in: path
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Successful response - returns the identifier of the submitted request (RequestId) and the corrisponding status.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EnquiryQueueDto'
        '404':
          description: Entity not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CustomErrorResponse'
        '500':
          description: Generic Internal Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CustomErrorResponse'
  /kpis/extract:
    post:
      tags:
        - Enquiry
      summary: 'GKS: KPIs request for a single subject'
      description: The method triggers the KPIs calculation for the declared `packageID` and `subjectId`.
      operationId: getKpiBySubjectIdAndPackage
      parameters:
        - name: Authorization
          in: header
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/GksRequestDto'
        required: true
      responses:
        '200':
          description: Successful response - returns the KPIs for the enquired `subjectId`
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/KpiOnlineResponseDto'
        '400':
          description: Bad Request - invalid input parameter or value
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CustomErrorResponse'
        '403':
          description: Forbidden - invalid bank or package
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CustomErrorResponse'
        '404':
          description: Not found - the request refers to one or more resources that were not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CustomErrorResponse'
        '422':
          description: Unprocessable request - the system is unable to process the contained instructions
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CustomErrorResponse'
        '500':
          description: Generic Internal Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CustomErrorResponse'
  /sysouts/execution/status:
    post:
      tags:
        - Sysout
      summary: Returns the status of the last execution filtered by requestId
      operationId: getStatusByRequestId
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ExecutionSysoutSearchDto'
        required: true
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ExecutionSysoutDto'
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CustomErrorResponse'
        '404':
          description: Execution Not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CustomErrorResponse'
        '500':
          description: Generic Internal Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CustomErrorResponse'
  /transactions/contribute:
    post:
      tags:
        - Submission
      summary: 'PAT: submission of a single transaction'
      description: The method allows to submit a single transaction with the related account data.Transaction and Account information refer to the subject whose identifier is indicated by the `subjectNo`.
      operationId: putTransaction
      parameters:
        - name: Authorization
          in: header
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PatRequestDto'
        required: true
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PatResponseDto'
        '400':
          description: Bad Request - invalid input parameter or value
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CustomErrorResponse'
        '403':
          description: Not found - the request refers to one or more resources that were not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CustomErrorResponse'
        '409':
          description: Conflict - the requested operation conflicts with an existing item
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CustomErrorResponse'
        '422':
          description: Unprocessable request - the system is unable to process the contained instructions
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CustomErrorResponse'
        '500':
          description: Generic Internal Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CustomErrorResponse'
        '503':
          description: Service is momentarily not available
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CustomErrorResponse'
components:
  schemas:
    AccountDto:
      type: object
      properties:
        accountNo:
          type: string
        kpis:
          type: array
          items:
            $ref: '#/components/schemas/KpiDto'
    BankDto:
      type: object
      properties:
        accounts:
          type: array
          items:
            $ref: '#/components/schemas/AccountDto'
          example:
            - accountNo: '10004'
              bankId: BANK_ONE
              kpis:
                - confidence: 0.96
                  description: 
                  lastTransactionDate: '2020-11-16'
                  name: AmountNegativeOOLast180
                  value: -532.46
                - confidence: 
                  description: 
                  lastTransactionDate: 
                  name: ACCOUNT_MAIN
                  value: 0
        bankId:
          type: string
        kpis:
          type: array
          items:
            $ref: '#/components/schemas/KpiDto'
          example:
            - confidence: 100
              description: Custom KPI 001 Calculated on Package 1
              lastTransactionDate: '2020-10-30'
              name: KPI_Custom_001
              value: 3
            - confidence: 
              description: 
              lastTransactionDate: 
              name: Num_of_Current_Accounts
              value: 1
    BatchSysoutDto:
      type: object
      properties:
        noOfRecordWithErrors:
          type: integer
          format: int32
        noOfSuccessRecord:
          type: integer
          format: int32
        recordType:
          type: string
    CategorizedTransactionDto:
      type: object
      properties:
        dateFrom:
          type: string
          description: 'pattern: YYYY-MM-DD'
          example: '2020-11-01'
        dateTo:
          type: string
          description: 'pattern: YYYY-MM-DD'
          example: '2020-11-30'
        latRequestId:
          type: string
          example: 12345_20210101120000
    CustomErrorResponse:
      required:
        - fault
      type: object
      properties:
        fault:
          $ref: '#/components/schemas/Fault'
    EnquiryQueueDto:
      required:
        - message
        - requestId
        - status
      type: object
      properties:
        message:
          type: string
          example: Request added to queue
        requestId:
          enum:
            - 'range[-infinity,64]'
          type: string
          example: f520cc0bbdca926c
        status:
          enum:
            - ABANDONED
            - COMPLETED
            - FAILED
            - PENDING_ABANDON
            - READY
            - RUNNING
            - STOPPED
            - UNKNOWN
          type: string
          example: READY
    ExecutionSysoutDto:
      type: object
      properties:
        batchSysouts:
          type: array
          items:
            $ref: '#/components/schemas/BatchSysoutDto'
        elapsed:
          type: string
        end:
          type: string
          format: date-time
        precheckError:
          $ref: '#/components/schemas/PrecheckError'
        requestId:
          type: string
        start:
          type: string
          format: date-time
        status:
          enum:
            - ABANDONED
            - COMPLETED
            - FAILED
            - PENDING_ABANDON
            - READY
            - RUNNING
            - STOPPED
            - UNKNOWN
          type: string
    ExecutionSysoutSearchDto:
      required:
        - requestId
      type: object
      properties:
        requestId:
          type: string
    Fault:
      required:
        - code
        - message
      type: object
      properties:
        code:
          type: integer
          description: HTTP error code
          format: int32
        description:
          type: string
          description: Error description
        details:
          type: array
          items:
            $ref: '#/components/schemas/FaultDetail'
        message:
          type: string
          description: Error message
    FaultDetail:
      required:
        - code
        - message
      type: object
      properties:
        code:
          type: integer
          description: Detail HTTP error code
          format: int32
        description:
          type: string
          description: Detail error description
        message:
          type: string
          description: Detail error message
    GkpDto:
      required:
        - packageId
      type: object
      properties:
        packageId:
          maxLength: 16
          minLength: 0
          type: string
          example: Package_1
    GksRequestDto:
      required:
        - packageId
        - subjectId
      type: object
      properties:
        packageId:
          maxLength: 16
          minLength: 0
          enum:
            - 'range[-infinity,16]'
          type: string
          example: Package_1
        subjectId:
          maxLength: 32
          minLength: 0
          enum:
            - 'range[-infinity,32]'
          type: string
          example: ID0001342
    GkuDto:
      required:
        - dateFrom
        - packageId
      type: object
      properties:
        dateFrom:
          type: string
          description: 'pattern: YYYY-MM-DD'
          example: '2020-09-26'
        packageId:
          maxLength: 16
          minLength: 0
          type: string
          example: Package_1
    KpiDto:
      type: object
      properties:
        bundleId:
          type: string
        confidence:
          type: number
          format: double
        description:
          enum:
            - 'range[-infinity,255]'
          type: string
          description: If filled contains the description of the KPI
        lastTransactionDate:
          type: string
          description: 'pattern: YYYY-MM-DD'
          format: date
        modelLevel:
          type: integer
          format: int32
        modelName:
          type: string
        name:
          enum:
            - 'range[-infinity,32]'
          type: string
        purpose:
          type: string
        value:
          enum:
            - 'range[-infinity,256]'
          type: string
    KpiOnlineResponseDto:
      type: object
      properties:
        banks:
          type: array
          items:
            $ref: '#/components/schemas/BankDto'
          example:
            accountNo: '10004'
            bankId: BANK_ONE
            kpis:
              - confidence: 0.96
                description: 
                lastTransactionDate: '2020-11-16'
                name: AmountNegativeOOLast180
                value: -532.46
              - confidence: 
                description: 
                lastTransactionDate: 
                name: ACCOUNT_MAIN
                value: 0
        kpis:
          type: array
          items:
            $ref: '#/components/schemas/KpiDto'
          example:
            - confidence: 100
              description: Custom KPI 001 Calculated on Package 1
              lastTransactionDate: '2020-10-30'
              name: KPI_Custom_001
              value: 3
            - confidence: 
              description: 
              lastTransactionDate: 
              name: Num_of_Current_Accounts
              value: 1
        packageId:
          enum:
            - 'range[-infinity,16]'
          type: string
          example: Package_1
        requestId:
          enum:
            - 'range[-infinity,64]'
          type: string
          example: ffab7ec375c2fb3b
        subjectNo:
          enum:
            - 'range[-infinity,32]'
          type: string
          example: ID0001342
    PatAccountDto:
      required:
        - accountNature
        - accountNo
        - accountPurpose
        - balance
        - creationDate
        - referenceDate
        - transaction
      type: object
      properties:
        accountNature:
          pattern: '[13]'
          enum:
            - '1,3'
          type: string
          description: 'The type of the account: 1-Account, 3-CreditCard'
          example: '1'
        accountNo:
          maxLength: 32
          minLength: 1
          type: string
          example: '200101'
        accountPurpose:
          pattern: '[13]'
          enum:
            - '1,3'
          type: string
          description: 'The AccountHolder purpose: 1-Individual, 3-Company'
          example: '1'
        balance:
          type: number
          example: 1050
        creationDate:
          type: string
          description: 'pattern: YYYY-MM-DD'
          example: '2020-01-01'
        noOfCoApplicants:
          maximum: 999999
          minimum: 0
          type: integer
          format: int32
          example: 2
        referenceDate:
          type: string
          description: 'pattern: YYYY-MM-DD'
          example: '2020-01-01'
        transaction:
          $ref: '#/components/schemas/PatTransactionDto'
    PatRequestDto:
      required:
        - account
        - subjectNo
      type: object
      properties:
        account:
          $ref: '#/components/schemas/PatAccountDto'
        subjectNo:
          maxLength: 32
          minLength: 1
          type: string
          example: IT3456092226G
    PatResponseDto:
      type: object
      properties:
        message:
          enum:
            - 'range[-infinity,64]'
          type: string
          example: OK
        requestId:
          type: string
          example: 756e5f9a99f259ca
    PatTransactionDto:
      required:
        - transactionAmount
        - transactionDate
        - transactionDescription
        - transactionNo
      type: object
      properties:
        bankCategory:
          maxLength: 32
          minLength: 1
          type: string
        cardAcceptorCountry:
          pattern: '[A-Z]{2}'
          type: string
          description: ISO 3166 ALPHA2 CountryCode Domain
        cardAcceptorId:
          maxLength: 35
          minLength: 1
          type: string
        cardAcceptorName:
          maxLength: 256
          minLength: 1
          type: string
        cardAcceptorStreet:
          maxLength: 256
          minLength: 1
          type: string
        cardAcceptorTownName:
          maxLength: 128
          minLength: 1
          type: string
        cardAcceptorZipCode:
          maxLength: 10
          minLength: 1
          type: string
        categoryConfidence:
          type: number
        categoryModel:
          maxLength: 40
          minLength: 1
          type: string
        merchantCategoryCode:
          pattern: '\d{4}'
          enum:
            - 'range[-infinity,4]'
          type: string
          description: ISO 18245 Merchant Code Domain
        purposeCode:
          pattern: '[a-zA-Z0-9]{1,4}'
          enum:
            - 'range[-infinity,4]'
          type: string
          description: ISO 20022 Purpose Code Domain
        transactionAmount:
          type: number
          format: double
          example: -200
        transactionDate:
          type: string
          description: 'pattern: YYYY-MM-DD'
          example: '2020-09-20'
        transactionDescription:
          maxLength: 1024
          minLength: 1
          type: string
          example: PAGAMENTO AFFITTO GARAGE E CANTINA
        transactionNo:
          maxLength: 64
          minLength: 1
          type: string
          example: '20010109'
    PrecheckError:
      type: object
      properties:
        code:
          type: string
        description:
          type: string
        row:
          type: string
  securitySchemes:
    Password:
      type: oauth2
      flows:
        password:
          tokenUrl: https://iam-uat.crif.com/oauth2/token
          scopes: { }
security:
  - Password: [ ]
tags:
  - name: Enquiry
    description: Enquiry with synchronous response
  - name: EnquiryQueue
    description: "Group of enquiries with asynchronous response\n\nThese methods are used to insert a request in the CATCH Enquiry Queue. The CATCH internal scheduler reads the request from the queue and executes the specific flow producing the output CSV file that is returned via Batch Channel"
  - name: Submission
    description: Input of a single transaction
  - name: Sysout
    description: Sysout APIs