mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/portal.git
synced 2026-08-29 17:34:25 +00:00
WIP Unity Order APIs
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Unity\Processors;
|
||||
|
||||
use Config;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use App\Classes\Modules\Unity\Services\CreatesContractEntity;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompany;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CreateContractEntityProcessor
|
||||
{
|
||||
private $createsContractEntity;
|
||||
|
||||
private $fetchesCompany;
|
||||
|
||||
public function __construct(CreatesContractEntity $createsContractEntity, FetchesCompany $fetchesCompany)
|
||||
{
|
||||
$this->createsContractEntity = $createsContractEntity;
|
||||
$this->fetchesCompany = $fetchesCompany;
|
||||
}
|
||||
|
||||
public function execute(Request $request, string $new_contract_id, array $obligations){
|
||||
|
||||
$entity_hash_ids = [];
|
||||
|
||||
$companies = $this->fetchesCompany->getRepository()->whereIn('id',[1, $request->get('warehouse_id')])->get();
|
||||
|
||||
$cief_company = $companies[0]->id == 1 ? $companies[0] : $companies[1];
|
||||
$warehouse_company = $companies[0]->id != 1 ? $companies[0] : $companies[1];
|
||||
|
||||
$entity_hash_ids[] = $cief_company->companyModule()->first()->unity_hash_id;
|
||||
$entity_hash_ids[] = $warehouse_company->companyModule()->first()->unity_hash_id;
|
||||
|
||||
return $this->createsContractEntity->execute($new_contract_id, $entity_hash_ids);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Unity\Services;
|
||||
|
||||
use Config;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use App\Classes\Modules\Unity\Services\GetAccessToken;
|
||||
|
||||
class CreatesContractEntity
|
||||
{
|
||||
private $getAccessToken;
|
||||
|
||||
private $createContractEntityEndpoint;
|
||||
|
||||
private $contract_hash_id;
|
||||
|
||||
public function __construct(GetAccessToken $getAccessToken)
|
||||
{
|
||||
$this->createContractEntityEndpoint = Config::get('unity.url').Config::get('unity.endpoint.create_contract_entity');
|
||||
$this->getAccessToken = $getAccessToken;
|
||||
$this->contract_hash_id = Config::get('unity.contract_template_hash_id');
|
||||
}
|
||||
|
||||
public function execute(string $new_contract_id, array $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();
|
||||
|
||||
echo($new_contract_id.'<br/>');
|
||||
|
||||
echo($this->createContractEntityEndpoint);
|
||||
dd($response );
|
||||
return (isset($response->data)) ? $response->data : null;
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user