mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-29 17:34:09 +00:00
Merge branch 'dillon/172-explore-unity-server-shut-down' into vapor/production
This commit is contained in:
@@ -51,6 +51,7 @@ MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
|
||||
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
|
||||
|
||||
UNITY_APP_URL="https://unity.izyim.com"
|
||||
UNITY_ENABLED=true
|
||||
EXCHANGE_URL=https://dev.exchange.cief-malaysia.com/
|
||||
MIX_EXCHANGE_URL="${EXCHANGE_URL}"
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace App\Classes\Modules\Companies\Standards\Validators;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractValidation;
|
||||
use App\Classes\Modules\Companies\DataTransferObjects\CompanyObject;
|
||||
use Config;
|
||||
|
||||
class CompanyModuleValidation extends AbstractValidation
|
||||
{
|
||||
@@ -25,9 +26,11 @@ class CompanyModuleValidation extends AbstractValidation
|
||||
*/
|
||||
protected function rules(): array
|
||||
{
|
||||
$required = !config('unity.enabled') ? 'nullable' : 'required';
|
||||
|
||||
return [
|
||||
'unity_hash_id' => 'required',
|
||||
'unity_signature' => 'required'
|
||||
'unity_hash_id' => $required,
|
||||
'unity_signature' => $required
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -132,37 +132,51 @@ class AssignPackingListOrderLogic extends AbstractControllerLogic
|
||||
$transport = $warehouse_packing_list->transports()->first();
|
||||
$transport = $this->updatesTransportStatus->execute($transport, ApprovalStatus::APPROVED);
|
||||
|
||||
$contract = $this->unityCreateContract->execute();
|
||||
$contractReference = $contract->hash_id;
|
||||
$contractObligations = $contract->contract_obligation_list;
|
||||
if(config('unity.enabled')) {
|
||||
$contract = $this->unityCreateContract->execute();
|
||||
$contractReference = $contract->hash_id;
|
||||
$contractObligations = $contract->contract_obligation_list;
|
||||
|
||||
$this->unityActivateContract->execute($contractReference);
|
||||
$supervisorHashId = $order->orderRoles()->where('role_id', '=', OrderRoleTypes::SUPERVISOR)->first()->appointee->unity_hash_id;
|
||||
$this->unityActivateContract->execute($contractReference);
|
||||
$supervisorHashId = $order->orderRoles()->where('role_id', '=', OrderRoleTypes::SUPERVISOR)->first()->appointee->unity_hash_id;
|
||||
|
||||
$supervisorContractEntity = $this->unityCreateContractEntity->execute($contractReference, $supervisorHashId);
|
||||
$order->orderRoles()->where('role_id', '=', OrderRoleTypes::SUPERVISOR)->first()->update(['entity_hash_id' => $supervisorContractEntity->hash_id, 'entity_signature' => $supervisorContractEntity->entity_signature_hash_id]);
|
||||
$supervisorContractEntity = $this->unityCreateContractEntity->execute($contractReference, $supervisorHashId);
|
||||
$order->orderRoles()->where('role_id', '=', OrderRoleTypes::SUPERVISOR)->first()->update(['entity_hash_id' => $supervisorContractEntity->hash_id, 'entity_signature' => $supervisorContractEntity->entity_signature_hash_id]);
|
||||
|
||||
$importerContractEntity = $this->unityCreateContractEntity->execute($contractReference, $order->orderRoles()->where('role_id', '=', OrderRoleTypes::IMPORTER)->first()->appointee->unity_hash_id);
|
||||
$order->orderRoles()->where('role_id', '=', OrderRoleTypes::IMPORTER)->first()->update(['entity_hash_id' => $importerContractEntity->hash_id, 'entity_signature' => $importerContractEntity->entity_signature_hash_id]);
|
||||
$importerContractEntity = $this->unityCreateContractEntity->execute($contractReference, $order->orderRoles()->where('role_id', '=', OrderRoleTypes::IMPORTER)->first()->appointee->unity_hash_id);
|
||||
$order->orderRoles()->where('role_id', '=', OrderRoleTypes::IMPORTER)->first()->update(['entity_hash_id' => $importerContractEntity->hash_id, 'entity_signature' => $importerContractEntity->entity_signature_hash_id]);
|
||||
|
||||
$this->unityAssignContractEntity->execute($supervisorContractEntity->hash_id, $contractObligations);
|
||||
$this->unityAssignContractEntity->execute($supervisorContractEntity->hash_id, $contractObligations);
|
||||
|
||||
try {
|
||||
$packing_list = $this->fetchesPackingList->execute([
|
||||
'reference' => $warehouse_packing_list->reference,
|
||||
'type' => PackingListType::SHIPPING_PACKING_LIST
|
||||
]);
|
||||
try {
|
||||
$packing_list = $this->fetchesPackingList->execute([
|
||||
'reference' => $warehouse_packing_list->reference,
|
||||
'type' => PackingListType::SHIPPING_PACKING_LIST
|
||||
]);
|
||||
|
||||
$warehouse_packing_list = $this->updatesPackingListOwner->execute($packing_list, $order);
|
||||
$warehouse_packing_list = $this->updatesPackingListOwner->execute($packing_list, $order);
|
||||
|
||||
$this->updatesPackingListContractReference->execute($packing_list, $contractReference);
|
||||
$this->updatesPackingListContractReference->execute($packing_list, $contractReference);
|
||||
|
||||
foreach($contractObligations as $obligation) {
|
||||
$stepObject = new StepsObject($order->orderRoles()->where('role_id', '=', OrderRoleTypes::SUPERVISOR)->first()->appointee->id, $obligation->reference, $obligation->sequence, $obligation->hash_id);
|
||||
$this->createsStep->execute($packing_list, $stepObject);
|
||||
}
|
||||
} catch (ResourceNotFoundException $exception) {
|
||||
|
||||
foreach($contractObligations as $obligation) {
|
||||
$stepObject = new StepsObject($order->orderRoles()->where('role_id', '=', OrderRoleTypes::SUPERVISOR)->first()->appointee->id, $obligation->reference, $obligation->sequence, $obligation->hash_id);
|
||||
$this->createsStep->execute($packing_list, $stepObject);
|
||||
}
|
||||
} catch (ResourceNotFoundException $exception) {
|
||||
}
|
||||
else{
|
||||
try {
|
||||
$packing_list = $this->fetchesPackingList->execute([
|
||||
'reference' => $warehouse_packing_list->reference,
|
||||
'type' => PackingListType::SHIPPING_PACKING_LIST
|
||||
]);
|
||||
$warehouse_packing_list = $this->updatesPackingListOwner->execute($packing_list, $order);
|
||||
|
||||
} catch (ResourceNotFoundException $exception) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Update Packing Lists' packages info,
|
||||
|
||||
@@ -37,6 +37,7 @@ use App\Models\Order;
|
||||
use App\Models\PackingList;
|
||||
use App\Models\Transport;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Str;
|
||||
@@ -139,6 +140,9 @@ class FetchOrderListsFromYdPortalProcessor
|
||||
*/
|
||||
public function execute(?Carbon $start = null, ?Carbon $end = null)
|
||||
{
|
||||
Log::info('FetchOrderListsFromYdPortalProcessor no longer in use, use FetchOrderListsFromYdPortalV2Processor instead');
|
||||
return;
|
||||
|
||||
ini_set('max_execution_time', '900');
|
||||
// $missingOrders = ['M202302161513122', 'YW202302161027442', 'YW202302151637022', 'M202302151605025', 'M202302151527103', 'M202302151527356', 'M202302151556019', 'YW202302151520241', 'YW202302151445068', 'M202302151359169', 'YW202302151349223', 'YW202302151336520', 'M202302151334316', 'YW202302151148129', 'M202302151145379', 'M202302151142411', 'M202302151037036', 'M202302151036398', 'M202302150919406', 'M202302141535009', 'YW202302141532318', 'M202302141319463', 'M202302141319045', 'YW202302141405471', 'M202302141334494', 'YW202302141321569', 'YW202302141323005', 'M202302141309053', 'M202302140905116', 'M202302141039558', 'M202302141022333', 'YW202302140943182', 'YW202302140923485', 'YW202302131728233', 'YW202302131702040', 'M202302131649417', 'M202302131638056', 'YW202302131601110', 'YW202302131530436', 'YW202302131411338', 'YW202302131355161', 'YW202302131312526', 'M202302130859076', 'M202302111708070', 'M202302111455134', 'M202302111457501', 'M202302111444041', 'M202302111506514', 'M202302111440286', 'M202302111354585', 'M202302111055551', 'M202302110900216', 'YW202302101743112', 'M202302091559443', 'M202302101716374', 'M202302101700402', 'M202302101633570', 'M202302101612095', 'M202302101611408', 'M202302101542340', 'M202302101408370', 'M202302101323341', 'M202302101129532', 'M202302101025109', 'M202302101006595', 'M202302091706357', 'YW202302091255022', 'YW202302091448196', 'YW202302091446431', 'M202302091138154', 'M202302091129396', 'YW202302091028175', 'M202302091006545', 'YW202302090942033', 'YW202302081743094', 'M202302081530599', 'M202302081531210', 'M202302081508571', 'YW202302081530492', 'M202302081500361', 'M202302081253105', 'M202302081303370', 'M202302071636303', 'M202302071741187', 'YW202302071735407', 'M202302071706323', 'M202302071537501', 'M202302071538092', 'YW202302071516453', 'M202302071311314', 'M202302071148154', 'YW202302071136018', 'M202302071036027', 'M202302071008010', 'M202302061742178', 'M202302061615198', 'M202302061502093', 'M202302061458532', 'M202302061552141', 'M202302061548431', 'M202302061555033', 'YW202302061404567', 'M202302061322463', 'M202302061042556', 'M202302061021277', 'M202302060917276', 'M202302041551570', 'M202302041552382', 'YW202302041515257', 'M202302041405502', 'M202302041030185', 'YW202302041215576', 'YW202302041058469', 'YW202302041024459', 'YW202302040939568', 'M202302031701053', 'M202302031700316', 'M202302031430562', 'M202302031431535', 'M202302031147213', 'YW202302031406529', 'YW202302031322256', 'M202302021718554', 'M202302021417415', 'YW202302021404542', 'M202302021055324', 'YW202302021037462', 'M202302011613381', 'M202302011347586', 'M202302011348245', 'M202301151635132', 'M202301141803516', 'YW202301141653536', 'M202301131504477', 'M202301131538220', 'M202301121327453', 'YW202301111153183', 'M202301091649543', 'M202212311641071', 'YW202212211532191', 'YW202212191605226'];
|
||||
|
||||
|
||||
+5
-1
@@ -27,6 +27,7 @@ use App\Models\Order;
|
||||
use App\Models\PackingList;
|
||||
use Carbon\Carbon;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
@@ -107,6 +108,9 @@ class FetchPackingListsFromYdPortalProcessor
|
||||
*/
|
||||
public function execute(?Carbon $start = null, ?Carbon $end = null)
|
||||
{
|
||||
Log::info('FetchPackingListsFromYdPortalProcessor no longer in use, use FetchPackingListsFromYdPortalV2Processor instead');
|
||||
return;
|
||||
|
||||
$from = $end ? Carbon::today()->diff($end)->days : 0;
|
||||
$to = $start ? Carbon::today()->diff($start)->days : 10;
|
||||
|
||||
@@ -143,7 +147,7 @@ class FetchPackingListsFromYdPortalProcessor
|
||||
if (strpos($customerno, '正确唛头YD') !== false) {
|
||||
$customerno = explode('正确唛头YD', $customerno)[1];
|
||||
}
|
||||
|
||||
|
||||
$customerno = preg_split('/[-()\/]/', $customerno);
|
||||
|
||||
$orderNumber = $customerno[array_key_last($customerno)];
|
||||
|
||||
+11
-4
@@ -38,6 +38,7 @@ use App\Models\Order;
|
||||
use App\Models\PackingList;
|
||||
use App\Models\Transport;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Str;
|
||||
@@ -139,6 +140,12 @@ class FetchOrderListsFromYdPortalV2Processor
|
||||
*/
|
||||
public function execute(Carbon $startDate = null, Carbon $endDate = null)
|
||||
{
|
||||
// cief todo: 172
|
||||
// if(!config('unity.enabled')) {
|
||||
// Log::info('FetchOrderListsFromYdPortalV2Processor skipped: UNITY_ENABLED is false');
|
||||
// return;
|
||||
// }
|
||||
|
||||
Log::info('FetchOrderListsFromYdPortalV2Processor starts for start date: ' . $startDate . ', and end date: ' . $endDate);
|
||||
// return;
|
||||
|
||||
@@ -303,7 +310,7 @@ class FetchOrderListsFromYdPortalV2Processor
|
||||
$transportObject = new TransportObject(TransportType::LAND, null, $row->kuaidilist, Carbon::parse($receiveDate), Carbon::parse($receiveDate), $allow_contract ? ApprovalStatus::APPROVED : ApprovalStatus::REJECTED);
|
||||
$transport = $this->createsTransport->execute($transportObject, $warehouseReceiveList);
|
||||
|
||||
if ($allow_contract) {
|
||||
if (config('unity.enabled') && $allow_contract) {
|
||||
|
||||
$contract = $this->unityCreateContract->execute();
|
||||
|
||||
@@ -328,7 +335,7 @@ class FetchOrderListsFromYdPortalV2Processor
|
||||
/** @var PackingList $packingList */
|
||||
$packingList = $this->createPackingListProcessor->execute($packingListObject, $order);
|
||||
|
||||
if ($allow_contract) {
|
||||
if (config('unity.enabled') && $allow_contract) {
|
||||
foreach ($contractObligations as $obligation) {
|
||||
$stepObject = new StepsObject($order->orderRoles()->where('role_id', '=', OrderRoleTypes::SUPERVISOR)->first()->appointee->id, $obligation->reference, $obligation->sequence, $obligation->hash_id);
|
||||
$this->createsStep->execute($packingList, $stepObject);
|
||||
@@ -432,7 +439,7 @@ class FetchOrderListsFromYdPortalV2Processor
|
||||
$packingList->save();
|
||||
}
|
||||
|
||||
if ($allow_contract) {
|
||||
if (config('unity.enabled') && $allow_contract) {
|
||||
$signature = $packingList->owner->orderRoles()->where('role_id', '=', OrderRoleTypes::SUPERVISOR)->first()->appointee->entity_sigiture;
|
||||
foreach($packingList->steps()->where('reference', '!=', 'DELIVERY')->get() as $step){
|
||||
$this->updatesContractObligations->execute($signature, $step->obligation_hash_id);
|
||||
@@ -455,7 +462,7 @@ class FetchOrderListsFromYdPortalV2Processor
|
||||
$this->createsSchedule->execute($transport, new ScheduleObject($deliveryDate, $deliveryDate, ApprovalStatus::APPROVED));
|
||||
|
||||
|
||||
if ($allow_contract) {
|
||||
if (config('unity.enabled') && $allow_contract) {
|
||||
$deliveryStep = $packingList->steps()->where('reference', '=', 'LAST_MILE_DELIVERY')->first();
|
||||
$signature = $packingList->owner->orderRoles()->where('role_id', '=', OrderRoleTypes::SUPERVISOR)->first()->appointee->entity_sigiture;
|
||||
$this->updatesContractObligations->execute($signature, $deliveryStep->obligation_hash_id);
|
||||
|
||||
+9
-2
@@ -31,6 +31,7 @@ use Carbon\Carbon;
|
||||
use DateTime;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
@@ -111,6 +112,12 @@ class FetchPackingListsFromYdPortalV2Processor
|
||||
*/
|
||||
public function execute(Carbon $startDate = null, Carbon $endDate = null)
|
||||
{
|
||||
// cief todo: 172
|
||||
// if(!config('unity.enabled')) {
|
||||
// Log::info('FetchPackingListsFromYdPortalV2Processor skipped: UNITY_ENABLED is false');
|
||||
// return;
|
||||
// }
|
||||
|
||||
Log::info('FetchPackingListsFromYdPortalV2Processor starts for start date: ' . $startDate . ', and end date: ' . $endDate);
|
||||
// return;
|
||||
|
||||
@@ -200,7 +207,7 @@ class FetchPackingListsFromYdPortalV2Processor
|
||||
$transportObject = new TransportObject(TransportType::LAND, null, $row->kuaidilist, Carbon::parse($receiveDate), Carbon::parse($receiveDate), $allow_contract ? ApprovalStatus::APPROVED : ApprovalStatus::REJECTED);
|
||||
$transport = $this->createsTransport->execute($transportObject, $warehouseReceiveList);
|
||||
|
||||
if ($allow_contract) {
|
||||
if (config('unity.enabled') && $allow_contract) {
|
||||
|
||||
$contract = $this->unityCreateContract->execute();
|
||||
|
||||
@@ -226,7 +233,7 @@ class FetchPackingListsFromYdPortalV2Processor
|
||||
$packingList = $this->createPackingListProcessor->execute($packingListObject, $order);
|
||||
Log::info('Create SHIPPING_PACKING_LIST id: ' . $packingList->id);
|
||||
|
||||
if ($allow_contract) {
|
||||
if (config('unity.enabled') && $allow_contract) {
|
||||
foreach ($contractObligations as $obligation) {
|
||||
$stepObject = new StepsObject($order->orderRoles()->where('role_id', '=', OrderRoleTypes::SUPERVISOR)->first()->appointee->id, $obligation->reference, $obligation->sequence, $obligation->hash_id);
|
||||
$this->createsStep->execute($packingList, $stepObject);
|
||||
|
||||
@@ -4,6 +4,7 @@ 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 ActivatesContract
|
||||
@@ -20,11 +21,17 @@ class ActivatesContract
|
||||
|
||||
public function execute($contract_hash_id){
|
||||
|
||||
if(!config('unity.enabled')) return null;
|
||||
|
||||
Log::info('[ActivatesContract] UNITY CALLED', [
|
||||
'contract_hash_id' => $contract_hash_id,
|
||||
]);
|
||||
|
||||
$accessToken=$this->getAccessToken->execute();
|
||||
|
||||
$this->activateEntityEndpoint = str_replace('{hash}',$contract_hash_id,$this->activateEntityEndpoint);
|
||||
|
||||
$response = Http::withToken($accessToken)->put($this->activateEntityEndpoint)->object();
|
||||
$response = Http::withoutVerifying()->withToken($accessToken)->put($this->activateEntityEndpoint)->object();
|
||||
|
||||
return (isset($response->data)) ? $response->data : null;
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ 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 CreatesContract
|
||||
@@ -23,10 +24,13 @@ class CreatesContract
|
||||
|
||||
public function execute(){
|
||||
|
||||
if(!config('unity.enabled')) return null;
|
||||
|
||||
Log::info('[CreatesContract] UNITY CALLED');
|
||||
|
||||
$accessToken=$this->getAccessToken->execute();
|
||||
|
||||
$response = Http::withToken($accessToken)->post($this->createEntityEndpoint,['contract_template_id'=>[$this->contract_hash_id]])->object();
|
||||
$response = Http::withoutVerifying()->withToken($accessToken)->post($this->createEntityEndpoint,['contract_template_id'=>[$this->contract_hash_id]])->object();
|
||||
|
||||
return (isset($response->data)) ? $response->data : null;
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ 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 CreatesContractEntity
|
||||
@@ -23,8 +24,15 @@ class CreatesContractEntity
|
||||
|
||||
public function execute(string $new_contract_id, string $entity_hash_ids){
|
||||
|
||||
if(!config('unity.enabled')) return null;
|
||||
|
||||
Log::info('[CreatesContractEntity] UNITY CALLED', [
|
||||
'new_contract_id' => $new_contract_id,
|
||||
'entity_hash_ids' => $entity_hash_ids,
|
||||
]);
|
||||
|
||||
$accesToken=$this->getAccessToken->execute();
|
||||
$response = Http::withToken($accesToken)->post($this->createContractEntityEndpoint,['contract_id'=>[$new_contract_id],'entity_id'=>$entity_hash_ids])->object();
|
||||
$response = Http::withoutVerifying()->withToken($accesToken)->post($this->createContractEntityEndpoint,['contract_id'=>[$new_contract_id],'entity_id'=>$entity_hash_ids])->object();
|
||||
return (isset($response->data)) ? $response->data : null;
|
||||
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ 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 CreatesEntity
|
||||
@@ -20,9 +21,15 @@ class CreatesEntity
|
||||
|
||||
public function execute($entity_name){
|
||||
|
||||
if(!config('unity.enabled')) return (object)['hash_id' => ''];
|
||||
|
||||
Log::info('[CreatesEntity] UNITY CALLED', [
|
||||
'entity_name' => $entity_name,
|
||||
]);
|
||||
|
||||
$accesToken= $this->getAccessToken->execute();
|
||||
|
||||
$response = Http::withToken($accesToken)->post($this->createEntityEndpoint,['name'=>$entity_name])->object();
|
||||
$response = Http::withoutVerifying()->withToken($accesToken)->post($this->createEntityEndpoint,['name'=>$entity_name])->object();
|
||||
|
||||
return (isset($response->data)) ? $response->data : null;
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ 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 CreatesEntitySignature
|
||||
@@ -20,9 +21,15 @@ class CreatesEntitySignature
|
||||
|
||||
public function execute(string $entity_hash_id){
|
||||
|
||||
if(!config('unity.enabled')) return (object)['hash_id' => ''];
|
||||
|
||||
Log::info('[CreatesEntitySignature] UNITY CALLED', [
|
||||
'entity_hash_id' => $entity_hash_id,
|
||||
]);
|
||||
|
||||
$accesToken=$this->getAccessToken->execute();
|
||||
|
||||
$response = Http::withToken($accesToken)->post($this->createEntitySignatureEndpoint,['entity_id'=>[$entity_hash_id], 'type'=>'1'])->object();
|
||||
$response = Http::withoutVerifying()->withToken($accesToken)->post($this->createEntitySignatureEndpoint,['entity_id'=>[$entity_hash_id], 'type'=>'1'])->object();
|
||||
|
||||
return (isset($response->data)) ? $response->data : null;
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace App\Classes\Modules\Unity\Services;
|
||||
use Config;
|
||||
use Cache;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class GetAccessToken
|
||||
{
|
||||
@@ -35,10 +36,14 @@ class GetAccessToken
|
||||
|
||||
public function execute(){
|
||||
|
||||
if(!config('unity.enabled')) return "";
|
||||
|
||||
if(!empty($this->getCachedAccessToken())) return $this->getCachedAccessToken();
|
||||
|
||||
Log::info('[GetAccessToken] UNITY CALLED');
|
||||
|
||||
if(empty($this->apiKey)){
|
||||
$response = Http::post($this->getAccessTokenEndpoint, [
|
||||
$response = Http::withoutVerifying()->post($this->getAccessTokenEndpoint, [
|
||||
'email' => $this->username,
|
||||
'password' => $this->password ,
|
||||
])->object();
|
||||
|
||||
@@ -4,6 +4,7 @@ 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 GetContractObligations
|
||||
@@ -21,9 +22,13 @@ class GetContractObligations
|
||||
|
||||
public function execute(){
|
||||
|
||||
if(!config('unity.enabled')) return [];
|
||||
|
||||
Log::info('[GetContractObligations] UNITY CALLED');
|
||||
|
||||
$accesToken=$this->getAccessToken->execute();
|
||||
|
||||
$response = Http::withToken($accesToken)->get($this->getContractObligationsEndpoint)->object();
|
||||
$response = Http::withoutVerifying()->withToken($accesToken)->get($this->getContractObligationsEndpoint)->object();
|
||||
|
||||
return (isset($response->data)) ? $response->data : [];
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ 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 UpdatesContractEntity
|
||||
@@ -20,11 +21,18 @@ class UpdatesContractEntity
|
||||
|
||||
public function execute(string $obligation_hash_id, array $entity_hash_id){
|
||||
|
||||
if(!config('unity.enabled')) return null;
|
||||
|
||||
Log::info('[UpdatesContractEntity] UNITY CALLED', [
|
||||
'obligation_hash_id' => $obligation_hash_id,
|
||||
'entity_hash_id' => $entity_hash_id,
|
||||
]);
|
||||
|
||||
$accessToken=$this->getAccessToken->execute();
|
||||
|
||||
$this->assignEntityEndpoint = str_replace('{hash}',$obligation_hash_id,$this->assignEntityEndpoint);
|
||||
|
||||
$response = Http::withToken($accessToken)->put( $this->assignEntityEndpoint,['contract_entity_id'=>$entity_hash_id])->object();
|
||||
$response = Http::withoutVerifying()->withToken($accessToken)->put( $this->assignEntityEndpoint,['contract_entity_id'=>$entity_hash_id])->object();
|
||||
|
||||
return (isset($response->data)) ? $response->data : null;
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ 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
|
||||
@@ -20,11 +21,18 @@ class UpdatesContractObligation
|
||||
|
||||
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::withToken($accessToken)->put($this->updateContractStatusEndpoint,['entity_signature_id'=>$contract_entity_signature])->object();
|
||||
$response = Http::withoutVerifying()->withToken($accessToken)->put($this->updateContractStatusEndpoint,['entity_signature_id'=>$contract_entity_signature])->object();
|
||||
|
||||
return (isset($response->data)) ? $response->data : null;
|
||||
|
||||
|
||||
@@ -41,6 +41,8 @@ return [
|
||||
|
||||
'on_error_email' => env('UNITY_ON_ERROR_EMAIL','dev@shipping.com,dev@unity.com'),
|
||||
|
||||
'enabled' => env('UNITY_ENABLED', false),
|
||||
|
||||
'contract_template_hash_id' => env('UNITY_CONTRACT_TEMPLATE_HASH_ID', 'Kp3qzMV82m5R2PZg6eX0'),
|
||||
|
||||
'contract_template_cache' => env('UNITY_CONTRACT_TEMPLATE_CACHE','60'),
|
||||
|
||||
Reference in New Issue
Block a user