Skip to content
This repository has been archived by the owner on Dec 2, 2022. It is now read-only.

Add pagination support to "users.list" #182

Merged
merged 4 commits into from
May 6, 2020
Merged
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
17 changes: 14 additions & 3 deletions SKWebAPI/Sources/WebAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1156,10 +1156,21 @@ extension WebAPI {
}
}

public func usersList(includePresence: Bool = false, success: ((_ userList: [[String: Any]]?) -> Void)?, failure: FailureClosure?) {
let parameters: [String: Any] = ["token": token, "presence": includePresence]
public func usersList(cursor: String? = nil,
limit: Int? = nil,
includePresence: Bool = false,
success: ((_ userList: [[String: Any]]?, _ nextCursor: String?) -> Void)?,
failure: FailureClosure?) {
var parameters: [String: Any] = ["token": token, "presence": includePresence]
if let cursor = cursor {
parameters["cursor"] = cursor
}
if let limit = limit {
parameters["limit"] = limit
}

networkInterface.request(.usersList, parameters: parameters, successClosure: {(response) in
success?(response["members"] as? [[String: Any]])
success?(response["members"] as? [[String: Any]], (response["response_metadata"] as? [String: Any])?["next_cursor"] as? String)
}) {(error) in
failure?(error)
}
Expand Down