<?php

//declare(strict_types=1);

/**



 *  SensFRX Main Class of App



 *



 */



namespace SensFRX;



use SensFRX\Login\LoginLogs;

use SensFRX\Transaction\TransactionLogs;

use SensFRX\OrderUpdate\OrderUpdateLogs;

use SensFRX\Login\ResetPasswordLogs;

use SensFRX\Update\UpdateLogs;

use SensFRX\Register\RegisterLogs;

use SensFRX\Common\ApiCalls;

use SensFRX\Common\ErrorMessage;

use SensFRX\Device\DeviceManage;

use SensFRX\Profile\Profile;

use SensFRX\Privacy\Privacy;

use SensFRX\Plugin\Plugin;

use SensFRX\Shadow\Shadow;

use SensFRX\Redirect\Redirect;

use SensFRX\PropertySecrets\PropertySecrets;

use SensFRX\Itemslug\Itemslug;

use SensFRX\TransReview\TransReview;

use SensFRX\AccountReview\AccountReview;

use SensFRX\Stats\Stats;

use SensFRX\Alerts\Alerts;

use SensFRX\License\License;

use SensFRX\FraudRate\FraudRate;

use SensFRX\ReviewCount\ReviewCount;

use SensFRX\RecentAlert\RecentAlert;

use SensFRX\Rules\Rules;

use SensFRX\ImprtExport\ImprtExport;

use SensFRX\AdvanceRules\AdvanceRules;

use SensFRX\BlackList\BlackList;

use SensFRX\WhiteList\WhiteList;

use SensFRX\Bot\Bot;

use SensFRX\WebHook\WebHook;



/**

 * Class SensFRX

 *

 * @package SensFRX

 */



class SensFRX {



	/**

	 * Version number of the SensFRX PHP SDK.

	 * 

	 * @const string Version number of the SensFRX PHP SDK.

	 */



	const VERSION = '1.2.0';



	/**

	 * App ID of the SensFRX PHP SDK.

	 * 

	 * @const string The name of the environment variable that contains the app ID.

	 */



	const APP_ID_ENV_NAME = 'AUTHSAFE_APP_ID';



	/**

	 * App Secret of the SensFRX PHP SDK.

	 * 

	 * @const string The name of the environment variable that contains the app secret.

	 */



	const APP_SECRET_ENV_NAME = 'AUTHSAFE_APP_SECRET';



	/**

	 * SensFRXApp of the SensFRX PHP SDK.

	 * 

	 * @var SensFRXApp The SensFRXApp entity.

	 */



	protected $app;



	/**

	 * Instantiates a new SensFRX super-class object.

	 *

	 * @param array $config

	 *

	 * @throws SensFRXSDKException

	 */



	public $objAPI;

	public $apiUrl;

	public $loginLog;

	public $transactionLog;

	public $orderUpdateLog;

	public $resetPasswordLog;

	public $updateLog;

	public $registerLog;

	public $botLog;

	public $TransReviewObj;

	public $AccountReviewObj;

	public $ReviewCountObj;

	public $RecentAlertObj;

	public $RulesObj;

	public $AdvanceRulesObj;

	public $BlackListtObj;

	public $WhiteListtObj;

	public $StatsObj;

	public $AlertsObj;

	public $ImportExportObj;

	public $PluginObj;

	public $PrivacyObj;

	public $ProfileObj;

	public $deviceManage;

	public $ItemslugObj;

	public $webHook;

	public $ShadowObj;

	public $RedirectObj;

	public $PropertySecretsObj;

	public $LicenseObj;

	public $FraudRateObj;

	public $OAuthObj;



