Skip to content

Commit 0e94e0f

Browse files
authored
Shipping Labels: Fix issue mapping shipments after updating for REST API response (#16078)
2 parents e062618 + 375c97a commit 0e94e0f

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

Modules/Sources/Networking/Mapper/WooShippingUpdateShipmentMapper.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ struct WooShippingUpdateShipmentMapper: Mapper {
77
///
88
func map(response: Data) throws -> WooShippingShipments {
99
let decoder = JSONDecoder()
10-
if hasDataEnvelope(in: response) {
10+
do {
1111
return try decoder.decode(WooShippingUpdateShipmentResponseEnvelope.self, from: response).data.shipments
12-
} else {
12+
} catch {
1313
return try decoder.decode(WooShippingUpdateShipmentResponse.self, from: response).shipments
1414
}
1515
}

Modules/Tests/NetworkingTests/Mapper/WooShippingUpdateShipmentMapperTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ final class WooShippingUpdateShipmentMapperTests: XCTestCase {
2020
}
2121

2222
func test_shipments_are_properly_parsed_when_response_has_no_data_envelope() throws {
23-
guard let shipments = mapLoadShippingLabelConfig() else {
23+
guard let shipments = mapLoadShippingLabelConfigWithoutDataEnvelope() else {
2424
XCTFail()
2525
return
2626
}

0 commit comments

Comments
 (0)