startDate >= $searchRequest->endDate) { throw new ApiErrorException( new ApiErrorMessage(422, ApiErrorMessage::TYPE_INVALID_DATE), 'startDate cant be before endDate', ); } $rs = $repoAvailability->getAvailabilityForPeriod($searchRequest->startDate, $searchRequest->endDate); return $this->json(["results" => $rs]); } /** * Get Availability for all rooms on each day of a period. * (Not used on Front-end APP) */ #[Route('/api/search/availabilityDetails', name: 'app_search_availabilityDetails', methods: ["POST"], format: "json")] #[OA\Tag(name: "Searchs")] public function getAvailabilityForPeriodDetails( RoomAvailabilityRepository $repoAvailability, #[MapRequestPayload()] SearchAvailabilityPeriodRequest $searchRequest ): JsonResponse { $rs = $repoAvailability->getAvailabilityForPeriodDetails($searchRequest->startDate, $searchRequest->endDate); return $this->json(["results" => $rs]); } /** * Get room category price for given period. * Returns price for a room category. * This price is the total for all the selected days by guest number. */ #[Route('/api/search/prices', name: 'app_search_pricesForCategory', methods: ["POST"], format: "json")] #[OA\Tag(name: "Searchs")] #[OA\Response( response: 200, description: 'Room price by guest number', content: new OA\JsonContent( type: 'object', properties: [ new OA\Property( property: "results", type: "array", items: new OA\Items(ref: new Model(type: SearchPricesForCategoryResponse::class)) ) ] ) )] #[OA\RequestBody( content: new OA\JsonContent( type: 'object', ref: new Model(type: SearchPricesForCategoryRequest::class), ) )] public function getPricesForCategoryOnPeriod( RoomCategoryRepository $repoCat, PricesService $priceService, #[MapRequestPayload()] SearchPricesForCategoryRequest $searchRequest ): JsonResponse { $roomCategory = $repoCat->find($searchRequest->roomCategory); if ($roomCategory === null) { throw new ApiErrorException( new ApiErrorMessage(422, ApiErrorMessage::TYPE_VALIDATION_ERROR), 'Invalid RoomCategory: ' . $searchRequest->roomCategory, ); } if ($searchRequest->startDate >= $searchRequest->endDate) { throw new ApiErrorException( new ApiErrorMessage(422, ApiErrorMessage::TYPE_INVALID_DATE), 'startDate cant be before endDate', ); } $fareList = $priceService->getFinalPricesForSearch($roomCategory, $searchRequest->startDate, $searchRequest->endDate); $rs = []; foreach ($fareList as $key => $value) { $rs[] = ["guestNumber" => $key, "price" => $value]; } return $this->json(["results" => $rs]); } }