|
@@ -24,24 +24,36 @@ class OnuExportService
|
|
$this->container = $container;
|
|
$this->container = $container;
|
|
}
|
|
}
|
|
|
|
|
|
- public function send($tenancyId, $format){
|
|
|
|
|
|
+ public function send($tenancyId, $filename, $format, $className){
|
|
$amqpChannel = $this->container->get('amqp.channel');
|
|
$amqpChannel = $this->container->get('amqp.channel');
|
|
|
|
+ $notificationService = $this->container->get('notification_service');
|
|
|
|
|
|
try{
|
|
try{
|
|
- $msgBody = serialize([
|
|
|
|
- 'tenancyId' => $tenancyId,
|
|
|
|
- 'format' => $format,
|
|
|
|
- 'endpointToken' => 'https://'.getenv('HOST_BASE')."/oauth/v2/token",
|
|
|
|
- 'endpointOnus' => 'https://'.getenv('HOST_FTTH')."/api/onus-export",
|
|
|
|
- 'params' => [
|
|
|
|
- 'client_id' => getenv('OAUTH_CLIENT_ID'),
|
|
|
|
- 'client_secret' => getenv('OAUTH_CLIENT_SECRET'),
|
|
|
|
- 'grant_type' => 'client_credentials'
|
|
|
|
- ]
|
|
|
|
- ]);
|
|
|
|
- $amqpChannel->basic_publish(new AMQPMessage((string) $msgBody), '','export.ftth');
|
|
|
|
|
|
+ $notification = $notificationService->create('Onus enviado a la cola para procesar', $className, $tenancyId);
|
|
|
|
+ if(!is_null($notification)){
|
|
|
|
+ $msgBody = serialize([
|
|
|
|
+ 'tenancyId' => $tenancyId,
|
|
|
|
+ 'format' => $format,
|
|
|
|
+ 'filename' => $filename,
|
|
|
|
+ 'notificationId' => $notification['id'],
|
|
|
|
+ 'endpointBase' => 'https://'.getenv('HOST_BASE'),
|
|
|
|
+ 'endpointOnus' => 'https://'.getenv('HOST_FTTH')."/api/onus-export",
|
|
|
|
+ 'params' => [
|
|
|
|
+ 'client_id' => getenv('OAUTH_CLIENT_ID'),
|
|
|
|
+ 'client_secret' => getenv('OAUTH_CLIENT_SECRET'),
|
|
|
|
+ 'grant_type' => 'client_credentials'
|
|
|
|
+ ]
|
|
|
|
+ ]);
|
|
|
|
+ $amqpChannel->basic_publish(new AMQPMessage((string) $msgBody), '','export.ftth');
|
|
|
|
+ }else{
|
|
|
|
+ if ($this->container->has('monolog.logger.webservice')) {
|
|
|
|
+ $this->container->get('monolog.logger.webservice')->error("Can't create a notification in Base");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}catch (\Exception $ex){
|
|
}catch (\Exception $ex){
|
|
-
|
|
|
|
|
|
+ if ($this->container->has('monolog.logger.webservice')) {
|
|
|
|
+ $this->container->get('monolog.logger.webservice')->error($ex->getMessage());
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|