Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
9 / 9
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
MyAppointmentsController
100.00% covered (success)
100.00%
9 / 9
100.00% covered (success)
100.00%
2 / 2
3
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 readResponse
100.00% covered (success)
100.00%
8 / 8
100.00% covered (success)
100.00%
1 / 1
2
1<?php
2
3declare(strict_types=1);
4
5namespace BO\Zmscitizenapi\Controllers\Appointment;
6
7use BO\Mellon\Validator;
8use BO\Zmscitizenapi\BaseController;
9use BO\Zmscitizenapi\Services\Core\AuthenticationService;
10use BO\Zmscitizenapi\Services\Appointment\MyAppointmentsService;
11use BO\Zmscitizenapi\Utils\ErrorMessages;
12use Psr\Http\Message\RequestInterface;
13use Psr\Http\Message\ResponseInterface;
14
15class MyAppointmentsController extends BaseController
16{
17    private MyAppointmentsService $service;
18    public function __construct()
19    {
20        $this->service = new MyAppointmentsService();
21    }
22
23    public function readResponse(RequestInterface $request, ResponseInterface $response, array $args): ResponseInterface
24    {
25        $filterId = Validator::param('filterId')->isNumber()->getValue();
26        $user = AuthenticationService::getAuthenticatedUser($request);
27        if (is_null($user)) {
28            return $this->createJsonResponse($response, [
29                'errors' => [ErrorMessages::get('authKeyMismatch')]
30            ], 401);
31        }
32        $result = $this->service->getAppointmentsForUser($user, $filterId);
33        return $this->createJsonResponse($response, $result, 200);
34    }
35}