/** * Fetch an order * * @param $reference * * @return Order * @throws BpostCurlException * @throws BpostInvalidResponseException * @throws BpostInvalidSelectionException * @throws Exception\XmlException\BpostXmlNoReferenceFoundException */ public function fetchOrder($reference) { $url = '/orders/' . (string) $reference; $headers = array('Accept: application/vnd.bpost.shm-order-v3.3+XML'); $xml = $this->doCall($url, null, $headers); return Order::createFromXML($xml); }
/** * @param \SimpleXMLElement $xml * * @return Order * @throws BpostXmlNoReferenceFoundException * @throws BpostNotImplementedException */ public static function createFromXML(\SimpleXMLElement $xml) { // @todo work with classmaps ... if (!isset($xml->reference)) { throw new BpostXmlNoReferenceFoundException(); } $order = new Order((string) $xml->reference); if (isset($xml->costCenter) && $xml->costCenter != '') { $order->setCostCenter((string) $xml->costCenter); } if (isset($xml->orderLine)) { foreach ($xml->orderLine as $orderLine) { $order->addLine(Line::createFromXML($orderLine)); } } if (isset($xml->box)) { foreach ($xml->box as $box) { $order->addBox(Box::createFromXML($box)); } } return $order; }