public function testFromPack() { $response = InkRouter_Response_Response::fromPack($this->xml); $update = new InkRouter_Response_Update(); $update->setId(2)->setType('PRINT')->setQuantity(500)->setOrderItemId('pg4f7969f8a4891')->setComment("SHEET ID: '579468'; POSITION: '1'")->setReplyUrl('http://printserver.com/api/client-updates')->setTimestamp(123456789)->setPrintCustomerInvoice('123a33412fg11')->setMisc('misc')->setTrackingNumber('1234lfdsaj23434')->setWeight(10.2)->setCost(11.1)->setPrintProviderInvoice('1236433fd1123rf'); $this->assertEquals(array($update), $response->getUpdates()); }
/** * @static * @param string $pack with xml from InkRouter * @return InkRouter_Response_Response */ public static function fromPack($pack) { $xml = new DOMDocument(); $xml->loadXML($pack); $response = new self(); foreach ($xml->getElementsByTagName('client_update') as $update) { $updateObj = new InkRouter_Response_Update(); foreach ($update->childNodes as $property) { switch ($property->nodeName) { case 'update_id': $updateObj->setId($property->nodeValue); break; case 'update_type': $updateObj->setType($property->nodeValue); break; case 'quantity': $updateObj->setQuantity($property->nodeValue); break; case 'order_item_id': $updateObj->setOrderItemId($property->nodeValue); break; case 'comment': $updateObj->setComment($property->nodeValue); break; case 'replyUrl': $updateObj->setReplyUrl($property->nodeValue); break; case 'timestamp': $updateObj->setTimestamp($property->nodeValue); break; case 'print_customer_invoice': $updateObj->setPrintCustomerInvoice($property->nodeValue); break; case 'misc': $updateObj->setMisc($property->nodeValue); break; case 'tracking_number': $updateObj->setTrackingNumber($property->nodeValue); break; case 'weight': $updateObj->setWeight($property->nodeValue); break; case 'cost': $updateObj->setCost($property->nodeValue); break; case 'print_provider_invoice': $updateObj->setPrintProviderInvoice($property->nodeValue); break; } } $response->addUpdate($updateObj); } return $response; }