Skip to content

Commit 178b11f

Browse files
authored
Merge branch 'task/fix-receipt-eligibility-analytics-test' into task/update-gems-to-report-swifttesting-failures
2 parents a48f878 + 8990b01 commit 178b11f

File tree

86 files changed

+1832
-557
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+1832
-557
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
<!--
22
Contains editorialized release notes. Raw release notes should go into `RELEASE-NOTES.txt`.
33
-->
4+
## 23.2
5+
This update smooths your WooCommerce experience with improved cash payments, easier access to POS settings, and accurate HAZMAT details on shipping labels. Plus, we fixed a Blaze flow issue so campaigns behave as expected. Faster, clearer, and more reliable — just how you need it!
6+
47
## 23.1
58
Managing your store just got smoother with a more reliable shipping label workflow! Jetpack setup has also been improved for a faster, easier connection. Update now and enjoy the improvements!
69

Modules/Sources/Fakes/NetworkingCore.generated.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,7 @@ extension NetworkingCore.OrderItem {
270270
totalTax: .fake(),
271271
attributes: .fake(),
272272
addOns: .fake(),
273+
image: .fake(),
273274
parent: .fake(),
274275
bundleConfiguration: .fake()
275276
)
@@ -455,7 +456,8 @@ extension NetworkingCore.ShippingLabel {
455456
productNames: .fake(),
456457
commercialInvoiceURL: .fake(),
457458
usedDate: .fake(),
458-
expiryDate: .fake()
459+
expiryDate: .fake(),
460+
hazmatCategory: .fake()
459461
)
460462
}
461463
}

Modules/Sources/Networking/Mapper/WooShippingConfigMapper.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ extension WooShippingConfigMapper {
4848
"config.shipments",
4949
"config.shippingLabelData.currentOrderLabels",
5050
"config.shippingLabelData.storedData.selected_destination",
51-
"config.shippingLabelData.storedData.selected_origin"
51+
"config.shippingLabelData.storedData.selected_origin",
52+
"config.shippingLabelData.storedData.selected_hazmat"
5253
].joined(separator: ", ")
5354
}

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/Sources/Networking/Model/Copiable/Models+Copiable.generated.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import Codegen
55
import Foundation
66
import WooFoundation
77
import struct Alamofire.JSONEncoding
8+
import struct NetworkingCore.JetpackSite
89

910

