<?php
include 'common.php';

include 'wallet_common.php';

$wallet_id = $_GET["user_id"];
$curl_response = get(WALLET_API_URL.'/is_tx_available', array(
		'wallet_id' => $wallet_id));		

//echo $curl_response ;

 //crystal to token
 $min_crystal_amount = MIN_EXCHANGE_CRYSTAL_AMOUNT;
 $max_crystal_amount = MAX_EXCHANGE_CRYSTAL_AMOUNT;

 //token to crystal
 $min_token_amount = MIN_EXCHANGE_CRYSTAL_AMOUNT;
 $max_token_amount = MAX_EXCHANGE_CRYSTAL_AMOUNT;

 $exchange_rate_crystal_to_token = EXCHANGE_RATE_CRYSTAL_TO_TOKEN;
 $exchange_rate_token_to_crystal = EXCHANGE_RATE_TOKEN_TO_CRYSTAL;

$response = "WALLET_IS_UNAVAILABLE";
$error = "";
if($curl_response == "available")
{
	$response = "WALLET_IS_AVAILABLE";
}
else
{
	$response = "WALLET_IS_UNAVAILABLE";
	$error = "Wallet is not available";
}



$isXmlHttpRequest = (isset($_SERVER['HTTP_X_REQUESTED_WITH'])) ?
(strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') ? true : false: false;
($isXmlHttpRequest) ? header('Content-type: application/json') : header('Content-type: text/plain');
 
echo json_encode(array('result'=>$response,'error'=>$error, 'exchange_rate_crystal_to_token'=>$exchange_rate_crystal_to_token, 'exchange_rate_token_to_crystal'=>$exchange_rate_token_to_crystal, 'min_crystal_amount'=>$min_crystal_amount,'max_crystal_amount'=>$max_crystal_amount, 'min_token_amount'=>$min_token_amount,'max_token_amount'=>$max_token_amount));

	

?>