remove compose file to another repo

This commit is contained in:
2025-05-05 15:30:11 +03:30
parent 02ef3ae2ad
commit 3b739558ee
179 changed files with 130 additions and 341 deletions

View File

@@ -0,0 +1,37 @@
<?php
namespace App\Services\Notification\Exceptions;
use App\Exceptions\Throwable;
use Exception;
use Illuminate\Http\JsonResponse;
class NotificationServerNotRespondingException extends Exception
{
public $message;
public function __construct(string $message = "", int $code = 500, ?Throwable $previous = null)
{
$this->message = $message;
parent::__construct($message, $code, $previous);
}
/**
* Report the exception.
*/
public function report(): void
{
// ...
}
/**
* Render the exception into an HTTP response.
*/
public function render(): JsonResponse
{
return response()->json([
'message' => $this->message
], $this->code);
}
}

View File

@@ -0,0 +1,40 @@
<?php
namespace App\Services\Notification\Exceptions;
use App\Exceptions\Throwable;
use Exception;
use Illuminate\Http\JsonResponse;
use Illuminate\Support\Facades\Log;
class OperatorNotConnectedException extends Exception
{
public $message;
public function __construct(string $message = "", int $code = 500, ?Throwable $previous = null)
{
$this->message = $message;
parent::__construct($message, $code, $previous);
}
/**
* Report the exception.
*/
public function report(): void
{
Log::channel('notification_service')
->error(OperatorNotConnectedException::class,[__('messages.operator_could_not_connect')]
);
}
/**
* Render the exception into an HTTP response.
*/
public function render(): JsonResponse
{
return response()->json([
'message' => $this->message
], $this->code);
}
}

View File

@@ -0,0 +1,40 @@
<?php
namespace App\Services\Notification\Exceptions;
use App\Exceptions\Throwable;
use Exception;
use Illuminate\Http\JsonResponse;
use Illuminate\Support\Facades\Log;
class OperatorOfflineException extends Exception
{
public $message;
public function __construct(string $message = "", int $code = 500, ?Throwable $previous = null)
{
$this->message = $message;
parent::__construct($message, $code, $previous);
}
/**
* Report the exception.
*/
public function report(): void
{
Log::channel('notification_service')
->error(OperatorOfflineException::class, [__('messages.the_operator_is_offline')]
);
}
/**
* Render the exception into an HTTP response.
*/
public function render(): JsonResponse
{
return response()->json([
'message' => $this->message
], $this->code);
}
}

View File

@@ -0,0 +1,47 @@
<?php
namespace App\Services\Notification;
use App\Services\Notification\Exceptions\NotificationServerNotRespondingException;
use App\Services\Notification\Exceptions\OperatorNotConnectedException;
use App\Services\Notification\Exceptions\OperatorOfflineException;
use Illuminate\Http\Client\ConnectionException;
use Illuminate\Http\Client\RequestException;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Log;
class NotificationService
{
public function deliverDataToNotificationServer(array $data): void
{
try
{
$response = Http::retry(3)
->post(config('globalVariables.NOTIFICATION_SERVER_URL'), $data)
->throwIfServerError();
$response_status = json_decode($response->body())->status;
throw_if($response_status == 1,
new OperatorOfflineException(__('messages.the_operator_is_offline'))
);
throw_if($response_status == 2,
new OperatorNotConnectedException(__('messages.operator_could_not_connect'))
);
}
catch (RequestException $exception)
{
Log::channel('notification_service')
->error(RequestException::class, [
$exception->getMessage(),
NotificationServerNotRespondingException::class,
__('messages.notification_server_is_down')
]);
throw_if($exception->response->serverError(),
new NotificationServerNotRespondingException(__('messages.notification_server_is_down'))
);
}
}
}