	public function __construct(array $config = []) {



		$msg = array();



		$a = new ErrorMessage();



		$this->apiUrl = 'https://a.sensfrx.ai/v1';



		$config = array_merge([



			'property_id' => getenv(static::APP_ID_ENV_NAME),



			'property_secret' => getenv(static::APP_SECRET_ENV_NAME),



			'api_url' => $this->apiUrl



		], $config);



		$this->objAPI = new ApiCalls($config['property_id'], $config['property_secret'], $config['api_url']);



		$this->loginLog = new LoginLogs($this->objAPI);



		$this->transactionLog = new TransactionLogs($this->objAPI);



		$this->orderUpdateLog = new OrderUpdateLogs($this->objAPI);



		$this->resetPasswordLog = new ResetPasswordLogs($this->objAPI);



		$this->updateLog = new UpdateLogs($this->objAPI);



		$this->registerLog = new RegisterLogs($this->objAPI);



		$this->ProfileObj = new Profile($this->objAPI);



		$this->PrivacyObj = new Privacy($this->objAPI);



		$this->PluginObj = new Plugin($this->objAPI);



		$this->ShadowObj = new Shadow($this->objAPI);



		$this->RedirectObj = new Redirect($this->objAPI);



		$this->PropertySecretsObj = new PropertySecrets($this->objAPI);



		$this->OAuthObj = new OAuth\OAuth($this->objAPI);



		$this->ItemslugObj = new Itemslug($this->objAPI);



		$this->TransReviewObj = new TransReview($this->objAPI);



		$this->AccountReviewObj = new AccountReview($this->objAPI);



		$this->StatsObj = new Stats($this->objAPI);



		$this->AlertsObj = new Alerts($this->objAPI);



		$this->LicenseObj = new License($this->objAPI);



		$this->FraudRateObj = new FraudRate($this->objAPI);



		$this->ReviewCountObj = new ReviewCount($this->objAPI);



		$this->RecentAlertObj = new RecentAlert($this->objAPI);



		$this->RulesObj = new Rules($this->objAPI);



		$this->ImportExportObj = new ImprtExport($this->objAPI);



		$this->AdvanceRulesObj = new AdvanceRules($this->objAPI);



		$this->BlackListtObj = new BlackList($this->objAPI);



		$this->WhiteListtObj = new WhiteList($this->objAPI);



		$this->botLog = new Bot($this->objAPI);



		$this->deviceManage = new DeviceManage($this->objAPI);



		$this->webHook = new WebHook($this->objAPI);



		if (empty($config['property_id']) || !isset($config['property_id'])) {



			$msg['status'] = 'error';



			$erno = 0;



			$msg['message'] = $a->errormsg($erno);



			return $msg;



		}



		if (empty($config['property_secret']) || !isset($config['property_secret'])) {



			$msg['status'] = 'error';



			$erno = 0;



			$msg['message'] = $a->errormsg($erno);



			return $msg;



		}



	}



	public function loginAttempt($loginEvent,$userId = null,$deviceId = null,$userExtras = array()) {



		$b = new ErrorMessage();



		if (empty($loginEvent) || !isset($loginEvent)) {



			$msg['status'] = 'error';



			$erno = 1;



			$msg['message'] = $b->errormsg($erno);



			return $msg;



		}



		if ( ( 'login_success' == $loginEvent ) && ( empty($userId) || !isset($userId) ) ) {



			$msg['status'] = 'error';



			$erno = 1;



			$msg['message'] = $b->errormsg($erno);



			return $msg;



		}



		return $this->loginLog->loginLog($loginEvent, $userId, $deviceId, $userExtras);



	}



	public function transactionAttempt($transactionEvent,$deviceId = null,$transactionExtras = array()) {



		$b = new ErrorMessage();



		if (empty($transactionEvent) || !isset($transactionEvent)) {



			$msg['status'] = 'error';



			$erno = 1;



			$msg['message'] = $b->errormsg($erno);



			return $msg;



		}



		return $this->transactionLog->transactionLog($transactionEvent, $deviceId, $transactionExtras);



	}



	public function orderUpdate($orderUpdateEvent, $orderOex, $deviceId = null, $ordertfs = array()) {



		$b = new ErrorMessage();



		if (empty($orderUpdateEvent) || !isset($orderUpdateEvent)) {



			$msg['status'] = 'error';



			$erno = 1;



			$msg['message'] = $b->errormsg($erno);



			return $msg;



		}



		return $this->orderUpdateLog->orderUpdateLog($orderUpdateEvent, $orderOex, $deviceId, $ordertfs);



	}



	public function registerAttempt($registerEvent,$deviceId = null,$registerFields = array()) {



		$b = new ErrorMessage();



		if (empty($registerEvent) || !isset($registerEvent)) {



			$msg['status'] = 'error';



			$erno = 1;



			$msg['message'] = $b->errormsg($erno);



			return $msg;



		}



		if (count($registerFields) == 0) {



			$msg['status'] = 'error';



			$erno = 1;



			$msg['message'] = $b->errormsg($erno);



			return $msg;



		}



		return $this->registerLog->registerLog($registerEvent, $deviceId, $registerFields);



	}



