Skip to content

Commit

Permalink
Merge pull request #63 from myparcelnl/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
Reindert authored Aug 1, 2018
2 parents 99cc5c5 + 20ba514 commit 4d30e23
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 59 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "myparcelnl/sdk",
"version": "v1.3.14",
"version": "v1.3.15",
"description": "This package is designed to send and receive data from MyParcel by means of an API.",
"homepage": "https://www.myparcel.nl",
"tags": ["MyParcel", "My Parcel", "Post NL", "PostNL"],
Expand Down
34 changes: 17 additions & 17 deletions src/Helper/MyParcelCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,18 +73,18 @@ class MyParcelCollection

private $user_agent = '';

/**
* @param bool $keepKeys
*
* @return MyParcelConsignmentRepository[]
*/
/**
* @param bool $keepKeys
*
* @return MyParcelConsignmentRepository[]
*/
public function getConsignments($keepKeys = true)
{
if ( $keepKeys ) {
if ($keepKeys) {
return $this->consignments;
}
}

return array_values($this->consignments);
return array_values($this->consignments);
}

/**
Expand Down Expand Up @@ -179,9 +179,9 @@ public function addConsignment(MyParcelConsignmentRepository $consignment, $need

if ($needReferenceId && !empty($this->consignments)) {
if ($consignment->getReferenceId() === null) {
throw new \Exception('First set the reference id with setReferenceId() before running addConsignment() for multiple shipments');
throw new \Exception('First set the reference id with setReferenceId() before running addConsignment() for multiple shipments');
} elseif (key_exists($consignment->getReferenceId(), $this->consignments)) {
throw new \Exception('setReferenceId() must be unique. For example, do not use an ID of an order as an order has multiple shipments. In that case, use the shipment ID.');
throw new \Exception('setReferenceId() must be unique. For example, do not use an ID of an order as an order has multiple shipments. In that case, use the shipment ID.');
}
}

Expand Down Expand Up @@ -227,12 +227,12 @@ public function createConcepts()
return $this;
}

/**
* Delete concepts in MyParcel
*
* @return $this
* @throws \Exception
*/
/**
* Delete concepts in MyParcel
*
* @return $this
* @throws \Exception
*/
public function deleteConcepts()
{
/* @var $consignments MyParcelConsignmentRepository[] */
Expand Down Expand Up @@ -459,7 +459,7 @@ public function downloadPdfOfLabels($inline_download = false)
*/
public function sendReturnLabelMails()
{
$parentConsignment = $this->getConsignments(false)[0];
$parentConsignment = $this->getConsignments(false)[0];

$apiKey = $parentConsignment->getApiKey();
$data = $this->apiEncodeReturnShipments($parentConsignment);
Expand Down
82 changes: 41 additions & 41 deletions src/Model/Repository/MyParcelConsignmentRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,47 @@ public function isCorrectAddress($fullStreet)
return (bool) $result;
}

/**
* Check if the address is outside the EU
*
* @return bool
*/
public function isCdCountry()
{
return !in_array(
$this->getCountry(),
array (
'NL',
'BE',
'AT',
'BG',
'CZ',
'CY',
'DK',
'EE',
'FI',
'FR',
'DE',
'GB',
'GR',
'HU',
'IE',
'IT',
'LV',
'LT',
'LU',
'PL',
'PT',
'RO',
'SK',
'SI',
'ES',
'SE',
'XK',
)
);
}

/**
* Splits street data into separate parts for street name, house number and extension.
* Only for Dutch addresses
Expand Down Expand Up @@ -374,47 +415,6 @@ private function splitStreet($fullStreet)
return $streetData;
}

/**
* Check if the address is outside the EU
*
* @return bool
*/
protected function isCdCountry()
{
return !in_array(
$this->getCountry(),
array (
'NL',
'BE',
'AT',
'BG',
'CZ',
'CY',
'DK',
'EE',
'FI',
'FR',
'DE',
'GB',
'GR',
'HU',
'IE',
'IT',
'LV',
'LT',
'LU',
'PL',
'PT',
'RO',
'SK',
'SI',
'ES',
'SE',
'XK',
)
);
}

/**
* @return $this
*/
Expand Down

0 comments on commit 4d30e23

Please sign in to comment.