/** * {@inheritDoc} * * Format: * * <Shipment> (Optional) * <Code>Ship_Code</Code> (Optional) * <Cost>1</Cost> (Optional) * <MarkAsShipped>Yes</MarkAsShipped> (Optional) * <TrackingNumber>1111111111</TrackingNumber> (Required) * <TrackingType>FedEx</TrackingType> (Required) * <ShipDate> (Optional) * <Day>7</Day> * <Month>9</Month> * <Year>2012</Year> * </ShipDate> * </Shipment> */ public function toXml($version = Version::CURRENT, array $options = array()) { $xmlObject = new SimpleXMLElement('<Shipment />'); $xmlObject->addChild('TrackingNumber', $this->getTrackingNumber()); $xmlObject->addChild('TrackingType', $this->getTrackingType()); $xmlObject->addChild('MarkAsShipped', $this->getMarkAsShipped() ? 'Yes' : 'No'); if ($this->getCode()) { $xmlObject->addChild('Code', $this->getCode()); } if ($this->getCost()) { $xmlObject->addChild('Cost', $this->getCost()); } if ($this->getShipDate() instanceof \DateTime) { $date = $xmlObject->addChild('ShipDate'); XmlHelper::dateToXml($date, $this->getShipDate()); } return $xmlObject; }