-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: add all dhl carriers * fix conflict * fix conflict * fix failing tests * refactor: indexing * refactor: changed if * refactor: feedback * refactor: feedback * refactor: feedback * refactor: feedback * refactor: fix test * refactor: fix test * refactor: feedback
- Loading branch information
Showing
19 changed files
with
629 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace MyParcelNL\Sdk\src\Model\Carrier; | ||
|
||
use MyParcelNL\Sdk\src\Model\Consignment\AbstractConsignment; | ||
use MyParcelNL\Sdk\src\Model\Consignment\DHLEuroplusConsignment; | ||
|
||
class CarrierDHLEuroplus extends AbstractCarrier | ||
{ | ||
public const CONSIGNMENT = DHLEuroplusConsignment::class; | ||
public const HUMAN = 'DHL Europlus'; | ||
public const ID = 11; | ||
public const NAME = 'dhleuroplus'; | ||
public const TYPE = AbstractConsignment::TYPE_B2B; | ||
|
||
/** | ||
* @var class-string | ||
*/ | ||
protected $consignmentClass = self::CONSIGNMENT; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
protected $human = self::HUMAN; | ||
|
||
/** | ||
* @var int | ||
*/ | ||
protected $id = self::ID; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
protected $name = self::NAME; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
protected $type = self::TYPE; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace MyParcelNL\Sdk\src\Model\Carrier; | ||
|
||
use MyParcelNL\Sdk\src\Model\Consignment\AbstractConsignment; | ||
use MyParcelNL\Sdk\src\Model\Consignment\DHLParcelConnectConsignment; | ||
|
||
class CarrierDHLParcelConnect extends AbstractCarrier | ||
{ | ||
public const CONSIGNMENT = DHLParcelConnectConsignment::class; | ||
public const HUMAN = 'DHL Parcel Connect'; | ||
public const ID = 10; | ||
public const NAME = 'dhlparcelconnect'; | ||
public const TYPE = AbstractConsignment::TYPE_B2C; | ||
|
||
/** | ||
* @var class-string | ||
*/ | ||
protected $consignmentClass = self::CONSIGNMENT; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
protected $human = self::HUMAN; | ||
|
||
/** | ||
* @var int | ||
*/ | ||
protected $id = self::ID; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
protected $name = self::NAME; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
protected $type = self::TYPE; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace MyParcelNL\Sdk\src\Model\Consignment; | ||
|
||
use MyParcelNL\Sdk\src\Model\Carrier\CarrierDHLEuroplus; | ||
use MyParcelNL\Sdk\src\Validator\Consignment\DHLEuroplusConsignmentValidator; | ||
|
||
class DHLEuroplusConsignment extends AbstractConsignment | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
protected $carrierClass = CarrierDHLEuroplus::class; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
protected $validatorClass = DHLEuroplusConsignmentValidator::class; | ||
|
||
/** | ||
* @return string[] | ||
*/ | ||
public function getAllowedDeliveryTypes(): array | ||
{ | ||
return [ | ||
self::DELIVERY_TYPE_STANDARD_NAME, | ||
]; | ||
} | ||
|
||
/** | ||
* @return string[] | ||
*/ | ||
public function getAllowedPackageTypes(): array | ||
{ | ||
return [ | ||
self::PACKAGE_TYPE_PACKAGE_NAME, | ||
self::PACKAGE_TYPE_MAILBOX_NAME, | ||
]; | ||
} | ||
|
||
/** | ||
* @return string[] | ||
*/ | ||
public function getAllowedShipmentOptions(): array | ||
{ | ||
return [ | ||
self::SHIPMENT_OPTION_INSURANCE, | ||
self::SHIPMENT_OPTION_SIGNATURE, | ||
self::EXTRA_OPTION_DELIVERY_SATURDAY | ||
]; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getLocalCountryCode(): string | ||
{ | ||
return self::CC_NL; | ||
} | ||
|
||
/** | ||
* @return int[] | ||
*/ | ||
protected function getLocalInsurancePossibilities(): array | ||
{ | ||
return [500, 1000, 5000]; | ||
} | ||
|
||
/** | ||
* @return int[] | ||
*/ | ||
protected function getEuInsurancePossibilities(): array | ||
{ | ||
return [500, 1000, 5000]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace MyParcelNL\Sdk\src\Model\Consignment; | ||
|
||
use MyParcelNL\Sdk\src\Model\Carrier\CarrierDHLParcelConnect; | ||
use MyParcelNL\Sdk\src\Validator\Consignment\DHLParcelConnectConsignmentValidator; | ||
|
||
class DHLParcelConnectConsignment extends AbstractConsignment | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
protected $carrierClass = CarrierDHLParcelConnect::class; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
protected $validatorClass = DHLParcelConnectConsignmentValidator::class; | ||
|
||
/** | ||
* @return string[] | ||
*/ | ||
public function getAllowedDeliveryTypes(): array | ||
{ | ||
return [ | ||
self::DELIVERY_TYPE_STANDARD_NAME, | ||
self::DELIVERY_TYPE_PICKUP_NAME, | ||
]; | ||
} | ||
|
||
/** | ||
* @return string[] | ||
*/ | ||
public function getAllowedPackageTypes(): array | ||
{ | ||
return [ | ||
self::PACKAGE_TYPE_PACKAGE_NAME, | ||
self::PACKAGE_TYPE_MAILBOX_NAME, | ||
]; | ||
} | ||
|
||
/** | ||
* @return string[] | ||
*/ | ||
public function getAllowedShipmentOptions(): array | ||
{ | ||
return [ | ||
self::SHIPMENT_OPTION_INSURANCE, | ||
self::SHIPMENT_OPTION_SIGNATURE, | ||
]; | ||
} | ||
|
||
/** | ||
* @return array|string[] | ||
*/ | ||
public function getAllowedShipmentOptionsForPickup(): array | ||
{ | ||
return [ | ||
self::SHIPMENT_OPTION_SIGNATURE, | ||
]; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getLocalCountryCode(): string | ||
{ | ||
return self::CC_NL; | ||
} | ||
|
||
/** | ||
* @return int[] | ||
*/ | ||
protected function getLocalInsurancePossibilities(): array | ||
{ | ||
return [500, 1000, 5000]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace MyParcelNL\Sdk\src\Rule\Consignment; | ||
|
||
use MyParcelNL\Sdk\src\Rule\Rule; | ||
|
||
class RestrictCountriesRule extends Rule | ||
{ | ||
private $allowedCountries; | ||
|
||
/** | ||
* @param array $countries | ||
*/ | ||
public function __construct(array $countries) { | ||
$this->allowedCountries = $countries; | ||
parent::__construct(); | ||
} | ||
|
||
/** | ||
* @param \MyParcelNL\Sdk\src\Model\Consignment\AbstractConsignment $validationSubject | ||
*/ | ||
public function validate($validationSubject): void | ||
{ | ||
if (in_array($validationSubject->getCountry(), $this->allowedCountries, true)) { | ||
return; | ||
} | ||
|
||
$this->addError( | ||
'Shipments are only allowed to the following countries: ' . implode(', ', $this->allowedCountries) | ||
); | ||
} | ||
} |
Oops, something went wrong.