1 | <?php |
||
19 | abstract class AbstractService |
||
20 | { |
||
21 | /** |
||
22 | * @var ConnectionInterface |
||
23 | */ |
||
24 | private $connection; |
||
25 | |||
26 | /** |
||
27 | * AbstractService constructor. |
||
28 | * |
||
29 | * @param ConnectionInterface $connection |
||
30 | */ |
||
31 | public function __construct(ConnectionInterface $connection) |
||
35 | |||
36 | /** |
||
37 | * @return ConnectionInterface |
||
38 | */ |
||
39 | protected function getConnection(): ConnectionInterface |
||
43 | |||
44 | /** |
||
45 | * Formats a date to a timestamp. |
||
46 | * |
||
47 | * @param \DateTime|null $date |
||
48 | * |
||
49 | * @return int|null |
||
50 | */ |
||
51 | final protected function toTimestamp(\DateTime $date = null): ?int |
||
59 | |||
60 | /** |
||
61 | * Calls the API with signed session. |
||
62 | * |
||
63 | * @param string $method |
||
64 | * @param array $params |
||
65 | * @param SessionInterface|null $session |
||
66 | * @param string $requestMethod |
||
67 | * |
||
68 | * @throws ApiException |
||
69 | * @throws NotFoundException |
||
70 | * |
||
71 | * @return array |
||
72 | */ |
||
73 | final protected function signedCall(string $method, array $params = [], SessionInterface $session = null, $requestMethod = 'GET'): array |
||
85 | |||
86 | /** |
||
87 | * Calls the API unsigned. |
||
88 | * |
||
89 | * @param string $method |
||
90 | * @param array $params |
||
91 | * @param string $requestMethod |
||
92 | * |
||
93 | * @throws ApiException |
||
94 | * @throws NotFoundException |
||
95 | * |
||
96 | * @return array |
||
97 | */ |
||
98 | final protected function unsignedCall(string $method, array $params = [], $requestMethod = 'GET'): array |
||
110 | } |
||
111 |