1 | <?php |
||
12 | class PublicAPIClient |
||
13 | { |
||
14 | /** |
||
15 | * @var CredentialsInterface |
||
16 | */ |
||
17 | private $credentials; |
||
18 | |||
19 | /** |
||
20 | * @var TransportInterface |
||
21 | */ |
||
22 | private $transport; |
||
23 | |||
24 | /** |
||
25 | * @var LoggerInterface |
||
26 | */ |
||
27 | private $logger; |
||
28 | |||
29 | /** |
||
30 | * @var ValidatorV1 |
||
31 | */ |
||
32 | private $validator; |
||
33 | |||
34 | /** |
||
35 | * Client constructor. |
||
36 | * @param CredentialsInterface $credentials |
||
37 | * @param TransportInterface $transport |
||
38 | * @param LoggerInterface|null $logger |
||
39 | */ |
||
40 | public function __construct( |
||
50 | |||
51 | private function send(RequestInterface $request) |
||
85 | |||
86 | /** |
||
87 | * Utility method, that reads JSON data |
||
88 | * |
||
89 | * @param $string |
||
90 | * @return mixed|null |
||
91 | * @throws Exception |
||
92 | */ |
||
93 | private function readJson($string) |
||
114 | |||
115 | /** |
||
116 | * Sends request to Covery and returns access level, associated with |
||
117 | * used credentials |
||
118 | * |
||
119 | * This method can be used for Covery health check and availability |
||
120 | * On any problem (network, credentials, server side) this method |
||
121 | * will throw an exception |
||
122 | * |
||
123 | * @return string |
||
124 | * @throws Exception |
||
125 | */ |
||
126 | public function ping() |
||
135 | |||
136 | /** |
||
137 | * Sends envelope to Covery and returns it's ID on Covery side |
||
138 | * Before sending, validation is performed |
||
139 | * |
||
140 | * @param EnvelopeInterface $envelope |
||
141 | * @return int |
||
142 | * @throws Exception |
||
143 | */ |
||
144 | public function sendEvent(EnvelopeInterface $envelope) |
||
158 | } |
||
159 |