<?php
require_once('config.php');

class APIGetPlemiumCardAuth extends System {

	/*-------------------------------------------------------------------------
	 * @ メンバ変数
	-------------------------------------------------------------------------*/
	private $signature		= NO_STRING;
	private $currency		= NO_STRING;
	private $userAccount	= NO_STRING;

	/*-------------------------------------------------------------------------
	 * @function_name: ロジックのコンストラクタ
	* @parameter	: なし
	* @return		: なし
	-------------------------------------------------------------------------*/
	function __construct() {
		ob_start();
		parent::__construct();
	}

	/*-------------------------------------------------------------------------
	 * @function_name: パスワードの更新
	* @parameter	: なし
	* @return		: なし
	-------------------------------------------------------------------------*/
	function action() {

		// 変数宣言部
		$rtn		= array();
		$currencies	= null;
		$tmp		= null;

		try {

			$url = "https://wcapi.wavecrest.in/v3/services/authenticator";

			$curl = curl_init($url); // 初期化！

			// オプション配列
			$options = array(
				CURLOPT_HTTPHEADER		=> array('Developerid'				=> '719u8zu4ghg3bvo73iqp'
													, 'Developerpassword'	=> 'Cathy@1111'
													, 'X-Method-Override'	=> 'login'
				)
				, CURLOPT_POST			=> true
				, CURLINFO_HEADER_OUT	=> true
			);

			curl_setopt_array($curl, $options);

			// リクエスト実行
			$result = curl_exec($curl);
			echo $result;

// 			curl_close($curl);

// 			$result = json_decode($body, true);

// 			$response = curl_getinfo($curl, CURLINFO_HEADER_OUT);
			echo $result;
			var_dump($result);

			$balanceUrl = 'https://wcapi.wavecrest.in:443/v3/services/users/1218675/cards/246654418652051/balance';

			$options = array(
					CURLOPT_URL				=> $balanceUrl
					, CURLOPT_HTTPHEADER	=> array('Developerid'				=> '719u8zu4ghg3bvo73iqp'
														, 'Developerpassword'	=> 'Cathy@1111'
														, 'X-Method-Override'	=> 'login'
														, 'AuthenticationToken'	=> '24We3DBEwd7uhONbeaa542b')
					, CURLOPT_HTTPGET		=> true
					, CURLINFO_HEADER_OUT	=> true
			);

			curl_setopt_array($curl, $options);

			// リクエスト実行
			$result = curl_exec($curl);
			echo $result;

			curl_close($curl);
		} catch (Exception $e) {
			$rtn = array('result'		=> 'NG'
					, 'messages'	=> $e -> getMessage());

			ob_end_clean();
			echo json_encode($rtn);
		}
	}

	/*-------------------------------------------------------------------------
	 * @function_name: エラーチェック
	* @parameter	: なし
	* @return		: なし
	-------------------------------------------------------------------------*/
	function validate() {

		// 変数宣言部
		$msgs = array();

		try {
		} catch (Exception $e) {
			throw  $e;
		}
	}
}

$api = new APIGetPlemiumCardAuth();
$api -> action();
?>
