{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/simcloud-co-za/json-schema/simcloud-co-za-transaction-history-schema.json",
  "title": "TransactionHistory",
  "x-generated": "2026-11-24",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/simcloud-co-za-openapi.yaml#/components/schemas/TransactionHistory",
  "type": "object",
  "required": [
    "status",
    "date_from",
    "date_to",
    "type",
    "transactions",
    "pagination"
  ],
  "properties": {
    "status": {
      "type": "string",
      "enum": [
        "success"
      ]
    },
    "date_from": {
      "type": "string",
      "format": "date"
    },
    "date_to": {
      "type": "string",
      "format": "date"
    },
    "type": {
      "type": [
        "array",
        "null"
      ],
      "items": {
        "$ref": "#/$defs/TransactionService"
      },
      "description": "Active service filter, or null when all services are included."
    },
    "transactions": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/Transaction"
      }
    },
    "pagination": {
      "$ref": "#/$defs/TransactionPagination"
    }
  },
  "$defs": {
    "LocalTimestamp": {
      "type": "string",
      "description": "Local timestamp in Africa/Johannesburg, using YYYY-MM-DD HH:MM:SS."
    },
    "NullableLocalTimestamp": {
      "type": [
        "string",
        "null"
      ],
      "description": "Local timestamp in Africa/Johannesburg, using YYYY-MM-DD HH:MM:SS."
    },
    "Transaction": {
      "type": "object",
      "required": [
        "id",
        "service",
        "status",
        "reason",
        "reference",
        "created_at",
        "updated_at"
      ],
      "properties": {
        "id": {
          "type": "string"
        },
        "service": {
          "$ref": "#/$defs/TransactionService"
        },
        "status": {
          "type": "string",
          "enum": [
            "success",
            "failed",
            "pending"
          ]
        },
        "reason": {
          "type": [
            "string",
            "null"
          ]
        },
        "reference": {
          "type": "string"
        },
        "created_at": {
          "$ref": "#/$defs/LocalTimestamp"
        },
        "updated_at": {
          "$ref": "#/$defs/NullableLocalTimestamp"
        }
      }
    },
    "TransactionPagination": {
      "type": "object",
      "required": [
        "limit",
        "next_cursor"
      ],
      "properties": {
        "limit": {
          "type": "integer",
          "minimum": 1,
          "maximum": 100
        },
        "next_cursor": {
          "type": [
            "string",
            "null"
          ],
          "description": "Pass unchanged with the same dates and service filter. Null marks the last page."
        }
      }
    },
    "TransactionService": {
      "type": "string",
      "enum": [
        "airtime",
        "data",
        "electricity",
        "vas",
        "sms"
      ]
    }
  }
}