@@ -195,6 +195,14 @@ extension WebAPI {
195195 }
196196 }
197197
198+ public func createChannel( channel: String , success: ChannelClosure ? , failure: FailureClosure ? ) {
199+ create ( . channelsCreate, name: channel, success: success, failure: failure)
200+ }
201+
202+ public func inviteToChannel( _ channelID: String , userID: String , success: SuccessClosure ? , failure: FailureClosure ? ) {
203+ invite ( . channelsInvite, channelID: channelID, userID: userID, success: success, failure: failure)
204+ }
205+
198206 public func setChannelPurpose( channel: String , purpose: String , success: SuccessClosure ? , failure: FailureClosure ? ) {
199207 setInfo ( . channelsSetPurpose, type: . purpose, channel: channel, text: purpose, success: { ( purposeSet) in
200208 success ? ( purposeSet)
@@ -1191,4 +1199,33 @@ extension WebAPI {
11911199 failure ? ( error)
11921200 }
11931201 }
1202+
1203+ fileprivate func create(
1204+ _ endpoint: Endpoint ,
1205+ name: String ,
1206+ success: ChannelClosure ? ,
1207+ failure: FailureClosure ?
1208+ ) {
1209+ let parameters : [ String : Any ] = [ " token " : token, " name " : name]
1210+ networkInterface. request ( endpoint, parameters: parameters, successClosure: { ( response) in
1211+ success ? ( Channel ( channel: response [ " channel " ] as? [ String : Any ] ) )
1212+ } ) { ( error) in
1213+ failure ? ( error)
1214+ }
1215+ }
1216+
1217+ fileprivate func invite(
1218+ _ endpoint: Endpoint ,
1219+ channelID: String ,
1220+ userID: String ,
1221+ success: SuccessClosure ? ,
1222+ failure: FailureClosure ?
1223+ ) {
1224+ let parameters : [ String : Any ] = [ " token " : token, " channel " : channelID, " user " : userID]
1225+ networkInterface. request ( endpoint, parameters: parameters, successClosure: { ( response) in
1226+ success ? ( true )
1227+ } ) { ( error) in
1228+ failure ? ( error)
1229+ }
1230+ }
11941231}
0 commit comments