openapi: 3.0.3
info:
  title: Order Module
  description: Lists all operations possible in this module
  version: 1.0.0
paths:
  /event/async:
    post:
      requestBody:
        content:
          application/json:
            schema:
              oneOf:
                - $ref: '#/components/schemas/add-payment-transaction'

      responses:
        200:
          description: "Successful Operation"
        401:
          description: "Authorization Error - Invalid Bearer Token / No permission"
        400:
          description: "Client Error - Bad Request"

components:
  schemas:
    add-payment-transaction:
      description: Adds a payment transaction to an existing order
      type: object
      required: [
          "name", "retailer-id", "entity-ref", "entity-type", "entity-subtype", "root-entity-ref", "root-entity-type", "attributes"
      ]
      properties:
        name:
          type: string
          nullable: false
          default: "order::add-payment-transaction"
        retailer-id:
          type: string
          nullable: false
          example: "1"
        entity-ref:
          type: string
          nullable: false
          example: "PC:MASTER:<retailer_id>"
        entity-type:
          type: string
          nullable: false
          enum:
            - PRODUCT_CATALOGUE
        entity-subtype:
          type: string
          nullable: false
          example: "MASTER"
        root-entity-ref:
          type: string
          nullable: false
          example: "PC:MASTER:<retailer_id>"
        root-entity-type:
          type: string
          nullable: false
          enum:
            - PRODUCT_CATALOGUE
        attributes:
          type: object
          nullable: false
          properties:
            product:
              $ref: '#/components/schemas/payment-transaction'

    payment-transaction:
      description: Order Payment Transaction
      required: [
          "ref", "amount", "payment-service-provider-ref", "payment-method"
      ]
      properties:
        ref:
          type: string
          description: The reference identifier used to identify the payment transaction
          nullable: false
        type:
          type: string
          description: Type of the payment
          nullable: false
        status:
          type: string
          description: Status of the payment
          nullable: true
        amount:
          type: number
          format: double
          description: Transaction Amount
          nullable: true
        currency-code:
          type: string
          description: Transaction currency in ISO format
          nullable: true
        payment-ref:
          type: string
          description: TODO
          nullable: true
        payment-service-provider-ref:
          type: string
          description: Payment provider ID
          nullable: true
        authorization-key:
          type: string
          description: TODO
          nullable: true
        card-type:
          type: string
          description: Cart type
          nullable: true
        payment-method:
          type: string
          nullable: true
        attributes:
          type: array
          description: Additional attributes of the category
          items:
            $ref: '#/components/schemas/attribute'

    attribute:
      type: object
      required: [
          "value", "name", "type"
      ]
      properties:
        name:
          type: string
          nullable: false
        type:
          type: string
          nullable: false
        value:
          type: string
          nullable: false