	public function passwordResetAttempt($resetPasswordEvent,$userId = null,$deviceId = null,$userExtras = array()) {



		$b = new ErrorMessage();



		if (empty($resetPasswordEvent) || !isset($resetPasswordEvent)) {



			$msg['status'] = 'error';



			$erno = 1;



			$msg['message'] = $b->errormsg($erno);



			return $msg;



		}



		if ( ( 'reset_password_success' == $resetPasswordEvent ) && ( empty($userId) || !isset($userId) ) ) {



			$msg['status'] = 'error';



			$erno = 1;



			$msg['message'] = $b->errormsg($erno);



			return $msg;



		}



		return $this->resetPasswordLog->resetPasswordLog($resetPasswordEvent, $userId, $deviceId, $userExtras);



	}



	public function updateAttempt($updateEvent,$userId = null,$deviceId = null,$userExtras = array()) {



		$b = new ErrorMessage();



		if (empty($updateEvent) || !isset($updateEvent)) {



			$msg['status'] = 'error';



			$erno = 1;



			$msg['message'] = $b->errormsg($erno);



			return $msg;



		}



		return $this->updateLog->updateLog($updateEvent, $userId, $deviceId, $userExtras);



	}



	public function approveDevice($deviceId) {



		$b = new ErrorMessage();



		if (empty($deviceId) || !isset($deviceId) ) {



			$msg['status'] = 'error';



			$erno = 1;



			$msg['message'] = $b->errormsg($erno);



			return $msg;



		}



		return $this->deviceManage->deviceManage($deviceId, 'approve');



	}



	public function denyDevice($deviceId) {



		$b = new ErrorMessage();



		if (empty($deviceId) || !isset($deviceId)) {



			$msg['status'] = 'error';



			$erno = 1;



			$msg['message'] = $b->errormsg($erno);



			return $msg;



		}



		return $this->deviceManage->deviceManage($deviceId, 'deny');



	}



	public function getUserDevices($userId) {



		$b = new ErrorMessage();



		if (empty($userId) || !isset($userId)) {



			$msg['status'] = 'error';



			$erno = 1;



			$msg['message'] = $b->errormsg($erno);



			return $msg;



		}



		return $this->deviceManage->getUserDevices($userId);



	}



	public function addWebHook($url) {



		$b = new ErrorMessage();



		if (empty($url) || !isset($url)) {



			$msg['status'] = 'error';



			$erno = 1;



			$msg['message'] = $b->errormsg($erno);



			return $msg;



		}



		if (!filter_var($url, FILTER_VALIDATE_URL)) {



			$msg['status'] = 'error';



			$erno = 3;



			$msg['message'] = $b->errormsg($erno);



			return $msg;



		}



		return $this->webHook->addWebHook($url);



	}



	public function getprofileinfo() {



		return $this->ProfileObj->getProfile();



	}



	public function postprofileinfo($EditFields = array()) {



		$b = new ErrorMessage();



		if (empty($EditFields) || !isset($EditFields)) {



			$msg['status'] = 'error';



			$erno = 1;



			$msg['message'] = $b->errormsg($erno);



			return $msg;



		}



		if (count($EditFields) == 0) {



			$msg['status'] = 'error';



			$erno = 1;



			$msg['message'] = $b->errormsg($erno);



			return $msg;



		}



		return $this->ProfileObj->postProfile($EditFields);



	}



	public function getalertsinfo() {



		return $this->AlertsObj->getAlerts();



	}



	public function postalertsinfo($EditFields = array()) {



		$b = new ErrorMessage();



		if (empty($EditFields) || !isset($EditFields)) {



			$msg['status'] = 'error';



			$erno = 1;



			$msg['message'] = $b->errormsg($erno);



			return $msg;



		}



		if (count($EditFields) == 0) {



			$msg['status'] = 'error';



			$erno = 1;



			$msg['message'] = $b->errormsg($erno);



			return $msg;



		}



		return $this->AlertsObj->postAlerts($EditFields);



	}



	public function getprivacyinfo() {



		return $this->PrivacyObj->getPrivacy();



	}



