Skip to content

Commit 69ef11f

Browse files
committed
Use minimal get requests to get through jetpack
1 parent 323cbe4 commit 69ef11f

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

Modules/Sources/Networking/Remote/POSCatalogSyncRemote.swift

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,12 +195,18 @@ public class POSCatalogSyncRemote: Remote, POSCatalogSyncRemoteProtocol {
195195
/// - Returns: Total number of products.
196196
public func getProductCount(siteID: Int64) async throws -> Int {
197197
let path = Path.products
198+
let parameters = [
199+
ParameterKey.page: String(1),
200+
ParameterKey.perPage: String(1),
201+
ParameterKey.fields: POSProductVariation.requestFields.first ?? ""
202+
]
198203

199204
let request = JetpackRequest(
200205
wooApiVersion: .mark3,
201-
method: .head,
206+
method: .get,
202207
siteID: siteID,
203208
path: path,
209+
parameters: parameters,
204210
availableAsRESTRequest: true
205211
)
206212
let responseHeaders = try await enqueueWithResponseHeaders(request)
@@ -214,12 +220,18 @@ public class POSCatalogSyncRemote: Remote, POSCatalogSyncRemoteProtocol {
214220
/// - Returns: Total number of variations.
215221
public func getProductVariationCount(siteID: Int64) async throws -> Int {
216222
let path = Path.variations
223+
let parameters = [
224+
ParameterKey.page: String(1),
225+
ParameterKey.perPage: String(1),
226+
ParameterKey.fields: POSProductVariation.requestFields.first ?? ""
227+
]
217228

218229
let request = JetpackRequest(
219230
wooApiVersion: .wcAnalytics,
220-
method: .head,
231+
method: .get,
221232
siteID: siteID,
222233
path: path,
234+
parameters: parameters,
223235
availableAsRESTRequest: true
224236
)
225237
let responseHeaders = try await enqueueWithResponseHeaders(request)

0 commit comments

Comments
 (0)