Skip to content
This repository was archived by the owner on Jan 28, 2019. It is now read-only.

Commit a4559c8

Browse files
committed
add conversationsList
1 parent b6b8364 commit a4559c8

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

Sources/Endpoint.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public enum Endpoint: String {
3737
case chatPostMessage = "chat.postMessage"
3838
case chatMeMessage = "chat.meMessage"
3939
case chatUpdate = "chat.update"
40+
case conversationsList = "conversations.list"
4041
case dndInfo = "dnd.info"
4142
case dndTeamInfo = "dnd.teamInfo"
4243
case emojiList = "emoji.list"

Sources/WebAPI.swift

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1097,6 +1097,34 @@ extension WebAPI {
10971097
}
10981098
}
10991099

1100+
// MARK: - Conversations
1101+
extension WebAPI {
1102+
public func conversationsList(
1103+
excludeArchived: Bool = false,
1104+
cursor: String? = nil,
1105+
limit: Int? = nil,
1106+
types: [String]? = nil,
1107+
success: ((_ channels: [[String: Any]]?) -> Void)?,
1108+
failure: FailureClosure?
1109+
) {
1110+
var parameters: [String: Any] = ["token": token, "exclude_archived": excludeArchived]
1111+
if let cursor = cursor {
1112+
parameters["cursor"] = cursor
1113+
}
1114+
if let limit = limit {
1115+
parameters["limit"] = limit
1116+
}
1117+
if let types = types {
1118+
parameters["types"] = types.joined(separator: ",")
1119+
}
1120+
networkInterface.request(.conversationsList, parameters: parameters, successClosure: {(response) in
1121+
success?(response["channels"] as? [[String: Any]])
1122+
}) {(error) in
1123+
failure?(error)
1124+
}
1125+
}
1126+
}
1127+
11001128
// MARK: - Utilities
11011129
extension WebAPI {
11021130
fileprivate func encodeAttachments(_ attachments: [Attachment?]?) -> String? {

0 commit comments

Comments
 (0)