| @@ 9-71 (lines=63) @@ | ||
| 6 | use DOMElement; |
|
| 7 | use Ups\NodeInterface; |
|
| 8 | ||
| 9 | class InvoiceLineTotal implements NodeInterface |
|
| 10 | { |
|
| 11 | private $currencyCode; |
|
| 12 | private $monetaryValue; |
|
| 13 | ||
| 14 | public function __construct($response = null) |
|
| 15 | { |
|
| 16 | if (null !== $response) { |
|
| 17 | if (isset($response->CurrencyCode)) { |
|
| 18 | $this->setCurrencyCode($response->CurrencyCode); |
|
| 19 | } |
|
| 20 | if (isset($response->MonetaryValue)) { |
|
| 21 | $this->setMonetaryValue($response->MonetaryValue); |
|
| 22 | } |
|
| 23 | } |
|
| 24 | } |
|
| 25 | ||
| 26 | /** |
|
| 27 | * @param null|DOMDocument $document |
|
| 28 | * |
|
| 29 | * @return DOMElement |
|
| 30 | */ |
|
| 31 | public function toNode(DOMDocument $document = null) |
|
| 32 | { |
|
| 33 | if (null === $document) { |
|
| 34 | $document = new DOMDocument(); |
|
| 35 | } |
|
| 36 | ||
| 37 | $node = $document->createElement('InvoiceLineTotal'); |
|
| 38 | ||
| 39 | if ($this->getCurrencyCode()) { |
|
| 40 | $node->appendChild($document->createElement('CurrencyCode', $this->getCurrencyCode())); |
|
| 41 | } |
|
| 42 | ||
| 43 | $node->appendChild($document->createElement('MonetaryValue', $this->getMonetaryValue())); |
|
| 44 | ||
| 45 | return $node; |
|
| 46 | } |
|
| 47 | ||
| 48 | public function getCurrencyCode() |
|
| 49 | { |
|
| 50 | return $this->currencyCode; |
|
| 51 | } |
|
| 52 | ||
| 53 | public function setCurrencyCode($var) |
|
| 54 | { |
|
| 55 | $this->currencyCode = $var; |
|
| 56 | } |
|
| 57 | ||
| 58 | public function getMonetaryValue() |
|
| 59 | { |
|
| 60 | return $this->monetaryValue; |
|
| 61 | } |
|
| 62 | ||
| 63 | public function setMonetaryValue($var) |
|
| 64 | { |
|
| 65 | if (!is_numeric($var)) { |
|
| 66 | throw new \Exception('Monetary value should be a numeric value'); |
|
| 67 | } |
|
| 68 | ||
| 69 | $this->monetaryValue = $var; |
|
| 70 | } |
|
| 71 | } |
|
| 72 | ||
| @@ 9-71 (lines=63) @@ | ||
| 6 | use DOMElement; |
|
| 7 | use Ups\NodeInterface; |
|
| 8 | ||
| 9 | class ShipmentTotalWeight implements NodeInterface |
|
| 10 | { |
|
| 11 | private $UnitOfMeasurement; |
|
| 12 | private $Weight; |
|
| 13 | ||
| 14 | public function __construct($response = null) |
|
| 15 | { |
|
| 16 | if (null !== $response) { |
|
| 17 | if (isset($response->UnitOfMeasurement)) { |
|
| 18 | $this->setUnitOfMeasurement($response->UnitOfMeasurement); |
|
| 19 | } |
|
| 20 | if (isset($response->Weight)) { |
|
| 21 | $this->setWeight($response->Weight); |
|
| 22 | } |
|
| 23 | } |
|
| 24 | } |
|
| 25 | ||
| 26 | /** |
|
| 27 | * @param null|DOMDocument $document |
|
| 28 | * |
|
| 29 | * @return DOMElement |
|
| 30 | */ |
|
| 31 | public function toNode(DOMDocument $document = null) |
|
| 32 | { |
|
| 33 | if (null === $document) { |
|
| 34 | $document = new DOMDocument(); |
|
| 35 | } |
|
| 36 | ||
| 37 | $node = $document->createElement('ShipmentTotalWeight'); |
|
| 38 | if ($this->getUnitOfMeasurement()) { |
|
| 39 | $node->appendChild($this->getUnitOfMeasurement()->toNode($document)); |
|
| 40 | // $node->appendChild($document->createElement('UnitOfMeasurement', $this->getUnitOfMeasurement())); |
|
| 41 | } |
|
| 42 | ||
| 43 | $node->appendChild($document->createElement('Weight', $this->getWeight())); |
|
| 44 | ||
| 45 | return $node; |
|
| 46 | } |
|
| 47 | ||
| 48 | public function getUnitOfMeasurement() |
|
| 49 | { |
|
| 50 | return $this->UnitOfMeasurement; |
|
| 51 | } |
|
| 52 | ||
| 53 | public function setUnitOfMeasurement($var) |
|
| 54 | { |
|
| 55 | $this->UnitOfMeasurement = $var; |
|
| 56 | } |
|
| 57 | ||
| 58 | public function getWeight() |
|
| 59 | { |
|
| 60 | return $this->Weight; |
|
| 61 | } |
|
| 62 | ||
| 63 | public function setWeight($var) |
|
| 64 | { |
|
| 65 | if (!is_numeric($var)) { |
|
| 66 | throw new \Exception('Weight value should be a numeric value'); |
|
| 67 | } |
|
| 68 | ||
| 69 | $this->Weight = $var; |
|
| 70 | } |
|
| 71 | } |
|
| 72 | ||