openapi: 3.0.0
servers:
  - description: Fabric Instance
    url: 'https://dbxqa.konycloud.com'
info:
  description: Service Request Fabric Java Integration Sevice APIs, that can be used by Implementation teams to perform various service request operations available. <b>Please note that a valid X-Kony-Authorization token need to be passed while accessing these APIs.</b>
  version: v1.0.0
  title: Service Request Fabric APIs
  license:
    name: Apache 2.0
    url: 'http://www.apache.org/licenses/LICENSE-2.0.html'
paths:
  '/services/ServiceRequestJavaService/createOrder':
    post:
      description: Creates a service request, after performing validations expected as per service request configuration.
      summary: Creates a new Service Request 
      tags:
        - Service Request
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ServiceRequestOrder'
      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'
  '/services/ServiceRequestJavaService/approveServiceRequest':
    post:
      description: Approves a service request,after performing validations expected as per service request configuration. This can be done only if the service request was created with approval flow enabled and hasn't been rejected/withdrawn/fully approved already. There can be mulitple approvals, only if "signatoryApproved" tag is set to true, it indicates complete approval and the request is ready to be processed
      summary: Approves the Service Request
      tags:
        - Approval Flow
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ServiceRequestApprovalRequest'
      responses:
        '200':
          description: Status for the creation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ServiceRequestApprovalResponse'
        default:
          description: Get the error message
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StandardErrorResponse'
  '/services/ServiceRequestJavaService/rejectServiceRequest':
    post:
      description: Rejects a service request, after performing validations expected as per service request configuration. This can be done only if the service request was created with approval flow enabled, and hasn't been fully approved/withdrawn.
      summary: Rejects the Service Request
      tags:
        - Approval Flow
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ServiceRequestRejectRequest'
      responses:
        '200':
          description: Status for the creation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ServiceRequestApprovalResponse'
        default:
          description: Get the error message
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StandardErrorResponse'
  '/services/ServiceRequestJavaService/withdrawServiceRequest':
    post:
      description: Withdraws a service request, after performing validations expected as per service request configuration. This can be done only if the service request was created with approval flow enabled, and hasn't been fully approved/rejected.
      summary: Withdraws the Service Request
      tags:
        - Approval Flow
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ServiceRequestRejectRequest'
      responses:
        '200':
          description: Status for the creation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ServiceRequestApprovalResponse'
        default:
          description: Get the error message
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StandardErrorResponse'
  '/services/ServiceRequestJavaService/updateServiceRequest':
    post:
      description: Initiates an update of the service request in the backend if possible, after performing validations expected as per service request configuration. This can only be done if the service request created initially has already been processed by the backend. Eg. Trying to change an inital request that wanted a cheque book of 100 leaves which was accepted by the bank to a cheque book with just 25 leaves
      summary: Initiates an update of the service request for the backend
      tags:
        - Service Request
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ServiceRequestUpdateRequest'
      responses:
        '200':
          description: Status for the creation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CancelResponse'
        default:
          description: Get the error message
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StandardErrorResponse'
  '/services/ServiceRequestJavaService/cancelServiceRequest':
    post:
      description: Initiates a cancel of the service request in the backend if possible, after performing validations expected as per service request configuration. This can only be done if the service request created initially has already been processed by the backend. Eg. Trying to cancel an inital request that wanted a cheque book of 100 leaves which was accepted by the bank as it was done by mistake
      summary: Initiates a cancel of the service request for the backend
      tags:
        - Service Request
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ServiceRequestUpdateRequest'
      responses:
        '200':
          description: Status for the creation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CancelResponse'
        default:
          description: Get the error message
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StandardErrorResponse'
  '/services/ServiceRequestJavaService/getServiceRequestsByID':
    post:
      description: Gets the service request by service request ID(s) which can be comma separated
      summary: Gets the Service Request records by ID(s)
      tags:
        - Service Request
      requestBody:
        content:
          application/json:
            schema:
             type: object
             properties:
                 serviceRequestId:
                  description: Service request IDs
                  example: OCB21319TLFC5,OCB21319TLFC4
                  type: string
      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'
  '/services/ServiceRequestJavaService/getOrderDetails':
    post:
      description: Gets the service request details, by using the customerId from dbxUserLogin/Identity Session.
      summary: Gets the Service Request records based on the customerId from Identity
      tags:
        - Service Request
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ServiceRequestCriteria'
      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'
  '/services/ServiceRequestJavaService/getServiceRequestBasedOnCriteria':
    post:
      description: Gets the service request order details based on custom criteria after basic validations, accountId(s) could be tilde separated multi values, criteria can formed with all given request parameters or just one or any combination of the request paramters, results fetched will be fetched accordingly
      summary: Gets the Service Request records based on custom criteria
      tags:
        - Service Request
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ServiceRequestCriteria'
      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'
  '/services/ServiceRequestJavaService/getTemplateDetails':
    post:
      description: Gets the service request configuration record for given type, subtype.
      summary: Get the Service Request configuration
      tags:
        - Service Request Configuration
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ServiceRequestGetConfigRequest'
      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'
  '/services/ServiceRequestJavaService/triggerForStatus':
    post:
      description:  Triggers Service Request(s) based on given criteria which could just be one parameter in the request, or any combination or all the parameters to synchronize service requests that suit the criteria with the changes in the respective backend, if provisioned in config
      summary: Triggers Service Request(s) based on given criteria and synchronizes it with backend
      tags:
        - Service Request
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ServiceRequestCriteria'
      responses:
        '200':
          description: Status for the creation
          content:
            application/json:
              schema:
                type: object
                properties:
                 statusMessage:
                  description: Status of the chek
                  example: Status Check Successful
                  
        default:
          description: Get the error message
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StandardErrorResponse'
  '/services/ServiceRequestJavaService/getHistory':
    post:
      description:  Gets the history of actions performed on a service request like the update or cancel details and changes done in request payload
      summary: Gets the history of actions performed on a service request
      tags:
        - Service Request
      requestBody:
        content:
          application/json:
            schema:
                type: object
                properties:
                 serviceRequestId:
                  description: Service request ID
                  example: OCB21319TLFC5
                  type: string
      responses:
        '200':
          description: Status for the creation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SRAttributeHistoryResponse'
        default:
          description: Get the error message
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StandardErrorResponse'
components:
  schemas:
    StandardErrorResponse:
      properties:
        dbpErrCode:
          description: Holds an error code
          example: 20041
          type: string
        dbpErrMsg:
          description: Holds an error Message
          example: Backend request failed
          type: string
    ServiceRequestOrder:
      properties:
        accountId:
          type: string
          description: Account ID for which service request needs to be created
          example: GB0010001-89707
        type:
          type: string
          description: Type ID
          example: Card
        subType:
          type: string
          description: Sub Type ID
          example: replaceCard
        signatoryApprovalRequired:
          type: string
          description:  boolean flag to enable/disable approval flow
          example: true
        requestBody:
          type: string
          description: Request Load for Creating ServiceReq
          example: "{'checkIssueId': 'SB.2406',
            'note': 'CreateNew'}"
            
    ServiceRequestUpdateRequest:
     properties:
        serviceRequestId:
          type: string
          description: Service Request ID
          example: SR127REDFDSAS
        signatoryApprovalRequired:
          type: string
          description:  boolean flag to enable/disable approval flow
          example: true
        requestBody:
          type: object
          description: Request Load for Creating ServiceReq
          example:
            checkIssueId: SB.2406
            note: CreateNew
    ServiceRequestApprovalRequest:
     properties:
        serviceRequestId:
          type: string
          description: Service Request ID
          example: SR127REDFDSAS 
        comments:
          type: string
          description: Description for the action done
          example: Check Book Request Approved
        signatoryApproved:
          type: string
          description: If the request has been approved by all signatories
          example: true
    ServiceRequestApprovalResponse:
     properties:
        signatoryAction:
          type: string
          description: Signatory Action
          example: Approved/Withdraw/Rejected
        comments:
          type: string
          description: Description for the action done
          example: Check Book Request Approved/Rejected/Withdrawn
        serviceReqStatus:
          type: string
          description: Overall Status of the request
          example: Request Placed 
        requestId: 
          type: string
          description: Request Id
          example: OCB21021U0UIG
        partyId:
          type: string
          description: Party Id
          example: 100100
        message:
          type: string
          description: Specifies the text that provide more details and corrective actions
          example: Approved/Rejected/Withdrawn Succesfully
    ServiceRequestRejectRequest:
     properties:
        serviceRequestId:
          type: string
          description: Service Request ID
          example: SR127REDFDSAS 
        comments:
          type: string
          description: Description for the action to be done
          example: reject
    StandardResponse:
      properties:
        orderId:
          type: string
          description: ID of the service request order created
          example: SR127REDFDSAS 
        message:
          type: string
          description: Specifies the text that provide more details and corrective
          example: Service Request created/updated/cancelled successfully
        status:
          type: string
          description: Status of the order
          example: Signatory Approval Pending
        code:
          type: string
          description:  Returns the code
          example: true
    CancelResponse:
      properties:
        orderId:
          type: string
          description: ID of the service request order created
          example: SR127REDFDSAS 
        message:
          type: string
          description: Specifies the text that provide more details and corrective
          example: Service Request update/cancellation successfully
        status:
          type: string
          description: Status of the order
          example: cancellation/Update Initiated
    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
        type_description:
          type: string
          description: Type Description
          example: Card
        subType_description:
          type: string
          description: Subtype Description
          example: Card
        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
        errorMessage:
          type: string
          description: Error Message from Fabric
          example: Nil
        additionalInfo:
          type: string
          description: Additional Info and Details from Fabric
          example: Operation was successfully completed with this additional info
        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'
        requestCreatedTime:
          type: string
          format: date
          description: Timestamp of request creation
          example: '2020-08-20T06:01:01.729Z'
        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
        actionPerformed:
          type: string
          description: Action Performed
          example: CREATE
    ServiceRequestResponse:
      properties:
        serviceReqs:
          type: array
          items:
            $ref: '#/components/schemas/ServiceRequestView'
          description: List of serviceReq
    ServiceRequestCriteria:
      properties:
        accountId:
          type: string
          description: ID of the service request order created
          example: SR127REDFDSAS 
        type:
          type: string
          description: Type ID
          example: Card
        subType:
          type: string
          description: Sub Type ID
          example: replaceCard
        status:
          type: string
          description: Status of the order
          example: REQUESTED
        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'
        partyId:
          type: string
          description: Party ID
          example: GB0010001-100100
        pageSize:
          type: string
          description: Page size
          example: 5
    ServiceRequestGetConfigRequest:
      properties:
        type:
          type: string
          description: Type ID
          example: Card
        subType:
          type: string
          description: Sub Type ID
          example: replaceCard
    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
        updateEnabled:
          type: boolean
          description: Indicates whether SR can be updated or not
          example: true  
        cancelEnabled:
          type: boolean
          description: Indicates whether SR can be updated or not
          example: true   
        updateEndPoint:
          type: string
          description: EndPoint/Command Name for a update ServiceReqConfig
          example: T24ISSTOPPAYMENTS_CREATECHEQUEBOOKREQUESTS 
        cancelEndPoint:
          type: string
          description: EndPoint/Command Name for a cancel ServiceReqConfig
          example: T24ISSTOPPAYMENTS_CREATECHEQUEBOOKREQUESTS
    ServiceReqConfigResponses:
      properties:
        serviceReqConfig:
          type: array
          items:
            $ref: '#/components/schemas/ServiceReqConfRequestItem'
    ServiceReqAttributeHistoryItem:
      properties:   
        serviceRequestId:
          type: string
          description: Service Request ID
          example: SR127REDFDSAS    
        version:
          type: string
          description: Version
          example: 1    
        action:
          type: string
          description: Action Perfomed
          example: cancel/udpate    
        changedPayload:
          type: object
          description: Key Value Pair of the previous Image
          example:
            chequeBookId: 5            
    SRAttributeHistoryResponse:
      properties:
        srAttributeRecords:
          type: array
          items:
            $ref: '#/components/schemas/ServiceReqAttributeHistoryItem'