<?php

namespace Encgateway;

class GetCardTrx extends ApiResource {
	
	public static $data = array(); 
	
	public static $processors = "GetCardTrx";
	
	public static function validParams($param){
		
		$Allparam = array('UserName','Password','RPNum','BeginDt','EndDt','PaymentType','ExcludePaymentType','TransType','ExcludeTransType','ApprovalCode','Result','ExcludeResult','NameOnCard','CardNum','CardType','ExcludeCardType','ExcludeVoid','User','InvoiceId','SettleFlag','SettleMsg','SettleDt','TransformType','Xsl','Format');
	  
	  $required = array('UserName','Password','ExcludeVoid','BeginDt','EndDt');
		
		$is_valid = GUMP::is_valid($param, array(
			'UserName' => 'required',
			'Password' => 'required',
			'ExcludeVoid' => 'required',
			'BeginDt' => 'required|date',
			'EndDt' => 'required|date'
		));
		
		return $is_valid;
	}
	
	public static function create($params = null)
    {	
		self::$data['params'] 	= $params;
		self::$data['success'] 	= 0;
		self::$data['error'] 	= '';
		if(self::_validateArray($params)){
			if(Apib::getApiKey()) {
				$params['ApiToken'] = Apib::getApiKey();
			}
			$ret = self::validParams($params);
			if($ret == 1){
				$response = self::_doTrans($params,self::$processors);
				self::$data['response'] = $response; 
				if(count($response) >= 1) : 
					self::$data['success'] = 1;
				endif;
			}else{
				self::$data['error'] = $ret;
			}
		}else{
			self::$data['error']['invalid_argument'] = 'Array is not valid, You must pass array is argument.';
		}
		
		self::$data = self::responseFormat(self::$data,Apib::getOutputFormat());
		return self::$data;
    }
}