diff --git a/SKRTMAPI/Sources/SKRTMAPI.swift b/SKRTMAPI/Sources/SKRTMAPI.swift index 9457a074..a199af8a 100755 --- a/SKRTMAPI/Sources/SKRTMAPI.swift +++ b/SKRTMAPI/Sources/SKRTMAPI.swift @@ -38,13 +38,13 @@ public protocol RTMWebSocket { func sendMessage(_ message: String) throws } -public protocol RTMAdapter: class { +public protocol RTMAdapter: AnyObject { func initialSetup(json: [String: Any], instance: SKRTMAPI) func notificationForEvent(_ event: Event, type: EventType, instance: SKRTMAPI) func connectionClosed(with error: Error, instance: SKRTMAPI) } -public protocol RTMDelegate: class { +public protocol RTMDelegate: AnyObject { func didConnect() func disconnected() func receivedMessage(_ message: String) @@ -76,34 +76,17 @@ public final class SKRTMAPI: RTMDelegate { self.rtm.delegate = self } - public func connect(withInfo: Bool = true) { - if withInfo { - WebAPI.rtmStart( - token: token, - batchPresenceAware: options.noUnreads, - mpimAware: options.mpimAware, - noLatest: options.noLatest, - noUnreads: options.noUnreads, - presenceSub: options.presenceSub, - simpleLatest: options.simpleLatest, - success: {(response) in - self.connectWithResponse(response) - }, failure: { (error) in - self.adapter?.connectionClosed(with: error, instance: self) - } - ) - } else { - WebAPI.rtmConnect( - token: token, - batchPresenceAware: options.batchPresenceAware, - presenceSub: options.presenceSub, - success: {(response) in - self.connectWithResponse(response) - }, failure: { (error) in - self.adapter?.connectionClosed(with: error, instance: self) - } - ) - } + public func connect() { + WebAPI.rtmConnect( + token: token, + batchPresenceAware: options.batchPresenceAware, + presenceSub: options.presenceSub, + success: {(response) in + self.connectWithResponse(response) + }, failure: { (error) in + self.adapter?.connectionClosed(with: error, instance: self) + } + ) } public func disconnect() { diff --git a/SKWebAPI/README.md b/SKWebAPI/README.md index 4e784037..6a0c56b5 100755 --- a/SKWebAPI/README.md +++ b/SKWebAPI/README.md @@ -134,7 +134,7 @@ SlackKit currently supports the a subset of the Slack Web API that is available | `reactions.get`| | `reactions.list`| | `reactions.remove`| -| `rtm.start`| +| `rtm.connect`| | `stars.add`| | `stars.remove`| | `team.info`| diff --git a/SKWebAPI/Sources/Endpoint.swift b/SKWebAPI/Sources/Endpoint.swift index 437b4155..1f3fbb50 100755 --- a/SKWebAPI/Sources/Endpoint.swift +++ b/SKWebAPI/Sources/Endpoint.swift @@ -79,7 +79,6 @@ public enum Endpoint: String { case reactionsList = "reactions.list" case reactionsRemove = "reactions.remove" case rtmConnect = "rtm.connect" - case rtmStart = "rtm.start" case searchAll = "search.all" case searchFiles = "search.files" case searchMessages = "search.messages" diff --git a/SKWebAPI/Sources/WebAPI.swift b/SKWebAPI/Sources/WebAPI.swift index a5dbf679..8fd8ded9 100755 --- a/SKWebAPI/Sources/WebAPI.swift +++ b/SKWebAPI/Sources/WebAPI.swift @@ -71,33 +71,6 @@ public final class WebAPI { // MARK: - RTM extension WebAPI { - public static func rtmStart( - token: String, - batchPresenceAware: Bool = false, - mpimAware: Bool? = nil, - noLatest: Bool = false, - noUnreads: Bool? = nil, - presenceSub: Bool = false, - simpleLatest: Bool? = nil, - success: ((_ response: [String: Any]) -> Void)?, - failure: FailureClosure? - ) { - let parameters: [String: Any?] = - [ - "batch_presence_aware": batchPresenceAware, - "mpim_aware": mpimAware, - "no_latest": noLatest, - "no_unreads": noUnreads, - "presence_sub": presenceSub, - "simple_latest": simpleLatest - ] - NetworkInterface().request(.rtmStart, accessToken: token, parameters: parameters, successClosure: {(response) in - success?(response) - }) {(error) in - failure?(error) - } - } - public static func rtmConnect( token: String, batchPresenceAware: Bool = false,