<?php
require_once('../../vendor/autoload.php');
require_once('../init.php');

function error_res($status, $response_code, $message)
{
    return "{
        'status': $status,
        'response_code': '$response_code',
        'message': '$message',
        }";
}

if (isset($_SESSION['user_id'])) {

    $user = User::find_by_id($_SESSION['user_id']);
    if ($user) {

        $my_wallet = Wallet::find_by_query("SELECT * FROM wallet WHERE user_id =" . $user->id . " LIMIT 1");
        $my_wallet = array_shift($my_wallet);
        $my_wallet_balance = intval($my_wallet->balance);
        echo $my_wallet_balance;
    }
} else {
    echo error_res(false, "03", "Contact Administrator!");
    exit;
}