<?php
namespace App\Controller\Api\Reservation;
use App\Enum\Parameter;
use App\Message\PuzzleReservationMessage;
use App\Service\Filter\Reservation\DataModels\ReservationFilter;
use App\Service\Filter\Reservation\Method\ReservationListService;
use App\Service\Reservation\AutoComplate\Paramerter\PackageProfitAll;
use App\Service\Reservation\Reservation\Paramerter\DiscountCoupon;
use App\Service\Reservation\Reservation\Paramerter\EbInsurance;
use App\Service\Reservation\Reservation\Paramerter\ForwardingNotification;
use App\Service\Reservation\Reservation\Paramerter\HotelProfit;
use App\Service\Reservation\Reservation\Paramerter\Invoice;
use App\Service\Reservation\Reservation\Paramerter\Note;
use App\Service\Reservation\Reservation\Paramerter\HotelExtra;
use App\Service\Reservation\Reservation\Paramerter\PackageProfit;
use App\Service\Reservation\Reservation\Paramerter\Pax;
use App\Service\Reservation\Reservation\Paramerter\Profit;
use App\Service\Reservation\Reservation\Paramerter\ReservationDetail;
use App\Service\Reservation\Reservation\Paramerter\ReservationPaxInvoiceSave;
use App\Service\Reservation\Reservation\Paramerter\ReservationUserSave;
use App\Service\Reservation\Reservation\Paramerter\Review;
use App\Service\Reservation\Reservation\Paramerter\RequestData;
use App\Service\Reservation\Reservation\ReservationService;
use App\Service\Respy\RespyService;
use App\Service\Validator\ValidatorService;
use Exception;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\Messenger\MessageBusInterface;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Contracts\Translation\TranslatorInterface;
/**
* Class ReservationController
* @package App\Controller\Admin
*/
class ReservationController extends AbstractController
{
/**
* @param TranslatorInterface $translator
*/
public function __construct(
protected TranslatorInterface $translator,
)
{
}
/**
* @Route("/api/integration/reservation", name="api_integration_reservation", methods={"POST"})
*
* @param RespyService $respy
* @param ValidatorService $validatorService
* @param MessageBusInterface $bus
* @return JsonResponse
*/
public function reservationUpdate(RespyService $respy, ValidatorService $validatorService, MessageBusInterface $bus): JsonResponse
{
$constraints = new Assert\Collection([
'reservationCode' => [
new Assert\Required(),
],
'voucher' => [
new Assert\Optional(),
],
]);
try {
$input = $validatorService->validate($constraints);
$bus->dispatch(new PuzzleReservationMessage($input['reservationCode']));
$respy->success();
} catch (Exception $exception) {
$respy->setError($exception->getMessage());
$respy->setErrorCode($exception->getCode());
}
return new JsonResponse($respy->getResponse());
}
/**
* @Route("/api/reservation/user/save", name="api_reservation_user_save", methods={"POST"})
*
* @param RespyService $respy
* @param ValidatorService $validatorService
* @param ReservationService $reservationService
* @return JsonResponse
*/
public function reservationUserSave(RespyService $respy, ValidatorService $validatorService, ReservationService $reservationService): JsonResponse
{
$constraints = new Assert\Collection([
'guid' => [
new Assert\Required()
],
'userId' => [
new Assert\NotBlank()
]
]);
try {
$input = $validatorService->validate($constraints);
$reservationUserSave = (new ReservationUserSave())
->setGuid($input["guid"])
->setUserId($input["userId"]);
if ($response = $reservationService->userSave($reservationUserSave)) {
$respy->success();
$respy->setData($response);
}
} catch (Exception $exception) {
$respy->setError($exception->getMessage());
$respy->setErrorCode($exception->getCode());
}
return new JsonResponse($respy->getResponse());
}
/**
* @Route("/api/reservation/user/details", name="api_reservation_user_details", methods={"POST"})
*
* @param RespyService $respy
* @param ValidatorService $validatorService
* @param ReservationService $reservationService
* @return JsonResponse
*/
public function reservationUserDetails(RespyService $respy, ValidatorService $validatorService, ReservationService $reservationService): JsonResponse
{
$constraints = new Assert\Collection([
'user' => [
new Assert\Required(),
new Assert\NotBlank(),
]
]);
try {
$input = $validatorService->validate($constraints);
$reservationDetail = (new ReservationDetail())
->setUser($input["user"]);
$response = $reservationService->userDetails($reservationDetail);
$respy->success();
$respy->setData($response);
} catch (Exception $exception) {
$respy->setError($exception->getMessage());
$respy->setErrorCode($exception->getCode());
}
return new JsonResponse($respy->getResponse());
}
/**
* @Route("/api/reservation/puzzle-booking/user/details", name="api_reservation_puzzle_booking_user_details", methods={"POST"})
*
* @param RespyService $respy
* @param ValidatorService $validatorService
* @param ReservationListService $reservationListService
* @return JsonResponse
*/
public function reservationPuzzleBookingUserDetails(RespyService $respy, ValidatorService $validatorService, ReservationListService $reservationListService): JsonResponse
{
$constraints = new Assert\Collection([
'processFrom' => [
new Assert\Required(),
],
'processTo' => [
new Assert\Required(),
],
'checkInFrom' => [
new Assert\Required(),
],
'checkInTo' => [
new Assert\Required(),
],
'checkOutFrom' => [
new Assert\Required(),
],
'checkOutTo' => [
new Assert\Required(),
],
'firstName' => [
new Assert\Required(),
],
'lastName' => [
new Assert\Required(),
],
'voucher' => [
new Assert\Required(),
],
'pnr' => [
new Assert\Required(),
],
'hotelId' => [
new Assert\Required(),
],
'agencyId' => [
new Assert\Required(),
new Assert\NotBlank(),
],
'status' => [
new Assert\Required(),
],
'page' => [
new Assert\NotBlank(),
],
'pageCount' => [
new Assert\NotBlank(),
],
'category' => [
new Assert\Required(),
]
]);
try {
$input = $validatorService->validate($constraints);
$agency = $this->getUser()?->getAgency()?->getId();
if (!$agency) {
$agency = $input["agencyId"];
}
$reservationFilter = (new ReservationFilter())
->setProcessFrom($input["processFrom"])
->setProcessTo($input["processTo"])
->setCheckInFrom($input["checkInFrom"])
->setCheckInTo($input["checkInTo"])
->setCheckOutFrom($input["checkOutFrom"])
->setCheckOutTo($input["checkOutTo"])
->setFirstName($input["firstName"])
->setLastName($input["lastName"])
->setVoucher($input["voucher"])
->setPnr($input["pnr"])
->setHotelId($input["hotelId"])
->setAgencyId($agency)
->setType(0)
->setCategory($input["category"])
->setStatus($input["status"])
->setVariable('search')
->setPaymentTransferNo('');
$response = $reservationListService->handle($reservationFilter, $input['page'] ?? 1, $input['pageCount'] ?? 50, false);
$respy->success();
$respy->setData($response);
$sales = 0;
$cost = 0;
$remaining = 0;
foreach ($response->reservations as $resp) {
$sales += $resp->getTotalPrice();
$cost += $resp->getTotalCost();
$remaining += $resp->getRemainingPrice();
}
$respy->setParams([
'sales' => (float)number_format($sales, 2, '.', ''),
'cost' => (float)number_format($cost, 2, '.', ''),
'profit' => (float)number_format($sales - $cost, 2, '.', ''),
'remaining' => (float)number_format($remaining, 2, '.', ''),
]);
} catch (Exception $exception) {
$respy->setError($exception->getMessage());
$respy->setErrorCode($exception->getCode());
}
return new JsonResponse($respy->getResponse());
}
/**
* @Route("/api/reservation/user/status", name="api_reservation_user_status", methods={"POST"})
*
* @param RespyService $respy
* @return JsonResponse
*/
public function reservationStatus(RespyService $respy): JsonResponse
{
$response = Parameter::RESERVATION_STATUS_API;
$respy->success();
$respy->setData($response);
return new JsonResponse($respy->getResponse());
}
/**
* @Route("/api/reservation/detail", name="api_reservation_detail", methods={"POST"})
*
* @param RespyService $respy
* @param ValidatorService $validatorService
* @param ReservationService $reservationService
* @return JsonResponse
*/
public function reservationDetail(RespyService $respy, ValidatorService $validatorService, ReservationService $reservationService): JsonResponse
{
$constraints = new Assert\Collection([
'guid' => [
new Assert\Optional()
],
'voucherNo' => [
new Assert\Optional(),
],
'surname' => [
new Assert\Optional(),
],
]);
try {
$input = $validatorService->validate($constraints);
$reservationDetail = (new ReservationDetail())
->setGuid($input["guid"])
->setSurname($input["surname"])
->setVoucherNo($input["voucherNo"]);
if ($response = $reservationService->detail($reservationDetail, true)) {
$respy->success();
$respy->setData($response);
}
} catch (Exception $exception) {
$respy->setError($exception->getMessage());
$respy->setErrorCode($exception->getCode());
}
return new JsonResponse($respy->getResponse());
}
/**
* @Route("/api/reservation/pax-invoice/save", name="api_reservation_pax_invoice_save", methods={"POST"})
*
* @param RespyService $respy
* @param ValidatorService $validatorService
* @param ReservationService $reservationService
* @return JsonResponse
*/
public function reservationPaxInvoiceSave(RespyService $respy, ValidatorService $validatorService, ReservationService $reservationService): JsonResponse
{
$constraints = new Assert\Collection([
'guid' => [
new Assert\Required()
],
'pax' => [
new Assert\Optional([
new Assert\Type('array'),
new Assert\Count(['min' => 1]),
new Assert\All([
new Assert\Collection([
'type' => [
new Assert\NotBlank([
'message' => $this->translator->trans('reservation.nameRequired'),
]),
new Assert\Choice(Parameter::RESERVATION_PAX_TYPE)
],
'firstName' => [
new Assert\NotBlank(),
new Assert\Type(['type' => 'string']),
],
'lastName' => [
new Assert\NotBlank([
'message' => $this->translator->trans('reservation.lastNameRequired'),
]),
new Assert\Type(['type' => 'string']),
],
'gender' => [
new Assert\NotBlank([
'message' => $this->translator->trans('reservation.genderRequired'),
]),
new Assert\Choice(Parameter::RESERVATION_PAX_GENDER)
],
'birthday' => [
new Assert\NotBlank([
'message' => $this->translator->trans('reservation.birthdayRequired'),
]),
new Assert\Date([
'message' => $this->translator->trans('reservation.birthdayDateFormatNotCorrect'),
])
],
'identifyNumber' => [
new Assert\NotBlank([
'message' => $this->translator->trans('reservation.identifyNumberRequired'),
])
],
'phone' => [
new Assert\NotBlank([
'message' => $this->translator->trans('reservation.phoneRequired'),
])
],
'passportNumber' => [
new Assert\Required(),
],
'passportValidityDate' => [
new Assert\Date([
'message' => $this->translator->trans('reservation.passportDateFormatNotCorrect'),
]),
],
]),
]),
]),
],
'invoice' => [
new Assert\Optional(
new Assert\Collection([
'type' => [
new Assert\NotBlank([
'message' => $this->translator->trans('reservation.typeRequired'),
]),
new Assert\Choice(Parameter::RESERVATION_INVOICE_TYPE)
],
'firstName' => [
new Assert\Required(),
new Assert\Type(['type' => 'string']),
],
'lastName' => [
new Assert\Required(),
new Assert\Type(['type' => 'string']),
],
'companyName' => [
new Assert\Required(),
new Assert\Type(['type' => 'string']),
],
'email' => [
new Assert\NotBlank([
'message' => $this->translator->trans('reservation.emailRequired'),
]),
new Assert\Type(['type' => 'string']),
],
'identifyNumber' => [
new Assert\Required()
],
'phone' => [
new Assert\Required(),
],
'address' => [
new Assert\Required(),
],
'taxOffice' => [
new Assert\Required()
],
'taxNumber' => [
new Assert\Required()
],
'city' => [
new Assert\Optional()
],
'district' => [
new Assert\Optional()
],
])),
],
'guestNote' => [
new Assert\Required(),
],
'kvkkConsentContract' => [
new Assert\Required(),
],
'kvkkLightingContract' => [
new Assert\Required(),
],
'consentContract' => [
new Assert\Optional(),
],
'agencyVoucherNo' => [
new Assert\Optional(),
],
]);
try {
$input = $validatorService->validateWithoutError($constraints);
$reservationPaxInvoiceSave = (new ReservationPaxInvoiceSave())
->setGuid($input['guid'])
->setGuestNote($input['guestNote'])
->setKvkkConsentContract($input['kvkkConsentContract'] ?? false)
->setKvkkLightingContract($input['kvkkLightingContract'] ?? false)
->setConsentContract($input['consentContract'] ?? false)
->setAgencyVoucherNo($input['agencyVoucherNo'] ?? false);
$phone = '';
foreach ($input["pax"] as $p) {
$pax = (new Pax())
->setType($p["type"])
->setFirstName($p["firstName"])
->setLastName($p["lastName"])
->setGender($p["gender"])
->setBirthDay($p["birthday"])
->setIdentifyNumber($p["identifyNumber"])
->setPhone($p["phone"])
->setPassportNumber($p["passportNumber"] ?: '')
->setPassportValidityDate($p["passportValidityDate"] ?: '');
if ($p["phone"]) {
$phone = $p["phone"];
}
$reservationPaxInvoiceSave->addPax($pax);
}
if (!empty($input["invoice"])) {
$invoice = (new Invoice())
->setType($input["invoice"]["type"])
->setFirstName($input["invoice"]["firstName"])
->setLastName($input["invoice"]["lastName"])
->setCompanyName($input["invoice"]["companyName"])
->setEmail($input["invoice"]["email"])
->setPhone($input["invoice"]["phone"] ?: $phone)
->setIdentifyNumber($input["invoice"]["identifyNumber"])
->setTaxOffice($input["invoice"]["taxOffice"])
->setTaxNumber($input["invoice"]["taxNumber"])
->setAddress($input["invoice"]["address"])
->setCity($input["invoice"]["city"] ?? '')
->setDistrict($input["invoice"]["district"] ?? '');
$reservationPaxInvoiceSave->setInvoice($invoice);
}
if ($response = $reservationService->paxInvoiceSave($reservationPaxInvoiceSave)) {
$respy->success();
$respy->setData($response);
}
} catch (Exception $exception) {
$respy->setError($exception->getMessage());
$respy->setErrorCode($exception->getCode());
}
return new JsonResponse($respy->getResponse());
}
/**
* @Route("/api/reservation/discountcoupon", name="api_reservation_discountcoupon", methods={"POST"})
*
* @param RespyService $respy
* @param ValidatorService $validatorService
* @param ReservationService $reservationService
* @return JsonResponse
*/
public function reservationDiscount(RespyService $respy, ValidatorService $validatorService, ReservationService $reservationService): JsonResponse
{
$constraints = new Assert\Collection([
'guid' => [
new Assert\NotBlank()
],
'discountCode' => [
new Assert\NotBlank()
]
]);
try {
$input = $validatorService->validate($constraints);
$discountCoupon = (new DiscountCoupon())
->setGuid($input["guid"])
->setDiscountCouponCode($input["discountCode"]);
if ($response = $reservationService->discount($discountCoupon)) {
$respy->success();
$respy->setData($response);
} else {
$respy->setError($this->translator->trans('reservation.couponNotFound'));
}
} catch (Exception $exception) {
$respy->setError($exception->getMessage());
$respy->setErrorCode($exception->getCode());
}
return new JsonResponse($respy->getResponse());
}
/**
* @Route("/api/reservation/packageprofit", name="api_reservation_packageprofit", methods={"POST"})
*
* @param RespyService $respy
* @param ValidatorService $validatorService
* @param ReservationService $reservationService
* @return JsonResponse
*/
public function reservationPackageprofit(RespyService $respy, ValidatorService $validatorService, ReservationService $reservationService): JsonResponse
{
$constraints = new Assert\Collection([
'voucher' => [
new Assert\NotBlank()
],
'pakageProfitId' => [
new Assert\Required()
]
]);
try {
$input = $validatorService->validate($constraints);
$packageProfit = (new PackageProfit())
->setVoucher($input["voucher"])
->setPackageProfitId($input["pakageProfitId"]);
if ($response = $reservationService->packageProfit($packageProfit)) {
$respy->success();
$respy->setData($response);
}
} catch (Exception $exception) {
$respy->setError($exception->getMessage());
$respy->setErrorCode($exception->getCode());
}
return new JsonResponse($respy->getResponse());
}
/**
* @Route("/api/reservation/hotel-profit", name="api_reservation_hotel_profit", methods={"POST"})
*
* @param RespyService $respy
* @param ValidatorService $validatorService
* @param ReservationService $reservationService
* @return JsonResponse
*/
public function reservationHotelProfit(RespyService $respy, ValidatorService $validatorService, ReservationService $reservationService): JsonResponse
{
$constraints = new Assert\Collection([
'voucher' => [
new Assert\NotBlank()
],
'hotelProfitId' => [
new Assert\Required()
]
]);
try {
$input = $validatorService->validate($constraints);
$hotelProfit = (new HotelProfit())
->setVoucher($input['voucher'])
->setHotelProfitId($input['hotelProfitId']);
if ($response = $reservationService->hotelProfit($hotelProfit)) {
$respy->success();
$respy->setData($response);
}
} catch (Exception $exception) {
$respy->setError($exception->getMessage());
$respy->setErrorCode($exception->getCode());
}
return new JsonResponse($respy->getResponse());
}
/**
* @Route("/api/reservation/profit", name="api_reservation_profit", methods={"POST"})
*
* @param RespyService $respy
* @param ValidatorService $validatorService
* @param ReservationService $reservationService
* @return JsonResponse
*/
public function reservationProfit(RespyService $respy, ValidatorService $validatorService, ReservationService $reservationService): JsonResponse
{
$constraints = new Assert\Collection([
'voucher' => [
new Assert\NotBlank()
],
'percent' => [
new Assert\Required()
]
]);
try {
$input = $validatorService->validate($constraints);
$profit = (new Profit())
->setVoucher($input["voucher"])
->setPercent($input["percent"]);
if ($response = $reservationService->profit($profit)) {
$respy->success();
$respy->setData($response);
}
} catch (Exception $exception) {
$respy->setError($exception->getMessage());
$respy->setErrorCode($exception->getCode());
}
return new JsonResponse($respy->getResponse());
}
/**
* @Route("/api/reservation/packageprofitall", name="api_reservation_packageprofit_all", methods={"POST"})
*
* @param RespyService $respy
* @param ValidatorService $validatorService
* @param ReservationService $reservationService
* @return JsonResponse
*/
public function reservationPackageprofitAll(RespyService $respy, ValidatorService $validatorService, ReservationService $reservationService): JsonResponse
{
$constraints = new Assert\Collection([
'checkIn' => [
new Assert\NotBlank()
],
'checkOut' => [
new Assert\NotBlank()
]
]);
try {
$input = $validatorService->validate($constraints);
$packageProfitAll = (new PackageProfitAll())
->setCheckIn($input["checkIn"])
->setCheckOut($input["checkOut"]);
if ($response = $reservationService->packageProfitAll($packageProfitAll)) {
$respy->success();
$respy->setData($response);
}
} catch (Exception $exception) {
$respy->setError($exception->getMessage());
$respy->setErrorCode($exception->getCode());
}
return new JsonResponse($respy->getResponse());
}
/**
* @Route("/api/reservation/ebinsurance", name="api_reservation_ebinsurance", methods={"POST"})
*
* @param RespyService $respy
* @param ValidatorService $validatorService
* @param ReservationService $reservationService
* @return JsonResponse
*/
public function reservationEbInsurance(RespyService $respy, ValidatorService $validatorService, ReservationService $reservationService): JsonResponse
{
$constraints = new Assert\Collection([
'voucher' => [
new Assert\NotBlank()
],
'check' => [
new Assert\NotBlank(),
new Assert\Choice(Parameter::YES_NO)
],
]);
try {
$input = $validatorService->validate($constraints);
$ebInsurance = (new EbInsurance())
->setVoucher($input["voucher"])
->setCheck($input["check"]);
if ($response = $reservationService->ebInsurance($ebInsurance)) {
$respy->success();
$respy->setData($response);
}
} catch (Exception $exception) {
$respy->setError($exception->getMessage());
$respy->setErrorCode($exception->getCode());
}
return new JsonResponse($respy->getResponse());
}
/**
* @Route("/api/site-reservation-review", name="api_site_reservation_review")
*
* @param RespyService $respy
* @param ValidatorService $validatorService
* @param ReservationService $reservationService
* @return JsonResponse
*/
public function reservationReview(RespyService $respy, ValidatorService $validatorService, ReservationService $reservationService): JsonResponse
{
$constraints = new Assert\Collection([
'voucher' => [
new Assert\NotBlank(),
],
'pointMeal' => [
new Assert\NotBlank(),
new Assert\Choice(Parameter::REVIEW_POINT)
],
'pointRoom' => [
new Assert\NotBlank(),
new Assert\Choice(Parameter::REVIEW_POINT)
],
'pointService' => [
new Assert\NotBlank(),
new Assert\Choice(Parameter::REVIEW_POINT)
],
'pointOperationUser' => [
new Assert\Optional([
new Assert\Choice(Parameter::REVIEW_POINT)
]),
],
'description' => [
new Assert\NotBlank()
],
'vocationType' => [
new Assert\NotBlank(),
new Assert\Choice(Parameter::REVIEW_VOCATION_TYPE)
],
'recommend' => [
new Assert\NotBlank(),
new Assert\Choice(Parameter::REVIEW_RECOMMEND)
],
]);
try {
$input = $validatorService->validate($constraints);
$review = (new Review())
->setVoucher($input["voucher"])
->setPointMeal($input["pointMeal"])
->setPointRoom($input["pointRoom"])
->setPointService($input["pointService"])
->setPointOperationUser($input["pointOperationUser"])
->setDescription($input["description"])
->setVocationType($input["vocationType"])
->setRecommend($input["recommend"]);
if ($response = $reservationService->review($review)) {
$respy->success();
$respy->setData($response);
}
} catch (Exception $exception) {
$respy->setError($exception->getMessage());
$respy->setErrorCode($exception->getCode());
}
return new JsonResponse($respy->getResponse());
}
/**
* @Route("/api/reservation/request", name="api_reservation_request")
*
* @param Request $request
* @param RespyService $respy
* @param ValidatorService $validatorService
* @param ReservationService $reservationService
* @return JsonResponse
*/
public function addRequest(Request $request, RespyService $respy, ValidatorService $validatorService, ReservationService $reservationService): JsonResponse
{
$constraints = new Assert\Collection([
'title' => [
new Assert\Required(),
],
'checkIn' => [
new Assert\Required(),
new Assert\Date()
],
'checkOut' => [
new Assert\Required(),
new Assert\Date()
],
'adtCount' => [
new Assert\Required(),
],
'chdCount' => [
new Assert\Required(),
],
'chd1Age' => [
new Assert\Required(),
],
'chd2Age' => [
new Assert\Required(),
],
'callDate' => [
new Assert\NotBlank(),
new Assert\Date(),
],
'callTime' => [
new Assert\NotBlank(),
new Assert\Choice(Parameter::REQUEST_CALLTIME)
],
'firstName' => [
new Assert\Required(),
],
'lastName' => [
new Assert\Required(),
],
'phone' => [
new Assert\NotBlank(),
],
'email' => [
new Assert\Required(),
new Assert\Email(),
],
'guestNote' => [
new Assert\NotBlank(),
],
'pageUrl' => [
new Assert\Optional(),
],
'consentContract' => [
new Assert\Required(),
new Assert\IsTrue(),
],
'hotelId' => [
new Assert\Optional(),
],
'tourId' => [
new Assert\Optional(),
],
'reservationId' => [
new Assert\Optional(),
],
]);
$content = json_decode($request->getContent(), true);
try {
$input = $validatorService->validate($constraints);
$requestData = (new RequestData())
->setHotelId($input['hotelId'] ?? 0)
->setTourId($input['tourId'] ?? 0)
->setReservationId($content['reservationId'] ?? 0)
->setTitle($input['title'])
->setCheckIn($input['checkIn'])
->setCheckOut($input['checkOut'])
->setAdtCount($input['adtCount'])
->setChdCount($input['chdCount'])
->setChd1Age($input['chd1Age'])
->setChd2Age($input['chd2Age'])
->setFirstName($input['firstName'])
->setLastName($input['lastName'])
->setPhone($input['phone'])
->setEmail($input['email'])
->setCallDate($input['callDate'])
->setCallTime($input['callTime'])
->setGuestNote($input['guestNote'])
->setUrl($input['pageUrl'] ?? '')
->setConsentContract($input['consentContract'] ?? false);
if ($response = $reservationService->request($requestData)) {
$respy->success();
$respy->setData($response);
}
} catch (Exception $exception) {
$respy->setError($exception->getMessage());
$respy->setErrorCode($exception->getCode());
}
return new JsonResponse($respy->getResponse());
}
/**
* @Route("/api/reservation/note", name="api_reservation_note")
*
* @param RespyService $respy
* @param ValidatorService $validatorService
* @param ReservationService $reservationService
* @return JsonResponse
*/
public function addNote(RespyService $respy, ValidatorService $validatorService, ReservationService $reservationService): JsonResponse
{
$constraints = new Assert\Collection([
'voucher' => [
new Assert\Required(),
new Assert\NotBlank(),
],
'note' => [
new Assert\Required(),
new Assert\NotBlank(),
],
]);
try {
$input = $validatorService->validate($constraints);
$requestData = (new Note())
->setVoucher($input['voucher'] ?? '')
->setNote($input['note'] ?? '');
if ($response = $reservationService->note($requestData)) {
$respy->success();
$respy->setData($response);
}
} catch (Exception $exception) {
$respy->setError($exception->getMessage());
$respy->setErrorCode($exception->getCode());
}
return new JsonResponse($respy->getResponse());
}
/**
* @Route("/api/reservation/forwarding-notification", name="api_reservation_forwarding_notification")
*
* @param RespyService $respy
* @param ValidatorService $validatorService
* @param ReservationService $reservationService
* @return JsonResponse
*/
public function forwardingNotification(RespyService $respy, ValidatorService $validatorService, ReservationService $reservationService): JsonResponse
{
$constraints = new Assert\Collection([
'reservation' => [
new Assert\Required(),
new Assert\NotBlank(),
],
]);
try {
$input = $validatorService->validate($constraints);
$requestData = (new ForwardingNotification())
->setReservation($input['reservation'] ?? '');
if ($response = $reservationService->forwardingNotification($requestData)) {
$respy->success();
$respy->setData($response);
}
} catch (Exception $exception) {
$respy->setError($exception->getMessage());
$respy->setErrorCode($exception->getCode());
}
return new JsonResponse($respy->getResponse());
}
/**
* @Route("/api/reservation/hotelextra", name="api_reservation_hotelextra", methods={"POST"})
*
* @param RespyService $respy
* @param ValidatorService $validatorService
* @param ReservationService $reservationService
* @return JsonResponse
*/
public function reservationHotelExtras(RespyService $respy, ValidatorService $validatorService, ReservationService $reservationService): JsonResponse
{
$constraints = new Assert\Collection([
'voucher' => [
new Assert\NotBlank()
],
'code' => [
new Assert\NotBlank(),
],
]);
try {
$input = $validatorService->validate($constraints);
$hotelExtra = (new HotelExtra())
->setVoucher($input["voucher"])
->setCode($input["code"]);
if ($response = $reservationService->hotelExtra($hotelExtra)) {
$respy->success();
$respy->setData($response);
}
} catch (Exception $exception) {
$respy->setError($exception->getMessage());
$respy->setErrorCode($exception->getCode());
}
return new JsonResponse($respy->getResponse());
}
}