Lines
9.37%
3 / 32
Methods
33.33%
1 / 3
Classes
0.00%
0 / 1
| Name | Lines | Methods | CRAP | ||||
|---|---|---|---|---|---|---|---|
| readResponse | 0.00% | 0 / 22 | 0.00% | 0 / 1 | 6 | ||
| testProcessData | 0.00% | 0 / 7 | 0.00% | 0 / 1 | 20 | ||
| [BO\Zmsbackend\Api\BaseController] __invoke | 100.00% | 3 / 3 | 100.00% | 1 / 1 | 1 | ||
| 17 | class ProcessPreconfirm extends \BO\Zmsbackend\Api\BaseController | |
| 18 | { | |
| 19 | /** | |
| 20 | * @SuppressWarnings(Param) | |
| 21 | * @return \Psr\Http\Message\ResponseInterface | |
| 22 | */ | |
| 23 | #[\Override] | |
| 24 | public function readResponse( | |
| 25 | \Psr\Http\Message\RequestInterface $request, | |
| 26 | \Psr\Http\Message\ResponseInterface $response, | |
| 27 | array $args | |
| 28 | ) { | |
| 29 | \BO\Zmsbackend\Connection\Select::setCriticalReadSession(); | |
| 30 | ||
| 31 | $resolveReferences = Validator::param('resolveReferences')->isNumber()->setDefault(3)->getValue(); | |
| 32 | $input = Validator::input()->isJson()->assertValid()->getValue(); | |
| 33 | $entity = new \BO\Zmsentities\Process($input); | |
| 34 | $entity->testValid(); | |
| 35 | $this->testProcessData($entity); | |
| 36 | ||
| 37 | $userAccount = (new \BO\Zmsbackend\Helper\User($request))->readWorkstation()->getUseraccount(); | |
| 38 | $process = (new \BO\Zmsbackend\Process\Service\Process())->readEntity($entity->id, $entity->authKey, 2); | |
| 39 | ||
| 40 | if ('reserved' != $process->status) { | |
| 41 | throw new \BO\Zmsbackend\Process\Exception\ProcessNotReservedAnymore(); | |
| 42 | } | |
| 43 | ||
| 44 | $process = (new \BO\Zmsbackend\Process\Service\Process())->updateProcessStatus( | |
| 45 | $process, | |
| 46 | 'preconfirmed', | |
| 47 | \App::$now, | |
| 48 | $resolveReferences, | |
| 49 | $userAccount | |
| 50 | ); | |
| 51 | $message = \BO\Zmsbackend\Api\Response\Message::create($request); | |
| 52 | $message->data = $process; | |
| 53 | ||
| 54 | $response = Render::withLastModified($response, time(), '0'); | |
| 55 | $response = Render::withJson($response, $message->setUpdatedMetaData(), $message->getStatuscode()); | |
| 56 | return $response; | |
| 57 | } | |
| 58 | ||
| 59 | /** | |
| 60 | * @return void | |
| 61 | */ | |
| 62 | protected function testProcessData(\BO\Zmsentities\Process $entity) | |
| 63 | { | |
| 64 | $authCheck = (new \BO\Zmsbackend\Process\Service\Process())->readAuthKeyByProcessId($entity->id); | |
| 65 | ||
| 66 | if (! (new \BO\Zmsbackend\Process\Service\Process())->isAppointmentAllowedWithSameMail($entity)) { | |
| 67 | throw new \BO\Zmsbackend\Process\Exception\MoreThanAllowedAppointmentsPerMail(); | |
| 68 | } | |
| 69 | ||
| 70 | if (! $authCheck) { | |
| 71 | throw new \BO\Zmsbackend\Process\Exception\ProcessNotFound(); | |
| 72 | } elseif ($authCheck['authKey'] !== $entity->authKey) { | |
| 73 | throw new \BO\Zmsbackend\Process\Exception\AuthKeyMatchFailed(); | |
| 74 | } | |
| 75 | } | |
| 76 | } |
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 | } |