Actualizacion de Diseño Logins y Parte de Registro Negocios

This commit is contained in:
kquiroz
2023-08-23 16:11:21 -04:00
parent d71e89adae
commit 38bf59042d
3498 changed files with 691264 additions and 0 deletions

View File

@@ -0,0 +1,91 @@
<?php
namespace App\Utility;
class MimoUtility
{
public static function getToken()
{
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => '52.30.114.86:8080/mimosms/v1/user/login',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{
"username": "'.env('MIMO_USERNAME').'",
"password": "'.env('MIMO_PASSWORD').'"
}',
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json'
),
));
$response = curl_exec($curl);
curl_close($curl);
return json_decode($response)->token;
}
public static function sendMessage($text, $to, $token)
{
$curl = curl_init();
$fields = array(
"sender" => env("MIMO_SENDER_ID"),
"text" => $text,
"recipients" => $to
);
// dd($to);
curl_setopt_array($curl, array(
CURLOPT_URL => '52.30.114.86:8080/mimosms/v1/message/send?token='.$token,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => json_encode($fields),
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json'
),
));
$response = curl_exec($curl);
// dd($response);
curl_close($curl);
return 1;
}
public static function logout($token)
{
// dd('Hello world');
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => '52.30.114.86:8080/mimosms/v1/user/logout?token='.$token,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'GET',
));
$response = curl_exec($curl);
curl_close($curl);
// dd($response, $token);
}
}

View File

@@ -0,0 +1,78 @@
<?php
namespace App\Utility;
use App\Models\OtpConfiguration;
use App\Models\SmsTemplate;
use App\Models\User;
use App\Services\SendSmsService;
class SmsUtility
{
public static function phone_number_verification($user = '')
{
$sms_template = SmsTemplate::where('identifier', 'phone_number_verification')->first();
$sms_body = $sms_template->sms_body;
$sms_body = str_replace('[[code]]', $user->verification_code, $sms_body);
$sms_body = str_replace('[[site_name]]', env('APP_NAME'), $sms_body);
$template_id = $sms_template->template_id;
(new SendSmsService())->sendSMS($user->phone, env('APP_NAME'), $sms_body, $template_id);
}
public static function password_reset($user = '')
{
$sms_template = SmsTemplate::where('identifier', 'password_reset')->first();
$sms_body = $sms_template->sms_body;
$sms_body = str_replace('[[code]]', $user->verification_code, $sms_body);
$template_id = $sms_template->template_id;
(new SendSmsService())->sendSMS($user->phone, env('APP_NAME'), $sms_body, $template_id);
}
public static function order_placement($phone = '', $order = '')
{
$sms_template = SmsTemplate::where('identifier', 'order_placement')->first();
$sms_body = $sms_template->sms_body;
$sms_body = str_replace('[[order_code]]', $order->code, $sms_body);
$template_id = $sms_template->template_id;
(new SendSmsService())->sendSMS($phone, env('APP_NAME'), $sms_body, $template_id);
}
public static function delivery_status_change($phone = '', $order)
{
$sms_template = SmsTemplate::where('identifier', 'delivery_status_change')->first();
$sms_body = $sms_template->sms_body;
$delivery_status = translate(ucfirst(str_replace('_', ' ', $order->delivery_status)));
$sms_body = str_replace('[[delivery_status]]', $delivery_status, $sms_body);
$sms_body = str_replace('[[order_code]]', $order->code, $sms_body);
$template_id = $sms_template->template_id;
(new SendSmsService())->sendSMS($phone, env('APP_NAME'), $sms_body, $template_id);
}
public static function payment_status_change($phone = '', $order = '')
{
$sms_template = SmsTemplate::where('identifier', 'payment_status_change')->first();
$sms_body = $sms_template->sms_body;
$sms_body = str_replace('[[payment_status]]', translate(ucfirst($order->payment_status)), $sms_body);
$sms_body = str_replace('[[order_code]]', $order->code, $sms_body);
$template_id = $sms_template->template_id;
(new SendSmsService())->sendSMS($phone, env('APP_NAME'), $sms_body, $template_id);
}
public static function assign_delivery_boy($phone = '', $code = '')
{
$sms_template = SmsTemplate::where('identifier', 'assign_delivery_boy')->first();
$sms_body = $sms_template->sms_body;
$sms_body = str_replace('[[order_code]]', $code, $sms_body);
$template_id = $sms_template->template_id;
(new SendSmsService())->sendSMS($phone, env('APP_NAME'), $sms_body, $template_id);
}
}