	public function postprivacyinfo($EditFields = array()) {



		$b = new ErrorMessage();



		if (empty($EditFields) || !isset($EditFields)) {



			$msg['status'] = 'error';



			$erno = 1;



			$msg['message'] = $b->errormsg($erno);



			return $msg;



		}



		if (count($EditFields) == 0) {



			$msg['status'] = 'error';



			$erno = 1;



			$msg['message'] = $b->errormsg($erno);



			return $msg;



		}



		return $this->PrivacyObj->postPrivacy($EditFields);



	}



	public function integrateplugininfo($Fields = array()) {



		$b = new ErrorMessage();



		if (empty($Fields) || !isset($Fields)) {



			$msg['status'] = 'error';



			$erno = 1;



			$msg['message'] = $b->errormsg($erno);



			return $msg;



		}



		if (count($Fields) == 0) {



			$msg['status'] = 'error';



			$erno = 1;



			$msg['message'] = $b->errormsg($erno);



			return $msg;



		}



		return $this->PluginObj->integratePlugin($Fields);



	}



	public function uninstallplugininfo($Fields = array()) {



		$b = new ErrorMessage();



		if (empty($Fields) || !isset($Fields)) {



			$msg['status'] = 'error';



			$erno = 1;



			$msg['message'] = $b->errormsg($erno);



			return $msg;



		}



		if (count($Fields) == 0) {



			$msg['status'] = 'error';



			$erno = 1;



			$msg['message'] = $b->errormsg($erno);



			return $msg;



		}



		return $this->PluginObj->uninstallPlugin($Fields);



	}



	public function getItem_sluginfo() {



		return $this->ItemslugObj->getItem_slug();



	}



	public function getTrans_Review() {



		return $this->TransReviewObj->getTransReview();



	}



	public function getAccount_Review() {



		return $this->AccountReviewObj->getAccountReview();



	}



	public function postTrans_Review($trans_review_fields) {



		$b = new ErrorMessage();



		if (empty($trans_review_fields) || !isset($trans_review_fields)) {



			$msg['status'] = 'error';



			$erno = 1;



			$msg['message'] = $b->errormsg($erno);



			return $msg;



		}



		if (count($trans_review_fields) == 0) {



			$msg['status'] = 'error';



			$erno = 1;



			$msg['message'] = $b->errormsg($erno);



			return $msg;



		} 



		return $this->TransReviewObj->postTransReview($trans_review_fields);



	}



	public function postAccount_Review($account_review_fields) {



		$b = new ErrorMessage();



		if (empty($account_review_fields) || !isset($account_review_fields)) {



			$msg['status'] = 'error';



			$erno = 1;



			$msg['message'] = $b->errormsg($erno);



			return $msg;



		}



		if (count($account_review_fields) == 0) {



			$msg['status'] = 'error';



			$erno = 1;



			$msg['message'] = $b->errormsg($erno);



			return $msg;



		} 



		return $this->AccountReviewObj->postAccountReview($account_review_fields);



	}



	public function getshadowinfo() {



		return $this->ShadowObj->getShadow();



	}



	public function redirectBefore() {



		return $this->RedirectObj->getRedirectBefore();



	}



	public function getPropertySecrets($pid) {



		return $this->PropertySecretsObj->getPropertySecretsCall($pid);



	}



	public function postPropertySecrets($EditFields = array()) {



		$b = new ErrorMessage();



		if (empty($EditFields) || !isset($EditFields)) {



			$msg['status'] = 'error';



			$erno = 1;



			$msg['message'] = $b->errormsg($erno);



			return $msg;



		}



		if (count($EditFields) == 0) {



			$msg['status'] = 'error';



			$erno = 1;



			$msg['message'] = $b->errormsg($erno);



			return $msg;



		}



		return $this->PropertySecretsObj->postPropertySecretsCall($EditFields);



	}



	public function oauthSendOtp($EditFields = array()) {



		$b = new ErrorMessage();



		if (empty($EditFields) || !isset($EditFields)) {



			$msg['status'] = 'error';



			$erno = 1;



			$msg['message'] = $b->errormsg($erno);



			return $msg;



		}



		if (count($EditFields) == 0) {



			$msg['status'] = 'error';



			$erno = 1;



			$msg['message'] = $b->errormsg($erno);



			return $msg;



		}



		return $this->OAuthObj->oauthSendOtp($EditFields);



	}



