Lines
96.96%
32 / 33
Methods
50.00%
1 / 2
Classes
0.00%
0 / 1
| Name | Lines | Methods | CRAP | ||||
|---|---|---|---|---|---|---|---|
| readResponse | 96.66% | 29 / 30 | 0.00% | 0 / 1 | 6 | ||
| [BO\Zmsbackend\Api\BaseController] __invoke | 100.00% | 3 / 3 | 100.00% | 1 / 1 | 1 | ||
| 18 | class CalendarAvailabilityGet extends \BO\Zmsbackend\Api\BaseController | |
| 19 | { | |
| 20 | /** | |
| 21 | * @SuppressWarnings(Param) | |
| 22 | * @return \Psr\Http\Message\ResponseInterface | |
| 23 | */ | |
| 24 | #[\Override] | |
| 25 | public function readResponse( | |
| 26 | \Psr\Http\Message\RequestInterface $request, | |
| 27 | \Psr\Http\Message\ResponseInterface $response, | |
| 28 | array $args | |
| 29 | ) { | |
| 30 | $slotsRequired = Validator::param('slotsRequired')->isNumber()->getValue(); | |
| 31 | $slotType = Validator::param('slotType')->isString()->getValue(); | |
| 32 | if ($slotType || $slotsRequired) { | |
| 33 | (new \BO\Zmsbackend\Helper\User($request))->checkPermissions(); | |
| 34 | } else { | |
| 35 | $slotsRequired = 0; | |
| 36 | $slotType = 'public'; | |
| 37 | } | |
| 38 | $slotsRequired = (int) ($slotsRequired ?? 0); | |
| 39 | ||
| 40 | try { | |
| 41 | $message = \BO\Zmsbackend\Api\Response\Message::create($request); | |
| 42 | $message->data = (new CalendarAvailability())->readFromQuery( | |
| 43 | \App::getNow(), | |
| 44 | $slotType, | |
| 45 | $slotsRequired, | |
| 46 | Validator::param('startDate')->isString()->getValue(), | |
| 47 | Validator::param('endDate')->isString()->getValue(), | |
| 48 | Validator::param('officeIds')->isString()->getValue(), | |
| 49 | Validator::param('serviceIds')->isString()->getValue(), | |
| 50 | Validator::param('serviceCounts')->isString()->setDefault('')->getValue(), | |
| 51 | Validator::param('providerSource')->isString()->getValue() ?: null, | |
| 52 | Validator::param('requestSource')->isString()->getValue() ?: null, | |
| 53 | Validator::param('slotsStartDate')->isString()->getValue(), | |
| 54 | Validator::param('slotsEndDate')->isString()->getValue() | |
| 55 | ); | |
| 56 | } catch (InvalidAvailabilityInput $exception) { | |
| 57 | throw new \BO\Zmsbackend\Calendar\Exception\InvalidFirstDay( | |
| 58 | $exception->getMessage(), | |
| 59 | 0, | |
| 60 | $exception | |
| 61 | ); | |
| 62 | } | |
| 63 | ||
| 64 | $response = Render::withLastModified($response, time(), '0'); | |
| 65 | return Render::withJson($response, $message->setUpdatedMetaData(), 200); | |
| 66 | } | |
| 67 | } |
Inherited from BO\Zmsbackend\Api\BaseController
| 20 | public function __invoke(RequestInterface $request, ResponseInterface $response, array $args) | |
| 21 | { | |
| 22 | $request = $this->initRequest($request); | |
| 23 | $noCacheResponse = \BO\Slim\Render::withLastModified($response, time(), '0'); | |
| 24 | return $this->readResponse($request, $noCacheResponse, $args); | |
| 25 | } |