From 312cdfa89cfcd31119807e3cdd296740425862b0 Mon Sep 17 00:00:00 2001 From: Martin Boer Date: Mon, 9 Dec 2024 15:36:58 +0100 Subject: [PATCH] :bug: actually send the colli meta to the rates endpoint when a shipment contains colli --- src/MyParcelComApi.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/MyParcelComApi.php b/src/MyParcelComApi.php index 384d71c..98e92e4 100644 --- a/src/MyParcelComApi.php +++ b/src/MyParcelComApi.php @@ -413,7 +413,17 @@ public function resolveDynamicServiceRates( ]; } - $response = $this->doRequest('/get-dynamic-service-rates', 'post', ['data' => $data], [ + $body = array_filter([ + 'data' => $data, + 'meta' => array_filter([ + 'colli' => array_map( + fn (ShipmentInterface $collo) => $collo->jsonSerialize()['attributes'] ?? null, + $shipmentData?->getColli() ?? [], + ), + ]), + ]); + + $response = $this->doRequest('/get-dynamic-service-rates', 'post', $body, [ AuthenticatorInterface::HEADER_ACCEPT => AuthenticatorInterface::MIME_TYPE_JSON, ]); $json = json_decode((string) $response->getBody(), true);