	public function oauthVerifyOtp($EditFields = array()) {



		$b = new ErrorMessage();



		if (empty($EditFields) || !isset($EditFields)) {



			$msg['status'] = 'error';



			$erno = 1;



			$msg['message'] = $b->errormsg($erno);



			return $msg;



		}



		if (count($EditFields) == 0) {



			$msg['status'] = 'error';



			$erno = 1;



			$msg['message'] = $b->errormsg($erno);



			return $msg;



		}



		return $this->OAuthObj->oauthVerifyOtp($EditFields);



	}



	public function oauthResendOtp($EditFields = array()) {



		$b = new ErrorMessage();



		if (empty($EditFields) || !isset($EditFields)) {



			$msg['status'] = 'error';



			$erno = 1;



			$msg['message'] = $b->errormsg($erno);



			return $msg;



		}



		if (count($EditFields) == 0) {



			$msg['status'] = 'error';



			$erno = 1;



			$msg['message'] = $b->errormsg($erno);



			return $msg;



		}



		return $this->OAuthObj->oauthResendOtp($EditFields);



	}



	public function oauthRegister($EditFields = array()) {



		$b = new ErrorMessage();



		if (empty($EditFields) || !isset($EditFields)) {



			$msg['status'] = 'error';



			$erno = 1;



			$msg['message'] = $b->errormsg($erno);



			return $msg;



		}



		if (count($EditFields) == 0) {



			$msg['status'] = 'error';



			$erno = 1;



			$msg['message'] = $b->errormsg($erno);



			return $msg;



		}



		return $this->OAuthObj->oauthRegister($EditFields);



	}



	public function postshadowinfo($EditFields = array()) {



		$b = new ErrorMessage();



		if (empty($EditFields) || !isset($EditFields)) {



			$msg['status'] = 'error';



			$erno = 1;



			$msg['message'] = $b->errormsg($erno);



			return $msg;



		}



		if (count($EditFields) == 0) {



			$msg['status'] = 'error';



			$erno = 1;



			$msg['message'] = $b->errormsg($erno);



			return $msg;



		}



		return $this->ShadowObj->postShadow($EditFields);



	}



	public function getlicenseinfo() {



		return $this->LicenseObj->getLicense();



	}



	public function getFraudRateInfo() {



		return $this->FraudRateObj->getFraudRate();



	}



	public function getAllFraudTrans($DateFilter = array()) {



		$b = new ErrorMessage();



		if (empty($DateFilter) || !isset($DateFilter)) {



			$msg['status'] = 'error';



			$erno = 1;



			$msg['message'] = $b->errormsg($erno);



			return $msg;



		}



		if (count($DateFilter) == 0) {



			$msg['status'] = 'error';



			$erno = 1;



			$msg['message'] = $b->errormsg($erno);



			return $msg;



		}



		return $this->FraudRateObj->getTransAllFraud($DateFilter);



	}



	public function getAllFraudReg($DateFilter = array()) {



		$b = new ErrorMessage();



		if (empty($DateFilter) || !isset($DateFilter)) {



			$msg['status'] = 'error';



			$erno = 1;



			$msg['message'] = $b->errormsg($erno);



			return $msg;



		}



		if (count($DateFilter) == 0) {



			$msg['status'] = 'error';



			$erno = 1;



			$msg['message'] = $b->errormsg($erno);



			return $msg;



		}



		return $this->FraudRateObj->getRegAllFraud($DateFilter);



	}



	public function getAllFraudATO($DateFilter = array()) {



		$b = new ErrorMessage();



		if (empty($DateFilter) || !isset($DateFilter)) {



			$msg['status'] = 'error';



			$erno = 1;



			$msg['message'] = $b->errormsg($erno);



			return $msg;



		}



		if (count($DateFilter) == 0) {



			$msg['status'] = 'error';



			$erno = 1;



			$msg['message'] = $b->errormsg($erno);



			return $msg;



		}



		return $this->FraudRateObj->getATOAllFraud($DateFilter);



	}



	public function getreviewcountinfo() {



		return $this->ReviewCountObj->getReviewCount();



	}



	public function getreviewqueueinfo($type = 'trans', $from_date = null, $to_date = null) {



		return $this->ReviewCountObj->getReviewQueue($type, $from_date, $to_date);



	}



	public function processreviewaction($item_id, $action, $type = 'trans') {



		return $this->ReviewCountObj->processReviewAction($item_id, $action, $type);



	}



	public function getreviewstats($date = null, $type = 'both', $from_date = null, $to_date = null) {



		return $this->ReviewCountObj->getReviewStats($date, $type, $from_date, $to_date);



	}



