| @@ 80-104 (lines=25) @@ | ||
| 77 | * @param EditCasesRequest $request | |
| 78 | * @return CasesResponse | |
| 79 | */ | |
| 80 | public function edit(EditCasesRequest $request) | |
| 81 |     { | |
| 82 | $transformer = $this->transformerFactory->get(CasesDataTransformerFactory::REQUEST_EDIT); | |
| 83 | $configuration = $this->configurationFactory->get(CasesConfigurationFactory::CONFIGURATION_EDIT); | |
| 84 | ||
| 85 |         try { | |
| 86 | $params = $this->checkRequest($request, $transformer, $configuration); | |
| 87 |         } catch (InvalidConfigurationException $exception) { | |
| 88 | throw new InvalidConfigurationException($exception->getMessage()); | |
| 89 | } | |
| 90 | ||
| 91 |         try { | |
| 92 |             $result = $this->requestService->put("cases/{$params['case_id']}", ['case' => $params]); | |
| 93 |         } catch (ClientException $exception) { | |
| 94 | $contents = json_decode($exception->getResponse()->getBody(), JSON_UNESCAPED_UNICODE); | |
| 95 | ||
| 96 |             if ($contents['error'] === CasesResponse::ERROR_STAFF_HAS_NOT_ACCESS) { | |
| 97 | throw new StaffNotActiveException(CasesResponse::ERROR_STAFF_HAS_NOT_ACCESS); | |
| 98 | } | |
| 99 | ||
| 100 | throw $exception; | |
| 101 | } | |
| 102 | ||
| 103 | return $this->transformerFactory->get(CasesDataTransformerFactory::RESPONSE_VIEW)->transform($result); | |
| 104 | } | |
| 105 | ||
| 106 | /** | |
| 107 | * @param ListCasesRequest $request | |
| @@ 59-83 (lines=25) @@ | ||
| 56 | * @return StaffResponse | |
| 57 | * @throws StaffAlreadyExistException | |
| 58 | */ | |
| 59 | public function add(AddStaffRequest $request) | |
| 60 |     { | |
| 61 | $transformer = $this->transformerFactory->get(StaffDataTransformerFactory::REQUEST_ADD); | |
| 62 | $configuration = $this->configurationFactory->get(StaffConfigurationFactory::CONFIGURATION_ADD); | |
| 63 | ||
| 64 |         try { | |
| 65 | $params = $this->checkRequest($request, $transformer, $configuration); | |
| 66 |         } catch (InvalidConfigurationException $exception) { | |
| 67 | throw new InvalidConfigurationException($exception->getMessage()); | |
| 68 | } | |
| 69 | ||
| 70 |         try { | |
| 71 |             $result = $this->requestService->post('staff', ['staff' => $params]); | |
| 72 |         } catch (ClientException $exception) { | |
| 73 | $contents = json_decode($exception->getResponse()->getBody(), JSON_UNESCAPED_UNICODE); | |
| 74 | ||
| 75 |             if ($contents['error'] === StaffResponse::ERROR_EMAIL_ALREADY_EXIST) { | |
| 76 | throw new StaffAlreadyExistException(); | |
| 77 | } | |
| 78 | ||
| 79 | throw $exception; | |
| 80 | } | |
| 81 | ||
| 82 | return $this->transformerFactory->get(StaffDataTransformerFactory::RESPONSE_VIEW)->transform($result); | |
| 83 | } | |
| 84 | ||
| 85 | /** | |
| 86 | * @param EditStaffRequest $request | |