Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 79e59f23fb | |||
| 01e199659e | |||
| 851b2f5e14 | |||
| c506512800 | |||
| 20fa05605b | |||
| 30baf1f76c | |||
| 1c3f01f861 | |||
| 47dc9b3d9f | |||
| b9e828ef3d |
@@ -30,10 +30,10 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
||||
|
||||
@IBOutlet weak var window: NSWindow!
|
||||
|
||||
let learderboard = Leaderboard(token: "SLACK_AUTH_TOKEN")
|
||||
let leaderboard = Leaderboard(token: "SLACK_AUTH_TOKEN")
|
||||
|
||||
func applicationDidFinishLaunching(aNotification: NSNotification) {
|
||||
learderboard.client.connect()
|
||||
leaderboard.client.connect()
|
||||
}
|
||||
|
||||
func applicationWillTerminate(aNotification: NSNotification) {
|
||||
|
||||
@@ -73,6 +73,7 @@ SlackKit currently supports the a subset of the Slack Web APIs that are availabl
|
||||
- files.comments.edit
|
||||
- files.comments.delete
|
||||
- files.delete
|
||||
- files.info
|
||||
- files.upload
|
||||
- groups.close
|
||||
- groups.history
|
||||
@@ -130,6 +131,7 @@ There are a number of delegates that you can set to receive callbacks for certai
|
||||
|
||||
#####SlackEventsDelegate
|
||||
```swift
|
||||
func clientConnectionFailed(error: SlackError)
|
||||
func clientConnected()
|
||||
func clientDisconnected()
|
||||
func preferenceChanged(preference: String, value: AnyObject)
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
Pod::Spec.new do |s|
|
||||
s.name = "SlackKit"
|
||||
s.version = "1.0.1"
|
||||
s.version = "1.0.2"
|
||||
s.summary = "a Slack client library for iOS and OS X written in Swift"
|
||||
s.homepage = "https://github.com/pvzig/SlackKit"
|
||||
s.license = 'MIT'
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>FMWK</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0.1</string>
|
||||
<string>1.0.2</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
|
||||
@@ -52,7 +52,7 @@ public class Client: WebSocketDelegate {
|
||||
public var subteamEventsDelegate: SubteamEventsDelegate?
|
||||
public var teamProfileEventsDelegate: TeamProfileEventsDelegate?
|
||||
|
||||
internal var token = "SLACK_AUTH_TOKEN"
|
||||
public var token = "SLACK_AUTH_TOKEN"
|
||||
|
||||
public func setAuthToken(token: String) {
|
||||
self.token = token
|
||||
@@ -92,7 +92,9 @@ public class Client: WebSocketDelegate {
|
||||
self.webSocket?.delegate = self
|
||||
self.webSocket?.connect()
|
||||
}
|
||||
}, failure:nil)
|
||||
}, failure: {(error) -> Void in
|
||||
self.slackEventsDelegate?.clientConnectionFailed(error)
|
||||
})
|
||||
}
|
||||
|
||||
public func disconnect() {
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
import Foundation
|
||||
|
||||
public protocol SlackEventsDelegate {
|
||||
func clientConnectionFailed(error: SlackError)
|
||||
func clientConnected()
|
||||
func clientDisconnected()
|
||||
func preferenceChanged(preference: String, value: AnyObject)
|
||||
|
||||
@@ -36,6 +36,7 @@ internal struct NetworkInterface {
|
||||
NSURLSession.sharedSession().dataTaskWithRequest(request) {
|
||||
(data, response, internalError) -> Void in
|
||||
guard let data = data else {
|
||||
errorClosure(SlackError.ClientNetworkError)
|
||||
return
|
||||
}
|
||||
do {
|
||||
|
||||
@@ -42,6 +42,7 @@ internal enum SlackAPIEndpoint: String {
|
||||
case FilesCommentsEdit = "files.comments.edit"
|
||||
case FilesCommentsDelete = "files.comments.delete"
|
||||
case FilesDelete = "files.delete"
|
||||
case FilesInfo = "files.info"
|
||||
case FilesUpload = "files.upload"
|
||||
case GroupsClose = "groups.close"
|
||||
case GroupsHistory = "groups.history"
|
||||
@@ -257,6 +258,23 @@ public class SlackWebAPI {
|
||||
}
|
||||
}
|
||||
|
||||
public func fileInfo(fileID: String, commentCount: Int = 100, totalPages: Int = 1, success: ((file: File?)->Void)?, failure: FailureClosure?) {
|
||||
let parameters: [String: AnyObject] = ["file":fileID, "count": commentCount, "totalPages":totalPages]
|
||||
client.api.request(.FilesInfo, token: client.token, parameters: parameters, successClosure: {
|
||||
(response) in
|
||||
var file = File(file: response["file"] as? [String: AnyObject])
|
||||
(response["comments"] as? [[String: AnyObject]])?.objectArrayFromDictionaryArray({(comment) -> Comment? in
|
||||
if let comment = Comment(comment: comment), id = comment.id {
|
||||
file?.comments[id] = comment
|
||||
}
|
||||
return nil
|
||||
})
|
||||
success?(file: file)
|
||||
}) {(error) in
|
||||
failure?(error: error)
|
||||
}
|
||||
}
|
||||
|
||||
public func uploadFile(file: NSData, filename: String, filetype: String = "auto", title: String? = nil, initialComment: String? = nil, channels: [String]? = nil, success: ((file: File?)->Void)?, failure: FailureClosure?) {
|
||||
let parameters: [String: AnyObject?] = ["file":file, "filename": filename, "filetype":filetype, "title":title, "initial_comment":initialComment, "channels":channels?.joinWithSeparator(",")]
|
||||
client.api.uploadRequest(client.token, data: file, parameters: filterNilParameters(parameters), successClosure: {
|
||||
|
||||
@@ -111,6 +111,8 @@ public enum SlackError: ErrorType {
|
||||
case UserListNotSupplied
|
||||
case UserNotFound
|
||||
case UserNotVisible
|
||||
// Client
|
||||
case ClientNetworkError
|
||||
}
|
||||
|
||||
internal struct ErrorDispatcher {
|
||||
|
||||
Reference in New Issue
Block a user