Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dav pagination #111

Merged
merged 5 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions Sources/NextcloudKit/NKCommon.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import CoreServices
#endif

public protocol NextcloudKitDelegate {

Check warning on line 15 in Sources/NextcloudKit/NKCommon.swift

View workflow job for this annotation

GitHub Actions / Lint

Class Delegate Protocol Violation: Delegate protocols should be class-only so they can be weakly referenced (class_delegate_protocol)
func authenticationChallenge(_ session: URLSession, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void)
func urlSessionDidFinishEvents(forBackgroundURLSession session: URLSession)

Expand Down Expand Up @@ -411,6 +411,21 @@
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
}
}
Loading