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

Commit

Permalink
Merge pull request #6 from SlackKit/rtm-connect
Browse files Browse the repository at this point in the history
Add support for rtm.connect web endpoint
  • Loading branch information
pvzig authored Jul 15, 2017
2 parents 193b02e + 474d32f commit 55537c1
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 3 deletions.
1 change: 1 addition & 0 deletions Sources/Endpoint.swift
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public enum Endpoint: String {
case reactionsList = "reactions.list"
case reactionsRemove = "reactions.remove"
case rtmStart = "rtm.start"
case rtmConnect = "rtm.connect"
case starsAdd = "stars.add"
case starsRemove = "stars.remove"
case teamInfo = "team.info"
Expand Down
39 changes: 36 additions & 3 deletions Sources/WebAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,19 +64,52 @@ public final class WebAPI {
extension WebAPI {
public static func rtmStart(
token: String,
simpleLatest: Bool? = nil,
noUnreads: Bool? = nil,
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?] = ["token": token, "simple_latest": simpleLatest, "no_unreads": noUnreads, "mpim_aware": mpimAware]
let parameters: [String: Any?] =
[
"token": token,
"batch_presence_aware": batchPresenceAware,
"mpim_aware": mpimAware,
"no_latest": noLatest,
"no_unreads": noUnreads,
"presence_sub": presenceSub,
"simple_latest": simpleLatest
]
NetworkInterface().request(.rtmStart, parameters: parameters, successClosure: {(response) in
success?(response)
}) {(error) in
failure?(error)
}
}

public static func rtmConnect(
token: String,
batchPresenceAware: Bool = false,
presenceSub: Bool = false,
success: ((_ response: [String: Any]) -> Void)?,
failure: FailureClosure?
) {
let parameters: [String: Any?] =
[
"token": token,
"batch_presence_aware": batchPresenceAware,
"presence_sub": presenceSub
]
NetworkInterface().request(.rtmConnect, parameters: parameters, successClosure: {(response) in
success?(response)
}) {(error) in
failure?(error)
}

}
}

// MARK: - Auth
Expand Down

0 comments on commit 55537c1

Please sign in to comment.