<?php

/*
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

$keyregex = "/[a-z0-9]{64}/";

$APIS = [
    "ping" => [
        "load" => "ping.php",
        "insecure" => true,
        "vars" => [
        ]
    ],
    "signup" => [
        "load" => "addaccount.php",
        "insecure" => true,
        "vars" => [
            "username" => "string",
            "password" => "string",
            "accttype" => "/(giver|receiver)/"
        ]
    ],
    "getkey" => [
        "load" => "getkey.php",
        "insecure" => true,
        "vars" => [
            "OR user" => [
                "username" => "/[a-zA-Z0-9]+/",
                "email" => "/.+/",
                "phone" => "/[0-9]{10,}/"
            ],
            "OR pass" => [
                "password (optional)" => "string",
                "pin (optional)" => "/[0-9]{4,10}"
            ]
        ]
    ],
    "checkkey" => [
        "load" => "checkkey.php",
        "vars" => [
            "key" => $keyregex
        ]
    ],
    "checkbalance" => [
        "load" => "balance.php",
        "vars" => [
            "key" => $keyregex
        ]
    ],
    "sendmoney" => [
        "load" => "send.php",
        "vars" => [
            "key" => $keyregex,
            "to" => "/[0-9a-z]+/",
            "amount" => "/[0-9]{1,4}(\.[0-9]{2})?/"
        ]
    ],
    "getprofile" => [
        "load" => "getprofile.php",
        "vars" => [
            "key" => $keyregex,
            "id (optional)" => "/[0-9a-z]+/"
        ]
    ],
    "setprofile" => [
        "load" => "setprofile.php",
        "vars" => [
            "key" => $keyregex,
            "name (optional)" => "string",
            "bio (optional)" => "string"
        ]
    ],
    "getnearby" => [
        "load" => "nearby.php",
        "vars" => [
            "key" => $keyregex,
            "latitude" => "/-?[0-9]{2}\.[0-9]+/",
            "longitude" => "/-?[0-9]{2,3}\.[0-9]+/",
            "radius (optional)" => "/[0-9]*\.?[0-9]+/",
            "format (optional)" => "/(geojson)/"
        ]
    ],
    "getmerchants" => [
        "load" => "merchants.php",
        "vars" => [
            "key" => $keyregex,
            "latitude" => "/-?[0-9]{2}\.[0-9]+/",
            "longitude" => "/-?[0-9]{2,3}\.[0-9]+/",
            "radius (optional)" => "/[0-9]*\.?[0-9]+/",
            "format (optional)" => "/(geojson)/"
        ]
    ],
    "broadcast" => [
        "load" => "broadcast.php",
        "vars" => [
            "key" => $keyregex,
            "latitude" => "/-?[0-9]{2}\.[0-9]+/",
            "longitude" => "/-?[0-9]{2,3}\.[0-9]+/"
        ]
    ],
    "addfunds" => [
        "load" => "addfunds.php",
        "vars" => [
            "key" => $keyregex,
            "amount" => "/[0-9]{1,4}(\.[0-9]{2})?/",
            "token" => "string"
        ]
    ],
    "gettxcode" => [
        "load" => "gettxcode.php",
        "vars" => [
            "key" => $keyregex,
            "amount" => "/[0-9]{1,4}(\.[0-9]{2})?/"
        ]
    ],
    "gettxstatus" => [
        "load" => "gettxstatus.php",
        "vars" => [
            "key" => $keyregex,
            "txcode" => "/[0-9a-z]+/"
        ]
    ],
];
