-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
168 additions
and
1 deletion.
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,35 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace MyParcelNL\Sdk\src\Model\Carrier; | ||
|
||
use MyParcelNL\Sdk\src\Model\Consignment\UPSConsignment; | ||
|
||
class CarrierUPS extends AbstractCarrier | ||
{ | ||
public const CONSIGNMENT = UPSConsignment::class; | ||
public const HUMAN = 'UPS'; | ||
public const ID = 8; | ||
public const NAME = 'ups'; | ||
|
||
/** | ||
* @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; | ||
} |
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,57 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace MyParcelNL\Sdk\src\Model\Consignment; | ||
|
||
use MyParcelNL\Sdk\src\Model\Carrier\CarrierUPS; | ||
use MyParcelNL\Sdk\src\Validator\Consignment\UPSConsignmentValidator; | ||
|
||
class UPSConsignment extends AbstractConsignment | ||
{ | ||
public const DEFAULT_WEIGHT = 3000; | ||
|
||
/** | ||
* @internal | ||
* @var int | ||
*/ | ||
public $physical_properties = ['weight' => self::DEFAULT_WEIGHT]; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
protected $carrierClass = CarrierUPS::class; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
protected $validatorClass = UPSConsignmentValidator::class; | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getLocalCountryCode(): string | ||
{ | ||
return self::CC_NL; | ||
} | ||
|
||
/** | ||
* @return array|string[] | ||
*/ | ||
public function getAllowedPackageTypes(): array | ||
{ | ||
return [ | ||
self::PACKAGE_TYPE_PACKAGE, | ||
]; | ||
} | ||
|
||
/** | ||
* @return array|string[] | ||
*/ | ||
public function getAllowedDeliveryTypes(): array | ||
{ | ||
return [ | ||
self::DELIVERY_TYPE_STANDARD, | ||
]; | ||
} | ||
} |
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,23 @@ | ||
<?php | ||
|
||
namespace MyParcelNL\Sdk\src\Validator\Consignment; | ||
|
||
use MyParcelNL\Sdk\src\Rule\Consignment\DeliveryDateRule; | ||
use MyParcelNL\Sdk\src\Rule\Consignment\MinimumWeightRule; | ||
use MyParcelNL\Sdk\src\Rule\Consignment\ShipmentOptionsRule; | ||
use MyParcelNL\Sdk\src\Validator\AbstractValidator; | ||
|
||
class UPSConsignmentValidator extends AbstractValidator | ||
{ | ||
/** | ||
* @return \MyParcelNL\Sdk\src\Rule\Rule[] | ||
*/ | ||
protected function getRules(): array | ||
{ | ||
return [ | ||
new DeliveryDateRule(), | ||
new MinimumWeightRule(), | ||
new ShipmentOptionsRule(), | ||
]; | ||
} | ||
} |
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,51 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace MyParcelNL\Sdk\Test\Model\Consignment; | ||
|
||
use MyParcelNL\Sdk\src\Model\Carrier\CarrierUPS; | ||
use MyParcelNL\Sdk\Test\Bootstrap\ConsignmentTestCase; | ||
|
||
class UPSConsignmentTest extends ConsignmentTestCase | ||
{ | ||
/** | ||
* @return array | ||
* @throws \Exception | ||
*/ | ||
public function provideUPSConsignmentsData(): array | ||
{ | ||
return $this->createConsignmentProviderDataset([ | ||
]); | ||
} | ||
|
||
/** | ||
* @param array $testData | ||
* | ||
* @throws \Exception | ||
* @throws \Exception | ||
* @dataProvider provideUPSConsignmentsData | ||
*/ | ||
public function testUPSForYouConsignments(array $testData): void | ||
{ | ||
$this->doConsignmentTest($testData); | ||
} | ||
|
||
/** | ||
* @return array|string[] | ||
* @throws \Exception | ||
*/ | ||
protected function getDefaultConsignmentData(): array | ||
{ | ||
return array_replace( | ||
parent::getDefaultConsignmentData(), | ||
[ | ||
self::CARRIER_ID => CarrierUPS::ID, | ||
self::FULL_STREET => 'Meander 631', | ||
self::POSTAL_CODE => '6825ME', | ||
self::CITY => 'Arnhem', | ||
self::PHONE => '123456', | ||
] | ||
); | ||
} | ||
} |