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",
|
"key": "dataInstallersWhatsApp",
|
||||||
"label": "Datos de los instaladores en formato JSON",
|
"label": "Datos de los instaladores en formato JSON",
|
||||||
"required": 1,
|
"required": 1,
|
||||||
"type": "text"
|
"type": "textarea"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"key": "debugMode",
|
"key": "debugMode",
|
||||||
|
|||||||
@ -10,6 +10,7 @@ use SmsNotifier\Service\Logger;
|
|||||||
use SmsNotifier\Service\SmsNumberProvider;
|
use SmsNotifier\Service\SmsNumberProvider;
|
||||||
use Twilio\Exceptions\HttpException;
|
use Twilio\Exceptions\HttpException;
|
||||||
use SmsNotifier\Facade\ClientCallBellAPI;
|
use SmsNotifier\Facade\ClientCallBellAPI;
|
||||||
|
use GuzzleHttp\Client;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -88,8 +89,9 @@ abstract class AbstractMessageNotifierFacade
|
|||||||
*/
|
*/
|
||||||
public function verifyClientActionToDo(NotificationData $notificationData): void
|
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);
|
$arrayPhones = $this->clientPhoneNumber->getUcrmClientNumbers($notificationData);
|
||||||
// Procesar el array de teléfonos y ejecutar la función correspondiente
|
// 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
|
* Verify contact type numbers to do client's data update at CallBell by invoice add or edit
|
||||||
@ -441,8 +494,9 @@ abstract class AbstractMessageNotifierFacade
|
|||||||
$this->logger->info("Se proceso los contactos " . PHP_EOL);
|
$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
|
$stripe = new \Stripe\StripeClient($StripeToken); //Instancia de la clase manejadora de clientes para la API de Stripe
|
||||||
|
|
||||||
if ($client_email !== null && $customerStripeID !== null) {
|
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"
|
$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"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -67,7 +67,7 @@ abstract class AbstractOxxoOperationsFacade
|
|||||||
$stripe = new \Stripe\StripeClient($StripeToken);
|
$stripe = new \Stripe\StripeClient($StripeToken);
|
||||||
$this->ucrmApi = UcrmApi::create();
|
$this->ucrmApi = UcrmApi::create();
|
||||||
$currentUserAdmin = $this->ucrmApi->get('users/admins', []);
|
$currentUserAdmin = $this->ucrmApi->get('users/admins', []);
|
||||||
$clientID = $event_json->client_id;
|
$clientID = $event_json['client_id'];
|
||||||
|
|
||||||
$stripeCustomerId = null;
|
$stripeCustomerId = null;
|
||||||
$clientEmail = '';
|
$clientEmail = '';
|
||||||
@ -123,7 +123,7 @@ abstract class AbstractOxxoOperationsFacade
|
|||||||
if ($amount > 10) {
|
if ($amount > 10) {
|
||||||
$amount = intval($amount * 100);
|
$amount = intval($amount * 100);
|
||||||
try {
|
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([
|
$paymentIntent = $stripe->paymentIntents->create([
|
||||||
'amount' => $amount,
|
'amount' => $amount,
|
||||||
'currency' => 'mxn',
|
'currency' => 'mxn',
|
||||||
|
|||||||
@ -368,7 +368,7 @@ class ClientCallBellAPI
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
curl_close($ch);
|
curl_close($ch);
|
||||||
$this->deleteFilesExceptLastFifty();
|
$this->deleteFilesExceptLastHundred();
|
||||||
//return $fileNameComprobante;
|
//return $fileNameComprobante;
|
||||||
return true;
|
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
|
* @return void
|
||||||
*/
|
*/
|
||||||
function deleteFilesExceptLastFifty()
|
function deleteFilesExceptLastHundred()
|
||||||
{
|
{
|
||||||
$log = PluginLogManager::create(); //Initialize Logger
|
$log = PluginLogManager::create(); //Initialize Logger
|
||||||
$directory = __DIR__ . '/../../comprobantes/';
|
$directory = __DIR__ . '/../../comprobantes/';
|
||||||
@ -1261,10 +1261,10 @@ class ClientCallBellAPI
|
|||||||
return filemtime($b) - filemtime($a);
|
return filemtime($b) - filemtime($a);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Verificar que haya más de 30 archivos
|
// Verificar que haya más de 100 archivos
|
||||||
if (count($files) > 50) {
|
if (count($files) > 100) {
|
||||||
// Obtener los archivos que deben ser eliminados (todos menos los 50 más recientes)
|
// Obtener los archivos que deben ser eliminados (todos menos los 100 más recientes)
|
||||||
$filesToDelete = array_slice($files, 50);
|
$filesToDelete = array_slice($files, 100);
|
||||||
|
|
||||||
// Eliminar los archivos
|
// Eliminar los archivos
|
||||||
foreach ($filesToDelete as $file) {
|
foreach ($filesToDelete as $file) {
|
||||||
|
|||||||
181
src/Plugin.php
@ -73,13 +73,13 @@ class Plugin
|
|||||||
// $hola = PHP_SAPI;
|
// $hola = PHP_SAPI;
|
||||||
// $this->logger->info('valor de PHP_SAPI: ' . $hola);
|
// $this->logger->info('valor de PHP_SAPI: ' . $hola);
|
||||||
if (PHP_SAPI === 'fpm-fcgi') {
|
if (PHP_SAPI === 'fpm-fcgi') {
|
||||||
$this->logger->debug('Whatsapp over HTTP started');
|
//$this->logger->debug('Whatsapp over HTTP started');
|
||||||
$this->processHttpRequest();
|
$this->processHttpRequest();
|
||||||
$this->logger->debug('HTTP request processing ended.');
|
//$this->logger->debug('HTTP request processing ended.');
|
||||||
} elseif (PHP_SAPI === 'cli') {
|
} elseif (PHP_SAPI === 'cli') {
|
||||||
$this->logger->debug('Whatsapp over CLI started');
|
//$this->logger->debug('Whatsapp over CLI started');
|
||||||
$this->processCli();
|
$this->processCli();
|
||||||
$this->logger->debug('CLI process ended.');
|
//$this->logger->debug('CLI process ended.');
|
||||||
} else {
|
} else {
|
||||||
throw new \UnexpectedValueException('Unknown PHP_SAPI type: ' . PHP_SAPI);
|
throw new \UnexpectedValueException('Unknown PHP_SAPI type: ' . PHP_SAPI);
|
||||||
}
|
}
|
||||||
@ -111,25 +111,29 @@ class Plugin
|
|||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$event_json = json_decode($userInput);
|
|
||||||
$webhook_string = json_encode($event_json);
|
|
||||||
$this->logger->debug("El valor de webhook_string: " . $webhook_string . PHP_EOL);
|
|
||||||
|
|
||||||
|
$jsonData = @json_decode($userInput, true, 10);
|
||||||
|
|
||||||
// Maneja el evento del webhook
|
if (!isset($jsonData['uuid'])) {
|
||||||
if ($event_json) {
|
$this->logger->info('No UUID found in the webhook data');
|
||||||
switch ($event_json->type) {
|
//$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':
|
case 'customer_cash_balance_transaction.created':
|
||||||
$this->logger->info('Evento de transfencia al cliente encontrado');
|
$this->logger->info('Evento de transfencia al cliente encontrado');
|
||||||
$this->logger->info('Valor del EventJSON: ' . json_encode($event_json) . PHP_EOL);
|
$this->logger->info('Valor del EventJSON: ' . json_encode($jsonData) . PHP_EOL);
|
||||||
$this->pluginNotifierFacade->createPaymentIntent($event_json);
|
$this->pluginNotifierFacade->createPaymentIntent($jsonData);
|
||||||
break;
|
break;
|
||||||
case 'inbound_payment.payment_attempt':
|
case 'inbound_payment.payment_attempt':
|
||||||
$this->logger->info('Evento de Pago de OXXO recibido');
|
$this->logger->info('Evento de Pago de OXXO recibido');
|
||||||
$this->logger->info('Valor del EventJSON: ' . json_encode($event_json) . PHP_EOL);
|
$this->logger->info('Valor del EventJSON: ' . json_encode($jsonData) . PHP_EOL);
|
||||||
break;
|
break;
|
||||||
case 'energy.alert':
|
case 'energy.alert':
|
||||||
$this->logger->info('Evento de Energía recibido: ' . $event_json->message . PHP_EOL);
|
$this->logger->info('Evento de Energía recibido: ' . $jsonData['message'] . PHP_EOL);
|
||||||
break;
|
break;
|
||||||
case 'oxxo.request':
|
case 'oxxo.request':
|
||||||
$this->logger->info('Evento de referencia de oxxo recibido' . PHP_EOL);
|
$this->logger->info('Evento de referencia de oxxo recibido' . PHP_EOL);
|
||||||
@ -137,14 +141,14 @@ class Plugin
|
|||||||
|
|
||||||
// Construir la URL basada en el "client_id"
|
// Construir la URL basada en el "client_id"
|
||||||
// $url = "https://siip.mx/wp/wp-content/uploads/img/voucher.png";
|
// $url = "https://siip.mx/wp/wp-content/uploads/img/voucher.png";
|
||||||
if (!empty($event_json->amount)) {
|
if (!empty($jsonData['amount'])) {
|
||||||
$this->logger->info('Referencia persnoalizada, Valor del monto: ' . $event_json->amount . PHP_EOL);
|
$this->logger->info('Referencia persnoalizada, Valor del monto: ' . $jsonData['amount'] . PHP_EOL);
|
||||||
$intentos = 0;
|
$intentos = 0;
|
||||||
do {
|
do {
|
||||||
if ($intentos > 1) {
|
if ($intentos > 1) {
|
||||||
sleep(2);
|
sleep(2);
|
||||||
}
|
}
|
||||||
$url = $this->pluginOxxoNotifierFacade->createOxxoPaymentIntent($event_json, $event_json->amount);
|
$url = $this->pluginOxxoNotifierFacade->createOxxoPaymentIntent($jsonData, $jsonData['amount']);
|
||||||
$intentos++;
|
$intentos++;
|
||||||
} while (strpos($url, 'https') !== 0 && $intentos < 5);
|
} while (strpos($url, 'https') !== 0 && $intentos < 5);
|
||||||
} else {
|
} else {
|
||||||
@ -153,7 +157,7 @@ class Plugin
|
|||||||
// if ($intentos > 1) {
|
// if ($intentos > 1) {
|
||||||
// sleep(2);
|
// sleep(2);
|
||||||
// }
|
// }
|
||||||
$url = $this->pluginOxxoNotifierFacade->createOxxoPaymentIntent($event_json);
|
$url = $this->pluginOxxoNotifierFacade->createOxxoPaymentIntent($jsonData);
|
||||||
$intentos++;
|
$intentos++;
|
||||||
} while (strpos($url, 'https') !== 0 && $intentos < 5);
|
} while (strpos($url, 'https') !== 0 && $intentos < 5);
|
||||||
}
|
}
|
||||||
@ -190,27 +194,32 @@ class Plugin
|
|||||||
// Otros eventos relevantes
|
// Otros eventos relevantes
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$jsonData = @json_decode($userInput, true, 10);
|
|
||||||
if (!isset($jsonData['uuid'])) {
|
|
||||||
$this->logger->error('JSON error: ' . json_last_error_msg());
|
|
||||||
|
|
||||||
return;
|
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);
|
$notification = $this->notificationDataFactory->getObject($jsonData);
|
||||||
$this->logger->debug('valor el evento recibido por webhook: ' . $notification->eventName . PHP_EOL);
|
$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') {
|
if ($notification->changeType === 'test') {
|
||||||
$this->logger->info('Webhook test successful.');
|
$this->logger->info('Webhook test successful.');
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!$notification->clientId) {
|
// if (!$notification->clientId) {
|
||||||
$this->logger->warning('No client specified, cannot notify them.');
|
// $this->logger->warning('No client specified, cannot notify them.');
|
||||||
|
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
|
||||||
$configManager = \Ubnt\UcrmPluginSdk\Service\PluginConfigManager::create();
|
$configManager = \Ubnt\UcrmPluginSdk\Service\PluginConfigManager::create();
|
||||||
$config = $configManager->loadConfig();
|
$config = $configManager->loadConfig();
|
||||||
@ -310,12 +319,30 @@ class Plugin
|
|||||||
|
|
||||||
|
|
||||||
} else if ($notification->eventName === 'client.edit') {
|
} else if ($notification->eventName === 'client.edit') {
|
||||||
$this->logger->debug('Se actualiza a un cliente' . PHP_EOL);
|
$this->logger->debug('Se actualiza a un cliente');
|
||||||
// Verificar que existen tanto 'entityBeforeEdit' como 'entity'
|
$this->logger->debug('Valor de json_data: ' . json_encode($jsonData));
|
||||||
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'];
|
|
||||||
|
|
||||||
|
// 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
|
// Comprobar si 'isLead' cambió de true a false
|
||||||
if ($isLeadBefore === true && $isLeadAfter === false) {
|
if ($isLeadBefore === true && $isLeadAfter === false) {
|
||||||
$this->logger->debug('El campo isLead cambió de true a false');
|
$this->logger->debug('El campo isLead cambió de true a false');
|
||||||
@ -323,14 +350,33 @@ class Plugin
|
|||||||
} else {
|
} else {
|
||||||
$this->logger->debug('No hubo cambio de true a false en el campo isLead');
|
$this->logger->debug('No hubo cambio de true a false en el campo isLead');
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$this->logger->warning('Los datos entityBeforeEdit o entity no contienen 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 están presentes en extraData');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->notifierFacade->verifyClientActionToDo($notification);
|
$this->notifierFacade->verifyClientActionToDo($notification);
|
||||||
} else if ($notification->eventName === 'client.add') {
|
} else if ($notification->eventName === 'client.add') {
|
||||||
$this->logger->debug('Se agregó un nuevo cliente' . PHP_EOL);
|
$this->logger->debug('Se agregó un nuevo cliente' . PHP_EOL);
|
||||||
|
// 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);
|
$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') {
|
} else if ($notification->eventName === 'service.suspend') {
|
||||||
$this->logger->debug('Se suspendió el servicio a un cliente' . PHP_EOL);
|
$this->logger->debug('Se suspendió el servicio a un cliente' . PHP_EOL);
|
||||||
$this->notifierFacade->verifyServiceActionToDo($notification);
|
$this->notifierFacade->verifyServiceActionToDo($notification);
|
||||||
@ -361,6 +407,75 @@ class Plugin
|
|||||||
} else if ($notification->eventName === 'invoice.edit') {
|
} else if ($notification->eventName === 'invoice.edit') {
|
||||||
$this->logger->debug('Edición de Factura' . PHP_EOL);
|
$this->logger->debug('Edición de Factura' . PHP_EOL);
|
||||||
$this->notifierFacade->verifyInvoiceActionToDo($notification);
|
$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));
|
call_user_func(\Composer\Autoload\ComposerStaticInitd6442a7ec79f2f43fc97d16bdcdd18ee::getInitializer($loader));
|
||||||
} else {
|
} 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';
|
$classMap = require __DIR__ . '/autoload_classmap.php';
|
||||||
if ($classMap) {
|
if ($classMap) {
|
||||||
$loader->addClassMap($classMap);
|
$loader->addClassMap($classMap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$loader->setClassMapAuthoritative(true);
|
||||||
$loader->register(true);
|
$loader->register(true);
|
||||||
|
|
||||||
if ($useStaticLoader) {
|
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"
|
"install-path": "../ubnt/ucrm-plugin-sdk"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"dev": true,
|
"dev": false,
|
||||||
"dev-package-names": []
|
"dev-package-names": []
|
||||||
}
|
}
|
||||||
|
|||||||
6
vendor/composer/installed.php
vendored
@ -5,9 +5,9 @@
|
|||||||
'type' => 'library',
|
'type' => 'library',
|
||||||
'install_path' => __DIR__ . '/../../',
|
'install_path' => __DIR__ . '/../../',
|
||||||
'aliases' => array(),
|
'aliases' => array(),
|
||||||
'reference' => '93a0f30eecd7b45a1b45bcb2c4642e734275029d',
|
'reference' => 'efd6f36c37acff90564096937d34b606769ee63c',
|
||||||
'name' => 'ucrm-plugins/sms-twilio',
|
'name' => 'ucrm-plugins/sms-twilio',
|
||||||
'dev' => true,
|
'dev' => false,
|
||||||
),
|
),
|
||||||
'versions' => array(
|
'versions' => array(
|
||||||
'firebase/php-jwt' => array(
|
'firebase/php-jwt' => array(
|
||||||
@ -307,7 +307,7 @@
|
|||||||
'type' => 'library',
|
'type' => 'library',
|
||||||
'install_path' => __DIR__ . '/../../',
|
'install_path' => __DIR__ . '/../../',
|
||||||
'aliases' => array(),
|
'aliases' => array(),
|
||||||
'reference' => '93a0f30eecd7b45a1b45bcb2c4642e734275029d',
|
'reference' => 'efd6f36c37acff90564096937d34b606769ee63c',
|
||||||
'dev_requirement' => false,
|
'dev_requirement' => false,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||