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