diff --git a/LICENSE b/LICENSE
index 8840448..aa6d2c1 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,6 +1,6 @@
The MIT License (MIT)
-Copyright (c) 2016 Peter Zignego
+Copyright (c) 2017 Peter Zignego
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
diff --git a/Package.swift b/Package.swift
index 91dcdf8..7dd348b 100644
--- a/Package.swift
+++ b/Package.swift
@@ -3,38 +3,12 @@ import PackageDescription
let package = Package(
name: "SlackKit",
targets: [
- Target(name: "SlackKit", dependencies: [
- "SKCore",
- "SKClient",
- "SKRTMAPI",
- "SKServer"
- ]),
- Target(name: "SKCore", dependencies: []),
- Target(name: "SKRTMAPI", dependencies: [
- "SKCore",
- "SKWebAPI"
- ]),
- Target(name: "SKWebAPI", dependencies: [
- "SKCore"
- ]),
- Target(name: "SKClient", dependencies: [
- "SKCore"
- ]),
- Target(name: "SKServer", dependencies: [
- "SKCore",
- "SKWebAPI"
- ])
+ Target(name: "SlackKit")
],
dependencies: [
- .Package(url: "https://github.com/Zewo/WebSocketClient", majorVersion: 0),
- .Package(url: "https://github.com/Zewo/HTTPServer", majorVersion: 0)
+ .Package(url: "https://github.com/SlackKit/SKCore", "4.0.0"),
+ .Package(url: "https://github.com/SlackKit/SKClient", "4.0.0"),
+ .Package(url: "https://github.com/SlackKit/SKRTMAPI", "4.0.0"),
+ .Package(url: "https://github.com/SlackKit/SKServer", "4.0.0")
]
)
-
-#if os(macOS) || os(iOS) || os(tvOS)
-let dependencies: [Package.Dependency] = [
- .Package(url: "https://github.com/daltoniam/Starscream", majorVersion: 2),
- .Package(url: "https://github.com/pvzig/swifter.git", majorVersion: 3)
-]
-package.dependencies.append(contentsOf: dependencies)
-#endif
diff --git a/Podfile b/Podfile
new file mode 100644
index 0000000..b9352bc
--- /dev/null
+++ b/Podfile
@@ -0,0 +1,22 @@
+use_frameworks!
+
+target 'SlackKit macOS' do
+ pod 'SKCore'
+ pod 'SKClient'
+ pod 'SKWebAPI'
+ pod 'SKRTMAPI'
+end
+
+target 'SlackKit iOS' do
+ pod 'SKCore'
+ pod 'SKClient'
+ pod 'SKWebAPI'
+ pod 'SKRTMAPI'
+end
+
+target 'SlackKit tvOS' do
+ pod 'SKCore'
+ pod 'SKClient'
+ pod 'SKWebAPI'
+ pod 'SKRTMAPI'
+end
\ No newline at end of file
diff --git a/README.md b/README.md
index 662196b..6ed49ce 100644
--- a/README.md
+++ b/README.md
@@ -1,316 +1,205 @@
-
+

