@@ 11-41 (lines=31) @@ | ||
8 | use React\Promise\PromiseInterface; |
|
9 | use RingCentral\Psr7\Request; |
|
10 | ||
11 | final class DeleteHandler |
|
12 | { |
|
13 | /** |
|
14 | * @var RequestService |
|
15 | */ |
|
16 | private $requestService; |
|
17 | ||
18 | /** |
|
19 | * @param RequestService $requestService |
|
20 | */ |
|
21 | public function __construct(RequestService $requestService) |
|
22 | { |
|
23 | $this->requestService = $requestService; |
|
24 | } |
|
25 | ||
26 | /** |
|
27 | * @param DeleteCommand $command |
|
28 | * @return PromiseInterface |
|
29 | */ |
|
30 | public function handle(DeleteCommand $command): PromiseInterface |
|
31 | { |
|
32 | return $this->requestService->request( |
|
33 | new Request( |
|
34 | 'DELETE', |
|
35 | $command->getUrl() |
|
36 | ) |
|
37 | )->then(function (ResponseInterface $response) { |
|
38 | return $response->getStatusCode() == 204; |
|
39 | }); |
|
40 | } |
|
41 | } |
|
42 |
@@ 11-41 (lines=31) @@ | ||
8 | use React\Promise\PromiseInterface; |
|
9 | use RingCentral\Psr7\Request; |
|
10 | ||
11 | final class PingHandler |
|
12 | { |
|
13 | /** |
|
14 | * @var RequestService |
|
15 | */ |
|
16 | private $requestService; |
|
17 | ||
18 | /** |
|
19 | * @param RequestService $requestService |
|
20 | */ |
|
21 | public function __construct(RequestService $requestService) |
|
22 | { |
|
23 | $this->requestService = $requestService; |
|
24 | } |
|
25 | ||
26 | /** |
|
27 | * @param PingCommand $command |
|
28 | * @return PromiseInterface |
|
29 | */ |
|
30 | public function handle(PingCommand $command): PromiseInterface |
|
31 | { |
|
32 | return $this->requestService->request( |
|
33 | new Request( |
|
34 | 'POST', |
|
35 | $command->getPingUrl() |
|
36 | ) |
|
37 | )->then(function (ResponseInterface $response) { |
|
38 | return $response->getStatusCode() == 204; |
|
39 | }); |
|
40 | } |
|
41 | } |
|
42 |