From 239ad092179b4f2a702f9e9d2089f31736a9f6ca Mon Sep 17 00:00:00 2001 From: Rickard Andersson Date: Mon, 12 Dec 2022 14:09:05 +0100 Subject: [PATCH 1/7] Added isoCountryCode to PostalAddress --- src/CXml/Models/Messages/PostalAddress.php | 33 ++++++++++++++++------ 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/src/CXml/Models/Messages/PostalAddress.php b/src/CXml/Models/Messages/PostalAddress.php index ddc58e9..bd969f4 100644 --- a/src/CXml/Models/Messages/PostalAddress.php +++ b/src/CXml/Models/Messages/PostalAddress.php @@ -22,6 +22,8 @@ class PostalAddress implements RequestInterface, MessageInterface * Optional Properties */ + private $isoCountryCode; + /** * @var string[] */ @@ -38,6 +40,11 @@ public function getCountry() return $this->country; } + public function getISOCountryCode() + { + return $this->isoCountryCode; + } + /** * @param string $country * @@ -163,37 +170,45 @@ public function setPostalCode($postalCode) return $this; } - public function parse(\SimpleXMLElement $contactXml) : void + public function parse(\SimpleXMLElement $contactXml): void { if ($data = $contactXml->xpath('Country')) { - $this->country = (string) current($data); + $current = current($data); + + $attr = $current->attributes(); + + if ($attr && isset($attr->isoCountryCode)) { + $this->isoCountryCode = $attr->isoCountryCode; + } + + $this->country = (string)$current; } if ($data = $contactXml->xpath('City')) { - $this->city = (string) current($data); + $this->city = (string)current($data); } if ($data = $contactXml->xpath('Street')) { foreach ($data as $street) { - $this->street[] = (string) $street; + $this->street[] = (string)$street; } } if ($data = $contactXml->xpath('DeliverTo')) { foreach ($data as $deliverTo) { - $this->deliverTo[] = (string) $deliverTo; + $this->deliverTo[] = (string)$deliverTo; } } if ($data = $contactXml->xpath('Municipality')) { - $this->municipality = (string) current($data); + $this->municipality = (string)current($data); } if ($data = $contactXml->xpath('State')) { - $this->state = (string) current($data); + $this->state = (string)current($data); } if ($data = $contactXml->xpath('PostalCode')) { - $this->postalCode = (string) current($data); + $this->postalCode = (string)current($data); } } - public function render(\SimpleXMLElement $parentNode) : void + public function render(\SimpleXMLElement $parentNode): void { if ($this->country) { $parentNode->addChild('Country', htmlspecialchars($this->country, ENT_XML1 | ENT_COMPAT, 'UTF-8')); From 02c03a7e42b010436529a71c5e1320804d9d9926 Mon Sep 17 00:00:00 2001 From: Rickard Andersson Date: Mon, 12 Dec 2022 14:09:26 +0100 Subject: [PATCH 2/7] Parse ShipTo objects in PunchOutSetupRequest --- .../Models/Requests/PunchOutSetupRequest.php | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/CXml/Models/Requests/PunchOutSetupRequest.php b/src/CXml/Models/Requests/PunchOutSetupRequest.php index 027000c..cdf5837 100644 --- a/src/CXml/Models/Requests/PunchOutSetupRequest.php +++ b/src/CXml/Models/Requests/PunchOutSetupRequest.php @@ -5,6 +5,7 @@ use CXml\Models\Messages\Contact; use CXml\Models\EntrinsicTrait; use CXml\Models\Messages\SelectedItem; +use CXml\Models\Messages\ShipTo; class PunchOutSetupRequest implements RequestInterface { @@ -30,6 +31,11 @@ class PunchOutSetupRequest implements RequestInterface */ private $contact = []; + /** + * @var \CXml\Models\Messages\ShipTo[] + */ + private $shipTo = []; + /** * @var \CXml\Models\Messages\SelectedItem|null */ @@ -55,6 +61,12 @@ public function parse(\SimpleXMLElement $requestNode): void $contact->parse($contactElement); $this->contact[] = $contact; } + + foreach ($requestNode->xpath('ShipTo/Address') as $shipToElement) { + $shipTo = new ShipTo(); + $shipTo->parse($shipToElement); + $this->shipTo[] = $shipTo; + } } public function getOperation(): ?string @@ -98,6 +110,14 @@ public function getContact(): array return $this->contact; } + /** + * @return \CXml\Models\Messages\ShipTo[] + */ + public function getShipTo(): array + { + return $this->shipTo; + } + /** * @param \CXml\Models\Messages\Contact[] $contact * From 170a150450a2cec62e08fc5a7f44944496899077 Mon Sep 17 00:00:00 2001 From: Rickard Andersson Date: Mon, 12 Dec 2022 14:09:51 +0100 Subject: [PATCH 3/7] Fix for PostalAddress getter in ShipTo --- src/CXml/Models/Messages/ShipTo.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/CXml/Models/Messages/ShipTo.php b/src/CXml/Models/Messages/ShipTo.php index 433c6d6..5cc1aef 100644 --- a/src/CXml/Models/Messages/ShipTo.php +++ b/src/CXml/Models/Messages/ShipTo.php @@ -20,7 +20,7 @@ class ShipTo implements RequestInterface /** * @var \CXml\Models\Messages\PostalAddress */ - private $address; + private $postalAddress; protected $isoCountryCode; protected $addressId; @@ -42,8 +42,8 @@ public function parse(\SimpleXMLElement $billToXml) : void $this->name = $billToXml->xpath('Name')[0]; if ($postalAddressElement = current($billToXml->xpath('PostalAddress'))) { - $this->address = new PostalAddress(); - $this->address->parse($postalAddressElement); + $this->postalAddress = new PostalAddress(); + $this->postalAddress->parse($postalAddressElement); } } From 1d15fe4e90564af3f96afca683a782929aa877f0 Mon Sep 17 00:00:00 2001 From: Rickard Andersson Date: Wed, 29 Mar 2023 14:44:13 +0200 Subject: [PATCH 4/7] Additional work to make OrderRequest parsing work --- src/CXml/Models/Messages/BillTo.php | 14 +++- src/CXml/Models/Messages/PostalAddress.php | 2 +- src/CXml/Models/Messages/ShipTo.php | 22 ++++-- src/CXml/Models/Requests/OrderRequest.php | 86 +++++++++++++++++----- 4 files changed, 95 insertions(+), 29 deletions(-) diff --git a/src/CXml/Models/Messages/BillTo.php b/src/CXml/Models/Messages/BillTo.php index 874668f..36901af 100644 --- a/src/CXml/Models/Messages/BillTo.php +++ b/src/CXml/Models/Messages/BillTo.php @@ -38,9 +38,19 @@ public function parse(\SimpleXMLElement $billToXml): void $this->addressIdDomain = $data; } - $this->name = $billToXml->xpath('Name')[0]; + $this->name = (string) $billToXml->xpath('Name')[0]; - if ($postalAddressElement = current($billToXml->xpath('PostalAddress'))) { + if (strlen($this->name) === 0) { + $this->name = (string) $billToXml->xpath('Address/Name')[0]; + } + + $postalAddressElement = current($billToXml->xpath('PostalAddress')); + + if (!$postalAddressElement) { + $postalAddressElement = current($billToXml->xpath('Address/PostalAddress')); + } + + if ($postalAddressElement) { $this->postalAddress = new PostalAddress(); $this->postalAddress->parse($postalAddressElement); } diff --git a/src/CXml/Models/Messages/PostalAddress.php b/src/CXml/Models/Messages/PostalAddress.php index bd969f4..71bca5a 100644 --- a/src/CXml/Models/Messages/PostalAddress.php +++ b/src/CXml/Models/Messages/PostalAddress.php @@ -178,7 +178,7 @@ public function parse(\SimpleXMLElement $contactXml): void $attr = $current->attributes(); if ($attr && isset($attr->isoCountryCode)) { - $this->isoCountryCode = $attr->isoCountryCode; + $this->isoCountryCode = (string)$attr->isoCountryCode; } $this->country = (string)$current; diff --git a/src/CXml/Models/Messages/ShipTo.php b/src/CXml/Models/Messages/ShipTo.php index 5cc1aef..dfbef8c 100644 --- a/src/CXml/Models/Messages/ShipTo.php +++ b/src/CXml/Models/Messages/ShipTo.php @@ -26,22 +26,32 @@ class ShipTo implements RequestInterface protected $addressId; protected $addressIdDomain; - public function parse(\SimpleXMLElement $billToXml) : void + public function parse(\SimpleXMLElement $billToXml): void { - if ($data = (string) $billToXml->attributes()->isoCountryCode) { + if ($data = (string)$billToXml->attributes()->isoCountryCode) { $this->isoCountryCode = $data; } - if ($data = (string) $billToXml->attributes()->addressID) { + if ($data = (string)$billToXml->attributes()->addressID) { $this->addressId = $data; } - if ($data = (string) $billToXml->attributes()->addressIDDomain) { + if ($data = (string)$billToXml->attributes()->addressIDDomain) { $this->addressIdDomain = $data; } - $this->name = $billToXml->xpath('Name')[0]; + $this->name = (string)$billToXml->xpath('Name')[0]; - if ($postalAddressElement = current($billToXml->xpath('PostalAddress'))) { + if (strlen($this->name) === 0) { + $this->name = (string)$billToXml->xpath('Address/Name')[0]; + } + + $postalAddressElement = current($billToXml->xpath('PostalAddress')); + + if (!$postalAddressElement) { + $postalAddressElement = current($billToXml->xpath('Address/PostalAddress')); + } + + if ($postalAddressElement) { $this->postalAddress = new PostalAddress(); $this->postalAddress->parse($postalAddressElement); } diff --git a/src/CXml/Models/Requests/OrderRequest.php b/src/CXml/Models/Requests/OrderRequest.php index 2e5fb4d..0370efd 100644 --- a/src/CXml/Models/Requests/OrderRequest.php +++ b/src/CXml/Models/Requests/OrderRequest.php @@ -16,6 +16,7 @@ class OrderRequest implements RequestInterface protected $orderID; protected $orderDate; + protected $orderVersion; /** * Type of order: @@ -37,17 +38,22 @@ class OrderRequest implements RequestInterface protected $type; /** - * @var float|null + * @var float|null */ protected $total; /** - * @var string|null + * @var string|null + */ + protected $currency; + + /** + * @var ShipTo|null */ protected $shipTo; /** - * @var BillTo + * @var BillTo|null */ protected $billTo; @@ -55,30 +61,37 @@ class OrderRequest implements RequestInterface protected $tax; /** - * @var \CXml\Models\Messages\Contact + * @var \CXml\Models\Messages\Contact */ protected $contact; /** - * @var \CXml\Models\Messages\ItemOut[] + * @var \CXml\Models\Messages\ItemOut[] */ protected $itemOut = []; /** - * @noinspection PhpUndefinedFieldInspection + * @noinspection PhpUndefinedFieldInspection */ public function parse(\SimpleXMLElement $requestNode): void { $this->parseAttributes( - $requestNode, [ + current($requestNode->xpath('OrderRequestHeader')), [ 'orderID', 'orderDate', 'orderType', + 'orderVersion', 'type', ] ); + $this->parseAttributes( + current($requestNode->xpath('OrderRequestHeader/Total/Money')), [ + 'currency', + ] + ); + $this->parseEntrinsic($requestNode); foreach ($requestNode->xpath('ItemOut') as $itemOutElement) { @@ -99,9 +112,10 @@ public function parse(\SimpleXMLElement $requestNode): void $this->shipTo = new ShipTo(); $this->shipTo->parse($node); } - $this->total = (string) current($requestNode->xpath('OrderRequestHeader/Total')); - $this->shipping = (string) current($requestNode->xpath('OrderRequestHeader/Shipping')); - $this->tax = (string) current($requestNode->xpath('OrderRequestHeader/Tax')); + $totalMoney = $requestNode->xpath('OrderRequestHeader/Total/Money'); + $this->total = (string) current($totalMoney); + $this->shipping = (string) current($requestNode->xpath('OrderRequestHeader/Shipping/Money')); + $this->tax = (string) current($requestNode->xpath('OrderRequestHeader/Tax/Money')); } /** @@ -109,7 +123,7 @@ public function parse(\SimpleXMLElement $requestNode): void */ public function getOrderId() { - return $this->orderId; + return $this->orderID; } /** @@ -119,7 +133,7 @@ public function getOrderId() */ public function setOrderId($orderId) { - $this->orderId = $orderId; + $this->orderID = $orderId; return $this; } @@ -200,38 +214,38 @@ public function setTotal(?float $total): OrderRequest } /** - * @return string|null + * @return ShipTo|null */ - public function getShipTo(): ?string + public function getShipTo(): ?ShipTo { return $this->shipTo; } /** - * @param string|null $shipTo + * @param ShipTo|null $shipTo * * @return OrderRequest */ - public function setShipTo(?string $shipTo): OrderRequest + public function setShipTo(?ShipTo $shipTo): OrderRequest { $this->shipTo = $shipTo; return $this; } /** - * @return string|null + * @return BillTo|null */ - public function getBillTo(): ?string + public function getBillTo(): ?BillTo { return $this->billTo; } /** - * @param string|null $billTo + * @param BillTo|null $billTo * * @return OrderRequest */ - public function setBillTo(?string $billTo): OrderRequest + public function setBillTo(?BillTo $billTo): OrderRequest { $this->billTo = $billTo; return $this; @@ -579,4 +593,36 @@ public function setItemOut(array $itemOut): OrderRequest return $this; } + /** + * @return mixed + */ + public function getOrderVersion() + { + return $this->orderVersion; + } + + /** + * @param mixed $orderVersion + */ + public function setOrderVersion($orderVersion): void + { + $this->orderVersion = $orderVersion; + } + + /** + * @return string|null + */ + public function getCurrency(): ?string + { + return $this->currency; + } + + /** + * @param string|null $currency + */ + public function setCurrency(?string $currency): void + { + $this->currency = $currency; + } + } From ec4aa61eb88240013bf95caeb7de887ab81b686d Mon Sep 17 00:00:00 2001 From: Rickard Andersson Date: Thu, 6 Apr 2023 10:08:32 +0200 Subject: [PATCH 5/7] Additional work to make OrderRequest parsing work --- src/CXml/Models/Messages/BillTo.php | 14 +++-- src/CXml/Models/Messages/Header.php | 29 +++++---- src/CXml/Models/Messages/ItemOut.php | 73 +++++++++++++++++++++-- src/CXml/Models/Messages/ShipTo.php | 6 +- src/CXml/Models/Requests/OrderRequest.php | 5 +- 5 files changed, 103 insertions(+), 24 deletions(-) diff --git a/src/CXml/Models/Messages/BillTo.php b/src/CXml/Models/Messages/BillTo.php index 36901af..d13d549 100644 --- a/src/CXml/Models/Messages/BillTo.php +++ b/src/CXml/Models/Messages/BillTo.php @@ -28,20 +28,24 @@ class BillTo implements RequestInterface public function parse(\SimpleXMLElement $billToXml): void { - if ($data = (string) $billToXml->attributes()->isoCountryCode) { + if ($data = (string)$billToXml->attributes()->isoCountryCode) { $this->isoCountryCode = $data; } - if ($data = (string) $billToXml->attributes()->addressID) { + if ($data = (string)$billToXml->attributes()->addressID) { $this->addressId = $data; } - if ($data = (string) $billToXml->attributes()->addressIDDomain) { + if ($data = (string)$billToXml->attributes()->addressIDDomain) { $this->addressIdDomain = $data; } - $this->name = (string) $billToXml->xpath('Name')[0]; + $name = $billToXml->xpath('Name'); + + if ($name) { + $this->name = (string)$name[0]; + } if (strlen($this->name) === 0) { - $this->name = (string) $billToXml->xpath('Address/Name')[0]; + $this->name = (string)$billToXml->xpath('Address/Name')[0]; } $postalAddressElement = current($billToXml->xpath('PostalAddress')); diff --git a/src/CXml/Models/Messages/Header.php b/src/CXml/Models/Messages/Header.php index 2146921..d85c37b 100644 --- a/src/CXml/Models/Messages/Header.php +++ b/src/CXml/Models/Messages/Header.php @@ -142,10 +142,18 @@ public function setSenderCredentials(array $senderCredentials): Header return $this; } - public function parse(\SimpleXMLElement $headerXml, $validate = false) : void + public function parse(\SimpleXMLElement $headerXml, $validate = false): void { - $this->senderIdentity = (string)$headerXml->xpath('Sender/Credential/Identity')[0]; - $this->senderSharedSecret = (string)$headerXml->xpath('Sender/Credential/SharedSecret')[0]; + $identity = $headerXml->xpath('Sender/Credential/Identity'); + $sharedSecret = $headerXml->xpath('Sender/Credential/SharedSecret'); + + if ($identity) { + $this->senderIdentity = (string)$identity[0]; + } + + if ($sharedSecret) { + $this->senderSharedSecret = (string)$sharedSecret[0]; + } // cXml Spec as of January 2021 @@ -160,7 +168,7 @@ public function parse(\SimpleXMLElement $headerXml, $validate = false) : void // sends payload that violates this.... if ($fromCredentials = $headerXml->xpath('From/Credential')) { $this->fromIdentity = (string)$fromCredentials[0]->xpath('Identity')[0]; - $this->fromDomain = (string)$fromCredentials[0]->attributes()->domain; + $this->fromDomain = (string)$fromCredentials[0]->attributes()->domain; $domainValidation = []; foreach ($fromCredentials as $fromCredential) { @@ -198,7 +206,7 @@ public function parse(\SimpleXMLElement $headerXml, $validate = false) : void } } - public function render(\SimpleXMLElement $parentNode) : void + public function render(\SimpleXMLElement $parentNode): void { $headerNode = $parentNode->addChild('Header'); @@ -207,8 +215,7 @@ public function render(\SimpleXMLElement $parentNode) : void foreach ($this->fromCredentials as $fromCredential) { $fromCredential->render($fromNode); } - } - else { + } else { $this->addNode($headerNode, 'From', htmlspecialchars($this->fromIdentity ?? 'Unknown', ENT_XML1 | ENT_COMPAT, 'UTF-8')); } @@ -217,8 +224,7 @@ public function render(\SimpleXMLElement $parentNode) : void foreach ($this->toCredentials as $toCredential) { $toCredential->render($toNode); } - } - else { + } else { $this->addNode($headerNode, 'To', 'Unknown'); } @@ -227,14 +233,13 @@ public function render(\SimpleXMLElement $parentNode) : void foreach ($this->senderCredentials as $senderCredential) { $senderCredential->render($senderNode); } - } - else { + } else { $this->addNode($headerNode, 'Sender', $this->getSenderIdentity() ?? 'Unknown') ->addChild('UserAgent', 'Unknown'); } } - private function addNode(\SimpleXMLElement $parentNode, string $nodeName, string $identity) : \SimpleXMLElement + private function addNode(\SimpleXMLElement $parentNode, string $nodeName, string $identity): \SimpleXMLElement { $node = $parentNode->addChild($nodeName); diff --git a/src/CXml/Models/Messages/ItemOut.php b/src/CXml/Models/Messages/ItemOut.php index 97b22eb..363a2bd 100644 --- a/src/CXml/Models/Messages/ItemOut.php +++ b/src/CXml/Models/Messages/ItemOut.php @@ -63,6 +63,9 @@ class ItemOut implements RequestInterface * @var \CXml\Models\Messages\Contact */ protected $contact; + protected $unitPrice; + protected $unitPriceCurrency; + protected $comments; public function parse(\SimpleXMLElement $requestNode): void { @@ -106,16 +109,27 @@ public function parse(\SimpleXMLElement $requestNode): void } if ($node = current($requestNode->xpath('ItemID/SupplierPartID'))) { - $this->itemIdSupplierPartID = (string) $node; + $this->itemIdSupplierPartID = (string)$node; } if ($node = current($requestNode->xpath('ItemID/SupplierPartAuxiliaryID'))) { - $this->itemIdSupplierPartAuxiliaryID = (string) $node; + $this->itemIdSupplierPartAuxiliaryID = (string)$node; } if ($node = current($requestNode->xpath('ItemID/BuyerPartID'))) { - $this->itemIdBuyerPartID = (string) $node; + $this->itemIdBuyerPartID = (string)$node; } if ($node = current($requestNode->xpath('ItemID/IdReference'))) { - $this->itemIdIdReference = (string) $node; + $this->itemIdIdReference = (string)$node; + } + if ($node = current($requestNode->xpath('ItemDetail/UnitPrice/Money'))) { + $this->unitPrice = (string)$node; + $attrs = $node->attributes(); + + if (isset($attrs['currency'])) { + $this->unitPriceCurrency = (string)$attrs['currency']; + } + } + if ($node = current($requestNode->xpath('Comments'))) { + $this->comments = (string)$node; } } @@ -191,7 +205,8 @@ public function getItemIdSupplierPartAuxiliaryID() */ public function setItemIdSupplierPartAuxiliaryID( $itemIdSupplierPartAuxiliaryID - ): self { + ): self + { $this->itemIdSupplierPartAuxiliaryID = $itemIdSupplierPartAuxiliaryID; return $this; } @@ -747,4 +762,52 @@ public function setContact(Contact $contact): self return $this; } + /** + * @return mixed + */ + public function getUnitPrice() + { + return $this->unitPrice; + } + + /** + * @param mixed $unitPrice + */ + public function setUnitPrice($unitPrice): void + { + $this->unitPrice = $unitPrice; + } + + /** + * @return mixed + */ + public function getUnitPriceCurrency() + { + return $this->unitPriceCurrency; + } + + /** + * @param mixed $unitPriceCurrency + */ + public function setUnitPriceCurrency($unitPriceCurrency): void + { + $this->unitPriceCurrency = $unitPriceCurrency; + } + + /** + * @return mixed + */ + public function getComments() + { + return $this->comments; + } + + /** + * @param mixed $comments + */ + public function setComments($comments): void + { + $this->comments = $comments; + } + } diff --git a/src/CXml/Models/Messages/ShipTo.php b/src/CXml/Models/Messages/ShipTo.php index dfbef8c..29553aa 100644 --- a/src/CXml/Models/Messages/ShipTo.php +++ b/src/CXml/Models/Messages/ShipTo.php @@ -39,7 +39,11 @@ public function parse(\SimpleXMLElement $billToXml): void $this->addressIdDomain = $data; } - $this->name = (string)$billToXml->xpath('Name')[0]; + $name = $billToXml->xpath('Name'); + + if ($name) { + $this->name = (string)$name[0]; + } if (strlen($this->name) === 0) { $this->name = (string)$billToXml->xpath('Address/Name')[0]; diff --git a/src/CXml/Models/Requests/OrderRequest.php b/src/CXml/Models/Requests/OrderRequest.php index 0370efd..eba4435 100644 --- a/src/CXml/Models/Requests/OrderRequest.php +++ b/src/CXml/Models/Requests/OrderRequest.php @@ -76,8 +76,10 @@ class OrderRequest implements RequestInterface public function parse(\SimpleXMLElement $requestNode): void { + $requestHeader = current($requestNode->xpath('OrderRequestHeader')); + $this->parseAttributes( - current($requestNode->xpath('OrderRequestHeader')), [ + $requestHeader, [ 'orderID', 'orderDate', 'orderType', @@ -93,6 +95,7 @@ public function parse(\SimpleXMLElement $requestNode): void ); $this->parseEntrinsic($requestNode); + $this->parseEntrinsic($requestHeader); foreach ($requestNode->xpath('ItemOut') as $itemOutElement) { $itemOut = new ItemOut(); From 82ff794fd9d884d2a59bfe3c8f65e5d27cf825b4 Mon Sep 17 00:00:00 2001 From: Rickard Andersson Date: Tue, 11 Apr 2023 15:48:37 +0200 Subject: [PATCH 6/7] Additional work to make OrderRequest parsing work --- src/CXml/Models/Messages/ItemOut.php | 20 ++++++++++++++++++++ src/CXml/Models/Requests/OrderRequest.php | 2 ++ 2 files changed, 22 insertions(+) diff --git a/src/CXml/Models/Messages/ItemOut.php b/src/CXml/Models/Messages/ItemOut.php index 363a2bd..1233d5e 100644 --- a/src/CXml/Models/Messages/ItemOut.php +++ b/src/CXml/Models/Messages/ItemOut.php @@ -66,6 +66,7 @@ class ItemOut implements RequestInterface protected $unitPrice; protected $unitPriceCurrency; protected $comments; + protected $description; public function parse(\SimpleXMLElement $requestNode): void { @@ -131,6 +132,9 @@ public function parse(\SimpleXMLElement $requestNode): void if ($node = current($requestNode->xpath('Comments'))) { $this->comments = (string)$node; } + if ($node = current($requestNode->xpath('ItemDetail/Description'))) { + $this->description = (string)$node; + } } /** @@ -810,4 +814,20 @@ public function setComments($comments): void $this->comments = $comments; } + /** + * @return mixed + */ + public function getDescription() + { + return $this->description; + } + + /** + * @param mixed $description + */ + public function setDescription($description): void + { + $this->description = $description; + } + } diff --git a/src/CXml/Models/Requests/OrderRequest.php b/src/CXml/Models/Requests/OrderRequest.php index eba4435..0fc264d 100644 --- a/src/CXml/Models/Requests/OrderRequest.php +++ b/src/CXml/Models/Requests/OrderRequest.php @@ -69,6 +69,7 @@ class OrderRequest implements RequestInterface * @var \CXml\Models\Messages\ItemOut[] */ protected $itemOut = []; + protected $comments; /** * @noinspection PhpUndefinedFieldInspection @@ -119,6 +120,7 @@ public function parse(\SimpleXMLElement $requestNode): void $this->total = (string) current($totalMoney); $this->shipping = (string) current($requestNode->xpath('OrderRequestHeader/Shipping/Money')); $this->tax = (string) current($requestNode->xpath('OrderRequestHeader/Tax/Money')); + $this->comments = (string) current($requestNode->xpath('OrderRequestHeader/Comments')); } /** From f7fe97a29f9df84c768d2b10097bac1da6e425d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johan=20So=CC=88lve?= Date: Wed, 13 Sep 2023 15:00:11 +0200 Subject: [PATCH 7/7] Optional address --- src/CXml/Models/Messages/ShipTo.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/CXml/Models/Messages/ShipTo.php b/src/CXml/Models/Messages/ShipTo.php index 29553aa..63a8f8a 100644 --- a/src/CXml/Models/Messages/ShipTo.php +++ b/src/CXml/Models/Messages/ShipTo.php @@ -45,7 +45,7 @@ public function parse(\SimpleXMLElement $billToXml): void $this->name = (string)$name[0]; } - if (strlen($this->name) === 0) { + if (strlen($this->name) === 0 && $billToXml->xpath('Address/Name')) { $this->name = (string)$billToXml->xpath('Address/Name')[0]; } @@ -83,7 +83,7 @@ public function setName($name) /** * @return \CXml\Models\Messages\PostalAddress */ - public function getPostalAddress(): PostalAddress + public function getPostalAddress(): ?PostalAddress { return $this->postalAddress; }