|
@@ 198-211 (lines=14) @@
|
| 195 |
|
* @return int |
| 196 |
|
* @throws Exception |
| 197 |
|
*/ |
| 198 |
|
public function sendEvent(EnvelopeInterface $envelope) |
| 199 |
|
{ |
| 200 |
|
// Validating |
| 201 |
|
$this->validator->validate($envelope); |
| 202 |
|
|
| 203 |
|
// Sending |
| 204 |
|
$data = $this->readJson($this->send(new Event($envelope))); |
| 205 |
|
|
| 206 |
|
if (!is_array($data) || !isset($data['requestId']) || !is_int($data['requestId'])) { |
| 207 |
|
throw new Exception("Malformed response"); |
| 208 |
|
} |
| 209 |
|
|
| 210 |
|
return $data['requestId']; |
| 211 |
|
} |
| 212 |
|
|
| 213 |
|
/** |
| 214 |
|
* Sends postback envelope to Covery and returns it's ID on Covery side |
|
@@ 221-234 (lines=14) @@
|
| 218 |
|
* @return int |
| 219 |
|
* @throws Exception |
| 220 |
|
*/ |
| 221 |
|
public function sendPostback(EnvelopeInterface $envelope) |
| 222 |
|
{ |
| 223 |
|
// Validating |
| 224 |
|
$this->validator->validate($envelope); |
| 225 |
|
|
| 226 |
|
// Sending |
| 227 |
|
$data = $this->readJson($this->send(new Postback($envelope))); |
| 228 |
|
|
| 229 |
|
if (!is_array($data) || !isset($data['requestId']) || empty($data['requestId']) || !is_int($data['requestId'])) { |
| 230 |
|
throw new Exception("Malformed response"); |
| 231 |
|
} |
| 232 |
|
|
| 233 |
|
return $data['requestId']; |
| 234 |
|
} |
| 235 |
|
|
| 236 |
|
/** |
| 237 |
|
* Sends envelope to Covery for analysis |