create harim services
This commit is contained in:
42
app/Services/Cartables/Harim/FetchNewRequestsService.php
Normal file
42
app/Services/Cartables/Harim/FetchNewRequestsService.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Cartables\Harim;
|
||||
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class FetchNewRequestsService
|
||||
{
|
||||
protected string $url;
|
||||
protected string $channelName;
|
||||
protected string $username;
|
||||
protected string $password;
|
||||
public function __construct()
|
||||
{
|
||||
$this->url = config('cmms_web_services.MACHINE_INFO.url');
|
||||
$this->username = config('cmms_web_services.MACHINE_INFO.ViewName');
|
||||
$this->password = config('cmms_web_services.MACHINE_INFO.password');
|
||||
}
|
||||
|
||||
public function run(): array
|
||||
{
|
||||
try {
|
||||
return $this->sendRequest();
|
||||
}
|
||||
catch (Exception $e) {
|
||||
Log::channel($this->channelName)
|
||||
->error(get_class($this),
|
||||
[
|
||||
'message' => $e->getMessage(),
|
||||
]
|
||||
);
|
||||
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
public function sendRequest()
|
||||
{
|
||||
return Http::post($this->url, [])->json();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user