Created contract at Unity

This commit is contained in:
Fairuz
2021-07-26 13:14:43 +08:00
parent 06de032867
commit fde433d60c
6 changed files with 54 additions and 14 deletions
@@ -4,18 +4,18 @@ namespace App\Classes\Modules\Unity\Processors;
use Config;
use Illuminate\Support\Facades\Http;
use App\Classes\Modules\Unity\Services\GetContractObligations;
use App\Classes\Modules\Unity\Services\CreatesContract;
class CreateContractProcessor
{
private $getContractObligations;
private $createsContract;
public function __construct(GetContractObligations $getContractObligations)
public function __construct(CreatesContract $createsContract)
{
$this->getContractObligations = $getContractObligations;
$this->createsContract = $createsContract;
}
public function execute(){
return $this->getContractObligations->execute();
return $this->createsContract->execute();
}
}
@@ -0,0 +1,33 @@
<?php
namespace App\Classes\Modules\Unity\Services;
use Config;
use Illuminate\Support\Facades\Http;
use App\Classes\Modules\Unity\Services\GetAccessToken;
class CreatesContract
{
private $getAccessToken;
private $createEntityEndpoint;
private $contract_hash_id;
public function __construct(GetAccessToken $getAccessToken)
{
$this->createEntityEndpoint = Config::get('unity.url').Config::get('unity.endpoint.create_contract');
$this->getAccessToken = $getAccessToken;
$this->contract_hash_id = Config::get('unity.contract_template_hash_id');
}
public function execute(){
$accesToken=$this->getAccessToken->execute();
$response = Http::withToken($accesToken)->post($this->createEntityEndpoint,['contract_template_id'=>[$this->contract_hash_id]])->object();
return (isset($response->data)) ? $response->data : null;
}
}