From 1e62045a1e03cc285806e01390582321ee5fd61d Mon Sep 17 00:00:00 2001 From: Zwaans Date: Fri, 18 Apr 2025 14:55:17 +0200 Subject: [PATCH 1/3] :lipstick: Added carrier code as a required field to the delivery dates endpoint --- src/MyParcelComApi.php | 2 ++ src/MyParcelComApiInterface.php | 2 ++ tests/Feature/MyParcelComApi/DeliveryDatesTest.php | 1 + 3 files changed, 5 insertions(+) diff --git a/src/MyParcelComApi.php b/src/MyParcelComApi.php index 409edb8..c671bb2 100644 --- a/src/MyParcelComApi.php +++ b/src/MyParcelComApi.php @@ -1002,6 +1002,7 @@ public function deleteShipmentSurcharge(ShipmentSurchargeInterface $shipmentSurc */ public function getDeliveryDates( string $serviceCode, + string $carrierCode, AddressInterface $address, DatetimeInterface $startDate, DatetimeInterface $endDate, @@ -1013,6 +1014,7 @@ public function getDeliveryDates( 'post', [ 'service_code' => $serviceCode, + 'carrier_code' => $carrierCode, 'service_option_codes' => $serviceOptionCodes, 'address' => [ 'country_code' => $address->getCountryCode(), diff --git a/src/MyParcelComApiInterface.php b/src/MyParcelComApiInterface.php index 1949c59..efa88d8 100644 --- a/src/MyParcelComApiInterface.php +++ b/src/MyParcelComApiInterface.php @@ -266,6 +266,7 @@ public function generateManifestForCollection(CollectionInterface $collection): * Accepts an optional array of `delivery-window` service option codes * * @param string $serviceCode + * @param string $carrierCode * @param AddressInterface $address * @param DateTimeInterface $startDate * @param DateTimeInterface $endDate @@ -281,6 +282,7 @@ public function generateManifestForCollection(CollectionInterface $collection): */ public function getDeliveryDates( string $serviceCode, + string $carrierCode, AddressInterface $address, DatetimeInterface $startDate, DatetimeInterface $endDate, diff --git a/tests/Feature/MyParcelComApi/DeliveryDatesTest.php b/tests/Feature/MyParcelComApi/DeliveryDatesTest.php index 27f3367..3e3789e 100644 --- a/tests/Feature/MyParcelComApi/DeliveryDatesTest.php +++ b/tests/Feature/MyParcelComApi/DeliveryDatesTest.php @@ -24,6 +24,7 @@ public function testItRetrievesDeliveryDates(): void $deliveryDates = $this->api->getDeliveryDates( 'service-code', + 'carrier-code', $address, new DateTime(), new DateTime(), From cea627e791fca29a8edbd6fff3a5ddedae877d2a Mon Sep 17 00:00:00 2001 From: zwaans <83594488+zwaans@users.noreply.github.com> Date: Fri, 25 Apr 2025 11:18:16 +0200 Subject: [PATCH 2/3] Update src/MyParcelComApi.php Co-authored-by: Martin Boer --- src/MyParcelComApi.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/MyParcelComApi.php b/src/MyParcelComApi.php index c671bb2..55372e2 100644 --- a/src/MyParcelComApi.php +++ b/src/MyParcelComApi.php @@ -1001,8 +1001,8 @@ public function deleteShipmentSurcharge(ShipmentSurchargeInterface $shipmentSurc * @throws DateMalformedStringException */ public function getDeliveryDates( - string $serviceCode, string $carrierCode, + string $serviceCode, AddressInterface $address, DatetimeInterface $startDate, DatetimeInterface $endDate, From cf6089174a4ad2a4eb5a163c84b1f3907ccc71fa Mon Sep 17 00:00:00 2001 From: Martin Boer Date: Fri, 25 Apr 2025 14:15:54 +0200 Subject: [PATCH 3/3] Make carrier_code the first parameter of getDeliveryDates() --- src/MyParcelComApi.php | 2 +- src/MyParcelComApiInterface.php | 4 ++-- tests/Feature/MyParcelComApi/DeliveryDatesTest.php | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/MyParcelComApi.php b/src/MyParcelComApi.php index 55372e2..df169ec 100644 --- a/src/MyParcelComApi.php +++ b/src/MyParcelComApi.php @@ -1013,8 +1013,8 @@ public function getDeliveryDates( self::PATH_DELIVERY_DATES, 'post', [ - 'service_code' => $serviceCode, 'carrier_code' => $carrierCode, + 'service_code' => $serviceCode, 'service_option_codes' => $serviceOptionCodes, 'address' => [ 'country_code' => $address->getCountryCode(), diff --git a/src/MyParcelComApiInterface.php b/src/MyParcelComApiInterface.php index efa88d8..a48b50b 100644 --- a/src/MyParcelComApiInterface.php +++ b/src/MyParcelComApiInterface.php @@ -265,8 +265,8 @@ public function generateManifestForCollection(CollectionInterface $collection): * Get delivery date time windows from a carrier for the provided service. * Accepts an optional array of `delivery-window` service option codes * - * @param string $serviceCode * @param string $carrierCode + * @param string $serviceCode * @param AddressInterface $address * @param DateTimeInterface $startDate * @param DateTimeInterface $endDate @@ -281,8 +281,8 @@ public function generateManifestForCollection(CollectionInterface $collection): * @throws DateMalformedStringException */ public function getDeliveryDates( - string $serviceCode, string $carrierCode, + string $serviceCode, AddressInterface $address, DatetimeInterface $startDate, DatetimeInterface $endDate, diff --git a/tests/Feature/MyParcelComApi/DeliveryDatesTest.php b/tests/Feature/MyParcelComApi/DeliveryDatesTest.php index 3e3789e..5ff6ba3 100644 --- a/tests/Feature/MyParcelComApi/DeliveryDatesTest.php +++ b/tests/Feature/MyParcelComApi/DeliveryDatesTest.php @@ -23,8 +23,8 @@ public function testItRetrievesDeliveryDates(): void ->setStreetNumber(221); $deliveryDates = $this->api->getDeliveryDates( - 'service-code', 'carrier-code', + 'service-code', $address, new DateTime(), new DateTime(),