[
  {
    "endpoint": "/api/payments",
    "method": "GET",
    "description": "Retrieve all payments.",
    "responses": {
      "200": { "$ref": "../examples/payments/list.200.json" },
      "403": { "$ref": "../examples/errors/403.json" }
    }
  },
  {
    "endpoint": "/api/payments/:id",
    "method": "GET",
    "description": "Retrieve a payment by ID.",
    "request": {
      "params": { "id": "integer" }
    },
    "responses": {
      "200": { "$ref": "../examples/payments/get.200.json" },
      "403": { "$ref": "../examples/errors/403.json" },
      "404": { "$ref": "../examples/errors/404.json" }
    }
  },
  {
    "endpoint": "/api/payments",
    "method": "POST",
    "description": "Create a new payment.",
    "request": {
      "body": {
        "invoice_id": "integer (required, must exist in invoices)",
        "payment_method": "string (required, enum: [mpesa, cash])",
        "payment_method_id": "integer (optional, must exist in MpesaTransactions or CashTransactions)"
      }
    },
    "responses": {
      "201": { "$ref": "../examples/payments/post.201.json" },
      "400": { "$ref": "../examples/errors/400.json" },
      "403": { "$ref": "../examples/errors/403.json" },
      "409": { "$ref": "../examples/errors/409.json" }
    }
  },
  {
    "endpoint": "/api/payments/:id",
    "method": "PUT",
    "description": "Update an existing payment.",
    "request": {
      "params": { "id": "integer" },
      "body": {
        "invoice_id": "integer (optional)",
        "payment_method": "string (optional, enum: [mpesa, cash])",
        "payment_method_id": "integer (optional)"
      }
    },
    "responses": {
      "200": { "$ref": "../examples/payments/put.200.json" },
      "400": { "$ref": "../examples/errors/400.json" },
      "403": { "$ref": "../examples/errors/403.json" },
      "404": { "$ref": "../examples/errors/404.json" }
    }
  },
  {
    "endpoint": "/api/payments/:id",
    "method": "DELETE",
    "description": "Delete a payment by ID.",
    "request": {
      "params": { "id": "integer" }
    },
    "responses": {
      "200": { "$ref": "../examples/payments/delete.200.json" },
      "403": { "$ref": "../examples/errors/403.json" },
      "404": { "$ref": "../examples/errors/404.json" }
    }
  }
]
