@@ -53,6 +53,10 @@ public final class WebAPI {
5353 case channel, group, im
5454 }
5555
56+ public enum ConversationType : String {
57+ case public_channel, private_channel, mpim, im
58+ }
59+
5660 fileprivate let networkInterface : NetworkInterface
5761 fileprivate let token : String
5862
@@ -1097,6 +1101,34 @@ extension WebAPI {
10971101 }
10981102}
10991103
1104+ // MARK: - Conversations
1105+ extension WebAPI {
1106+ public func conversationsList(
1107+ excludeArchived: Bool = false ,
1108+ cursor: String ? = nil ,
1109+ limit: Int ? = nil ,
1110+ types: [ ConversationType ] ? = nil ,
1111+ success: ( ( _ channels: [ [ String : Any ] ] ? , _ nextCursor: String ? ) -> Void ) ? ,
1112+ failure: FailureClosure ?
1113+ ) {
1114+ var parameters : [ String : Any ] = [ " token " : token, " exclude_archived " : excludeArchived]
1115+ if let cursor = cursor {
1116+ parameters [ " cursor " ] = cursor
1117+ }
1118+ if let limit = limit {
1119+ parameters [ " limit " ] = limit
1120+ }
1121+ if let types = types {
1122+ parameters [ " types " ] = types. map ( { $0. rawValue } ) . joined ( separator: " , " )
1123+ }
1124+ networkInterface. request ( . conversationsList, parameters: parameters, successClosure: { ( response) in
1125+ success ? ( response [ " channels " ] as? [ [ String : Any ] ] , ( response [ " response_metadata " ] as? [ String : Any ] ) ? [ " next_cursor " ] as? String )
1126+ } ) { ( error) in
1127+ failure ? ( error)
1128+ }
1129+ }
1130+ }
1131+
11001132// MARK: - Utilities
11011133extension WebAPI {
11021134 fileprivate func encodeAttachments( _ attachments: [ Attachment ? ] ? ) -> String ? {
0 commit comments