Skip to content

Commit

Permalink
BUGFIX - API: reflect qry param in GetAvailability
Browse files Browse the repository at this point in the history
With GetAvailability(resourceId = null) the GET query parameter is not reflected in the response. Maybe this was intermittently set since there is an alternative route for GetAvailability that uses a static URI instead of a query parameter for resourceId. See /Web/Services/index.php . This fix prefers the route with explicit query params for resourceId and dateTime over the static route. Hence, the alternative route should be disabled with a subsequent change.

Please feel free to correct me if I misunderstood the function signature or if there is a way to enable both routes. I have tried but the Slim framework seems not to allow alternative signatures on the same function.
  • Loading branch information
flotonus authored Mar 25, 2023
1 parent 5002645 commit 4c8ce39
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions WebServices/ResourcesWebService.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,10 @@ public function GetTypes()
* @response ResourcesAvailabilityResponse
* @return void
*/
public function GetAvailability($resourceId = null)
public function GetAvailability()
{
$dateQueryString = $this->server->GetQueryString(WebServiceQueryStringKeys::DATE_TIME);
$resourceId = $this->server->GetQueryString(WebServiceQueryStringKeys::RESOURCE_ID);

if (!empty($dateQueryString)) {
$requestedTime = WebServiceDate::GetDate($dateQueryString, $this->server->GetSession());
Expand All @@ -144,7 +145,7 @@ public function GetAvailability($resourceId = null)
$resources[] = $this->resourceRepository->LoadById($resourceId);
}

$lastDateSearched = $requestedTime->AddDays(30);
$lastDateSearched = $requestedTime->AddDays(7);
$reservations = $this->GetReservations($this->reservationRepository->GetReservations($requestedTime, $lastDateSearched, null, null, null, $resourceId));

$resourceAvailability = [];
Expand Down

1 comment on commit 4c8ce39

@flotonus
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P.S: In addition I have changed the delivered time span for availability as described in the API documentation to 7 days instead of 30.

Please sign in to comment.