Skip to content

Commit

Permalink
Merge pull request #28 from guiparmezani/master
Browse files Browse the repository at this point in the history
Shipping
  • Loading branch information
gabrielbull committed Apr 29, 2015
2 parents 2c71efa + ef9c8cc commit 45edb2f
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 6 deletions.
26 changes: 26 additions & 0 deletions src/Ups/Entity/Shipper.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ class Shipper implements NodeInterface
*/
protected $name;

/**
* @var string
*/
protected $companyName;

/**
* @var string
*/
Expand Down Expand Up @@ -75,6 +80,9 @@ public function __construct($attributes = null)
if (isset($attributes->Name)) {
$this->setName($attributes->Name);
}
if (isset($attributes->CompanyName)) {
$this->setCompanyName($attributes->CompanyName);
}
if (isset($attributes->AttentionName)) {
$this->setAttentionName($attributes->AttentionName);
}
Expand Down Expand Up @@ -219,6 +227,24 @@ public function setName($name)
return $this;
}

/**
* @return string
*/
public function getCompanyName()
{
return $this->companyName;
}

/**
* @param string $companyName
* @return $this
*/
public function setCompanyName($companyName)
{
$this->companyName = $companyName;
return $this;
}

/**
* @return string
*/
Expand Down
11 changes: 5 additions & 6 deletions src/Ups/Shipping.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ private function createConfirmRequest($validation, $shipment, $labelSpecOpts, $r
$request->appendChild($node);

$request->appendChild($xml->createElement('RequestAction', 'ShipConfirm'));
$request->appendChild($xml->createElement('RequestOption', $validation ? : ''));
$request->appendChild($xml->createElement('RequestOption', $validation ? : 'nonvalidate'));

// Page 47
$shipmentNode = $container->appendChild($xml->createElement('Shipment'));
Expand Down Expand Up @@ -176,7 +176,7 @@ private function createConfirmRequest($validation, $shipment, $labelSpecOpts, $r
if (isset($shipment->ShipFrom)) {
$shipFromNode = $shipmentNode->appendChild($xml->createElement('ShipFrom'));

$shipFromNode->appendChild($xml->createElement('CompanyName', $shipment->ShipFrom->CompanyName));
$shipFromNode->appendChild($xml->createElement('CompanyName', $shipment->ShipFrom->getCompanyName()));

if (isset($shipment->ShipFrom->AttentionName)) {
$shipFromNode->appendChild($xml->createElement('AttentionName', $shipment->ShipFrom->AttentionName));
Expand Down Expand Up @@ -283,7 +283,7 @@ private function createConfirmRequest($validation, $shipment, $labelSpecOpts, $r
}

$serviceNode = $shipmentNode->appendChild($xml->createElement('Service'));
$serviceNode->appendChild($xml->createElement('Code', $shipment->Service->Code));
$serviceNode->appendChild($xml->createElement('Code', $shipment->Service->getCode()));

if (isset($shipment->Service->Description)) {
$serviceNode->appendChild($xml->createElement('Description', $shipment->Service->Description));
Expand All @@ -308,7 +308,7 @@ private function createConfirmRequest($validation, $shipment, $labelSpecOpts, $r
$node->appendChild($xml->createElement('NegotiatedRatesIndicator'));
}

foreach ($shipment->Package as &$package) {
foreach ($shipment->getPackages() as &$package) {
$node = $shipmentNode->appendChild($xml->createElement('Package'));

$ptNode = $node->appendChild($xml->createElement('PackagingType'));
Expand Down Expand Up @@ -398,7 +398,6 @@ private function createConfirmRequest($validation, $shipment, $labelSpecOpts, $r
$node->appendChild($xml->createElement('Description', $receiptSpecOpts->ImageFormat->Description));
}
}

return $xml->saveXML();
}

Expand Down Expand Up @@ -442,7 +441,7 @@ private function createAcceptRequest($shipmentDigest)
$request->appendChild($node);

$request->appendChild($xml->createElement('RequestAction', 'ShipAccept'));
$container->appendChild($xml->createElement('ShipmentDigest', $shipmentDigest));
$container->appendChild($xml->createElement('ShipmentDigest', $shipmentDigest->ShipmentDigest));

return $xml->saveXML();
}
Expand Down

0 comments on commit 45edb2f

Please sign in to comment.