mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-19 20:43:56 +00:00
76 lines
1.9 KiB
PHP
76 lines
1.9 KiB
PHP
<?php
|
|
|
|
|
|
namespace App\Classes\Modules\Bookings\ControllersLogic;
|
|
|
|
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
|
use App\Classes\Jobs\ListBookingsJob;
|
|
use App\Classes\Modules\Jobs\DataTransferObjects\JobSubmissionObject;
|
|
use Illuminate\Http\JsonResponse;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\Auth;
|
|
use App\Classes\Modules\Jobs\Services\CreatesJobResult;
|
|
|
|
|
|
class ListBookingJobLogic extends AbstractControllerLogic
|
|
{
|
|
/**
|
|
* @return array
|
|
*/
|
|
protected function notification():array {
|
|
return [
|
|
'title' => 'List Booking Job',
|
|
'message' => 'You have successfully submit a job to list bookings'
|
|
];
|
|
}
|
|
|
|
/** @var CreatesJobResult */
|
|
private $createsJobResult;
|
|
|
|
/**
|
|
* ListPackingListsJobLogic constructor.
|
|
* @param CreatesJobResult $createsJobResult
|
|
*/
|
|
public function __construct(CreatesJobResult $createsJobResult)
|
|
{
|
|
$this->createsJobResult = $createsJobResult;
|
|
}
|
|
|
|
|
|
/**
|
|
* @param Request $request
|
|
* @return JsonResponse
|
|
*/
|
|
public function logic(Request $request) : JsonResponse
|
|
{
|
|
$jobId = uniqid();
|
|
|
|
$user = Auth::user();
|
|
$userInfo = (object) [
|
|
'type' => $user->type,
|
|
];
|
|
|
|
$userInfoJson = json_encode($userInfo);
|
|
$requestSignature = md5($userInfoJson . $request->fullUrl());
|
|
|
|
$jobSubmissionObject = new JobSubmissionObject(
|
|
$request->fullUrl(),
|
|
$request->all(),
|
|
$requestSignature,
|
|
null,
|
|
$jobId,
|
|
$userInfo
|
|
);
|
|
|
|
ListBookingsJob::dispatch($jobSubmissionObject)->onQueue(env('SQS_QUEUENAME_PREFIX', '').'high_priority');
|
|
|
|
$result = [];
|
|
$result['job_id'] = $jobId;
|
|
|
|
$this->createsJobResult->execute($jobSubmissionObject);
|
|
|
|
return $this->response(['data' => $result]);
|
|
}
|
|
|
|
}
|