openapi: 3.0.3
info:
  title: cx-debt-service-v1
  version: '1.0'
  description: An API to manage the debt of customers.
  contact:
    name: CS+
servers:
  - url: http://localhost:3000
tags:
  - name: debt-controller
paths:
  /{salesOrg}/debt/{customerId}:
    parameters:
      - $ref: '#/components/parameters/customerId'
      - $ref: '#/components/parameters/salesOrg'
    get:
      summary: Get Debt Info by Customer ID
      tags:
        - debt-controller
      responses:
        '200':
          $ref: '#/components/responses/Debt'
        '400':
          $ref: '#/components/responses/400'
      operationId: get-debt-by-customer-id
      description: Retrieve debt of the customer.
components:
  schemas:
    WithErrorCode-v1:
      title: Errors With Error Code
      type: object
      properties:
        title:
          type: string
          description: A short summary of the problem type. Written in English and readable for engineers, usually not suited for non technical stakeholders and not localized.
          example: Bad Request
        status:
          type: integer
          format: int32
          description: The HTTP status code generated by the origin server for this occurrence of the problem.
          minimum: 100
          example: 400
        detail:
          type: string
          description: A human readable explanation specific to this occurrence of the problem that is helpful to locate the problem and give advice on how to proceed. Written in English and readable for engineers, usually not suited for non technical stakeholders and not localized.
          example: 'Customer: ''620069'' not found'
        errorCode:
          type: string
          description: The error code of this problem
          example: CSP-001
        errorMessage:
          type: string
          description: Brief message about the error. It is usually key message beside errorCode for client to identify the problem.
        errorMetadata:
          type: object
          description: Specific metadata for the error code
      required:
        - title
        - status
        - detail
        - errorCode
    Debt-v1:
      title: debt-v1
      x-stoplight:
        id: 76zt5llavdt8n
      type: object
      description: The debt of a certain customer
      properties:
        amount:
          type: number
          description: the amount of the debt
        comment:
          type: string
          description: a comment about the debt
        modifiedAt:
          type: string
          format: date-time
          description: the last time the debt was updated
  responses:
    '400':
      description: |-
        Possible outcome with status code 400:
         - DEB-001 - SalesOrg is not available
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/WithErrorCode-v1'
    Debt:
      description: The debt of a customer.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Debt-v1'
          examples: {}
  parameters:
    salesOrg:
      name: salesOrg
      in: path
      required: true
      schema:
        type: string
        minLength: 4
        maxLength: 4
      description: The sales org.
    customerId:
      name: customerId
      in: path
      required: true
      schema:
        type: string
      description: The id of customer to retrieve the debt.
x-stoplight:
  id: 84w2h6xzrddki
