From 375c97af7000108fae19ec94e655e978a3ba648b Mon Sep 17 00:00:00 2001 From: Huong Do Date: Thu, 4 Sep 2025 12:01:46 +0700 Subject: [PATCH] Fix issue mapping shipments after updating for REST API response --- .../Networking/Mapper/WooShippingUpdateShipmentMapper.swift | 4 ++-- .../Mapper/WooShippingUpdateShipmentMapperTests.swift | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Modules/Sources/Networking/Mapper/WooShippingUpdateShipmentMapper.swift b/Modules/Sources/Networking/Mapper/WooShippingUpdateShipmentMapper.swift index a30d3b2f921..f428903c33c 100644 --- a/Modules/Sources/Networking/Mapper/WooShippingUpdateShipmentMapper.swift +++ b/Modules/Sources/Networking/Mapper/WooShippingUpdateShipmentMapper.swift @@ -7,9 +7,9 @@ struct WooShippingUpdateShipmentMapper: Mapper { /// func map(response: Data) throws -> WooShippingShipments { let decoder = JSONDecoder() - if hasDataEnvelope(in: response) { + do { return try decoder.decode(WooShippingUpdateShipmentResponseEnvelope.self, from: response).data.shipments - } else { + } catch { return try decoder.decode(WooShippingUpdateShipmentResponse.self, from: response).shipments } } diff --git a/Modules/Tests/NetworkingTests/Mapper/WooShippingUpdateShipmentMapperTests.swift b/Modules/Tests/NetworkingTests/Mapper/WooShippingUpdateShipmentMapperTests.swift index 289683a117c..502f02361c4 100644 --- a/Modules/Tests/NetworkingTests/Mapper/WooShippingUpdateShipmentMapperTests.swift +++ b/Modules/Tests/NetworkingTests/Mapper/WooShippingUpdateShipmentMapperTests.swift @@ -20,7 +20,7 @@ final class WooShippingUpdateShipmentMapperTests: XCTestCase { } func test_shipments_are_properly_parsed_when_response_has_no_data_envelope() throws { - guard let shipments = mapLoadShippingLabelConfig() else { + guard let shipments = mapLoadShippingLabelConfigWithoutDataEnvelope() else { XCTFail() return }