mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-28 17:04:06 +00:00
41 lines
1.4 KiB
PHP
41 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Classes\Modules\Unity\Services;
|
|
|
|
use Config;
|
|
use Illuminate\Support\Facades\Http;
|
|
use Illuminate\Support\Facades\Log;
|
|
use App\Classes\Modules\Unity\Services\GetAccessToken;
|
|
|
|
class UpdatesContractObligation
|
|
{
|
|
private $getAccessToken;
|
|
|
|
private $updateContractStatusEndpoint;
|
|
|
|
public function __construct(GetAccessToken $getAccessToken)
|
|
{
|
|
$this->updateContractStatusEndpoint = Config::get('unity.url').Config::get('unity.endpoint.update_obligation_status');
|
|
$this->getAccessToken = $getAccessToken;
|
|
}
|
|
|
|
public function execute($contract_entity_signature, $obligation_hash_id){
|
|
|
|
if(!config('unity.enabled')) return (object)['status' => 3, 'completed_at' => date('Y-m-d H:i:s')];
|
|
|
|
Log::info('[UpdatesContractObligation] UNITY CALLED', [
|
|
'contract_entity_signature' => $contract_entity_signature,
|
|
'obligation_hash_id' => $obligation_hash_id,
|
|
]);
|
|
|
|
$accessToken=$this->getAccessToken->execute();
|
|
|
|
$this->updateContractStatusEndpoint = str_replace('{hash}', $obligation_hash_id, $this->updateContractStatusEndpoint);
|
|
|
|
$response = Http::withoutVerifying()->withToken($accessToken)->put($this->updateContractStatusEndpoint,['entity_signature_id'=>$contract_entity_signature])->object();
|
|
|
|
return (isset($response->data)) ? $response->data : null;
|
|
|
|
}
|
|
}
|