create sending webservices to panjereh vahed
This commit is contained in:
74
app/Services/PanjarehVahed/SendAccessRoadStatusService.php
Normal file
74
app/Services/PanjarehVahed/SendAccessRoadStatusService.php
Normal file
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\PanjarehVahed;
|
||||
|
||||
use Exception;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class SendAccessRoadStatusService
|
||||
{
|
||||
protected string $url;
|
||||
protected string $channelName;
|
||||
protected string $inputParameters;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->url = config('harim_web_services.Reject.url');
|
||||
$this->channelName = '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public function run(): array
|
||||
{
|
||||
try {
|
||||
return $this->sendRequest();
|
||||
}
|
||||
catch (Exception $e) {
|
||||
Log::channel($this->channelName)
|
||||
->error(get_class($this),
|
||||
[
|
||||
'message' => $e->getMessage(),
|
||||
]
|
||||
);
|
||||
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
private function sendRequest(): array
|
||||
{
|
||||
return Http::withHeaders(['Content-Type' => 'application/json'])
|
||||
->withBody($this->inputParameters)
|
||||
->throw()
|
||||
->withoutVerifying()
|
||||
->post($this->url)
|
||||
->json();
|
||||
}
|
||||
|
||||
public function makeInputParameters($data): void
|
||||
{
|
||||
$arrayData = json_decode($data, true);
|
||||
|
||||
$inputParameters = [
|
||||
'data' => [
|
||||
'actionId' => $arrayData['actionId'],
|
||||
'ruleId' => $arrayData['ruleId'],
|
||||
'activityId' => $arrayData['activityId'],
|
||||
'requestId' => $arrayData['requestId'],
|
||||
'taskId' => $arrayData['taskId'],
|
||||
'code' => $arrayData['code'],
|
||||
'resultStatus' => $arrayData['resultStatus'],
|
||||
'Description' => $arrayData['Description'],
|
||||
],
|
||||
'token' => $arrayData['token'],
|
||||
];
|
||||
|
||||
$key = config('harim_web_services.Harim_Info.key');
|
||||
$iv = config('harim_web_services.Harim_Info.iv');
|
||||
|
||||
$this->inputParameters = openssl_encrypt(json_encode($inputParameters), 'aes-256-cbc', $key, false, $iv);
|
||||
}
|
||||
}
|
||||
74
app/Services/PanjarehVahed/SendPaymentInfoService.php
Normal file
74
app/Services/PanjarehVahed/SendPaymentInfoService.php
Normal file
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\PanjarehVahed;
|
||||
|
||||
use Exception;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class SendPaymentInfoService
|
||||
{
|
||||
protected string $url;
|
||||
protected string $channelName;
|
||||
protected string $inputParameters;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->url = config('harim_web_services.Reject.url');
|
||||
$this->channelName = '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public function run(): array
|
||||
{
|
||||
try {
|
||||
return $this->sendRequest();
|
||||
}
|
||||
catch (Exception $e) {
|
||||
Log::channel($this->channelName)
|
||||
->error(get_class($this),
|
||||
[
|
||||
'message' => $e->getMessage(),
|
||||
]
|
||||
);
|
||||
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
private function sendRequest(): array
|
||||
{
|
||||
return Http::withHeaders(['Content-Type' => 'application/json'])
|
||||
->withBody($this->inputParameters)
|
||||
->throw()
|
||||
->withoutVerifying()
|
||||
->post($this->url)
|
||||
->json();
|
||||
}
|
||||
|
||||
public function makeInputParameters($data): void
|
||||
{
|
||||
$arrayData = json_decode($data, true);
|
||||
|
||||
$inputParameters = [
|
||||
'data' => [
|
||||
'actionId' => $arrayData['actionId'],
|
||||
'ruleId' => $arrayData['ruleId'],
|
||||
'activityId' => $arrayData['activityId'],
|
||||
'requestId' => $arrayData['requestId'],
|
||||
'taskId' => $arrayData['taskId'],
|
||||
'code' => $arrayData['code'],
|
||||
'warrantStatus' => $arrayData['warrantStatus'],
|
||||
'amountPaid' => $arrayData['amountPaid'],
|
||||
],
|
||||
'token' => $arrayData['token'],
|
||||
];
|
||||
|
||||
$key = config('harim_web_services.Harim_Info.key');
|
||||
$iv = config('harim_web_services.Harim_Info.iv');
|
||||
|
||||
$this->inputParameters = openssl_encrypt(json_encode($inputParameters), 'aes-256-cbc', $key, false, $iv);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user