Skip to content

Commit 07ea92a

Browse files
authored
[Shipping Labels] Custom package weight sometimes as box_weight sometimes as boxWeight (#14726)
2 parents 6e7497d + 0d938e1 commit 07ea92a

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

Networking/Networking/Model/ShippingLabel/Packages/Custom package/WooShippingCustomPackage.swift

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,21 @@ extension WooShippingCustomPackage: Codable {
6767

6868
var boxWeight: Double = 0.0
6969
// Looks like some endpoints have boxWeight as String and some as Double
70+
// and some endpoints have it as box_weight and some as boxWeight
7071
if let boxWeightDouble = try? container.decodeIfPresent(Double.self, forKey: .boxWeight) {
7172
boxWeight = boxWeightDouble
7273
}
7374
else if let boxWeightString = try? container.decodeIfPresent(String.self, forKey: .boxWeight),
7475
let boxWeightDouble = Double(boxWeightString) {
7576
boxWeight = boxWeightDouble
7677
}
78+
else if let boxWeightDouble = try? container.decodeIfPresent(Double.self, forKey: .boxWeightAlternate) {
79+
boxWeight = boxWeightDouble
80+
}
81+
else if let boxWeightString = try? container.decodeIfPresent(String.self, forKey: .boxWeightAlternate),
82+
let boxWeightDouble = Double(boxWeightString) {
83+
boxWeight = boxWeightDouble
84+
}
7785

7886
self.init(id: id, name: name, rawType: type, dimensions: dimensions, boxWeight: boxWeight)
7987
}
@@ -92,6 +100,7 @@ extension WooShippingCustomPackage: Codable {
92100
case name
93101
case type
94102
case dimensions
95-
case boxWeight = "box_weight"
103+
case boxWeight
104+
case boxWeightAlternate = "box_weight"
96105
}
97106
}

0 commit comments

Comments
 (0)