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

Commit

Permalink
Remove deprecated rtmStart
Browse files Browse the repository at this point in the history
  • Loading branch information
pvzig committed Dec 28, 2021
1 parent 8e46cbb commit ab751a0
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 59 deletions.
43 changes: 13 additions & 30 deletions SKRTMAPI/Sources/SKRTMAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion SKWebAPI/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`|
Expand Down
1 change: 0 additions & 1 deletion SKWebAPI/Sources/Endpoint.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
27 changes: 0 additions & 27 deletions SKWebAPI/Sources/WebAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit ab751a0

Please sign in to comment.