@@ -30,34 +30,39 @@ public protocol POSCatalogSyncRemoteProtocol {
3030 /// - Parameters:
3131 /// - siteID: Site ID to generate catalog for.
3232 /// - forceGeneration: Whether to always generate a catalog.
33+ /// - allowCellular: Should cellular data be used if required.
3334 /// - Returns: Catalog job response with job ID.
3435 ///
3536 // periphery:ignore - TODO - remove this periphery ignore comment when this endpoint is integrated with catalog sync
36- func requestCatalogGeneration( for siteID: Int64 , forceGeneration: Bool ) async throws -> POSCatalogRequestResponse
37+ func requestCatalogGeneration( for siteID: Int64 , forceGeneration: Bool , allowCellular : Bool ) async throws -> POSCatalogRequestResponse
3738
3839 /// Downloads the generated catalog at the specified download URL.
3940 /// - Parameters:
4041 /// - siteID: Site ID to download catalog for.
4142 /// - downloadURL: Download URL of the catalog file.
43+ /// - allowCellular: Should cellular data be used if required.
4244 /// - Returns: List of products and variations in the POS catalog.
43- // periphery:ignore - TODO - remove this periphery ignore comment when this endpoint is integrated with catalog sync
44- func downloadCatalog( for siteID: Int64 , downloadURL: String ) async throws -> POSCatalogResponse
45+ func downloadCatalog( for siteID: Int64 ,
46+ downloadURL: String ,
47+ allowCellular: Bool ) async throws -> POSCatalogResponse
4548
4649 /// Loads POS products for full sync.
4750 ///
4851 /// - Parameters:
4952 /// - siteID: Site ID to load products from.
5053 /// - pageNumber: Page number for pagination.
54+ /// - allowCellular: Should cellular data be used if required.
5155 /// - Returns: Paginated list of POS products.
52- func loadProducts( siteID: Int64 , pageNumber: Int ) async throws -> PagedItems < POSProduct >
56+ func loadProducts( siteID: Int64 , pageNumber: Int , allowCellular : Bool ) async throws -> PagedItems < POSProduct >
5357
5458 /// Loads POS product variations for full sync.
5559 ///
5660 /// - Parameters:
5761 /// - siteID: Site ID to load variations from.
5862 /// - pageNumber: Page number for pagination.
63+ /// - allowCellular: Should cellular data be used if required.
5964 /// - Returns: Paginated list of POS product variations.
60- func loadProductVariations( siteID: Int64 , pageNumber: Int ) async throws -> PagedItems < POSProductVariation >
65+ func loadProductVariations( siteID: Int64 , pageNumber: Int , allowCellular : Bool ) async throws -> PagedItems < POSProductVariation >
6166
6267 /// Gets the total count of products for the specified site.
6368 ///
@@ -87,7 +92,6 @@ public class POSCatalogSyncRemote: Remote, POSCatalogSyncRemoteProtocol {
8792 /// - pageNumber: Page number for pagination.
8893 /// - Returns: Paginated list of POS products.
8994 ///
90- // periphery:ignore - TODO - remove this periphery ignore comment when this endpoint is integrated with catalog sync
9195 public func loadProducts( modifiedAfter: Date , siteID: Int64 , pageNumber: Int )
9296 async throws -> PagedItems < POSProduct > {
9397 let path = Path . products
@@ -120,7 +124,6 @@ public class POSCatalogSyncRemote: Remote, POSCatalogSyncRemoteProtocol {
120124 /// - pageNumber: Page number for pagination.
121125 /// - Returns: Paginated list of POS product variations.
122126 ///
123- // periphery:ignore - TODO - remove this periphery ignore comment when this endpoint is integrated with catalog sync
124127 public func loadProductVariations( modifiedAfter: Date , siteID: Int64 , pageNumber: Int ) async throws -> PagedItems < POSProductVariation > {
125128 let path = Path . variations
126129 let parameters = [
@@ -131,7 +134,7 @@ public class POSCatalogSyncRemote: Remote, POSCatalogSyncRemoteProtocol {
131134 ]
132135
133136 let request = JetpackRequest (
134- wooApiVersion: . wcAnalytics ,
137+ wooApiVersion: . mark3 ,
135138 method: . get,
136139 siteID: siteID,
137140 path: path,
@@ -151,10 +154,11 @@ public class POSCatalogSyncRemote: Remote, POSCatalogSyncRemoteProtocol {
151154 ///
152155 /// - Parameters:
153156 /// - siteID: Site ID to generate catalog for.
157+ /// - forceGeneration: Whether to always generate a catalog.
158+ /// - allowCellular: Should cellular data be used if required.
154159 /// - Returns: Catalog job response with job ID.
155160 ///
156- // periphery:ignore - TODO - remove this periphery ignore comment when this endpoint is integrated with catalog sync
157- public func requestCatalogGeneration( for siteID: Int64 , forceGeneration: Bool ) async throws -> POSCatalogRequestResponse {
161+ public func requestCatalogGeneration( for siteID: Int64 , forceGeneration: Bool , allowCellular: Bool ) async throws -> POSCatalogRequestResponse {
158162 let path = " products/catalog "
159163 let parameters : [ String : Any ] = [
160164 ParameterKey . fullSyncFields: POSProduct . requestFields,
@@ -166,7 +170,8 @@ public class POSCatalogSyncRemote: Remote, POSCatalogSyncRemoteProtocol {
166170 siteID: siteID,
167171 path: path,
168172 parameters: parameters,
169- availableAsRESTRequest: true
173+ availableAsRESTRequest: true ,
174+ allowsCellularAccess: allowCellular
170175 )
171176 let mapper = SingleItemMapper < POSCatalogRequestResponse > ( siteID: siteID)
172177 return try await enqueue ( request, mapper: mapper)
@@ -176,14 +181,17 @@ public class POSCatalogSyncRemote: Remote, POSCatalogSyncRemoteProtocol {
176181 /// - Parameters:
177182 /// - siteID: Site ID to download catalog for.
178183 /// - downloadURL: Download URL of the catalog file.
184+ /// - allowCellular: Should cellular data be used if required.
179185 /// - Returns: List of products and variations in the POS catalog.
180- // periphery:ignore - TODO - remove this periphery ignore comment when this endpoint is integrated with catalog sync
181- public func downloadCatalog( for siteID: Int64 , downloadURL: String ) async throws -> POSCatalogResponse {
186+ public func downloadCatalog( for siteID: Int64 ,
187+ downloadURL: String ,
188+ allowCellular: Bool ) async throws -> POSCatalogResponse {
182189 // TODO: WOOMOB-1173 - move download task to the background using `URLSessionConfiguration.background`
183190 guard let url = URL ( string: downloadURL) else {
184191 throw NetworkError . invalidURL
185192 }
186- let request = URLRequest ( url: url)
193+ var request = URLRequest ( url: url)
194+ request. allowsCellularAccess = allowCellular
187195 let mapper = ListMapper < POSProduct > ( siteID: siteID)
188196 let items = try await enqueue ( request, mapper: mapper)
189197 let variationProductTypeKey = " variation "
@@ -198,10 +206,10 @@ public class POSCatalogSyncRemote: Remote, POSCatalogSyncRemoteProtocol {
198206 /// - Parameters:
199207 /// - siteID: Site ID to load products from.
200208 /// - pageNumber: Page number for pagination.
209+ /// - allowCellular: Should cellular data be used if required.
201210 /// - Returns: Paginated list of POS products.
202211 ///
203- // periphery:ignore - TODO - remove this periphery ignore comment when this endpoint is integrated with catalog sync
204- public func loadProducts( siteID: Int64 , pageNumber: Int ) async throws -> PagedItems < POSProduct > {
212+ public func loadProducts( siteID: Int64 , pageNumber: Int , allowCellular: Bool ) async throws -> PagedItems < POSProduct > {
205213 let path = Path . products
206214 let parameters = [
207215 ParameterKey . page: String ( pageNumber) ,
@@ -215,7 +223,8 @@ public class POSCatalogSyncRemote: Remote, POSCatalogSyncRemoteProtocol {
215223 siteID: siteID,
216224 path: path,
217225 parameters: parameters,
218- availableAsRESTRequest: true
226+ availableAsRESTRequest: true ,
227+ allowsCellularAccess: allowCellular
219228 )
220229 let mapper = ListMapper < POSProduct > ( siteID: siteID)
221230 let ( products, responseHeaders) = try await enqueueWithResponseHeaders ( request, mapper: mapper)
@@ -228,10 +237,10 @@ public class POSCatalogSyncRemote: Remote, POSCatalogSyncRemoteProtocol {
228237 /// - Parameters:
229238 /// - siteID: Site ID to load variations from.
230239 /// - pageNumber: Page number for pagination.
240+ /// - allowCellular: Should cellular data be used if required.
231241 /// - Returns: Paginated list of POS product variations.
232242 ///
233- // periphery:ignore - TODO - remove this periphery ignore comment when this endpoint is integrated with catalog sync
234- public func loadProductVariations( siteID: Int64 , pageNumber: Int ) async throws -> PagedItems < POSProductVariation > {
243+ public func loadProductVariations( siteID: Int64 , pageNumber: Int , allowCellular: Bool ) async throws -> PagedItems < POSProductVariation > {
235244 let path = Path . variations
236245 let parameters = [
237246 ParameterKey . page: String ( pageNumber) ,
@@ -240,12 +249,13 @@ public class POSCatalogSyncRemote: Remote, POSCatalogSyncRemoteProtocol {
240249 ]
241250
242251 let request = JetpackRequest (
243- wooApiVersion: . wcAnalytics ,
252+ wooApiVersion: . mark3 ,
244253 method: . get,
245254 siteID: siteID,
246255 path: path,
247256 parameters: parameters,
248- availableAsRESTRequest: true
257+ availableAsRESTRequest: true ,
258+ allowsCellularAccess: allowCellular
249259 )
250260 let mapper = ListMapper < POSProductVariation > ( siteID: siteID)
251261 let ( variations, responseHeaders) = try await enqueueWithResponseHeaders ( request, mapper: mapper)
@@ -293,7 +303,7 @@ public class POSCatalogSyncRemote: Remote, POSCatalogSyncRemoteProtocol {
293303 ]
294304
295305 let request = JetpackRequest (
296- wooApiVersion: . wcAnalytics ,
306+ wooApiVersion: . mark3 ,
297307 method: . get,
298308 siteID: siteID,
299309 path: path,
@@ -331,7 +341,6 @@ private extension POSCatalogSyncRemote {
331341// MARK: - Response Models
332342
333343/// Response from catalog generation request.
334- // periphery:ignore - TODO - remove this periphery ignore comment when this endpoint is integrated with catalog sync
335344public struct POSCatalogRequestResponse : Decodable {
336345 /// Current status of the catalog generation job.
337346 public let status : POSCatalogStatus
@@ -353,7 +362,6 @@ public enum POSCatalogStatus: String, Decodable {
353362}
354363
355364/// POS catalog from download.
356- // periphery:ignore - TODO - remove this periphery ignore comment when this endpoint is integrated with catalog sync
357365public struct POSCatalogResponse {
358366 public let products : [ POSProduct ]
359367 public let variations : [ POSProductVariation ]
0 commit comments