	public function addreviewnote($item_id, $note, $type = 'trans') {



		return $this->ReviewCountObj->addReviewNote($item_id, $note, $type);



	}



	public function getrecentalertinfo() {



		return $this->RecentAlertObj->getRecentAlert();



	}



	public function getblacklistinfo() {



		return $this->BlackListtObj->getBlackList();



	}



	public function postblacklistinfo($EditFields = array()) {



		$b = new ErrorMessage();



		if (empty($EditFields) || !isset($EditFields)) {



			$msg['status'] = 'error';



			$erno = 1;



			$msg['message'] = $b->errormsg($erno);



			return $msg;



		}



		if (count($EditFields) == 0) {



			$msg['status'] = 'error';



			$erno = 1;



			$msg['message'] = $b->errormsg($erno);



			return $msg;



		}



		return $this->BlackListtObj->postBlackList($EditFields);



	}



	public function postblacklistdeleteinfo($EditFields = array()) {



		$b = new ErrorMessage();



		if (empty($EditFields) || !isset($EditFields)) {



			$msg['status'] = 'error';



			$erno = 1;



			$msg['message'] = $b->errormsg($erno);



			return $msg;



		}



		if (count($EditFields) == 0) {



			$msg['status'] = 'error';



			$erno = 1;



			$msg['message'] = $b->errormsg($erno);



			return $msg;



		}



		return $this->BlackListtObj->postBlackListDelete($EditFields);



	}



	public function getwhitelistinfo() {



		return $this->WhiteListtObj->getWhiteList();



	}



	public function postwhitelistinfo($EditFields = array()) {



		$b = new ErrorMessage();



		if (empty($EditFields) || !isset($EditFields)) {



			$msg['status'] = 'error';



			$erno = 1;



			$msg['message'] = $b->errormsg($erno);



			return $msg;



		}



		if (count($EditFields) == 0) {



			$msg['status'] = 'error';



			$erno = 1;



			$msg['message'] = $b->errormsg($erno);



			return $msg;



		}



		return $this->WhiteListtObj->postWhiteList($EditFields);



	}



	public function postwhitelistDeleteinfo($EditFields = array()) {



		$b = new ErrorMessage();



		if (empty($EditFields) || !isset($EditFields)) {



			$msg['status'] = 'error';



			$erno = 1;



			$msg['message'] = $b->errormsg($erno);



			return $msg;



		}



		if (count($EditFields) == 0) {



			$msg['status'] = 'error';



			$erno = 1;



			$msg['message'] = $b->errormsg($erno);



			return $msg;



		}



		return $this->WhiteListtObj->postWhiteDeleteList($EditFields);



	}



	public function getadvancerulesinfo() {



		return $this->AdvanceRulesObj->getAdvanceRules();



	}



	public function postadvancerulesinfo($EditFields = array()) {



		$b = new ErrorMessage();



		if (empty($EditFields) || !isset($EditFields)) {



			$msg['status'] = 'error';



			$erno = 1;



			$msg['message'] = $b->errormsg($erno);



			return $msg;



		}



		if (count($EditFields) == 0) {



			$msg['status'] = 'error';



			$erno = 1;



			$msg['message'] = $b->errormsg($erno);



			return $msg;



		}



		return $this->AdvanceRulesObj->postAdvanceRules($EditFields);



	}



	public function getimportinfo() {



		return $this->ImportExportObj->getImport();



	}



	public function postexportinfo($EditFields = array()) {



		$b = new ErrorMessage();



		if (empty($EditFields) || !isset($EditFields)) {



			$msg['status'] = 'error';



			$erno = 1;



			$msg['message'] = $b->errormsg($erno);



			return $msg;



		}



		if (count($EditFields) == 0) {



			$msg['status'] = 'error';



			$erno = 1;



			$msg['message'] = $b->errormsg($erno);



			return $msg;



		}



		return $this->ImportExportObj->postExport($EditFields);



	}



	public function getrulesinfo() {



		return $this->RulesObj->getRules();



	}



	public function postrulesinfo($EditFields = array()) {



		$b = new ErrorMessage();



		if (empty($EditFields) || !isset($EditFields)) {



			$msg['status'] = 'error';



			$erno = 1;



			$msg['message'] = $b->errormsg($erno);



			return $msg;



		}



		if (count($EditFields) == 0) {



			$msg['status'] = 'error';



			$erno = 1;



			$msg['message'] = $b->errormsg($erno);



			return $msg;



		}



		return $this->RulesObj->postRules($EditFields);



	}



