Compare commits

..

16 Commits

Author SHA1 Message Date
Peter Zignego 0ebd3cb0e7 Merge pull request #60 from pvzig/ios-fix
Fix iOS crash + Swift 3 style changes
2016-11-24 12:19:39 -05:00
Peter Zignego 5d7064ee13 Podfile + versioning 2016-11-24 12:16:53 -05:00
Peter Zignego d02768ddad Bump starscream version 2016-11-24 12:01:54 -05:00
Peter Zignego dbc7b361c8 Merge branch 'master' into ios-fix 2016-11-24 11:59:50 -05:00
Peter Zignego a0de46e3c7 Code quality improvements 2016-11-20 22:10:44 -05:00
Peter Zignego 2d6e19baee Bump starscream version 2016-11-20 22:07:06 -05:00
Peter Zignego 21ec3cb2a1 Fix iOS crash 2016-11-20 22:04:50 -05:00
Peter Zignego cb542da068 Merge pull request #59 from MarcusSmith/master
Fix File Upload Bug
2016-11-18 14:16:18 -05:00
Marcus Smith 788b4e4f7a Remove File data from upload's query parameters, which was preventing a proper URL from being created from the request string 2016-11-18 14:14:02 -05:00
Peter Zignego 24b2292cba Request string bugfix 2016-11-17 16:48:00 -05:00
Peter Zignego 72866262d2 Fix request string bug 2016-11-17 16:30:28 -05:00
Peter Zignego fff0f0befc Merge branch 'master' of https://github.com/pvzig/SlackKit into ios-fix
# Conflicts:
#	SlackKit/Sources/WebAPI.swift
2016-11-17 14:44:35 -05:00
Peter Zignego 9ebd8182a6 Lowercase enums 2016-11-13 17:26:32 -05:00
Peter Zignego 63a8ae7f08 Lowercase enums 2016-11-13 15:34:27 -05:00
Peter Zignego 992f94e870 Lowercase error enums 2016-11-13 15:32:50 -05:00
Peter Zignego 1c476c77ad Lowercase enums 2016-11-11 14:59:43 -05:00
13 changed files with 427 additions and 424 deletions
+2 -2
View File
@@ -1,2 +1,2 @@
git "https://github.com/daltoniam/Starscream" == 2.0.0
git "https://github.com/pvzig/swifter.git" == 3.0.4
github "https://github.com/daltoniam/Starscream" == 2.0.2
github "https://github.com/pvzig/swifter.git" == 3.0.4
+2 -2
View File
@@ -1,2 +1,2 @@
git "https://github.com/daltoniam/Starscream" "2.0.0"
git "https://github.com/pvzig/swifter.git" "3.0.4"
github "daltoniam/Starscream" "2.0.2"
github "pvzig/swifter" "3.0.4"
+6 -6
View File
@@ -3,16 +3,16 @@ source 'https://github.com/CocoaPods/Specs.git'
use_frameworks!
target 'SlackKit OS X' do
pod 'Starscream', '~> 2.0.0'
pod 'Swifter', '~> 1.3.2'
pod 'Starscream', '~> 2.0.2'
pod 'Swifter', :git => 'https://github.com/pvzig/swifter.git', :tag => '3.0.4'
end
target 'SlackKit iOS' do
pod 'Starscream', '~> 2.0.0'
pod 'Swifter', '~> 1.3.2'
pod 'Starscream', '~> 2.0.2'
pod 'Swifter', :git => 'https://github.com/pvzig/swifter.git', :tag => '3.0.4'
end
target 'SlackKit tvOS' do
pod 'Starscream', '~> 2.0.0'
pod 'Swifter', '~> 1.3.2'
pod 'Starscream', '~> 2.0.2'
pod 'Swifter', :git => 'https://github.com/pvzig/swifter.git', :tag => '3.0.4'
end
+15 -5
View File
@@ -1,15 +1,25 @@
PODS:
- Starscream (2.0.0)
- Starscream (2.0.2)
- Swifter (1.3.2)
DEPENDENCIES:
- Starscream (~> 2.0.0)
- Swifter (~> 1.3.2)
- Starscream (~> 2.0.2)
- Swifter (from `https://github.com/pvzig/swifter.git`, tag `3.0.4`)
EXTERNAL SOURCES:
Swifter:
:git: https://github.com/pvzig/swifter.git
:tag: 3.0.4
CHECKOUT OPTIONS:
Swifter:
:git: https://github.com/pvzig/swifter.git
:tag: 3.0.4
SPEC CHECKSUMS:
Starscream: 947c865596f0d6bb3f0203fee23228ed2d471468
Starscream: 6c135a34e0a6e60cedaa0b30db67a4c05cf7cd38
Swifter: dd1800ba8eb3e28b22b8bd20f91a8561a0110fac
PODFILE CHECKSUM: 3d4e92bde92fd20d6fe672ad26f677fcbfafda1f
PODFILE CHECKSUM: cd86ea0f8422027c9d5fa3c40243ae7a816fb79a
COCOAPODS: 1.1.0.rc.3
+62 -64
View File
@@ -24,137 +24,135 @@
internal extension Client {
func dispatch(_ event: [String: Any]) {
let event = Event(event: event)
guard let type = event.type else {
return
}
let event = Event(event)
let type = event.type ?? .error
switch type {
case .Hello:
case .hello:
connected = true
connectionEventsDelegate?.connected(self)
case .Ok:
case .ok:
messageSent(event)
case .Message:
case .message:
if (event.subtype != nil) {
messageDispatcher(event)
} else {
messageReceived(event)
}
case .UserTyping:
case .userTyping:
userTyping(event)
case .ChannelMarked, .IMMarked, .GroupMarked:
case .channelMarked, .imMarked, .groupMarked:
channelMarked(event)
case .ChannelCreated, .IMCreated:
case .channelCreated, .imCreated:
channelCreated(event)
case .ChannelJoined, .GroupJoined:
case .channelJoined, .groupJoined:
channelJoined(event)
case .ChannelLeft, .GroupLeft:
case .channelLeft, .groupLeft:
channelLeft(event)
case .ChannelDeleted:
case .channelDeleted:
channelDeleted(event)
case .ChannelRenamed, .GroupRename:
case .channelRenamed, .groupRename:
channelRenamed(event)
case .ChannelArchive, .GroupArchive:
case .channelArchive, .groupArchive:
channelArchived(event, archived: true)
case .ChannelUnarchive, .GroupUnarchive:
case .channelUnarchive, .groupUnarchive:
channelArchived(event, archived: false)
case .ChannelHistoryChanged, .IMHistoryChanged, .GroupHistoryChanged:
case .channelHistoryChanged, .imHistoryChanged, .groupHistoryChanged:
channelHistoryChanged(event)
case .DNDUpdated:
case .dndUpdated:
doNotDisturbUpdated(event)
case .DNDUpatedUser:
case .dndUpatedUser:
doNotDisturbUserUpdated(event)
case .IMOpen, .GroupOpen:
case .imOpen, .groupOpen:
open(event, open: true)
case .IMClose, .GroupClose:
case .imClose, .groupClose:
open(event, open: false)
case .FileCreated:
case .fileCreated:
processFile(event)
case .FileShared:
case .fileShared:
processFile(event)
case .FileUnshared:
case .fileUnshared:
processFile(event)
case .FilePublic:
case .filePublic:
processFile(event)
case .FilePrivate:
case .filePrivate:
filePrivate(event)
case .FileChanged:
case .fileChanged:
processFile(event)
case .FileDeleted:
case .fileDeleted:
deleteFile(event)
case .FileCommentAdded:
case .fileCommentAdded:
fileCommentAdded(event)
case .FileCommentEdited:
case .fileCommentEdited:
fileCommentEdited(event)
case .FileCommentDeleted:
case .fileCommentDeleted:
fileCommentDeleted(event)
case .PinAdded:
case .pinAdded:
pinAdded(event)
case .PinRemoved:
case .pinRemoved:
pinRemoved(event)
case .Pong:
case .pong:
pong(event)
case .PresenceChange:
case .presenceChange:
presenceChange(event)
case .ManualPresenceChange:
case .manualPresenceChange:
manualPresenceChange(event)
case .PrefChange:
case .prefChange:
changePreference(event)
case .UserChange:
case .userChange:
userChange(event)
case .TeamJoin:
case .teamJoin:
teamJoin(event)
case .StarAdded:
case .starAdded:
itemStarred(event, star: true)
case .StarRemoved:
case .starRemoved:
itemStarred(event, star: false)
case .ReactionAdded:
case .reactionAdded:
addedReaction(event)
case .ReactionRemoved:
case .reactionRemoved:
removedReaction(event)
case .EmojiChanged:
case .emojiChanged:
emojiChanged(event)
case .CommandsChanged:
case .commandsChanged:
// This functionality is only used by our web client.
// The other APIs required to support slash command metadata are currently unstable.
// Until they are released other clients should ignore this event.
break
case .TeamPlanChange:
case .teamPlanChange:
teamPlanChange(event)
case .TeamPrefChange:
case .teamPrefChange:
teamPreferenceChange(event)
case .TeamRename:
case .teamRename:
teamNameChange(event)
case .TeamDomainChange:
case .teamDomainChange:
teamDomainChange(event)
case .EmailDomainChange:
case .emailDomainChange:
emailDomainChange(event)
case .TeamProfileChange:
case .teamProfileChange:
teamProfileChange(event)
case .TeamProfileDelete:
case .teamProfileDelete:
teamProfileDeleted(event)
case .TeamProfileReorder:
case .teamProfileReorder:
teamProfileReordered(event)
case .BotAdded:
case .botAdded:
bot(event)
case .BotChanged:
case .botChanged:
bot(event)
case .AccountsChanged:
case .accountsChanged:
// The accounts_changed event is used by our web client to maintain a list of logged-in accounts.
// Other clients should ignore this event.
break
case .TeamMigrationStarted:
case .teamMigrationStarted:
connect(options: options ?? ClientOptions())
case .ReconnectURL:
case .reconnectURL:
// The reconnect_url event is currently unsupported and experimental.
break
case .SubteamCreated, .SubteamUpdated:
case .subteamCreated, .subteamUpdated:
subteam(event)
case .SubteamSelfAdded:
case .subteamSelfAdded:
subteamAddedSelf(event)
case.SubteamSelfRemoved:
case .subteamSelfRemoved:
subteamRemovedSelf(event)
case .Error:
case .error:
print("Error: \(event)")
}
}
@@ -164,9 +162,9 @@ internal extension Client {
return
}
switch subtype {
case .MessageChanged:
case .messageChanged:
messageChanged(event)
case .MessageDeleted:
case .messageDeleted:
messageDeleted(event)
default:
messageReceived(event)
+96 -97
View File
@@ -23,108 +23,107 @@
internal enum EventType: String {
case Hello = "hello"
case Message = "message"
case UserTyping = "user_typing"
case ChannelMarked = "channel_marked"
case ChannelCreated = "channel_created"
case ChannelJoined = "channel_joined"
case ChannelLeft = "channel_left"
case ChannelDeleted = "channel_deleted"
case ChannelRenamed = "channel_rename"
case ChannelArchive = "channel_archive"
case ChannelUnarchive = "channel_unarchive"
case ChannelHistoryChanged = "channel_history_changed"
case DNDUpdated = "dnd_updated"
case DNDUpatedUser = "dnd_updated_user"
case IMCreated = "im_created"
case IMOpen = "im_open"
case IMClose = "im_close"
case IMMarked = "im_marked"
case IMHistoryChanged = "im_history_changed"
case GroupJoined = "group_joined"
case GroupLeft = "group_left"
case GroupOpen = "group_open"
case GroupClose = "group_close"
case GroupArchive = "group_archive"
case GroupUnarchive = "group_unarchive"
case GroupRename = "group_rename"
case GroupMarked = "group_marked"
case GroupHistoryChanged = "group_history_changed"
case FileCreated = "file_created"
case FileShared = "file_shared"
case FileUnshared = "file_unshared"
case FilePublic = "file_public"
case FilePrivate = "file_private"
case FileChanged = "file_change"
case FileDeleted = "file_deleted"
case FileCommentAdded = "file_comment_added"
case FileCommentEdited = "file_comment_edited"
case FileCommentDeleted = "file_comment_deleted"
case PinAdded = "pin_added"
case PinRemoved = "pin_removed"
case Pong = "pong"
case PresenceChange = "presence_change"
case ManualPresenceChange = "manual_presence_change"
case PrefChange = "pref_change"
case UserChange = "user_change"
case TeamJoin = "team_join"
case StarAdded = "star_added"
case StarRemoved = "star_removed"
case ReactionAdded = "reaction_added"
case ReactionRemoved = "reaction_removed"
case EmojiChanged = "emoji_changed"
case CommandsChanged = "commands_changed"
case TeamPlanChange = "team_plan_change"
case TeamPrefChange = "team_pref_change"
case TeamRename = "team_rename"
case TeamDomainChange = "team_domain_change"
case EmailDomainChange = "email_domain_change"
case TeamProfileChange = "team_profile_change"
case TeamProfileDelete = "team_profile_delete"
case TeamProfileReorder = "team_profile_reorder"
case BotAdded = "bot_added"
case BotChanged = "bot_changed"
case AccountsChanged = "accounts_changed"
case TeamMigrationStarted = "team_migration_started"
case ReconnectURL = "reconnect_url"
case SubteamCreated = "subteam_created"
case SubteamUpdated = "subteam_updated"
case SubteamSelfAdded = "subteam_self_added"
case SubteamSelfRemoved = "subteam_self_removed"
case Ok = "ok"
case Error = "error"
case hello = "hello"
case message = "message"
case userTyping = "user_typing"
case channelMarked = "channel_marked"
case channelCreated = "channel_created"
case channelJoined = "channel_joined"
case channelLeft = "channel_left"
case channelDeleted = "channel_deleted"
case channelRenamed = "channel_rename"
case channelArchive = "channel_archive"
case channelUnarchive = "channel_unarchive"
case channelHistoryChanged = "channel_history_changed"
case dndUpdated = "dnd_updated"
case dndUpatedUser = "dnd_updated_user"
case imCreated = "im_created"
case imOpen = "im_open"
case imClose = "im_close"
case imMarked = "im_marked"
case imHistoryChanged = "im_history_changed"
case groupJoined = "group_joined"
case groupLeft = "group_left"
case groupOpen = "group_open"
case groupClose = "group_close"
case groupArchive = "group_archive"
case groupUnarchive = "group_unarchive"
case groupRename = "group_rename"
case groupMarked = "group_marked"
case groupHistoryChanged = "group_history_changed"
case fileCreated = "file_created"
case fileShared = "file_shared"
case fileUnshared = "file_unshared"
case filePublic = "file_public"
case filePrivate = "file_private"
case fileChanged = "file_change"
case fileDeleted = "file_deleted"
case fileCommentAdded = "file_comment_added"
case fileCommentEdited = "file_comment_edited"
case fileCommentDeleted = "file_comment_deleted"
case pinAdded = "pin_added"
case pinRemoved = "pin_removed"
case pong = "pong"
case presenceChange = "presence_change"
case manualPresenceChange = "manual_presence_change"
case prefChange = "pref_change"
case userChange = "user_change"
case teamJoin = "team_join"
case starAdded = "star_added"
case starRemoved = "star_removed"
case reactionAdded = "reaction_added"
case reactionRemoved = "reaction_removed"
case emojiChanged = "emoji_changed"
case commandsChanged = "commands_changed"
case teamPlanChange = "team_plan_change"
case teamPrefChange = "team_pref_change"
case teamRename = "team_rename"
case teamDomainChange = "team_domain_change"
case emailDomainChange = "email_domain_change"
case teamProfileChange = "team_profile_change"
case teamProfileDelete = "team_profile_delete"
case teamProfileReorder = "team_profile_reorder"
case botAdded = "bot_added"
case botChanged = "bot_changed"
case accountsChanged = "accounts_changed"
case teamMigrationStarted = "team_migration_started"
case reconnectURL = "reconnect_url"
case subteamCreated = "subteam_created"
case subteamUpdated = "subteam_updated"
case subteamSelfAdded = "subteam_self_added"
case subteamSelfRemoved = "subteam_self_removed"
case ok = "ok"
case error = "error"
}
internal enum MessageSubtype: String {
case BotMessage = "bot_message"
case MeMessage = "me_message"
case MessageChanged = "message_changed"
case MessageDeleted = "message_deleted"
case ChannelJoin = "channel_join"
case ChannelLeave = "channel_leave"
case ChannelTopic = "channel_topic"
case ChannelPurpose = "channel_purpose"
case ChannelName = "channel_name"
case ChannelArchive = "channel_archive"
case ChannelUnarchive = "channel_unarchive"
case GroupJoin = "group_join"
case GroupLeave = "group_leave"
case GroupTopic = "group_topic"
case GroupPurpose = "group_purpose"
case GroupName = "group_name"
case GroupArchive = "group_archive"
case GroupUnarchive = "group_unarchive"
case FileShare = "file_share"
case FileComment = "file_comment"
case FileMention = "file_mention"
case PinnedItem = "pinned_item"
case UnpinnedItem = "unpinned_item"
case botMessage = "bot_message"
case meMessage = "me_message"
case messageChanged = "message_changed"
case messageDeleted = "message_deleted"
case channelJoin = "channel_join"
case channelLeave = "channel_leave"
case channelTopic = "channel_topic"
case channelPurpose = "channel_purpose"
case channelName = "channel_name"
case channelArchive = "channel_archive"
case channelUnarchive = "channel_unarchive"
case groupJoin = "group_join"
case groupLeave = "group_leave"
case groupTopic = "group_topic"
case groupPurpose = "group_purpose"
case groupName = "group_name"
case groupArchive = "group_archive"
case groupUnarchive = "group_unarchive"
case fileShare = "file_share"
case fileComment = "file_comment"
case fileMention = "file_mention"
case pinnedItem = "pinned_item"
case unpinnedItem = "unpinned_item"
}
internal struct Event {
internal class Event {
let type: EventType?
let ts: String?
let subtype: String?
@@ -162,7 +161,7 @@ internal struct Event {
let subteamID: String?
var profile: CustomProfile?
init(event:[String: Any]) {
init(_ event:[String: Any]) {
type = EventType(rawValue: event["type"] as? String ?? "ok")
ts = event["ts"] as? String
subtype = event["subtype"] as? String
+2 -3
View File
@@ -41,17 +41,16 @@ internal extension String {
}
internal extension Dictionary where Key: ExpressibleByStringLiteral, Value: Any {
var requestStringFromParameters: String {
var requestString = ""
for key in self.keys {
if let value = self[key] as? String, let encodedValue = value.addingPercentEncoding(withAllowedCharacters: CharacterSet.urlHostAllowed) {
requestString += "&\(key)=\(encodedValue)"
} else if let value = self[key] as? Int {
} else if let value = self[key] {
requestString += "&\(key)=\(value)"
}
}
return requestString
}
}
+26 -28
View File
@@ -36,24 +36,24 @@ internal struct NetworkInterface {
requestString += params.requestStringFromParameters
}
guard let url = URL(string: requestString) else {
errorClosure(SlackError.ClientNetworkError)
errorClosure(SlackError.clientNetworkError)
return
}
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)
})
do {
successClosure(try self.handleResponse(data, response: response, internalError: internalError))
} catch let error {
errorClosure(error as? SlackError ?? SlackError.unknownError)
}
}.resume()
}
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)
errorClosure(SlackError.clientNetworkError)
return
}
var request = URLRequest(url:url)
@@ -67,18 +67,18 @@ internal struct NetworkInterface {
if internalError == nil {
success(true)
} else {
errorClosure(SlackError.ClientNetworkError)
errorClosure(SlackError.clientNetworkError)
}
}.resume()
}
internal func uploadRequest(_ token: String, data: Data, parameters: [String: Any]?, successClosure: @escaping ([String: Any])->Void, errorClosure: @escaping (SlackError)->Void) {
var requestString = "\(apiUrl)\(Endpoint.FilesUpload.rawValue)?token=\(token)"
var requestString = "\(apiUrl)\(Endpoint.filesUpload.rawValue)?token=\(token)"
if let params = parameters {
requestString = requestString + params.requestStringFromParameters
}
guard let url = URL(string: requestString) else {
errorClosure(SlackError.ClientNetworkError)
errorClosure(SlackError.clientNetworkError)
return
}
var request = URLRequest(url:url)
@@ -103,46 +103,44 @@ 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)
})
do {
successClosure(try self.handleResponse(data, response: response, internalError: internalError))
} catch let error {
errorClosure(error as? SlackError ?? SlackError.unknownError)
}
}.resume()
}
private func handleResponse(_ data: Data?, response:URLResponse?, internalError:Error?, successClosure: ([String: Any])->Void, errorClosure: (SlackError)->Void) {
private func handleResponse(_ data: Data?, response:URLResponse?, internalError:Error?) throws -> [String: Any] {
guard let data = data, let response = response as? HTTPURLResponse else {
errorClosure(SlackError.ClientNetworkError)
return
throw SlackError.clientNetworkError
}
do {
guard let json = try JSONSerialization.jsonObject(with: data, options: []) as? [String: Any] else {
errorClosure(SlackError.ClientJSONError)
return
throw SlackError.clientJSONError
}
switch response.statusCode {
case 200:
if (json["ok"] as! Bool == true) {
successClosure(json)
return json
} else {
if let errorString = json["error"] as? String {
throw SlackError(rawValue: errorString) ?? .UnknownError
throw SlackError(rawValue: errorString) ?? .unknownError
} else {
throw SlackError.UnknownError
throw SlackError.unknownError
}
}
case 429:
throw SlackError.TooManyRequests
throw SlackError.tooManyRequests
default:
throw SlackError.ClientNetworkError
throw SlackError.clientNetworkError
}
} catch let error {
if let slackError = error as? SlackError {
errorClosure(slackError)
throw slackError
} else {
errorClosure(SlackError.UnknownError)
throw SlackError.unknownError
}
}
}
+94 -95
View File
@@ -22,101 +22,100 @@
// THE SOFTWARE.
public enum SlackError: String, Error {
case AccountInactive = "account_inactive"
case AlreadyArchived = "already_archived"
case AlreadyInChannel = "already_in_channel"
case AlreadyPinned = "already_pinned"
case AlreadyReacted = "already_reacted"
case AlreadyStarred = "already_starred"
case BadClientSecret = "bad_client_secret"
case BadRedirectURI = "bad_redirect_uri"
case BadTimeStamp = "bad_timestamp"
case CantArchiveGeneral = "cant_archive_general"
case CantDelete = "cant_delete"
case CantDeleteFile = "cant_delete_file"
case CantDeleteMessage = "cant_delete_message"
case CantInvite = "cant_invite"
case CantInviteSelf = "cant_invite_self"
case CantKickFromGeneral = "cant_kick_from_general"
case CantKickFromLastChannel = "cant_kick_from_last_channel"
case CantKickSelf = "cant_kick_self"
case CantLeaveGeneral = "cant_leave_general"
case CantLeaveLastChannel = "cant_leave_last_channel"
case CantUpdateMessage = "cant_update_message"
case ChannelNotFound = "channel_not_found"
case ComplianceExportsPreventDeletion = "compliance_exports_prevent_deletion"
case EditWindowClosed = "edit_window_closed"
case FileCommentNotFound = "file_comment_not_found"
case FileDeleted = "file_deleted"
case FileNotFound = "file_not_found"
case FileNotShared = "file_not_shared"
case GroupContainsOthers = "group_contains_others"
case InvalidArgName = "invalid_arg_name"
case InvalidArrayArg = "invalid_array_arg"
case InvalidAuth = "invalid_auth"
case InvalidChannel = "invalid_channel"
case InvalidCharSet = "invalid_charset"
case InvalidClientID = "invalid_client_id"
case InvalidCode = "invalid_code"
case InvalidFormData = "invalid_form_data"
case InvalidName = "invalid_name"
case InvalidPostType = "invalid_post_type"
case InvalidPresence = "invalid_presence"
case InvalidTS = "invalid_timestamp"
case InvalidTSLatest = "invalid_ts_latest"
case InvalidTSOldest = "invalid_ts_oldest"
case IsArchived = "is_archived"
case LastMember = "last_member"
case LastRAChannel = "last_ra_channel"
case MessageNotFound = "message_not_found"
case MessageTooLong = "msg_too_long"
case MigrationInProgress = "migration_in_progress"
case MissingDuration = "missing_duration"
case MissingPostType = "missing_post_type"
case MissingScope = "missing_scope"
case NameTaken = "name_taken"
case NoChannel = "no_channel"
case NoComment = "no_comment"
case NoItemSpecified = "no_item_specified"
case NoReaction = "no_reaction"
case NoText = "no_text"
case NotArchived = "not_archived"
case NotAuthed = "not_authed"
case NotEnoughUsers = "not_enough_users"
case NotInChannel = "not_in_channel"
case NotInGroup = "not_in_group"
case NotPinned = "not_pinned"
case NotStarred = "not_starred"
case OverPaginationLimit = "over_pagination_limit"
case PaidOnly = "paid_only"
case PermissionDenied = "perimssion_denied"
case PostingToGeneralChannelDenied = "posting_to_general_channel_denied"
case RateLimited = "rate_limited"
case RequestTimeout = "request_timeout"
case RestrictedAction = "restricted_action"
case SnoozeEndFailed = "snooze_end_failed"
case SnoozeFailed = "snooze_failed"
case SnoozeNotActive = "snooze_not_active"
case TooLong = "too_long"
case TooManyEmoji = "too_many_emoji"
case TooManyReactions = "too_many_reactions"
case TooManyUsers = "too_many_users"
case UnknownError
case UnknownType = "unknown_type"
case UserDisabled = "user_disabled"
case UserDoesNotOwnChannel = "user_does_not_own_channel"
case UserIsBot = "user_is_bot"
case UserIsRestricted = "user_is_restricted"
case UserIsUltraRestricted = "user_is_ultra_restricted"
case UserListNotSupplied = "user_list_not_supplied"
case UserNotFound = "user_not_found"
case UserNotVisible = "user_not_visible"
case accountInactive = "account_inactive"
case alreadyArchived = "already_archived"
case alreadyInChannel = "already_in_channel"
case alreadyPinned = "already_pinned"
case alreadyReacted = "already_reacted"
case alreadyStarred = "already_starred"
case badClientSecret = "bad_client_secret"
case badRedirectURI = "bad_redirect_uri"
case badTimeStamp = "bad_timestamp"
case cantArchiveGeneral = "cant_archive_general"
case cantDelete = "cant_delete"
case cantDeleteFile = "cant_delete_file"
case cantDeleteMessage = "cant_delete_message"
case cantInvite = "cant_invite"
case cantInviteSelf = "cant_invite_self"
case cantKickFromGeneral = "cant_kick_from_general"
case cantKickFromLastChannel = "cant_kick_from_last_channel"
case cantKickSelf = "cant_kick_self"
case cantLeaveGeneral = "cant_leave_general"
case cantLeaveLastChannel = "cant_leave_last_channel"
case cantUpdateMessage = "cant_update_message"
case channelNotFound = "channel_not_found"
case complianceExportsPreventDeletion = "compliance_exports_prevent_deletion"
case editWindowClosed = "edit_window_closed"
case fileCommentNotFound = "file_comment_not_found"
case fileDeleted = "file_deleted"
case fileNotFound = "file_not_found"
case fileNotShared = "file_not_shared"
case groupContainsOthers = "group_contains_others"
case invalidArgName = "invalid_arg_name"
case invalidArrayArg = "invalid_array_arg"
case invalidAuth = "invalid_auth"
case invalidChannel = "invalid_channel"
case invalidCharSet = "invalid_charset"
case invalidClientID = "invalid_client_id"
case invalidCode = "invalid_code"
case invalidFormData = "invalid_form_data"
case invalidName = "invalid_name"
case invalidPostType = "invalid_post_type"
case invalidPresence = "invalid_presence"
case invalidTS = "invalid_timestamp"
case invalidTSLatest = "invalid_ts_latest"
case invalidTSOldest = "invalid_ts_oldest"
case isArchived = "is_archived"
case lastMember = "last_member"
case lastRAChannel = "last_ra_channel"
case messageNotFound = "message_not_found"
case messageTooLong = "msg_too_long"
case migrationInProgress = "migration_in_progress"
case missingDuration = "missing_duration"
case missingPostType = "missing_post_type"
case missingScope = "missing_scope"
case nameTaken = "name_taken"
case noChannel = "no_channel"
case noComment = "no_comment"
case noItemSpecified = "no_item_specified"
case noReaction = "no_reaction"
case noText = "no_text"
case notArchived = "not_archived"
case notAuthed = "not_authed"
case notEnoughUsers = "not_enough_users"
case notInChannel = "not_in_channel"
case notInGroup = "not_in_group"
case notPinned = "not_pinned"
case notStarred = "not_starred"
case overPaginationLimit = "over_pagination_limit"
case paidOnly = "paid_only"
case permissionDenied = "perimssion_denied"
case postingToGeneralChannelDenied = "posting_to_general_channel_denied"
case rateLimited = "rate_limited"
case requestTimeout = "request_timeout"
case restrictedAction = "restricted_action"
case snoozeEndFailed = "snooze_end_failed"
case snoozeFailed = "snooze_failed"
case snoozeNotActive = "snooze_not_active"
case tooLong = "too_long"
case tooManyEmoji = "too_many_emoji"
case tooManyReactions = "too_many_reactions"
case tooManyUsers = "too_many_users"
case unknownError
case unknownType = "unknown_type"
case userDisabled = "user_disabled"
case userDoesNotOwnChannel = "user_does_not_own_channel"
case userIsBot = "user_is_bot"
case userIsRestricted = "user_is_restricted"
case userIsUltraRestricted = "user_is_ultra_restricted"
case userListNotSupplied = "user_list_not_supplied"
case userNotFound = "user_not_found"
case userNotVisible = "user_not_visible"
// Client
case ClientNetworkError
case ClientJSONError
case ClientOAuthError
case clientNetworkError
case clientJSONError
case clientOAuthError
// HTTP
case TooManyRequests
case UnknownHTTPError
case tooManyRequests
case unknownHTTPError
}
+119 -119
View File
@@ -25,62 +25,62 @@ import Foundation
internal enum Endpoint: String {
case APITest = "api.test"
case AuthRevoke = "auth.revoke"
case AuthTest = "auth.test"
case ChannelsHistory = "channels.history"
case ChannelsInfo = "channels.info"
case ChannelsList = "channels.list"
case ChannelsMark = "channels.mark"
case ChannelsSetPurpose = "channels.setPurpose"
case ChannelsSetTopic = "channels.setTopic"
case ChatDelete = "chat.delete"
case ChatPostMessage = "chat.postMessage"
case ChatMeMessage = "chat.meMessage"
case ChatUpdate = "chat.update"
case DNDInfo = "dnd.info"
case DNDTeamInfo = "dnd.teamInfo"
case EmojiList = "emoji.list"
case FilesCommentsAdd = "files.comments.add"
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"
case GroupsInfo = "groups.info"
case GroupsList = "groups.list"
case GroupsMark = "groups.mark"
case GroupsOpen = "groups.open"
case GroupsSetPurpose = "groups.setPurpose"
case GroupsSetTopic = "groups.setTopic"
case IMClose = "im.close"
case IMHistory = "im.history"
case IMList = "im.list"
case IMMark = "im.mark"
case IMOpen = "im.open"
case MPIMClose = "mpim.close"
case MPIMHistory = "mpim.history"
case MPIMList = "mpim.list"
case MPIMMark = "mpim.mark"
case MPIMOpen = "mpim.open"
case OAuthAccess = "oauth.access"
case PinsAdd = "pins.add"
case PinsRemove = "pins.remove"
case ReactionsAdd = "reactions.add"
case ReactionsGet = "reactions.get"
case ReactionsList = "reactions.list"
case ReactionsRemove = "reactions.remove"
case RTMStart = "rtm.start"
case StarsAdd = "stars.add"
case StarsRemove = "stars.remove"
case TeamInfo = "team.info"
case UsersGetPresence = "users.getPresence"
case UsersInfo = "users.info"
case UsersList = "users.list"
case UsersSetActive = "users.setActive"
case UsersSetPresence = "users.setPresence"
case apiTest = "api.test"
case authRevoke = "auth.revoke"
case authTest = "auth.test"
case channelsHistory = "channels.history"
case channelsInfo = "channels.info"
case channelsList = "channels.list"
case channelsMark = "channels.mark"
case channelsSetPurpose = "channels.setPurpose"
case channelsSetTopic = "channels.setTopic"
case chatDelete = "chat.delete"
case chatPostMessage = "chat.postMessage"
case chatMeMessage = "chat.meMessage"
case chatUpdate = "chat.update"
case dndInfo = "dnd.info"
case dndTeamInfo = "dnd.teamInfo"
case emojiList = "emoji.list"
case filesCommentsAdd = "files.comments.add"
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"
case groupsInfo = "groups.info"
case groupsList = "groups.list"
case groupsMark = "groups.mark"
case groupsOpen = "groups.open"
case groupsSetPurpose = "groups.setPurpose"
case groupsSetTopic = "groups.setTopic"
case imClose = "im.close"
case imHistory = "im.history"
case imList = "im.list"
case imMark = "im.mark"
case imOpen = "im.open"
case mpimClose = "mpim.close"
case mpimHistory = "mpim.history"
case mpimList = "mpim.list"
case mpimMark = "mpim.mark"
case mpimOpen = "mpim.open"
case oauthAccess = "oauth.access"
case pinsAdd = "pins.add"
case pinsRemove = "pins.remove"
case reactionsAdd = "reactions.add"
case reactionsGet = "reactions.get"
case reactionsList = "reactions.list"
case reactionsRemove = "reactions.remove"
case rtmStart = "rtm.start"
case starsAdd = "stars.add"
case starsRemove = "stars.remove"
case teamInfo = "team.info"
case usersGetPresence = "users.getPresence"
case usersInfo = "users.info"
case usersList = "users.list"
case usersSetActive = "users.setActive"
case usersSetPresence = "users.setPresence"
}
public final class WebAPI {
@@ -88,24 +88,24 @@ public final class WebAPI {
public typealias FailureClosure = (_ error: SlackError)->Void
public enum InfoType: String {
case Purpose = "purpose"
case Topic = "topic"
case purpose = "purpose"
case topic = "topic"
}
public enum ParseMode: String {
case Full = "full"
case None = "none"
case full = "full"
case none = "none"
}
public enum Presence: String {
case Auto = "auto"
case Away = "away"
case auto = "auto"
case away = "away"
}
fileprivate enum ChannelType: String {
case Channel = "channel"
case Group = "group"
case IM = "im"
case channel = "channel"
case group = "group"
case im = "im"
}
fileprivate let networkInterface: NetworkInterface
@@ -119,7 +119,7 @@ public final class WebAPI {
//MARK: - RTM
public func rtmStart(_ simpleLatest: Bool? = nil, noUnreads: Bool? = nil, mpimAware: Bool? = nil, success: ((_ response: [String: Any])->Void)?, failure: FailureClosure?) {
let parameters: [String: Any?] = ["simple_latest": simpleLatest, "no_unreads": noUnreads, "mpim_aware": mpimAware]
networkInterface.request(.RTMStart, token: token, parameters: WebAPI.filterNilParameters(parameters), successClosure: {
networkInterface.request(.rtmStart, token: token, parameters: WebAPI.filterNilParameters(parameters), successClosure: {
(response) -> Void in
success?(response)
}) {(error) -> Void in
@@ -129,7 +129,7 @@ public final class WebAPI {
//MARK: - Auth
public func authenticationTest(_ success: ((_ authenticated: Bool)->Void)?, failure: FailureClosure?) {
networkInterface.request(.AuthTest, token: token, parameters: nil, successClosure: {
networkInterface.request(.authTest, token: token, parameters: nil, successClosure: {
(response) -> Void in
success?(true)
}) {(error) -> Void in
@@ -139,7 +139,7 @@ public final class WebAPI {
public static func oauthAccess(_ clientID: String, clientSecret: String, code: String, redirectURI: String? = nil, success: ((_ response: [String: Any])->Void)?, failure: ((SlackError)->Void)?) {
let parameters: [String: Any?] = ["client_id": clientID, "client_secret": clientSecret, "code": code, "redirect_uri": redirectURI]
NetworkInterface().request(.OAuthAccess, parameters: filterNilParameters(parameters), successClosure: {
NetworkInterface().request(.oauthAccess, parameters: filterNilParameters(parameters), successClosure: {
(response) -> Void in
success?(response)
}) {(error) -> Void in
@@ -149,7 +149,7 @@ public final class WebAPI {
public static func oauthRevoke(_ token: String, test: Bool? = nil, success: ((_ revoked:Bool)->Void)?, failure: ((SlackError)->Void)?) {
let parameters: [String: Any?] = ["token": token, "test": test]
NetworkInterface().request(.AuthRevoke, parameters: filterNilParameters(parameters), successClosure: {
NetworkInterface().request(.authRevoke, parameters: filterNilParameters(parameters), successClosure: {
(response) -> Void in
success?(true)
}) {(error) -> Void in
@@ -159,7 +159,7 @@ public final class WebAPI {
//MARK: - Channels
public func channelHistory(_ id: String, latest: String = "\(Date().timeIntervalSince1970)", oldest: String = "0", inclusive: Bool = false, count: Int = 100, unreads: Bool = false, success: ((_ history: History)->Void)?, failure: FailureClosure?) {
history(.ChannelsHistory, id: id, latest: latest, oldest: oldest, inclusive: inclusive, count: count, unreads: unreads, success: {
history(.channelsHistory, id: id, latest: latest, oldest: oldest, inclusive: inclusive, count: count, unreads: unreads, success: {
(history) -> Void in
success?(history)
}) {(error) -> Void in
@@ -168,7 +168,7 @@ public final class WebAPI {
}
public func channelInfo(_ id: String, success: ((_ channel: Channel)->Void)?, failure: FailureClosure?) {
info(.ChannelsInfo, type:ChannelType.Channel, id: id, success: {
info(.channelsInfo, type:.channel, id: id, success: {
(channel) -> Void in
success?(channel)
}) { (error) -> Void in
@@ -177,7 +177,7 @@ public final class WebAPI {
}
public func channelsList(_ excludeArchived: Bool = false, success: ((_ channels: [[String: Any]]?)->Void)?, failure: FailureClosure?) {
list(.ChannelsList, type:ChannelType.Channel, excludeArchived: excludeArchived, success: {
list(.channelsList, type:.channel, excludeArchived: excludeArchived, success: {
(channels) -> Void in
success?(channels)
}) {(error) -> Void in
@@ -186,7 +186,7 @@ public final class WebAPI {
}
public func markChannel(_ channel: String, timestamp: String, success: ((_ ts: String)->Void)?, failure: FailureClosure?) {
mark(.ChannelsMark, channel: channel, timestamp: timestamp, success: {
mark(.channelsMark, channel: channel, timestamp: timestamp, success: {
(ts) -> Void in
success?(timestamp)
}) {(error) -> Void in
@@ -195,7 +195,7 @@ public final class WebAPI {
}
public func setChannelPurpose(_ channel: String, purpose: String, success: ((_ purposeSet: Bool)->Void)?, failure: FailureClosure?) {
setInfo(.ChannelsSetPurpose, type: .Purpose, channel: channel, text: purpose, success: {
setInfo(.channelsSetPurpose, type: .purpose, channel: channel, text: purpose, success: {
(purposeSet) -> Void in
success?(purposeSet)
}) { (error) -> Void in
@@ -204,7 +204,7 @@ public final class WebAPI {
}
public func setChannelTopic(_ channel: String, topic: String, success: ((_ topicSet: Bool)->Void)?, failure: FailureClosure?) {
setInfo(.ChannelsSetTopic, type: .Topic, channel: channel, text: topic, success: {
setInfo(.channelsSetTopic, type: .topic, channel: channel, text: topic, success: {
(topicSet) -> Void in
success?(topicSet)
}) {(error) -> Void in
@@ -215,7 +215,7 @@ public final class WebAPI {
//MARK: - Messaging
public func deleteMessage(_ channel: String, ts: String, success: ((_ deleted: Bool)->Void)?, failure: FailureClosure?) {
let parameters: [String: Any] = ["channel": channel, "ts": ts]
networkInterface.request(.ChatDelete, token: token, parameters: parameters, successClosure: { (response) -> Void in
networkInterface.request(.chatDelete, token: token, parameters: parameters, successClosure: { (response) -> Void in
success?(true)
}) {(error) -> Void in
failure?(error)
@@ -224,7 +224,7 @@ public final class WebAPI {
public func sendMessage(_ channel: String, text: String, username: String? = nil, asUser: Bool? = nil, parse: ParseMode? = nil, linkNames: Bool? = nil, attachments: [Attachment?]? = nil, unfurlLinks: Bool? = nil, unfurlMedia: Bool? = nil, iconURL: String? = nil, iconEmoji: String? = nil, success: (((ts: String?, channel: String?))->Void)?, failure: FailureClosure?) {
let parameters: [String: Any?] = ["channel": channel, "text": text.slackFormatEscaping, "as_user": asUser, "parse": parse?.rawValue, "link_names": linkNames, "unfurl_links": unfurlLinks, "unfurlMedia": unfurlMedia, "username": username, "icon_url": iconURL, "icon_emoji": iconEmoji, "attachments": encodeAttachments(attachments)]
networkInterface.request(.ChatPostMessage, token: token, parameters: WebAPI.filterNilParameters(parameters), successClosure: {
networkInterface.request(.chatPostMessage, token: token, parameters: WebAPI.filterNilParameters(parameters), successClosure: {
(response) -> Void in
success?((ts: response["ts"] as? String, response["channel"] as? String))
}) {(error) -> Void in
@@ -234,7 +234,7 @@ public final class WebAPI {
public func sendMeMessage(_ channel: String, text: String, success: (((ts: String?, channel: String?))->Void)?, failure: FailureClosure?) {
let parameters: [String: Any?] = ["channel": channel, "text": text.slackFormatEscaping]
networkInterface.request(.ChatMeMessage, token: token, parameters: WebAPI.filterNilParameters(parameters), successClosure: {
networkInterface.request(.chatMeMessage, token: token, parameters: WebAPI.filterNilParameters(parameters), successClosure: {
(response) -> Void in
success?((ts: response["ts"] as? String, response["channel"] as? String))
}) {(error) -> Void in
@@ -242,9 +242,9 @@ public final class WebAPI {
}
}
public func updateMessage(_ channel: String, ts: String, message: String, attachments: [Attachment?]? = nil, parse:ParseMode = .None, linkNames: Bool = false, success: ((_ updated: Bool)->Void)?, failure: FailureClosure?) {
public func updateMessage(_ channel: String, ts: String, message: String, attachments: [Attachment?]? = nil, parse:ParseMode = .none, linkNames: Bool = false, success: ((_ updated: Bool)->Void)?, failure: FailureClosure?) {
let parameters: [String: Any?] = ["channel": channel, "ts": ts, "text": message.slackFormatEscaping, "parse": parse.rawValue, "link_names": linkNames, "attachments": encodeAttachments(attachments)]
networkInterface.request(.ChatUpdate, token: token, parameters: WebAPI.filterNilParameters(parameters), successClosure: {
networkInterface.request(.chatUpdate, token: token, parameters: WebAPI.filterNilParameters(parameters), successClosure: {
(response) -> Void in
success?(true)
}) {(error) -> Void in
@@ -255,7 +255,7 @@ public final class WebAPI {
//MARK: - Do Not Disturb
public func dndInfo(_ user: String? = nil, success: ((_ status: DoNotDisturbStatus)->Void)?, failure: FailureClosure?) {
let parameters: [String: Any?] = ["user": user]
networkInterface.request(.DNDInfo, token: token, parameters: WebAPI.filterNilParameters(parameters), successClosure: {
networkInterface.request(.dndInfo, token: token, parameters: WebAPI.filterNilParameters(parameters), successClosure: {
(response) -> Void in
success?(DoNotDisturbStatus(status: response))
}) {(error) -> Void in
@@ -265,7 +265,7 @@ public final class WebAPI {
public func dndTeamInfo(_ users: [String]? = nil, success: ((_ statuses: [String: DoNotDisturbStatus])->Void)?, failure: FailureClosure?) {
let parameters: [String: Any?] = ["users": users?.joined(separator: ",")]
networkInterface.request(.DNDTeamInfo, token: token, parameters: WebAPI.filterNilParameters(parameters), successClosure: {
networkInterface.request(.dndTeamInfo, token: token, parameters: WebAPI.filterNilParameters(parameters), successClosure: {
(response) -> Void in
guard let usersDictionary = response["users"] as? [String: Any] else {
success?([:])
@@ -279,7 +279,7 @@ public final class WebAPI {
//MARK: - Emoji
public func emojiList(_ success: ((_ emojiList: [String: Any]?)->Void)?, failure: FailureClosure?) {
networkInterface.request(.EmojiList, token: token, parameters: nil, successClosure: {
networkInterface.request(.emojiList, token: token, parameters: nil, successClosure: {
(response) -> Void in
success?(response["emoji"] as? [String: Any])
}) { (error) -> Void in
@@ -290,7 +290,7 @@ public final class WebAPI {
//MARK: - Files
public func deleteFile(_ fileID: String, success: ((_ deleted: Bool)->Void)?, failure: FailureClosure?) {
let parameters = ["file": fileID]
networkInterface.request(.FilesDelete, token: token, parameters: parameters as [String : Any]?, successClosure: {
networkInterface.request(.filesDelete, token: token, parameters: parameters as [String : Any]?, successClosure: {
(response) -> Void in
success?(true)
}) {(error) -> Void in
@@ -300,7 +300,7 @@ public final class WebAPI {
public func fileInfo(_ fileID: String, commentCount: Int = 100, totalPages: Int = 1, success: ((_ file: File)->Void)?, failure: FailureClosure?) {
let parameters: [String: Any] = ["file": fileID, "count": commentCount, "totalPages": totalPages]
networkInterface.request(.FilesInfo, token: token, parameters: parameters, successClosure: {
networkInterface.request(.filesInfo, token: token, parameters: parameters, successClosure: {
(response) in
var file = File(file: response["file"] as? [String: Any])
(response["comments"] as? [[String: Any]])?.forEach { comment in
@@ -316,7 +316,7 @@ public final class WebAPI {
}
public func uploadFile(_ file: Data, filename: String, filetype: String = "auto", title: String? = nil, initialComment: String? = nil, channels: [String]? = nil, success: ((_ file: File)->Void)?, failure: FailureClosure?) {
let parameters: [String: Any?] = ["file": file, "filename": filename, "filetype": filetype, "title": title, "initial_comment": initialComment, "channels": channels?.joined(separator: ",")]
let parameters: [String: Any?] = ["filename": filename, "filetype": filetype, "title": title, "initial_comment": initialComment, "channels": channels?.joined(separator: ",")]
networkInterface.uploadRequest(token, data: file, parameters: WebAPI.filterNilParameters(parameters), successClosure: {
(response) -> Void in
success?(File(file: response["file"] as? [String: Any]))
@@ -328,7 +328,7 @@ public final class WebAPI {
//MARK: - File Comments
public func addFileComment(_ fileID: String, comment: String, success: ((_ comment: Comment)->Void)?, failure: FailureClosure?) {
let parameters: [String: Any] = ["file": fileID, "comment": comment.slackFormatEscaping]
networkInterface.request(.FilesCommentsAdd, token: token, parameters: parameters, successClosure: {
networkInterface.request(.filesCommentsAdd, token: token, parameters: parameters, successClosure: {
(response) -> Void in
success?(Comment(comment: response["comment"] as? [String: Any]))
}) {(error) -> Void in
@@ -338,7 +338,7 @@ public final class WebAPI {
public func editFileComment(_ fileID: String, commentID: String, comment: String, success: ((_ comment: Comment)->Void)?, failure: FailureClosure?) {
let parameters: [String: Any] = ["file": fileID, "id": commentID, "comment": comment.slackFormatEscaping]
networkInterface.request(.FilesCommentsEdit, token: token, parameters: parameters, successClosure: {
networkInterface.request(.filesCommentsEdit, token: token, parameters: parameters, successClosure: {
(response) -> Void in
success?(Comment(comment: response["comment"] as? [String: Any]))
}) {(error) -> Void in
@@ -348,7 +348,7 @@ public final class WebAPI {
public func deleteFileComment(_ fileID: String, commentID: String, success: ((_ deleted: Bool?)->Void)?, failure: FailureClosure?) {
let parameters: [String: Any] = ["file": fileID, "id": commentID]
networkInterface.request(.FilesCommentsDelete, token: token, parameters: parameters, successClosure: {
networkInterface.request(.filesCommentsDelete, token: token, parameters: parameters, successClosure: {
(response) -> Void in
success?(true)
}) {(error) -> Void in
@@ -358,7 +358,7 @@ public final class WebAPI {
//MARK: - Groups
public func closeGroup(_ groupID: String, success: ((_ closed: Bool)->Void)?, failure: FailureClosure?) {
close(.GroupsClose, channelID: groupID, success: {
close(.groupsClose, channelID: groupID, success: {
(closed) -> Void in
success?(closed)
}) {(error) -> Void in
@@ -367,7 +367,7 @@ public final class WebAPI {
}
public func groupHistory(_ id: String, latest: String = "\(Date().timeIntervalSince1970)", oldest: String = "0", inclusive: Bool = false, count: Int = 100, unreads: Bool = false, success: ((_ history: History)->Void)?, failure: FailureClosure?) {
history(.GroupsHistory, id: id, latest: latest, oldest: oldest, inclusive: inclusive, count: count, unreads: unreads, success: {
history(.groupsHistory, id: id, latest: latest, oldest: oldest, inclusive: inclusive, count: count, unreads: unreads, success: {
(history) -> Void in
success?(history)
}) {(error) -> Void in
@@ -376,7 +376,7 @@ public final class WebAPI {
}
public func groupInfo(_ id: String, success: ((_ channel: Channel)->Void)?, failure: FailureClosure?) {
info(.GroupsInfo, type:ChannelType.Group, id: id, success: {
info(.groupsInfo, type:.group, id: id, success: {
(channel) -> Void in
success?(channel)
}) {(error) -> Void in
@@ -385,7 +385,7 @@ public final class WebAPI {
}
public func groupsList(_ excludeArchived: Bool = false, success: ((_ channels: [[String: Any]]?)->Void)?, failure: FailureClosure?) {
list(.GroupsList, type:ChannelType.Group, excludeArchived: excludeArchived, success: {
list(.groupsList, type:.group, excludeArchived: excludeArchived, success: {
(channels) -> Void in
success?(channels)
}) {(error) -> Void in
@@ -394,7 +394,7 @@ public final class WebAPI {
}
public func markGroup(_ channel: String, timestamp: String, success: ((_ ts: String)->Void)?, failure: FailureClosure?) {
mark(.GroupsMark, channel: channel, timestamp: timestamp, success: {
mark(.groupsMark, channel: channel, timestamp: timestamp, success: {
(ts) -> Void in
success?(timestamp)
}) {(error) -> Void in
@@ -404,7 +404,7 @@ public final class WebAPI {
public func openGroup(_ channel: String, success: ((_ opened: Bool)->Void)?, failure: FailureClosure?) {
let parameters = ["channel":channel]
networkInterface.request(.GroupsOpen, token: token, parameters: parameters as [String: Any]?, successClosure: {
networkInterface.request(.groupsOpen, token: token, parameters: parameters as [String: Any]?, successClosure: {
(response) -> Void in
success?(true)
}) {(error) -> Void in
@@ -413,7 +413,7 @@ public final class WebAPI {
}
public func setGroupPurpose(_ channel: String, purpose: String, success: ((_ purposeSet: Bool)->Void)?, failure: FailureClosure?) {
setInfo(.GroupsSetPurpose, type: .Purpose, channel: channel, text: purpose, success: {
setInfo(.groupsSetPurpose, type: .purpose, channel: channel, text: purpose, success: {
(purposeSet) -> Void in
success?(purposeSet)
}) {(error) -> Void in
@@ -422,7 +422,7 @@ public final class WebAPI {
}
public func setGroupTopic(_ channel: String, topic: String, success: ((_ topicSet: Bool)->Void)?, failure: FailureClosure?) {
setInfo(.GroupsSetTopic, type: .Topic, channel: channel, text: topic, success: {
setInfo(.groupsSetTopic, type: .topic, channel: channel, text: topic, success: {
(topicSet) -> Void in
success?(topicSet)
}) {(error) -> Void in
@@ -432,7 +432,7 @@ public final class WebAPI {
//MARK: - IM
public func closeIM(_ channel: String, success: ((_ closed: Bool)->Void)?, failure: FailureClosure?) {
close(.IMClose, channelID: channel, success: {
close(.imClose, channelID: channel, success: {
(closed) -> Void in
success?(closed)
}) {(error) -> Void in
@@ -441,7 +441,7 @@ public final class WebAPI {
}
public func imHistory(_ id: String, latest: String = "\(Date().timeIntervalSince1970)", oldest: String = "0", inclusive: Bool = false, count: Int = 100, unreads: Bool = false, success: ((_ history: History)->Void)?, failure: FailureClosure?) {
history(.IMHistory, id: id, latest: latest, oldest: oldest, inclusive: inclusive, count: count, unreads: unreads, success: {
history(.imHistory, id: id, latest: latest, oldest: oldest, inclusive: inclusive, count: count, unreads: unreads, success: {
(history) -> Void in
success?(history)
}) {(error) -> Void in
@@ -450,7 +450,7 @@ public final class WebAPI {
}
public func imsList(_ excludeArchived: Bool = false, success: ((_ channels: [[String: Any]]?)->Void)?, failure: FailureClosure?) {
list(.IMList, type:ChannelType.IM, excludeArchived: excludeArchived, success: {
list(.imList, type:.im, excludeArchived: excludeArchived, success: {
(channels) -> Void in
success?(channels)
}) {(error) -> Void in
@@ -459,7 +459,7 @@ public final class WebAPI {
}
public func markIM(_ channel: String, timestamp: String, success: ((_ ts: String)->Void)?, failure: FailureClosure?) {
mark(.IMMark, channel: channel, timestamp: timestamp, success: {
mark(.imMark, channel: channel, timestamp: timestamp, success: {
(ts) -> Void in
success?(timestamp)
}) {(error) -> Void in
@@ -469,7 +469,7 @@ public final class WebAPI {
public func openIM(_ userID: String, success: ((_ imID: String?)->Void)?, failure: FailureClosure?) {
let parameters = ["user": userID]
networkInterface.request(.IMOpen, token: token, parameters: parameters as [String: Any]?, successClosure: {
networkInterface.request(.imOpen, token: token, parameters: parameters as [String: Any]?, successClosure: {
(response) -> Void in
let group = response["channel"] as? [String: Any]
success?(group?["id"] as? String)
@@ -480,7 +480,7 @@ public final class WebAPI {
//MARK: - MPIM
public func closeMPIM(_ channel: String, success: ((_ closed: Bool)->Void)?, failure: FailureClosure?) {
close(.MPIMClose, channelID: channel, success: {
close(.mpimClose, channelID: channel, success: {
(closed) -> Void in
success?(closed)
}) {(error) -> Void in
@@ -489,7 +489,7 @@ public final class WebAPI {
}
public func mpimHistory(_ id: String, latest: String = "\(Date().timeIntervalSince1970)", oldest: String = "0", inclusive: Bool = false, count: Int = 100, unreads: Bool = false, success: ((_ history: History)->Void)?, failure: FailureClosure?) {
history(.MPIMHistory, id: id, latest: latest, oldest: oldest, inclusive: inclusive, count: count, unreads: unreads, success: {
history(.mpimHistory, id: id, latest: latest, oldest: oldest, inclusive: inclusive, count: count, unreads: unreads, success: {
(history) -> Void in
success?(history)
}) {(error) -> Void in
@@ -498,7 +498,7 @@ public final class WebAPI {
}
public func mpimsList(_ excludeArchived: Bool = false, success: ((_ channels: [[String: Any]]?)->Void)?, failure: FailureClosure?) {
list(.MPIMList, type:ChannelType.Group, excludeArchived: excludeArchived, success: {
list(.mpimList, type:.group, excludeArchived: excludeArchived, success: {
(channels) -> Void in
success?(channels)
}) {(error) -> Void in
@@ -507,7 +507,7 @@ public final class WebAPI {
}
public func markMPIM(_ channel: String, timestamp: String, success: ((_ ts: String)->Void)?, failure: FailureClosure?) {
mark(.MPIMMark, channel: channel, timestamp: timestamp, success: {
mark(.mpimMark, channel: channel, timestamp: timestamp, success: {
(ts) -> Void in
success?(timestamp)
}) {(error) -> Void in
@@ -517,7 +517,7 @@ public final class WebAPI {
public func openMPIM(_ userIDs: [String], success: ((_ mpimID: String?)->Void)?, failure: FailureClosure?) {
let parameters = ["users": userIDs.joined(separator: ",")]
networkInterface.request(.MPIMOpen, token: token, parameters: parameters as [String: Any]?, successClosure: {
networkInterface.request(.mpimOpen, token: token, parameters: parameters as [String: Any]?, successClosure: {
(response) -> Void in
let group = response["group"] as? [String: Any]
success?(group?["id"] as? String)
@@ -528,7 +528,7 @@ public final class WebAPI {
//MARK: - Pins
public func pinItem(_ channel: String, file: String? = nil, fileComment: String? = nil, timestamp: String? = nil, success: ((_ pinned: Bool)->Void)?, failure: FailureClosure?) {
pin(.PinsAdd, channel: channel, file: file, fileComment: fileComment, timestamp: timestamp, success: {
pin(.pinsAdd, channel: channel, file: file, fileComment: fileComment, timestamp: timestamp, success: {
(ok) -> Void in
success?(ok)
}) {(error) -> Void in
@@ -537,7 +537,7 @@ public final class WebAPI {
}
public func unpinItem(_ channel: String, file: String? = nil, fileComment: String? = nil, timestamp: String? = nil, success: ((_ unpinned: Bool)->Void)?, failure: FailureClosure?) {
pin(.PinsRemove, channel: channel, file: file, fileComment: fileComment, timestamp: timestamp, success: {
pin(.pinsRemove, channel: channel, file: file, fileComment: fileComment, timestamp: timestamp, success: {
(ok) -> Void in
success?(ok)
}) {(error) -> Void in
@@ -558,7 +558,7 @@ public final class WebAPI {
//MARK: - Reactions
// One of file, file_comment, or the combination of channel and timestamp must be specified.
public func addReaction(_ name: String, file: String? = nil, fileComment: String? = nil, channel: String? = nil, timestamp: String? = nil, success: ((_ reacted: Bool)->Void)?, failure: FailureClosure?) {
react(.ReactionsAdd, name: name, file: file, fileComment: fileComment, channel: channel, timestamp: timestamp, success: {
react(.reactionsAdd, name: name, file: file, fileComment: fileComment, channel: channel, timestamp: timestamp, success: {
(ok) -> Void in
success?(ok)
}) {(error) -> Void in
@@ -568,7 +568,7 @@ public final class WebAPI {
// One of file, file_comment, or the combination of channel and timestamp must be specified.
public func removeReaction(_ name: String, file: String? = nil, fileComment: String? = nil, channel: String? = nil, timestamp: String? = nil, success: ((_ unreacted: Bool)->Void)?, failure: FailureClosure?) {
react(.ReactionsRemove, name: name, file: file, fileComment: fileComment, channel: channel, timestamp: timestamp, success: {
react(.reactionsRemove, name: name, file: file, fileComment: fileComment, channel: channel, timestamp: timestamp, success: {
(ok) -> Void in
success?(ok)
}) {(error) -> Void in
@@ -589,7 +589,7 @@ public final class WebAPI {
//MARK: - Stars
// One of file, file_comment, channel, or the combination of channel and timestamp must be specified.
public func addStar(_ file: String? = nil, fileComment: String? = nil, channel: String? = nil, timestamp: String? = nil, success: ((_ starred: Bool)->Void)?, failure: FailureClosure?) {
star(.StarsAdd, file: file, fileComment: fileComment, channel: channel, timestamp: timestamp, success: {
star(.starsAdd, file: file, fileComment: fileComment, channel: channel, timestamp: timestamp, success: {
(ok) -> Void in
success?(ok)
}) {(error) -> Void in
@@ -599,7 +599,7 @@ public final class WebAPI {
// One of file, file_comment, channel, or the combination of channel and timestamp must be specified.
public func removeStar(_ file: String? = nil, fileComment: String? = nil, channel: String? = nil, timestamp: String? = nil, success: ((_ unstarred: Bool)->Void)?, failure: FailureClosure?) {
star(.StarsRemove, file: file, fileComment: fileComment, channel: channel, timestamp: timestamp, success: {
star(.starsRemove, file: file, fileComment: fileComment, channel: channel, timestamp: timestamp, success: {
(ok) -> Void in
success?(ok)
}) {(error) -> Void in
@@ -620,7 +620,7 @@ public final class WebAPI {
//MARK: - Team
public func teamInfo(_ success: ((_ info: [String: Any]?)->Void)?, failure: FailureClosure?) {
networkInterface.request(.TeamInfo, token: token, parameters: nil, successClosure: {
networkInterface.request(.teamInfo, token: token, parameters: nil, successClosure: {
(response) -> Void in
success?(response["team"] as? [String: Any])
}) {(error) -> Void in
@@ -631,7 +631,7 @@ public final class WebAPI {
//MARK: - Users
public func userPresence(_ user: String, success: ((_ presence: String?)->Void)?, failure: FailureClosure?) {
let parameters: [String: Any] = ["user": user]
networkInterface.request(.UsersGetPresence, token: token, parameters: parameters, successClosure: {
networkInterface.request(.usersGetPresence, token: token, parameters: parameters, successClosure: {
(response) -> Void in
success?(response["presence"] as? String)
}){(error) -> Void in
@@ -641,7 +641,7 @@ public final class WebAPI {
public func userInfo(_ id: String, success: ((_ user: User)->Void)?, failure: FailureClosure?) {
let parameters: [String: Any] = ["user": id]
networkInterface.request(.UsersInfo, token: token, parameters: parameters, successClosure: {
networkInterface.request(.usersInfo, token: token, parameters: parameters, successClosure: {
(response) -> Void in
success?(User(user: response["user"] as? [String: Any]))
}) {(error) -> Void in
@@ -651,7 +651,7 @@ public final class WebAPI {
public func usersList(_ includePresence: Bool = false, success: ((_ userList: [[String: Any]]?)->Void)?, failure: FailureClosure?) {
let parameters: [String: Any] = ["presence": includePresence]
networkInterface.request(.UsersList, token: token, parameters: parameters, successClosure: {
networkInterface.request(.usersList, token: token, parameters: parameters, successClosure: {
(response) -> Void in
success?(response["members"] as? [[String: Any]])
}){(error) -> Void in
@@ -660,7 +660,7 @@ public final class WebAPI {
}
public func setUserActive(_ success: ((_ success: Bool)->Void)?, failure: FailureClosure?) {
networkInterface.request(.UsersSetActive, token: token, parameters: nil, successClosure: {
networkInterface.request(.usersSetActive, token: token, parameters: nil, successClosure: {
(response) -> Void in
success?(true)
}) {(error) -> Void in
@@ -670,7 +670,7 @@ public final class WebAPI {
public func setUserPresence(_ presence: Presence, success: ((_ success: Bool)->Void)?, failure: FailureClosure?) {
let parameters: [String: Any] = ["presence": presence.rawValue]
networkInterface.request(.UsersSetPresence, token: token, parameters: parameters, successClosure: {
networkInterface.request(.usersSetPresence, token: token, parameters: parameters, successClosure: {
(response) -> Void in
success?(true)
}) {(error) -> Void in
+1 -1
View File
@@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>3.1.0</string>
<string>3.1.5</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
+1 -1
View File
@@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>3.1.0</string>
<string>3.1.5</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
+1 -1
View File
@@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>3.1.0</string>
<string>3.1.5</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>