From ab276de93248676366de18e9009ff756b2cb9ee3 Mon Sep 17 00:00:00 2001 From: Mohamed ELIDRISSI <67818913+elidrissidev@users.noreply.github.com> Date: Tue, 8 Jul 2025 11:59:55 +0100 Subject: [PATCH] Make NegotiatedRateCharges field nullable Closes #35 --- openapi.yaml | 1 + openapi/Rating.yaml | 1 + src/Api/Model/RateResponseRatedShipment.php | 10 +++++----- .../Normalizer/RateResponseRatedShipmentNormalizer.php | 10 ++++++++-- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/openapi.yaml b/openapi.yaml index 00438097..d46325bc 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -20262,6 +20262,7 @@ components: TotalChargesWithTaxes: $ref: '#/components/schemas/NegotiatedRateCharges_TotalChargesWithTaxes' description: 'Negotiated Rate Charges Container. For tiered rates and promotional discounts, if a particular shipment based on zone, origin, destination or even shipment size doesn''t qualify for the existing discount then no negotiated rates container will be returned. Published rates will be the applicable rate.' + nullable: true xml: name: NegotiatedRateCharges NegotiatedRateCharges_ItemizedCharges: diff --git a/openapi/Rating.yaml b/openapi/Rating.yaml index a1767cd3..eb4601d6 100644 --- a/openapi/Rating.yaml +++ b/openapi/Rating.yaml @@ -5012,6 +5012,7 @@ components: even shipment size doesn't qualify for the existing discount then no negotiated rates container will be returned. Published rates will be the applicable rate. maximum: 1 + nullable: true NegotiatedRateCharges_ItemizedCharges: type: object required: diff --git a/src/Api/Model/RateResponseRatedShipment.php b/src/Api/Model/RateResponseRatedShipment.php index d467d376..cfdbc56d 100644 --- a/src/Api/Model/RateResponseRatedShipment.php +++ b/src/Api/Model/RateResponseRatedShipment.php @@ -126,7 +126,7 @@ public function isInitialized($property): bool /** * Negotiated Rate Charges Container. For tiered rates and promotional discounts, if a particular shipment based on zone, origin, destination or even shipment size doesn't qualify for the existing discount then no negotiated rates container will be returned. Published rates will be the applicable rate. * - * @var RatedShipmentNegotiatedRateCharges + * @var RatedShipmentNegotiatedRateCharges|null */ protected $negotiatedRateCharges; /** @@ -529,20 +529,20 @@ public function setTotalChargesWithTaxes(RatedShipmentTotalChargesWithTaxes $tot /** * Negotiated Rate Charges Container. For tiered rates and promotional discounts, if a particular shipment based on zone, origin, destination or even shipment size doesn't qualify for the existing discount then no negotiated rates container will be returned. Published rates will be the applicable rate. * - * @return RatedShipmentNegotiatedRateCharges + * @return RatedShipmentNegotiatedRateCharges|null */ - public function getNegotiatedRateCharges(): RatedShipmentNegotiatedRateCharges + public function getNegotiatedRateCharges(): ?RatedShipmentNegotiatedRateCharges { return $this->negotiatedRateCharges; } /** * Negotiated Rate Charges Container. For tiered rates and promotional discounts, if a particular shipment based on zone, origin, destination or even shipment size doesn't qualify for the existing discount then no negotiated rates container will be returned. Published rates will be the applicable rate. * - * @param RatedShipmentNegotiatedRateCharges $negotiatedRateCharges + * @param RatedShipmentNegotiatedRateCharges|null $negotiatedRateCharges * * @return self */ - public function setNegotiatedRateCharges(RatedShipmentNegotiatedRateCharges $negotiatedRateCharges): self + public function setNegotiatedRateCharges(?RatedShipmentNegotiatedRateCharges $negotiatedRateCharges): self { $this->initialized['negotiatedRateCharges'] = true; $this->negotiatedRateCharges = $negotiatedRateCharges; diff --git a/src/Api/Normalizer/RateResponseRatedShipmentNormalizer.php b/src/Api/Normalizer/RateResponseRatedShipmentNormalizer.php index e79b26d6..045f57c6 100644 --- a/src/Api/Normalizer/RateResponseRatedShipmentNormalizer.php +++ b/src/Api/Normalizer/RateResponseRatedShipmentNormalizer.php @@ -116,10 +116,13 @@ public function denormalize(mixed $data, string $type, string $format = null, ar $object->setTotalChargesWithTaxes($this->denormalizer->denormalize($data['TotalChargesWithTaxes'], \ShipStream\Ups\Api\Model\RatedShipmentTotalChargesWithTaxes::class, 'json', $context)); unset($data['TotalChargesWithTaxes']); } - if (\array_key_exists('NegotiatedRateCharges', $data)) { + if (\array_key_exists('NegotiatedRateCharges', $data) && $data['NegotiatedRateCharges'] !== null) { $object->setNegotiatedRateCharges($this->denormalizer->denormalize($data['NegotiatedRateCharges'], \ShipStream\Ups\Api\Model\RatedShipmentNegotiatedRateCharges::class, 'json', $context)); unset($data['NegotiatedRateCharges']); } + elseif (\array_key_exists('NegotiatedRateCharges', $data) && $data['NegotiatedRateCharges'] === null) { + $object->setNegotiatedRateCharges(null); + } if (\array_key_exists('RatedPackage', $data)) { $values_4 = []; foreach ($data['RatedPackage'] as $value_4) { @@ -336,10 +339,13 @@ public function denormalize($data, $type, $format = null, array $context = []) $object->setTotalChargesWithTaxes($this->denormalizer->denormalize($data['TotalChargesWithTaxes'], \ShipStream\Ups\Api\Model\RatedShipmentTotalChargesWithTaxes::class, 'json', $context)); unset($data['TotalChargesWithTaxes']); } - if (\array_key_exists('NegotiatedRateCharges', $data)) { + if (\array_key_exists('NegotiatedRateCharges', $data) && $data['NegotiatedRateCharges'] !== null) { $object->setNegotiatedRateCharges($this->denormalizer->denormalize($data['NegotiatedRateCharges'], \ShipStream\Ups\Api\Model\RatedShipmentNegotiatedRateCharges::class, 'json', $context)); unset($data['NegotiatedRateCharges']); } + elseif (\array_key_exists('NegotiatedRateCharges', $data) && $data['NegotiatedRateCharges'] === null) { + $object->setNegotiatedRateCharges(null); + } if (\array_key_exists('RatedPackage', $data)) { $values_4 = []; foreach ($data['RatedPackage'] as $value_4) {