Total Complexity | 3 |
Total Lines | 49 |
Duplicated Lines | 0 % |
Coverage | 20% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
12 | final class Orders |
||
13 | { |
||
14 | /** @var ApiClient */ |
||
15 | private $client; |
||
16 | |||
17 | 1 | public function __construct(ApiClient $client) |
|
18 | { |
||
19 | 1 | $this->client = $client; |
|
20 | 1 | } |
|
21 | |||
22 | /** |
||
23 | * Создание заказа. |
||
24 | * |
||
25 | * @link https://otpravka.pochta.ru/specification#/orders-creating_order |
||
26 | * |
||
27 | * @param OrderRequest $request |
||
28 | * |
||
29 | * @throws OrderException |
||
30 | * |
||
31 | * @return string номер созданного заказа |
||
32 | */ |
||
33 | public function create(OrderRequest $request): string |
||
34 | { |
||
35 | $response = $this->client->put('/1.0/user/backlog', $request); |
||
36 | |||
37 | if (isset($response['result-ids'])) { |
||
38 | return (string) $response['result-ids'][0]; |
||
39 | } |
||
40 | |||
41 | return $response['errors'] ?? $response; |
||
42 | } |
||
43 | |||
44 | public function delete(array $ids) |
||
45 | { |
||
46 | $response = $this->client->delete('/1.0/user/backlog', new class($ids) implements Arrayable { |
||
47 | private $ids; |
||
48 | |||
49 | public function __construct(array $ids) |
||
61 | } |
||
62 | } |
||
63 |