mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-19 04:23:55 +00:00
35 lines
1005 B
PHP
35 lines
1005 B
PHP
<?php
|
|
|
|
namespace App\Classes\Modules\PerfexCRM\Services;
|
|
|
|
use Illuminate\Support\Facades\Http;
|
|
use App\Classes\Exceptions\MalformedRequestException;
|
|
use Illuminate\Support\Facades\Log;
|
|
|
|
class ConvertsPerfexCRMLeadToCustomer
|
|
{
|
|
/**
|
|
* @param string $email
|
|
* @return null|object
|
|
* @throws MalformedRequestException
|
|
*/
|
|
public function execute(string $email) {
|
|
try{
|
|
$response = Http::withHeaders([
|
|
'authtoken' => config('perfexcrm.api_key'),])
|
|
->get(config('perfexcrm.base_url').'/api/leads/convertocustomer/'.$email);
|
|
|
|
if($response->successful()){
|
|
$data = $response->json();
|
|
|
|
return (object) $data;
|
|
}else{
|
|
Log::error($response);
|
|
return null;
|
|
}
|
|
}catch(\Exception $exception){
|
|
throw new MalformedRequestException('Unable to get correct response from Perfex CRM server' . $exception->getMessage());
|
|
}
|
|
}
|
|
}
|