Permalink
Browse files

GM

  • Loading branch information...
pvzig committed Sep 15, 2016
1 parent 183ed91 commit ca444930a42ccd610ca5b7e0d110f07a6c8fa3d2
View
@@ -16,6 +16,7 @@ DerivedData
*.hmap
*.ipa
*.xcuserstate
+*.DS_Store
# SwiftPM
Packages/
View
@@ -1,2 +1,2 @@
-github "https://github.com/pvzig/swifter.git" "master"
-github "https://github.com/pvzig/Starscream.git" "swift3"
+git "/Users/pzignego/Repositories/swifter" "xcode8b6"
+git "/Users/pzignego/Repositories/Starscream" "xcode8b6"
View
@@ -1,2 +1,2 @@
-github "pvzig/Starscream" "2fde5c5eb9302439e634753c3aacc794ca2e42e8"
-github "pvzig/swifter" "ddbebdde19360a2c9e4e01e5a0642dd12082cc92"
+git "/Users/pzignego/Repositories/Starscream" "34ed78556478730252d77cab878ff5aa2fda7fe4"
+git "/Users/pzignego/Repositories/swifter" "0b4fadaca0011da031730f225357f2b87f6e68fa"
@@ -50,12 +50,12 @@ public struct Action {
internal func dictionary() -> [String: AnyObject] {
var dict = [String: AnyObject]()
- dict["name"] = name
- dict["text"] = text
- dict["type"] = type
- dict["value"] = value
- dict["style"] = style?.rawValue
- dict["confirm"] = confirm?.dictionary()
+ dict["name"] = name as AnyObject?
+ dict["text"] = text as AnyObject?
+ dict["type"] = type as AnyObject?
+ dict["value"] = value as AnyObject?
+ dict["style"] = style?.rawValue as AnyObject?
+ dict["confirm"] = confirm?.dictionary() as AnyObject?
return dict
}
@@ -82,10 +82,10 @@ public struct Action {
internal func dictionary() -> [String: AnyObject] {
var dict = [String: AnyObject]()
- dict["title"] = title
- dict["text"] = text
- dict["ok_text"] = okText
- dict["dismiss_text"] = dismissText
+ dict["title"] = title as AnyObject?
+ dict["text"] = text as AnyObject?
+ dict["ok_text"] = okText as AnyObject?
+ dict["dismiss_text"] = dismissText as AnyObject?
return dict
}
@@ -86,24 +86,24 @@ public struct Attachment {
internal func dictionary() -> [String: AnyObject] {
var attachment = [String: AnyObject]()
- attachment["fallback"] = fallback
- attachment["callback_id"] = callbackID
- attachment["attachment_type"] = type
- attachment["color"] = color
- attachment["pretext"] = pretext
- attachment["authorName"] = authorName
- attachment["author_link"] = authorLink
- attachment["author_icon"] = authorIcon
- attachment["title"] = title
- attachment["title_link"] = titleLink
- attachment["text"] = text
- attachment["fields"] = fields?.map{$0.dictionary()}
- attachment["actions"] = actions?.map{$0.dictionary()}
- attachment["image_url"] = imageURL
- attachment["thumb_url"] = thumbURL
- attachment["footer"] = footer
- attachment["footer_icon"] = footerIcon
- attachment["ts"] = ts
+ attachment["fallback"] = fallback as AnyObject?
+ attachment["callback_id"] = callbackID as AnyObject?
+ attachment["attachment_type"] = type as AnyObject?
+ attachment["color"] = color as AnyObject?
+ attachment["pretext"] = pretext as AnyObject?
+ attachment["authorName"] = authorName as AnyObject?
+ attachment["author_link"] = authorLink as AnyObject?
+ attachment["author_icon"] = authorIcon as AnyObject?
+ attachment["title"] = title as AnyObject?
+ attachment["title_link"] = titleLink as AnyObject?
+ attachment["text"] = text as AnyObject?
+ attachment["fields"] = fields?.map{$0.dictionary()} as AnyObject?
+ attachment["actions"] = actions?.map{$0.dictionary()} as AnyObject?
+ attachment["image_url"] = imageURL as AnyObject?
+ attachment["thumb_url"] = thumbURL as AnyObject?
+ attachment["footer"] = footer as AnyObject?
+ attachment["footer_icon"] = footerIcon as AnyObject?
+ attachment["ts"] = ts as AnyObject?
return attachment
}
@@ -41,9 +41,9 @@ public struct AttachmentField {
internal func dictionary() -> [String: AnyObject] {
var field = [String: AnyObject]()
- field["title"] = title
- field["value"] = value
- field["short"] = short
+ field["title"] = title as AnyObject?
+ field["value"] = value as AnyObject?
+ field["short"] = short as AnyObject?
return field
}
@@ -31,9 +31,9 @@ internal struct AuthorizeRequest {
var parameters: [String: AnyObject] {
var json = [String : AnyObject]()
- json["scope"] = scope.map({$0.rawValue}).joined(separator: ",")
- json["state"] = state
- json["team"] = team
+ json["scope"] = scope.map({$0.rawValue}).joined(separator: ",") as AnyObject?
+ json["state"] = state as AnyObject?
+ json["team"] = team as AnyObject?
return json
}
@@ -144,7 +144,7 @@ internal extension Client {
// Other clients should ignore this event.
break
case .TeamMigrationStarted:
- connect(options: options ?? ClientOptions())
+ connect(options ?? ClientOptions())
case .ReconnectURL:
// The reconnect_url event is currently unsupported and experimental.
break
@@ -43,11 +43,11 @@ public extension Client {
return id
}
- public func getImIDForUserWithID(_ id: String, success: (imID: String?)->Void, failure: (error: SlackError)->Void) {
+ public func getImIDForUserWithID(_ id: String, success: @escaping (_ imID: String?)->Void, failure: @escaping (SlackError)->Void) {
let ims = channels.filter{$0.1.isIM == true}
let channel = ims.filter{$0.1.user == id}.first
if let channel = channel {
- success(imID: channel.0)
+ success(channel.0)
} else {
webAPI.openIM(id, success: success, failure: failure)
}
@@ -44,7 +44,7 @@ public final class Client: WebSocketDelegate {
}
internal var webSocket: WebSocket?
- private let pingPongQueue = DispatchQueue(label: "com.launchsoft.SlackKit")
+ fileprivate let pingPongQueue = DispatchQueue(label: "com.launchsoft.SlackKit")
internal var ping: Double?
internal var pong: Double?
internal var options: ClientOptions?
@@ -73,7 +73,7 @@ public final class Client: WebSocketDelegate {
self.token = token
}
- public func connect(options: ClientOptions = ClientOptions()) {
+ public func connect(_ options: ClientOptions = ClientOptions()) {
self.options = options
webAPI.rtmStart(options.simpleLatest, noUnreads: options.noUnreads, mpimAware: options.mpimAware, success: {
(response) -> Void in
@@ -102,31 +102,31 @@ public final class Client: WebSocketDelegate {
}
}
- private func formatMessageToSlackJsonString(_ message: (msg: String, channel: String)) throws -> Data {
+ fileprivate func formatMessageToSlackJsonString(_ message: (msg: String, channel: String)) throws -> Data {
let json: [String: AnyObject] = [
- "id": Date().slackTimestamp(),
- "type": "message",
- "channel": message.channel,
- "text": message.msg.slackFormatEscaping()
+ "id": Date().slackTimestamp() as AnyObject,
+ "type": "message" as AnyObject,
+ "channel": message.channel as AnyObject,
+ "text": message.msg.slackFormatEscaping() as AnyObject
]
addSentMessage(json)
return try JSONSerialization.data(withJSONObject: json, options: [])
}
- private func addSentMessage(_ dictionary: [String: AnyObject]) {
+ fileprivate func addSentMessage(_ dictionary: [String: AnyObject]) {
var message = dictionary
guard let id = message["id"] as? NSNumber else {
return
}
- let ts = String(id)
+ let ts = String(describing: id)
message.removeValue(forKey: "id")
- message["ts"] = ts
- message["user"] = self.authenticatedUser?.id
+ message["ts"] = ts as AnyObject?
+ message["user"] = self.authenticatedUser?.id as AnyObject?
sentMessages[ts] = Message(message: message)
}
//MARK: - RTM Ping
- private func pingRTMServerAtInterval(_ interval: TimeInterval) {
+ fileprivate func pingRTMServerAtInterval(_ interval: TimeInterval) {
let delay = DispatchTime.now() + Double(Int64(interval * Double(NSEC_PER_SEC))) / Double(NSEC_PER_SEC)
pingPongQueue.asyncAfter(deadline: delay, execute: {
guard self.connected && self.timeoutCheck() else {
@@ -138,13 +138,13 @@ public final class Client: WebSocketDelegate {
})
}
- private func sendRTMPing() {
+ fileprivate func sendRTMPing() {
guard connected else {
return
}
let json: [String: AnyObject] = [
- "id": Date().slackTimestamp(),
- "type": "ping",
+ "id": Date().slackTimestamp() as AnyObject,
+ "type": "ping" as AnyObject,
]
guard let data = try? JSONSerialization.data(withJSONObject: json, options: []) else {
return
@@ -155,7 +155,7 @@ public final class Client: WebSocketDelegate {
}
}
- private func timeoutCheck() -> Bool {
+ fileprivate func timeoutCheck() -> Bool {
if let pong = pong, let ping = ping, let timeout = options?.timeout {
if pong - ping < timeout {
return true
@@ -169,7 +169,7 @@ public final class Client: WebSocketDelegate {
}
//MARK: - Client setup
- private func initialSetup(_ json: [String: AnyObject]) {
+ fileprivate func initialSetup(_ json: [String: AnyObject]) {
team = Team(team: json["team"] as? [String: AnyObject])
authenticatedUser = User(user: json["self"] as? [String: AnyObject])
authenticatedUser?.doNotDisturbStatus = DoNotDisturbStatus(status: json["dnd"] as? [String: AnyObject])
@@ -182,28 +182,28 @@ public final class Client: WebSocketDelegate {
enumerateSubteams(json["subteams"] as? [String: AnyObject])
}
- private func addUser(_ aUser: [String: AnyObject]) {
+ fileprivate func addUser(_ aUser: [String: AnyObject]) {
let user = User(user: aUser)
if let id = user.id {
users[id] = user
}
}
- private func addChannel(_ aChannel: [String: AnyObject]) {
+ fileprivate func addChannel(_ aChannel: [String: AnyObject]) {
let channel = Channel(channel: aChannel)
if let id = channel.id {
channels[id] = channel
}
}
- private func addBot(_ aBot: [String: AnyObject]) {
+ fileprivate func addBot(_ aBot: [String: AnyObject]) {
let bot = Bot(bot: aBot)
if let id = bot.id {
bots[id] = bot
}
}
- private func enumerateSubteams(_ subteams: [String: AnyObject]?) {
+ fileprivate func enumerateSubteams(_ subteams: [String: AnyObject]?) {
if let subteams = subteams {
if let all = subteams["all"] as? [[String: AnyObject]] {
for item in all {
@@ -221,7 +221,7 @@ public final class Client: WebSocketDelegate {
}
// MARK: - Utilities
- private func enumerateObjects(_ array: [AnyObject]?, initalizer: ([String: AnyObject])-> Void) {
+ fileprivate func enumerateObjects(_ array: [AnyObject]?, initalizer: ([String: AnyObject])-> Void) {
if let array = array {
for object in array {
if let dictionary = object as? [String: AnyObject] {
@@ -232,7 +232,7 @@ public final class Client: WebSocketDelegate {
}
// MARK: - WebSocketDelegate
- public func websocketDidConnect(socket: WebSocket) {
+ public func websocketDidConnect(_ socket: WebSocket) {
if let pingInterval = options?.pingInterval {
pingRTMServerAtInterval(pingInterval)
}
@@ -244,7 +244,7 @@ public final class Client: WebSocketDelegate {
authenticatedUser = nil
connectionEventsDelegate?.clientDisconnected(self)
if let options = options, options.reconnect == true {
- connect(options: options)
+ connect(options)
}
}
@@ -60,12 +60,12 @@ public struct IncomingWebhook {
}
}
- private func jsonBody(_ response: [String: AnyObject]) -> [String: AnyObject] {
+ fileprivate func jsonBody(_ response: [String: AnyObject]) -> [String: AnyObject] {
var json = response
- json["channel"] = channel
- json["username"] = username
- json["icon_emoji"] = iconEmoji
- json["icon_url"] = iconURL
+ json["channel"] = channel as AnyObject?
+ json["username"] = username as AnyObject?
+ json["icon_emoji"] = iconEmoji as AnyObject?
+ json["icon_url"] = iconURL as AnyObject?
return json
}
@@ -21,7 +21,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-public class MessageActionServer: Server {
+open class MessageActionServer: Server {
internal let responder: MessageActionResponder
@@ -27,7 +27,7 @@ internal struct NetworkInterface {
private let apiUrl = "https://slack.com/api/"
- internal func request(_ endpoint: Endpoint, token: String? = nil, parameters: [String: AnyObject]?, successClosure: ([String: AnyObject])->Void, errorClosure: (SlackError)->Void) {
+ internal func request(_ endpoint: Endpoint, token: String? = nil, parameters: [String: AnyObject]?, successClosure: @escaping ([String: AnyObject])->Void, errorClosure: @escaping (SlackError)->Void) {
var requestString = "\(apiUrl)\(endpoint.rawValue)?"
if let token = token {
requestString += "token=\(token)"
@@ -42,15 +42,15 @@ internal struct NetworkInterface {
let request = URLRequest(url:url)
URLSession.shared.dataTask(with: request) {
(data, response, internalError) -> Void in
- self.handleResponse(data, response: response, internalError: internalError, successClosure: {(json) in
- successClosure(json)
- }, errorClosure: {(error) in
- errorClosure(error)
- })
+// self.handleResponse(data, response: response, internalError: internalError, successClosure: {(json) in
+// successClosure(json)
+// }, errorClosure: {(error) in
+// errorClosure(error)
+// })
}.resume()
}
- internal func customRequest(_ url: String, data: Data, success: (Bool)->Void, errorClosure: (SlackError)->Void) {
+ internal func customRequest(_ url: String, data: Data, success: @escaping (Bool)->Void, errorClosure: @escaping (SlackError)->Void) {
guard let url = URL(string: url.removePercentEncoding()) else {
errorClosure(SlackError.ClientNetworkError)
return
@@ -71,7 +71,7 @@ internal struct NetworkInterface {
}.resume()
}
- internal func uploadRequest(_ token: String, data: Data, parameters: [String: AnyObject]?, successClosure: ([String: AnyObject])->Void, errorClosure: (SlackError)->Void) {
+ internal func uploadRequest(_ token: String, data: Data, parameters: [String: AnyObject]?, successClosure: @escaping ([String: AnyObject])->Void, errorClosure: @escaping (SlackError)->Void) {
var requestString = "\(apiUrl)\(Endpoint.FilesUpload.rawValue)?token=\(token)"
if let params = parameters {
requestString = requestString + params.requestStringFromParameters
@@ -102,11 +102,11 @@ internal struct NetworkInterface {
URLSession.shared.dataTask(with: request) {
(data, response, internalError) -> Void in
- self.handleResponse(data, response: response, internalError: internalError, successClosure: {(json) in
- successClosure(json)
- }, errorClosure: {(error) in
- errorClosure(error)
- })
+// self.handleResponse(data, response: response, internalError: internalError, successClosure: {(json) in
+// successClosure(json)
+// }, errorClosure: {(error) in
+// errorClosure(error)
+// })
}.resume()
}
Oops, something went wrong.

0 comments on commit ca44493

Please sign in to comment.