{
    "$schema": "http://json-schema.org/draft-07/schema#",
    "$id": "https://developers.tulus.my/schema/adb.json",
    "title": "ADB Transactions Schema",
    "description": "Schema for ADB transaction data structure",
    "type": "object",
    "properties": {
        "$schema": {
            "type": "string",
            "description": "JSON Schema reference"
        },
        "transactions": {
            "type": "array",
            "description": "Array of transaction records",
            "items": {
                "type": "object",
                "properties": {
                    "agency": {
                        "type": "string",
                        "enum": [
                            "ADB",
                            "ADBLZS",
                            "ADBPPZ"
                        ],
                        "description": "Ignored by the server: send 'ADB'. Tulus files each payment under the zakat board itself, from the order number and data.zakat_type / data.zakat_state (see https://developers.tulus.my/adb/). The other values remain valid for compatibility."
                    },
                    "orderno": {
                        "type": "string",
                        "description": "Unique order number for the transaction"
                    },
                    "amount": {
                        "type": "number",
                        "minimum": 0,
                        "description": "Transaction amount in RM"
                    },
                    "name": {
                        "type": "string",
                        "description": "Customer name"
                    },
                    "email": {
                        "type": "string",
                        "format": "email",
                        "description": "Customer email address"
                    },
                    "time": {
                        "type": "string",
                        "format": "date-time",
                        "description": "Transaction timestamp in ISO 8601 format"
                    },
                    "status": {
                        "type": "string",
                        "enum": [
                            "success",
                            "pending",
                            "failed"
                        ],
                        "description": "Transaction status"
                    },
                    "data": {
                        "type": "object",
                        "description": "Additional optional data",
                        "properties": {
                            "email": {
                                "type": "string",
                                "format": "email",
                                "description": "Email from data object"
                            },
                            "zakat_name": {
                                "type": "string",
                                "description": "Name for zakat payment"
                            },
                            "zakat_ic_no": {
                                "type": "string",
                                "description": "MyKad number for Malaysian citizen (12 digits)"
                            },
                            "zakat_state": {
                                "type": "string",
                                "enum": [
                                    "johor",
                                    "kedah",
                                    "kelantan",
                                    "melaka",
                                    "negeri_sembilan",
                                    "pahang",
                                    "pulau_pinang",
                                    "perak",
                                    "perlis",
                                    "sabah",
                                    "sarawak",
                                    "selangor",
                                    "terengganu",
                                    "kuala_lumpur",
                                    "labuan",
                                    "putrajaya"
                                ],
                                "description": "Malaysian state for zakat payment"
                            },
                            "zakat_type": {
                                "type": "string",
                                "enum": [
                                    "fitrah",
                                    "zakat_emas",
                                    "zakat_fitrah",
                                    "zakat_kwsp",
                                    "zakat_padi",
                                    "zakat_pendapatan",
                                    "zakat_perak",
                                    "zakat_perniagaan",
                                    "zakat_pertanian",
                                    "zakat_qada",
                                    "zakat_rikaz",
                                    "zakat_saham",
                                    "zakat_simpanan",
                                    "zakat_ternakan"
                                ],
                                "description": "Type of zakat payment"
                            },
                            "zakat_year": {
                                "type": "string",
                                "pattern": "^[0-9]{4}$",
                                "description": "Year for zakat payment"
                            },
                            "zakat_phone": {
                                "type": "string",
                                "pattern": "^[0-9]{10,12}$",
                                "description": "Phone number for zakat payment"
                            },
                            "zakat_address": {
                                "type": "string",
                                "description": "Address for zakat payment"
                            },
                            "zakat_postcode": {
                                "type": "string",
                                "pattern": "^[0-9]{5}$",
                                "description": "Postcode for zakat payment"
                            },
                            "zakat_city": {
                                "type": "string",
                                "description": "City for zakat payment"
                            },
                            "zakat_amount": {
                                "type": "string",
                                "pattern": "^[0-9]+(\\.?[0-9]{1,2})?$",
                                "description": "Zakat amount as string"                            },
                            "zakat_rate": {
                                "type": "string",
                                "description": "Rice price per kg for Zakat Fitrah (e.g., \"7\", \"10\"). Applicable for Zakat Fitrah only. The transaction amount equals zakat_rate multiplied by zakat_dependant."
                            },
                            "zakat_dependant": {
                                "type": "string",
                                "description": "Number of dependants for Zakat Fitrah payment (e.g., \"1\", \"4\"). Applicable for Zakat Fitrah only. The transaction amount equals zakat_rate multiplied by zakat_dependant."                            }
                        },
                        "additionalProperties": true
                    }
                },
                "required": [
                    "agency",
                    "orderno",
                    "amount",
                    "name",
                    "email",
                    "time",
                    "status",
                    "data"
                ],
                "additionalProperties": false
            }
        }
    },
    "required": [
        "transactions"
    ],
    "additionalProperties": false
}