openapi: 3.0.0
servers:
  - description: Locally Deployed Environment
    url: 'http://localhost:8310/ms-servicerequest-api/api/v1.0.0'
info:
  description: Service Request Microservice
  version: v1.0.0
  title: Service Request APIs
  license:
    name: Apache 2.0
    url: 'http://www.apache.org/licenses/LICENSE-2.0.html'
paths:
  '/orders/type/{typeId}/subType/{subTypeId}/serviceRequestConfiguration/{requestConfigId}':
    post:
      description: Creates new Service Request Configuration record with the given details
      summary: Creates new Service Request Configuration record
      operationId: createServiceReqConfig
      tags:
        - Service Request Configuration
      parameters:
        - name: typeId 
          in: path
          description: Type Id
          required: true
          schema:
            type: string
            example: card
        - name: subTypeId
          in: path
          description: SubType Id
          required: true
          schema:
            type: string
            example: replaceCard
        - name: requestConfigId
          in: path
          description: Request Config Id
          required: true
          schema:
            type: string
            example: replaceCard
      requestBody:
        content:
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/ServiceReqConfRequest'
      responses:
        '200':
          description: Status for the creation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StandardResponse'
        default:
          description: Get the error message
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StandardErrorResponse'
    put:
      description: Updates Service Request Configuration record with the given details
      summary: Updates Service Request Configuration record
      operationId: updateServiceReqConfig
      tags:
        - Service Request Configuration
      parameters:
        - name: typeId
          in: path
          description: Type Id
          required: true
          schema:
            type: string
            example: card
        - name: subTypeId
          in: path
          description: SubType Id
          required: true
          schema:
            type: string
            example: replaceCard
        - name: requestConfigId
          in: path
          description: Request Config Id
          required: true
          schema:
            type: string
            example: replaceCard
      requestBody:
        content:
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/ServiceReqConfRequest'
      responses:
        '200':
          description: Status for the creation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StandardResponse'
        default:
          description: Get the error message
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StandardErrorResponse'
  /orders/serviceRequestConfigurations:
    get:
      description: Fetch the Service Request Configuration record with the given details
      summary: Returns the Service Request Configuration record
      operationId: getServiceReqConfig
      tags:
        - Service Request Configuration
      parameters:
        - name: type
          in: query
          description: Type Id
          schema:
            type: string
            example: card
        - name: subType
          in: query
          description: SubType Id
          schema:
            type: string
            example: replaceCard
      responses:
        '200':
          description: Status for the creation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ServiceReqConfigResponses'
        default:
          description: Get the error message
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StandardErrorResponse'
  '/orders/party/{partyId}/type/{typeId}/subtype/{subtypeId}/serviceRequest':
    post:
      description: Creates new Service Request record with the given details
      summary: Creates new Service Request record
      operationId: createServiceReq
      tags:
        - Service Request
      parameters:
        - name: partyId
          in: path
          description: party Id
          required: true
          schema:
            type: string
            example: GB0010001-100100
        - name: typeId
          in: path
          description: type Id
          required: true
          schema:
            type: string
            example: card
        - name: subtypeId
          in: path
          description: subtype Id
          required: true
          schema:
            type: string
            example: replaceCard
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ServiceRequest'
      responses:
        '200':
          description: Status for the creation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StandardResponse'
        default:
          description: Get the error message
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StandardErrorResponse'
  '/orders/party/{partyId}':
    get:
      description: Fetch the Request record
      summary: Returns the Request record
      operationId: getRequestDetails
      tags:
        - Service Request
      parameters:
        - name: partyId
          in: path
          description: party Id
          required: true
          schema:
            type: string
            example: GB0010001-100100
        - name: status
          in: query
          description: Status
          schema:
            type: string
            example: Initiated
        - name: account
          in: query
          description: Account Id
          schema:
            type: string
            example: GB0010001-89707
        - name: type
          in: query
          description: Type
          schema:
            type: string
            example: card
        - name: subType
          in: query
          description: subType
          schema:
            type: string
            example: replaceCard
        - name: dateFrom
          in: query
          description: Starting Date
          schema:
            type: string
            example: "2020-09-10"
        - name: dateTo
          in: query
          description: Ending Date
          schema:
            type: string
            example: "2020-09-10"
      responses:
        '200':
          description: Status for fetch success
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ServiceRequestResponse'
        default:
          description: Get the error message
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StandardErrorResponse'
  '/orders/serviceRequest/{requestId}':
    get:
      description: Returns the Service Request record(s)
      summary: Returns the Service Request record(s) for comma separated requestIds
      operationId: getAllRequestDetailsByRequestId
      tags:
        - Service Request
      parameters:
        - name: requestId
          in: path
          description: Request Id
          required: true
          schema:
            type: string
            example: SRD20251HNXN9
        - name: partyId
          in: query
          description: party Id
          schema:
            type: string
            example: GB0010001-100100          
      responses:
        '200':
          description: Status for the creation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ServiceRequestResponse'
        default:
          description: Get the error message
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StandardErrorResponse'    
    put:
      description: Update the Service Request record
      summary: updates the Service Request record
      operationId: updateServiceReq
      tags:
        - Service Request
      parameters:
        - name: requestId
          in: path
          description: Request Id
          required: true
          schema:
            type: string
            example: SRD20251HNXN9
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateServiceRequest'
      responses:
        '200':
          description: Status for the creation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StandardResponse'
        default:
          description: Get the error message
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StandardErrorResponse'
  '/orders/type/{typeId}/subType/{subTypeId}/status/statusCheck':
    put:
      description: Status check for Awaiting order periodically
      summary: Status check for Awaiting order periodically
      operationId: reTriggerAwaitingSerReq
      tags:
        - ReTrigger Service Request
      parameters:
        - name: typeId
          in: path
          description: Type Id
          required: true
          schema:
            type: string
            example: card
        - name: subTypeId
          in: path
          description: SubType Id
          required: true
          schema:
            type: string
            example: replaceCard
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ReTriggerRequestItem'
      responses:
        '200':
          description: Status for the creation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StandardResponse'
        default:
          description: Get the error message
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StandardErrorResponse'
  '/orders/party/{partyId}/serviceRequest/{requestId}/approve':
    post:
      description: Approval for the Service Request
      summary: Approve a service request
      operationId: approveServiceRequest
      tags:
        - Service Request
      parameters:
        - name: partyId
          in: path
          description: Party Id
          required: true
          schema:
            type: string
            example: 100100
        - name: requestId
          in: path
          description: Request Id
          required: true
          schema:
            type: string
            example: OCB21021U0UIG        
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ApprovalRequest'
      responses:
        '200':
          description: Status for the creation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApprovalResponse'
        default:
          description: Get the error message
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StandardErrorResponse'       
  '/orders/party/{partyId}/serviceRequest/{requestId}/reject':
    post:
      description: Reject for the Service Request
      summary: Reject a service request
      operationId: rejectServiceRequest
      tags:
        - Service Request
      parameters:
        - name: partyId
          in: path
          description: Party Id
          required: true
          schema:
            type: string
            example: 100100
        - name: requestId
          in: path
          description: Request Id
          required: true
          schema:
            type: string
            example: OCB21021U0UIG        
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ApprovalRequest'
      responses:
        '200':
          description: Status for the creation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApprovalResponse'
        default:
          description: Get the error message
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StandardErrorResponse'
  '/orders/party/{partyId}/serviceRequest/{requestId}/withdraw':
    post:
      description: Withdraw for the Service Request
      summary: Withdraw a service request
      operationId: withdrawServiceRequest
      tags:
        - Service Request
      parameters:
        - name: partyId
          in: path
          description: Party Id
          required: true
          schema:
            type: string
            example: 100100
        - name: requestId
          in: path
          description: Request Id
          required: true
          schema:
            type: string
            example: OCB21021U0UIG        
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ApprovalRequest'
      responses:
        '200':
          description: Status for the creation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApprovalResponse'
        default:
          description: Get the error message
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StandardErrorResponse'
  '/system/file':
    post:
      description: Ingest JSON file
      summary: Ingest file
      operationId: fileIngestor
      tags:
        - File
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/FileRequest'
      responses:
        '200':
          description: Status for the creation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FileListResponse'
        default:
          description: Get the error message
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StandardErrorResponse'
components:
  schemas:
    StandardErrorResponse:
      properties:
        errorCode:
          description: Holds an error code
          example: SRMS-0110
          type: string
        errorMessage:
          description: Holds an error Message
          example: Transformation Failed
          type: string
    StandardResponse:
      properties:
        id:
          description: Unique identifier for ServiceReqConfig/ServiceReq
          example: '200722894'
          type: string
        status:
          type: string
          description: Specifies http error code extension
          example: Success
        message:
          type: string
          description: Specifies the text that provide more details and corrective actions
          example: Created/Updated Succesfully
    ApprovalRequest:
      properties:
        comments:
          type: string
          description: Description for the Approved/Rejected
          example: Check Book Request Approved
        signatoryApproved:
          type: string
          description: If the request has been approved by all signatories
          example: true
        uuid:
          type: string
          description: Unique Identifier
          example: 390882aa-6453-4546-ad74-77dd33655f0c
    ApprovalResponse:
      properties:
        partyId:
          type: string
          description: Party Id
          example: 100100
        requestId: 
          type: string
          description: Request Id
          example: OCB21021U0UIG
        comments:
          type: string
          description: Description for the Approved/Rejected
          example: Check Book Request Approved
        signatoryAction:
          type: string
          description: Signatory Action
          example: Approved
        serviceReqStatus:
          type: string
          description: Overall Status of the request
          example: Request Placed
    StandardFileResponse:
      properties:
        id:
          description: Unique identifier for ServiceReqConfig/ServiceReq
          example: 'conf1.json'
          type: string
        status:
          type: string
          description: Specifies http error code extension
          example: Success
        response:
          type: object
          description: Specifies the text that provide more details and corrective actions
          example:
            {"id":"ChequeBookRequest","status":"Success"}
    FileRequest:
      properties:
        filename:
          type: array
          items:
            type: string 
          description: List of files to be Ingested
          example: 
            - serviceRequestConfig.json
            - getServiceReqConfig.json
    FileListResponse:
      properties:
        APIResponses:
          type: array
          items:
            $ref: '#/components/schemas/StandardFileResponse'
          description: Attributes      
    AttributeObjects:
      properties:
        attributeName:
          type: string
          description: Attribute Name
          example: ChequeIssueId/note
        mandatory:
          type: boolean
          description: Attribute Value Mandatory or Not
          example: true
        dataType:
          type: string
          description: Data Type for Attribute
          example: string
        maxLength:
          type: number
          description: Maximum Length for an Attribute
          example: 15
        allowedValues:
          type: array
          items:
            type: string
          description: Allowded Values for an Attribute
          example:
            - SB.2406
            - SB.2568
    ServiceReqConfRequestItem:
      properties:
        requestConfigId:
          type: string
          description: Service Request Configuration Name
          example: replaceCard
        type:
          type: string
          description: Type for a ServiceReqConfig
          example: Card
        subType:
          type: string
          description: SubType for a ServiceReqConfig
          example: replaceCard
        endPointCommandName:
          type: string
          description: EndPoint/Command Name for a ServiceReqConfig
          example: T24ISSTOPPAYMENTS_CREATECHEQUEBOOKREQUESTS
        maxRetryAttempt:
          type: number
          description: Maximum Retry Attempt for a ServiceReqConfig
          example: 15
        adminApprovalRequired:
          type: boolean
          description: Infinity AdminApprovalRequired for a ServiceReqConfig
          example: true
        notificationEnabled:
          type: boolean
          description: Notification Enabled for a ServiceReqConfig
          example: true
        notificationStages:
          type: array
          items:
            type: string
          description: Notification Stages for a ServiceReqConfig
          example:
            - Initiated
            - Processed
        awaitingEnabled:
          type: boolean
          description: Awaiting Enabled for a ServiceReqConfig
          example: false
        awaitingEndPoint:
          type: string
          description: Awaiting End Point for a ServiceReqConfig
          example: T24ISSTOPPAYMENTS_CREATECHEQUEBOOKREQUESTS
        awaitingMaxRetryAttempted:
          type: number
          description: Awaiting Max Retry Attempt for a ServiceReqConfig
          example: 15
        preSubmissionScript:
          type: string
          description: Base64 string that coverts the stores the external JS Validation
          example: zhfuifnerDSAHRIOnjfsaduf+oHDSNFEO=UR184145+62
        requestAttribute:
          type: array
          items:
            $ref: '#/components/schemas/AttributeObjects'
          description: Attributes
        realTime:
          type: boolean
          description: Real Time for a ServiceReqConfig
          example: false
        eventSource:
          type: string
          description: Event Source for a ServiceReqConfig
          example: api
        product:
          type: string
          description: Product for the ServiceReqConfig
          example: Card
        prefix:
          type: string
          description: Prefix for the Service Request
          example: CRD
        defaultStatus:
          type: string
          description: Default Status , in case backend response does not contain status
          example: Yet to confirm
        statusConfigurationMapper:
          type: object
          description: Mapper to maintain status lifecycle
          example:
            ISSUED: ORDER CONFIRMED
            REQUEST RECIEVED: ORDER RECIEVED
    ServiceRequest:
      properties:
        uuid:
          type: string
          description: Unique Identifier
          example: 390882aa-6453-4546-ad74-77dd33655f0c
        serviceReqConfId:
          type: string
          description: serviceReqConfName Id
          example: deleteCard
        account:
          type: string
          description: Account Id
          example: '87907'
        requestIn:
          type: object
          description: Request Load for Creating ServiceReq
          example:
            checkIssueId: SB.2406
            note: CreateNew
        signatoryApprovalRequired:
          type: string
          description: signatory Approved or Not
          example: true
    ServiceRequestView:
      properties:
        serviceReqId:
          type: string
          description: Generic serviceReq ID
          example: ORD127REDFDSAS
        externalserviceReqRef:
          type: string
          description: External serviceReq ID
          example: ORD12HNFU34I4N5
        description:
          type: string
          description: Description ServiceReq
          example: Status Initiated
        partyId:
          type: string
          description: Party ID
          example: GB0010001-100100
        accountId:
          type: string
          description: Account ID
          example: GB0010001-89707
        type:
          type: string
          description: Type ID
          example: Card
        subType:
          type: string
          description: Sub Type ID
          example: replaceCard
        currentAttempt:
          type: number
          description: Number of Attempts
          example: 5
        requestConfigId:
          type: string
          description: serviceReqConfig ID
          example: replaceCard
        serviceReqRequestIn:
          type: object
          description: Request In for ServiceReq
          example:
            checkIssueId: SB.2406
            note: CreateNew
        serviceReqResponse:
          type: object
          description: ServiceReq Response
          example:
            httpStatus: '200'
            dbpError: ''
        responseAttributes:
          type: object
          description: Response Attributes in Detail
          example:
            httpStatus: '200'
            dbpError: ''
        errorDetails:
          type: string
          description: Error Details from Fabric
          example: Nil
        serviceReqStatus:
          type: string
          description: ServiceReq Updated Status - as per external system
          example: Initiated/Success
        internalStatus:
          type: string
          description: Status maintained by Service Request Internally to track retrigger attempts
          example: ReInitiated/Awaiting
        serviceReqProcessedTime:
          type: string
          description: ServiceReq Processing Time
          example: '2020-08-20T06:01:01.729Z'
        requestDate:
          type: string
          description: Date of request
          example: '2020-08-20'
        signatoryApprovalRequired:
          type: string
          description: signatory Approved or Not
          example: true
        returnCode:
          type: string
          description: Returns the Error Code
          example: 400
        additionalErrorInfo:
          type: string
          description: Additional Error Message
          example: Service Request Not found
        currrentSignatoryApprovedCount:
          type: number
          description: currrentSignatoryApprovedCount
          example: 1
        currentSignatoryRejectCount:
          type: number
          description: currentSignatoryRejectCount
          example: 1
    ServiceRequestResponse:
      properties:
        serviceReqs:
          type: array
          items:
            $ref: '#/components/schemas/ServiceRequestView'
          description: List of serviceReq
    UpdateServiceRequest:
      properties:
        request:
          type: string
          description: Request In for ServiceReq
          example: '{''checkIssueId'':''SB.2406'',''note'':''CreateNew''}'
        backendResponse:
          type: string
          description: ServiceReq Response
          example: '{''httpStatus'':''200'',''dbpError'':''''}'
        serviceReqId:
          type: string
          description: Generic serviceReq ID
          example: ORD127REDFDSAS
        status:
          type: string
          description: ServiceReq Updated Status
          example: Initiated/Success
        errorMessage:
          type: string
          description: Error Details from Fabric
          example: Nil
        externalReference:
          type: string
          description: External ServiceRequest
          example: SB.1441         
    ReTriggerRequestItem:
      properties:
        dateFrom:
          type: string
          format: date
          description: Starting Date in UTC/YYYY-MM-DD format
          example: '2020-08-20T06:01:01.729Z'
        dateTo:
          type: string
          format: date
          description: Ending Date in UTC/YYYY-MM-DD format
          example: '2020-08-20T06:01:01.729Z'
        status:
          type: array
          items:
            type: string 
          description: List of Status to be Retriggered
          example: 
            - Initiated
            - Awaiting
        uuid:
          type: string
          description: Unique Identifier
          example: 390882aa-6453-4546-ad74-77dd33655f0c            
    ServiceReqConfRequest:
      type: object
      properties:
        serReqConfigDetails:
          allOf:
            - $ref: '#/components/schemas/ServiceReqConfRequestItem'
          description: Service Request Configuration Details
        fileName:
          type: array
          description: External JS File
          items:
            type: string
            format: binary
    ServiceReqConfigResponses:
      properties:
        serviceReqConfig:
          type: array
          items:
            $ref: '#/components/schemas/ServiceReqConfRequestItem'