	public function isBot($deviceId = null, $userId = null) {



		$b = new ErrorMessage();



		if (empty($deviceId) || !isset($deviceId)) {



			$msg['status'] = 'error';



			$erno = 1;



			$msg['message'] = $b->errormsg($erno);



			return $msg;



		} 



		return $this->botLog->botLog($deviceId, $userId);



	}



	public function getAtoStatsinfo($DateFilter = array()) {



		$b = new ErrorMessage();



		if (empty($DateFilter) || !isset($DateFilter)) {



			$msg['status'] = 'error';



			$erno = 1;



			$msg['message'] = $b->errormsg($erno);



			return $msg;



		}



		if (count($DateFilter) == 0) {



			$msg['status'] = 'error';



			$erno = 1;



			$msg['message'] = $b->errormsg($erno);



			return $msg;



		}



		return $this->StatsObj->getAtoStats($DateFilter);



	}



	public function getTransStatsinfo($DateFilter = array()) {



		$b = new ErrorMessage();



		if (empty($DateFilter) || !isset($DateFilter)) {



			$msg['status'] = 'error';



			$erno = 1;



			$msg['message'] = $b->errormsg($erno);



			return $msg;



		}



		if (count($DateFilter) == 0) {



			$msg['status'] = 'error';



			$erno = 1;



			$msg['message'] = $b->errormsg($erno);



			return $msg;



		}



		return $this->StatsObj->getTransStats($DateFilter);



	}



	public function getRegStatsinfo($DateFilter = array()) {



		$b = new ErrorMessage();



		if (empty($DateFilter) || !isset($DateFilter)) {



			$msg['status'] = 'error';



			$erno = 1;



			$msg['message'] = $b->errormsg($erno);



			return $msg;



		}



		if (count($DateFilter) == 0) {



			$msg['status'] = 'error';



			$erno = 1;



			$msg['message'] = $b->errormsg($erno);



			return $msg;



		}



		return $this->StatsObj->getRegStats($DateFilter);



	}



	public function getBotStatsinfo($DateFilter = array()) {



		$b = new ErrorMessage();



		if (empty($DateFilter) || !isset($DateFilter)) {



			$msg['status'] = 'error';



			$erno = 1;



			$msg['message'] = $b->errormsg($erno);



			return $msg;



		}



		if (count($DateFilter) == 0) {



			$msg['status'] = 'error';



			$erno = 1;



			$msg['message'] = $b->errormsg($erno);



			return $msg;



		}



		return $this->StatsObj->getBotStats($DateFilter);



	}



	public function getProtectionStats($DateFilter = array()) {



		$b = new ErrorMessage();



		if (empty($DateFilter) || !isset($DateFilter)) {



			$msg['status'] = 'error';



			$erno = 1;



			$msg['message'] = $b->errormsg($erno);



			return $msg;



		}



		if (count($DateFilter) == 0) {



			$msg['status'] = 'error';



			$erno = 1;



			$msg['message'] = $b->errormsg($erno);



			return $msg;



		}



		return $this->StatsObj->getProtectionStats($DateFilter);



	}



	/**

	 * Get admin email alert settings from SensFRX API

	 *

	 * @return array API response with current email alert settings

	 */

	public function getAdminEmailAlerts() {

		// Call the email alerts GET endpoint

		return $this->objAPI->callAPI('GET', '/email-alerts', []);

	}



	/**

	 * Sync admin email alert settings to SensFRX API

	 *

	 * @param array $alertSettings Email alert configuration

	 * @return array API response

	 */

	public function syncAdminEmailAlerts($alertSettings = array()) {



		$b = new ErrorMessage();



		if (empty($alertSettings) || !isset($alertSettings)) {



			$msg['status'] = 'error';



			$erno = 1;



			$msg['message'] = $b->errormsg($erno);



			return $msg;



		}



		if (count($alertSettings) == 0) {



			$msg['status'] = 'error';



			$erno = 1;



			$msg['message'] = $b->errormsg($erno);



			return $msg;



		}



		// Call the email alerts endpoint

		return $this->objAPI->callAPI('POST', '/email-alerts', $alertSettings);



	}



}



