{
  "openapi": "3.0.0",
  "info": {
    "title": "KPRA RIMS API",
    "version": "1.0.0",
    "description": "Restaurant Invoice Monitoring System API for KPRA"
  },
  "servers": [
    {
      "url": "https://kpra.gov.pk/api"
    },
    {
      "url": "http://localhost:3000"
    }
  ],
  "paths": {
    "/rims-integration": {
      "post": {
        "summary": "Submit Invoice (Live API)",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/LiveInvoice"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Invoice Created",
            "content": {
              "application/json": {
                "$ref": "#/components/schemas/SuccessResponse"
              }
            }
          },
          "400": { "description": "Bad Request" },
          "401": { "description": "Unauthorized" },
          "500": { "description": "Server Error" }
        }
      }
    },
    "/api/invoice": {
      "post": {
        "summary": "Submit Invoice (Middleware)",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UtilityInvoice"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Invoice Accepted"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "LiveInvoice": {
        "type": "object",
        "required": [
          "ntn",
          "pos_id",
          "key",
          "invoice_no",
          "total_amount",
          "sales_tax",
          "tax_rate",
          "date"
        ],
        "properties": {
          "ntn": { "type": "string" },
          "pos_id": { "type": "string" },
          "key": { "type": "string" },
          "invoice_no": { "type": "string" },
          "total_amount": { "type": "number" },
          "sales_tax": { "type": "number" },
          "tax_rate": { "type": "number" },
          "date": { "type": "string", "format": "date-time" }
        }
      },
      "UtilityInvoice": {
        "type": "object",
        "required": [
          "ntn",
          "pos_id",
          "key",
          "invoice_no",
          "amount",
          "tax_rate",
          "tax_amount",
          "total_amount",
          "date_time"
        ],
        "properties": {
          "ntn": { "type": "string" },
          "pos_id": { "type": "string" },
          "key": { "type": "string" },
          "invoice_no": { "type": "string" },
          "amount": { "type": "number" },
          "tax_rate": { "type": "number" },
          "tax_amount": { "type": "number" },
          "total_amount": { "type": "number" },
          "date_time": { "type": "string", "format": "date-time" }
        }
      },
      "SuccessResponse": {
        "type": "object",
        "properties": {
          "status": { "type": "integer" },
          "message": { "type": "string" },
          "data": {
            "type": "object",
            "properties": {
              "transaction_id": { "type": "integer" },
              "invoice_no": { "type": "string" },
              "pos_id": { "type": "string" },
              "date_time": { "type": "string" }
            }
          }
        }
      }
    }
  }
}