-   [](https://cocoapods.org) [](https://github.com/Carthage/Carthage) [](https://github.com/apple/swift-package-manager)
-## SlackKit: A Swift Slack Client Library
+
+
+
+[](https://github.com/apple/swift-package-manager)
+[](https://github.com/Carthage/Carthage)
+[](https://cocoapods.org)
+
+## SlackKit: Slack Apps in Swift
### Description
-This is a Slack client library for OS X, iOS, and tvOS written in Swift. It's intended to expose all of the functionality of Slack's [Real Time Messaging API](https://api.slack.com/rtm) as well as the [web APIs](https://api.slack.com/web) that are accessible to [bot users](https://api.slack.com/bot-users). SlackKit also supports Slack’s [OAuth 2.0](https://api.slack.com/docs/oauth) flow including the [Add to Slack](https://api.slack.com/docs/slack-button) and [Sign in with Slack](https://api.slack.com/docs/sign-in-with-slack) buttons, [incoming webhooks](https://api.slack.com/incoming-webhooks), [slash commands](https://api.slack.com/slash-commands), and [message buttons](https://api.slack.com/docs/message-buttons).
+SlackKit makes it easy to build Slack apps in Swift.
-This is the **Swift 3** branch of SlackKit. SlackKit also has support for [Swift 2.3](https://github.com/pvzig/SlackKit/tree/swift2.3) and [Linux](https://github.com/pvzig/SlackKit/tree/linux).
-
-#### Building the SlackKit Framework
-To build the SlackKit project directly, first build the dependencies using Carthage or CocoaPods. To use the framework in your application, install it in one of the following ways:
+It's intended to expose all of the functionality of Slack's [Real Time Messaging API](https://api.slack.com/rtm) as well as the [web APIs](https://api.slack.com/web) that are accessible to [bot users](https://api.slack.com/bot-users). SlackKit also supports Slack’s [OAuth 2.0](https://api.slack.com/docs/oauth) flow including the [Add to Slack](https://api.slack.com/docs/slack-button) and [Sign in with Slack](https://api.slack.com/docs/sign-in-with-slack) buttons, [incoming webhooks](https://api.slack.com/incoming-webhooks), [slash commands](https://api.slack.com/slash-commands), and [message buttons](https://api.slack.com/docs/message-buttons).
### Installation
-#### CocoaPods
-
-Add SlackKit to your pod file:
-```
-use_frameworks!
-pod 'SlackKit', '~> 3.1.7'
-```
-and run
-```
-# Use CocoaPods version >= 1.1.0
-pod install
-```
-
-#### Carthage
-
-Add SlackKit to your Cartfile:
-```
-github "https://github.com/pvzig/slackkit.git"
-```
-and run
-```
-carthage bootstrap
-```
-
-Drag the built `SlackKit.framework` into your Xcode project.
-
#### Swift Package Manager
-Add SlackKit to your Package.swift
+Add `SlackKit` to your `Package.swift`
+
```swift
import PackageDescription
let package = Package(
dependencies: [
- .Package(url: "https://github.com/pvzig/SlackKit.git", majorVersion: 3)
+ .Package(url: "https://github.com/SlackKit/SlackKit.git", "4.0.0")
]
)
```
+#### Carthage
-Run `swift build` on your application’s main directory.
+Add `SlackKit` to your `Cartfile`:
-To use the library in your project import it:
```
-import SlackKit
+github "SlackKit/SlackKit"
+```
+
+#### CocoaPods
+Add `SlackKit` to your `Podfile`:
+
+```
+pod 'SlackKit'
```
### Usage
+#### The Basics
+Create a bot user with an API token:
+
+```swift
+import SlackKit
+
+let bot = SlackKit()
+bot.addRTMBotWithAPIToken("xoxb-SLACK-BOT-TOKEN")
+// Register for event notifications
+bot.notificationForEvent(.message) { (event, _) in
+ // Your bot logic here
+ print(event.message)
+}
+```
+
+or create a ready-to-launch Slack app with your [application’s `Client ID` and `Client Secret`](https://api.slack.com/apps):
+
+```swift
+import SlackKit
+
+let bot = SlackKit()
+let oauthConfig = OAuthConfig(clientID: "CLIENT_ID", clientSecret: "CLIENT_SECRET")
+bot.addServer(oauth: oauthConfig)
+```
+
+or just make calls to the Slack Web API:
+
+```swift
+import SlackKit
+
+let bot = SlackKit()
+bot.addWebAPIAccessWithToken("xoxb-SLACK-BOT-TOKEN")
+bot.webAPI?.authenticationTest(success: { (success) in
+ print(success)
+}, failure: nil)
+
+```
+
+#### Slash Commands
+After [configuring your slash command in Slack](https://my.slack.com/services/new/slash-commands) (you can also provide slash commands as part of a [Slack App](https://api.slack.com/slack-apps)), create a route, response middleware for that route, and add it to a responder:
+
+```swift
+let slackkit = SlackKit()
+let middleware = ResponseMiddleware(token: "SLASH_COMMAND_TOKEN", response: SKResponse(text: "👋"))
+let route = RequestRoute(path: "/hello", middleware: middleware)
+let responder = SlackKitResponder(routes: [route])
+slackkit.addServer(responder: responder)
+```
+When a user enters that slash command, it will hit your configured route and return the response you specified.
+
+#### Message Buttons
+Add [message buttons](https://api.slack.com/docs/message-buttons) to your responses for additional interactivity.
+
+To send messages with actions, add them to an attachment and send them using the Web API:
+
+```swift
+let helloAction = Action(name: "hello", text: "🌎")
+let attachment = Attachment(fallback: "Hello World", title: "Welcome to SlackKit", callbackID: "hello_world", actions: [helloAction])
+slackkit.webAPI?.sendMessage(channel: "CXXXXXX", text: "", attachments: [attachment], success: nil, failure: nil)
+```
+
+To respond to message actions, add a `RequestRoute` with `MessageActionMiddleware` using your app’s verification token to your `SlackKitResponder`:
+
+```swift
+let response = ResponseMiddleware(token: "SLACK_APP_VERIFICATION_TOKEN", response: SKResponse(text: "Hello, world!"))
+let actionRoute = MessageActionRoute(action: helloAction, middleware: response)
+let actionMiddleware = MessageActionMiddleware(token: "SLACK_APP_VERIFICATION_TOKEN", routes:[actionRoute])
+let actions = RequestRoute(path: "/actions", middleware: actionMiddleware)
+let responder = SlackKitResponder(routes: [actions])
+slackkit.addServer(responder: responder)
+```
#### OAuth
Slack has [many different oauth scopes](https://api.slack.com/docs/oauth-scopes) that can be combined in different ways. If your application does not request the proper OAuth scopes, your API calls will fail.
If you authenticate using OAuth and the Add to Slack or Sign in with Slack buttons this is handled for you.
-If you wish to make OAuth requests yourself, you can generate them using the `authorizeRequest` function on `SlackKit`’s `oauth` property:
-```swift
-func authorizeRequest(scope:[Scope], redirectURI: String, state: String = "slackkit", team: String? = nil)
-```
-
-For local development of things like OAuth, slash commands, and message buttons that require connecting over `https`, you may want to use a tool like [ngrok](https://ngrok.com) or [localtunnel](http://localtunnel.me).
-
-#### Incoming Webhooks
-After [configuring your incoming webhook in Slack](https://my.slack.com/services/new/incoming-webhook/), initialize IncomingWebhook with the provided URL and use `postMessage` to send messages.
-```swift
-let incoming = IncomingWebhook(url: "https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX")
-let message = Response(text: "Hello, World!")
-incoming.postMessage(message)
-```
-
-#### Slash Commands
-After [configuring your slash command in Slack](https://my.slack.com/services/new/slash-commands) (you can also provide slash commands as part of a [Slack App](https://api.slack.com/slack-apps)), initialize a webhook server with the token for the slash command, a configured route, and a response.
-```swift
-let response = Response(text: "Hello, World!", responseType: .inChannel)
-let webhook = WebhookServer(token: "SLASH-COMMAND-TOKEN", route: "hello_world", response: response)
-webhook.start()
-```
-When a user enters that slash command, it will hit your configured route and return the response you specified.
-
-To add additional routes and responses, you can use WebhookServer’s addRoute function:
-```swift
-func addRoute(route: String, response: Response)
-```
-
-#### Message Buttons
-If you are developing a Slack App and are authorizing using OAuth, you can use [message buttons](https://api.slack.com/docs/message-buttons).
-
-To send messages with actions, add them to an attachment:
-```swift
-let helloAction = Action(name: "hello_world", text: "Hello, World!")
-let attachment = Attachment(fallback: "Hello World Attachment", title: "Attachment with an Action Button", callbackID: "helloworld", actions: [helloAction])
-```
-
-To act on message actions, initialize an instance of the `MessageActionServer` using your app’s verification token, your specified interactive messages request URL route, and a `MessageActionResponder`:
-```swift
-let action = Action(name: "hello_world", text: "Hello, World!")
-let response = Response(text: "Hello, 🌎!", responseType: .inChannel)
-let responder = MessageActionResponder(responses: [(action, response)])
-let server = MessageActionServer(token: "SLACK-APP-VERIFICATION-TOKEN", route: "actions", responder: responder)
-server.start()
-```
-
-#### Bot Users
-To deploy a bot user using SlackKit you'll need a bearer token which identifies a single user. You can generate a [full access token or create one using OAuth 2](https://api.slack.com/web).
-
-Initialize a SlackKit instance using your [application’s Client ID and Client Secret](https://api.slack.com/apps) to set up SlackKit for OAuth authorization:
-```swift
-let bot = SlackKit(clientID: "CLIENT_ID", clientSecret: "CLIENT_SECRET")
-```
-
-or use a manually acquired token:
-```swift
-let bot = SlackKit(withAPIToken: "xoxp-YOUR-SLACK-API-TOKEN")
-```
-
-#### Client Connection Options
-You can also set options for a ping/pong interval, timeout interval, and automatic reconnection:
-```swift
-let options = ClientOptions(pingInterval: 2, timeout: 10, reconnect: false)
-let bot = SlackKit(clientID: "CLIENT_ID", clientSecret: "CLIENT_SECRET", clientOptions: options)
-```
-
-Once connected, the client will begin to consume any messages sent by the Slack RTM API.
+For local development of things like OAuth, slash commands, and message buttons, you may want to use a tool like [ngrok](https://ngrok.com).
#### Web API Methods
SlackKit currently supports the a subset of the Slack Web APIs that are available to bot users:
-- api.test
-- auth.revoke
-- auth.test
-- channels.history
-- channels.info
-- channels.list
-- channels.mark
-- channels.setPurpose
-- channels.setTopic
-- chat.delete
-- chat.meMessage
-- chat.postMessage
-- chat.update
-- emoji.list
-- files.comments.add
-- files.comments.edit
-- files.comments.delete
-- files.delete
-- files.info
-- files.upload
-- groups.close
-- groups.history
-- groups.info
-- groups.list
-- groups.mark
-- groups.open
-- groups.setPurpose
-- groups.setTopic
-- im.close
-- im.history
-- im.list
-- im.mark
-- im.open
-- mpim.close
-- mpim.history
-- mpim.list
-- mpim.mark
-- mpim.open
-- oauth.access
-- pins.add
-- pins.list
-- pins.remove
-- reactions.add
-- reactions.get
-- reactions.list
-- reactions.remove
-- rtm.start
-- stars.add
-- stars.remove
-- team.info
-- users.getPresence
-- users.info
-- users.list
-- users.setActive
-- users.setPresence
+| Web APIs |
+| ------------- |
+| `api.test`|
+| `api.revoke`|
+| `auth.test`|
+| `channels.history`|
+| `channels.info`|
+| `channels.list`|
+| `channels.mark`|
+| `channels.setPurpose`|
+| `channels.setTopic`|
+| `chat.delete`|
+| `chat.meMessage`|
+| `chat.postMessage`|
+| `chat.update`|
+| `emoji.list`|
+| `files.comments.add`|
+| `files.comments.edit`|
+| `files.comments.delete`|
+| `files.delete`|
+| `files.info`|
+| `files.upload`|
+| `groups.close`|
+| `groups.history`|
+| `groups.info`|
+| `groups.list`|
+| `groups.mark`|
+| `groups.open`|
+| `groups.setPurpose`|
+| `groups.setTopic`|
+| `im.close`|
+| `im.history`|
+| `im.list`|
+| `im.mark`|
+| `im.open`|
+| `mpim.close`|
+| `mpim.history`|
+| `mpim.list`|
+| `mpim.mark`|
+| `mpim.open`|
+| `oauth.access`|
+| `pins.add`|
+| `pins.list`|
+| `pins.remove`|
+| `reactions.add`|
+| `reactions.get`|
+| `reactions.list`|
+| `reactions.remove`|
+| `rtm.start`|
+| `stars.add`|
+| `stars.remove`|
+| `team.info`|
+| `users.getPresence`|
+| `users.info`|
+| `users.list`|
+| `users.setActive`|
+| `users.setPresence`|
-They can be accessed through a Client object’s `webAPI` property:
-```swift
-client.webAPI.authenticationTest({(auth) in
- print(auth)
-}, failure: {(error) in
- print(error)
-})
-```
+Don’t need the whole banana? Want more control over the low-level implementation details? Use the extensible modules SlackKit is built on:
-#### Delegate methods
-
-To receive delegate callbacks for events, register an object as the delegate for those events using the `onClientInitalization` block:
-```swift
-let bot = SlackKit(clientID: clientID, clientSecret: clientSecret)
-bot.onClientInitalization = { (client: Client) in
- DispatchQueue.main.async(execute: {
- client.messageEventsDelegate = self
- })
-}
-```
-
-Delegate callbacks contain a reference to the Client where the event occurred.
-
-There are a number of delegates that you can set to receive callbacks for certain events.
-
-##### ConnectionEventsDelegate
-```swift
-connected(_ client: Client)
-disconnected(_ client: Client)
-connectionFailed(_ client: Client, error: SlackError)
-```
-##### MessageEventsDelegate
-```swift
-sent(_ message: Message, client: Client)
-received(_ message: Message, client: Client)
-changed(_ message: Message, client: Client)
-deleted(_ message: Message?, client: Client)
-```
-##### ChannelEventsDelegate
-```swift
-userTypingIn(_ channel: Channel, user: User, client: Client)
-marked(_ channel: Channel, timestamp: String, client: Client)
-created(_ channel: Channel, client: Client)
-deleted(_ channel: Channel, client: Client)
-renamed(_ channel: Channel, client: Client)
-archived(_ channel: Channel, client: Client)
-historyChanged(_ channel: Channel, client: Client)
-joined(_ channel: Channel, client: Client)
-left(_ channel: Channel, client: Client)
-```
-##### DoNotDisturbEventsDelegate
-```swift
-updated(_ status: DoNotDisturbStatus, client: Client)
-userUpdated(_ status: DoNotDisturbStatus, user: User, client: Client)
-```
-##### GroupEventsDelegate
-```swift
-opened(_ group: Channel, client: Client)
-```
-##### FileEventsDelegate
-```swift
-processed(_ file: File, client: Client)
-madePrivate(_ file: File, client: Client)
-deleted(_ file: File, client: Client)
-commentAdded(_ file: File, comment: Comment, client: Client)
-commentEdited(_ file: File, comment: Comment, client: Client)
-commentDeleted(_ file: File, comment: Comment, client: Client)
-```
-##### PinEventsDelegate
-```swift
-pinned(_ item: Item, channel: Channel?, client: Client)
-unpinned(_ item: Item, channel: Channel?, client: Client)
-```
-##### StarEventsDelegate
-```swift
-starred(_ item: Item, starred: Bool, _ client: Client)
-```
-##### ReactionEventsDelegate
-```swift
-added(_ reaction: String, item: Item, itemUser: String, client: Client)
-removed(_ reaction: String, item: Item, itemUser: String, client: Client)
-```
-##### SlackEventsDelegate
-```swift
-preferenceChanged(_ preference: String, value: Any?, client: Client)
-userChanged(_ user: User, client: Client)
-presenceChanged(_ user: User, presence: String, client: Client)
-manualPresenceChanged(_ user: User, presence: String, client: Client)
-botEvent(_ bot: Bot, client: Client)
-```
-##### TeamEventsDelegate
-```swift
-userJoined(_ user: User, client: Client)
-planChanged(_ plan: String, client: Client)
-preferencesChanged(_ preference: String, value: Any?, client: Client)
-nameChanged(_ name: String, client: Client)
-domainChanged(_ domain: String, client: Client)
-emailDomainChanged(_ domain: String, client: Client)
-emojiChanged(_ client: Client)
-```
-##### SubteamEventsDelegate
-```swift
-event(_ userGroup: UserGroup, client: Client)
-selfAdded(_ subteamID: String, client: Client)
-selfRemoved(_ subteamID: String, client: Client)
-```
-##### TeamProfileEventsDelegate
-```swift
-changed(_ profile: CustomProfile, client: Client)
-deleted(_ profile: CustomProfile, client: Client)
-reordered(_ profile: CustomProfile, client: Client)
-```
+| Module | Slack Service |
+| ------------- |------------- |
+| **[SKClient](https://github.com/SlackKit/SKClient)** | Write your own client implementation|
+| **[SKRTMAPI](https://github.com/SlackKit/SKRTMAPI)** | Connect to the Slack RTM API|
+| **[SKServer](https://github.com/SlackKit/SKServer)** | Spin up a server|
+| **[SKWebAPI](https://github.com/SlackKit/SKWebAPI)** | Access the Slack Web API|
### Examples
-[Check out example applications here.](https://github.com/pvzig/SlackKit-examples)
+You can find the source code for several example applications [here](https://github.com/SlackKit/Examples).
+### Tutorials
+Coming soon!
### Get In Touch
-[@pvzig](https://twitter.com/pvzig)
+Twitter: [@pvzig](https://twitter.com/pvzig)
-
+Email:
diff --git a/SKClient/Sources/Client.swift b/SKClient/Sources/Client.swift
deleted file mode 100644
index 725cb1a..0000000
--- a/SKClient/Sources/Client.swift
+++ /dev/null
@@ -1,846 +0,0 @@
-//
-// Client.swift
-//
-// Copyright © 2017 Peter Zignego. All rights reserved.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-#if os(Linux)
-import Dispatch
-#endif
-import Foundation
-import SKCore
-
-open class Client {
-
- internal(set) public var authenticatedUser: User?
- internal(set) public var team: Team?
- internal(set) public var channels = [String: Channel]()
- internal(set) public var users = [String: User]()
- internal(set) public var userGroups = [String: UserGroup]()
- internal(set) public var bots = [String: Bot]()
- internal(set) public var files = [String: File]()
- internal(set) public var sentMessages = [String: Message]()
-
- public init(){}
-
- open func notificationForEvent(_ event: Event, type: EventType) {
- switch type {
- case .hello:
- // Connection event
- break
- case .ok:
- messageSent(event)
- case .message:
- if (event.subtype != nil) {
- messageDispatcher(event)
- } else {
- messageReceived(event)
- }
- case .userTyping:
- userTyping(event)
- case .channelMarked, .imMarked, .groupMarked:
- channelMarked(event)
- case .channelCreated, .imCreated:
- channelCreated(event)
- case .channelJoined, .groupJoined:
- channelJoined(event)
- case .channelLeft, .groupLeft:
- channelLeft(event)
- case .channelDeleted:
- channelDeleted(event)
- case .channelRenamed, .groupRename:
- channelRenamed(event)
- case .channelArchive, .groupArchive:
- channelArchived(event, archived: true)
- case .channelUnarchive, .groupUnarchive:
- channelArchived(event, archived: false)
- case .channelHistoryChanged, .imHistoryChanged, .groupHistoryChanged:
- channelHistoryChanged(event)
- case .dndUpdated:
- doNotDisturbUpdated(event)
- case .dndUpatedUser:
- doNotDisturbUserUpdated(event)
- case .imOpen, .groupOpen:
- open(event, open: true)
- case .imClose, .groupClose:
- open(event, open: false)
- case .fileCreated:
- processFile(event)
- case .fileShared:
- processFile(event)
- case .fileUnshared:
- processFile(event)
- case .filePublic:
- processFile(event)
- case .filePrivate:
- filePrivate(event)
- case .fileChanged:
- processFile(event)
- case .fileDeleted:
- deleteFile(event)
- case .fileCommentAdded:
- fileCommentAdded(event)
- case .fileCommentEdited:
- fileCommentEdited(event)
- case .fileCommentDeleted:
- fileCommentDeleted(event)
- case .pinAdded:
- pinAdded(event)
- case .pinRemoved:
- pinRemoved(event)
- case .pong:
- // Pong event
- break
- case .presenceChange:
- presenceChange(event)
- case .manualPresenceChange:
- manualPresenceChange(event)
- case .prefChange:
- changePreference(event)
- case .userChange:
- userChange(event)
- case .teamJoin:
- teamJoin(event)
- case .starAdded:
- itemStarred(event, star: true)
- case .starRemoved:
- itemStarred(event, star: false)
- case .reactionAdded:
- addedReaction(event)
- case .reactionRemoved:
- removedReaction(event)
- case .emojiChanged:
- emojiChanged(event)
- 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:
- teamPlanChange(event)
- case .teamPrefChange:
- teamPreferenceChange(event)
- case .teamRename:
- teamNameChange(event)
- case .teamDomainChange:
- teamDomainChange(event)
- case .emailDomainChange:
- emailDomainChange(event)
- case .teamProfileChange:
- teamProfileChange(event)
- case .teamProfileDelete:
- teamProfileDeleted(event)
- case .teamProfileReorder:
- teamProfileReordered(event)
- case .botAdded:
- bot(event)
- case .botChanged:
- bot(event)
- 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:
- // Team migration event
- break
- case .reconnectURL:
- // The reconnect_url event is currently unsupported and experimental.
- break
- case .subteamCreated, .subteamUpdated:
- subteam(event)
- case .subteamSelfAdded:
- subteamAddedSelf(event)
- case .subteamSelfRemoved:
- subteamRemovedSelf(event)
- case .error:
- // Error event
- break
- case .goodbye:
- // Goodbye event
- break
- case .unknown:
- // Unsupported event
- break
- }
- }
-
- //MARK: - Client setup
- open func initialSetup(JSON: [String: Any]) {
- team = Team(team: JSON["team"] as? [String: Any])
- authenticatedUser = User(user: JSON["self"] as? [String: Any])
- authenticatedUser?.doNotDisturbStatus = DoNotDisturbStatus(status: JSON["dnd"] as? [String: Any])
- enumerateObjects(JSON["users"] as? Array) { (user) in self.addUser(user) }
- enumerateObjects(JSON["channels"] as? Array) { (channel) in self.addChannel(channel) }
- enumerateObjects(JSON["groups"] as? Array) { (group) in self.addChannel(group) }
- enumerateObjects(JSON["mpims"] as? Array) { (mpim) in self.addChannel(mpim) }
- enumerateObjects(JSON["ims"] as? Array) { (ims) in self.addChannel(ims) }
- enumerateObjects(JSON["bots"] as? Array) { (bots) in self.addBot(bots) }
- enumerateSubteams(JSON["subteams"] as? [String: Any])
- }
-
- private func messageDispatcher(_ event:Event) {
- guard let value = event.subtype, let subtype = MessageSubtype(rawValue:value) else {
- return
- }
- switch subtype {
- case .messageChanged:
- messageChanged(event)
- case .messageDeleted:
- messageDeleted(event)
- default:
- messageReceived(event)
- }
- }
-}
-
-internal extension Client {
-
- //MARK: - Messages
- func messageSent(_ event: Event) {
- guard
- let reply = event.replyTo,
- let message = sentMessages[NSNumber(value: reply).stringValue],
- let channel = message.channel,
- let ts = message.ts
- else {
- return
- }
- message.ts = event.ts
- message.text = event.text
- channels[channel]?.messages[ts] = message
- }
-
- func messageReceived(_ event: Event) {
- guard
- let channel = event.channel,
- let message = event.message,
- let id = channel.id,
- let ts = message.ts
- else {
- return
- }
- channels[id]?.messages[ts] = message
- }
-
- func messageChanged(_ event: Event) {
- guard
- let id = event.channel?.id,
- let nested = event.nestedMessage,
- let ts = nested.ts
- else {
- return
- }
- channels[id]?.messages[ts] = nested
- }
-
- func messageDeleted(_ event: Event) {
- guard
- let id = event.channel?.id,
- let key = event.message?.deletedTs
- else {
- return
- }
- _ = channels[id]?.messages.removeValue(forKey: key)
- }
-
- //MARK: - Channels
- func userTyping(_ event: Event) {
- guard
- let channel = event.channel,
- let channelID = channel.id,
- let user = event.user,
- let userID = user.id,
- channels.index(forKey: channelID) != nil,
- !channels[channelID]!.usersTyping.contains(userID)
- else {
- return
- }
- channels[channelID]?.usersTyping.append(userID)
-
- let timeout = DispatchTime.now() + Double(Int64(5.0 * Double(UInt64.nanosecondsPerSecond))) / Double(UInt64.nanosecondsPerSecond)
- DispatchQueue.main.asyncAfter(deadline: timeout, execute: {
- if let index = self.channels[channelID]?.usersTyping.index(of: userID) {
- self.channels[channelID]?.usersTyping.remove(at: index)
- }
- })
- }
-
- func channelMarked(_ event: Event) {
- guard
- let channel = event.channel,
- let id = channel.id
- else {
- return
- }
- channels[id]?.lastRead = event.ts
- }
-
- func channelCreated(_ event: Event) {
- guard
- let channel = event.channel,
- let id = channel.id
- else {
- return
- }
- channels[id] = channel
- }
-
- func channelDeleted(_ event: Event) {
- guard
- let channel = event.channel,
- let id = channel.id
- else {
- return
- }
- channels.removeValue(forKey: id)
- }
-
- func channelJoined(_ event: Event) {
- guard
- let channel = event.channel,
- let id = channel.id
- else {
- return
- }
- channels[id] = event.channel
- }
-
- func channelLeft(_ event: Event) {
- guard
- let channel = event.channel,
- let id = channel.id
- else {
- return
- }
-
- if let userID = authenticatedUser?.id, let index = channels[id]?.members?.index(of: userID) {
- channels[id]?.members?.remove(at: index)
- }
- }
-
- func channelRenamed(_ event: Event) {
- guard
- let channel = event.channel,
- let id = channel.id
- else {
- return
- }
- channels[id]?.name = channel.name
- }
-
- func channelArchived(_ event: Event, archived: Bool) {
- guard
- let channel = event.channel,
- let id = channel.id
- else {
- return
- }
- channels[id]?.isArchived = archived
- }
-
- func channelHistoryChanged(_ event: Event) {
-
- }
-
- //MARK: - Do Not Disturb
- func doNotDisturbUpdated(_ event: Event) {
- guard let dndStatus = event.dndStatus else {
- return
- }
- authenticatedUser?.doNotDisturbStatus = dndStatus
- }
-
- func doNotDisturbUserUpdated(_ event: Event) {
- guard
- let dndStatus = event.dndStatus,
- let user = event.user,
- let id = user.id
- else {
- return
- }
- users[id]?.doNotDisturbStatus = dndStatus
- }
-
- //MARK: - IM & Group Open/Close
- func open(_ event: Event, open: Bool) {
- guard
- let channel = event.channel,
- let id = channel.id
- else {
- return
- }
- channels[id]?.isOpen = open
- }
-
- //MARK: - Files
- func processFile(_ event: Event) {
- guard
- let file = event.file,
- let id = file.id
- else {
- return
- }
- if let comment = file.initialComment, let commentID = comment.id {
- if files[id]?.comments[commentID] == nil {
- files[id]?.comments[commentID] = comment
- }
- }
- files[id] = file
- }
-
- func filePrivate(_ event: Event) {
- guard
- let file = event.file,
- let id = file.id
- else {
- return
- }
- files[id]?.isPublic = false
- }
-
- func deleteFile(_ event: Event) {
- guard
- let file = event.file,
- let id = file.id
- else {
- return
- }
- if files[id] != nil {
- files.removeValue(forKey: id)
- }
- }
-
- func fileCommentAdded(_ event: Event) {
- guard
- let file = event.file,
- let id = file.id,
- let comment = event.comment,
- let commentID = comment.id
- else {
- return
- }
- files[id]?.comments[commentID] = comment
- }
-
- func fileCommentEdited(_ event: Event) {
- guard
- let file = event.file,
- let id = file.id,
- let comment = event.comment,
- let commentID = comment.id
- else {
- return
- }
- files[id]?.comments[commentID]?.comment = comment.comment
- }
-
- func fileCommentDeleted(_ event: Event) {
- guard
- let file = event.file,
- let id = file.id,
- let comment = event.comment,
- let commentID = comment.id
- else {
- return
- }
- _ = files[id]?.comments.removeValue(forKey: commentID)
- }
-
- //MARK: - Pins
- func pinAdded(_ event: Event) {
- guard
- let id = event.channelID,
- let item = event.item
- else {
- return
- }
- channels[id]?.pinnedItems.append(item)
- }
-
- func pinRemoved(_ event: Event) {
- guard
- let id = event.channelID,
- let item = event.item
- else {
- return
- }
- if let pins = channels[id]?.pinnedItems.filter({$0 != item}) {
- channels[id]?.pinnedItems = pins
- }
- }
-
- //MARK: - Stars
- func itemStarred(_ event: Event, star: Bool) {
- guard
- let item = event.item,
- let type = item.type
- else {
- return
- }
- switch type {
- case "message":
- starMessage(item, star: star)
- case "file":
- starFile(item, star: star)
- case "file_comment":
- starComment(item)
- default:
- break
- }
- }
-
- func starMessage(_ item: Item, star: Bool) {
- guard
- let message = item.message,
- let ts = message.ts,
- let channel = item.channel,
- channels[channel]?.messages[ts] != nil
- else {
- return
- }
- channels[channel]?.messages[ts]?.isStarred = star
- }
-
- func starFile(_ item: Item, star: Bool) {
- guard
- let file = item.file,
- let id = file.id
- else {
- return
- }
- files[id]?.isStarred = star
- if let stars = files[id]?.stars {
- if star == true {
- files[id]?.stars = stars + 1
- } else {
- if stars > 0 {
- files[id]?.stars = stars - 1
- }
- }
- }
- }
-
- func starComment(_ item: Item) {
- guard
- let file = item.file,
- let id = file.id,
- let comment = item.comment,
- let commentID = comment.id
- else {
- return
- }
- files[id]?.comments[commentID] = comment
- }
-
- //MARK: - Reactions
- func addedReaction(_ event: Event) {
- guard
- let item = event.item,
- let type = item.type,
- let reaction = event.reaction,
- let userID = event.user?.id
- else {
- return
- }
- switch type {
- case "message":
- guard
- let channel = item.channel,
- let ts = item.ts,
- let message = channels[channel]?.messages[ts]
- else {
- return
- }
- message.reactions.append(Reaction(name: reaction, user: userID))
- case "file":
- guard let id = item.file?.id else {
- return
- }
- files[id]?.reactions.append(Reaction(name: reaction, user: userID))
- case "file_comment":
- guard
- let id = item.file?.id,
- let commentID = item.fileCommentID
- else {
- return
- }
- files[id]?.comments[commentID]?.reactions.append(Reaction(name: reaction, user: userID))
- default:
- break
- }
- }
-
- func removedReaction(_ event: Event) {
- guard
- let item = event.item,
- let type = item.type,
- let key = event.reaction,
- let userID = event.user?.id
- else {
- return
- }
- switch type {
- case "message":
- guard
- let channel = item.channel,
- let ts = item.ts,
- let message = channels[channel]?.messages[ts]
- else {
- return
- }
- message.reactions = message.reactions.filter({$0.name != key && $0.user != userID})
- case "file":
- guard
- let itemFile = item.file,
- let id = itemFile.id
- else {
- return
- }
- files[id]?.reactions = files[id]!.reactions.filter({$0.name != key && $0.user != userID})
- case "file_comment":
- guard
- let id = item.file?.id,
- let commentID = item.fileCommentID
- else {
- return
- }
- files[id]?.comments[commentID]?.reactions = files[id]!.comments[commentID]!.reactions.filter({$0.name != key && $0.user != userID})
- default:
- break
- }
- }
-
- //MARK: - Preferences
- func changePreference(_ event: Event) {
- guard let name = event.name else {
- return
- }
- authenticatedUser?.preferences?[name] = event.value
- }
-
- //Mark: - User Change
- func userChange(_ event: Event) {
- guard
- let user = event.user,
- let id = user.id
- else {
- return
- }
- let preferences = users[id]?.preferences
- users[id] = user
- users[id]?.preferences = preferences
- }
-
- //MARK: - User Presence
- func presenceChange(_ event: Event) {
- guard
- let user = event.user,
- let id = user.id
- else {
- return
- }
- users[id]?.presence = event.presence
- }
-
- //MARK: - Team
- func teamJoin(_ event: Event) {
- guard
- let user = event.user,
- let id = user.id
- else {
- return
- }
- users[id] = user
- }
-
- func teamPlanChange(_ event: Event) {
- guard let plan = event.plan else {
- return
- }
- team?.plan = plan
- }
-
- func teamPreferenceChange(_ event: Event) {
- guard let name = event.name else {
- return
- }
- team?.prefs?[name] = event.value
- }
-
- func teamNameChange(_ event: Event) {
- guard let name = event.name else {
- return
- }
- team?.name = name
- }
-
- func teamDomainChange(_ event: Event) {
- guard let domain = event.domain else {
- return
- }
- team?.domain = domain
- }
-
- func emailDomainChange(_ event: Event) {
- guard let domain = event.emailDomain else {
- return
- }
- team?.emailDomain = domain
- }
-
- func emojiChanged(_ event: Event) {
-
- }
-
- //MARK: - Bots
- func bot(_ event: Event) {
- guard
- let bot = event.bot,
- let id = bot.id
- else {
- return
- }
- bots[id] = bot
- }
-
- //MARK: - Subteams
- func subteam(_ event: Event) {
- guard
- let subteam = event.subteam,
- let id = subteam.id
- else {
- return
- }
- userGroups[id] = subteam
- }
-
- func subteamAddedSelf(_ event: Event) {
- guard
- let subteamID = event.subteamID,
- let _ = authenticatedUser?.userGroups
- else {
- return
- }
- authenticatedUser?.userGroups![subteamID] = subteamID
- }
-
- func subteamRemovedSelf(_ event: Event) {
- guard let subteamID = event.subteamID else {
- return
- }
- _ = authenticatedUser?.userGroups?.removeValue(forKey: subteamID)
- }
-
- //MARK: - Team Profiles
- func teamProfileChange(_ event: Event) {
- guard let profile = event.profile else {
- return
- }
- for user in users {
- for key in profile.fields.keys {
- users[user.0]?.profile?.customProfile?.fields[key]?.updateProfileField(profile.fields[key])
- }
- }
- }
-
- func teamProfileDeleted(_ event: Event) {
- guard let profile = event.profile else {
- return
- }
- for user in users {
- if let id = profile.fields.first?.0 {
- users[user.0]?.profile?.customProfile?.fields[id] = nil
- }
- }
- }
-
- func teamProfileReordered(_ event: Event) {
- guard let profile = event.profile else {
- return
- }
- for user in users {
- for key in profile.fields.keys {
- users[user.0]?.profile?.customProfile?.fields[key]?.ordering = profile.fields[key]?.ordering
- }
- }
- }
-
- //MARK: - Authenticated User
- func manualPresenceChange(_ event: Event) {
- guard let presence = event.presence else {
- return
- }
- authenticatedUser?.presence = presence
- }
-}
-
-public extension Client {
-
- fileprivate func addUser(_ aUser: [String: Any]) {
- let user = User(user: aUser)
- if let id = user.id {
- users[id] = user
- }
- }
-
- fileprivate func addChannel(_ aChannel: [String: Any]) {
- let channel = Channel(channel: aChannel)
- if let id = channel.id {
- channels[id] = channel
- }
- }
-
- fileprivate func addBot(_ aBot: [String: Any]) {
- let bot = Bot(bot: aBot)
- if let id = bot.id {
- bots[id] = bot
- }
- }
-
- fileprivate func enumerateSubteams(_ subteams: [String: Any]?) {
- if let subteams = subteams {
- if let all = subteams["all"] as? [[String: Any]] {
- for item in all {
- let u = UserGroup(userGroup: item)
- if let id = u.id {
- self.userGroups[id] = u
- }
- }
- }
- if let auth = subteams["self"] as? [String] {
- for item in auth {
- authenticatedUser?.userGroups = [String: String]()
- authenticatedUser?.userGroups?[item] = item
- }
- }
- }
- }
-
- // MARK: - Utilities
- fileprivate func enumerateObjects(_ array: [Any]?, initalizer: ([String: Any])-> Void) {
- if let array = array {
- for object in array {
- if let dictionary = object as? [String: Any] {
- initalizer(dictionary)
- }
- }
- }
- }
-}
diff --git a/SKClient/Supporting Files/Info.plist b/SKClient/Supporting Files/Info.plist
deleted file mode 100644
index 92ffb16..0000000
--- a/SKClient/Supporting Files/Info.plist
+++ /dev/null
@@ -1,26 +0,0 @@
-
-
-
-
- CFBundleDevelopmentRegion
- en
- CFBundleExecutable
- $(EXECUTABLE_NAME)
- CFBundleIdentifier
- $(PRODUCT_BUNDLE_IDENTIFIER)
- CFBundleInfoDictionaryVersion
- 6.0
- CFBundleName
- $(PRODUCT_NAME)
- CFBundlePackageType
- FMWK
- CFBundleShortVersionString
- 1.0
- CFBundleVersion
- $(CURRENT_PROJECT_VERSION)
- NSHumanReadableCopyright
- Copyright © 2017 Launch Software LLC. All rights reserved.
- NSPrincipalClass
-
-
-
diff --git a/SKClient/Supporting Files/SKClient.h b/SKClient/Supporting Files/SKClient.h
deleted file mode 100644
index 01dbd96..0000000
--- a/SKClient/Supporting Files/SKClient.h
+++ /dev/null
@@ -1,19 +0,0 @@
-//
-// SKClient.h
-// SKClient
-//
-// Created by Peter Zignego on 2/4/17.
-// Copyright © 2017 Launch Software LLC. All rights reserved.
-//
-
-#import
-
-//! Project version number for SKClient.
-FOUNDATION_EXPORT double SKClientVersionNumber;
-
-//! Project version string for SKClient.
-FOUNDATION_EXPORT const unsigned char SKClientVersionString[];
-
-// In this header, you should import all the public headers of your framework using statements like #import
-
-
diff --git a/SKCore/Sources/Action.swift b/SKCore/Sources/Action.swift
deleted file mode 100644
index e1db220..0000000
--- a/SKCore/Sources/Action.swift
+++ /dev/null
@@ -1,103 +0,0 @@
-//
-// Action.swift
-//
-// Copyright © 2017 Peter Zignego. All rights reserved.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-public struct Action {
-
- public let name: String?
- public let text: String?
- public let type: String?
- public let value: String?
- public let style: ActionStyle?
- public let confirm: Confirm?
-
- public init(action:[String: Any]?) {
- name = action?["name"] as? String
- text = action?["text"] as? String
- type = action?["type"] as? String
- value = action?["value"] as? String
- style = ActionStyle(rawValue: action?["style"] as? String ?? "")
- confirm = Confirm(confirm:action?["confirm"] as? [String: Any])
- }
-
- public init(name: String, text: String, style: ActionStyle = .defaultStyle, value: String? = nil, confirm: Confirm? = nil) {
- self.type = "button"
- self.name = name
- self.text = text
- self.value = value
- self.style = style
- self.confirm = confirm
- }
-
- public var dictionary: [String: Any] {
- var dict = [String: Any]()
- dict["name"] = name
- dict["text"] = text
- dict["type"] = type
- dict["value"] = value
- dict["style"] = style?.rawValue
- dict["confirm"] = confirm?.dictionary
- return dict
- }
-
- public struct Confirm {
-
- public let title: String?
- public let text: String?
- public let okText: String?
- public let dismissText: String?
-
- public init(confirm:[String: Any]?) {
- title = confirm?["title"] as? String
- text = confirm?["text"] as? String
- okText = confirm?["ok_text"] as? String
- dismissText = confirm?["dismiss_text"] as? String
- }
-
- public init(text: String, title: String? = nil, okText: String? = nil, dismissText: String? = nil) {
- self.text = text
- self.title = title
- self.okText = okText
- self.dismissText = dismissText
- }
-
- public var dictionary: [String: Any] {
- var dict = [String: Any]()
- dict["title"] = title
- dict["text"] = text
- dict["ok_text"] = okText
- dict["dismiss_text"] = dismissText
- return dict
- }
- }
-}
-
-public enum ActionStyle: String {
- case defaultStyle = "default"
- case primary = "primary"
- case danger = "danger"
-}
-
-public enum ResponseType: String {
- case inChannel = "in_channel"
- case ephemeral = "ephemeral"
-}
diff --git a/SKCore/Sources/Attachment.swift b/SKCore/Sources/Attachment.swift
deleted file mode 100644
index c19a4ed..0000000
--- a/SKCore/Sources/Attachment.swift
+++ /dev/null
@@ -1,131 +0,0 @@
-//
-// Attachment.swift
-//
-// Copyright © 2017 Peter Zignego. All rights reserved.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-public struct Attachment {
-
- public let fallback: String?
- public let callbackID: String?
- public let type: String?
- public let color: String?
- public let pretext: String?
- public let authorName: String?
- public let authorLink: String?
- public let authorIcon: String?
- public let title: String?
- public let titleLink: String?
- public let text: String?
- public let fields: [AttachmentField]?
- public let actions: [Action]?
- public let imageURL: String?
- public let thumbURL: String?
- public let footer: String?
- public let footerIcon: String?
- public let ts: Int?
-
- public let markdownEnabledFields: Set?
-
- public init(attachment: [String: Any]?) {
- fallback = attachment?["fallback"] as? String
- callbackID = attachment?["callback_id"] as? String
- type = attachment?["attachment_type"] as? String
- color = attachment?["color"] as? String
- pretext = attachment?["pretext"] as? String
- authorName = attachment?["author_name"] as? String
- authorLink = attachment?["author_link"] as? String
- authorIcon = attachment?["author_icon"] as? String
- title = attachment?["title"] as? String
- titleLink = attachment?["title_link"] as? String
- text = attachment?["text"] as? String
- imageURL = attachment?["image_url"] as? String
- thumbURL = attachment?["thumb_url"] as? String
- footer = attachment?["footer"] as? String
- footerIcon = attachment?["footer_icon"] as? String
- ts = attachment?["ts"] as? Int
- fields = (attachment?["fields"] as? [[String: Any]])?.map { AttachmentField(field: $0) }
- actions = (attachment?["actions"] as? [[String: Any]])?.map { Action(action: $0) }
-
- markdownEnabledFields = (attachment?["mrkdwn_in"] as? [String]).map { Set($0.flatMap(AttachmentTextField.init)) }
- }
-
- public init(fallback: String, title: String?, callbackID: String? = nil, type: String? = nil, colorHex: String? = nil, pretext: String? = nil, authorName: String? = nil, authorLink: String? = nil, authorIcon: String? = nil, titleLink: String? = nil, text: String? = nil, fields: [AttachmentField]? = nil, actions: [Action]? = nil, imageURL: String? = nil, thumbURL: String? = nil, footer: String? = nil, footerIcon:String? = nil, ts:Int? = nil, markdownFields: Set? = nil) {
- self.fallback = fallback
- self.callbackID = callbackID
- self.type = type
- self.color = colorHex
- self.pretext = pretext
- self.authorName = authorName
- self.authorLink = authorLink
- self.authorIcon = authorIcon
- self.title = title
- self.titleLink = titleLink
- self.text = text
- self.fields = fields
- self.actions = actions
- self.imageURL = imageURL
- self.thumbURL = thumbURL
- self.footer = footer
- self.footerIcon = footerIcon
- self.ts = ts
- self.markdownEnabledFields = markdownFields
- }
-
- public var dictionary: [String: Any] {
- var attachment = [String: Any]()
- attachment["fallback"] = fallback
- attachment["callback_id"] = callbackID
- attachment["attachment_type"] = type
- attachment["color"] = color
- attachment["pretext"] = pretext
- attachment["author_name"] = 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["mrkdwn_in"] = markdownEnabledFields?.map { $0.rawValue }
- return attachment
- }
-}
-
-public enum AttachmentColor: String {
- case good = "good"
- case warning = "warning"
- case danger = "danger"
-}
-
-public enum AttachmentTextField: String {
- case fallback = "fallback"
- case pretext = "pretext"
- case authorName = "author_name"
- case title = "title"
- case text = "text"
- case fields = "fields"
- case footer = "footer"
-}
diff --git a/SKCore/Sources/AttachmentField.swift b/SKCore/Sources/AttachmentField.swift
deleted file mode 100644
index 95d63b3..0000000
--- a/SKCore/Sources/AttachmentField.swift
+++ /dev/null
@@ -1,49 +0,0 @@
-//
-// AttachmentField.swift
-//
-// Copyright © 2017 Peter Zignego. All rights reserved.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-public struct AttachmentField {
-
- public let title: String?
- public let value: String?
- public let short: Bool?
-
- public init(field: [String: Any]?) {
- title = field?["title"] as? String
- value = field?["value"] as? String
- short = field?["short"] as? Bool
- }
-
- public init(title: String?, value: String?, short: Bool? = nil) {
- self.title = title
- self.value = value?.slackFormatEscaping
- self.short = short
- }
-
- public var dictionary: [String: Any] {
- var field = [String: Any]()
- field["title"] = title
- field["value"] = value
- field["short"] = short
- return field
- }
-}
diff --git a/SKCore/Sources/Bot.swift b/SKCore/Sources/Bot.swift
deleted file mode 100644
index a6c5d55..0000000
--- a/SKCore/Sources/Bot.swift
+++ /dev/null
@@ -1,41 +0,0 @@
-//
-// Bot.swift
-//
-// Copyright © 2017 Peter Zignego. All rights reserved.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-public struct Bot {
-
- public let id: String?
- public var botToken: String?
- public var name: String?
- public var icons: [String: Any]?
-
- public init(bot: [String: Any]?) {
- id = bot?["id"] as? String
- name = bot?["name"] as? String
- icons = bot?["icons"] as? [String: Any]
- }
-
- public init(botUser: [String: Any]?) {
- id = botUser?["bot_user_id"] as? String
- botToken = botUser?["bot_access_token"] as? String
- }
-}
diff --git a/SKCore/Sources/Channel.swift b/SKCore/Sources/Channel.swift
deleted file mode 100644
index 8bb6763..0000000
--- a/SKCore/Sources/Channel.swift
+++ /dev/null
@@ -1,89 +0,0 @@
-//
-// Channel.swift
-//
-// Copyright © 2017 Peter Zignego. All rights reserved.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-public struct Channel {
-
- public let id: String?
- public let created: Int?
- public let creator: String?
- public var name: String?
- public var isArchived: Bool?
- public var isGeneral: Bool?
- public let isGroup: Bool?
- public let isIM: Bool?
- public let isMPIM: Bool?
- public var user: String?
- public var isUserDeleted: Bool?
- public var isOpen: Bool?
- public var topic: Topic?
- public var purpose: Topic?
- public var isMember: Bool?
- public var lastRead: String?
- public var latest: Message?
- public var unread: Int?
- public var unreadCountDisplay: Int?
- public var hasPins: Bool?
- public var members: [String]?
- // Client use
- public var pinnedItems = [Item]()
- public var usersTyping = [String]()
- public var messages = [String: Message]()
-
- public init(channel: [String: Any]?) {
- id = channel?["id"] as? String
- name = channel?["name"] as? String
- created = channel?["created"] as? Int
- creator = channel?["creator"] as? String
- isArchived = channel?["is_archived"] as? Bool
- isGeneral = channel?["is_general"] as? Bool
- isGroup = channel?["is_group"] as? Bool
- isIM = channel?["is_im"] as? Bool
- isMPIM = channel?["is_mpim"] as? Bool
- isUserDeleted = channel?["is_user_deleted"] as? Bool
- user = channel?["user"] as? String
- isOpen = channel?["is_open"] as? Bool
- topic = Topic(topic: channel?["topic"] as? [String: Any])
- purpose = Topic(topic: channel?["purpose"] as? [String: Any])
- isMember = channel?["is_member"] as? Bool
- lastRead = channel?["last_read"] as? String
- unread = channel?["unread_count"] as? Int
- unreadCountDisplay = channel?["unread_count_display"] as? Int
- hasPins = channel?["has_pins"] as? Bool
- members = channel?["members"] as? [String]
-
- if let latestMesssageDictionary = channel?["latest"] as? [String: Any] {
- latest = Message(dictionary: latestMesssageDictionary)
- } else {
- latest = Message(ts: channel?["latest"] as? String)
- }
- }
-
- public init(id:String?) {
- self.id = id
- created = nil
- creator = nil
- isGroup = false
- isIM = false
- isMPIM = false
- }
-}
diff --git a/SKCore/Sources/Comment.swift b/SKCore/Sources/Comment.swift
deleted file mode 100644
index dac4706..0000000
--- a/SKCore/Sources/Comment.swift
+++ /dev/null
@@ -1,51 +0,0 @@
-//
-// Comment.swift
-//
-// Copyright © 2017 Peter Zignego. All rights reserved.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-public struct Comment: Equatable {
-
- public let id: String?
- public let user: String?
- public var created: Int?
- public var comment: String?
- public var starred: Bool?
- public var stars: Int?
- public var reactions = [Reaction]()
-
- public init(comment:[String: Any]?) {
- id = comment?["id"] as? String
- created = comment?["created"] as? Int
- user = comment?["user"] as? String
- starred = comment?["is_starred"] as? Bool
- stars = comment?["num_stars"] as? Int
- self.comment = comment?["comment"] as? String
- }
-
- public init(id: String?) {
- self.id = id
- self.user = nil
- }
-
- public static func ==(lhs: Comment, rhs: Comment) -> Bool {
- return lhs.id == rhs.id
- }
-}
diff --git a/SKCore/Sources/CustomProfile.swift b/SKCore/Sources/CustomProfile.swift
deleted file mode 100644
index 96285d3..0000000
--- a/SKCore/Sources/CustomProfile.swift
+++ /dev/null
@@ -1,50 +0,0 @@
-//
-// CustomProfile.swift
-//
-// Copyright © 2017 Peter Zignego. All rights reserved.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-public struct CustomProfile {
-
- public var fields = [String: CustomProfileField]()
-
- public init(profile: [String: Any]?) {
- if let eventFields = profile?["fields"] as? [Any] {
- for field in eventFields {
- var cpf: CustomProfileField?
- if let fieldDictionary = field as? [String: Any] {
- cpf = CustomProfileField(field: fieldDictionary)
- } else {
- cpf = CustomProfileField(id: field as? String)
- }
- if let id = cpf?.id { fields[id] = cpf }
- }
- }
- }
-
- public init(customFields: [String: Any]?) {
- if let customFields = customFields {
- for key in customFields.keys {
- let cpf = CustomProfileField(field: customFields[key] as? [String: Any])
- self.fields[key] = cpf
- }
- }
- }
-}
diff --git a/SKCore/Sources/CustomProfileField.swift b/SKCore/Sources/CustomProfileField.swift
deleted file mode 100644
index b6ffa96..0000000
--- a/SKCore/Sources/CustomProfileField.swift
+++ /dev/null
@@ -1,66 +0,0 @@
-//
-// CustomProfileField.swift
-//
-// Copyright © 2017 Peter Zignego. All rights reserved.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-public struct CustomProfileField {
-
- public var id: String?
- public var alt: String?
- public var value: String?
- public var hidden: Bool?
- public var hint: String?
- public var label: String?
- public var options: String?
- public var ordering: Int?
- public var possibleValues: [String]?
- public var type: String?
-
- public init(field: [String: Any]?) {
- id = field?["id"] as? String
- alt = field?["alt"] as? String
- value = field?["value"] as? String
- hidden = field?["is_hidden"] as? Bool
- hint = field?["hint"] as? String
- label = field?["label"] as? String
- options = field?["options"] as? String
- ordering = field?["ordering"] as? Int
- possibleValues = field?["possible_values"] as? [String]
- type = field?["type"] as? String
- }
-
- public init(id: String?) {
- self.id = id
- }
-
- public mutating func updateProfileField(_ profile: CustomProfileField?) {
- id = profile?.id != nil ? profile?.id : id
- alt = profile?.alt != nil ? profile?.alt : alt
- value = profile?.value != nil ? profile?.value : value
- hidden = profile?.hidden != nil ? profile?.hidden : hidden
- hint = profile?.hint != nil ? profile?.hint : hint
- label = profile?.label != nil ? profile?.label : label
- options = profile?.options != nil ? profile?.options : options
- ordering = profile?.ordering != nil ? profile?.ordering : ordering
- possibleValues = profile?.possibleValues != nil ? profile?.possibleValues : possibleValues
- type = profile?.type != nil ? profile?.type : type
- }
-}
diff --git a/SKCore/Sources/DoNotDisturbStatus.swift b/SKCore/Sources/DoNotDisturbStatus.swift
deleted file mode 100644
index 79c4bf1..0000000
--- a/SKCore/Sources/DoNotDisturbStatus.swift
+++ /dev/null
@@ -1,39 +0,0 @@
-//
-// DoNotDisturbStatus.swift
-//
-// Copyright © 2017 Peter Zignego. All rights reserved.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-public struct DoNotDisturbStatus {
-
- public var enabled: Bool?
- public var nextDoNotDisturbStart: Int?
- public var nextDoNotDisturbEnd: Int?
- public var snoozeEnabled: Bool?
- public var snoozeEndtime: Int?
-
- public init(status: [String: Any]?) {
- enabled = status?["dnd_enabled"] as? Bool
- nextDoNotDisturbStart = status?["next_dnd_start_ts"] as? Int
- nextDoNotDisturbEnd = status?["next_dnd_end_ts"] as? Int
- snoozeEnabled = status?["snooze_enabled"] as? Bool
- snoozeEndtime = status?["snooze_endtime"] as? Int
- }
-}
diff --git a/SKCore/Sources/Edited.swift b/SKCore/Sources/Edited.swift
deleted file mode 100644
index 9a339fb..0000000
--- a/SKCore/Sources/Edited.swift
+++ /dev/null
@@ -1,33 +0,0 @@
-//
-// Edited.swift
-//
-// Copyright © 2017 Peter Zignego. All rights reserved.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-public struct Edited {
-
- public let user: String?
- public let ts: String?
-
- public init(edited:[String: Any]?) {
- user = edited?["user"] as? String
- ts = edited?["ts"] as? String
- }
-}
diff --git a/SKCore/Sources/Event.swift b/SKCore/Sources/Event.swift
deleted file mode 100644
index 2b7383c..0000000
--- a/SKCore/Sources/Event.swift
+++ /dev/null
@@ -1,218 +0,0 @@
-//
-// Event.swift
-//
-// Copyright © 2017 Peter Zignego. All rights reserved.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-public 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 goodbye = "goodbye"
- case unknown = "unknown"
-}
-
-public 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"
-}
-
-public class Event {
- public let type: EventType?
- public let ts: String?
- public let subtype: String?
- public let channelID: String?
- public let text: String?
- public let eventTs: String?
- public let latest: String?
- public let hidden: Bool?
- public let isStarred: Bool?
- public let hasPins: Bool?
- public let pinnedTo: [String]?
- public let fileID: String?
- public let presence: String?
- public let name: String?
- public let value: Any?
- public let plan: String?
- public let url: String?
- public let domain: String?
- public let emailDomain: String?
- public let reaction: String?
- public let replyTo: Double?
- public let reactions: [[String: Any]]?
- public let edited: Edited?
- public let bot: Bot?
- public let channel: Channel?
- public let comment: Comment?
- public let user: User?
- public let file: File?
- public let message: Message?
- public let nestedMessage: Message?
- public let itemUser: String?
- public let item: Item?
- public let dndStatus: DoNotDisturbStatus?
- public let subteam: UserGroup?
- public let subteamID: String?
- public var profile: CustomProfile?
-
- public init(_ event: [String: Any]) {
- type = EventType(rawValue: event["type"] as? String ?? "ok")
- ts = event["ts"] as? String
- subtype = event["subtype"] as? String
- channelID = event["channel_id"] as? String
- text = event["text"] as? String
- eventTs = event["event_ts"] as? String
- latest = event["latest"] as? String
- hidden = event["hidden"] as? Bool
- isStarred = event["is_starred"] as? Bool
- hasPins = event["has_pins"] as? Bool
- pinnedTo = event["pinned_top"] as? [String]
- fileID = event["file_id"] as? String
- presence = event["presence"] as? String
- name = event["name"] as? String
- value = event["value"]
- plan = event["plan"] as? String
- url = event["url"] as? String
- domain = event["domain"] as? String
- emailDomain = event["email_domain"] as? String
- reaction = event["reaction"] as? String
- replyTo = event["reply_to"] as? Double
- reactions = event["reactions"] as? [[String: Any]]
- bot = Bot(bot: event["bot"] as? [String: Any])
- edited = Edited(edited:event["edited"] as? [String: Any])
- dndStatus = DoNotDisturbStatus(status: event["dnd_status"] as? [String: Any])
- itemUser = event["item_user"] as? String
- item = Item(item: event["item"] as? [String: Any])
- subteam = UserGroup(userGroup: event["subteam"] as? [String: Any])
- subteamID = event["subteam_id"] as? String
- message = Message(dictionary: event)
- nestedMessage = Message(dictionary: event["message"] as? [String: Any])
- profile = CustomProfile(profile: event["profile"] as? [String: Any])
- file = File(id: event["file"] as? String)
-
- // Comment, Channel, and User can come across as Strings or Dictionaries
- if let commentDictionary = event["comment"] as? [String: Any] {
- comment = Comment(comment: commentDictionary)
- } else {
- comment = Comment(id: event["comment"] as? String)
- }
-
- if let userDictionary = event["user"] as? [String: Any] {
- user = User(user: userDictionary)
- } else {
- user = User(id: event["user"] as? String)
- }
-
- if let channelDictionary = event["channel"] as? [String: Any] {
- channel = Channel(channel: channelDictionary)
- } else {
- channel = Channel(id: event["channel"] as? String)
- }
- }
-}
diff --git a/SKCore/Sources/Extensions.swift b/SKCore/Sources/Extensions.swift
deleted file mode 100644
index bd7b669..0000000
--- a/SKCore/Sources/Extensions.swift
+++ /dev/null
@@ -1,52 +0,0 @@
-//
-// Extensions.swift
-//
-// Copyright © 2017 Peter Zignego. All rights reserved.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-import Foundation
-
-public extension Date {
-
- var slackTimestamp: Double {
- return NSNumber(value: timeIntervalSince1970).doubleValue
- }
-}
-
-public extension String {
-
- var slackFormatEscaping: String {
- var escapedString = replacingOccurrences(of: "&", with: "&")
- escapedString = replacingOccurrences(of: "<", with: "<")
- escapedString = replacingOccurrences(of: ">", with: ">")
- return escapedString
- }
-}
-
-public extension UInt64 {
-
- static var nanosecondsPerSecond: UInt64 {
- #if os(Linux)
- return UInt64(CLOCKS_PER_SEC)
- #else
- return NSEC_PER_SEC
- #endif
- }
-}
diff --git a/SKCore/Sources/File.swift b/SKCore/Sources/File.swift
deleted file mode 100644
index 4f67fbc..0000000
--- a/SKCore/Sources/File.swift
+++ /dev/null
@@ -1,186 +0,0 @@
-//
-// File.swift
-//
-// Copyright © 2017 Peter Zignego. All rights reserved.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-public struct File: Equatable {
-
- public let id: String?
- public let created: Int?
- public let name: String?
- public let title: String?
- public let mimeType: String?
- public let fileType: String?
- public let prettyType: String?
- public let user: String?
- public let mode: String?
- public var editable: Bool?
- public let isExternal: Bool?
- public let externalType: String?
- public let size: Int?
- public let urlPrivate: String?
- public let urlPrivateDownload: String?
- public let thumb64: String?
- public let thumb80: String?
- public let thumb360: String?
- public let thumb360gif: String?
- public let thumb360w: String?
- public let thumb360h: String?
- public let thumb480: String?
- public let thumb480gif: String?
- public let thumb480w: String?
- public let thumb480h: String?
- public let thumb720: String?
- public let thumb720gif: String?
- public let thumb720w: String?
- public let thumb720h: String?
- public let thumb960: String?
- public let thumb960gif: String?
- public let thumb960w: String?
- public let thumb960h: String?
- public let thumb1024: String?
- public let thumb1024gif: String?
- public let thumb1024w: String?
- public let thumb1024h: String?
- public let permalink: String?
- public let editLink: String?
- public let preview: String?
- public let previewHighlight: String?
- public let lines: Int?
- public let linesMore: Int?
- public var isPublic: Bool?
- public var publicSharedURL: Bool?
- public var channels: [String]?
- public var groups: [String]?
- public var ims: [String]?
- public let initialComment: Comment?
- public var stars: Int?
- public var isStarred: Bool?
- public var pinnedTo: [String]?
- public var comments = [String: Comment]()
- public var reactions = [Reaction]()
-
- public init(file:[String: Any]?) {
- id = file?["id"] as? String
- created = file?["created"] as? Int
- name = file?["name"] as? String
- title = file?["title"] as? String
- mimeType = file?["mimetype"] as? String
- fileType = file?["filetype"] as? String
- prettyType = file?["pretty_type"] as? String
- user = file?["user"] as? String
- mode = file?["mode"] as? String
- editable = file?["editable"] as? Bool
- isExternal = file?["is_external"] as? Bool
- externalType = file?["external_type"] as? String
- size = file?["size"] as? Int
- urlPrivate = file?["url_private"] as? String
- urlPrivateDownload = file?["url_private_download"] as? String
- thumb64 = file?["thumb_64"] as? String
- thumb80 = file?["thumb_80"] as? String
- thumb360 = file?["thumb_360"] as? String
- thumb360gif = file?["thumb_360_gif"] as? String
- thumb360w = file?["thumb_360_w"] as? String
- thumb360h = file?["thumb_360_h"] as? String
- thumb480 = file?["thumb_480"] as? String
- thumb480gif = file?["thumb_480_gif"] as? String
- thumb480w = file?["thumb_480_w"] as? String
- thumb480h = file?["thumb_480_h"] as? String
- thumb720 = file?["thumb_720"] as? String
- thumb720gif = file?["thumb_720_gif"] as? String
- thumb720w = file?["thumb_720_w"] as? String
- thumb720h = file?["thumb_720_h"] as? String
- thumb960 = file?["thumb_960"] as? String
- thumb960gif = file?["thumb_960_gif"] as? String
- thumb960w = file?["thumb_960_w"] as? String
- thumb960h = file?["thumb_960_h"] as? String
- thumb1024 = file?["thumb_1024"] as? String
- thumb1024gif = file?["thumb_1024_gif"] as? String
- thumb1024w = file?["thumb_1024_w"] as? String
- thumb1024h = file?["thumb_1024_h"] as? String
- permalink = file?["permalink"] as? String
- editLink = file?["edit_link"] as? String
- preview = file?["preview"] as? String
- previewHighlight = file?["preview_highlight"] as? String
- lines = file?["lines"] as? Int
- linesMore = file?["lines_more"] as? Int
- isPublic = file?["is_public"] as? Bool
- publicSharedURL = file?["public_url_shared"] as? Bool
- channels = file?["channels"] as? [String]
- groups = file?["groups"] as? [String]
- ims = file?["ims"] as? [String]
- initialComment = Comment(comment: file?["initial_comment"] as? [String: Any])
- stars = file?["num_stars"] as? Int
- isStarred = file?["is_starred"] as? Bool
- pinnedTo = file?["pinned_to"] as? [String]
- reactions = Reaction.reactionsFromArray(file?["reactions"] as? [[String: Any]])
- }
-
- public init(id:String?) {
- self.id = id
- created = nil
- name = nil
- title = nil
- mimeType = nil
- fileType = nil
- prettyType = nil
- user = nil
- mode = nil
- isExternal = nil
- externalType = nil
- size = nil
- urlPrivate = nil
- urlPrivateDownload = nil
- thumb64 = nil
- thumb80 = nil
- thumb360 = nil
- thumb360gif = nil
- thumb360w = nil
- thumb360h = nil
- thumb480 = nil
- thumb480gif = nil
- thumb480w = nil
- thumb480h = nil
- thumb720 = nil
- thumb720gif = nil
- thumb720w = nil
- thumb720h = nil
- thumb960 = nil
- thumb960gif = nil
- thumb960w = nil
- thumb960h = nil
- thumb1024 = nil
- thumb1024gif = nil
- thumb1024w = nil
- thumb1024h = nil
- permalink = nil
- editLink = nil
- preview = nil
- previewHighlight = nil
- lines = nil
- linesMore = nil
- initialComment = nil
- }
-
- public static func ==(lhs: File, rhs: File) -> Bool {
- return lhs.id == rhs.id
- }
-}
diff --git a/SKCore/Sources/History.swift b/SKCore/Sources/History.swift
deleted file mode 100644
index 5918f82..0000000
--- a/SKCore/Sources/History.swift
+++ /dev/null
@@ -1,43 +0,0 @@
-//
-// History.swift
-//
-// Copyright © 2017 Peter Zignego. All rights reserved.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-import Foundation
-
-public struct History {
-
- public var latest: Date?
- public var messages = [Message]()
- public let hasMore: Bool?
-
- public init(history: [String: Any]?) {
- if let latestStr = history?["latest"] as? String, let latestDouble = Double(latestStr) {
- latest = Date(timeIntervalSince1970: TimeInterval(latestDouble))
- }
- if let msgs = history?["messages"] as? [[String: Any]] {
- for message in msgs {
- messages.append(Message(dictionary: message))
- }
- }
- hasMore = history?["has_more"] as? Bool
- }
-}
diff --git a/SKCore/Sources/Item.swift b/SKCore/Sources/Item.swift
deleted file mode 100644
index 91787aa..0000000
--- a/SKCore/Sources/Item.swift
+++ /dev/null
@@ -1,59 +0,0 @@
-//
-// Item.swift
-//
-// Copyright © 2017 Peter Zignego. All rights reserved.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-public struct Item: Equatable {
-
- public let type: String?
- public let ts: String?
- public let channel: String?
- public let message: Message?
- public let file: File?
- public let comment: Comment?
- public let fileCommentID: String?
-
- public init(item:[String: Any]?) {
- type = item?["type"] as? String
- ts = item?["ts"] as? String
- channel = item?["channel"] as? String
- message = Message(dictionary: item?["message"] as? [String: Any])
-
- // Comment and File can come across as Strings or Dictionaries
- if let commentDictionary = item?["comment"] as? [String: Any] {
- comment = Comment(comment: commentDictionary)
- } else {
- comment = Comment(id: item?["comment"] as? String)
- }
-
- if let fileDictionary = item?["file"] as? [String: Any] {
- file = File(file: fileDictionary)
- } else {
- file = File(id: item?["file"] as? String)
- }
-
- fileCommentID = item?["file_comment"] as? String
- }
-
- public static func ==(lhs: Item, rhs: Item) -> Bool {
- return lhs.type == rhs.type && lhs.channel == rhs.channel && lhs.file == rhs.file && lhs.comment == rhs.comment && lhs.message == rhs.message
- }
-}
diff --git a/SKCore/Sources/Message.swift b/SKCore/Sources/Message.swift
deleted file mode 100644
index 85f6cab..0000000
--- a/SKCore/Sources/Message.swift
+++ /dev/null
@@ -1,101 +0,0 @@
-//
-// Message.swift
-//
-// Copyright © 2017 Peter Zignego. All rights reserved.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-public final class Message: Equatable {
-
- public let type = "message"
- public let subtype: String?
- public var ts: String?
- public let user: String?
- public let channel: String?
- public var hidden: Bool?
- public var text: String?
- public let botID: String?
- public let username: String?
- public let icons: [String: Any]?
- public let deletedTs: String?
- public var purpose: String?
- public var topic: String?
- public var name: String?
- public var members: [String]?
- public var oldName: String?
- public let upload: Bool?
- public let itemType: String?
- public var isStarred: Bool?
- public var pinnedTo: [String]?
- public let comment: Comment?
- public let file: File?
- public var reactions = [Reaction]()
- public var attachments: [Attachment]?
- public var responseType: ResponseType?
- public var replaceOriginal: Bool?
- public var deleteOriginal: Bool?
-
- public init(dictionary: [String: Any]?) {
- subtype = dictionary?["subtype"] as? String
- ts = dictionary?["ts"] as? String
- user = dictionary?["user"] as? String
- channel = dictionary?["channel"] as? String
- hidden = dictionary?["hidden"] as? Bool
- text = dictionary?["text"] as? String
- botID = dictionary?["bot_id"] as? String
- username = dictionary?["username"] as? String
- icons = dictionary?["icons"] as? [String: Any]
- deletedTs = dictionary?["deleted_ts"] as? String
- purpose = dictionary?["purpose"] as? String
- topic = dictionary?["topic"] as? String
- name = dictionary?["name"] as? String
- members = dictionary?["members"] as? [String]
- oldName = dictionary?["old_name"] as? String
- upload = dictionary?["upload"] as? Bool
- itemType = dictionary?["item_type"] as? String
- isStarred = dictionary?["is_starred"] as? Bool
- pinnedTo = dictionary?["pinned_to"] as? [String]
- comment = Comment(comment: dictionary?["comment"] as? [String: Any])
- file = File(file: dictionary?["file"] as? [String: Any])
- reactions = Reaction.reactionsFromArray(dictionary?["reactions"] as? [[String: Any]])
- attachments = (dictionary?["attachments"] as? [[String: Any]])?.map{Attachment(attachment: $0)}
- responseType = ResponseType(rawValue: dictionary?["response_type"] as? String ?? "")
- replaceOriginal = dictionary?["replace_original"] as? Bool
- deleteOriginal = dictionary?["delete_original"] as? Bool
- }
-
- public init(ts:String?) {
- self.ts = ts
- subtype = nil
- user = nil
- channel = nil
- botID = nil
- username = nil
- icons = nil
- deletedTs = nil
- upload = nil
- itemType = nil
- comment = nil
- file = nil
- }
-
- public static func ==(lhs: Message, rhs: Message) -> Bool {
- return lhs.ts == rhs.ts && lhs.user == rhs.user && lhs.text == rhs.text
- }
-}
diff --git a/SKCore/Sources/OAuthConfig.swift b/SKCore/Sources/OAuthConfig.swift
deleted file mode 100644
index 2f2eee0..0000000
--- a/SKCore/Sources/OAuthConfig.swift
+++ /dev/null
@@ -1,39 +0,0 @@
-//
-// OAuthConfig.swift
-//
-// Copyright © 2017 Peter Zignego. All rights reserved.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-import Foundation
-
-public struct OAuthConfig {
-
- public let clientID: String
- public let clientSecret: String
- public let state: String
- public let redirectURI: String?
-
- public init(clientID: String, clientSecret: String, state: String = "", redirectURI: String? = nil) {
- self.clientID = clientID
- self.clientSecret = clientSecret
- self.state = state
- self.redirectURI = redirectURI
- }
-}
diff --git a/SKCore/Sources/RTMOptions.swift b/SKCore/Sources/RTMOptions.swift
deleted file mode 100644
index fb8ae92..0000000
--- a/SKCore/Sources/RTMOptions.swift
+++ /dev/null
@@ -1,43 +0,0 @@
-//
-// RTMOptions.swift
-//
-// Copyright © 2017 Peter Zignego. All rights reserved.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-import Foundation
-
-public struct RTMOptions {
-
- public let simpleLatest: Bool
- public let noUnreads: Bool
- public let mpimAware: Bool
- public let pingInterval: TimeInterval
- public let timeout: TimeInterval
- public let reconnect: Bool
-
- public init(simpleLatest: Bool = false, noUnreads: Bool = false, mpimAware: Bool = true, pingInterval: TimeInterval = 30, timeout: TimeInterval = 300, reconnect: Bool = true) {
- self.simpleLatest = simpleLatest
- self.noUnreads = noUnreads
- self.mpimAware = mpimAware
- self.pingInterval = pingInterval
- self.timeout = timeout
- self.reconnect = reconnect
- }
-}
diff --git a/SKCore/Sources/Reaction.swift b/SKCore/Sources/Reaction.swift
deleted file mode 100644
index 45883cf..0000000
--- a/SKCore/Sources/Reaction.swift
+++ /dev/null
@@ -1,55 +0,0 @@
-//
-// Reaction.swift
-//
-// Copyright © 2017 Peter Zignego. All rights reserved.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-public struct Reaction: Equatable {
-
- public let name: String?
- public var user: String?
-
- public init(reaction:[String: Any]?) {
- name = reaction?["name"] as? String
- }
-
- public init(name: String, user: String) {
- self.name = name
- self.user = user
- }
-
- static func reactionsFromArray(_ array: [[String: Any]]?) -> [Reaction] {
- var reactions = [Reaction]()
- if let array = array {
- for reaction in array {
- if let users = reaction["users"] as? [String], let name = reaction["name"] as? String {
- for user in users {
- reactions.append(Reaction(name: name, user: user))
- }
- }
- }
- }
- return reactions
- }
-
- public static func ==(lhs: Reaction, rhs: Reaction) -> Bool {
- return lhs.name == rhs.name
- }
-}
diff --git a/SKCore/Sources/Scope.swift b/SKCore/Sources/Scope.swift
deleted file mode 100644
index a2f58ae..0000000
--- a/SKCore/Sources/Scope.swift
+++ /dev/null
@@ -1,71 +0,0 @@
-//
-// Scope.swift
-//
-// Copyright © 2017 Peter Zignego. All rights reserved.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-public enum Scope: String {
-
- case ChannelsHistory = "channels:history"
- case ChannelsRead = "channels:read"
- case ChannelsWrite = "channels:write"
- case ChatWriteBot = "chat:write:bot"
- case ChatWriteUser = "chat:write:user"
- case DNDRead = "dnd:read"
- case DNDWrite = "dnd:write"
- case EmojiRead = "emoji:read"
- case FilesRead = "files:read"
- case FilesWriteUser = "files:write:user"
- case GroupsHistory = "groups:history"
- case GroupsRead = "groups:read"
- case GroupsWrite = "groups:write"
- case IdentityBasic = "identity.basic"
- case IMHistory = "im:history"
- case IMRead = "im:read"
- case IMWrite = "im:write"
- case MPIMHistory = "mpim:history"
- case MPIMRead = "mpim:read"
- case MPIMWrite = "mpim:write"
- case PinsRead = "pins:read"
- case PinsWrite = "pins:write"
- case ReactionsRead = "reactions:read"
- case ReactionsWrite = "reactions:write"
- case RemindersRead = "reminders:read"
- case RemindersWrite = "reminders:write"
- case SearchRead = "search:read"
- case StarsRead = "stars:read"
- case StarsWrite = "stars:write"
- case TeamRead = "team:read"
- case UserGroupsRead = "usergroups:read"
- case UserGroupsWrite = "usergroups:write"
- case UserProfilesRead = "user.profiles:read"
- case UserProfilesWrite = "user.profiles:write"
- case UsersRead = "users:read"
- case UsersWrite = "users:write"
- case IncomingWebhook = "incoming-webhook"
- case Commands = "commands"
- case Bot = "bot"
- case Identify = "identify"
- case Client = "client"
- case Admin = "admin"
- //Deprecated
- case Read = "read"
- case Post = "post"
-}
diff --git a/SKCore/Sources/SlackError.swift b/SKCore/Sources/SlackError.swift
deleted file mode 100644
index 4b6cf23..0000000
--- a/SKCore/Sources/SlackError.swift
+++ /dev/null
@@ -1,123 +0,0 @@
-//
-// SlackError.swift
-//
-// Copyright © 2017 Peter Zignego. All rights reserved.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// 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"
- // Client
- case clientNetworkError
- case clientJSONError
- case clientOAuthError
- // HTTP
- case tooManyRequests
- case unknownHTTPError
- // RTM
- case rtmConnectionError
-}
diff --git a/SKCore/Sources/Team.swift b/SKCore/Sources/Team.swift
deleted file mode 100644
index 253a087..0000000
--- a/SKCore/Sources/Team.swift
+++ /dev/null
@@ -1,47 +0,0 @@
-//
-// Team.swift
-//
-// Copyright © 2017 Peter Zignego. All rights reserved.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-public struct Team {
-
- public let id: String?
- public var name: String?
- public var domain: String?
- public var emailDomain: String?
- public var messageEditWindowMinutes: Int?
- public var overStorageLimit: Bool?
- public var prefs: [String: Any]?
- public var plan: String?
- public var icon: TeamIcon?
-
- public init(team: [String: Any]?) {
- id = team?["id"] as? String
- name = team?["name"] as? String
- domain = team?["domain"] as? String
- emailDomain = team?["email_domain"] as? String
- messageEditWindowMinutes = team?["msg_edit_window_mins"] as? Int
- overStorageLimit = team?["over_storage_limit"] as? Bool
- prefs = team?["prefs"] as? [String: Any]
- plan = team?["plan"] as? String
- icon = TeamIcon(icon: team?["icon"] as? [String: Any])
- }
-}
diff --git a/SKCore/Sources/TeamIcon.swift b/SKCore/Sources/TeamIcon.swift
deleted file mode 100644
index 9c8e7ee..0000000
--- a/SKCore/Sources/TeamIcon.swift
+++ /dev/null
@@ -1,45 +0,0 @@
-//
-// TeamIcon.swift
-//
-// Copyright © 2017 Peter Zignego. All rights reserved.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-public struct TeamIcon {
-
- public var image34: String?
- public var image44: String?
- public var image68: String?
- public var image88: String?
- public var image102: String?
- public var image132: String?
- public var imageOriginal: String?
- public var imageDefault: Bool?
-
- public init(icon: [String: Any]?) {
- image34 = icon?["image_34"] as? String
- image44 = icon?["image_44"] as? String
- image68 = icon?["image_68"] as? String
- image88 = icon?["image_88"] as? String
- image102 = icon?["image_102"] as? String
- image132 = icon?["image_132"] as? String
- imageOriginal = icon?["image_original"] as? String
- imageDefault = icon?["image_default"] as? Bool
- }
-}
diff --git a/SKCore/Sources/Topic.swift b/SKCore/Sources/Topic.swift
deleted file mode 100644
index e5856bf..0000000
--- a/SKCore/Sources/Topic.swift
+++ /dev/null
@@ -1,35 +0,0 @@
-//
-// Topic.swift
-//
-// Copyright © 2017 Peter Zignego. All rights reserved.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-public struct Topic {
-
- public let value: String?
- public let creator: String?
- public let lastSet: Int?
-
- public init(topic: [String: Any]?) {
- value = topic?["value"] as? String
- creator = topic?["creator"] as? String
- lastSet = topic?["last_set"] as? Int
- }
-}
diff --git a/SKCore/Sources/User.swift b/SKCore/Sources/User.swift
deleted file mode 100644
index cf7d078..0000000
--- a/SKCore/Sources/User.swift
+++ /dev/null
@@ -1,106 +0,0 @@
-//
-// User.swift
-//
-// Copyright © 2017 Peter Zignego. All rights reserved.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-public struct User {
-
- public struct Profile {
-
- public var firstName: String?
- public var lastName: String?
- public var realName: String?
- public var email: String?
- public var skype: String?
- public var phone: String?
- public var image24: String?
- public var image32: String?
- public var image48: String?
- public var image72: String?
- public var image192: String?
- public var customProfile: CustomProfile?
-
- public init(profile: [String: Any]?) {
- firstName = profile?["first_name"] as? String
- lastName = profile?["last_name"] as? String
- realName = profile?["real_name"] as? String
- email = profile?["email"] as? String
- skype = profile?["skype"] as? String
- phone = profile?["phone"] as? String
- image24 = profile?["image_24"] as? String
- image32 = profile?["image_32"] as? String
- image48 = profile?["image_48"] as? String
- image72 = profile?["image_72"] as? String
- image192 = profile?["image_192"] as? String
- customProfile = CustomProfile(customFields: profile?["fields"] as? [String: Any])
- }
- }
-
- public let id: String?
- public var name: String?
- public var deleted: Bool?
- public var profile: Profile?
- public var doNotDisturbStatus: DoNotDisturbStatus?
- public var presence: String?
- public var color: String?
- public let isBot: Bool?
- public var isAdmin: Bool?
- public var isOwner: Bool?
- public var isPrimaryOwner: Bool?
- public var isRestricted: Bool?
- public var isUltraRestricted: Bool?
- public var has2fa: Bool?
- public var hasFiles: Bool?
- public var status: String?
- public var timeZone: String?
- public var timeZoneLabel: String?
- public var timeZoneOffSet: Int?
- public var preferences: [String: Any]?
- // Client properties
- public var userGroups: [String: String]?
-
- public init(user: [String: Any]?) {
- id = user?["id"] as? String
- name = user?["name"] as? String
- deleted = user?["deleted"] as? Bool
- profile = Profile(profile: user?["profile"] as? [String: Any])
- color = user?["color"] as? String
- isAdmin = user?["is_admin"] as? Bool
- isOwner = user?["is_owner"] as? Bool
- isPrimaryOwner = user?["is_primary_owner"] as? Bool
- isRestricted = user?["is_restricted"] as? Bool
- isUltraRestricted = user?["is_ultra_restricted"] as? Bool
- has2fa = user?["has_2fa"] as? Bool
- hasFiles = user?["has_files"] as? Bool
- isBot = user?["is_bot"] as? Bool
- presence = user?["presence"] as? String
- status = user?["status"] as? String
- timeZone = user?["tz"] as? String
- timeZoneLabel = user?["tz_label"] as? String
- timeZoneOffSet = user?["tz_offset"] as? Int
- preferences = user?["prefs"] as? [String: Any]
- }
-
- public init(id: String?) {
- self.id = id
- self.isBot = nil
- }
-}
diff --git a/SKCore/Sources/UserGroup.swift b/SKCore/Sources/UserGroup.swift
deleted file mode 100644
index f84bcc2..0000000
--- a/SKCore/Sources/UserGroup.swift
+++ /dev/null
@@ -1,65 +0,0 @@
-//
-// UserGroup.swift
-//
-// Copyright © 2017 Peter Zignego. All rights reserved.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-public struct UserGroup {
-
- public let id: String?
- public var teamID: String?
- public let isUserGroup: Bool?
- public var name: String?
- public var description: String?
- public var handle: String?
- public var isExternal: Bool?
- public let dateCreated: Int?
- public var dateUpdated: Int?
- public var dateDeleted: Int?
- public var autoType: String?
- public let createdBy: String?
- public var updatedBy: String?
- public var deletedBy: String?
- public var preferences: [String: Any]?
- public var users: [String]?
- public var userCount: Int?
-
- public init(userGroup: [String: Any]?) {
- id = userGroup?["id"] as? String
- teamID = userGroup?["team_id"] as? String
- isUserGroup = userGroup?["is_usergroup"] as? Bool
- name = userGroup?["name"] as? String
- description = userGroup?["description"] as? String
- handle = userGroup?["handle"] as? String
- isExternal = userGroup?["is_external"] as? Bool
- dateCreated = userGroup?["date_create"] as? Int
- dateUpdated = userGroup?["date_update"] as? Int
- dateDeleted = userGroup?["date_delete"] as? Int
- autoType = userGroup?["auto_type"] as? String
- createdBy = userGroup?["created_by"] as? String
- updatedBy = userGroup?["updated_by"] as? String
- deletedBy = userGroup?["deleted_by"] as? String
- preferences = userGroup?["prefs"] as? [String: Any]
- users = userGroup?["users"] as? [String]
- if let count = userGroup?["user_count"] as? String {
- userCount = Int(count)
- }
- }
-}
diff --git a/SKCore/Supporting Files/SKCore.h b/SKCore/Supporting Files/SKCore.h
deleted file mode 100644
index 0de3159..0000000
--- a/SKCore/Supporting Files/SKCore.h
+++ /dev/null
@@ -1,19 +0,0 @@
-//
-// SKCore.h
-// SKCore
-//
-// Created by Peter Zignego on 2/4/17.
-// Copyright © 2017 Launch Software LLC. All rights reserved.
-//
-
-#import
-
-//! Project version number for SKCore.
-FOUNDATION_EXPORT double SKCoreVersionNumber;
-
-//! Project version string for SKCore.
-FOUNDATION_EXPORT const unsigned char SKCoreVersionString[];
-
-// In this header, you should import all the public headers of your framework using statements like #import
-
-
diff --git a/SKRTMAPI/Sources/Conformers/StarscreamRTM.swift b/SKRTMAPI/Sources/Conformers/StarscreamRTM.swift
deleted file mode 100644
index 9d50b88..0000000
--- a/SKRTMAPI/Sources/Conformers/StarscreamRTM.swift
+++ /dev/null
@@ -1,74 +0,0 @@
-//
-// StarscreamRTM.swift
-//
-// Copyright © 2017 Peter Zignego. All rights reserved.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-#if os(macOS) || os(iOS) || os(tvOS)
-import Foundation
-import SKCore
-import Starscream
-
-public class StarscreamRTM: RTMWebSocket, WebSocketDelegate {
-
- public var delegate: RTMDelegate?
- private var webSocket: WebSocket?
-
- public required init() {}
-
- //MARK: - RTM
- public func connect(url: URL) {
- self.webSocket = WebSocket(url: url)
- self.webSocket?.delegate = self
- self.webSocket?.connect()
- }
-
- public func disconnect() {
- webSocket?.disconnect()
- }
-
- public func sendMessage(_ message: String) throws {
- guard webSocket != nil else {
- throw SlackError.rtmConnectionError
- }
- webSocket?.write(string: message)
- }
-
- public func ping() {
- webSocket?.write(ping: Data())
- }
-
- // MARK: - WebSocketDelegate
- public func websocketDidConnect(socket: WebSocket) {
- delegate?.didConnect()
- }
-
- public func websocketDidDisconnect(socket: WebSocket, error: NSError?) {
- webSocket = nil
- delegate?.disconnected()
- }
-
- public func websocketDidReceiveMessage(socket: WebSocket, text: String) {
- delegate?.receivedMessage(text)
- }
-
- public func websocketDidReceiveData(socket: WebSocket, data: Data) {}
-}
-#endif
diff --git a/SKRTMAPI/Sources/Conformers/ZewoRTM.swift b/SKRTMAPI/Sources/Conformers/ZewoRTM.swift
deleted file mode 100644
index 8849cde..0000000
--- a/SKRTMAPI/Sources/Conformers/ZewoRTM.swift
+++ /dev/null
@@ -1,75 +0,0 @@
-//
-// ZewoRTM.swift
-//
-// Copyright © 2017 Peter Zignego. All rights reserved.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-import Foundation
-import SKCore
-import WebSocketClient
-
-public class ZewoRTM: RTMWebSocket {
-
- public var delegate: RTMDelegate?
- internal var client: WebSocketClient?
- internal var webSocket: WebSocket?
-
- public required init() {}
-
- //MARK: - RTM
- public func connect(url: URL) {
- do {
- self.client = try WebSocketClient(url: url, didConnect: { (webSocket) in
- self.setupSocket(webSocket)
- })
- try self.client?.connect()
- } catch let error {
- print("WebSocket client could not connect: \(error)")
- }
- }
-
- public func disconnect() {
- try? webSocket?.close()
- }
-
- public func sendMessage(_ message: String) throws {
- guard webSocket != nil else {
- throw SlackError.rtmConnectionError
- }
- do {
- try webSocket?.send(message)
- } catch let error {
- throw error
- }
- }
-
- // MARK: - WebSocket
- private func setupSocket(_ webSocket: WebSocket) {
- webSocket.onText { (message) in
- self.delegate?.receivedMessage(message)
- }
- webSocket.onClose { (code: CloseCode?, reason: String?) in
- self.delegate?.disconnected()
- }
- webSocket.onPing { (data) in try webSocket.pong() }
- webSocket.onPong { (data) in try webSocket.ping() }
- self.webSocket = webSocket
- }
-}
diff --git a/SKRTMAPI/Sources/SKRTMAPI.swift b/SKRTMAPI/Sources/SKRTMAPI.swift
deleted file mode 100644
index 7d5553b..0000000
--- a/SKRTMAPI/Sources/SKRTMAPI.swift
+++ /dev/null
@@ -1,207 +0,0 @@
-//
-// SKRTMAPI.swift
-//
-// Copyright © 2017 Peter Zignego. All rights reserved.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-#if os(Linux)
-import Dispatch
-#endif
-import Foundation
-import SKCore
-import SKWebAPI
-
-public protocol RTMWebSocket {
- init()
- var delegate: RTMDelegate? { get set }
- func connect(url: URL)
- func disconnect()
- func sendMessage(_ message: String) throws
-}
-
-public protocol RTMAdapter: class {
- func initialSetup(json: [String: Any], instance: SKRTMAPI)
- func notificationForEvent(_ event: Event, type: EventType, instance: SKRTMAPI)
-}
-
-public protocol RTMDelegate {
- func didConnect()
- func disconnected()
- func receivedMessage(_ message: String)
-}
-
-public final class SKRTMAPI: RTMDelegate {
-
- public var rtm: RTMWebSocket
- public var adapter: RTMAdapter?
- public var token = "xoxp-SLACK_AUTH_TOKEN"
- internal var options: RTMOptions
- var connected = false
-
- var ping: Double?
- var pong: Double?
-
- public init(withAPIToken token: String, options: RTMOptions = RTMOptions(), rtm: RTMWebSocket? = nil) {
- self.token = token
- self.options = options
- if let rtm = rtm {
- self.rtm = rtm
- } else {
- #if os(Linux)
- self.rtm = ZewoRTM()
- #else
- self.rtm = StarscreamRTM()
- #endif
- }
- self.rtm.delegate = self
- self.connect()
- }
-
- public func connect() {
- WebAPI.rtmStart(token: token, simpleLatest: options.simpleLatest, noUnreads: options.noUnreads, mpimAware: options.mpimAware, success: {(response) in
- guard let socketURL = response["url"] as? String, let url = URL(string: socketURL) else {
- return
- }
- self.rtm.connect(url: url)
- self.adapter?.initialSetup(json: response, instance: self)
- }, failure: { (error) in
- print(error)
- })
- }
-
- public func disconnect() {
- rtm.disconnect()
- }
-
- public func sendMessage(_ message: String, channelID: String) throws {
- guard connected else {
- throw SlackError.rtmConnectionError
- }
- do {
- let string = try format(message: message, channel: channelID)
- try rtm.sendMessage(string)
- } catch let error {
- throw error
- }
- }
-
- private func format(message: String, channel: String) throws -> String {
- let json: [String: Any] = [
- "id": Date().slackTimestamp,
- "type": "message",
- "channel": channel,
- "text": message.slackFormatEscaping
- ]
- guard
- let data = try? JSONSerialization.data(withJSONObject: json, options: []),
- let str = String(data: data, encoding: String.Encoding.utf8)
- else {
- throw SlackError.clientJSONError
- }
- return str
- }
-
- //MARK: - RTM Ping
- private func pingRTMServer() {
- let delay = DispatchTime.now() + Double(UInt64(options.pingInterval * Double(UInt64.nanosecondsPerSecond))) / Double(UInt64.nanosecondsPerSecond)
- DispatchQueue.main.asyncAfter(deadline: delay) {
- guard self.connected && self.isConnectionTimedOut else {
- self.disconnect()
- return
- }
- try? self.sendRTMPing()
- self.pingRTMServer()
- }
- }
-
- private func sendRTMPing() throws {
- guard connected else {
- throw SlackError.rtmConnectionError
- }
- let json: [String: Any] = [
- "id": Date().slackTimestamp,
- "type": "ping"
- ]
- guard let data = try? JSONSerialization.data(withJSONObject: json, options: []) else {
- throw SlackError.clientJSONError
- }
- if let string = String(data: data, encoding: String.Encoding.utf8) {
- ping = json["id"] as? Double
- try rtm.sendMessage(string)
- }
- }
-
- var isConnectionTimedOut: Bool {
- if let pong = pong, let ping = ping {
- if pong - ping < options.timeout {
- return true
- } else {
- return false
- }
- } else {
- return true
- }
- }
-
- //MARK: RTMDelegate
- public func didConnect() {
- connected = true
- pingRTMServer()
- }
-
- public func disconnected() {
- connected = false
- if options.reconnect {
- connect()
- }
- }
-
- public func receivedMessage(_ message: String) {
- guard let data = message.data(using: String.Encoding.utf8) else {
- return
- }
-
- if let json = (try? JSONSerialization.jsonObject(with: data, options: JSONSerialization.ReadingOptions.allowFragments)) as? [String: Any] {
- dispatch(json)
- }
- }
-
- internal func dispatch(_ anEvent: [String: Any]) {
- let event = Event(anEvent)
- let type = event.type ?? .unknown
- switch type {
- case .hello:
- connected = true
- case .pong:
- pong = event.replyTo
- case .teamMigrationStarted:
- connect()
- case .error:
- print("Error: \(anEvent)")
- case .goodbye:
- connect()
- case .unknown:
- print("Unsupported event of type: \(anEvent["type"] ?? "No Type Information")")
- default:
- break
- }
- adapter?.notificationForEvent(event, type: type, instance: self)
- }
-}
diff --git a/SKRTMAPI/Supporting Files/Info.plist b/SKRTMAPI/Supporting Files/Info.plist
deleted file mode 100644
index 92ffb16..0000000
--- a/SKRTMAPI/Supporting Files/Info.plist
+++ /dev/null
@@ -1,26 +0,0 @@
-
-
-
-
- CFBundleDevelopmentRegion
- en
- CFBundleExecutable
- $(EXECUTABLE_NAME)
- CFBundleIdentifier
- $(PRODUCT_BUNDLE_IDENTIFIER)
- CFBundleInfoDictionaryVersion
- 6.0
- CFBundleName
- $(PRODUCT_NAME)
- CFBundlePackageType
- FMWK
- CFBundleShortVersionString
- 1.0
- CFBundleVersion
- $(CURRENT_PROJECT_VERSION)
- NSHumanReadableCopyright
- Copyright © 2017 Launch Software LLC. All rights reserved.
- NSPrincipalClass
-
-
-
diff --git a/SKRTMAPI/Supporting Files/SKRTMAPI.h b/SKRTMAPI/Supporting Files/SKRTMAPI.h
deleted file mode 100644
index 03bf1bc..0000000
--- a/SKRTMAPI/Supporting Files/SKRTMAPI.h
+++ /dev/null
@@ -1,19 +0,0 @@
-//
-// SKRTMAPI.h
-// SKRTMAPI
-//
-// Created by Peter Zignego on 2/4/17.
-// Copyright © 2017 Launch Software LLC. All rights reserved.
-//
-
-#import
-
-//! Project version number for SKRTMAPI.
-FOUNDATION_EXPORT double SKRTMAPIVersionNumber;
-
-//! Project version string for SKRTMAPI.
-FOUNDATION_EXPORT const unsigned char SKRTMAPIVersionString[];
-
-// In this header, you should import all the public headers of your framework using statements like #import
-
-
diff --git a/SKServer/Sources/Conformers/SwifterServer.swift b/SKServer/Sources/Conformers/SwifterServer.swift
deleted file mode 100644
index 022c6fc..0000000
--- a/SKServer/Sources/Conformers/SwifterServer.swift
+++ /dev/null
@@ -1,124 +0,0 @@
-//
-// SwifterServer.swift
-//
-// Copyright © 2017 Peter Zignego. All rights reserved.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-#if os(macOS) || os(iOS) || os(tvOS)
-import Foundation
-import HTTP
-import Swifter
-
-class SwifterServer: SlackKitServer {
-
- let server = HttpServer()
- let port: in_port_t
- let forceIPV4: Bool
-
- init(port: in_port_t = 8080, forceIPV4: Bool = false, responder: SlackKitResponder) {
- self.port = port
- self.forceIPV4 = forceIPV4
-
- for route in responder.routes {
- server[route.path] = { request in
- do {
- return try route.middleware.respond(to: request.request, chainingTo: responder).httpResponse
- } catch let error {
- print(error)
- return .badRequest(.text(error.localizedDescription))
- }
- }
- }
- }
-
- public func start() {
- do {
- try server.start(port, forceIPv4: forceIPV4)
- } catch let error as NSError {
- print("Server failed to start with error: \(error)")
- }
- }
-
- public func stop() {
- server.stop()
- }
-}
-
-extension Response {
-
- public var httpResponse: HttpResponse {
- switch self.status {
- case .ok where contentType == nil:
- do {
- var req = self
- let text = try String(buffer: try req.body.becomeBuffer(deadline: 3.seconds))
- return .ok(.text(text))
- } catch let error {
- print(error)
- return .badRequest(.text(error.localizedDescription))
- }
- case .ok where contentType == MediaType(type: "application", subtype: "json"):
- do {
- var req = self
- let data = Data(try req.body.becomeBuffer(deadline: 3.seconds).bytes)
- let json = try JSONSerialization.jsonObject(with: data, options: [])
- return .ok(.json(json as AnyObject))
- } catch let error {
- print(error)
- return .badRequest(.text(error.localizedDescription))
- }
- case .badRequest:
- return .badRequest(.text("Bad request."))
- default:
- return .ok(.text("ok"))
- }
- }
-}
-
-extension HttpRequest: RequestRepresentable {
-
- public var request: Request {
- let method = Request.Method(self.method)
- let url = URL(string:self.path)
- var headers = [CaseInsensitiveString: String]()
- _ = self.headers.map{headers[CaseInsensitiveString($0.key)] = $0.value}
- let body = Body.buffer(Buffer(self.body))
- return Request(method: method, url: url!, headers: Headers(headers), body: body)
- }
-}
-
-extension Request.Method {
- init(_ rawValue: String) {
- let method = rawValue.uppercased()
- switch method {
- case "DELETE": self = .delete
- case "GET": self = .get
- case "HEAD": self = .head
- case "POST": self = .post
- case "PUT": self = .put
- case "CONNECT": self = .connect
- case "OPTIONS": self = .options
- case "TRACE": self = .trace
- case "PATCH": self = .patch
- default: self = .other(method: method)
- }
- }
-}
-#endif
diff --git a/SKServer/Sources/Conformers/ZewoServer.swift b/SKServer/Sources/Conformers/ZewoServer.swift
deleted file mode 100644
index b686d34..0000000
--- a/SKServer/Sources/Conformers/ZewoServer.swift
+++ /dev/null
@@ -1,50 +0,0 @@
-//
-// ZewoServer.swift
-//
-// Copyright © 2017 Peter Zignego. All rights reserved.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-import Foundation
-import HTTPServer
-
-class ZewoServer: SlackKitServer {
-
- let server: Server
-
- init(host: String = "0.0.0.0", port: Int = 8080, responder: Responder) throws {
- do {
- server = try Server(host: host, port: port, responder: responder)
- } catch let error {
- throw error
- }
- }
-
- public func start() {
- do {
- try server.start()
- } catch let error {
- print("Server failed to start with error: \(error)")
- }
- }
-
- public func stop() {
-
- }
-}
diff --git a/SKServer/Sources/MessageActionResponder.swift b/SKServer/Sources/MessageActionResponder.swift
deleted file mode 100644
index bfdcb00..0000000
--- a/SKServer/Sources/MessageActionResponder.swift
+++ /dev/null
@@ -1,38 +0,0 @@
-//
-// MessageActionResponder.swift
-//
-// Copyright © 2017 Peter Zignego. All rights reserved.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-import HTTP
-import Foundation
-
-public struct MessageActionResponder {
-
- public let routes: [MessageActionRoute]
-
- public init(routes: [MessageActionRoute]) {
- self.routes = routes
- }
-
- internal func routes(_ request: MessageActionRequest) -> Middleware? {
- return routes.first(where: {$0.action.name == request.action?.name})?.middleware
- }
-}
diff --git a/SKServer/Sources/Middleware/MessageActionMiddleware.swift b/SKServer/Sources/Middleware/MessageActionMiddleware.swift
deleted file mode 100644
index 86b07aa..0000000
--- a/SKServer/Sources/Middleware/MessageActionMiddleware.swift
+++ /dev/null
@@ -1,58 +0,0 @@
-//
-// MessageActionMiddleware.swift
-//
-// Copyright © 2017 Peter Zignego. All rights reserved.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-import Foundation
-import HTTP
-
-public struct MessageActionMiddleware: Middleware {
-
- let token: String
- let responder: MessageActionResponder
-
- public init(token: String, responder: MessageActionResponder) {
- self.token = token
- self.responder = responder
- }
-
- public func respond(to request: Request, chainingTo next: Responder) throws -> Response {
- if let action = MessageActionRequest(request: request), let middleware = responder.routes(action), action.token == token {
- return try middleware.respond(to: request, chainingTo: next)
- }
- return Response(status: .badRequest)
- }
-}
-
-extension MessageActionRequest {
- public init?(request: Request) {
- var req = request
- let encoded = try? URLEncodedFormMapParser.parse(try req.body.becomeBuffer(deadline: 3.seconds))
- guard
- let response = encoded?.dictionary?["payload"]?.string,
- let data = response.data(using: .utf8),
- let json = try? JSONSerialization.jsonObject(with: data, options: .allowFragments) as? [String: Any]
- else {
- return nil
- }
- self.init(response: json)
- }
-}
diff --git a/SKServer/Sources/Middleware/OAuthMiddleware.swift b/SKServer/Sources/Middleware/OAuthMiddleware.swift
deleted file mode 100644
index bc11927..0000000
--- a/SKServer/Sources/Middleware/OAuthMiddleware.swift
+++ /dev/null
@@ -1,50 +0,0 @@
-//
-// OAuthMiddleware.swift
-//
-// Copyright © 2017 Peter Zignego. All rights reserved.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-import Foundation
-import HTTP
-import SKCore
-import SKWebAPI
-
-public struct OAuthMiddleware: Middleware {
-
- private let config: OAuthConfig
- internal(set) public var authed: ((OAuthResponse) -> Void)? = nil
-
- public init(config: OAuthConfig, authed: ((OAuthResponse) -> Void)? = nil) {
- self.config = config
- self.authed = authed
- }
-
- public func respond(to request: Request, chainingTo next: Responder) throws -> Response {
- guard let response = AuthorizeResponse(queryItems: request.url.queryItems), let code = response.code, response.state == config.state else {
- return Response(status: .badRequest)
- }
- let authResponse = WebAPI.oauthAccess(clientID: config.clientID, clientSecret: config.clientSecret, code: code, redirectURI: config.redirectURI)
- self.authed?(OAuthResponse(response: authResponse))
- guard let redirect = config.redirectURI else {
- return Response(status: .ok)
- }
- return Response(redirectTo: redirect)
- }
-}
diff --git a/SKServer/Sources/Middleware/RedirectMiddleware.swift b/SKServer/Sources/Middleware/RedirectMiddleware.swift
deleted file mode 100644
index 94e25f1..0000000
--- a/SKServer/Sources/Middleware/RedirectMiddleware.swift
+++ /dev/null
@@ -1,50 +0,0 @@
-//
-// RedirectMiddleware.swift
-//
-// Copyright (c) 2017 Quark
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all
-// copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-// SOFTWARE.
-
-import HTTP
-
-public struct RedirectMiddleware : Middleware {
- let location: String
- let shouldRedirect: (Request) -> Bool
-
- public init(redirectTo location: String, if shouldRedirect: @escaping (Request) -> Bool) {
- self.location = location
- self.shouldRedirect = shouldRedirect
- }
-
- public func respond(to request: Request, chainingTo chain: Responder) throws -> Response {
- if shouldRedirect(request) {
- return Response(redirectTo: location)
- }
-
- return try chain.respond(to: request)
- }
-}
-
-extension Response {
- public init(redirectTo location: String, headers: Headers = [:]) {
- var headers = headers
- headers["location"] = location
- self.init(status: .found, headers: headers)
- }
-}
diff --git a/SKServer/Sources/Middleware/ResponseMiddleware.swift b/SKServer/Sources/Middleware/ResponseMiddleware.swift
deleted file mode 100644
index fba2973..0000000
--- a/SKServer/Sources/Middleware/ResponseMiddleware.swift
+++ /dev/null
@@ -1,94 +0,0 @@
-//
-// ResponseMiddleware.swift
-//
-// Copyright © 2017 Peter Zignego. All rights reserved.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-import Foundation
-import HTTP
-
-public struct ResponseMiddleware: Middleware {
-
- let token: String
- let response: SKResponse
-
- public init(token: String, response: SKResponse) {
- self.token = token
- self.response = response
- }
-
- public func respond(to request: Request, chainingTo next: Responder) throws -> Response {
- if let respondable = Respondable(request: request), respondable.token == token {
- return Response(response: response)
- }
- return Response(status: .badRequest)
- }
-
- private struct Respondable {
-
- let token: String
-
- init?(request: Request) {
- if let webhook = WebhookRequest(request: request), let token = webhook.token {
- self.token = token
- } else if let action = MessageActionRequest(request: request), let token = action.token {
- self.token = token
- } else {
- return nil
- }
- }
- }
-}
-
-extension WebhookRequest {
- public init?(request: Request) {
- do {
- var req = request
- let body = try req.body.becomeBuffer(deadline: 3.seconds).bytes
- guard
- let queryString = String(data: Data(body), encoding: .utf8),
- let proto = req.headers["X-Forwarded-Proto"],
- let host = req.headers["Host"]
- else {
- return nil
- }
- let requestString = proto + host + req.url.relativeString + "?" + queryString
- let components = URLComponents(string: requestString)
- var dict = [String: Any]()
- _ = components?.queryItems.flatMap {$0.map({dict[$0.name]=$0.value})}
- self.init(request: dict)
- } catch let error {
- print(error)
- return nil
- }
- }
-}
-
-extension Response {
- public init(response: SKResponse) {
- if let text = response.text.data(using: .utf8), response.attachments == nil, response.responseType == nil {
- self.init(body: Buffer([UInt8](text)))
- } else if let data = try? JSONSerialization.data(withJSONObject: response.json, options: []) {
- self.init(status: .ok, headers: ["content-type":"application/json"], body: Buffer([UInt8](data)))
- } else {
- self.init(status: .badRequest)
- }
- }
-}
diff --git a/SKServer/Sources/Model/AuthorizeResponse.swift b/SKServer/Sources/Model/AuthorizeResponse.swift
deleted file mode 100644
index 37fad0a..0000000
--- a/SKServer/Sources/Model/AuthorizeResponse.swift
+++ /dev/null
@@ -1,43 +0,0 @@
-//
-// AuthorizeResponse.swift
-//
-// Copyright © 2017 Peter Zignego. All rights reserved.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-import Foundation
-
-public struct AuthorizeResponse {
-
- var code: String?
- var state: String?
-
- init?(queryItems: [URLQueryItem]) {
- for item in queryItems {
- switch item.name {
- case "code":
- self.code = item.value
- case "state":
- self.state = item.value
- default:
- continue
- }
- }
- }
-}
diff --git a/SKServer/Sources/Model/IncomingWebhook.swift b/SKServer/Sources/Model/IncomingWebhook.swift
deleted file mode 100644
index 625391b..0000000
--- a/SKServer/Sources/Model/IncomingWebhook.swift
+++ /dev/null
@@ -1,41 +0,0 @@
-//
-// IncomingWebhook.swift
-//
-// Copyright © 2017 Peter Zignego. All rights reserved.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-public struct IncomingWebhook {
-
- public let url: String?
- public let channel: String?
- public let configurationURL: String?
- public let username: String?
- public let iconEmoji: String?
- public let iconURL: String?
-
- internal init(webhook: [String: Any]?) {
- url = webhook?["url"] as? String
- channel = webhook?["channel"] as? String
- configurationURL = webhook?["configuration_url"] as? String
- username = webhook?["username"] as? String
- iconEmoji = webhook?["icon_emoji"] as? String
- iconURL = webhook?["icon_url"] as? String
- }
-}
diff --git a/SKServer/Sources/Model/MessageActionRequest.swift b/SKServer/Sources/Model/MessageActionRequest.swift
deleted file mode 100644
index 288bfe8..0000000
--- a/SKServer/Sources/Model/MessageActionRequest.swift
+++ /dev/null
@@ -1,53 +0,0 @@
-//
-// MessageActionRequest.swift
-//
-// Copyright © 2017 Peter Zignego. All rights reserved.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-import SKCore
-
-public struct MessageActionRequest {
-
- public let action: Action?
- public let callbackID: String?
- public let team: Team?
- public let channel: Channel?
- public let user: User?
- public let actionTS: String?
- public let messageTS: String?
- public let attachmentID: String?
- public let token: String?
- public let originalMessage: Message?
- public let responseURL: String?
-
- internal init(response: [String: Any]?) {
- action = (response?["actions"] as? [Any])?.map({$0 as? [String: Any]}).first.map({Action(action: $0)})
- callbackID = response?["callback_id"] as? String
- team = Team(team: response?["team"] as? [String: Any])
- channel = Channel(channel: response?["channel"] as? [String: Any])
- user = User(user: response?["channel"] as? [String: Any])
- actionTS = response?["action_ts"] as? String
- messageTS = response?["message_ts"] as? String
- attachmentID = response?["attachment_id"] as? String
- token = response?["token"] as? String
- originalMessage = Message(dictionary: response?["original_message"] as? [String: Any])
- responseURL = response?["response_url"] as? String
- }
-}
diff --git a/SKServer/Sources/Model/MessageActionRoute.swift b/SKServer/Sources/Model/MessageActionRoute.swift
deleted file mode 100644
index 18e36e3..0000000
--- a/SKServer/Sources/Model/MessageActionRoute.swift
+++ /dev/null
@@ -1,36 +0,0 @@
-//
-// MessageActionRoute.swift
-//
-// Copyright © 2017 Peter Zignego. All rights reserved.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-import HTTP
-import SKCore
-
-public struct MessageActionRoute {
-
- let action: Action
- let middleware: Middleware
-
- public init(action: Action, middleware: Middleware) {
- self.action = action
- self.middleware = middleware
- }
-}
diff --git a/SKServer/Sources/Model/OAuthResponse.swift b/SKServer/Sources/Model/OAuthResponse.swift
deleted file mode 100644
index 977174e..0000000
--- a/SKServer/Sources/Model/OAuthResponse.swift
+++ /dev/null
@@ -1,46 +0,0 @@
-//
-// OAuthResponse.swift
-//
-// Copyright © 2017 Peter Zignego. All rights reserved.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-import Foundation
-import SKCore
-
-public struct OAuthResponse {
-
- public let accessToken: String?
- public let scope: [Scope]?
- public let userID: String?
- public let teamName: String?
- public let teamID: String?
- public let incomingWebhook: IncomingWebhook?
- public let bot: Bot?
-
- internal init(response: [String: Any]?) {
- accessToken = response?["access_token"] as? String
- scope = (response?["scope"] as? String)?.components(separatedBy: ",").flatMap{Scope(rawValue: $0)}
- userID = response?["user_id"] as? String
- teamName = response?["team_name"] as? String
- teamID = response?["team_id"] as? String
- incomingWebhook = IncomingWebhook(webhook: response?["incoming_webhook"] as? [String: Any])
- bot = Bot(botUser: response?["bot"] as? [String: Any])
- }
-}
diff --git a/SKServer/Sources/Model/RequestRoute.swift b/SKServer/Sources/Model/RequestRoute.swift
deleted file mode 100644
index 9e6923c..0000000
--- a/SKServer/Sources/Model/RequestRoute.swift
+++ /dev/null
@@ -1,35 +0,0 @@
-//
-// RequestRoute.swift
-//
-// Copyright © 2017 Peter Zignego. All rights reserved.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-import HTTP
-
-public struct RequestRoute {
-
- let path: String
- let middleware: Middleware
-
- public init(path: String, middleware: Middleware) {
- self.path = path
- self.middleware = middleware
- }
-}
diff --git a/SKServer/Sources/Model/SKResponse.swift b/SKServer/Sources/Model/SKResponse.swift
deleted file mode 100644
index 51a0486..0000000
--- a/SKServer/Sources/Model/SKResponse.swift
+++ /dev/null
@@ -1,50 +0,0 @@
-//
-// SKResponse.swift
-//
-// Copyright © 2017 Peter Zignego. All rights reserved.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-import Foundation
-import SKCore
-
-public struct SKResponse {
-
- let text: String
- let responseType: ResponseType?
- let attachments: [Attachment]?
-
- public init(text: String, responseType: ResponseType? = nil, attachments: [Attachment]? = nil) {
- self.responseType = responseType
- self.text = text
- self.attachments = attachments
- }
-
- internal var json: [String: Any] {
- var json = [String : Any]()
- json["text"] = text
- json["response_type"] = responseType?.rawValue
- json["attachments"] = attachments?.map({$0.dictionary})
- return json
- }
-
- internal var data: Data? {
- return try? JSONSerialization.data(withJSONObject: self.json, options: [])
- }
-}
diff --git a/SKServer/Sources/Model/WebhookRequest.swift b/SKServer/Sources/Model/WebhookRequest.swift
deleted file mode 100644
index 419ca9b..0000000
--- a/SKServer/Sources/Model/WebhookRequest.swift
+++ /dev/null
@@ -1,53 +0,0 @@
-//
-// WebhookRequest.swift
-//
-// Copyright © 2017 Peter Zignego. All rights reserved.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-public struct WebhookRequest {
-
- public let token: String?
- public let teamID: String?
- public let teamDomain: String?
- public let channelID: String?
- public let channelName: String?
- public let ts: String?
- public let userID: String?
- public let userName: String?
- public let command: String?
- public let text: String?
- public let triggerWord: String?
- public let responseURL: String?
-
- internal init(request: [String: Any]?) {
- token = request?["token"] as? String
- teamID = request?["team_id"] as? String
- teamDomain = request?["team_domain"] as? String
- channelID = request?["channel_id"] as? String
- channelName = request?["channel_name"] as? String
- ts = request?["timestamp"] as? String
- userID = request?["user_id"] as? String
- userName = request?["user_name"] as? String
- command = request?["command"] as? String
- text = request?["text"] as? String
- triggerWord = request?["trigger_word"] as? String
- responseURL = request?["response_url"] as? String
- }
-}
diff --git a/SKServer/Sources/SKServer.swift b/SKServer/Sources/SKServer.swift
deleted file mode 100644
index a4814ee..0000000
--- a/SKServer/Sources/SKServer.swift
+++ /dev/null
@@ -1,60 +0,0 @@
-//
-// SKServer.swift
-//
-// Copyright © 2017 Peter Zignego. All rights reserved.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-import Foundation
-import SKCore
-
-public protocol SlackKitServer {
- func start()
- func stop()
-}
-
-public final class SKServer {
-
- internal let server: SlackKitServer
-
- public init?(server: SlackKitServer? = nil, responder: SlackKitResponder) {
- if let server = server {
- self.server = server
- } else {
- #if os(Linux)
- do {
- self.server = try ZewoServer(responder: responder)
- } catch let error {
- print(error)
- return nil
- }
- #else
- self.server = SwifterServer(responder: responder)
- #endif
- }
- }
-
- public func start() {
- server.start()
- }
-
- public func stop() {
- server.stop()
- }
-}
diff --git a/SKServer/Sources/SlackKitResponder.swift b/SKServer/Sources/SlackKitResponder.swift
deleted file mode 100644
index 0a6d02b..0000000
--- a/SKServer/Sources/SlackKitResponder.swift
+++ /dev/null
@@ -1,57 +0,0 @@
-//
-// SlackKitResponder.swift
-//
-// Copyright © 2017 Peter Zignego. All rights reserved.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-#if os(Linux)
-import Dispatch
-#endif
-import Foundation
-import HTTP
-
-public struct SlackKitResponder: Responder {
-
- public var routes: [RequestRoute]
-
- public init(routes: [RequestRoute]) {
- self.routes = routes
- }
-
- public func respond(to request: Request) throws -> Response {
- guard sslCheck(request: request) == false else {
- return Response(status: .ok)
- }
- // Timeout
- DispatchQueue.main.asyncAfter(deadline: DispatchTime(uptimeNanoseconds: 3 * UInt64.nanosecondsPerSecond), execute: {
- return Response(status:.ok)
- })
- return try self.routes.filter{$0.path == request.path}.first?.middleware.respond(to: request, chainingTo: self) ?? Response(status: .badRequest)
- }
-
- private func sslCheck(request: Request) -> Bool {
- var req = request
- let encoded = try? URLEncodedFormMapParser.parse(try req.body.becomeBuffer(deadline: 3.seconds))
- if encoded?.dictionary?["ssl_check"]?.string == "1" {
- return true
- }
- return false
- }
-}
diff --git a/SKServer/Supporting Files/Info.plist b/SKServer/Supporting Files/Info.plist
deleted file mode 100644
index 92ffb16..0000000
--- a/SKServer/Supporting Files/Info.plist
+++ /dev/null
@@ -1,26 +0,0 @@
-
-
-
-
- CFBundleDevelopmentRegion
- en
- CFBundleExecutable
- $(EXECUTABLE_NAME)
- CFBundleIdentifier
- $(PRODUCT_BUNDLE_IDENTIFIER)
- CFBundleInfoDictionaryVersion
- 6.0
- CFBundleName
- $(PRODUCT_NAME)
- CFBundlePackageType
- FMWK
- CFBundleShortVersionString
- 1.0
- CFBundleVersion
- $(CURRENT_PROJECT_VERSION)
- NSHumanReadableCopyright
- Copyright © 2017 Launch Software LLC. All rights reserved.
- NSPrincipalClass
-
-
-
diff --git a/SKServer/Supporting Files/SKServer.h b/SKServer/Supporting Files/SKServer.h
deleted file mode 100644
index c7eb5d1..0000000
--- a/SKServer/Supporting Files/SKServer.h
+++ /dev/null
@@ -1,19 +0,0 @@
-//
-// SKServer.h
-// SKServer
-//
-// Created by Peter Zignego on 2/4/17.
-// Copyright © 2017 Launch Software LLC. All rights reserved.
-//
-
-#import
-
-//! Project version number for SKServer.
-FOUNDATION_EXPORT double SKServerVersionNumber;
-
-//! Project version string for SKServer.
-FOUNDATION_EXPORT const unsigned char SKServerVersionString[];
-
-// In this header, you should import all the public headers of your framework using statements like #import
-
-
diff --git a/SKWebAPI/Sources/NetworkInterface.swift b/SKWebAPI/Sources/NetworkInterface.swift
deleted file mode 100644
index b47eaca..0000000
--- a/SKWebAPI/Sources/NetworkInterface.swift
+++ /dev/null
@@ -1,196 +0,0 @@
-//
-// NetworkInterface.swift
-//
-// Copyright © 2017 Peter Zignego. All rights reserved.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-#if os(Linux)
-import Dispatch
-#endif
-import Foundation
-import SKCore
-
-public struct NetworkInterface {
-
- private let apiUrl = "https://slack.com/api/"
- private let session = URLSession(configuration: .default)
-
- internal init() {}
-
- internal func request(_ endpoint: Endpoint, parameters: [String: Any?], successClosure: @escaping ([String: Any])->Void, errorClosure: @escaping (SlackError)->Void) {
- var components = URLComponents(string: "\(apiUrl)\(endpoint.rawValue)")
- if parameters.count > 0 {
- components?.queryItems = filterNilParameters(parameters).map { URLQueryItem(name: $0.0, value: "\($0.1)") }
- }
- guard let url = components?.url else {
- errorClosure(SlackError.clientNetworkError)
- return
- }
- let request = URLRequest(url: url)
-
- session.dataTask(with: request) {(data, response, publicError) in
- do {
- successClosure(try NetworkInterface.handleResponse(data, response: response, publicError: publicError))
- } catch let error {
- errorClosure(error as? SlackError ?? SlackError.unknownError)
- }
- }.resume()
- }
-
- //Adapted from https://gist.github.com/erica/baa8a187a5b4796dab27
- internal func synchronusRequest(_ endpoint: Endpoint, parameters: [String: Any?]) -> [String: Any]? {
- var components = URLComponents(string: "\(apiUrl)\(endpoint.rawValue)")
- if parameters.count > 0 {
- components?.queryItems = filterNilParameters(parameters).map { URLQueryItem(name: $0.0, value: "\($0.1)") }
- }
- guard let url = components?.url else {
- return nil
- }
- let request = URLRequest(url: url)
- var data: Data? = nil
- var response: URLResponse? = nil
- var error: Error? = nil
- let semaphore = DispatchSemaphore(value: 0)
- session.dataTask(with: request) { (reqData, reqResponse, reqError) in
- data = reqData
- response = reqResponse
- error = reqError
- if data == nil, let error = error { print(error) }
- semaphore.signal()
- }.resume()
- _ = semaphore.wait(timeout: DispatchTime.distantFuture)
- return try? NetworkInterface.handleResponse(data, response: response, publicError: error)
- }
-
- internal func customRequest(_ url: String, data: Data, success: @escaping (Bool)->Void, errorClosure: @escaping (SlackError)->Void) {
- guard let string = url.removingPercentEncoding, let url = URL(string: string) else {
- errorClosure(SlackError.clientNetworkError)
- return
- }
- var request = URLRequest(url:url)
- request.httpMethod = "POST"
- let contentType = "application/json"
- request.setValue(contentType, forHTTPHeaderField: "Content-Type")
- request.httpBody = data
-
- session.dataTask(with: request) {(data, response, publicError) in
- if publicError == nil {
- success(true)
- } else {
- errorClosure(SlackError.clientNetworkError)
- }
- }.resume()
- }
-
- internal func uploadRequest(data: Data, parameters: [String: Any?], successClosure: @escaping ([String: Any])->Void, errorClosure: @escaping (SlackError)->Void) {
- var components = URLComponents(string: "\(apiUrl)\(Endpoint.filesUpload.rawValue)")
- if parameters.count > 0 {
- components?.queryItems = filterNilParameters(parameters).map { URLQueryItem(name: $0.0, value: "\($0.1)") }
- }
- guard let url = components?.url else {
- errorClosure(SlackError.clientNetworkError)
- return
- }
- var request = URLRequest(url:url)
- request.httpMethod = "POST"
- let boundaryConstant = randomBoundary()
- let contentType = "multipart/form-data; boundary=" + boundaryConstant
- let boundaryStart = "--\(boundaryConstant)\r\n"
- let boundaryEnd = "--\(boundaryConstant)--\r\n"
- let contentDispositionString = "Content-Disposition: form-data; name=\"file\"; filename=\"\(parameters["filename"])\"\r\n"
- let contentTypeString = "Content-Type: \(parameters["filetype"])\r\n\r\n"
-
- guard let boundaryStartData = boundaryStart.data(using: .utf8), let dispositionData = contentDispositionString.data(using: .utf8), let contentTypeData = contentTypeString.data(using: .utf8), let boundaryEndData = boundaryEnd.data(using: .utf8) else {
- errorClosure(SlackError.clientNetworkError)
- return
- }
-
- var requestBodyData = Data()
- requestBodyData.append(contentsOf: boundaryStartData)
- requestBodyData.append(contentsOf: dispositionData)
- requestBodyData.append(contentsOf: contentTypeData)
- requestBodyData.append(contentsOf: data)
- requestBodyData.append(contentsOf: boundaryEndData)
-
- request.setValue(contentType, forHTTPHeaderField: "Content-Type")
- request.httpBody = requestBodyData as Data
-
- session.dataTask(with: request) {(data, response, publicError) in
- do {
- successClosure(try NetworkInterface.handleResponse(data, response: response, publicError: publicError))
- } catch let error {
- errorClosure(error as? SlackError ?? SlackError.unknownError)
- }
- }.resume()
- }
-
- internal static func handleResponse(_ data: Data?, response: URLResponse?, publicError: Error?) throws -> [String: Any] {
- guard let data = data, let response = response as? HTTPURLResponse else {
- throw SlackError.clientNetworkError
- }
- do {
- guard let json = try JSONSerialization.jsonObject(with: data, options: []) as? [String: Any] else {
- throw SlackError.clientJSONError
- }
-
- switch response.statusCode {
- case 200:
- if (json["ok"] as! Bool == true) {
- return json
- } else {
- if let errorString = json["error"] as? String {
- throw SlackError(rawValue: errorString) ?? .unknownError
- } else {
- throw SlackError.unknownError
- }
- }
- case 429:
- throw SlackError.tooManyRequests
- default:
- throw SlackError.clientNetworkError
- }
- } catch let error {
- if let slackError = error as? SlackError {
- throw slackError
- } else {
- throw SlackError.unknownError
- }
- }
- }
-
- private func randomBoundary() -> String {
- #if os(Linux)
- return "slackkit.boundary.\(Int(random()))\(Int(random()))"
- #else
- return "slackkit.boundary.\(arc4random())\(arc4random())"
- #endif
- }
-
- //MARK: - Filter Nil Parameters
- private func filterNilParameters(_ parameters: [String: Any?]) -> [String: Any] {
- var finalParameters = [String: Any]()
- for (key, value) in parameters {
- if let unwrapped = value {
- finalParameters[key] = unwrapped
- }
- }
- return finalParameters
- }
-}
diff --git a/SKWebAPI/Sources/WebAPI.swift b/SKWebAPI/Sources/WebAPI.swift
deleted file mode 100644
index d69970e..0000000
--- a/SKWebAPI/Sources/WebAPI.swift
+++ /dev/null
@@ -1,704 +0,0 @@
-//
-// WebAPI.swift
-//
-// Copyright © 2017 Peter Zignego. All rights reserved.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-import Foundation
-import SKCore
-
-public 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"
-}
-
-public final class WebAPI {
-
- public typealias FailureClosure = (_ error: SlackError)->Void
-
- public enum InfoType: String {
- case purpose = "purpose"
- case topic = "topic"
- }
-
- public enum ParseMode: String {
- case full = "full"
- case none = "none"
- }
-
- public enum Presence: String {
- case auto = "auto"
- case away = "away"
- }
-
- private enum ChannelType: String {
- case channel = "channel"
- case group = "group"
- case im = "im"
- }
-
- private let networkInterface: NetworkInterface
- private let token: String
-
- public init(token: String) {
- self.networkInterface = NetworkInterface()
- self.token = token
- }
-
- //MARK: - RTM
- public static func rtmStart(token: String, simpleLatest: Bool? = nil, noUnreads: Bool? = nil, mpimAware: Bool? = nil, success: ((_ response: [String: Any])->Void)?, failure: FailureClosure?) {
- let parameters: [String: Any?] = ["token": token, "simple_latest": simpleLatest, "no_unreads": noUnreads, "mpim_aware": mpimAware]
- NetworkInterface().request(.rtmStart, parameters: parameters, successClosure: {(response) in
- success?(response)
- }) {(error) in
- failure?(error)
- }
- }
-
- //MARK: - Auth
- public func authenticationTest(success: ((_ authenticated: Bool)->Void)?, failure: FailureClosure?) {
- networkInterface.request(.authTest, parameters: ["token": token], successClosure: {(response) in
- success?(true)
- }) {(error) in
- failure?(error)
- }
- }
-
- public static func oauthAccess(clientID: String, clientSecret: String, code: String, redirectURI: String? = nil) -> [String: Any]? {
- let parameters: [String: Any?] = ["client_id": clientID, "client_secret": clientSecret, "code": code, "redirect_uri": redirectURI]
- return NetworkInterface().synchronusRequest(.oauthAccess, parameters: parameters)
- }
-
- 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: parameters, successClosure: {(response) in
- success?(true)
- }) {(error) in
- failure?(error)
- }
- }
-
- //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) in
- success?(history)
- }) {(error) in
- failure?(error)
- }
- }
-
- public func channelInfo(id: String, success: ((_ channel: Channel)->Void)?, failure: FailureClosure?) {
- info(.channelsInfo, type:.channel, id: id, success: {(channel) in
- success?(channel)
- }) {(error) in
- failure?(error)
- }
- }
-
- public func channelsList(excludeArchived: Bool = false, success: ((_ channels: [[String: Any]]?)->Void)?, failure: FailureClosure?) {
- list(.channelsList, type:.channel, excludeArchived: excludeArchived, success: {(channels) in
- success?(channels)
- }) {(error) in
- failure?(error)
- }
- }
-
- public func markChannel(channel: String, timestamp: String, success: ((_ ts: String)->Void)?, failure: FailureClosure?) {
- mark(.channelsMark, channel: channel, timestamp: timestamp, success: {(ts) in
- success?(timestamp)
- }) {(error) in
- failure?(error)
- }
- }
-
- public func setChannelPurpose(channel: String, purpose: String, success: ((_ purposeSet: Bool)->Void)?, failure: FailureClosure?) {
- setInfo(.channelsSetPurpose, type: .purpose, channel: channel, text: purpose, success: {(purposeSet) in
- success?(purposeSet)
- }) {(error) in
- failure?(error)
- }
- }
-
- public func setChannelTopic(channel: String, topic: String, success: ((_ topicSet: Bool)->Void)?, failure: FailureClosure?) {
- setInfo(.channelsSetTopic, type: .topic, channel: channel, text: topic, success: {(topicSet) in
- success?(topicSet)
- }) {(error) in
- failure?(error)
- }
- }
-
- //MARK: - Messaging
- public func deleteMessage(channel: String, ts: String, success: ((_ deleted: Bool)->Void)?, failure: FailureClosure?) {
- let parameters: [String: Any] = ["token": token, "channel": channel, "ts": ts]
- networkInterface.request(.chatDelete, parameters: parameters, successClosure: {(response) in
- success?(true)
- }) {(error) in
- failure?(error)
- }
- }
-
- 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?] = ["token": token, "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, parameters: parameters, successClosure: {(response) in
- success?((ts: response["ts"] as? String, response["channel"] as? String))
- }) {(error) in
- failure?(error)
- }
- }
-
- public func sendMeMessage(channel: String, text: String, success: (((ts: String?, channel: String?))->Void)?, failure: FailureClosure?) {
- let parameters: [String: Any?] = ["token": token, "channel": channel, "text": text.slackFormatEscaping]
- networkInterface.request(.chatMeMessage, parameters: parameters, successClosure: {(response) in
- success?((ts: response["ts"] as? String, response["channel"] as? String))
- }) {(error) in
- failure?(error)
- }
- }
-
- 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?] = ["token": token, "channel": channel, "ts": ts, "text": message.slackFormatEscaping, "parse": parse.rawValue, "link_names": linkNames, "attachments": encodeAttachments(attachments)]
- networkInterface.request(.chatUpdate, parameters: parameters, successClosure: {(response) in
- success?(true)
- }) {(error) in
- failure?(error)
- }
- }
-
- //MARK: - Do Not Disturb
- public func dndInfo(user: String? = nil, success: ((_ status: DoNotDisturbStatus)->Void)?, failure: FailureClosure?) {
- let parameters: [String: Any?] = ["token": token, "user": user]
- networkInterface.request(.dndInfo, parameters: parameters, successClosure: {(response) in
- success?(DoNotDisturbStatus(status: response))
- }) {(error) in
- failure?(error)
- }
- }
-
- public func dndTeamInfo(users: [String]? = nil, success: ((_ statuses: [String: DoNotDisturbStatus])->Void)?, failure: FailureClosure?) {
- let parameters: [String: Any?] = ["token": token, "users": users?.joined(separator: ",")]
- networkInterface.request(.dndTeamInfo, parameters: parameters, successClosure: {(response) in
- guard let usersDictionary = response["users"] as? [String: Any] else {
- success?([:])
- return
- }
- success?(self.enumerateDNDStatuses(usersDictionary))
- }) {(error) in
- failure?(error)
- }
- }
-
- //MARK: - Emoji
- public func emojiList(success: ((_ emojiList: [String: Any]?)->Void)?, failure: FailureClosure?) {
- networkInterface.request(.emojiList, parameters: ["token": token], successClosure: {(response) in
- success?(response["emoji"] as? [String: Any])
- }) {(error) in
- failure?(error)
- }
- }
-
- //MARK: - Files
- public func deleteFile(fileID: String, success: ((_ deleted: Bool)->Void)?, failure: FailureClosure?) {
- let parameters = ["token": token, "file": fileID]
- networkInterface.request(.filesDelete, parameters: parameters, successClosure: {(response) in
- success?(true)
- }) {(error) in
- failure?(error)
- }
- }
-
- public func fileInfo(fileID: String, commentCount: Int = 100, totalPages: Int = 1, success: ((_ file: File)->Void)?, failure: FailureClosure?) {
- let parameters: [String: Any] = ["token": token, "file": fileID, "count": commentCount, "totalPages": totalPages]
- networkInterface.request(.filesInfo, parameters: parameters, successClosure: {(response) in
- var file = File(file: response["file"] as? [String: Any])
- (response["comments"] as? [[String: Any]])?.forEach { comment in
- let comment = Comment(comment: comment)
- if let id = comment.id {
- file.comments[id] = comment
- }
- }
- success?(file)
- }) {(error) in
- failure?(error)
- }
- }
-
- 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?] = ["token": token, "filename": filename, "filetype": filetype, "title": title, "initial_comment": initialComment, "channels": channels?.joined(separator: ",")]
- networkInterface.uploadRequest(data: file, parameters: parameters, successClosure: {(response) in
- success?(File(file: response["file"] as? [String: Any]))
- }) {(error) in
- failure?(error)
- }
- }
-
- //MARK: - File Comments
- public func addFileComment(fileID: String, comment: String, success: ((_ comment: Comment)->Void)?, failure: FailureClosure?) {
- let parameters: [String: Any] = ["token": token, "file": fileID, "comment": comment.slackFormatEscaping]
- networkInterface.request(.filesCommentsAdd, parameters: parameters, successClosure: {(response) in
- success?(Comment(comment: response["comment"] as? [String: Any]))
- }) {(error) in
- failure?(error)
- }
- }
-
- public func editFileComment(fileID: String, commentID: String, comment: String, success: ((_ comment: Comment)->Void)?, failure: FailureClosure?) {
- let parameters: [String: Any] = ["token": token, "file": fileID, "id": commentID, "comment": comment.slackFormatEscaping]
- networkInterface.request(.filesCommentsEdit, parameters: parameters, successClosure: {(response) in
- success?(Comment(comment: response["comment"] as? [String: Any]))
- }) {(error) in
- failure?(error)
- }
- }
-
- public func deleteFileComment(fileID: String, commentID: String, success: ((_ deleted: Bool?)->Void)?, failure: FailureClosure?) {
- let parameters: [String: Any] = ["token": token, "file": fileID, "id": commentID]
- networkInterface.request(.filesCommentsDelete, parameters: parameters, successClosure: {(response) in
- success?(true)
- }) {(error) in
- failure?(error)
- }
- }
-
- //MARK: - Groups
- public func closeGroup(groupID: String, success: ((_ closed: Bool)->Void)?, failure: FailureClosure?) {
- close(.groupsClose, channelID: groupID, success: {(closed) in
- success?(closed)
- }) {(error) in
- failure?(error)
- }
- }
-
- 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) in
- success?(history)
- }) {(error) in
- failure?(error)
- }
- }
-
- public func groupInfo(id: String, success: ((_ channel: Channel)->Void)?, failure: FailureClosure?) {
- info(.groupsInfo, type:.group, id: id, success: {(channel) in
- success?(channel)
- }) {(error) in
- failure?(error)
- }
- }
-
- public func groupsList(excludeArchived: Bool = false, success: ((_ channels: [[String: Any]]?)->Void)?, failure: FailureClosure?) {
- list(.groupsList, type:.group, excludeArchived: excludeArchived, success: {(channels) in
- success?(channels)
- }) {(error) in
- failure?(error)
- }
- }
-
- public func markGroup(channel: String, timestamp: String, success: ((_ ts: String)->Void)?, failure: FailureClosure?) {
- mark(.groupsMark, channel: channel, timestamp: timestamp, success: {(ts) in
- success?(timestamp)
- }) {(error) in
- failure?(error)
- }
- }
-
- public func openGroup(channel: String, success: ((_ opened: Bool)->Void)?, failure: FailureClosure?) {
- let parameters = ["token": token, "channel":channel]
- networkInterface.request(.groupsOpen, parameters: parameters, successClosure: {(response) in
- success?(true)
- }) {(error) in
- failure?(error)
- }
- }
-
- public func setGroupPurpose(channel: String, purpose: String, success: ((_ purposeSet: Bool)->Void)?, failure: FailureClosure?) {
- setInfo(.groupsSetPurpose, type: .purpose, channel: channel, text: purpose, success: {(purposeSet) in
- success?(purposeSet)
- }) {(error) in
- failure?(error)
- }
- }
-
- public func setGroupTopic(channel: String, topic: String, success: ((_ topicSet: Bool)->Void)?, failure: FailureClosure?) {
- setInfo(.groupsSetTopic, type: .topic, channel: channel, text: topic, success: {(topicSet) in
- success?(topicSet)
- }) {(error) in
- failure?(error)
- }
- }
-
- //MARK: - IM
- public func closeIM(channel: String, success: ((_ closed: Bool)->Void)?, failure: FailureClosure?) {
- close(.imClose, channelID: channel, success: {(closed) in
- success?(closed)
- }) {(error) in
- failure?(error)
- }
- }
-
- 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) in
- success?(history)
- }) {(error) in
- failure?(error)
- }
- }
-
- public func imsList(excludeArchived: Bool = false, success: ((_ channels: [[String: Any]]?)->Void)?, failure: FailureClosure?) {
- list(.imList, type:.im, excludeArchived: excludeArchived, success: {(channels) in
- success?(channels)
- }) {(error) in
- failure?(error)
- }
- }
-
- public func markIM(channel: String, timestamp: String, success: ((_ ts: String)->Void)?, failure: FailureClosure?) {
- mark(.imMark, channel: channel, timestamp: timestamp, success: {(ts) in
- success?(timestamp)
- }) {(error) in
- failure?(error)
- }
- }
-
- public func openIM(userID: String, success: ((_ imID: String?)->Void)?, failure: FailureClosure?) {
- let parameters = ["token": token, "user": userID]
- networkInterface.request(.imOpen, parameters: parameters, successClosure: {(response) in
- let group = response["channel"] as? [String: Any]
- success?(group?["id"] as? String)
- }) {(error) in
- failure?(error)
- }
- }
-
- //MARK: - MPIM
- public func closeMPIM(channel: String, success: ((_ closed: Bool)->Void)?, failure: FailureClosure?) {
- close(.mpimClose, channelID: channel, success: {(closed) in
- success?(closed)
- }) {(error) in
- failure?(error)
- }
- }
-
- 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) in
- success?(history)
- }) {(error) in
- failure?(error)
- }
- }
-
- public func mpimsList(excludeArchived: Bool = false, success: ((_ channels: [[String: Any]]?)->Void)?, failure: FailureClosure?) {
- list(.mpimList, type:.group, excludeArchived: excludeArchived, success: {(channels) in
- success?(channels)
- }) {(error) in
- failure?(error)
- }
- }
-
- public func markMPIM(channel: String, timestamp: String, success: ((_ ts: String)->Void)?, failure: FailureClosure?) {
- mark(.mpimMark, channel: channel, timestamp: timestamp, success: {(ts) in
- success?(timestamp)
- }) {(error) in
- failure?(error)
- }
- }
-
- public func openMPIM(userIDs: [String], success: ((_ mpimID: String?)->Void)?, failure: FailureClosure?) {
- let parameters = ["token": token, "users": userIDs.joined(separator: ",")]
- networkInterface.request(.mpimOpen, parameters: parameters, successClosure: {(response) in
- let group = response["group"] as? [String: Any]
- success?(group?["id"] as? String)
- }) {(error) in
- failure?(error)
- }
- }
-
- //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: {(ok) in
- success?(ok)
- }) {(error) in
- failure?(error)
- }
- }
-
- 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: {(ok) in
- success?(ok)
- }) {(error) in
- failure?(error)
- }
- }
-
- private func pin(_ endpoint: Endpoint, channel: String, file: String? = nil, fileComment: String? = nil, timestamp: String? = nil, success: ((_ ok: Bool)->Void)?, failure: FailureClosure?) {
- let parameters: [String: Any?] = ["token": token, "channel": channel, "file": file, "file_comment": fileComment, "timestamp": timestamp]
- networkInterface.request(endpoint, parameters: parameters, successClosure: {(response) in
- success?(true)
- }) {(error) in
- failure?(error)
- }
- }
-
- //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: {(ok) in
- success?(ok)
- }) {(error) in
- failure?(error)
- }
- }
-
- // 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: {(ok) in
- success?(ok)
- }) {(error) in
- failure?(error)
- }
- }
-
- private func react(_ endpoint: Endpoint, name: String, file: String? = nil, fileComment: String? = nil, channel: String? = nil, timestamp: String? = nil, success: ((_ ok: Bool)->Void)?, failure: FailureClosure?) {
- let parameters: [String: Any?] = ["token": token, "name": name, "file": file, "file_comment": fileComment, "channel": channel, "timestamp": timestamp]
- networkInterface.request(endpoint, parameters: parameters, successClosure: {(response) in
- success?(true)
- }) {(error) in
- failure?(error)
- }
- }
-
- //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: {(ok) in
- success?(ok)
- }) {(error) in
- failure?(error)
- }
- }
-
- // 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: {(ok) in
- success?(ok)
- }) {(error) in
- failure?(error)
- }
- }
-
- private func star(_ endpoint: Endpoint, file: String?, fileComment: String?, channel: String?, timestamp: String?, success: ((_ ok: Bool)->Void)?, failure: FailureClosure?) {
- let parameters: [String: Any?] = ["token": token, "file": file, "file_comment": fileComment, "channel": channel, "timestamp": timestamp]
- networkInterface.request(endpoint, parameters: parameters, successClosure: {(response) in
- success?(true)
- }) {(error) in
- failure?(error)
- }
- }
-
-
- //MARK: - Team
- public func teamInfo(success: ((_ info: [String: Any]?)->Void)?, failure: FailureClosure?) {
- networkInterface.request(.teamInfo, parameters: ["token": token], successClosure: {(response) in
- success?(response["team"] as? [String: Any])
- }) {(error) in
- failure?(error)
- }
- }
-
- //MARK: - Users
- public func userPresence(user: String, success: ((_ presence: String?)->Void)?, failure: FailureClosure?) {
- let parameters: [String: Any] = ["token": token, "user": user]
- networkInterface.request(.usersGetPresence, parameters: parameters, successClosure: {(response) in
- success?(response["presence"] as? String)
- }) {(error) in
- failure?(error)
- }
- }
-
- public func userInfo(id: String, success: ((_ user: User)->Void)?, failure: FailureClosure?) {
- let parameters: [String: Any] = ["token": token, "user": id]
- networkInterface.request(.usersInfo, parameters: parameters, successClosure: {(response) in
- success?(User(user: response["user"] as? [String: Any]))
- }) {(error) in
- failure?(error)
- }
- }
-
- public func usersList(includePresence: Bool = false, success: ((_ userList: [[String: Any]]?)->Void)?, failure: FailureClosure?) {
- let parameters: [String: Any] = ["token": token, "presence": includePresence]
- networkInterface.request(.usersList, parameters: parameters, successClosure: {(response) in
- success?(response["members"] as? [[String: Any]])
- }) {(error) in
- failure?(error)
- }
- }
-
- public func setUserActive(success: ((_ success: Bool)->Void)?, failure: FailureClosure?) {
- networkInterface.request(.usersSetActive, parameters: ["token": token], successClosure: {(response) in
- success?(true)
- }) {(error) in
- failure?(error)
- }
- }
-
- public func setUserPresence(presence: Presence, success: ((_ success: Bool)->Void)?, failure: FailureClosure?) {
- let parameters: [String: Any] = ["token": token, "presence": presence.rawValue]
- networkInterface.request(.usersSetPresence, parameters: parameters, successClosure: {(response) in
- success?(true)
- }) {(error) in
- failure?(error)
- }
- }
-
- //MARK: - Channel Utilities
- private func close(_ endpoint: Endpoint, channelID: String, success: ((_ closed: Bool)->Void)?, failure: FailureClosure?) {
- let parameters: [String: Any] = ["token": token, "channel": channelID]
- networkInterface.request(endpoint, parameters: parameters, successClosure: {(response) in
- success?(true)
- }) {(error) in
- failure?(error)
- }
- }
-
- private func history(_ endpoint: Endpoint, id: String, latest: String = "\(Date().timeIntervalSince1970)", oldest: String = "0", inclusive: Bool = false, count: Int = 100, unreads: Bool = false, success: ((_ history: History)->Void)?, failure: FailureClosure?) {
- let parameters: [String: Any] = ["token": token, "channel": id, "latest": latest, "oldest": oldest, "inclusive": inclusive, "count": count, "unreads": unreads]
- networkInterface.request(endpoint, parameters: parameters, successClosure: {(response) in
- success?(History(history: response))
- }) {(error) in
- failure?(error)
- }
- }
-
- private func info(_ endpoint: Endpoint, type: ChannelType, id: String, success: ((_ channel: Channel)->Void)?, failure: FailureClosure?) {
- let parameters: [String: Any] = ["token": token, "channel": id]
- networkInterface.request(endpoint, parameters: parameters, successClosure: {(response) in
- success?(Channel(channel: response[type.rawValue] as? [String: Any]))
- }) {(error) in
- failure?(error)
- }
- }
-
- private func list(_ endpoint: Endpoint, type: ChannelType, excludeArchived: Bool = false, success: ((_ channels: [[String: Any]]?)->Void)?, failure: FailureClosure?) {
- let parameters: [String: Any] = ["token": token, "exclude_archived": excludeArchived]
- networkInterface.request(endpoint, parameters: parameters, successClosure: {(response) in
- success?(response[type.rawValue+"s"] as? [[String: Any]])
- }) {(error) in
- failure?(error)
- }
- }
-
- private func mark(_ endpoint: Endpoint, channel: String, timestamp: String, success: ((_ ts: String)->Void)?, failure: FailureClosure?) {
- let parameters: [String: Any] = ["token": token, "channel": channel, "ts": timestamp]
- networkInterface.request(endpoint, parameters: parameters, successClosure: {(response) in
- success?(timestamp)
- }) {(error) in
- failure?(error)
- }
- }
-
- fileprivate func setInfo(_ endpoint: Endpoint, type: InfoType, channel: String, text: String, success: ((_ success: Bool)->Void)?, failure: FailureClosure?) {
- let parameters: [String: Any] = ["token": token, "channel": channel, type.rawValue: text]
- networkInterface.request(endpoint, parameters: parameters, successClosure: {(response) in
- success?(true)
- }) {(error) in
- failure?(error)
- }
- }
-
- //MARK: - Encode Attachments
- private func encodeAttachments(_ attachments: [Attachment?]?) -> String? {
- if let attachments = attachments {
- var attachmentArray: [[String: Any]] = []
- for attachment in attachments {
- if let attachment = attachment {
- attachmentArray.append(attachment.dictionary)
- }
- }
- do {
- let data = try JSONSerialization.data(withJSONObject: attachmentArray, options: [])
- return String(data: data, encoding: String.Encoding.utf8)
- } catch _ {
-
- }
- }
- return nil
- }
-
- //MARK: - Enumerate Do Not Disturb Status
- private func enumerateDNDStatuses(_ statuses: [String: Any]) -> [String: DoNotDisturbStatus] {
- var retVal = [String: DoNotDisturbStatus]()
- for key in statuses.keys {
- retVal[key] = DoNotDisturbStatus(status: statuses[key] as? [String: Any])
- }
- return retVal
- }
-}
diff --git a/SKWebAPI/Supporting Files/Info.plist b/SKWebAPI/Supporting Files/Info.plist
deleted file mode 100644
index 92ffb16..0000000
--- a/SKWebAPI/Supporting Files/Info.plist
+++ /dev/null
@@ -1,26 +0,0 @@
-
-
-
-
- CFBundleDevelopmentRegion
- en
- CFBundleExecutable
- $(EXECUTABLE_NAME)
- CFBundleIdentifier
- $(PRODUCT_BUNDLE_IDENTIFIER)
- CFBundleInfoDictionaryVersion
- 6.0
- CFBundleName
- $(PRODUCT_NAME)
- CFBundlePackageType
- FMWK
- CFBundleShortVersionString
- 1.0
- CFBundleVersion
- $(CURRENT_PROJECT_VERSION)
- NSHumanReadableCopyright
- Copyright © 2017 Launch Software LLC. All rights reserved.
- NSPrincipalClass
-
-
-
diff --git a/SKWebAPI/Supporting Files/SKWebAPI.h b/SKWebAPI/Supporting Files/SKWebAPI.h
deleted file mode 100644
index f686a0c..0000000
--- a/SKWebAPI/Supporting Files/SKWebAPI.h
+++ /dev/null
@@ -1,19 +0,0 @@
-//
-// SKWebAPI.h
-// SKWebAPI
-//
-// Created by Peter Zignego on 2/4/17.
-// Copyright © 2017 Launch Software LLC. All rights reserved.
-//
-
-#import
-
-//! Project version number for SKWebAPI.
-FOUNDATION_EXPORT double SKWebAPIVersionNumber;
-
-//! Project version string for SKWebAPI.
-FOUNDATION_EXPORT const unsigned char SKWebAPIVersionString[];
-
-// In this header, you should import all the public headers of your framework using statements like #import
-
-
diff --git a/SlackKit.podspec b/SlackKit.podspec
new file mode 100644
index 0000000..70174af
--- /dev/null
+++ b/SlackKit.podspec
@@ -0,0 +1,20 @@
+Pod::Spec.new do |s|
+ s.name = "SlackKit"
+ s.version = "4.0.0"
+ s.summary = "Write Slack apps in Swift"
+ s.homepage = "https://github.com/pvzig/SlackKit"
+ s.license = 'MIT'
+ s.author = { "Peter Zignego" => "peter@launchsoft.co" }
+ s.source = { :git => "https://github.com/SlackKit/SlackKit.git", :tag => s.version.to_s }
+ s.social_media_url = 'https://twitter.com/pvzig'
+ s.ios.deployment_target = '9.0'
+ s.osx.deployment_target = '10.11'
+ s.tvos.deployment_target = '9.0'
+ s.requires_arc = true
+ s.source_files = 'Sources/*.swift'
+ s.frameworks = 'Foundation'
+ s.dependency 'SKCore'
+ s.dependency 'SKClient'
+ s.dependency 'SKRTMAPI'
+ s.dependency 'SKServer'
+end
\ No newline at end of file
diff --git a/SlackKit.xcodeproj/project.pbxproj b/SlackKit.xcodeproj/project.pbxproj
new file mode 100644
index 0000000..1148efd
--- /dev/null
+++ b/SlackKit.xcodeproj/project.pbxproj
@@ -0,0 +1,543 @@
+// !$*UTF8*$!
+{
+ archiveVersion = 1;
+ classes = {
+ };
+ objectVersion = 46;
+ objects = {
+
+/* Begin PBXBuildFile section */
+ 266687051E95CB9F00777D94 /* SlackKit.swift in Sources */ = {isa = PBXBuildFile; fileRef = 266687041E95CB9F00777D94 /* SlackKit.swift */; };
+ 266687061E95CB9F00777D94 /* SlackKit.swift in Sources */ = {isa = PBXBuildFile; fileRef = 266687041E95CB9F00777D94 /* SlackKit.swift */; };
+ 266687071E95CB9F00777D94 /* SlackKit.swift in Sources */ = {isa = PBXBuildFile; fileRef = 266687041E95CB9F00777D94 /* SlackKit.swift */; };
+/* End PBXBuildFile section */
+
+/* Begin PBXFileReference section */
+ 266687041E95CB9F00777D94 /* SlackKit.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SlackKit.swift; sourceTree = ""; };
+ 2684F17D1E95AA6900536DCC /* SlackKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SlackKit.framework; sourceTree = BUILT_PRODUCTS_DIR; };
+ 2684F1E41E95ABD400536DCC /* SlackKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SlackKit.framework; sourceTree = BUILT_PRODUCTS_DIR; };
+ 2684F2081E95ABD600536DCC /* SlackKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SlackKit.framework; sourceTree = BUILT_PRODUCTS_DIR; };
+ 2684F20D1E95AF8C00536DCC /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
+/* End PBXFileReference section */
+
+/* Begin PBXFrameworksBuildPhase section */
+ 2684F1791E95AA6900536DCC /* Frameworks */ = {
+ isa = PBXFrameworksBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ 2684F1DE1E95ABD400536DCC /* Frameworks */ = {
+ isa = PBXFrameworksBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ 2684F2021E95ABD600536DCC /* Frameworks */ = {
+ isa = PBXFrameworksBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXFrameworksBuildPhase section */
+
+/* Begin PBXGroup section */
+ 266687031E95CB9F00777D94 /* Sources */ = {
+ isa = PBXGroup;
+ children = (
+ 266687041E95CB9F00777D94 /* SlackKit.swift */,
+ );
+ path = Sources;
+ sourceTree = SOURCE_ROOT;
+ };
+ 2684F1731E95AA6900536DCC = {
+ isa = PBXGroup;
+ children = (
+ 2684F17F1E95AA6900536DCC /* SlackKit */,
+ 2684F17E1E95AA6900536DCC /* Products */,
+ );
+ sourceTree = "";
+ };
+ 2684F17E1E95AA6900536DCC /* Products */ = {
+ isa = PBXGroup;
+ children = (
+ 2684F17D1E95AA6900536DCC /* SlackKit.framework */,
+ 2684F1E41E95ABD400536DCC /* SlackKit.framework */,
+ 2684F2081E95ABD600536DCC /* SlackKit.framework */,
+ );
+ name = Products;
+ sourceTree = "";
+ };
+ 2684F17F1E95AA6900536DCC /* SlackKit */ = {
+ isa = PBXGroup;
+ children = (
+ 266687031E95CB9F00777D94 /* Sources */,
+ 2684F20C1E95AF8C00536DCC /* Supporting Files */,
+ );
+ name = SlackKit;
+ path = SKCore;
+ sourceTree = "";
+ };
+ 2684F20C1E95AF8C00536DCC /* Supporting Files */ = {
+ isa = PBXGroup;
+ children = (
+ 2684F20D1E95AF8C00536DCC /* Info.plist */,
+ );
+ path = "Supporting Files";
+ sourceTree = SOURCE_ROOT;
+ };
+/* End PBXGroup section */
+
+/* Begin PBXHeadersBuildPhase section */
+ 2684F17A1E95AA6900536DCC /* Headers */ = {
+ isa = PBXHeadersBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ 2684F1DF1E95ABD400536DCC /* Headers */ = {
+ isa = PBXHeadersBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ 2684F2031E95ABD600536DCC /* Headers */ = {
+ isa = PBXHeadersBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXHeadersBuildPhase section */
+
+/* Begin PBXNativeTarget section */
+ 2684F17C1E95AA6900536DCC /* SlackKit macOS */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = 2684F1851E95AA6900536DCC /* Build configuration list for PBXNativeTarget "SlackKit macOS" */;
+ buildPhases = (
+ 2684F1781E95AA6900536DCC /* Sources */,
+ 2684F1791E95AA6900536DCC /* Frameworks */,
+ 2684F17A1E95AA6900536DCC /* Headers */,
+ 2684F17B1E95AA6900536DCC /* Resources */,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ );
+ name = "SlackKit macOS";
+ productName = SKCore;
+ productReference = 2684F17D1E95AA6900536DCC /* SlackKit.framework */;
+ productType = "com.apple.product-type.framework";
+ };
+ 2684F1C21E95ABD400536DCC /* SlackKit iOS */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = 2684F1E11E95ABD400536DCC /* Build configuration list for PBXNativeTarget "SlackKit iOS" */;
+ buildPhases = (
+ 2684F1C31E95ABD400536DCC /* Sources */,
+ 2684F1DE1E95ABD400536DCC /* Frameworks */,
+ 2684F1DF1E95ABD400536DCC /* Headers */,
+ 2684F1E01E95ABD400536DCC /* Resources */,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ );
+ name = "SlackKit iOS";
+ productName = SKCore;
+ productReference = 2684F1E41E95ABD400536DCC /* SlackKit.framework */;
+ productType = "com.apple.product-type.framework";
+ };
+ 2684F1E61E95ABD600536DCC /* SlackKit tvOS */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = 2684F2051E95ABD600536DCC /* Build configuration list for PBXNativeTarget "SlackKit tvOS" */;
+ buildPhases = (
+ 2684F1E71E95ABD600536DCC /* Sources */,
+ 2684F2021E95ABD600536DCC /* Frameworks */,
+ 2684F2031E95ABD600536DCC /* Headers */,
+ 2684F2041E95ABD600536DCC /* Resources */,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ );
+ name = "SlackKit tvOS";
+ productName = SKCore;
+ productReference = 2684F2081E95ABD600536DCC /* SlackKit.framework */;
+ productType = "com.apple.product-type.framework";
+ };
+/* End PBXNativeTarget section */
+
+/* Begin PBXProject section */
+ 2684F1741E95AA6900536DCC /* Project object */ = {
+ isa = PBXProject;
+ attributes = {
+ LastUpgradeCheck = 0830;
+ ORGANIZATIONNAME = "Peter Zignego";
+ TargetAttributes = {
+ 2684F17C1E95AA6900536DCC = {
+ CreatedOnToolsVersion = 8.3;
+ ProvisioningStyle = Manual;
+ };
+ 2684F1C21E95ABD400536DCC = {
+ DevelopmentTeam = U63DWZL52M;
+ };
+ 2684F1E61E95ABD600536DCC = {
+ DevelopmentTeam = U63DWZL52M;
+ };
+ };
+ };
+ buildConfigurationList = 2684F1771E95AA6900536DCC /* Build configuration list for PBXProject "SlackKit" */;
+ compatibilityVersion = "Xcode 3.2";
+ developmentRegion = English;
+ hasScannedForEncodings = 0;
+ knownRegions = (
+ en,
+ );
+ mainGroup = 2684F1731E95AA6900536DCC;
+ productRefGroup = 2684F17E1E95AA6900536DCC /* Products */;
+ projectDirPath = "";
+ projectRoot = "";
+ targets = (
+ 2684F17C1E95AA6900536DCC /* SlackKit macOS */,
+ 2684F1C21E95ABD400536DCC /* SlackKit iOS */,
+ 2684F1E61E95ABD600536DCC /* SlackKit tvOS */,
+ );
+ };
+/* End PBXProject section */
+
+/* Begin PBXResourcesBuildPhase section */
+ 2684F17B1E95AA6900536DCC /* Resources */ = {
+ isa = PBXResourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ 2684F1E01E95ABD400536DCC /* Resources */ = {
+ isa = PBXResourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ 2684F2041E95ABD600536DCC /* Resources */ = {
+ isa = PBXResourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXResourcesBuildPhase section */
+
+/* Begin PBXSourcesBuildPhase section */
+ 2684F1781E95AA6900536DCC /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 266687051E95CB9F00777D94 /* SlackKit.swift in Sources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ 2684F1C31E95ABD400536DCC /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 266687061E95CB9F00777D94 /* SlackKit.swift in Sources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ 2684F1E71E95ABD600536DCC /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 266687071E95CB9F00777D94 /* SlackKit.swift in Sources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXSourcesBuildPhase section */
+
+/* Begin XCBuildConfiguration section */
+ 2684F1831E95AA6900536DCC /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ CLANG_ANALYZER_NONNULL = YES;
+ CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
+ CLANG_CXX_LIBRARY = "libc++";
+ CLANG_ENABLE_MODULES = YES;
+ CLANG_ENABLE_OBJC_ARC = YES;
+ CLANG_WARN_BOOL_CONVERSION = YES;
+ CLANG_WARN_CONSTANT_CONVERSION = YES;
+ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
+ CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
+ CLANG_WARN_EMPTY_BODY = YES;
+ CLANG_WARN_ENUM_CONVERSION = YES;
+ CLANG_WARN_INFINITE_RECURSION = YES;
+ CLANG_WARN_INT_CONVERSION = YES;
+ CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+ CLANG_WARN_SUSPICIOUS_MOVE = YES;
+ CLANG_WARN_UNREACHABLE_CODE = YES;
+ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
+ CODE_SIGN_IDENTITY = "-";
+ COPY_PHASE_STRIP = NO;
+ CURRENT_PROJECT_VERSION = 1;
+ DEBUG_INFORMATION_FORMAT = dwarf;
+ ENABLE_STRICT_OBJC_MSGSEND = YES;
+ ENABLE_TESTABILITY = YES;
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_DYNAMIC_NO_PIC = NO;
+ GCC_NO_COMMON_BLOCKS = YES;
+ GCC_OPTIMIZATION_LEVEL = 0;
+ GCC_PREPROCESSOR_DEFINITIONS = (
+ "DEBUG=1",
+ "$(inherited)",
+ );
+ GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
+ GCC_WARN_UNDECLARED_SELECTOR = YES;
+ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
+ GCC_WARN_UNUSED_FUNCTION = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ MACOSX_DEPLOYMENT_TARGET = 10.12;
+ MTL_ENABLE_DEBUG_INFO = YES;
+ ONLY_ACTIVE_ARCH = YES;
+ SDKROOT = macosx;
+ SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
+ SWIFT_OPTIMIZATION_LEVEL = "-Onone";
+ VERSIONING_SYSTEM = "apple-generic";
+ VERSION_INFO_PREFIX = "";
+ };
+ name = Debug;
+ };
+ 2684F1841E95AA6900536DCC /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ CLANG_ANALYZER_NONNULL = YES;
+ CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
+ CLANG_CXX_LIBRARY = "libc++";
+ CLANG_ENABLE_MODULES = YES;
+ CLANG_ENABLE_OBJC_ARC = YES;
+ CLANG_WARN_BOOL_CONVERSION = YES;
+ CLANG_WARN_CONSTANT_CONVERSION = YES;
+ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
+ CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
+ CLANG_WARN_EMPTY_BODY = YES;
+ CLANG_WARN_ENUM_CONVERSION = YES;
+ CLANG_WARN_INFINITE_RECURSION = YES;
+ CLANG_WARN_INT_CONVERSION = YES;
+ CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+ CLANG_WARN_SUSPICIOUS_MOVE = YES;
+ CLANG_WARN_UNREACHABLE_CODE = YES;
+ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
+ CODE_SIGN_IDENTITY = "-";
+ COPY_PHASE_STRIP = NO;
+ CURRENT_PROJECT_VERSION = 1;
+ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
+ ENABLE_NS_ASSERTIONS = NO;
+ ENABLE_STRICT_OBJC_MSGSEND = YES;
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_NO_COMMON_BLOCKS = YES;
+ GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
+ GCC_WARN_UNDECLARED_SELECTOR = YES;
+ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
+ GCC_WARN_UNUSED_FUNCTION = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ MACOSX_DEPLOYMENT_TARGET = 10.12;
+ MTL_ENABLE_DEBUG_INFO = NO;
+ SDKROOT = macosx;
+ SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
+ VERSIONING_SYSTEM = "apple-generic";
+ VERSION_INFO_PREFIX = "";
+ };
+ name = Release;
+ };
+ 2684F1861E95AA6900536DCC /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ CODE_SIGN_IDENTITY = "";
+ COMBINE_HIDPI_IMAGES = YES;
+ DEFINES_MODULE = YES;
+ DEVELOPMENT_TEAM = "";
+ DYLIB_COMPATIBILITY_VERSION = 1;
+ DYLIB_CURRENT_VERSION = 1;
+ DYLIB_INSTALL_NAME_BASE = "@rpath";
+ FRAMEWORK_VERSION = A;
+ INFOPLIST_FILE = "$(SRCROOT)/Supporting Files/Info.plist";
+ INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
+ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks";
+ MACOSX_DEPLOYMENT_TARGET = 10.11;
+ PRODUCT_BUNDLE_IDENTIFIER = com.launchsoft.SlackKit;
+ PRODUCT_NAME = SlackKit;
+ PROVISIONING_PROFILE_SPECIFIER = "";
+ SKIP_INSTALL = YES;
+ SWIFT_VERSION = 3.0;
+ };
+ name = Debug;
+ };
+ 2684F1871E95AA6900536DCC /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ CODE_SIGN_IDENTITY = "";
+ COMBINE_HIDPI_IMAGES = YES;
+ DEFINES_MODULE = YES;
+ DEVELOPMENT_TEAM = "";
+ DYLIB_COMPATIBILITY_VERSION = 1;
+ DYLIB_CURRENT_VERSION = 1;
+ DYLIB_INSTALL_NAME_BASE = "@rpath";
+ FRAMEWORK_VERSION = A;
+ INFOPLIST_FILE = "$(SRCROOT)/Supporting Files/Info.plist";
+ INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
+ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks";
+ MACOSX_DEPLOYMENT_TARGET = 10.11;
+ PRODUCT_BUNDLE_IDENTIFIER = com.launchsoft.SlackKit;
+ PRODUCT_NAME = SlackKit;
+ PROVISIONING_PROFILE_SPECIFIER = "";
+ SKIP_INSTALL = YES;
+ SWIFT_VERSION = 3.0;
+ };
+ name = Release;
+ };
+ 2684F1E21E95ABD400536DCC /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ CODE_SIGN_IDENTITY = "";
+ COMBINE_HIDPI_IMAGES = YES;
+ DEFINES_MODULE = YES;
+ DEVELOPMENT_TEAM = U63DWZL52M;
+ DYLIB_COMPATIBILITY_VERSION = 1;
+ DYLIB_CURRENT_VERSION = 1;
+ DYLIB_INSTALL_NAME_BASE = "@rpath";
+ FRAMEWORK_VERSION = A;
+ INFOPLIST_FILE = "$(SRCROOT)/Supporting Files/Info.plist";
+ INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
+ IPHONEOS_DEPLOYMENT_TARGET = 9.0;
+ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks";
+ PRODUCT_BUNDLE_IDENTIFIER = com.launchsoft.SlackKit;
+ PRODUCT_NAME = SlackKit;
+ SDKROOT = iphoneos;
+ SKIP_INSTALL = YES;
+ SWIFT_VERSION = 3.0;
+ };
+ name = Debug;
+ };
+ 2684F1E31E95ABD400536DCC /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ CODE_SIGN_IDENTITY = "";
+ COMBINE_HIDPI_IMAGES = YES;
+ DEFINES_MODULE = YES;
+ DEVELOPMENT_TEAM = U63DWZL52M;
+ DYLIB_COMPATIBILITY_VERSION = 1;
+ DYLIB_CURRENT_VERSION = 1;
+ DYLIB_INSTALL_NAME_BASE = "@rpath";
+ FRAMEWORK_VERSION = A;
+ INFOPLIST_FILE = "$(SRCROOT)/Supporting Files/Info.plist";
+ INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
+ IPHONEOS_DEPLOYMENT_TARGET = 9.0;
+ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks";
+ PRODUCT_BUNDLE_IDENTIFIER = com.launchsoft.SlackKit;
+ PRODUCT_NAME = SlackKit;
+ SDKROOT = iphoneos;
+ SKIP_INSTALL = YES;
+ SWIFT_VERSION = 3.0;
+ };
+ name = Release;
+ };
+ 2684F2061E95ABD600536DCC /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ CODE_SIGN_IDENTITY = "";
+ COMBINE_HIDPI_IMAGES = YES;
+ DEFINES_MODULE = YES;
+ DEVELOPMENT_TEAM = U63DWZL52M;
+ DYLIB_COMPATIBILITY_VERSION = 1;
+ DYLIB_CURRENT_VERSION = 1;
+ DYLIB_INSTALL_NAME_BASE = "@rpath";
+ FRAMEWORK_VERSION = A;
+ INFOPLIST_FILE = "$(SRCROOT)/Supporting Files/Info.plist";
+ INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
+ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks";
+ PRODUCT_BUNDLE_IDENTIFIER = com.launchsoft.SlackKit;
+ PRODUCT_NAME = SlackKit;
+ SDKROOT = appletvos;
+ SKIP_INSTALL = YES;
+ SWIFT_VERSION = 3.0;
+ TVOS_DEPLOYMENT_TARGET = 9.0;
+ };
+ name = Debug;
+ };
+ 2684F2071E95ABD600536DCC /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ CODE_SIGN_IDENTITY = "";
+ COMBINE_HIDPI_IMAGES = YES;
+ DEFINES_MODULE = YES;
+ DEVELOPMENT_TEAM = U63DWZL52M;
+ DYLIB_COMPATIBILITY_VERSION = 1;
+ DYLIB_CURRENT_VERSION = 1;
+ DYLIB_INSTALL_NAME_BASE = "@rpath";
+ FRAMEWORK_VERSION = A;
+ INFOPLIST_FILE = "$(SRCROOT)/Supporting Files/Info.plist";
+ INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
+ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks";
+ PRODUCT_BUNDLE_IDENTIFIER = com.launchsoft.SlackKit;
+ PRODUCT_NAME = SlackKit;
+ SDKROOT = appletvos;
+ SKIP_INSTALL = YES;
+ SWIFT_VERSION = 3.0;
+ TVOS_DEPLOYMENT_TARGET = 9.0;
+ };
+ name = Release;
+ };
+/* End XCBuildConfiguration section */
+
+/* Begin XCConfigurationList section */
+ 2684F1771E95AA6900536DCC /* Build configuration list for PBXProject "SlackKit" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 2684F1831E95AA6900536DCC /* Debug */,
+ 2684F1841E95AA6900536DCC /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+ 2684F1851E95AA6900536DCC /* Build configuration list for PBXNativeTarget "SlackKit macOS" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 2684F1861E95AA6900536DCC /* Debug */,
+ 2684F1871E95AA6900536DCC /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+ 2684F1E11E95ABD400536DCC /* Build configuration list for PBXNativeTarget "SlackKit iOS" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 2684F1E21E95ABD400536DCC /* Debug */,
+ 2684F1E31E95ABD400536DCC /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+ 2684F2051E95ABD600536DCC /* Build configuration list for PBXNativeTarget "SlackKit tvOS" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 2684F2061E95ABD600536DCC /* Debug */,
+ 2684F2071E95ABD600536DCC /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+/* End XCConfigurationList section */
+ };
+ rootObject = 2684F1741E95AA6900536DCC /* Project object */;
+}
diff --git a/SlackKit.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/SlackKit.xcodeproj/project.xcworkspace/contents.xcworkspacedata
new file mode 100644
index 0000000..6c3b77a
--- /dev/null
+++ b/SlackKit.xcodeproj/project.xcworkspace/contents.xcworkspacedata
@@ -0,0 +1,7 @@
+
+
+
+
+
diff --git a/SlackKit.xcodeproj/xcshareddata/xcschemes/SlackKit iOS.xcscheme b/SlackKit.xcodeproj/xcshareddata/xcschemes/SlackKit iOS.xcscheme
new file mode 100644
index 0000000..8c9f1cc
--- /dev/null
+++ b/SlackKit.xcodeproj/xcshareddata/xcschemes/SlackKit iOS.xcscheme
@@ -0,0 +1,80 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/SlackKit.xcodeproj/xcshareddata/xcschemes/SlackKit macOS.xcscheme b/SlackKit.xcodeproj/xcshareddata/xcschemes/SlackKit macOS.xcscheme
new file mode 100644
index 0000000..c4176fb
--- /dev/null
+++ b/SlackKit.xcodeproj/xcshareddata/xcschemes/SlackKit macOS.xcscheme
@@ -0,0 +1,80 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/SlackKit.xcodeproj/xcshareddata/xcschemes/SlackKit tvOS.xcscheme b/SlackKit.xcodeproj/xcshareddata/xcschemes/SlackKit tvOS.xcscheme
new file mode 100644
index 0000000..6e23ff5
--- /dev/null
+++ b/SlackKit.xcodeproj/xcshareddata/xcschemes/SlackKit tvOS.xcscheme
@@ -0,0 +1,80 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/SlackKit/Supporting Files/Info.plist b/SlackKit/Supporting Files/Info.plist
deleted file mode 100644
index 92ffb16..0000000
--- a/SlackKit/Supporting Files/Info.plist
+++ /dev/null
@@ -1,26 +0,0 @@
-
-
-
-
- CFBundleDevelopmentRegion
- en
- CFBundleExecutable
- $(EXECUTABLE_NAME)
- CFBundleIdentifier
- $(PRODUCT_BUNDLE_IDENTIFIER)
- CFBundleInfoDictionaryVersion
- 6.0
- CFBundleName
- $(PRODUCT_NAME)
- CFBundlePackageType
- FMWK
- CFBundleShortVersionString
- 1.0
- CFBundleVersion
- $(CURRENT_PROJECT_VERSION)
- NSHumanReadableCopyright
- Copyright © 2017 Launch Software LLC. All rights reserved.
- NSPrincipalClass
-
-
-
diff --git a/SlackKit/Supporting Files/SlackKit.h b/SlackKit/Supporting Files/SlackKit.h
deleted file mode 100644
index ce1ae98..0000000
--- a/SlackKit/Supporting Files/SlackKit.h
+++ /dev/null
@@ -1,19 +0,0 @@
-//
-// SlackKit.h
-// SlackKit
-//
-// Created by Peter Zignego on 2/4/17.
-// Copyright © 2017 Launch Software LLC. All rights reserved.
-//
-
-#import
-
-//! Project version number for SlackKit.
-FOUNDATION_EXPORT double SlackKitVersionNumber;
-
-//! Project version string for SlackKit.
-FOUNDATION_EXPORT const unsigned char SlackKitVersionString[];
-
-// In this header, you should import all the public headers of your framework using statements like #import
-
-
diff --git a/SlackKit/Sources/SlackKit.swift b/Sources/SlackKit.swift
similarity index 100%
rename from SlackKit/Sources/SlackKit.swift
rename to Sources/SlackKit.swift
diff --git a/SKCore/Supporting Files/Info.plist b/Supporting Files/Info.plist
similarity index 88%
rename from SKCore/Supporting Files/Info.plist
rename to Supporting Files/Info.plist
index 92ffb16..2253315 100644
--- a/SKCore/Supporting Files/Info.plist
+++ b/Supporting Files/Info.plist
@@ -15,11 +15,11 @@
CFBundlePackageType
FMWK
CFBundleShortVersionString
- 1.0
+ 4.0.0
CFBundleVersion
$(CURRENT_PROJECT_VERSION)
NSHumanReadableCopyright
- Copyright © 2017 Launch Software LLC. All rights reserved.
+ Copyright © 2017 Peter Zignego. All rights reserved.
NSPrincipalClass