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 }