namespace MiniOrange\IDPSaml\Helper;
use MiniOrange\IDPSaml\Helper\IDPConstants;
class Curl
{
public static function create_customer($Wc, $Un, $u0, $MZ = '', $lm = '', $P0 = '')
{
$cz = IDPConstants::HOSTNAME . "/moas/rest/customer/add";
$sK = IDPConstants::DEFAULT_CUSTOMER_KEY;
$Ua = IDPConstants::DEFAULT_API_KEY;
$nP = ["companyName" => $Un, "areaOfInterest" => IDPConstants::AREA_OF_INTEREST, "firstname" => $lm, "lastname" => $P0, "email" => $Wc, "phone" => $MZ, "password" => $u0];
$UQ = self::createAuthHeader($sK, $Ua);
$WG = self::callAPI($cz, $nP, $UQ);
return $WG;
}
public static function get_customer_key($Wc, $u0)
{
$cz = IDPConstants::HOSTNAME . "/moas/rest/customer/key";
$sK = IDPConstants::DEFAULT_CUSTOMER_KEY;
$Ua = IDPConstants::DEFAULT_API_KEY;
$nP = ["email" => $Wc, "password" => $u0];
$UQ = self::createAuthHeader($sK, $Ua);
$WG = self::callAPI($cz, $nP, $UQ);
return $WG;
}
public static function check_customer($Wc)
{
$cz = IDPConstants::HOSTNAME . "/moas/rest/customer/check-if-exists";
$sK = IDPConstants::DEFAULT_CUSTOMER_KEY;
$Ua = IDPConstants::DEFAULT_API_KEY;
$nP = ["email" => $Wc];
$UQ = self::createAuthHeader($sK, $Ua);
$WG = self::callAPI($cz, $nP, $UQ);
return $WG;
}
public static function mo_send_otp_token($wN, $Wc = '', $MZ = '')
{
$cz = IDPConstants::HOSTNAME . "/moas/api/auth/challenge";
$sK = IDPConstants::DEFAULT_CUSTOMER_KEY;
$Ua = IDPConstants::DEFAULT_API_KEY;
$nP = ["customerKey" => $sK, "email" => $Wc, "phone" => $MZ, "authType" => $wN, "transactionName" => IDPConstants::AREA_OF_INTEREST];
$UQ = self::createAuthHeader($sK, $Ua);
$WG = self::callAPI($cz, $nP, $UQ);
return $WG;
}
public static function validate_otp_token($MR, $e_)
{
$cz = IDPConstants::HOSTNAME . "/moas/api/auth/validate";
$sK = IDPConstants::DEFAULT_CUSTOMER_KEY;
$Ua = IDPConstants::DEFAULT_API_KEY;
$nP = ["txId" => $MR, "token" => $e_];
$UQ = self::createAuthHeader($sK, $Ua);
$WG = self::callAPI($cz, $nP, $UQ);
return $WG;
}
public static function submit_contact_us($uy, $Z3, $Y9, $DK)
{
$cz = IDPConstants::HOSTNAME . "/moas/rest/customer/contact-us";
$Y9 = "[" . IDPConstants::AREA_OF_INTEREST . "]: " . $Y9;
$sK = IDPConstants::DEFAULT_CUSTOMER_KEY;
$Ua = IDPConstants::DEFAULT_API_KEY;
$nP = ["company" => $DK, "email" => $uy, "phone" => $Z3, "query" => $Y9, "ccEmail" => "magentosupport@xecurify.com"];
$UQ = self::createAuthHeader($sK, $Ua);
$WG = self::callAPI($cz, $nP, $UQ);
return true;
}
public static function forgot_password($Wc, $sK, $Ua)
{
$cz = IDPConstants::HOSTNAME . "/moas/rest/customer/password-reset";
$nP = ["email" => $Wc];
$UQ = self::createAuthHeader($sK, $Ua);
$WG = self::callAPI($cz, $nP, $UQ);
return $WG;
}
public static function check_customer_ln($sK, $Ua)
{
$cz = IDPConstants::HOSTNAME . "/moas/rest/customer/license";
$nP = ["customerId" => $sK, "applicationName" => IDPConstants::APPLICATION_NAME, "licenseType" => !MoUtility::micr() ? "DEMO" : "PREMIUM"];
$UQ = self::createAuthHeader($sK, $Ua);
$WG = self::callAPI($cz, $nP, $UQ);
return $WG;
}
private static function createAuthHeader($sK, $Ua)
{
$cR = round(microtime(true) * 1000);
$cR = number_format($cR, 0, '', '');
$Gm = $sK . $cR . $Ua;
$UQ = hash("sha512", $Gm);
$pY = ["Content-Type: application/json", "Customer-Key: {$sK}", "Timestamp: {$cR}", "Authorization: {$UQ}"];
return $pY;
}
private static function callAPI($cz, $qn = array(), $VP = array("Content-Type: application/json"))
{
$VF = new MoCurl();
$VE = ["CURLOPT_FOLLOWLOCATION" => true, "CURLOPT_ENCODING" => '', "CURLOPT_RETURNTRANSFER" => true, "CURLOPT_AUTOREFERER" => true, "CURLOPT_TIMEOUT" => 0, "CURLOPT_MAXREDIRS" => 10];
$fy = !empty($qn) ? "POST" : "GET";
$VF->setConfig($VE);
$VF->write($fy, $cz, "1.1", $VP, !empty($qn) ? json_encode($qn) : '');
$Ib = $VF->read();
$VF->close();
return $Ib;
}
public static function ccl($sK, $Ua)
{
$cz = IDPConstants::HOSTNAME . "/moas/rest/customer/license";
$nP = array("customerId" => $sK, "applicationName" => IDPConstants::LICENSE_PLAN);
$UQ = self::createAuthHeader($sK, $Ua);
$WG = self::callAPI($cz, $nP, $UQ);
return $WG;
}
public static function vml($sK, $Ua, $Tv, $EJ)
{
$cz = IDPConstants::HOSTNAME . "/moas/api/backupcode/verify";
$nP = array("code" => $Tv, "customerKey" => $sK, "additionalFields" => array("field1" => $EJ));
$UQ = self::createAuthHeader($sK, $Ua);
$WG = self::callAPI($cz, $nP, $UQ);
return $WG;
}
public static function mius($sK, $Ua, $Tv)
{
$cz = IDPConstants::HOSTNAME . "/moas/api/backupcode/updatestatus";
$nP = array("code" => trim($Tv), "customerKey" => $sK);
$UQ = self::createAuthHeader($sK, $Ua);
$WG = self::callAPI($cz, $nP, $UQ);
return $WG;
}
public static function notify($sK, $Ua, $uh, $Ib, $Y1)
{
$cz = IDPConstants::HOSTNAME . "/moas/api/notify/send";
$nP = array("customerKey" => $sK, "sendEmail" => true, "email" => array("customerKey" => $sK, "fromEmail" => "raj@xecurify.com", "bccEmail" => "raj@xecurify.com", "fromName" => "miniOrange", "toEmail" => $uh, "toName" => $uh, "subject" => $Y1, "content" => $Ib));
$UQ = self::createAuthHeader($sK, $Ua);
$WG = self::callAPI($cz, $nP, $UQ);
return $WG;
}
public static function submit_to_magento_team($uy, $oV, $Ib)
{
$Ib = implode(", ", $Ib);
$cz = IDPConstants::HOSTNAME . "/moas/api/notify/send";
$sK = IDPConstants::DEFAULT_CUSTOMER_KEY;
$Ua = IDPConstants::DEFAULT_API_KEY;
$IQ = array("customerKey" => $sK, "sendEmail" => true, "email" => array("customerKey" => $sK, "fromEmail" => "nitesh.pamnani@xecurify.com", "bccEmail" => "rutuja.sonawane@xecurify.com", "fromName" => "miniOrange", "toEmail" => "nitesh.pamnani@xecurify.com", "toName" => "Nitesh", "subject" => "Magento IDP Trial Plugin {$oV} : {$uy}", "content" => $Ib));
$Z6 = array("customerKey" => $sK, "sendEmail" => true, "email" => array("customerKey" => $sK, "fromEmail" => "rushikesh.nikam@xecurify.com", "bccEmail" => "raj@xecurify.com", "fromName" => "miniOrange", "toEmail" => "rushikesh.nikam@xecurify.com", "toName" => "Rushikesh", "subject" => "Magento IDP Trial Plugin {$oV} : {$uy}", "content" => $Ib));
$A8 = json_encode($IQ);
$j0 = json_encode($Z6);
$UQ = self::createAuthHeader($sK, $Ua);
$qT = self::callAPI($cz, $IQ, $UQ);
$ps = self::callAPI($cz, $Z6, $UQ);
return true;
}
}
© 2023 Quttera Ltd. All rights reserved.