mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-19 04:23:55 +00:00
46 lines
1.6 KiB
PHP
46 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Classes\Modules\Companies\Processors;
|
|
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\App;
|
|
use Illuminate\Support\Facades\Log;
|
|
|
|
class CreateIdentificationDocumentOnShippingProcessor
|
|
{
|
|
/**
|
|
* @param Request $request
|
|
* @return string
|
|
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
|
* @throws \App\Classes\Exceptions\MalformedRequestException
|
|
* @throws \App\Classes\Exceptions\RequestValidationException
|
|
*/
|
|
public function execute(Request $request, $companyId) {
|
|
if (App::environment(['production'])) {
|
|
dd("Delete this line before push to production");
|
|
$url = "https://izyim.cief-malaysia.com/api/v1/exchange/company/{$companyId}/identification/create";
|
|
} else {
|
|
$url = "http://127.0.0.1:8001/api/v1/exchange/company/{$companyId}/identification/create";
|
|
}
|
|
try {
|
|
$client = new \GuzzleHttp\Client(['verify' => false]);
|
|
$token = $request->bearerToken();
|
|
$headers = [
|
|
'Authorization' => 'Bearer ' . $token,
|
|
'Accept' => 'application/json',
|
|
];
|
|
$formParams = $request->toArray();
|
|
$response = $client->request('POST', $url, [
|
|
'headers' => $headers,
|
|
'form_params' => $formParams
|
|
]);
|
|
$body = $response->getBody();
|
|
$contents = json_decode($body, true);
|
|
|
|
return $contents;
|
|
} catch(\GuzzleHttp\Exception\RequestException $exception){
|
|
Log::error($exception->getResponse()->getBody()->getContents());
|
|
}
|
|
}
|
|
|
|
} |