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

Commit

Permalink
Add pagination support to "users.list" (#182)
Browse files Browse the repository at this point in the history
* #171 Have each parameter on a dedicated line

This makes it easier to add new ones without exceeding a
readable line length.

* #171 Add optional parameter `cursor` to "users.list"

* #171 Read `next_cursor` from "users.list" response

This allows callers to properly use the pagination of this API method.

* #171 Add support for "limit" parameter of users.list call
  • Loading branch information
wtimme authored May 6, 2020
1 parent 94e6293 commit 7cb2dbb
Showing 1 changed file with 14 additions and 3 deletions.
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

0 comments on commit 7cb2dbb

Please sign in to comment.