diff --git a/Sources/NextcloudKit/NKCommon.swift b/Sources/NextcloudKit/NKCommon.swift index 2b0650f..87107a2 100644 --- a/Sources/NextcloudKit/NKCommon.swift +++ b/Sources/NextcloudKit/NKCommon.swift @@ -411,6 +411,21 @@ public class NKCommon: NSObject { for (key, value) in options?.customHeader ?? [:] { headers.update(name: key, value: value) } + // Paginate + if let options { + if options.paginate { + headers.update(name: "X-NC-Paginate", value: "true") + } + if let paginateCount = options.paginateCount { + headers.update(name: "X-NC-Paginate-Count", value: "\(paginateCount)") + } + if let paginateOffset = options.paginateOffset { + headers.update(name: "X-NC-Paginate-Offset", value: "\(paginateOffset)") + } + if let paginateToken = options.paginateToken { + headers.update(name: "X-NC-Paginate-Token", value: paginateToken) + } + } return headers } diff --git a/Sources/NextcloudKit/NKRequestOptions.swift b/Sources/NextcloudKit/NKRequestOptions.swift index e7bdeec..4b586a8 100644 --- a/Sources/NextcloudKit/NKRequestOptions.swift +++ b/Sources/NextcloudKit/NKRequestOptions.swift @@ -16,6 +16,10 @@ public class NKRequestOptions: NSObject { var taskDescription: String? var createProperties: [NKProperties]? var removeProperties: [NKProperties] + var paginate: Bool + var paginateToken: String? + var paginateOffset: Int? + var paginateCount: Int? var queue: DispatchQueue public init(endpoint: String? = nil, @@ -28,6 +32,10 @@ public class NKRequestOptions: NSObject { taskDescription: String? = nil, createProperties: [NKProperties]? = nil, removeProperties: [NKProperties] = [], + paginate: Bool = false, + paginateToken: String? = nil, + paginateOffset: Int? = nil, + paginateCount: Int? = nil, queue: DispatchQueue = .main) { self.endpoint = endpoint @@ -40,6 +48,10 @@ public class NKRequestOptions: NSObject { self.taskDescription = taskDescription self.createProperties = createProperties self.removeProperties = removeProperties + self.paginate = paginate + self.paginateToken = paginateToken + self.paginateOffset = paginateOffset + self.paginateCount = paginateCount self.queue = queue } }