Conditions | 4 |
Paths | 3 |
Total Lines | 24 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
18 | public function __construct($apiPath, EnvelopeInterface $envelope) |
||
19 | { |
||
20 | if (!is_string($apiPath) || empty($apiPath)) { |
||
21 | throw new \InvalidArgumentException('API path must be non-empty string'); |
||
22 | } |
||
23 | |||
24 | // Building request |
||
25 | $ids = array(); |
||
26 | foreach ($envelope->getIdentities() as $id) { |
||
27 | $ids[] = $id->getType() . '=' . $id->getId(); |
||
28 | } |
||
29 | |||
30 | $packet = array('type' => $envelope->getType(), 'sequence_id' => $envelope->getSequenceId()); |
||
31 | |||
32 | parent::__construct( |
||
33 | 'POST', |
||
34 | TransportInterface::DEFAULT_URL . $apiPath, |
||
35 | array( |
||
36 | 'X-Identities' => implode('&', $ids) |
||
37 | ), |
||
38 | json_encode(array_merge($packet, $envelope->toArray())) |
||
39 | ); |
||
40 | |||
41 | } |
||
42 | } |
||
43 |