Skip to content

Commit

Permalink
Dav pagination (#111)
Browse files Browse the repository at this point in the history
* add paginate

Signed-off-by: Marino Faggiana <[email protected]>

* StandardHeaders

Signed-off-by: Marino Faggiana <[email protected]>

* code

Signed-off-by: Marino Faggiana <[email protected]>

* fix

Signed-off-by: Marino Faggiana <[email protected]>

---------

Signed-off-by: Marino Faggiana <[email protected]>
  • Loading branch information
marinofaggiana authored Dec 5, 2024
1 parent 4e0a7fa commit c754b59
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
15 changes: 15 additions & 0 deletions Sources/NextcloudKit/NKCommon.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
12 changes: 12 additions & 0 deletions Sources/NextcloudKit/NKRequestOptions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand All @@ -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
}
}

0 comments on commit c754b59

Please sign in to comment.