corrección de referencias oxxo con linea return y rutina para ir evaluando los jobs
|
After Width: | Height: | Size: 433 KiB |
|
Before Width: | Height: | Size: 429 KiB After Width: | Height: | Size: 429 KiB |
0
comprobantes/Comprobante_Edward_Elric.png
Normal file → Executable file
|
Before Width: | Height: | Size: 419 KiB After Width: | Height: | Size: 419 KiB |
|
Before Width: | Height: | Size: 428 KiB After Width: | Height: | Size: 426 KiB |
@ -1 +1 @@
|
||||
{"ipserver":"172.16.5.134","apitoken":"6abef18c-783d-4dd0-b530-be6e6a7bbd1d","tokencallbell":"g8thcZkXGd3xBj2g3TtYNYFMH1fuesbJ.b6a940ea7d78cf6c9e42f067b21c8ddf96e9fa2a9e307bfd0c7c7c4d7fa38f79","tokenstripe":"sk_test_51OkG0REFY1WEUtgRH6UxBK5pu80Aq5Iy8EcdPnf0cOWzuVLQTpyLCd7CbPzqMsWMafZOHElCxhEHF7g8boURjWlJ00tBwE0W1M","unmsApiToken":null,"hostServerFTP":"siip.mx","usernameServerFTP":"siip0001","passServerFTP":"$spGiT,[wa)n","cashPaymentMethodId":false,"courtesyPaymentMethodId":false,"bankTransferPaymentMethodId":true,"paypalPaymentMethodId":true,"creditCardPaypalPaymentMethodId":true,"creditCardStripePaymentMethodId":true,"stripeSubscriptionCreditCardPaymentMethodId":true,"paypalSubscriptionPaymentMethodId":true,"mercadopagoPaymentMethodId":true,"checkPaymentMethodId":true,"customPaymentMethodId":true,"notificationTypeText":false,"dataInstallersWhatsApp":"{ \"instaladores\": [{\"ID\": 1015, \"nombre\": \"Daniel Peña, \"whatsapp\": 4181878106}, {\"ID\": 1020, \"nombre\": \"Angel Arvizu\", \"whatsapp\": 4123456789}, {\"ID\": 1035,\"nombre\": \"Juan Rostro, \"whatsapp\": 4198765432}] }","debugMode":true,"logging_level":true}
|
||||
{"ipserver":"172.16.5.134","apitoken":"6abef18c-783d-4dd0-b530-be6e6a7bbd1d","tokencallbell":"g8thcZkXGd3xBj2g3TtYNYFMH1fuesbJ.b6a940ea7d78cf6c9e42f067b21c8ddf96e9fa2a9e307bfd0c7c7c4d7fa38f79","tokenstripe":"sk_test_51OkG0REFY1WEUtgRH6UxBK5pu80Aq5Iy8EcdPnf0cOWzuVLQTpyLCd7CbPzqMsWMafZOHElCxhEHF7g8boURjWlJ00tBwE0W1M","unmsApiToken":null,"hostServerFTP":"siip.mx","usernameServerFTP":"siip0001","passServerFTP":"$spGiT,[wa)n","cashPaymentMethodId":false,"courtesyPaymentMethodId":false,"bankTransferPaymentMethodId":true,"paypalPaymentMethodId":true,"creditCardPaypalPaymentMethodId":true,"creditCardStripePaymentMethodId":true,"stripeSubscriptionCreditCardPaymentMethodId":true,"paypalSubscriptionPaymentMethodId":true,"mercadopagoPaymentMethodId":true,"checkPaymentMethodId":true,"customPaymentMethodId":true,"notificationTypeText":false,"dataInstallersWhatsApp":"{ \"instaladores\": [{\"ID\": 1015, \"nombre\": \"Daniel Peña\", \"whatsapp\": 4181878106}, {\"ID\": 1020, \"nombre\": \"Angel Arvizu\", \"whatsapp\": 4123456789}, {\"ID\": 1035,\"nombre\": \"Juan Rostro\", \"whatsapp\": 4198765432}, {\"ID\": 1035,\"nombre\": “Daniel Humberto\", \"whatsapp\": 4181878106] }","debugMode":true,"logging_level":true}
|
||||
1455
data/plugin.log
@ -157,7 +157,7 @@
|
||||
"key": "dataInstallersWhatsApp",
|
||||
"label": "Datos de los instaladores en formato JSON",
|
||||
"required": 1,
|
||||
"type": "text"
|
||||
"type": "textarea"
|
||||
},
|
||||
{
|
||||
"key": "debugMode",
|
||||
|
||||
@ -10,6 +10,7 @@ use SmsNotifier\Service\Logger;
|
||||
use SmsNotifier\Service\SmsNumberProvider;
|
||||
use Twilio\Exceptions\HttpException;
|
||||
use SmsNotifier\Facade\ClientCallBellAPI;
|
||||
use GuzzleHttp\Client;
|
||||
|
||||
|
||||
/*
|
||||
@ -48,7 +49,7 @@ abstract class AbstractMessageNotifierFacade
|
||||
$this->logger = $logger;
|
||||
$this->messageTextFactory = $messageTextFactory;
|
||||
$this->clientPhoneNumber = $clientPhoneNumber;
|
||||
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
@ -88,8 +89,9 @@ abstract class AbstractMessageNotifierFacade
|
||||
*/
|
||||
public function verifyClientActionToDo(NotificationData $notificationData): void
|
||||
{
|
||||
//$this->logger->debug("Verificar contactos" . PHP_EOL);
|
||||
|
||||
//$this->logger->debug(print_r(json_encode($notificationData),true).PHP_EOL);
|
||||
$this->logger->debug(print_r(json_encode($notificationData), true) . PHP_EOL);
|
||||
|
||||
$arrayPhones = $this->clientPhoneNumber->getUcrmClientNumbers($notificationData);
|
||||
// Procesar el array de teléfonos y ejecutar la función correspondiente
|
||||
@ -140,6 +142,57 @@ abstract class AbstractMessageNotifierFacade
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Verify contact type numbers to do client's
|
||||
*/
|
||||
public function verifyJobActionToDo($jsonNotificationData): void
|
||||
{
|
||||
|
||||
$this->logger->debug('Valor de $jsonNotificationData en verifyJobActionToDo: ' . json_encode($jsonNotificationData) . PHP_EOL);
|
||||
$clientId = $jsonNotificationData['extraData']['entity']['clientId'];
|
||||
$this->logger->debug('Valor de $clientId en verifyJobActionToDo: ' . $clientId . PHP_EOL);
|
||||
|
||||
$configManager = \Ubnt\UcrmPluginSdk\Service\PluginConfigManager::create();
|
||||
$config = $configManager->loadConfig();
|
||||
$IPServer = $config['ipserver'];
|
||||
$tokenCRM = $config['apitoken'];
|
||||
|
||||
$baseUri = 'https://' . $IPServer . '/crm/api/v1.0/';
|
||||
|
||||
$clientGuzzleHttp = new Client([
|
||||
'base_uri' => $baseUri,
|
||||
'headers' => [
|
||||
'X-Auth-App-Key' => $tokenCRM,
|
||||
'Accept' => 'application/json',
|
||||
],
|
||||
'verify' => false,
|
||||
]);
|
||||
|
||||
$response = $clientGuzzleHttp->request('GET', "clients/" . $clientId);
|
||||
$arrayClientCRM = json_decode($response->getBody()->getContents(), true);
|
||||
$this->logger->debug('Valor de $arrayClientCRM en verifyJobActionToDo: ' . json_encode($arrayClientCRM) . PHP_EOL);
|
||||
|
||||
|
||||
//$arrayPhones = $this->clientPhoneNumber->getUcrmClientNumbers($notificationData);
|
||||
// Procesar el array de teléfonos y ejecutar la función correspondiente
|
||||
|
||||
// foreach ($arrayPhones as $type => $phone) {
|
||||
|
||||
// switch ($type) {
|
||||
// case 'WhatsApp':
|
||||
// $this->onlyUpdateService($notificationData, $phone); // Ejecuta función de Notificar y Actualizar
|
||||
// break;
|
||||
// case 'WhatsActualiza':
|
||||
// $this->onlyUpdateService($notificationData, $phone); // Ejecuta función de Actualizar
|
||||
// break;
|
||||
// default:
|
||||
// $this->logger->info("Tipo de contacto no reconocido: $type" . PHP_EOL);
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Verify contact type numbers to do client's data update at CallBell by invoice add or edit
|
||||
@ -286,7 +339,7 @@ abstract class AbstractMessageNotifierFacade
|
||||
//$this->logger->debug(sprintf('llego al llamado de sendPaymentNotificationWhatsApp con client_id: %s y número de celular: %s', $notificationData->clientId, $clientPhoneNumber));
|
||||
|
||||
if ($notificationTypeText) {
|
||||
$this->logger->debug("Activado el check de mensajes de texto: ".$notificationTypeText.PHP_EOL);
|
||||
$this->logger->debug("Activado el check de mensajes de texto: " . $notificationTypeText . PHP_EOL);
|
||||
}
|
||||
|
||||
if ($notificationTypeText) {
|
||||
@ -441,8 +494,9 @@ abstract class AbstractMessageNotifierFacade
|
||||
$this->logger->info("Se proceso los contactos " . PHP_EOL);
|
||||
|
||||
$stripe = new \Stripe\StripeClient($StripeToken); //Instancia de la clase manejadora de clientes para la API de Stripe
|
||||
|
||||
if ($client_email !== null && $customerStripeID !== null) {
|
||||
$this->logger->info("Se actualizara el correo del cliente en Stripe " . PHP_EOL);
|
||||
$this->logger->info("Se actualizara el correo del cliente en Stripe: " . $client_email . PHP_EOL);
|
||||
$stripe->customers->update($customerStripeID, ['email' => $client_email]); //Actualiza el correo electrónico del cliente en la plataforma de Stripe en su correspondiente "customer Stripe ID"
|
||||
}
|
||||
|
||||
@ -456,7 +510,7 @@ abstract class AbstractMessageNotifierFacade
|
||||
$this->logger->warning('No se encontró un teléfono celular válido para el cliente: ' . $notificationData->clientId);
|
||||
return;
|
||||
} else {
|
||||
|
||||
|
||||
try {
|
||||
//$this->logger->debug(sprintf('llego al llamado de sendwhatsapp con client_id: %s y número de celular: %s', $notificationData->clientId, $clientPhoneNumber));
|
||||
//$this->sendMessage($notificationData, $clientSmsNumber, $messageBody);
|
||||
|
||||
@ -67,7 +67,7 @@ abstract class AbstractOxxoOperationsFacade
|
||||
$stripe = new \Stripe\StripeClient($StripeToken);
|
||||
$this->ucrmApi = UcrmApi::create();
|
||||
$currentUserAdmin = $this->ucrmApi->get('users/admins', []);
|
||||
$clientID = $event_json->client_id;
|
||||
$clientID = $event_json['client_id'];
|
||||
|
||||
$stripeCustomerId = null;
|
||||
$clientEmail = '';
|
||||
@ -123,7 +123,7 @@ abstract class AbstractOxxoOperationsFacade
|
||||
if ($amount > 10) {
|
||||
$amount = intval($amount * 100);
|
||||
try {
|
||||
$this->logger->info("Creando referencia en Stripe por: $amount " . PHP_EOL);
|
||||
$this->logger->info("Creando referencia en Stripe por: $amount para el cliente $stripeCustomerId" . PHP_EOL);
|
||||
$paymentIntent = $stripe->paymentIntents->create([
|
||||
'amount' => $amount,
|
||||
'currency' => 'mxn',
|
||||
|
||||
@ -368,7 +368,7 @@ class ClientCallBellAPI
|
||||
// }
|
||||
|
||||
curl_close($ch);
|
||||
$this->deleteFilesExceptLastFifty();
|
||||
$this->deleteFilesExceptLastHundred();
|
||||
//return $fileNameComprobante;
|
||||
return true;
|
||||
}
|
||||
@ -1239,10 +1239,10 @@ class ClientCallBellAPI
|
||||
|
||||
|
||||
/**
|
||||
* /Elimina los archivos del directorio de comprobantes de pago a excepción de los últimos 30 para evitar errores de envío
|
||||
* /Elimina los archivos del directorio de comprobantes de pago a excepción de los últimos 100 para evitar errores de envío
|
||||
* @return void
|
||||
*/
|
||||
function deleteFilesExceptLastFifty()
|
||||
function deleteFilesExceptLastHundred()
|
||||
{
|
||||
$log = PluginLogManager::create(); //Initialize Logger
|
||||
$directory = __DIR__ . '/../../comprobantes/';
|
||||
@ -1261,10 +1261,10 @@ class ClientCallBellAPI
|
||||
return filemtime($b) - filemtime($a);
|
||||
});
|
||||
|
||||
// Verificar que haya más de 30 archivos
|
||||
if (count($files) > 50) {
|
||||
// Obtener los archivos que deben ser eliminados (todos menos los 50 más recientes)
|
||||
$filesToDelete = array_slice($files, 50);
|
||||
// Verificar que haya más de 100 archivos
|
||||
if (count($files) > 100) {
|
||||
// Obtener los archivos que deben ser eliminados (todos menos los 100 más recientes)
|
||||
$filesToDelete = array_slice($files, 100);
|
||||
|
||||
// Eliminar los archivos
|
||||
foreach ($filesToDelete as $file) {
|
||||
|
||||
317
src/Plugin.php
@ -73,13 +73,13 @@ class Plugin
|
||||
// $hola = PHP_SAPI;
|
||||
// $this->logger->info('valor de PHP_SAPI: ' . $hola);
|
||||
if (PHP_SAPI === 'fpm-fcgi') {
|
||||
$this->logger->debug('Whatsapp over HTTP started');
|
||||
//$this->logger->debug('Whatsapp over HTTP started');
|
||||
$this->processHttpRequest();
|
||||
$this->logger->debug('HTTP request processing ended.');
|
||||
//$this->logger->debug('HTTP request processing ended.');
|
||||
} elseif (PHP_SAPI === 'cli') {
|
||||
$this->logger->debug('Whatsapp over CLI started');
|
||||
//$this->logger->debug('Whatsapp over CLI started');
|
||||
$this->processCli();
|
||||
$this->logger->debug('CLI process ended.');
|
||||
//$this->logger->debug('CLI process ended.');
|
||||
} else {
|
||||
throw new \UnexpectedValueException('Unknown PHP_SAPI type: ' . PHP_SAPI);
|
||||
}
|
||||
@ -111,106 +111,115 @@ class Plugin
|
||||
|
||||
return;
|
||||
}
|
||||
$event_json = json_decode($userInput);
|
||||
$webhook_string = json_encode($event_json);
|
||||
$this->logger->debug("El valor de webhook_string: " . $webhook_string . PHP_EOL);
|
||||
|
||||
|
||||
// Maneja el evento del webhook
|
||||
if ($event_json) {
|
||||
switch ($event_json->type) {
|
||||
case 'customer_cash_balance_transaction.created':
|
||||
$this->logger->info('Evento de transfencia al cliente encontrado');
|
||||
$this->logger->info('Valor del EventJSON: ' . json_encode($event_json) . PHP_EOL);
|
||||
$this->pluginNotifierFacade->createPaymentIntent($event_json);
|
||||
break;
|
||||
case 'inbound_payment.payment_attempt':
|
||||
$this->logger->info('Evento de Pago de OXXO recibido');
|
||||
$this->logger->info('Valor del EventJSON: ' . json_encode($event_json) . PHP_EOL);
|
||||
break;
|
||||
case 'energy.alert':
|
||||
$this->logger->info('Evento de Energía recibido: ' . $event_json->message . PHP_EOL);
|
||||
break;
|
||||
case 'oxxo.request':
|
||||
$this->logger->info('Evento de referencia de oxxo recibido' . PHP_EOL);
|
||||
|
||||
|
||||
// Construir la URL basada en el "client_id"
|
||||
// $url = "https://siip.mx/wp/wp-content/uploads/img/voucher.png";
|
||||
if (!empty($event_json->amount)) {
|
||||
$this->logger->info('Referencia persnoalizada, Valor del monto: ' . $event_json->amount . PHP_EOL);
|
||||
$intentos = 0;
|
||||
do {
|
||||
if ($intentos > 1) {
|
||||
sleep(2);
|
||||
}
|
||||
$url = $this->pluginOxxoNotifierFacade->createOxxoPaymentIntent($event_json, $event_json->amount);
|
||||
$intentos++;
|
||||
} while (strpos($url, 'https') !== 0 && $intentos < 5);
|
||||
} else {
|
||||
$intentos = 0;
|
||||
do {
|
||||
// if ($intentos > 1) {
|
||||
// sleep(2);
|
||||
// }
|
||||
$url = $this->pluginOxxoNotifierFacade->createOxxoPaymentIntent($event_json);
|
||||
$intentos++;
|
||||
} while (strpos($url, 'https') !== 0 && $intentos < 5);
|
||||
}
|
||||
|
||||
// Crear una respuesta en formato JSON
|
||||
// $response = [
|
||||
// 'event' => 'response.siip',
|
||||
// 'status' => 'success',
|
||||
// 'url' => $url
|
||||
// ];
|
||||
|
||||
$response = '{' .
|
||||
'"url": "' . $url . '"' .
|
||||
'}';
|
||||
|
||||
$this->logger->debug('Reponse que se envía a CallBell: ' . $response);
|
||||
// $json_codificado = json_encode($response);
|
||||
// if (json_last_error() !== JSON_ERROR_NONE) {
|
||||
// $this->logger->error('Error en la codificación JSON: ' . json_last_error_msg() . PHP_EOL);
|
||||
|
||||
// }
|
||||
|
||||
//$this->logger->info('Se está enviando esta respuesta: ' . json_encode($json_codificado) . PHP_EOL);
|
||||
|
||||
// Enviar el encabezado de respuesta como JSON
|
||||
header('Content-Type: application/json');
|
||||
|
||||
// Enviar la respuesta en formato JSON
|
||||
//echo json_encode($response);
|
||||
echo $response;
|
||||
|
||||
break;
|
||||
|
||||
// Otros eventos relevantes
|
||||
}
|
||||
}
|
||||
|
||||
$jsonData = @json_decode($userInput, true, 10);
|
||||
if (!isset($jsonData['uuid'])) {
|
||||
$this->logger->error('JSON error: ' . json_last_error_msg());
|
||||
|
||||
if (!isset($jsonData['uuid'])) {
|
||||
$this->logger->info('No UUID found in the webhook data');
|
||||
//$this->logger->error('JSON error: ' . json_last_error_msg());
|
||||
|
||||
//return;
|
||||
|
||||
// Maneja el evento del webhook externo
|
||||
if ($jsonData) {
|
||||
switch ($jsonData['type']) {
|
||||
case 'customer_cash_balance_transaction.created':
|
||||
$this->logger->info('Evento de transfencia al cliente encontrado');
|
||||
$this->logger->info('Valor del EventJSON: ' . json_encode($jsonData) . PHP_EOL);
|
||||
$this->pluginNotifierFacade->createPaymentIntent($jsonData);
|
||||
break;
|
||||
case 'inbound_payment.payment_attempt':
|
||||
$this->logger->info('Evento de Pago de OXXO recibido');
|
||||
$this->logger->info('Valor del EventJSON: ' . json_encode($jsonData) . PHP_EOL);
|
||||
break;
|
||||
case 'energy.alert':
|
||||
$this->logger->info('Evento de Energía recibido: ' . $jsonData['message'] . PHP_EOL);
|
||||
break;
|
||||
case 'oxxo.request':
|
||||
$this->logger->info('Evento de referencia de oxxo recibido' . PHP_EOL);
|
||||
|
||||
|
||||
// Construir la URL basada en el "client_id"
|
||||
// $url = "https://siip.mx/wp/wp-content/uploads/img/voucher.png";
|
||||
if (!empty($jsonData['amount'])) {
|
||||
$this->logger->info('Referencia persnoalizada, Valor del monto: ' . $jsonData['amount'] . PHP_EOL);
|
||||
$intentos = 0;
|
||||
do {
|
||||
if ($intentos > 1) {
|
||||
sleep(2);
|
||||
}
|
||||
$url = $this->pluginOxxoNotifierFacade->createOxxoPaymentIntent($jsonData, $jsonData['amount']);
|
||||
$intentos++;
|
||||
} while (strpos($url, 'https') !== 0 && $intentos < 5);
|
||||
} else {
|
||||
$intentos = 0;
|
||||
do {
|
||||
// if ($intentos > 1) {
|
||||
// sleep(2);
|
||||
// }
|
||||
$url = $this->pluginOxxoNotifierFacade->createOxxoPaymentIntent($jsonData);
|
||||
$intentos++;
|
||||
} while (strpos($url, 'https') !== 0 && $intentos < 5);
|
||||
}
|
||||
|
||||
// Crear una respuesta en formato JSON
|
||||
// $response = [
|
||||
// 'event' => 'response.siip',
|
||||
// 'status' => 'success',
|
||||
// 'url' => $url
|
||||
// ];
|
||||
|
||||
$response = '{' .
|
||||
'"url": "' . $url . '"' .
|
||||
'}';
|
||||
|
||||
$this->logger->debug('Reponse que se envía a CallBell: ' . $response);
|
||||
// $json_codificado = json_encode($response);
|
||||
// if (json_last_error() !== JSON_ERROR_NONE) {
|
||||
// $this->logger->error('Error en la codificación JSON: ' . json_last_error_msg() . PHP_EOL);
|
||||
|
||||
// }
|
||||
|
||||
//$this->logger->info('Se está enviando esta respuesta: ' . json_encode($json_codificado) . PHP_EOL);
|
||||
|
||||
// Enviar el encabezado de respuesta como JSON
|
||||
header('Content-Type: application/json');
|
||||
|
||||
// Enviar la respuesta en formato JSON
|
||||
//echo json_encode($response);
|
||||
echo $response;
|
||||
|
||||
break;
|
||||
|
||||
// Otros eventos relevantes
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// $event_json = json_decode($userInput);
|
||||
// $webhook_string = json_encode($event_json);
|
||||
// $this->logger->debug("El valor de webhook_string: " . $webhook_string . PHP_EOL);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$notification = $this->notificationDataFactory->getObject($jsonData);
|
||||
$this->logger->debug('valor el evento recibido por webhook: ' . $notification->eventName . PHP_EOL);
|
||||
$this->logger->debug('Valor de JSON: ' . json_encode($jsonData) . PHP_EOL);
|
||||
|
||||
if ($notification->changeType === 'test') {
|
||||
$this->logger->info('Webhook test successful.');
|
||||
|
||||
return;
|
||||
}
|
||||
if (!$notification->clientId) {
|
||||
$this->logger->warning('No client specified, cannot notify them.');
|
||||
// if (!$notification->clientId) {
|
||||
// $this->logger->warning('No client specified, cannot notify them.');
|
||||
|
||||
return;
|
||||
}
|
||||
// return;
|
||||
// }
|
||||
|
||||
$configManager = \Ubnt\UcrmPluginSdk\Service\PluginConfigManager::create();
|
||||
$config = $configManager->loadConfig();
|
||||
@ -310,27 +319,64 @@ class Plugin
|
||||
|
||||
|
||||
} else if ($notification->eventName === 'client.edit') {
|
||||
$this->logger->debug('Se actualiza a un cliente' . PHP_EOL);
|
||||
// Verificar que existen tanto 'entityBeforeEdit' como 'entity'
|
||||
if (isset($event_json['extraData']['entityBeforeEdit']['isLead']) && isset($event_json['extraData']['entity']['isLead'])) {
|
||||
$isLeadBefore = $event_json['extraData']['entityBeforeEdit']['isLead'];
|
||||
$isLeadAfter = $event_json['extraData']['entity']['isLead'];
|
||||
$this->logger->debug('Se actualiza a un cliente');
|
||||
$this->logger->debug('Valor de json_data: ' . json_encode($jsonData));
|
||||
|
||||
// Comprobar si 'isLead' cambió de true a false
|
||||
if ($isLeadBefore === true && $isLeadAfter === false) {
|
||||
$this->logger->debug('El campo isLead cambió de true a false');
|
||||
$this->pluginNotifierFacade->createStripeClient($notification);
|
||||
// Validar que 'extraData' existe y contiene las claves necesarias
|
||||
if (
|
||||
isset($jsonData['extraData']['entityBeforeEdit']) &&
|
||||
isset($jsonData['extraData']['entity'])
|
||||
) {
|
||||
$entityBeforeEdit = $jsonData['extraData']['entityBeforeEdit'];
|
||||
$entity = $jsonData['extraData']['entity'];
|
||||
|
||||
$this->logger->debug('Validando claves dentro de entityBeforeEdit y entity');
|
||||
|
||||
// Validar que 'isLead' existe en ambas entidades
|
||||
if (array_key_exists('isLead', $entityBeforeEdit) && array_key_exists('isLead', $entity)) {
|
||||
$this->logger->debug('Los datos entityBeforeEdit y entity contienen el campo isLead');
|
||||
|
||||
$isLeadBefore = $entityBeforeEdit['isLead'];
|
||||
$isLeadAfter = $entity['isLead'];
|
||||
|
||||
// Validar el tipo de dato de isLead
|
||||
if (!is_bool($isLeadBefore) || !is_bool($isLeadAfter)) {
|
||||
$this->logger->warning('El campo isLead no es de tipo booleano');
|
||||
} else {
|
||||
// Comprobar si 'isLead' cambió de true a false
|
||||
if ($isLeadBefore === true && $isLeadAfter === false) {
|
||||
$this->logger->debug('El campo isLead cambió de true a false');
|
||||
$this->pluginNotifierFacade->createStripeClient($notification);
|
||||
} else {
|
||||
$this->logger->debug('No hubo cambio de true a false en el campo isLead');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->logger->debug('No hubo cambio de true a false en el campo isLead');
|
||||
$this->logger->warning('El campo isLead no existe en entityBeforeEdit o entity');
|
||||
}
|
||||
} else {
|
||||
$this->logger->warning('Los datos entityBeforeEdit o entity no contienen el campo isLead');
|
||||
$this->logger->warning('Los datos entityBeforeEdit o entity no están presentes en extraData');
|
||||
}
|
||||
|
||||
$this->notifierFacade->verifyClientActionToDo($notification);
|
||||
} else if ($notification->eventName === 'client.add') {
|
||||
$this->logger->debug('Se agregó un nuevo cliente' . PHP_EOL);
|
||||
$this->pluginNotifierFacade->createStripeClient($notification);
|
||||
// Verificar que existen tanto 'entityBeforeEdit' como 'entity'
|
||||
if (isset($event_json['extraData']['entity']['isLead'])) {
|
||||
$this->logger->debug('El campo isLead existe en los datos del evento');
|
||||
$isLead = $jsonData['extraData']['entity']['isLead'];
|
||||
|
||||
// Comprobar si 'isLead' es true
|
||||
if ($isLead === true) {
|
||||
$this->logger->debug('El campo isLead es true');
|
||||
$this->pluginNotifierFacade->createStripeClient($notification);
|
||||
} else {
|
||||
$this->logger->debug('El campo isLead es false');
|
||||
}
|
||||
} else {
|
||||
$this->logger->warning('El campo isLead no existe en los datos del evento');
|
||||
}
|
||||
|
||||
} else if ($notification->eventName === 'service.suspend') {
|
||||
$this->logger->debug('Se suspendió el servicio a un cliente' . PHP_EOL);
|
||||
$this->notifierFacade->verifyServiceActionToDo($notification);
|
||||
@ -361,6 +407,75 @@ class Plugin
|
||||
} else if ($notification->eventName === 'invoice.edit') {
|
||||
$this->logger->debug('Edición de Factura' . PHP_EOL);
|
||||
$this->notifierFacade->verifyInvoiceActionToDo($notification);
|
||||
} else if ($notification->eventName === 'job.add') {
|
||||
$this->logger->debug('Se ha agregado un nuevo trabajo' . PHP_EOL);
|
||||
|
||||
|
||||
// Verificar que existen tanto 'assignedUserId' como 'entity'
|
||||
if (isset($event_json['extraData']['entity']['assignedUserId'])) {
|
||||
$this->logger->debug('El campo assignedUserId existe en los datos del evento');
|
||||
$assignedUserId = $jsonData['extraData']['entity']['assignedUserId'];
|
||||
|
||||
// Comprobar si 'isLead' es null
|
||||
if ($assignedUserId === null) {
|
||||
$this->logger->debug('El campo assignedUserId es null');
|
||||
$this->pluginNotifierFacade->createStripeClient($notification);
|
||||
} else {
|
||||
$this->logger->debug('El campo assignedUserId no es null');
|
||||
$this->notifierFacade->verifyJobActionToDo($notification);
|
||||
}
|
||||
} else {
|
||||
$this->logger->warning('El campo assignedUserId no existe en los datos del evento');
|
||||
}
|
||||
|
||||
} else if ($notification->eventName === 'job.edit') {
|
||||
$this->logger->debug('Se actualiza un trabajo' . PHP_EOL);
|
||||
$this->logger->debug('Valor de json_data: ' . json_encode($jsonData));
|
||||
|
||||
|
||||
// Validar que 'extraData' existe y contiene las claves necesarias
|
||||
if (
|
||||
isset($jsonData['extraData']['entityBeforeEdit']) &&
|
||||
isset($jsonData['extraData']['entity'])
|
||||
) {
|
||||
$entityBeforeEdit = $jsonData['extraData']['entityBeforeEdit'];
|
||||
$entity = $jsonData['extraData']['entity'];
|
||||
|
||||
$this->logger->debug('Validando claves dentro de entityBeforeEdit y entity');
|
||||
|
||||
// Validar que 'assignedUserId' existe en ambas entidades
|
||||
if (array_key_exists('assignedUserId', $entityBeforeEdit) && array_key_exists('assignedUserId', $entity)) {
|
||||
$this->logger->debug('Los datos entityBeforeEdit y entity contienen el campo assignedUserId');
|
||||
|
||||
$assignedUserIdBefore = $entityBeforeEdit['assignedUserId'];
|
||||
$assignedUserIdAfter = $entity['assignedUserId'];
|
||||
|
||||
// Validar el tipo de dato de assignedUserId
|
||||
if (!is_bool($assignedUserIdBefore) || !is_bool($assignedUserIdAfter)) {
|
||||
$this->logger->warning('El campo assignedUserId no es de tipo booleano');
|
||||
// Comprobar si 'assignedUserId' cambió
|
||||
if ($assignedUserIdBefore === null && $assignedUserIdAfter != null) {
|
||||
$this->logger->debug('El campo assignedUserId cambió ');
|
||||
$this->notifierFacade->verifyJobActionToDo($jsonData);
|
||||
} else {
|
||||
$this->logger->debug('No hubo cambio en el campo assignedUserId');
|
||||
}
|
||||
} else {
|
||||
// Comprobar si 'assignedUserId' cambió
|
||||
if ($assignedUserIdBefore === null && $assignedUserIdAfter != null) {
|
||||
$this->logger->debug('El campo assignedUserId cambió');
|
||||
$this->notifierFacade->verifyJobActionToDo($jsonData);
|
||||
} else {
|
||||
$this->logger->debug('No hubo cambio en el campo assignedUserId');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->logger->warning('El campo assignedUserId no existe en entityBeforeEdit o entity');
|
||||
}
|
||||
} else {
|
||||
$this->logger->warning('Los datos entityBeforeEdit o entity no están presentes en extraData');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
31545
vendor/composer/autoload_classmap.php
vendored
11
vendor/composer/autoload_real.php
vendored
@ -34,22 +34,13 @@ class ComposerAutoloaderInitd6442a7ec79f2f43fc97d16bdcdd18ee
|
||||
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInitd6442a7ec79f2f43fc97d16bdcdd18ee::getInitializer($loader));
|
||||
} else {
|
||||
$map = require __DIR__ . '/autoload_namespaces.php';
|
||||
foreach ($map as $namespace => $path) {
|
||||
$loader->set($namespace, $path);
|
||||
}
|
||||
|
||||
$map = require __DIR__ . '/autoload_psr4.php';
|
||||
foreach ($map as $namespace => $path) {
|
||||
$loader->setPsr4($namespace, $path);
|
||||
}
|
||||
|
||||
$classMap = require __DIR__ . '/autoload_classmap.php';
|
||||
if ($classMap) {
|
||||
$loader->addClassMap($classMap);
|
||||
}
|
||||
}
|
||||
|
||||
$loader->setClassMapAuthoritative(true);
|
||||
$loader->register(true);
|
||||
|
||||
if ($useStaticLoader) {
|
||||
|
||||
31545
vendor/composer/autoload_static.php
vendored
2
vendor/composer/installed.json
vendored
@ -2040,6 +2040,6 @@
|
||||
"install-path": "../ubnt/ucrm-plugin-sdk"
|
||||
}
|
||||
],
|
||||
"dev": true,
|
||||
"dev": false,
|
||||
"dev-package-names": []
|
||||
}
|
||||
|
||||
6
vendor/composer/installed.php
vendored
@ -5,9 +5,9 @@
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../../',
|
||||
'aliases' => array(),
|
||||
'reference' => '93a0f30eecd7b45a1b45bcb2c4642e734275029d',
|
||||
'reference' => 'efd6f36c37acff90564096937d34b606769ee63c',
|
||||
'name' => 'ucrm-plugins/sms-twilio',
|
||||
'dev' => true,
|
||||
'dev' => false,
|
||||
),
|
||||
'versions' => array(
|
||||
'firebase/php-jwt' => array(
|
||||
@ -307,7 +307,7 @@
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../../',
|
||||
'aliases' => array(),
|
||||
'reference' => '93a0f30eecd7b45a1b45bcb2c4642e734275029d',
|
||||
'reference' => 'efd6f36c37acff90564096937d34b606769ee63c',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
),
|
||||
|
||||