diff --git a/src/Model/Consignment/AbstractConsignment.php b/src/Model/Consignment/AbstractConsignment.php index a988f1d3..0599f887 100755 --- a/src/Model/Consignment/AbstractConsignment.php +++ b/src/Model/Consignment/AbstractConsignment.php @@ -471,6 +471,11 @@ abstract class AbstractConsignment */ protected $drop_off_point; + /** + * @var null|string + */ + private $state; + /** * @throws \Exception */ @@ -840,6 +845,26 @@ public function getRegion(): ?string return $this->region; } + /** + * @return null|string + */ + public function getState(): ?string + { + return $this->state; + } + + /** + * @param null|string $state + * + * @return self + */ + public function setState(?string $state): self + { + $this->state = $state; + + return $this; + } + /** * @param string|null $region * diff --git a/src/Services/ConsignmentEncode.php b/src/Services/ConsignmentEncode.php index 8cd135a0..c5c33ef7 100644 --- a/src/Services/ConsignmentEncode.php +++ b/src/Services/ConsignmentEncode.php @@ -172,6 +172,7 @@ private function encodeBase(): self 'postal_code' => $consignment->getPostalCode(), 'city' => (string) $consignment->getCity(), 'region' => (string) $consignment->getRegion(), + 'state' => (string) $consignment->getState(), 'email' => (string) $consignment->getEmail(), 'phone' => (string) $consignment->getPhone(), ], diff --git a/test/Model/Consignment/AbstractConsignmentTest.php b/test/Model/Consignment/AbstractConsignmentTest.php new file mode 100644 index 00000000..6d32b656 --- /dev/null +++ b/test/Model/Consignment/AbstractConsignmentTest.php @@ -0,0 +1,89 @@ + 'NL', + 'city' => 'Heerhugowaard', + 'street' => 'Dorpsstraat', + 'number' => '1', + 'box_number' => '2', + 'number_suffix' => 'b', + 'region' => 'Noord-Holland', + 'state' => 'NH', + 'postal_code' => '1701AA', + 'person' => 'Pietje Puk', + 'package_type' => AbstractConsignment::PACKAGE_TYPE_PACKAGE, + 'only_recipient' => true, + 'signature' => true, + 'return' => true, + 'large_format' => true, + 'age_check' => true, + 'label_description' => 'Voorbeeld123', + 'shop_id' => 1, + 'status' => 99, + 'external_identifier' => '123456789', + 'barcode' => '3STOIS912345678', + ]; + + /** + * @return void + * @throws \MyParcelNL\Sdk\src\Exception\MissingFieldException + */ + public function testAbstractConsignment(): void + { + $consignment = new PostNLConsignment(); + + $consignment + ->setCountry(self::TEST_DATA['cc']) + ->setCity(self::TEST_DATA['city']) + ->setStreet(self::TEST_DATA['street']) + ->setNumber(self::TEST_DATA['number']) + ->setBoxNumber(self::TEST_DATA['box_number']) + ->setNumberSuffix(self::TEST_DATA['number_suffix']) + ->setRegion(self::TEST_DATA['region']) + ->setState(self::TEST_DATA['state']) + ->setPostalCode(self::TEST_DATA['postal_code']) + ->setPerson(self::TEST_DATA['person']) + ->setPackageType(self::TEST_DATA['package_type']) + ->setOnlyRecipient(self::TEST_DATA['only_recipient']) + ->setSignature(self::TEST_DATA['signature']) + ->setReturn(self::TEST_DATA['return']) + ->setLargeFormat(self::TEST_DATA['large_format']) + ->setAgeCheck(self::TEST_DATA['age_check']) + ->setLabelDescription(self::TEST_DATA['label_description']) + ->setShopId(self::TEST_DATA['shop_id']) + ->setStatus(self::TEST_DATA['status']) + ->setExternalIdentifier(self::TEST_DATA['external_identifier']) + ->setBarcode(self::TEST_DATA['barcode']); + + self::assertEquals(self::TEST_DATA['cc'], $consignment->getCountry()); + self::assertEquals(self::TEST_DATA['city'], $consignment->getCity()); + self::assertEquals(self::TEST_DATA['street'], $consignment->getStreet()); + self::assertEquals(self::TEST_DATA['number'], $consignment->getNumber()); + self::assertEquals(self::TEST_DATA['box_number'], $consignment->getBoxNumber()); + self::assertEquals(self::TEST_DATA['number_suffix'], $consignment->getNumberSuffix()); + self::assertEquals(self::TEST_DATA['region'], $consignment->getRegion()); + self::assertEquals(self::TEST_DATA['state'], $consignment->getState()); + self::assertEquals(self::TEST_DATA['postal_code'], $consignment->getPostalCode()); + self::assertEquals(self::TEST_DATA['person'], $consignment->getPerson()); + self::assertEquals(self::TEST_DATA['only_recipient'], $consignment->isOnlyRecipient()); + self::assertEquals(self::TEST_DATA['signature'], $consignment->isSignature()); + self::assertEquals(self::TEST_DATA['return'], $consignment->isReturn()); + self::assertEquals(self::TEST_DATA['large_format'], $consignment->isLargeFormat()); + self::assertEquals(self::TEST_DATA['age_check'], $consignment->hasAgeCheck()); + self::assertEquals(self::TEST_DATA['label_description'], $consignment->getLabelDescription()); + self::assertEquals(self::TEST_DATA['shop_id'], $consignment->getShopId()); + self::assertEquals(self::TEST_DATA['status'], $consignment->getStatus()); + self::assertEquals(self::TEST_DATA['external_identifier'], $consignment->getExternalIdentifier()); + self::assertEquals(self::TEST_DATA['barcode'], $consignment->getBarcode()); + } +} diff --git a/test/Model/Consignment/UPSConsignmentTest.php b/test/Model/Consignment/UPSConsignmentTest.php index 81b3ad60..38c8c08f 100644 --- a/test/Model/Consignment/UPSConsignmentTest.php +++ b/test/Model/Consignment/UPSConsignmentTest.php @@ -28,7 +28,7 @@ public function provideUPSConsignmentsData(): array * @throws \Exception * @dataProvider provideUPSConsignmentsData */ - public function testUPSForYouConsignments(array $testData): void + public function testUPSConsignments(array $testData): void { $this->doConsignmentTest($testData); }