1011
extension Networking.AIProduct {

Modules/Sources/Networking/Model/ShippingLabel/Shipments/WooShippingConfigResponse.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,13 @@ public struct WooShippingLabelData: Decodable, Equatable {
111111

112112
let destinations = storedData?.selectedDestinations
113113
let origins = storedData?.selectedOrigins
114+
let hazmatSelections = storedData?.selectedHazmat
114115

115116
if destinations?.isEmpty == false || origins?.isEmpty == false {
116117
orderLabels = WooShippingLabelData.mapAddresses(
117118
origins: origins,
118119
destinations: destinations,
120+
hazmatSelections: hazmatSelections,
119121
into: decodedOrderLabels
120122
)
121123
} else {
@@ -136,14 +138,17 @@ public struct WooShippingLabelData: Decodable, Equatable {
136138

137139
public extension WooShippingLabelData {
138140
typealias WooShippingLabelAddressMap = [String: WooShippingAddress]
141+
typealias WooShippingHazmatMap = [String: HazmatSelection]
139142

140143
struct StoredData: Decodable, Equatable {
141144
let selectedDestinations: WooShippingLabelAddressMap?
142145
let selectedOrigins: WooShippingLabelAddressMap?
146+
let selectedHazmat: WooShippingHazmatMap?
143147

144148
public enum CodingKeys: String, CodingKey {
145149
case selectedDestination = "selected_destination"
146150
case selectedOrigin = "selected_origin"
151+
case selectedHazmat = "selected_hazmat"
147152
}
148153

149154
public init(from decoder: any Decoder) throws {
@@ -156,6 +161,7 @@ public extension WooShippingLabelData {
156161
WooShippingLabelAddressMap.self,
157162
forKey: CodingKeys.selectedOrigin
158163
)
164+
selectedHazmat = try? container.decodeIfPresent(WooShippingHazmatMap.self, forKey: .selectedHazmat)
159165
}
160166
}
161167
}
@@ -166,3 +172,7 @@ enum WooShippingConfigDecodingError: Error {
166172
case missingSiteID
167173
case missingOrderID
168174
}
175+
176+
public struct HazmatSelection: Decodable, Equatable {
177+
public let category: String
178+
}

Modules/Sources/Networking/Model/ShippingLabel/Shipments/WooShippingLabelData+mapDestinations.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ extension WooShippingLabelData {
44
static func mapAddresses(
55
origins: WooShippingLabelAddressMap?,
66
destinations: WooShippingLabelAddressMap?,
7+
hazmatSelections: WooShippingHazmatMap?,
78
into labels: [ShippingLabel]
89
) -> [ShippingLabel] {
910
return labels.map { label in
@@ -14,10 +15,12 @@ extension WooShippingLabelData {
1415
let formattedID = WooShippingShipmentIDFormatter.formattedShipmentID(shipmentID)
1516
let originAddress = origins?[formattedID] ?? origins?[shipmentID]
1617
let destinationAddress = destinations?[formattedID] ?? destinations?[shipmentID]
18+
let hazmat = hazmatSelections?[formattedID] ?? hazmatSelections?[shipmentID]
1719

1820
return label.copy(
1921
originAddress: originAddress?.toShippingLabelAddress() ?? .copy,
20-
destinationAddress: destinationAddress?.toShippingLabelAddress() ?? .copy
22+
destinationAddress: destinationAddress?.toShippingLabelAddress() ?? .copy,
23+
hazmatCategory: hazmat?.category
2124
)
2225
}
2326
}

Modules/Sources/NetworkingCore/Model/Copiable/Models+Copiable.generated.swift

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,7 @@ extension NetworkingCore.OrderItem {
444444
totalTax: CopiableProp<String> = .copy,
445445
attributes: CopiableProp<[OrderItemAttribute]> = .copy,
446446
addOns: CopiableProp<[OrderItemProductAddOn]> = .copy,
447+
image: NullableCopiableProp<OrderItemProductImage> = .copy,
447448
parent: NullableCopiableProp<Int64> = .copy,
448449
bundleConfiguration: CopiableProp<[OrderItemBundleItem]> = .copy
449450
) -> NetworkingCore.OrderItem {
@@ -462,6 +463,7 @@ extension NetworkingCore.OrderItem {
462463
let totalTax = totalTax ?? self.totalTax
463464
let attributes = attributes ?? self.attributes
464465
let addOns = addOns ?? self.addOns
466+
let image = image ?? self.image
465467
let parent = parent ?? self.parent
466468
let bundleConfiguration = bundleConfiguration ?? self.bundleConfiguration
467469

@@ -481,6 +483,7 @@ extension NetworkingCore.OrderItem {
481483
totalTax: totalTax,
482484
attributes: attributes,
483485
addOns: addOns,
486+
image: image,
484487
parent: parent,
485488
bundleConfiguration: bundleConfiguration
486489
)
@@ -713,7 +716,8 @@ extension NetworkingCore.ShippingLabel {
713716
productNames: CopiableProp<[String]> = .copy,
714717
commercialInvoiceURL: NullableCopiableProp<String> = .copy,
715718
usedDate: NullableCopiableProp<Date> = .copy,
716-
expiryDate: NullableCopiableProp<Date> = .copy
719+
expiryDate: NullableCopiableProp<Date> = .copy,
720+
hazmatCategory: NullableCopiableProp<String> = .copy
717721
) -> NetworkingCore.ShippingLabel {
718722
let siteID = siteID ?? self.siteID
719723
let orderID = orderID ?? self.orderID
@@ -736,6 +740,7 @@ extension NetworkingCore.ShippingLabel {
736740
let commercialInvoiceURL = commercialInvoiceURL ?? self.commercialInvoiceURL
737741
let usedDate = usedDate ?? self.usedDate
738742
let expiryDate = expiryDate ?? self.expiryDate
743+
let hazmatCategory = hazmatCategory ?? self.hazmatCategory
739744

740745
return NetworkingCore.ShippingLabel(
741746
siteID: siteID,
@@ -758,7 +763,8 @@ extension NetworkingCore.ShippingLabel {
758763
productNames: productNames,
759764
commercialInvoiceURL: commercialInvoiceURL,
760765
usedDate: usedDate,
761-
expiryDate: expiryDate
766+
expiryDate: expiryDate,
767+
hazmatCategory: hazmatCategory
762768
)
763769
}
764770
}

Modules/Sources/NetworkingCore/Model/OrderItem.swift

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ public struct OrderItem: Codable, Equatable, Hashable, Sendable, GeneratedFakeab
3030

3131
public let addOns: [OrderItemProductAddOn]
3232

33+
public let image: OrderItemProductImage?
34+
3335
/// Item ID of parent `OrderItem`, if any.
3436
///
3537
/// An `OrderItem` can have a parent if, for example, it is a bundled item within a product bundle.
@@ -58,6 +60,7 @@ public struct OrderItem: Codable, Equatable, Hashable, Sendable, GeneratedFakeab
5860
totalTax: String,
5961
attributes: [OrderItemAttribute],
6062
addOns: [OrderItemProductAddOn],
63+
image: OrderItemProductImage?,
6164
parent: Int64?,
6265
bundleConfiguration: [OrderItemBundleItem]) {
6366
self.itemID = itemID
@@ -75,6 +78,7 @@ public struct OrderItem: Codable, Equatable, Hashable, Sendable, GeneratedFakeab
7578
self.totalTax = totalTax
7679
self.attributes = attributes
7780
self.addOns = addOns
81+
self.image = image
7882
self.parent = parent
7983
self.bundleConfiguration = bundleConfiguration
8084
}
@@ -123,6 +127,9 @@ public struct OrderItem: Codable, Equatable, Hashable, Sendable, GeneratedFakeab
123127
forKey: .attributes)
124128
.first(where: { $0.key == "_pao_ids" })?.value ?? []
125129

130+
// Order item product image
131+
let image = try container.decodeIfPresent(OrderItemProductImage.self, forKey: .image)
132+
126133
// Product Bundle extension properties:
127134
// If the order item is part of a product bundle, `bundledBy` is the parent order item (product bundle).
128135
// If it's not a bundled item, the API returns an empty string for `bundledBy` and the value will be `nil`.
@@ -149,6 +156,7 @@ public struct OrderItem: Codable, Equatable, Hashable, Sendable, GeneratedFakeab
149156
totalTax: totalTax,
150157
attributes: attributes,
151158
addOns: productAddOns,
159+
image: image,
152160
parent: bundledBy ?? compositeParent,
153161
bundleConfiguration: [])
154162
}
@@ -174,6 +182,10 @@ public struct OrderItem: Codable, Equatable, Hashable, Sendable, GeneratedFakeab
174182
try container.encode(total, forKey: .total)
175183
}
176184

185+
if let image = image {
186+
try container.encode(image, forKey: .image)
187+
}
188+
177189
if !bundleConfiguration.isEmpty {
178190
try container.encode(bundleConfiguration, forKey: .bundleConfiguration)
179191
}
@@ -204,6 +216,7 @@ extension OrderItem {
204216
case bundledBy = "bundled_by"
205217
case compositeParent = "composite_parent"
206218
case bundleConfiguration = "bundle_configuration"
219+
case image
207220
}
208221
}
209222

@@ -222,3 +235,24 @@ private struct OrderItemProductAddOnContainer: Decodable {
222235
let key: String
223236
let value: [OrderItemProductAddOn]
224237
}
238+
239+
240+
// MARK: - Order Item Product Image
241+
//
242+
public struct OrderItemProductImage: Codable, Equatable, Hashable, Sendable {
243+
public let src: String?
244+
245+
public init(from decoder: Decoder) throws {
246+
let container = try decoder.container(keyedBy: CodingKeys.self)
247+
self.src = try? container.decodeIfPresent(String.self, forKey: .src)
248+
}
249+
250+
public func encode(to encoder: Encoder) throws {
251+
var container = encoder.container(keyedBy: CodingKeys.self)
252+
try container.encodeIfPresent(src, forKey: .src)
253+
}
254+
255+
private enum CodingKeys: String, CodingKey {
256+
case src
257+
}
258+
}

Modules/Sources/NetworkingCore/Model/ShippingLabel/ShippingLabel.swift

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ public struct ShippingLabel: Equatable, Sendable, GeneratedCopiable, GeneratedFa
7171
/// Expiry date of the label
7272
public let expiryDate: Date?
7373

74+
/// Selected HAZMAT category of the label
75+
public let hazmatCategory: String?
76+
7477
public init(siteID: Int64,
7578
orderID: Int64,
7679
shippingLabelID: Int64,
@@ -91,7 +94,8 @@ public struct ShippingLabel: Equatable, Sendable, GeneratedCopiable, GeneratedFa
9194
productNames: [String],
9295
commercialInvoiceURL: String?,
9396
usedDate: Date?,
94-
expiryDate: Date?) {
97+
expiryDate: Date?,
98+
hazmatCategory: String?) {
9599
self.siteID = siteID
96100
self.orderID = orderID
97101
self.shippingLabelID = shippingLabelID
@@ -113,6 +117,7 @@ public struct ShippingLabel: Equatable, Sendable, GeneratedCopiable, GeneratedFa
113117
self.commercialInvoiceURL = commercialInvoiceURL
114118
self.usedDate = usedDate
115119
self.expiryDate = expiryDate
120+
self.hazmatCategory = hazmatCategory
116121
}
117122
}
118123

@@ -177,7 +182,8 @@ extension ShippingLabel: Decodable {
177182
productNames: productNames,
178183
commercialInvoiceURL: commercialInvoiceURL,
179184
usedDate: usedDate,
180-
expiryDate: expiryDate)
185+
expiryDate: expiryDate,
186+
hazmatCategory: nil) // hazmat category is not available in label details, will be updated later
181187
}
182188

183189
private enum CodingKeys: String, CodingKey {

0 commit comments

Comments
 (0)