mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/izyim.git
synced 2026-08-19 04:24:00 +00:00
39 lines
1.2 KiB
PHP
39 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Classes\Modules\ControllerLogic\Contacts;
|
|
|
|
use App\Classes\Constants;
|
|
use App\Classes\Modules\Contacts\DataTransferObjects\ContactObject;
|
|
use App\Classes\Modules\Contacts\Exceptions\CannotCreateContactException;
|
|
use App\Classes\Modules\Contacts\Services\CreatesContact;
|
|
use Illuminate\Http\Request;
|
|
|
|
class CreateContactLogic
|
|
{
|
|
/** @var CreatesContact */
|
|
private $createContact;
|
|
|
|
/**
|
|
* CreateContactLogic constructor.
|
|
* @param CreatesContact $createContact
|
|
*/
|
|
public function __construct(CreatesContact $createContact)
|
|
{
|
|
$this->createContact = $createContact;
|
|
}
|
|
|
|
|
|
public function execute(string $type, int $referenceId, Request $request)
|
|
{
|
|
try{
|
|
|
|
$object = new ContactObject($type, $referenceId, $request->input('name'), $request->input('designation'), $request->input('contact'), $request->input('email'));
|
|
return $this->createContact->execute($object, $type, $referenceId);
|
|
|
|
}
|
|
catch (CannotCreateContactException $exception){
|
|
throw new InternalServerErrorException("Failed to create contact because {$exception->getMessage()}");
|
|
}
|
|
}
|
|
|
|
} |