Compare commits
164 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c428cac537 | |||
| 18c6516df9 | |||
| fe450a7db2 | |||
| bb57f59553 | |||
| e5a4a67bdb | |||
| 1e304f1f6d | |||
| 81ebf86abd | |||
| afa16e98b3 | |||
| 6596bb2861 | |||
| fd12ab0600 | |||
| 31508e44dc | |||
| b980f371f6 | |||
| 9526d739e1 | |||
| c3af5c33be | |||
| c6258c57a0 | |||
| 45e075aca2 | |||
| 5ebe40a389 | |||
| 0a5a8f83f7 | |||
| 8f4a287ad0 | |||
| deadc8855a | |||
| 98155f00b7 | |||
| a55d3be65b | |||
| 3b8f1834f0 | |||
| 34972eb8af | |||
| f21179f567 | |||
| e1bf5a160f | |||
| c66a5fe0db | |||
| f03908bcc7 | |||
| 591b0d9d55 | |||
| 6e83fb93d8 | |||
| c1d202f433 | |||
| c7db8ac578 | |||
| d2e430e5bf | |||
| ebe169bf2a | |||
| ca36653dc4 | |||
| 94895edfac | |||
| 3ea13ac6c4 | |||
| e94adfc019 | |||
| 1291323c5a | |||
| 4ceb452e6b | |||
| 457504e786 | |||
| 6d9a939575 | |||
| efc3847a20 | |||
| 3ed139b503 | |||
| a4d9083f72 | |||
| 67b2fa95b3 | |||
| e031f85447 | |||
| 0b1dc6068e | |||
| b027b5b779 | |||
| e507c85ca2 | |||
| 145dfccfae | |||
| b4ca2bcc07 | |||
| 85b2d920ad | |||
| 6415a113ed | |||
| 3a2324b279 | |||
| d647a6b0c9 | |||
| 4230d7841c | |||
| 8995a54d15 | |||
| ba43a123ea | |||
| d00419dc18 | |||
| 15f3a30ba9 | |||
| befa53e3a9 | |||
| 35dfa840e8 | |||
| edf56e1678 | |||
| 3eab323564 | |||
| 0b2ee1d10e | |||
| 5444948940 | |||
| 13335b5de1 | |||
| c8d8e18db6 | |||
| c11321c116 | |||
| 0041a118a7 | |||
| 6cb5280cf5 | |||
| 9cad043957 | |||
| fa15ed8751 | |||
| 0c9c146d58 | |||
| 109a20fac2 | |||
| a6cf1e3cb6 | |||
| d3c16bed5f | |||
| 797d95ab75 | |||
| efb7bc9458 | |||
| 79e59f23fb | |||
| 01e199659e | |||
| 851b2f5e14 | |||
| c506512800 | |||
| 20fa05605b | |||
| 30baf1f76c | |||
| 1c3f01f861 | |||
| 47dc9b3d9f | |||
| b9e828ef3d | |||
| b2be8d0170 | |||
| 45be1b7a3f | |||
| 09aa72d43e | |||
| bf4b55bbd6 | |||
| a82279fad1 | |||
| 500e489d5d | |||
| 874f4f51e1 | |||
| 654f419f4e | |||
| a7c25fe33b | |||
| d2037f4cc5 | |||
| b87232dfb5 | |||
| 9e5678739f | |||
| 5cc8582d65 | |||
| aa078934c0 | |||
| 5c157caea3 | |||
| b567113b5f | |||
| 5b08fb6031 | |||
| b48f33fb72 | |||
| deccb727a1 | |||
| 8f1df8d138 | |||
| 0048710e24 | |||
| f6da0ddd32 | |||
| 513485e704 | |||
| fb3719c29d | |||
| 76fdc55f9e | |||
| 687b57fc1f | |||
| 319dc9a095 | |||
| 64440b5c5b | |||
| 3efe5752cb | |||
| 31f69e3afd | |||
| 72b29562e5 | |||
| 2b26eb35d7 | |||
| c4c8e99c0b | |||
| 5efe222196 | |||
| e56ff971b2 | |||
| 18b8a31d85 | |||
| d386730c75 | |||
| bc6e94d99a | |||
| 89f5e3786e | |||
| 0665ea0270 | |||
| 4ebc33b59a | |||
| 9e93806437 | |||
| 572e363717 | |||
| d8c8c3cb57 | |||
| 02eff541b1 | |||
| 92d6d833ea | |||
| 78b73c4c99 | |||
| dee376e1b9 | |||
| 5550658d83 | |||
| 82978bb963 | |||
| 0a203bbc68 | |||
| 38a762c60b | |||
| 96543932af | |||
| 39fa80904f | |||
| e4f0429ffb | |||
| ab41c148cd | |||
| a74aba3c5e | |||
| 9f266fff64 | |||
| 78d31af3f7 | |||
| 1a787019ec | |||
| f2f25763e7 | |||
| de3cf52687 | |||
| 49b151cd98 | |||
| e9fc66a68f | |||
| 0e25584191 | |||
| 074be89825 | |||
| 12dcb791a8 | |||
| de7dbfb9df | |||
| fe49ca7b25 | |||
| 7888b0bbba | |||
| 02791a4ea0 | |||
| 64a0b0e8dc | |||
| 6653d934f6 | |||
| 27f49dfc07 | |||
| ce02093e20 |
+5
-3
@@ -16,8 +16,10 @@ DerivedData
|
||||
*.hmap
|
||||
*.ipa
|
||||
*.xcuserstate
|
||||
.build
|
||||
|
||||
# SwiftPM
|
||||
Packages/
|
||||
.build
|
||||
|
||||
# CocoaPods
|
||||
#
|
||||
@@ -26,10 +28,10 @@ Packages/
|
||||
# http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control
|
||||
#
|
||||
Pods/
|
||||
SlackKit.xcworkspace
|
||||
|
||||
# Carthage
|
||||
#
|
||||
# Add this line if you want to avoid checking in source code from Carthage dependencies.
|
||||
# Carthage/Checkouts
|
||||
|
||||
Carthage/Checkouts
|
||||
Carthage/Build
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
3.0
|
||||
@@ -0,0 +1,2 @@
|
||||
github "https://github.com/pvzig/swifter.git" "master"
|
||||
github "https://github.com/pvzig/Starscream.git" "swift3"
|
||||
@@ -0,0 +1,2 @@
|
||||
github "pvzig/Starscream" "98d7ccea30621d51a93ee5c155b3f670e37e037b"
|
||||
github "pvzig/swifter" "8adfae89a6d34cfea1c20d53d8112d1d69e01bd0"
|
||||
+5
-3
@@ -27,7 +27,9 @@ let package = Package(
|
||||
name: "SlackKit",
|
||||
targets: [],
|
||||
dependencies: [
|
||||
.Package(url: "https://github.com/pvzig/Starscream.git",
|
||||
majorVersion: 1),
|
||||
]
|
||||
.Package(url: "https://github.com/pvzig/swifter.git",
|
||||
majorVersion: 1, minor: 3),
|
||||
.Package(url: "https://github.com/pvzig/Starscream.git", majorVersion: 1, minor: 2)
|
||||
],
|
||||
exclude: ["Examples", "Carthage", "Pods"]
|
||||
)
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
source 'https://github.com/CocoaPods/Specs.git'
|
||||
|
||||
use_frameworks!
|
||||
|
||||
target 'SlackKit' do
|
||||
pod 'Starscream'
|
||||
end
|
||||
@@ -1,10 +0,0 @@
|
||||
PODS:
|
||||
- Starscream (1.0.2)
|
||||
|
||||
DEPENDENCIES:
|
||||
- Starscream
|
||||
|
||||
SPEC CHECKSUMS:
|
||||
Starscream: 40e2c4c1c770d811f24116b8b7dbeb4542c56767
|
||||
|
||||
COCOAPODS: 0.39.0
|
||||
@@ -1,156 +1,304 @@
|
||||

|
||||
##iOS/OS X Slack Client Library
|
||||
###Description
|
||||
This is a Slack client library for iOS and OS X written in Swift. It's intended to expose all of the functionality of Slack's [Real Time Messaging API](https://api.slack.com/rtm).
|
||||
## SlackKit: A Swift Slack Client Library
|
||||
### Description
|
||||
|
||||
###Installation
|
||||
####Swift Package Manager (Swift 2.2 and up)
|
||||
This is the Swift 3 beta branch. It will continue to track the Xcode 8 beta releases until it is officially released, at which point Swift 3 will be merged down to the master branch.
|
||||
|
||||
SlackKit also supports: [Swift 2.2](https://github.com/pvzig/SlackKit/), [Linux](https://github.com/pvzig/SlackKit/tree/linux)
|
||||
|
||||
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).
|
||||
|
||||
#### 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:
|
||||
|
||||
### Installation
|
||||
|
||||
#### Carthage
|
||||
|
||||
Add SlackKit to your Cartfile:
|
||||
```
|
||||
github "https://github.com/pvzig/slackkit.git" "swift3"
|
||||
```
|
||||
and run
|
||||
```
|
||||
carthage bootstrap
|
||||
```
|
||||
**Note:** SlackKit currently takes a _long_ time for the compiler to compile with optimizations turned on. I'm currently exploring a potential fix for this issue. In the meantime, you may want to skip the waiting and build it in the debug configuration instead:
|
||||
```
|
||||
carthage bootstrap --configuration "Debug"
|
||||
```
|
||||
Drag the built `SlackKit.framework` into your Xcode project.
|
||||
|
||||
#### Swift Package Manager
|
||||
Add SlackKit to your Package.swift
|
||||
|
||||
```swift
|
||||
import PackageDescription
|
||||
|
||||
let package = Package(
|
||||
dependencies: [
|
||||
.Package(url: "https://github.com/pvzig/SlackKit.git", majorVersion: 0)
|
||||
.Package(url: "https://github.com/pvzig/SlackKit.git", majorVersion: 3)
|
||||
]
|
||||
)
|
||||
```
|
||||
|
||||
Run `swift-build` on your application’s main directory.
|
||||
|
||||
####CocoaPods
|
||||
Add the pod to your podfile:
|
||||
```
|
||||
pod 'SlackKit'
|
||||
```
|
||||
and run
|
||||
```
|
||||
pod install
|
||||
```
|
||||
Run `swift build` on your application’s main directory.
|
||||
|
||||
To use the library in your project import it:
|
||||
```
|
||||
import SlackKit
|
||||
```
|
||||
|
||||
###Usage
|
||||
To use 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).
|
||||
### Usage
|
||||
|
||||
Once you have a token, give it to the Client:
|
||||
#### 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
|
||||
Client.sharedInstance.setAuthToken("YOUR_SLACK_AUTH_TOKEN")
|
||||
func authorizeRequest(scope:[Scope], redirectURI: String, state: String = "slackkit", team: String? = nil)
|
||||
```
|
||||
and connect:
|
||||
|
||||
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
|
||||
Client.sharedInstance.connect()
|
||||
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.
|
||||
|
||||
####Delegate methods
|
||||
#### 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.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({ (authenticated) -> Void in
|
||||
print(authenticated)
|
||||
}){(error) -> Void in
|
||||
print(error)
|
||||
}
|
||||
```
|
||||
|
||||
#### 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: "CLIENT_ID", clientSecret: "CLIENT_SECRET")
|
||||
bot.onClientInitalization = { (client: Client) in
|
||||
dispatch_async(dispatch_get_main_queue(), {
|
||||
client.connectionEventsDelegate = self
|
||||
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.
|
||||
|
||||
#####SlackEventsDelegate
|
||||
##### ConnectionEventsDelegate
|
||||
```swift
|
||||
func clientConnected()
|
||||
func clientDisconnected()
|
||||
func preferenceChanged(preference: String, value: AnyObject)
|
||||
func userChanged(user: User)
|
||||
func presenceChanged(user: User?, presence: String?)
|
||||
func manualPresenceChanged(user: User?, presence: String?)
|
||||
func botEvent(bot: Bot)
|
||||
clientConnected(client: Client)
|
||||
clientDisconnected(client: Client)
|
||||
clientConnectionFailed(client: Client, error: SlackError)
|
||||
```
|
||||
##### MessageEventsDelegate
|
||||
```swift
|
||||
messageSent(client: Client, message: Message)
|
||||
messageReceived(client: Client, message: Message)
|
||||
messageChanged(client: Client, message: Message)
|
||||
messageDeleted(client: Client, message: Message?)
|
||||
```
|
||||
##### ChannelEventsDelegate
|
||||
```swift
|
||||
userTyping(client: Client, channel: Channel, user: User)
|
||||
channelMarked(client: Client, channel: Channel, timestamp: String)
|
||||
channelCreated(client: Client, channel: Channel)
|
||||
channelDeleted(client: Client, channel: Channel)
|
||||
channelRenamed(client: Client, channel: Channel)
|
||||
channelArchived(client: Client, channel: Channel)
|
||||
channelHistoryChanged(client: Client, channel: Channel)
|
||||
channelJoined(client: Client, channel: Channel)
|
||||
channelLeft(client: Client, channel: Channel)
|
||||
```
|
||||
##### DoNotDisturbEventsDelegate
|
||||
```swift
|
||||
doNotDisturbUpdated(client: Client, dndStatus: DoNotDisturbStatus)
|
||||
doNotDisturbUserUpdated(client: Client, dndStatus: DoNotDisturbStatus, user: User)
|
||||
```
|
||||
##### GroupEventsDelegate
|
||||
```swift
|
||||
groupOpened(client: Client, group: Channel)
|
||||
```
|
||||
##### FileEventsDelegate
|
||||
```swift
|
||||
fileProcessed(client: Client, file: File)
|
||||
fileMadePrivate(client: Client, file: File)
|
||||
fileDeleted(client: Client, file: File)
|
||||
fileCommentAdded(client: Client, file: File, comment: Comment)
|
||||
fileCommentEdited(client: Client, file: File, comment: Comment)
|
||||
fileCommentDeleted(client: Client, file: File, comment: Comment)
|
||||
```
|
||||
##### PinEventsDelegate
|
||||
```swift
|
||||
itemPinned(client: Client, item: Item, channel: Channel?)
|
||||
itemUnpinned(client: Client, item: Item, channel: Channel?)
|
||||
```
|
||||
##### StarEventsDelegate
|
||||
```swift
|
||||
itemStarred(client: Client, item: Item, star: Bool)
|
||||
```
|
||||
##### ReactionEventsDelegate
|
||||
```swift
|
||||
reactionAdded(client: Client, reaction: String, item: Item, itemUser: String)
|
||||
reactionRemoved(client: Client, reaction: String, item: Item, itemUser: String)
|
||||
```
|
||||
##### SlackEventsDelegate
|
||||
```swift
|
||||
preferenceChanged(client: Client, preference: String, value: AnyObject?)
|
||||
userChanged(client: Client, user: User)
|
||||
presenceChanged(client: Client, user: User, presence: String)
|
||||
manualPresenceChanged(client: Client, user: User, presence: String)
|
||||
botEvent(client: Client, bot: Bot)
|
||||
```
|
||||
##### TeamEventsDelegate
|
||||
```swift
|
||||
teamJoined(client: Client, user: User)
|
||||
teamPlanChanged(client: Client, plan: String)
|
||||
teamPreferencesChanged(client: Client, preference: String, value: AnyObject?)
|
||||
teamNameChanged(client: Client, name: String)
|
||||
teamDomainChanged(client: Client, domain: String)
|
||||
teamEmailDomainChanged(client: Client, domain: String)
|
||||
teamEmojiChanged(client: Client)
|
||||
```
|
||||
##### SubteamEventsDelegate
|
||||
```swift
|
||||
subteamEvent(client: Client, userGroup: UserGroup)
|
||||
subteamSelfAdded(client: Client, subteamID: String)
|
||||
subteamSelfRemoved(client: Client, subteamID: String)
|
||||
```
|
||||
##### TeamProfileEventsDelegate
|
||||
```swift
|
||||
teamProfileChanged(client: Client, profile: CustomProfile)
|
||||
teamProfileDeleted(client: Client, profile: CustomProfile)
|
||||
teamProfileReordered(client: Client, profile: CustomProfile)
|
||||
```
|
||||
|
||||
#####MessageEventsDelegate
|
||||
```swift
|
||||
func messageSent(message: Message)
|
||||
func messageReceived(message: Message)
|
||||
func messageChanged(message: Message)
|
||||
func messageDeleted(message: Message?)
|
||||
```
|
||||
### Examples
|
||||
[Check out example applications here.](https://github.com/pvzig/SlackKit-examples)
|
||||
|
||||
#####ChannelEventsDelegate
|
||||
```swift
|
||||
func userTyping(channel: Channel?, user: User?)
|
||||
func channelMarked(channel: Channel, timestamp: String?)
|
||||
func channelCreated(channel: Channel)
|
||||
func channelDeleted(channel: Channel)
|
||||
func channelRenamed(channel: Channel)
|
||||
func channelArchived(channel: Channel)
|
||||
func channelHistoryChanged(channel: Channel)
|
||||
func channelJoined(channel: Channel)
|
||||
func channelLeft(channel: Channel)
|
||||
```
|
||||
|
||||
#####DoNotDisturbEventsDelegate
|
||||
```swift
|
||||
doNotDisturbUpdated(dndStatus: DoNotDisturbStatus)
|
||||
doNotDisturbUserUpdated(dndStatus: DoNotDisturbStatus, user: User?)
|
||||
```
|
||||
|
||||
#####GroupEventsDelegate
|
||||
```swift
|
||||
func groupOpened(group: Channel)
|
||||
```
|
||||
|
||||
#####FileEventsDelegate
|
||||
```swift
|
||||
func fileProcessed(file: File)
|
||||
func fileMadePrivate(file: File)
|
||||
func fileDeleted(file: File)
|
||||
func fileCommentAdded(file: File, comment: Comment)
|
||||
func fileCommentEdited(file: File, comment: Comment)
|
||||
func fileCommentDeleted(file: File, comment: Comment)
|
||||
```
|
||||
|
||||
#####PinEventsDelegate
|
||||
```swift
|
||||
func itemPinned(item: Item?, channel: Channel?)
|
||||
func itemUnpinned(item: Item?, channel: Channel?)
|
||||
```
|
||||
|
||||
#####StarEventsDelegate
|
||||
```swift
|
||||
func itemStarred(item: Item, star: Bool)
|
||||
```
|
||||
|
||||
#####ReactionEventsDelegate
|
||||
```swift
|
||||
func reactionAdded(reaction: String?, item: Item?)
|
||||
func reactionRemoved(reaction: String?, item: Item?)
|
||||
```
|
||||
|
||||
#####TeamEventsDelegate
|
||||
```swift
|
||||
func teamJoined(user: User)
|
||||
func teamPlanChanged(plan: String)
|
||||
func teamPreferencesChanged(preference: String, value: AnyObject)
|
||||
func teamNameChanged(name: String)
|
||||
func teamDomainChanged(domain: String)
|
||||
func teamEmailDomainChanged(domain: String)
|
||||
func teamEmojiChanged()
|
||||
```
|
||||
|
||||
#####SubteamEventsDelegate
|
||||
```swift
|
||||
func subteamEvent(userGroup: UserGroup)
|
||||
func subteamSelfAdded(subteamID: String)
|
||||
func subteamSelfRemoved(subteamID: String)
|
||||
```
|
||||
|
||||
###Examples
|
||||
####Sending a Message:
|
||||
```swift
|
||||
Client.sharedInstance.sendMessage(message: "Hello, world!", channelID: "CHANNEL_ID")
|
||||
```
|
||||
|
||||
####Print a List of Users in a Channel:
|
||||
```swift
|
||||
let users = Client.sharedInstance.channels?["CHANNEL_ID"]?.members
|
||||
print(users)
|
||||
```
|
||||
|
||||
###Get In Touch
|
||||
### Get In Touch
|
||||
[@pvzig](https://twitter.com/pvzig)
|
||||
|
||||
<peter@launchsoft.co>
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
Pod::Spec.new do |s|
|
||||
s.name = "SlackKit"
|
||||
s.version = "0.9.5"
|
||||
s.summary = "a Slack client library for iOS and OS X written 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/pvzig/SlackKit.git", :tag => s.version.to_s }
|
||||
s.social_media_url = 'https://twitter.com/pvzig'
|
||||
s.ios.deployment_target = '8.0'
|
||||
s.osx.deployment_target = '10.9'
|
||||
s.requires_arc = true
|
||||
s.source_files = 'SlackKit/*.swift'
|
||||
s.frameworks = 'Foundation'
|
||||
s.dependency 'Starscream', '~> 1.0.2'
|
||||
end
|
||||
@@ -7,42 +7,209 @@
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
2601D61B1C7646B80012BF22 /* SlackError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2601D61A1C7646B80012BF22 /* SlackError.swift */; };
|
||||
260EC2331C4DC61D0093B253 /* Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 260EC2301C4DC61D0093B253 /* Extensions.swift */; };
|
||||
260EC2341C4DC61D0093B253 /* NetworkInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 260EC2311C4DC61D0093B253 /* NetworkInterface.swift */; };
|
||||
260EC2351C4DC61D0093B253 /* WebAPI.swift in Sources */ = {isa = PBXBuildFile; fileRef = 260EC2321C4DC61D0093B253 /* WebAPI.swift */; };
|
||||
263993901CE90C87004A6E93 /* SlackKit.h in Headers */ = {isa = PBXBuildFile; fileRef = 2661A6A41BBF62FF0026F67B /* SlackKit.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
263993971CE90EE0004A6E93 /* Client+Utilities.swift in Sources */ = {isa = PBXBuildFile; fileRef = C16C98791CE7D3DD00692776 /* Client+Utilities.swift */; };
|
||||
263993981CE90EE0004A6E93 /* Channel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26BBA1881C398E3C00BF7225 /* Channel.swift */; };
|
||||
263993991CE90EE0004A6E93 /* User.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26BBA1921C398E3C00BF7225 /* User.swift */; };
|
||||
2639939B1CE90EE0004A6E93 /* Client.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26BBA1891C398E3C00BF7225 /* Client.swift */; };
|
||||
2639939C1CE90EE0004A6E93 /* Event.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26BBA18A1C398E3C00BF7225 /* Event.swift */; };
|
||||
2639939D1CE90EE0004A6E93 /* Bot.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26BBA1871C398E3C00BF7225 /* Bot.swift */; };
|
||||
2639939E1CE90EE0004A6E93 /* Client+EventDispatching.swift in Sources */ = {isa = PBXBuildFile; fileRef = C1A85FF71CE3BCEF00756C40 /* Client+EventDispatching.swift */; };
|
||||
2639939F1CE90EE0004A6E93 /* File.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26BBA18E1C398E3C00BF7225 /* File.swift */; };
|
||||
263993A01CE90EE0004A6E93 /* WebAPI.swift in Sources */ = {isa = PBXBuildFile; fileRef = 260EC2321C4DC61D0093B253 /* WebAPI.swift */; };
|
||||
263993A11CE90EE0004A6E93 /* Attachment.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26DF40341C7A0FA300E19241 /* Attachment.swift */; };
|
||||
263993A21CE90EE0004A6E93 /* Message.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26BBA18F1C398E3C00BF7225 /* Message.swift */; };
|
||||
263993A31CE90EE0004A6E93 /* Team.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26BBA1901C398E3C00BF7225 /* Team.swift */; };
|
||||
263993A41CE90EE0004A6E93 /* Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 260EC2301C4DC61D0093B253 /* Extensions.swift */; };
|
||||
263993A51CE90EE0004A6E93 /* UserGroup.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26BBA1931C398E3C00BF7225 /* UserGroup.swift */; };
|
||||
263993A61CE90EE0004A6E93 /* SlackError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2601D61A1C7646B80012BF22 /* SlackError.swift */; };
|
||||
263993A71CE90EE0004A6E93 /* Client+EventHandling.swift in Sources */ = {isa = PBXBuildFile; fileRef = C1A85FF81CE3BCEF00756C40 /* Client+EventHandling.swift */; };
|
||||
263993A81CE90EE0004A6E93 /* NetworkInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 260EC2311C4DC61D0093B253 /* NetworkInterface.swift */; };
|
||||
263993A91CE90EE0004A6E93 /* EventDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26BBA18B1C398E3C00BF7225 /* EventDelegate.swift */; };
|
||||
263993AB1CE90EE0004A6E93 /* Starscream.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4307A07F1CC6D0910011D5DE /* Starscream.framework */; };
|
||||
263993AD1CE90EE0004A6E93 /* SlackKit.h in Headers */ = {isa = PBXBuildFile; fileRef = 2661A6A41BBF62FF0026F67B /* SlackKit.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
263993B61CE90EED004A6E93 /* Client+Utilities.swift in Sources */ = {isa = PBXBuildFile; fileRef = C16C98791CE7D3DD00692776 /* Client+Utilities.swift */; };
|
||||
263993B71CE90EED004A6E93 /* Channel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26BBA1881C398E3C00BF7225 /* Channel.swift */; };
|
||||
263993B81CE90EED004A6E93 /* User.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26BBA1921C398E3C00BF7225 /* User.swift */; };
|
||||
263993BA1CE90EED004A6E93 /* Client.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26BBA1891C398E3C00BF7225 /* Client.swift */; };
|
||||
263993BB1CE90EED004A6E93 /* Event.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26BBA18A1C398E3C00BF7225 /* Event.swift */; };
|
||||
263993BC1CE90EED004A6E93 /* Bot.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26BBA1871C398E3C00BF7225 /* Bot.swift */; };
|
||||
263993BD1CE90EED004A6E93 /* Client+EventDispatching.swift in Sources */ = {isa = PBXBuildFile; fileRef = C1A85FF71CE3BCEF00756C40 /* Client+EventDispatching.swift */; };
|
||||
263993BE1CE90EED004A6E93 /* File.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26BBA18E1C398E3C00BF7225 /* File.swift */; };
|
||||
263993BF1CE90EED004A6E93 /* WebAPI.swift in Sources */ = {isa = PBXBuildFile; fileRef = 260EC2321C4DC61D0093B253 /* WebAPI.swift */; };
|
||||
263993C01CE90EED004A6E93 /* Attachment.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26DF40341C7A0FA300E19241 /* Attachment.swift */; };
|
||||
263993C11CE90EED004A6E93 /* Message.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26BBA18F1C398E3C00BF7225 /* Message.swift */; };
|
||||
263993C21CE90EED004A6E93 /* Team.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26BBA1901C398E3C00BF7225 /* Team.swift */; };
|
||||
263993C31CE90EED004A6E93 /* Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 260EC2301C4DC61D0093B253 /* Extensions.swift */; };
|
||||
263993C41CE90EED004A6E93 /* UserGroup.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26BBA1931C398E3C00BF7225 /* UserGroup.swift */; };
|
||||
263993C51CE90EED004A6E93 /* SlackError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2601D61A1C7646B80012BF22 /* SlackError.swift */; };
|
||||
263993C61CE90EED004A6E93 /* Client+EventHandling.swift in Sources */ = {isa = PBXBuildFile; fileRef = C1A85FF81CE3BCEF00756C40 /* Client+EventHandling.swift */; };
|
||||
263993C71CE90EED004A6E93 /* NetworkInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 260EC2311C4DC61D0093B253 /* NetworkInterface.swift */; };
|
||||
263993C81CE90EED004A6E93 /* EventDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26BBA18B1C398E3C00BF7225 /* EventDelegate.swift */; };
|
||||
263993CA1CE90EED004A6E93 /* Starscream.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4307A07F1CC6D0910011D5DE /* Starscream.framework */; };
|
||||
263993CC1CE90EED004A6E93 /* SlackKit.h in Headers */ = {isa = PBXBuildFile; fileRef = 2661A6A41BBF62FF0026F67B /* SlackKit.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
2678B5941D3151B900CE521A /* AuthorizeResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2678B5931D3151B900CE521A /* AuthorizeResponse.swift */; };
|
||||
2678B5951D3151B900CE521A /* AuthorizeResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2678B5931D3151B900CE521A /* AuthorizeResponse.swift */; };
|
||||
2678B5961D3151B900CE521A /* AuthorizeResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2678B5931D3151B900CE521A /* AuthorizeResponse.swift */; };
|
||||
2678B5971D3151C600CE521A /* MessageActionRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26B30B871D297A98004D4AB5 /* MessageActionRequest.swift */; };
|
||||
2678B5981D3151C900CE521A /* Response.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26B30B931D298E78004D4AB5 /* Response.swift */; };
|
||||
2678B5991D3151CD00CE521A /* WebhookRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26B30B981D298F25004D4AB5 /* WebhookRequest.swift */; };
|
||||
269B475A1D3493DE0042D137 /* OAuthResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = 269B47591D3493DE0042D137 /* OAuthResponse.swift */; };
|
||||
269B475B1D3493DE0042D137 /* OAuthResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = 269B47591D3493DE0042D137 /* OAuthResponse.swift */; };
|
||||
269B475C1D3493DE0042D137 /* OAuthResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = 269B47591D3493DE0042D137 /* OAuthResponse.swift */; };
|
||||
269B475E1D3538E90042D137 /* SlackKit.swift in Sources */ = {isa = PBXBuildFile; fileRef = 269B475D1D3538E90042D137 /* SlackKit.swift */; };
|
||||
269B475F1D3538E90042D137 /* SlackKit.swift in Sources */ = {isa = PBXBuildFile; fileRef = 269B475D1D3538E90042D137 /* SlackKit.swift */; };
|
||||
269B47601D3538E90042D137 /* SlackKit.swift in Sources */ = {isa = PBXBuildFile; fileRef = 269B475D1D3538E90042D137 /* SlackKit.swift */; };
|
||||
269B47621D3544240042D137 /* IncomingWebhook.swift in Sources */ = {isa = PBXBuildFile; fileRef = 269B47611D3544240042D137 /* IncomingWebhook.swift */; };
|
||||
269B47631D3544240042D137 /* IncomingWebhook.swift in Sources */ = {isa = PBXBuildFile; fileRef = 269B47611D3544240042D137 /* IncomingWebhook.swift */; };
|
||||
269B47641D3544240042D137 /* IncomingWebhook.swift in Sources */ = {isa = PBXBuildFile; fileRef = 269B47611D3544240042D137 /* IncomingWebhook.swift */; };
|
||||
269B47661D39AAA80042D137 /* MessageActionResponder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 269B47651D39AAA80042D137 /* MessageActionResponder.swift */; };
|
||||
269B47671D39AAA80042D137 /* MessageActionResponder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 269B47651D39AAA80042D137 /* MessageActionResponder.swift */; };
|
||||
269B47681D39AAA80042D137 /* MessageActionResponder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 269B47651D39AAA80042D137 /* MessageActionResponder.swift */; };
|
||||
269B47C71D3AE25B0042D137 /* MessageActionServer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26B30B8F1D298E08004D4AB5 /* MessageActionServer.swift */; };
|
||||
269B47C81D3AE25B0042D137 /* MessageActionServer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26B30B8F1D298E08004D4AB5 /* MessageActionServer.swift */; };
|
||||
269B47C91D3AE2620042D137 /* Server.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26B30B911D298E12004D4AB5 /* Server.swift */; };
|
||||
269B47CA1D3AE2670042D137 /* WebhookServer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26EC15001D260B1000FD3A53 /* WebhookServer.swift */; };
|
||||
269B47CE1D3C22FC0042D137 /* ClientOptions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 269B47CD1D3C22FC0042D137 /* ClientOptions.swift */; };
|
||||
269B47CF1D3C22FC0042D137 /* ClientOptions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 269B47CD1D3C22FC0042D137 /* ClientOptions.swift */; };
|
||||
269B47D01D3C22FC0042D137 /* ClientOptions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 269B47CD1D3C22FC0042D137 /* ClientOptions.swift */; };
|
||||
26B30B6C1D289FA0004D4AB5 /* Swifter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 26B30B6B1D289FA0004D4AB5 /* Swifter.framework */; };
|
||||
26B30B881D297A98004D4AB5 /* MessageActionRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26B30B871D297A98004D4AB5 /* MessageActionRequest.swift */; };
|
||||
26B30B901D298E08004D4AB5 /* MessageActionServer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26B30B8F1D298E08004D4AB5 /* MessageActionServer.swift */; };
|
||||
26B30B921D298E12004D4AB5 /* Server.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26B30B911D298E12004D4AB5 /* Server.swift */; };
|
||||
26B30B941D298E78004D4AB5 /* Response.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26B30B931D298E78004D4AB5 /* Response.swift */; };
|
||||
26B30B951D298E78004D4AB5 /* Response.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26B30B931D298E78004D4AB5 /* Response.swift */; };
|
||||
26B30B961D298EE1004D4AB5 /* MessageActionRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26B30B871D297A98004D4AB5 /* MessageActionRequest.swift */; };
|
||||
26B30B971D298EED004D4AB5 /* Server.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26B30B911D298E12004D4AB5 /* Server.swift */; };
|
||||
26B30B991D298F25004D4AB5 /* WebhookRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26B30B981D298F25004D4AB5 /* WebhookRequest.swift */; };
|
||||
26B30B9A1D298F25004D4AB5 /* WebhookRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26B30B981D298F25004D4AB5 /* WebhookRequest.swift */; };
|
||||
26B30BB61D2BC2E4004D4AB5 /* Scope.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26B30BB51D2BC2E4004D4AB5 /* Scope.swift */; };
|
||||
26B30BB71D2BC2E4004D4AB5 /* Scope.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26B30BB51D2BC2E4004D4AB5 /* Scope.swift */; };
|
||||
26B30BB81D2BC2E4004D4AB5 /* Scope.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26B30BB51D2BC2E4004D4AB5 /* Scope.swift */; };
|
||||
26B30BC31D2DFF0D004D4AB5 /* OAuthServer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26B30BC21D2DFF0D004D4AB5 /* OAuthServer.swift */; };
|
||||
26B30BC41D2DFF0D004D4AB5 /* OAuthServer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26B30BC21D2DFF0D004D4AB5 /* OAuthServer.swift */; };
|
||||
26B30BC51D2DFF0D004D4AB5 /* OAuthServer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26B30BC21D2DFF0D004D4AB5 /* OAuthServer.swift */; };
|
||||
26B30BC71D2DFF7D004D4AB5 /* AuthorizeRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26B30BC61D2DFF7D004D4AB5 /* AuthorizeRequest.swift */; };
|
||||
26B30BC81D2DFF7D004D4AB5 /* AuthorizeRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26B30BC61D2DFF7D004D4AB5 /* AuthorizeRequest.swift */; };
|
||||
26B30BC91D2DFF7D004D4AB5 /* AuthorizeRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26B30BC61D2DFF7D004D4AB5 /* AuthorizeRequest.swift */; };
|
||||
26BBA1941C398E3C00BF7225 /* Bot.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26BBA1871C398E3C00BF7225 /* Bot.swift */; };
|
||||
26BBA1951C398E3C00BF7225 /* Channel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26BBA1881C398E3C00BF7225 /* Channel.swift */; };
|
||||
26BBA1961C398E3C00BF7225 /* Client.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26BBA1891C398E3C00BF7225 /* Client.swift */; };
|
||||
26BBA1971C398E3C00BF7225 /* Event.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26BBA18A1C398E3C00BF7225 /* Event.swift */; };
|
||||
26BBA1981C398E3C00BF7225 /* EventDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26BBA18B1C398E3C00BF7225 /* EventDelegate.swift */; };
|
||||
26BBA1991C398E3C00BF7225 /* EventDispatcher.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26BBA18C1C398E3C00BF7225 /* EventDispatcher.swift */; };
|
||||
26BBA19A1C398E3C00BF7225 /* EventHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26BBA18D1C398E3C00BF7225 /* EventHandler.swift */; };
|
||||
26BBA19B1C398E3C00BF7225 /* File.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26BBA18E1C398E3C00BF7225 /* File.swift */; };
|
||||
26BBA19C1C398E3C00BF7225 /* Message.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26BBA18F1C398E3C00BF7225 /* Message.swift */; };
|
||||
26BBA19D1C398E3C00BF7225 /* Team.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26BBA1901C398E3C00BF7225 /* Team.swift */; };
|
||||
26BBA19E1C398E3C00BF7225 /* Types.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26BBA1911C398E3C00BF7225 /* Types.swift */; };
|
||||
26BBA19F1C398E3C00BF7225 /* User.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26BBA1921C398E3C00BF7225 /* User.swift */; };
|
||||
26BBA1A01C398E3C00BF7225 /* UserGroup.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26BBA1931C398E3C00BF7225 /* UserGroup.swift */; };
|
||||
FFE3AC870D1C42EF276CCA2D /* Pods_SlackKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 407A2ABFC0611867E2BE34D0 /* Pods_SlackKit.framework */; };
|
||||
26DF40351C7A0FA300E19241 /* Attachment.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26DF40341C7A0FA300E19241 /* Attachment.swift */; };
|
||||
26EC14C11D1EF16500FD3A53 /* AttachmentField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26EC14C01D1EF16500FD3A53 /* AttachmentField.swift */; };
|
||||
26EC14C21D1EF16500FD3A53 /* AttachmentField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26EC14C01D1EF16500FD3A53 /* AttachmentField.swift */; };
|
||||
26EC14C31D1EF16500FD3A53 /* AttachmentField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26EC14C01D1EF16500FD3A53 /* AttachmentField.swift */; };
|
||||
26EC14C91D1EF17400FD3A53 /* Comment.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26EC14C41D1EF17400FD3A53 /* Comment.swift */; };
|
||||
26EC14CA1D1EF17400FD3A53 /* Comment.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26EC14C41D1EF17400FD3A53 /* Comment.swift */; };
|
||||
26EC14CB1D1EF17400FD3A53 /* Comment.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26EC14C41D1EF17400FD3A53 /* Comment.swift */; };
|
||||
26EC14CC1D1EF17400FD3A53 /* CustomProfile.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26EC14C51D1EF17400FD3A53 /* CustomProfile.swift */; };
|
||||
26EC14CD1D1EF17400FD3A53 /* CustomProfile.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26EC14C51D1EF17400FD3A53 /* CustomProfile.swift */; };
|
||||
26EC14CE1D1EF17400FD3A53 /* CustomProfile.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26EC14C51D1EF17400FD3A53 /* CustomProfile.swift */; };
|
||||
26EC14CF1D1EF17400FD3A53 /* CustomProfileField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26EC14C61D1EF17400FD3A53 /* CustomProfileField.swift */; };
|
||||
26EC14D01D1EF17400FD3A53 /* CustomProfileField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26EC14C61D1EF17400FD3A53 /* CustomProfileField.swift */; };
|
||||
26EC14D11D1EF17400FD3A53 /* CustomProfileField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26EC14C61D1EF17400FD3A53 /* CustomProfileField.swift */; };
|
||||
26EC14D21D1EF17400FD3A53 /* DoNotDisturbStatus.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26EC14C71D1EF17400FD3A53 /* DoNotDisturbStatus.swift */; };
|
||||
26EC14D31D1EF17400FD3A53 /* DoNotDisturbStatus.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26EC14C71D1EF17400FD3A53 /* DoNotDisturbStatus.swift */; };
|
||||
26EC14D41D1EF17400FD3A53 /* DoNotDisturbStatus.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26EC14C71D1EF17400FD3A53 /* DoNotDisturbStatus.swift */; };
|
||||
26EC14D51D1EF17400FD3A53 /* Edited.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26EC14C81D1EF17400FD3A53 /* Edited.swift */; };
|
||||
26EC14D61D1EF17400FD3A53 /* Edited.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26EC14C81D1EF17400FD3A53 /* Edited.swift */; };
|
||||
26EC14D71D1EF17400FD3A53 /* Edited.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26EC14C81D1EF17400FD3A53 /* Edited.swift */; };
|
||||
26EC14DA1D1EF17E00FD3A53 /* History.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26EC14D81D1EF17E00FD3A53 /* History.swift */; };
|
||||
26EC14DB1D1EF17E00FD3A53 /* History.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26EC14D81D1EF17E00FD3A53 /* History.swift */; };
|
||||
26EC14DC1D1EF17E00FD3A53 /* History.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26EC14D81D1EF17E00FD3A53 /* History.swift */; };
|
||||
26EC14DD1D1EF17E00FD3A53 /* Item.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26EC14D91D1EF17E00FD3A53 /* Item.swift */; };
|
||||
26EC14DE1D1EF17E00FD3A53 /* Item.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26EC14D91D1EF17E00FD3A53 /* Item.swift */; };
|
||||
26EC14DF1D1EF17E00FD3A53 /* Item.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26EC14D91D1EF17E00FD3A53 /* Item.swift */; };
|
||||
26EC14E11D1EF18700FD3A53 /* Reaction.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26EC14E01D1EF18700FD3A53 /* Reaction.swift */; };
|
||||
26EC14E21D1EF18700FD3A53 /* Reaction.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26EC14E01D1EF18700FD3A53 /* Reaction.swift */; };
|
||||
26EC14E31D1EF18700FD3A53 /* Reaction.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26EC14E01D1EF18700FD3A53 /* Reaction.swift */; };
|
||||
26EC14E61D1EF18F00FD3A53 /* TeamIcon.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26EC14E41D1EF18F00FD3A53 /* TeamIcon.swift */; };
|
||||
26EC14E71D1EF18F00FD3A53 /* TeamIcon.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26EC14E41D1EF18F00FD3A53 /* TeamIcon.swift */; };
|
||||
26EC14E81D1EF18F00FD3A53 /* TeamIcon.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26EC14E41D1EF18F00FD3A53 /* TeamIcon.swift */; };
|
||||
26EC14E91D1EF18F00FD3A53 /* Topic.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26EC14E51D1EF18F00FD3A53 /* Topic.swift */; };
|
||||
26EC14EA1D1EF18F00FD3A53 /* Topic.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26EC14E51D1EF18F00FD3A53 /* Topic.swift */; };
|
||||
26EC14EB1D1EF18F00FD3A53 /* Topic.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26EC14E51D1EF18F00FD3A53 /* Topic.swift */; };
|
||||
26EC14F91D1F355A00FD3A53 /* Action.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26EC14F81D1F355A00FD3A53 /* Action.swift */; };
|
||||
26EC14FA1D1F355A00FD3A53 /* Action.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26EC14F81D1F355A00FD3A53 /* Action.swift */; };
|
||||
26EC14FB1D1F355A00FD3A53 /* Action.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26EC14F81D1F355A00FD3A53 /* Action.swift */; };
|
||||
26EC15011D260B1000FD3A53 /* WebhookServer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26EC15001D260B1000FD3A53 /* WebhookServer.swift */; };
|
||||
26EC15021D260B1000FD3A53 /* WebhookServer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26EC15001D260B1000FD3A53 /* WebhookServer.swift */; };
|
||||
26F76EB21D40318F00C3A3DD /* Swifter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 26B30B6E1D289FB2004D4AB5 /* Swifter.framework */; };
|
||||
26F76EB31D40319700C3A3DD /* Swifter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 269B47CB1D3AE5670042D137 /* Swifter.framework */; };
|
||||
4307A0801CC6D0910011D5DE /* Starscream.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4307A07F1CC6D0910011D5DE /* Starscream.framework */; };
|
||||
C16C987A1CE7D3DD00692776 /* Client+Utilities.swift in Sources */ = {isa = PBXBuildFile; fileRef = C16C98791CE7D3DD00692776 /* Client+Utilities.swift */; };
|
||||
C1A85FF91CE3BCEF00756C40 /* Client+EventDispatching.swift in Sources */ = {isa = PBXBuildFile; fileRef = C1A85FF71CE3BCEF00756C40 /* Client+EventDispatching.swift */; };
|
||||
C1A85FFA1CE3BCEF00756C40 /* Client+EventHandling.swift in Sources */ = {isa = PBXBuildFile; fileRef = C1A85FF81CE3BCEF00756C40 /* Client+EventHandling.swift */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
2601D61A1C7646B80012BF22 /* SlackError.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SlackError.swift; path = Sources/SlackError.swift; sourceTree = "<group>"; };
|
||||
26072A341BB48B3A00CD650C /* SlackKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SlackKit.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
260EC2301C4DC61D0093B253 /* Extensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Extensions.swift; path = Sources/Extensions.swift; sourceTree = "<group>"; };
|
||||
260EC2311C4DC61D0093B253 /* NetworkInterface.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = NetworkInterface.swift; path = Sources/NetworkInterface.swift; sourceTree = "<group>"; };
|
||||
260EC2321C4DC61D0093B253 /* WebAPI.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = WebAPI.swift; path = Sources/WebAPI.swift; sourceTree = "<group>"; };
|
||||
263993B21CE90EE0004A6E93 /* SlackKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SlackKit.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
263993D11CE90EED004A6E93 /* SlackKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SlackKit.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
2661A6A41BBF62FF0026F67B /* SlackKit.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SlackKit.h; sourceTree = "<group>"; };
|
||||
266E05F01BBF780C00840D76 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
2678B5931D3151B900CE521A /* AuthorizeResponse.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = AuthorizeResponse.swift; path = Sources/AuthorizeResponse.swift; sourceTree = "<group>"; };
|
||||
268E46131CE8F79D009F19CC /* Info-iOS.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = "Info-iOS.plist"; path = "Supporting Files/Info-iOS.plist"; sourceTree = "<group>"; };
|
||||
268E46141CE8F79D009F19CC /* Info-tvOS.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = "Info-tvOS.plist"; path = "Supporting Files/Info-tvOS.plist"; sourceTree = "<group>"; };
|
||||
268E46151CE8F79D009F19CC /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = Info.plist; path = "Supporting Files/Info.plist"; sourceTree = "<group>"; };
|
||||
269B47591D3493DE0042D137 /* OAuthResponse.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = OAuthResponse.swift; path = Sources/OAuthResponse.swift; sourceTree = "<group>"; };
|
||||
269B475D1D3538E90042D137 /* SlackKit.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SlackKit.swift; path = Sources/SlackKit.swift; sourceTree = "<group>"; };
|
||||
269B47611D3544240042D137 /* IncomingWebhook.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = IncomingWebhook.swift; path = Sources/IncomingWebhook.swift; sourceTree = "<group>"; };
|
||||
269B47651D39AAA80042D137 /* MessageActionResponder.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = MessageActionResponder.swift; path = Sources/MessageActionResponder.swift; sourceTree = "<group>"; };
|
||||
269B47CB1D3AE5670042D137 /* Swifter.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Swifter.framework; path = Carthage/Build/tvOS/Swifter.framework; sourceTree = "<group>"; };
|
||||
269B47CD1D3C22FC0042D137 /* ClientOptions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ClientOptions.swift; path = Sources/ClientOptions.swift; sourceTree = "<group>"; };
|
||||
26B30B6B1D289FA0004D4AB5 /* Swifter.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Swifter.framework; path = Carthage/Build/Mac/Swifter.framework; sourceTree = "<group>"; };
|
||||
26B30B6E1D289FB2004D4AB5 /* Swifter.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Swifter.framework; path = Carthage/Build/iOS/Swifter.framework; sourceTree = "<group>"; };
|
||||
26B30B871D297A98004D4AB5 /* MessageActionRequest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = MessageActionRequest.swift; path = Sources/MessageActionRequest.swift; sourceTree = "<group>"; };
|
||||
26B30B8F1D298E08004D4AB5 /* MessageActionServer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = MessageActionServer.swift; path = Sources/MessageActionServer.swift; sourceTree = "<group>"; };
|
||||
26B30B911D298E12004D4AB5 /* Server.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Server.swift; path = Sources/Server.swift; sourceTree = "<group>"; };
|
||||
26B30B931D298E78004D4AB5 /* Response.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Response.swift; path = Sources/Response.swift; sourceTree = "<group>"; };
|
||||
26B30B981D298F25004D4AB5 /* WebhookRequest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = WebhookRequest.swift; path = Sources/WebhookRequest.swift; sourceTree = "<group>"; };
|
||||
26B30BB51D2BC2E4004D4AB5 /* Scope.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Scope.swift; path = Sources/Scope.swift; sourceTree = "<group>"; };
|
||||
26B30BC21D2DFF0D004D4AB5 /* OAuthServer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = OAuthServer.swift; path = Sources/OAuthServer.swift; sourceTree = "<group>"; };
|
||||
26B30BC61D2DFF7D004D4AB5 /* AuthorizeRequest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = AuthorizeRequest.swift; path = Sources/AuthorizeRequest.swift; sourceTree = "<group>"; };
|
||||
26BBA1871C398E3C00BF7225 /* Bot.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Bot.swift; path = Sources/Bot.swift; sourceTree = "<group>"; };
|
||||
26BBA1881C398E3C00BF7225 /* Channel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Channel.swift; path = Sources/Channel.swift; sourceTree = "<group>"; };
|
||||
26BBA1891C398E3C00BF7225 /* Client.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Client.swift; path = Sources/Client.swift; sourceTree = "<group>"; };
|
||||
26BBA18A1C398E3C00BF7225 /* Event.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Event.swift; path = Sources/Event.swift; sourceTree = "<group>"; };
|
||||
26BBA18B1C398E3C00BF7225 /* EventDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = EventDelegate.swift; path = Sources/EventDelegate.swift; sourceTree = "<group>"; };
|
||||
26BBA18C1C398E3C00BF7225 /* EventDispatcher.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = EventDispatcher.swift; path = Sources/EventDispatcher.swift; sourceTree = "<group>"; };
|
||||
26BBA18D1C398E3C00BF7225 /* EventHandler.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = EventHandler.swift; path = Sources/EventHandler.swift; sourceTree = "<group>"; };
|
||||
26BBA18E1C398E3C00BF7225 /* File.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = File.swift; path = Sources/File.swift; sourceTree = "<group>"; };
|
||||
26BBA18F1C398E3C00BF7225 /* Message.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Message.swift; path = Sources/Message.swift; sourceTree = "<group>"; };
|
||||
26BBA1901C398E3C00BF7225 /* Team.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Team.swift; path = Sources/Team.swift; sourceTree = "<group>"; };
|
||||
26BBA1911C398E3C00BF7225 /* Types.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Types.swift; path = Sources/Types.swift; sourceTree = "<group>"; };
|
||||
26BBA1921C398E3C00BF7225 /* User.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = User.swift; path = Sources/User.swift; sourceTree = "<group>"; };
|
||||
26BBA1931C398E3C00BF7225 /* UserGroup.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = UserGroup.swift; path = Sources/UserGroup.swift; sourceTree = "<group>"; };
|
||||
407A2ABFC0611867E2BE34D0 /* Pods_SlackKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_SlackKit.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
4347F92F3932C96C23B10B2A /* Pods-SlackKit.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SlackKit.release.xcconfig"; path = "Pods/Target Support Files/Pods-SlackKit/Pods-SlackKit.release.xcconfig"; sourceTree = "<group>"; };
|
||||
F59B6A12F1C4C4E24C58E1BF /* Pods-SlackKit.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SlackKit.debug.xcconfig"; path = "Pods/Target Support Files/Pods-SlackKit/Pods-SlackKit.debug.xcconfig"; sourceTree = "<group>"; };
|
||||
26DF40341C7A0FA300E19241 /* Attachment.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Attachment.swift; path = Sources/Attachment.swift; sourceTree = "<group>"; };
|
||||
26EC14C01D1EF16500FD3A53 /* AttachmentField.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = AttachmentField.swift; path = Sources/AttachmentField.swift; sourceTree = "<group>"; };
|
||||
26EC14C41D1EF17400FD3A53 /* Comment.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Comment.swift; path = Sources/Comment.swift; sourceTree = "<group>"; };
|
||||
26EC14C51D1EF17400FD3A53 /* CustomProfile.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = CustomProfile.swift; path = Sources/CustomProfile.swift; sourceTree = "<group>"; };
|
||||
26EC14C61D1EF17400FD3A53 /* CustomProfileField.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = CustomProfileField.swift; path = Sources/CustomProfileField.swift; sourceTree = "<group>"; };
|
||||
26EC14C71D1EF17400FD3A53 /* DoNotDisturbStatus.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = DoNotDisturbStatus.swift; path = Sources/DoNotDisturbStatus.swift; sourceTree = "<group>"; };
|
||||
26EC14C81D1EF17400FD3A53 /* Edited.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Edited.swift; path = Sources/Edited.swift; sourceTree = "<group>"; };
|
||||
26EC14D81D1EF17E00FD3A53 /* History.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = History.swift; path = Sources/History.swift; sourceTree = "<group>"; };
|
||||
26EC14D91D1EF17E00FD3A53 /* Item.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Item.swift; path = Sources/Item.swift; sourceTree = "<group>"; };
|
||||
26EC14E01D1EF18700FD3A53 /* Reaction.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Reaction.swift; path = Sources/Reaction.swift; sourceTree = "<group>"; };
|
||||
26EC14E41D1EF18F00FD3A53 /* TeamIcon.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = TeamIcon.swift; path = Sources/TeamIcon.swift; sourceTree = "<group>"; };
|
||||
26EC14E51D1EF18F00FD3A53 /* Topic.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Topic.swift; path = Sources/Topic.swift; sourceTree = "<group>"; };
|
||||
26EC14F81D1F355A00FD3A53 /* Action.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Action.swift; path = Sources/Action.swift; sourceTree = "<group>"; };
|
||||
26EC15001D260B1000FD3A53 /* WebhookServer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = WebhookServer.swift; path = Sources/WebhookServer.swift; sourceTree = "<group>"; };
|
||||
4307A07F1CC6D0910011D5DE /* Starscream.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Starscream.framework; path = Carthage/Build/Mac/Starscream.framework; sourceTree = "<group>"; };
|
||||
C16C98791CE7D3DD00692776 /* Client+Utilities.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = "Client+Utilities.swift"; path = "Sources/Client+Utilities.swift"; sourceTree = "<group>"; };
|
||||
C1A85FF71CE3BCEF00756C40 /* Client+EventDispatching.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = "Client+EventDispatching.swift"; path = "Sources/Client+EventDispatching.swift"; sourceTree = "<group>"; };
|
||||
C1A85FF81CE3BCEF00756C40 /* Client+EventHandling.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = "Client+EventHandling.swift"; path = "Sources/Client+EventHandling.swift"; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
@@ -50,28 +217,37 @@
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
FFE3AC870D1C42EF276CCA2D /* Pods_SlackKit.framework in Frameworks */,
|
||||
4307A0801CC6D0910011D5DE /* Starscream.framework in Frameworks */,
|
||||
26B30B6C1D289FA0004D4AB5 /* Swifter.framework in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
263993AA1CE90EE0004A6E93 /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
263993AB1CE90EE0004A6E93 /* Starscream.framework in Frameworks */,
|
||||
26F76EB21D40318F00C3A3DD /* Swifter.framework in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
263993C91CE90EED004A6E93 /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
263993CA1CE90EED004A6E93 /* Starscream.framework in Frameworks */,
|
||||
26F76EB31D40319700C3A3DD /* Swifter.framework in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXFrameworksBuildPhase section */
|
||||
|
||||
/* Begin PBXGroup section */
|
||||
0C2928E508A686B69F9F0117 /* Pods */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
F59B6A12F1C4C4E24C58E1BF /* Pods-SlackKit.debug.xcconfig */,
|
||||
4347F92F3932C96C23B10B2A /* Pods-SlackKit.release.xcconfig */,
|
||||
);
|
||||
name = Pods;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
26072A2A1BB48B3A00CD650C = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
2661A6811BBF60E60026F67B /* SlackKit */,
|
||||
26072A351BB48B3A00CD650C /* Products */,
|
||||
0C2928E508A686B69F9F0117 /* Pods */,
|
||||
CA70A3A1A9A1A259960DFBCF /* Frameworks */,
|
||||
);
|
||||
sourceTree = "<group>";
|
||||
@@ -80,6 +256,8 @@
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
26072A341BB48B3A00CD650C /* SlackKit.framework */,
|
||||
263993B21CE90EE0004A6E93 /* SlackKit.framework */,
|
||||
263993D11CE90EED004A6E93 /* SlackKit.framework */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
@@ -87,29 +265,98 @@
|
||||
2661A6811BBF60E60026F67B /* SlackKit */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
26BBA1871C398E3C00BF7225 /* Bot.swift */,
|
||||
26BBA1881C398E3C00BF7225 /* Channel.swift */,
|
||||
26BBA1891C398E3C00BF7225 /* Client.swift */,
|
||||
26BBA18A1C398E3C00BF7225 /* Event.swift */,
|
||||
C1A85FF71CE3BCEF00756C40 /* Client+EventDispatching.swift */,
|
||||
C1A85FF81CE3BCEF00756C40 /* Client+EventHandling.swift */,
|
||||
C16C98791CE7D3DD00692776 /* Client+Utilities.swift */,
|
||||
26BBA18B1C398E3C00BF7225 /* EventDelegate.swift */,
|
||||
26BBA18C1C398E3C00BF7225 /* EventDispatcher.swift */,
|
||||
26BBA18D1C398E3C00BF7225 /* EventHandler.swift */,
|
||||
26BBA18E1C398E3C00BF7225 /* File.swift */,
|
||||
26BBA18F1C398E3C00BF7225 /* Message.swift */,
|
||||
26BBA1901C398E3C00BF7225 /* Team.swift */,
|
||||
26BBA1911C398E3C00BF7225 /* Types.swift */,
|
||||
26BBA1921C398E3C00BF7225 /* User.swift */,
|
||||
26BBA1931C398E3C00BF7225 /* UserGroup.swift */,
|
||||
2661A6A41BBF62FF0026F67B /* SlackKit.h */,
|
||||
266E05F01BBF780C00840D76 /* Info.plist */,
|
||||
260EC2301C4DC61D0093B253 /* Extensions.swift */,
|
||||
269B47611D3544240042D137 /* IncomingWebhook.swift */,
|
||||
260EC2311C4DC61D0093B253 /* NetworkInterface.swift */,
|
||||
26B30B8F1D298E08004D4AB5 /* MessageActionServer.swift */,
|
||||
269B47651D39AAA80042D137 /* MessageActionResponder.swift */,
|
||||
26B30BC21D2DFF0D004D4AB5 /* OAuthServer.swift */,
|
||||
26B30B911D298E12004D4AB5 /* Server.swift */,
|
||||
269B475D1D3538E90042D137 /* SlackKit.swift */,
|
||||
260EC2321C4DC61D0093B253 /* WebAPI.swift */,
|
||||
26EC15001D260B1000FD3A53 /* WebhookServer.swift */,
|
||||
26EC14B31D1B974500FD3A53 /* Models */,
|
||||
268E46161CE8F7A2009F19CC /* Supporting Files */,
|
||||
);
|
||||
path = SlackKit;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
268E46161CE8F7A2009F19CC /* Supporting Files */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
2661A6A41BBF62FF0026F67B /* SlackKit.h */,
|
||||
268E46151CE8F79D009F19CC /* Info.plist */,
|
||||
268E46131CE8F79D009F19CC /* Info-iOS.plist */,
|
||||
268E46141CE8F79D009F19CC /* Info-tvOS.plist */,
|
||||
);
|
||||
name = "Supporting Files";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
26B30B9B1D29AB1E004D4AB5 /* Server */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
26B30B871D297A98004D4AB5 /* MessageActionRequest.swift */,
|
||||
26B30B931D298E78004D4AB5 /* Response.swift */,
|
||||
26B30B981D298F25004D4AB5 /* WebhookRequest.swift */,
|
||||
);
|
||||
name = Server;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
26B30BB91D2BC2EA004D4AB5 /* Auth */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
26B30BC61D2DFF7D004D4AB5 /* AuthorizeRequest.swift */,
|
||||
2678B5931D3151B900CE521A /* AuthorizeResponse.swift */,
|
||||
26B30BB51D2BC2E4004D4AB5 /* Scope.swift */,
|
||||
269B47591D3493DE0042D137 /* OAuthResponse.swift */,
|
||||
);
|
||||
name = Auth;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
26EC14B31D1B974500FD3A53 /* Models */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
26EC14F81D1F355A00FD3A53 /* Action.swift */,
|
||||
26DF40341C7A0FA300E19241 /* Attachment.swift */,
|
||||
26EC14C01D1EF16500FD3A53 /* AttachmentField.swift */,
|
||||
26BBA1871C398E3C00BF7225 /* Bot.swift */,
|
||||
26BBA1881C398E3C00BF7225 /* Channel.swift */,
|
||||
269B47CD1D3C22FC0042D137 /* ClientOptions.swift */,
|
||||
26EC14C41D1EF17400FD3A53 /* Comment.swift */,
|
||||
26EC14C51D1EF17400FD3A53 /* CustomProfile.swift */,
|
||||
26EC14C61D1EF17400FD3A53 /* CustomProfileField.swift */,
|
||||
26EC14C71D1EF17400FD3A53 /* DoNotDisturbStatus.swift */,
|
||||
26EC14C81D1EF17400FD3A53 /* Edited.swift */,
|
||||
26BBA18A1C398E3C00BF7225 /* Event.swift */,
|
||||
26BBA18E1C398E3C00BF7225 /* File.swift */,
|
||||
26EC14D81D1EF17E00FD3A53 /* History.swift */,
|
||||
26EC14D91D1EF17E00FD3A53 /* Item.swift */,
|
||||
26BBA18F1C398E3C00BF7225 /* Message.swift */,
|
||||
26EC14E01D1EF18700FD3A53 /* Reaction.swift */,
|
||||
2601D61A1C7646B80012BF22 /* SlackError.swift */,
|
||||
26BBA1901C398E3C00BF7225 /* Team.swift */,
|
||||
26EC14E41D1EF18F00FD3A53 /* TeamIcon.swift */,
|
||||
26EC14E51D1EF18F00FD3A53 /* Topic.swift */,
|
||||
26BBA1921C398E3C00BF7225 /* User.swift */,
|
||||
26BBA1931C398E3C00BF7225 /* UserGroup.swift */,
|
||||
26B30BB91D2BC2EA004D4AB5 /* Auth */,
|
||||
26B30B9B1D29AB1E004D4AB5 /* Server */,
|
||||
);
|
||||
name = Models;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
CA70A3A1A9A1A259960DFBCF /* Frameworks */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
407A2ABFC0611867E2BE34D0 /* Pods_SlackKit.framework */,
|
||||
269B47CB1D3AE5670042D137 /* Swifter.framework */,
|
||||
26B30B6E1D289FB2004D4AB5 /* Swifter.framework */,
|
||||
26B30B6B1D289FA0004D4AB5 /* Swifter.framework */,
|
||||
4307A07F1CC6D0910011D5DE /* Starscream.framework */,
|
||||
);
|
||||
name = Frameworks;
|
||||
sourceTree = "<group>";
|
||||
@@ -121,44 +368,96 @@
|
||||
isa = PBXHeadersBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
263993901CE90C87004A6E93 /* SlackKit.h in Headers */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
263993AC1CE90EE0004A6E93 /* Headers */ = {
|
||||
isa = PBXHeadersBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
263993AD1CE90EE0004A6E93 /* SlackKit.h in Headers */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
263993CB1CE90EED004A6E93 /* Headers */ = {
|
||||
isa = PBXHeadersBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
263993CC1CE90EED004A6E93 /* SlackKit.h in Headers */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXHeadersBuildPhase section */
|
||||
|
||||
/* Begin PBXNativeTarget section */
|
||||
26072A331BB48B3A00CD650C /* SlackKit */ = {
|
||||
26072A331BB48B3A00CD650C /* SlackKit OS X */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = 26072A3C1BB48B3B00CD650C /* Build configuration list for PBXNativeTarget "SlackKit" */;
|
||||
buildConfigurationList = 26072A3C1BB48B3B00CD650C /* Build configuration list for PBXNativeTarget "SlackKit OS X" */;
|
||||
buildPhases = (
|
||||
EBD7A091EB278C5BA34791C5 /* Check Pods Manifest.lock */,
|
||||
26072A2F1BB48B3A00CD650C /* Sources */,
|
||||
26072A301BB48B3A00CD650C /* Frameworks */,
|
||||
26072A311BB48B3A00CD650C /* Headers */,
|
||||
26072A321BB48B3A00CD650C /* Resources */,
|
||||
AC19A945F408269E4B4132CC /* Copy Pods Resources */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
);
|
||||
name = SlackKit;
|
||||
name = "SlackKit OS X";
|
||||
productName = SlackRTMKit;
|
||||
productReference = 26072A341BB48B3A00CD650C /* SlackKit.framework */;
|
||||
productType = "com.apple.product-type.framework";
|
||||
};
|
||||
263993951CE90EE0004A6E93 /* SlackKit iOS */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = 263993AF1CE90EE0004A6E93 /* Build configuration list for PBXNativeTarget "SlackKit iOS" */;
|
||||
buildPhases = (
|
||||
263993961CE90EE0004A6E93 /* Sources */,
|
||||
263993AA1CE90EE0004A6E93 /* Frameworks */,
|
||||
263993AC1CE90EE0004A6E93 /* Headers */,
|
||||
263993AE1CE90EE0004A6E93 /* Resources */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
);
|
||||
name = "SlackKit iOS";
|
||||
productName = SlackRTMKit;
|
||||
productReference = 263993B21CE90EE0004A6E93 /* SlackKit.framework */;
|
||||
productType = "com.apple.product-type.framework";
|
||||
};
|
||||
263993B41CE90EED004A6E93 /* SlackKit tvOS */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = 263993CE1CE90EED004A6E93 /* Build configuration list for PBXNativeTarget "SlackKit tvOS" */;
|
||||
buildPhases = (
|
||||
263993B51CE90EED004A6E93 /* Sources */,
|
||||
263993C91CE90EED004A6E93 /* Frameworks */,
|
||||
263993CB1CE90EED004A6E93 /* Headers */,
|
||||
263993CD1CE90EED004A6E93 /* Resources */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
);
|
||||
name = "SlackKit tvOS";
|
||||
productName = SlackRTMKit;
|
||||
productReference = 263993D11CE90EED004A6E93 /* SlackKit.framework */;
|
||||
productType = "com.apple.product-type.framework";
|
||||
};
|
||||
/* End PBXNativeTarget section */
|
||||
|
||||
/* Begin PBXProject section */
|
||||
26072A2B1BB48B3A00CD650C /* Project object */ = {
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
LastSwiftUpdateCheck = 0700;
|
||||
LastUpgradeCheck = 0700;
|
||||
LastSwiftUpdateCheck = 0730;
|
||||
LastUpgradeCheck = 0800;
|
||||
ORGANIZATIONNAME = "Launch Software LLC";
|
||||
TargetAttributes = {
|
||||
26072A331BB48B3A00CD650C = {
|
||||
CreatedOnToolsVersion = 7.0;
|
||||
LastSwiftMigration = 0800;
|
||||
};
|
||||
};
|
||||
};
|
||||
@@ -168,13 +467,16 @@
|
||||
hasScannedForEncodings = 0;
|
||||
knownRegions = (
|
||||
en,
|
||||
Base,
|
||||
);
|
||||
mainGroup = 26072A2A1BB48B3A00CD650C;
|
||||
productRefGroup = 26072A351BB48B3A00CD650C /* Products */;
|
||||
projectDirPath = "";
|
||||
projectRoot = "";
|
||||
targets = (
|
||||
26072A331BB48B3A00CD650C /* SlackKit */,
|
||||
26072A331BB48B3A00CD650C /* SlackKit OS X */,
|
||||
263993951CE90EE0004A6E93 /* SlackKit iOS */,
|
||||
263993B41CE90EED004A6E93 /* SlackKit tvOS */,
|
||||
);
|
||||
};
|
||||
/* End PBXProject section */
|
||||
@@ -187,62 +489,179 @@
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
263993AE1CE90EE0004A6E93 /* Resources */ = {
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
263993CD1CE90EED004A6E93 /* Resources */ = {
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXResourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXShellScriptBuildPhase section */
|
||||
AC19A945F408269E4B4132CC /* Copy Pods Resources */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
inputPaths = (
|
||||
);
|
||||
name = "Copy Pods Resources";
|
||||
outputPaths = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-SlackKit/Pods-SlackKit-resources.sh\"\n";
|
||||
showEnvVarsInLog = 0;
|
||||
};
|
||||
EBD7A091EB278C5BA34791C5 /* Check Pods Manifest.lock */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
inputPaths = (
|
||||
);
|
||||
name = "Check Pods Manifest.lock";
|
||||
outputPaths = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n";
|
||||
showEnvVarsInLog = 0;
|
||||
};
|
||||
/* End PBXShellScriptBuildPhase section */
|
||||
|
||||
/* Begin PBXSourcesBuildPhase section */
|
||||
26072A2F1BB48B3A00CD650C /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
26BBA1991C398E3C00BF7225 /* EventDispatcher.swift in Sources */,
|
||||
2678B5941D3151B900CE521A /* AuthorizeResponse.swift in Sources */,
|
||||
26B30B921D298E12004D4AB5 /* Server.swift in Sources */,
|
||||
269B47CE1D3C22FC0042D137 /* ClientOptions.swift in Sources */,
|
||||
269B47621D3544240042D137 /* IncomingWebhook.swift in Sources */,
|
||||
C16C987A1CE7D3DD00692776 /* Client+Utilities.swift in Sources */,
|
||||
26BBA1951C398E3C00BF7225 /* Channel.swift in Sources */,
|
||||
26B30B901D298E08004D4AB5 /* MessageActionServer.swift in Sources */,
|
||||
26B30B941D298E78004D4AB5 /* Response.swift in Sources */,
|
||||
26EC14CF1D1EF17400FD3A53 /* CustomProfileField.swift in Sources */,
|
||||
269B47661D39AAA80042D137 /* MessageActionResponder.swift in Sources */,
|
||||
26BBA19F1C398E3C00BF7225 /* User.swift in Sources */,
|
||||
26BBA19E1C398E3C00BF7225 /* Types.swift in Sources */,
|
||||
26EC14DD1D1EF17E00FD3A53 /* Item.swift in Sources */,
|
||||
26EC15011D260B1000FD3A53 /* WebhookServer.swift in Sources */,
|
||||
26EC14CC1D1EF17400FD3A53 /* CustomProfile.swift in Sources */,
|
||||
26BBA1961C398E3C00BF7225 /* Client.swift in Sources */,
|
||||
26BBA19A1C398E3C00BF7225 /* EventHandler.swift in Sources */,
|
||||
26B30B881D297A98004D4AB5 /* MessageActionRequest.swift in Sources */,
|
||||
269B475E1D3538E90042D137 /* SlackKit.swift in Sources */,
|
||||
26B30BC71D2DFF7D004D4AB5 /* AuthorizeRequest.swift in Sources */,
|
||||
26BBA1971C398E3C00BF7225 /* Event.swift in Sources */,
|
||||
26EC14D21D1EF17400FD3A53 /* DoNotDisturbStatus.swift in Sources */,
|
||||
26BBA1941C398E3C00BF7225 /* Bot.swift in Sources */,
|
||||
26EC14E61D1EF18F00FD3A53 /* TeamIcon.swift in Sources */,
|
||||
C1A85FF91CE3BCEF00756C40 /* Client+EventDispatching.swift in Sources */,
|
||||
26BBA19B1C398E3C00BF7225 /* File.swift in Sources */,
|
||||
26EC14F91D1F355A00FD3A53 /* Action.swift in Sources */,
|
||||
26B30BC31D2DFF0D004D4AB5 /* OAuthServer.swift in Sources */,
|
||||
26EC14D51D1EF17400FD3A53 /* Edited.swift in Sources */,
|
||||
260EC2351C4DC61D0093B253 /* WebAPI.swift in Sources */,
|
||||
26EC14E11D1EF18700FD3A53 /* Reaction.swift in Sources */,
|
||||
26B30BB61D2BC2E4004D4AB5 /* Scope.swift in Sources */,
|
||||
26EC14E91D1EF18F00FD3A53 /* Topic.swift in Sources */,
|
||||
26DF40351C7A0FA300E19241 /* Attachment.swift in Sources */,
|
||||
26BBA19C1C398E3C00BF7225 /* Message.swift in Sources */,
|
||||
26BBA19D1C398E3C00BF7225 /* Team.swift in Sources */,
|
||||
260EC2331C4DC61D0093B253 /* Extensions.swift in Sources */,
|
||||
26BBA1A01C398E3C00BF7225 /* UserGroup.swift in Sources */,
|
||||
2601D61B1C7646B80012BF22 /* SlackError.swift in Sources */,
|
||||
26EC14DA1D1EF17E00FD3A53 /* History.swift in Sources */,
|
||||
269B475A1D3493DE0042D137 /* OAuthResponse.swift in Sources */,
|
||||
C1A85FFA1CE3BCEF00756C40 /* Client+EventHandling.swift in Sources */,
|
||||
26B30B991D298F25004D4AB5 /* WebhookRequest.swift in Sources */,
|
||||
26EC14C91D1EF17400FD3A53 /* Comment.swift in Sources */,
|
||||
26EC14C11D1EF16500FD3A53 /* AttachmentField.swift in Sources */,
|
||||
260EC2341C4DC61D0093B253 /* NetworkInterface.swift in Sources */,
|
||||
26BBA1981C398E3C00BF7225 /* EventDelegate.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
263993961CE90EE0004A6E93 /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
26B30B961D298EE1004D4AB5 /* MessageActionRequest.swift in Sources */,
|
||||
263993971CE90EE0004A6E93 /* Client+Utilities.swift in Sources */,
|
||||
269B47CF1D3C22FC0042D137 /* ClientOptions.swift in Sources */,
|
||||
269B47C71D3AE25B0042D137 /* MessageActionServer.swift in Sources */,
|
||||
263993981CE90EE0004A6E93 /* Channel.swift in Sources */,
|
||||
26EC14D01D1EF17400FD3A53 /* CustomProfileField.swift in Sources */,
|
||||
263993991CE90EE0004A6E93 /* User.swift in Sources */,
|
||||
26EC14DE1D1EF17E00FD3A53 /* Item.swift in Sources */,
|
||||
269B475B1D3493DE0042D137 /* OAuthResponse.swift in Sources */,
|
||||
26EC15021D260B1000FD3A53 /* WebhookServer.swift in Sources */,
|
||||
26B30BC41D2DFF0D004D4AB5 /* OAuthServer.swift in Sources */,
|
||||
26EC14CD1D1EF17400FD3A53 /* CustomProfile.swift in Sources */,
|
||||
2639939B1CE90EE0004A6E93 /* Client.swift in Sources */,
|
||||
2639939C1CE90EE0004A6E93 /* Event.swift in Sources */,
|
||||
26B30BC81D2DFF7D004D4AB5 /* AuthorizeRequest.swift in Sources */,
|
||||
2678B5951D3151B900CE521A /* AuthorizeResponse.swift in Sources */,
|
||||
26EC14D31D1EF17400FD3A53 /* DoNotDisturbStatus.swift in Sources */,
|
||||
2639939D1CE90EE0004A6E93 /* Bot.swift in Sources */,
|
||||
26EC14E71D1EF18F00FD3A53 /* TeamIcon.swift in Sources */,
|
||||
2639939E1CE90EE0004A6E93 /* Client+EventDispatching.swift in Sources */,
|
||||
26B30B971D298EED004D4AB5 /* Server.swift in Sources */,
|
||||
2639939F1CE90EE0004A6E93 /* File.swift in Sources */,
|
||||
26B30B951D298E78004D4AB5 /* Response.swift in Sources */,
|
||||
26EC14FA1D1F355A00FD3A53 /* Action.swift in Sources */,
|
||||
26EC14D61D1EF17400FD3A53 /* Edited.swift in Sources */,
|
||||
263993A01CE90EE0004A6E93 /* WebAPI.swift in Sources */,
|
||||
26B30B9A1D298F25004D4AB5 /* WebhookRequest.swift in Sources */,
|
||||
26EC14E21D1EF18700FD3A53 /* Reaction.swift in Sources */,
|
||||
26EC14EA1D1EF18F00FD3A53 /* Topic.swift in Sources */,
|
||||
263993A11CE90EE0004A6E93 /* Attachment.swift in Sources */,
|
||||
26B30BB71D2BC2E4004D4AB5 /* Scope.swift in Sources */,
|
||||
263993A21CE90EE0004A6E93 /* Message.swift in Sources */,
|
||||
263993A31CE90EE0004A6E93 /* Team.swift in Sources */,
|
||||
263993A41CE90EE0004A6E93 /* Extensions.swift in Sources */,
|
||||
263993A51CE90EE0004A6E93 /* UserGroup.swift in Sources */,
|
||||
263993A61CE90EE0004A6E93 /* SlackError.swift in Sources */,
|
||||
269B475F1D3538E90042D137 /* SlackKit.swift in Sources */,
|
||||
26EC14DB1D1EF17E00FD3A53 /* History.swift in Sources */,
|
||||
263993A71CE90EE0004A6E93 /* Client+EventHandling.swift in Sources */,
|
||||
269B47631D3544240042D137 /* IncomingWebhook.swift in Sources */,
|
||||
269B47671D39AAA80042D137 /* MessageActionResponder.swift in Sources */,
|
||||
26EC14CA1D1EF17400FD3A53 /* Comment.swift in Sources */,
|
||||
26EC14C21D1EF16500FD3A53 /* AttachmentField.swift in Sources */,
|
||||
263993A81CE90EE0004A6E93 /* NetworkInterface.swift in Sources */,
|
||||
263993A91CE90EE0004A6E93 /* EventDelegate.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
263993B51CE90EED004A6E93 /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
263993B61CE90EED004A6E93 /* Client+Utilities.swift in Sources */,
|
||||
263993B71CE90EED004A6E93 /* Channel.swift in Sources */,
|
||||
269B47D01D3C22FC0042D137 /* ClientOptions.swift in Sources */,
|
||||
26EC14D11D1EF17400FD3A53 /* CustomProfileField.swift in Sources */,
|
||||
263993B81CE90EED004A6E93 /* User.swift in Sources */,
|
||||
26EC14DF1D1EF17E00FD3A53 /* Item.swift in Sources */,
|
||||
2678B5981D3151C900CE521A /* Response.swift in Sources */,
|
||||
269B475C1D3493DE0042D137 /* OAuthResponse.swift in Sources */,
|
||||
26EC14CE1D1EF17400FD3A53 /* CustomProfile.swift in Sources */,
|
||||
269B47C91D3AE2620042D137 /* Server.swift in Sources */,
|
||||
263993BA1CE90EED004A6E93 /* Client.swift in Sources */,
|
||||
263993BB1CE90EED004A6E93 /* Event.swift in Sources */,
|
||||
269B47CA1D3AE2670042D137 /* WebhookServer.swift in Sources */,
|
||||
26EC14D41D1EF17400FD3A53 /* DoNotDisturbStatus.swift in Sources */,
|
||||
263993BC1CE90EED004A6E93 /* Bot.swift in Sources */,
|
||||
26EC14E81D1EF18F00FD3A53 /* TeamIcon.swift in Sources */,
|
||||
263993BD1CE90EED004A6E93 /* Client+EventDispatching.swift in Sources */,
|
||||
263993BE1CE90EED004A6E93 /* File.swift in Sources */,
|
||||
26B30BB81D2BC2E4004D4AB5 /* Scope.swift in Sources */,
|
||||
269B47601D3538E90042D137 /* SlackKit.swift in Sources */,
|
||||
2678B5991D3151CD00CE521A /* WebhookRequest.swift in Sources */,
|
||||
26EC14FB1D1F355A00FD3A53 /* Action.swift in Sources */,
|
||||
26EC14D71D1EF17400FD3A53 /* Edited.swift in Sources */,
|
||||
263993BF1CE90EED004A6E93 /* WebAPI.swift in Sources */,
|
||||
2678B5961D3151B900CE521A /* AuthorizeResponse.swift in Sources */,
|
||||
26EC14E31D1EF18700FD3A53 /* Reaction.swift in Sources */,
|
||||
26EC14EB1D1EF18F00FD3A53 /* Topic.swift in Sources */,
|
||||
26B30BC51D2DFF0D004D4AB5 /* OAuthServer.swift in Sources */,
|
||||
263993C01CE90EED004A6E93 /* Attachment.swift in Sources */,
|
||||
263993C11CE90EED004A6E93 /* Message.swift in Sources */,
|
||||
263993C21CE90EED004A6E93 /* Team.swift in Sources */,
|
||||
269B47681D39AAA80042D137 /* MessageActionResponder.swift in Sources */,
|
||||
263993C31CE90EED004A6E93 /* Extensions.swift in Sources */,
|
||||
2678B5971D3151C600CE521A /* MessageActionRequest.swift in Sources */,
|
||||
263993C41CE90EED004A6E93 /* UserGroup.swift in Sources */,
|
||||
269B47C81D3AE25B0042D137 /* MessageActionServer.swift in Sources */,
|
||||
263993C51CE90EED004A6E93 /* SlackError.swift in Sources */,
|
||||
26EC14DC1D1EF17E00FD3A53 /* History.swift in Sources */,
|
||||
263993C61CE90EED004A6E93 /* Client+EventHandling.swift in Sources */,
|
||||
26B30BC91D2DFF7D004D4AB5 /* AuthorizeRequest.swift in Sources */,
|
||||
269B47641D3544240042D137 /* IncomingWebhook.swift in Sources */,
|
||||
26EC14CB1D1EF17400FD3A53 /* Comment.swift in Sources */,
|
||||
26EC14C31D1EF16500FD3A53 /* AttachmentField.swift in Sources */,
|
||||
263993C71CE90EED004A6E93 /* NetworkInterface.swift in Sources */,
|
||||
263993C81CE90EED004A6E93 /* EventDelegate.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXSourcesBuildPhase section */
|
||||
|
||||
/* Begin XCBuildConfiguration section */
|
||||
@@ -282,6 +701,7 @@
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.11;
|
||||
MTL_ENABLE_DEBUG_INFO = YES;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
@@ -322,6 +742,7 @@
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.11;
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
SDKROOT = macosx;
|
||||
@@ -332,28 +753,122 @@
|
||||
};
|
||||
26072A3D1BB48B3B00CD650C /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = F59B6A12F1C4C4E24C58E1BF /* Pods-SlackKit.debug.xcconfig */;
|
||||
buildSettings = {
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CODE_SIGN_IDENTITY = "-";
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
DEFINES_MODULE = YES;
|
||||
DYLIB_COMPATIBILITY_VERSION = 1;
|
||||
DYLIB_CURRENT_VERSION = 1;
|
||||
DYLIB_INSTALL_NAME_BASE = "@rpath";
|
||||
FRAMEWORK_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"$(PROJECT_DIR)/Carthage/Build/Mac",
|
||||
);
|
||||
FRAMEWORK_VERSION = A;
|
||||
INFOPLIST_FILE = SlackKit/Info.plist;
|
||||
INFOPLIST_FILE = "$(SRCROOT)/SlackKit/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.10;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.launchsoft.SlackKit;
|
||||
PRODUCT_NAME = SlackKit;
|
||||
SKIP_INSTALL = YES;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
SWIFT_VERSION = 3.0;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
26072A3E1BB48B3B00CD650C /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = 4347F92F3932C96C23B10B2A /* Pods-SlackKit.release.xcconfig */;
|
||||
buildSettings = {
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CODE_SIGN_IDENTITY = "-";
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
DEFINES_MODULE = YES;
|
||||
DYLIB_COMPATIBILITY_VERSION = 1;
|
||||
DYLIB_CURRENT_VERSION = 1;
|
||||
DYLIB_INSTALL_NAME_BASE = "@rpath";
|
||||
FRAMEWORK_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"$(PROJECT_DIR)/Carthage/Build/Mac",
|
||||
);
|
||||
FRAMEWORK_VERSION = A;
|
||||
INFOPLIST_FILE = "$(SRCROOT)/SlackKit/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.10;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.launchsoft.SlackKit;
|
||||
PRODUCT_NAME = SlackKit;
|
||||
SKIP_INSTALL = YES;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
|
||||
SWIFT_VERSION = 3.0;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
263993B01CE90EE0004A6E93 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CODE_SIGN_IDENTITY = "iPhone Developer";
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
DEFINES_MODULE = YES;
|
||||
DYLIB_COMPATIBILITY_VERSION = 1;
|
||||
DYLIB_CURRENT_VERSION = 1;
|
||||
DYLIB_INSTALL_NAME_BASE = "@rpath";
|
||||
FRAMEWORK_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"$(PROJECT_DIR)/Carthage/Build/iOS",
|
||||
"$(PROJECT_DIR)/Carthage/Build/Mac",
|
||||
);
|
||||
FRAMEWORK_VERSION = A;
|
||||
INFOPLIST_FILE = "$(SRCROOT)/SlackKit/Supporting Files/Info-iOS.plist";
|
||||
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks";
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.10;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.launchsoft.SlackKit;
|
||||
PRODUCT_NAME = SlackKit;
|
||||
SDKROOT = iphoneos;
|
||||
SKIP_INSTALL = YES;
|
||||
SUPPORTED_PLATFORMS = "iphonesimulator iphoneos";
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
SWIFT_VERSION = 3.0;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
263993B11CE90EE0004A6E93 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CODE_SIGN_IDENTITY = "iPhone Developer";
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
DEFINES_MODULE = YES;
|
||||
DYLIB_COMPATIBILITY_VERSION = 1;
|
||||
DYLIB_CURRENT_VERSION = 1;
|
||||
DYLIB_INSTALL_NAME_BASE = "@rpath";
|
||||
FRAMEWORK_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"$(PROJECT_DIR)/Carthage/Build/iOS",
|
||||
"$(PROJECT_DIR)/Carthage/Build/Mac",
|
||||
);
|
||||
FRAMEWORK_VERSION = A;
|
||||
INFOPLIST_FILE = "$(SRCROOT)/SlackKit/Supporting Files/Info-iOS.plist";
|
||||
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks";
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.10;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.launchsoft.SlackKit;
|
||||
PRODUCT_NAME = SlackKit;
|
||||
SDKROOT = iphoneos;
|
||||
SKIP_INSTALL = YES;
|
||||
SUPPORTED_PLATFORMS = "iphonesimulator iphoneos";
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
|
||||
SWIFT_VERSION = 3.0;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
263993CF1CE90EED004A6E93 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
@@ -361,13 +876,52 @@
|
||||
DYLIB_COMPATIBILITY_VERSION = 1;
|
||||
DYLIB_CURRENT_VERSION = 1;
|
||||
DYLIB_INSTALL_NAME_BASE = "@rpath";
|
||||
FRAMEWORK_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"$(PROJECT_DIR)/Carthage/Build/tvOS",
|
||||
);
|
||||
FRAMEWORK_VERSION = A;
|
||||
INFOPLIST_FILE = SlackKit/Info.plist;
|
||||
INFOPLIST_FILE = "$(SRCROOT)/SlackKit/Supporting Files/Info-tvOS.plist";
|
||||
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks";
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.10;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.launchsoft.SlackKit;
|
||||
PRODUCT_NAME = SlackKit;
|
||||
SDKROOT = appletvos;
|
||||
SKIP_INSTALL = YES;
|
||||
SUPPORTED_PLATFORMS = "appletvsimulator appletvos";
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
SWIFT_VERSION = 3.0;
|
||||
TVOS_DEPLOYMENT_TARGET = 9.0;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
263993D01CE90EED004A6E93 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
DEFINES_MODULE = YES;
|
||||
DYLIB_COMPATIBILITY_VERSION = 1;
|
||||
DYLIB_CURRENT_VERSION = 1;
|
||||
DYLIB_INSTALL_NAME_BASE = "@rpath";
|
||||
FRAMEWORK_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"$(PROJECT_DIR)/Carthage/Build/tvOS",
|
||||
);
|
||||
FRAMEWORK_VERSION = A;
|
||||
INFOPLIST_FILE = "$(SRCROOT)/SlackKit/Supporting Files/Info-tvOS.plist";
|
||||
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks";
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.10;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.launchsoft.SlackKit;
|
||||
PRODUCT_NAME = SlackKit;
|
||||
SDKROOT = appletvos;
|
||||
SKIP_INSTALL = YES;
|
||||
SUPPORTED_PLATFORMS = "appletvsimulator appletvos";
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
|
||||
SWIFT_VERSION = 3.0;
|
||||
TVOS_DEPLOYMENT_TARGET = 9.0;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
@@ -383,7 +937,7 @@
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
26072A3C1BB48B3B00CD650C /* Build configuration list for PBXNativeTarget "SlackKit" */ = {
|
||||
26072A3C1BB48B3B00CD650C /* Build configuration list for PBXNativeTarget "SlackKit OS X" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
26072A3D1BB48B3B00CD650C /* Debug */,
|
||||
@@ -392,6 +946,24 @@
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
263993AF1CE90EE0004A6E93 /* Build configuration list for PBXNativeTarget "SlackKit iOS" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
263993B01CE90EE0004A6E93 /* Debug */,
|
||||
263993B11CE90EE0004A6E93 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
263993CE1CE90EED004A6E93 /* Build configuration list for PBXNativeTarget "SlackKit tvOS" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
263993CF1CE90EED004A6E93 /* Debug */,
|
||||
263993D01CE90EED004A6E93 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
/* End XCConfigurationList section */
|
||||
};
|
||||
rootObject = 26072A2B1BB48B3A00CD650C /* Project object */;
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "0800"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
buildImplicitDependencies = "YES">
|
||||
<BuildActionEntries>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "26072A331BB48B3A00CD650C"
|
||||
BuildableName = "SlackKit.framework"
|
||||
BlueprintName = "SlackKit OS X"
|
||||
ReferencedContainer = "container:SlackKit.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
</BuildActionEntries>
|
||||
</BuildAction>
|
||||
<TestAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||
<Testables>
|
||||
</Testables>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
launchStyle = "0"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
debugServiceExtension = "internal"
|
||||
allowLocationSimulation = "YES">
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "26072A331BB48B3A00CD650C"
|
||||
BuildableName = "SlackKit.framework"
|
||||
BlueprintName = "SlackKit OS X"
|
||||
ReferencedContainer = "container:SlackKit.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
buildConfiguration = "Release"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
debugDocumentVersioning = "YES">
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "26072A331BB48B3A00CD650C"
|
||||
BuildableName = "SlackKit.framework"
|
||||
BlueprintName = "SlackKit OS X"
|
||||
ReferencedContainer = "container:SlackKit.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
</ProfileAction>
|
||||
<AnalyzeAction
|
||||
buildConfiguration = "Debug">
|
||||
</AnalyzeAction>
|
||||
<ArchiveAction
|
||||
buildConfiguration = "Release"
|
||||
revealArchiveInOrganizer = "YES">
|
||||
</ArchiveAction>
|
||||
</Scheme>
|
||||
@@ -0,0 +1,80 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "0800"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
buildImplicitDependencies = "YES">
|
||||
<BuildActionEntries>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "263993951CE90EE0004A6E93"
|
||||
BuildableName = "SlackKit.framework"
|
||||
BlueprintName = "SlackKit iOS"
|
||||
ReferencedContainer = "container:SlackKit.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
</BuildActionEntries>
|
||||
</BuildAction>
|
||||
<TestAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||
<Testables>
|
||||
</Testables>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
launchStyle = "0"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
debugServiceExtension = "internal"
|
||||
allowLocationSimulation = "YES">
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "263993951CE90EE0004A6E93"
|
||||
BuildableName = "SlackKit.framework"
|
||||
BlueprintName = "SlackKit iOS"
|
||||
ReferencedContainer = "container:SlackKit.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
buildConfiguration = "Release"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
debugDocumentVersioning = "YES">
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "263993951CE90EE0004A6E93"
|
||||
BuildableName = "SlackKit.framework"
|
||||
BlueprintName = "SlackKit iOS"
|
||||
ReferencedContainer = "container:SlackKit.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
</ProfileAction>
|
||||
<AnalyzeAction
|
||||
buildConfiguration = "Debug">
|
||||
</AnalyzeAction>
|
||||
<ArchiveAction
|
||||
buildConfiguration = "Release"
|
||||
revealArchiveInOrganizer = "YES">
|
||||
</ArchiveAction>
|
||||
</Scheme>
|
||||
@@ -0,0 +1,80 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "0800"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
buildImplicitDependencies = "YES">
|
||||
<BuildActionEntries>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "263993B41CE90EED004A6E93"
|
||||
BuildableName = "SlackKit.framework"
|
||||
BlueprintName = "SlackKit tvOS"
|
||||
ReferencedContainer = "container:SlackKit.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
</BuildActionEntries>
|
||||
</BuildAction>
|
||||
<TestAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||
<Testables>
|
||||
</Testables>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
launchStyle = "0"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
debugServiceExtension = "internal"
|
||||
allowLocationSimulation = "YES">
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "263993B41CE90EED004A6E93"
|
||||
BuildableName = "SlackKit.framework"
|
||||
BlueprintName = "SlackKit tvOS"
|
||||
ReferencedContainer = "container:SlackKit.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
buildConfiguration = "Release"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
debugDocumentVersioning = "YES">
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "263993B41CE90EED004A6E93"
|
||||
BuildableName = "SlackKit.framework"
|
||||
BlueprintName = "SlackKit tvOS"
|
||||
ReferencedContainer = "container:SlackKit.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
</ProfileAction>
|
||||
<AnalyzeAction
|
||||
buildConfiguration = "Debug">
|
||||
</AnalyzeAction>
|
||||
<ArchiveAction
|
||||
buildConfiguration = "Release"
|
||||
revealArchiveInOrganizer = "YES">
|
||||
</ArchiveAction>
|
||||
</Scheme>
|
||||
-10
@@ -1,10 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Workspace
|
||||
version = "1.0">
|
||||
<FileRef
|
||||
location = "group:SlackKit.xcodeproj">
|
||||
</FileRef>
|
||||
<FileRef
|
||||
location = "group:Pods/Pods.xcodeproj">
|
||||
</FileRef>
|
||||
</Workspace>
|
||||
@@ -0,0 +1,104 @@
|
||||
//
|
||||
// Action.swift
|
||||
//
|
||||
// Copyright © 2016 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?
|
||||
|
||||
internal init(action:[String: AnyObject]?) {
|
||||
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: AnyObject])
|
||||
}
|
||||
|
||||
public init(name: String, text: String, style: ActionStyle = .Default, value: String? = nil, confirm: Confirm? = nil) {
|
||||
self.type = "button"
|
||||
self.name = name
|
||||
self.text = text
|
||||
self.value = value
|
||||
self.style = style
|
||||
self.confirm = confirm
|
||||
}
|
||||
|
||||
internal func dictionary() -> [String: AnyObject] {
|
||||
var dict = [String: AnyObject]()
|
||||
dict["name"] = name
|
||||
dict["text"] = text
|
||||
dict["type"] = type
|
||||
dict["value"] = value
|
||||
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?
|
||||
|
||||
internal init(confirm:[String: AnyObject]?) {
|
||||
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
|
||||
}
|
||||
|
||||
internal func dictionary() -> [String: AnyObject] {
|
||||
var dict = [String: AnyObject]()
|
||||
dict["title"] = title
|
||||
dict["text"] = text
|
||||
dict["ok_text"] = okText
|
||||
dict["dismiss_text"] = dismissText
|
||||
return dict
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public enum ActionStyle: String {
|
||||
case Default = "default"
|
||||
case Primary = "primary"
|
||||
case Danger = "danger"
|
||||
}
|
||||
|
||||
public enum ResponseType: String {
|
||||
case InChannel = "in_channel"
|
||||
case Ephemeral = "ephemeral"
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
//
|
||||
// Attachment.swift
|
||||
//
|
||||
// Copyright © 2016 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?
|
||||
|
||||
internal init(attachment: [String: AnyObject]?) {
|
||||
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: AnyObject]])?.map { AttachmentField(field: $0) }
|
||||
actions = (attachment?["actions"] as? [[String: AnyObject]])?.map { Action(action: $0) }
|
||||
}
|
||||
|
||||
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) {
|
||||
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
|
||||
}
|
||||
|
||||
internal func dictionary() -> [String: AnyObject] {
|
||||
var attachment = [String: AnyObject]()
|
||||
attachment["fallback"] = fallback
|
||||
attachment["callback_id"] = callbackID
|
||||
attachment["attachment_type"] = type
|
||||
attachment["color"] = color
|
||||
attachment["pretext"] = pretext
|
||||
attachment["authorName"] = authorName
|
||||
attachment["author_link"] = authorLink
|
||||
attachment["author_icon"] = authorIcon
|
||||
attachment["title"] = title
|
||||
attachment["title_link"] = titleLink
|
||||
attachment["text"] = text
|
||||
attachment["fields"] = fields?.map{$0.dictionary()}
|
||||
attachment["actions"] = actions?.map{$0.dictionary()}
|
||||
attachment["image_url"] = imageURL
|
||||
attachment["thumb_url"] = thumbURL
|
||||
attachment["footer"] = footer
|
||||
attachment["footer_icon"] = footerIcon
|
||||
attachment["ts"] = ts
|
||||
return attachment
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public enum AttachmentColor: String {
|
||||
case Good = "good"
|
||||
case Warning = "warning"
|
||||
case Danger = "danger"
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
//
|
||||
// AttachmentField.swift
|
||||
//
|
||||
// Copyright © 2016 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?
|
||||
|
||||
internal init(field: [String: AnyObject]?) {
|
||||
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
|
||||
}
|
||||
|
||||
internal func dictionary() -> [String: AnyObject] {
|
||||
var field = [String: AnyObject]()
|
||||
field["title"] = title
|
||||
field["value"] = value
|
||||
field["short"] = short
|
||||
return field
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
//
|
||||
// AuthorizeRequest.swift
|
||||
//
|
||||
// Copyright © 2016 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.
|
||||
|
||||
internal struct AuthorizeRequest {
|
||||
|
||||
let clientID: String
|
||||
let scope: [Scope]
|
||||
let redirectURI: String
|
||||
let state: String
|
||||
let team: String?
|
||||
|
||||
var parameters: [String: AnyObject] {
|
||||
var json = [String : AnyObject]()
|
||||
json["scope"] = scope.map({$0.rawValue}).joined(separator: ",")
|
||||
json["state"] = state
|
||||
json["team"] = team
|
||||
return json
|
||||
}
|
||||
|
||||
init(clientID: String, scope:[Scope], redirectURI: String, state: String = "slackkit", team: String? = nil) {
|
||||
self.clientID = clientID
|
||||
self.scope = scope
|
||||
self.redirectURI = redirectURI
|
||||
self.state = state
|
||||
self.team = team
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
//
|
||||
// AuthorizeResponse.swift
|
||||
//
|
||||
// Copyright © 2016 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.
|
||||
|
||||
internal struct AuthorizeResponse {
|
||||
|
||||
let code: String
|
||||
let state: String
|
||||
|
||||
init?(queryParameters: [(String, String)]) {
|
||||
guard let code = queryParameters.first?.1, let state = queryParameters.last?.1 else {
|
||||
return nil
|
||||
}
|
||||
self.code = code
|
||||
self.state = state
|
||||
}
|
||||
}
|
||||
@@ -24,13 +24,19 @@
|
||||
public struct Bot {
|
||||
|
||||
public let id: String?
|
||||
internal(set) public var botToken: String?
|
||||
internal(set) public var name: String?
|
||||
internal(set) public var icons: [String: AnyObject]?
|
||||
|
||||
internal init?(bot: [String: AnyObject]?) {
|
||||
internal init(bot: [String: AnyObject]?) {
|
||||
id = bot?["id"] as? String
|
||||
name = bot?["name"] as? String
|
||||
icons = bot?["icons"] as? [String: AnyObject]
|
||||
}
|
||||
|
||||
internal init(botUser: [String: AnyObject]?) {
|
||||
id = botUser?["bot_user_id"] as? String
|
||||
botToken = botUser?["bot_access_token"] as? String
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -38,18 +38,18 @@ public struct Channel {
|
||||
internal(set) public var topic: Topic?
|
||||
internal(set) public var purpose: Topic?
|
||||
internal(set) public var isMember: Bool?
|
||||
internal(set) public var lastRead: String?
|
||||
public var lastRead: String?
|
||||
internal(set) public var latest: Message?
|
||||
internal(set) public var unread: Int?
|
||||
internal(set) public var unreadCountDisplay: Int?
|
||||
public var unread: Int?
|
||||
public var unreadCountDisplay: Int?
|
||||
internal(set) public var hasPins: Bool?
|
||||
internal(set) public var members = [String]()
|
||||
internal(set) public var members: [String]?
|
||||
// Client use
|
||||
internal(set) public var pinnedItems = [Item]()
|
||||
internal(set) public var usersTyping = [String]()
|
||||
internal(set) public var messages = [String: Message]()
|
||||
|
||||
internal init?(channel: [String: AnyObject]?) {
|
||||
internal init(channel: [String: AnyObject]?) {
|
||||
id = channel?["id"] as? String
|
||||
name = channel?["name"] as? String
|
||||
created = channel?["created"] as? Int
|
||||
@@ -66,18 +66,19 @@ public struct Channel {
|
||||
purpose = Topic(topic: channel?["purpose"] as? [String: AnyObject])
|
||||
isMember = channel?["is_member"] as? Bool
|
||||
lastRead = channel?["last_read"] as? String
|
||||
latest = Message(message: channel?["latest"] as? [String: AnyObject])
|
||||
unread = channel?["unread_count"] as? Int
|
||||
unreadCountDisplay = channel?["unread_count_display"] as? Int
|
||||
hasPins = channel?["has_pins"] as? Bool
|
||||
|
||||
if let members = channel?["members"] as? [String] {
|
||||
self.members = members
|
||||
members = channel?["members"] as? [String]
|
||||
|
||||
if let latestMsgDictionary = channel?["latest"] as? [String: AnyObject] {
|
||||
latest = Message(message: latestMsgDictionary)
|
||||
} else {
|
||||
latest = Message(ts: channel?["latest"] as? String)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
internal init?(id:String?) {
|
||||
internal init(id:String?) {
|
||||
self.id = id
|
||||
created = nil
|
||||
creator = nil
|
||||
|
||||
@@ -0,0 +1,177 @@
|
||||
//
|
||||
// Client+EventDispatching.swift
|
||||
//
|
||||
// Copyright © 2016 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.
|
||||
|
||||
internal extension Client {
|
||||
|
||||
func dispatch(_ event: [String: AnyObject]) {
|
||||
let event = Event(event: event)
|
||||
guard let type = event.type else {
|
||||
return
|
||||
}
|
||||
switch type {
|
||||
case .Hello:
|
||||
connected = true
|
||||
connectionEventsDelegate?.clientConnected(self)
|
||||
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)
|
||||
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:
|
||||
connect(options: options ?? ClientOptions())
|
||||
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:
|
||||
print("Error: \(event)")
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,563 @@
|
||||
//
|
||||
// Client+EventHandling.swift
|
||||
//
|
||||
// Copyright © 2016 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
|
||||
|
||||
internal extension Client {
|
||||
|
||||
//MARK: - Pong
|
||||
func pong(_ event: Event) {
|
||||
pong = event.replyTo
|
||||
}
|
||||
|
||||
//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
|
||||
messageEventsDelegate?.messageSent(self, message: 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
|
||||
messageEventsDelegate?.messageReceived(self, message: 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
|
||||
messageEventsDelegate?.messageChanged(self, message: nested)
|
||||
}
|
||||
|
||||
func messageDeleted(_ event: Event) {
|
||||
guard let id = event.channel?.id, let key = event.message?.deletedTs, let message = channels[id]?.messages[key] else {
|
||||
return
|
||||
}
|
||||
|
||||
_ = channels[id]?.messages.removeValue(forKey: key)
|
||||
messageEventsDelegate?.messageDeleted(self, message: message)
|
||||
}
|
||||
|
||||
//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)
|
||||
channelEventsDelegate?.userTyping(self, channel: channel, user: user)
|
||||
|
||||
let timeout = DispatchTime.now() + Double(Int64(5.0 * Double(NSEC_PER_SEC))) / Double(NSEC_PER_SEC)
|
||||
DispatchQueue.main.after(when: timeout) {
|
||||
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, let timestamp = event.ts else {
|
||||
return
|
||||
}
|
||||
|
||||
channels[id]?.lastRead = event.ts
|
||||
channelEventsDelegate?.channelMarked(self, channel: channel, timestamp: timestamp)
|
||||
}
|
||||
|
||||
func channelCreated(_ event: Event) {
|
||||
guard let channel = event.channel, let id = channel.id else {
|
||||
return
|
||||
}
|
||||
|
||||
channels[id] = channel
|
||||
channelEventsDelegate?.channelCreated(self, channel: channel)
|
||||
}
|
||||
|
||||
func channelDeleted(_ event: Event) {
|
||||
guard let channel = event.channel, let id = channel.id else {
|
||||
return
|
||||
}
|
||||
|
||||
channels.removeValue(forKey: id)
|
||||
channelEventsDelegate?.channelDeleted(self, channel: channel)
|
||||
}
|
||||
|
||||
func channelJoined(_ event: Event) {
|
||||
guard let channel = event.channel, let id = channel.id else {
|
||||
return
|
||||
}
|
||||
|
||||
channels[id] = event.channel
|
||||
channelEventsDelegate?.channelJoined(self, channel: 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)
|
||||
}
|
||||
channelEventsDelegate?.channelLeft(self, channel: channel)
|
||||
}
|
||||
|
||||
func channelRenamed(_ event: Event) {
|
||||
guard let channel = event.channel, let id = channel.id else {
|
||||
return
|
||||
}
|
||||
|
||||
channels[id]?.name = channel.name
|
||||
channelEventsDelegate?.channelRenamed(self, channel: channel)
|
||||
}
|
||||
|
||||
func channelArchived(_ event: Event, archived: Bool) {
|
||||
guard let channel = event.channel, let id = channel.id else {
|
||||
return
|
||||
}
|
||||
|
||||
channels[id]?.isArchived = archived
|
||||
channelEventsDelegate?.channelArchived(self, channel: channel)
|
||||
}
|
||||
|
||||
func channelHistoryChanged(_ event: Event) {
|
||||
guard let channel = event.channel else {
|
||||
return
|
||||
}
|
||||
channelEventsDelegate?.channelHistoryChanged(self, channel: channel)
|
||||
}
|
||||
|
||||
//MARK: - Do Not Disturb
|
||||
func doNotDisturbUpdated(_ event: Event) {
|
||||
guard let dndStatus = event.dndStatus else {
|
||||
return
|
||||
}
|
||||
|
||||
authenticatedUser?.doNotDisturbStatus = dndStatus
|
||||
doNotDisturbEventsDelegate?.doNotDisturbUpdated(self, dndStatus: dndStatus)
|
||||
}
|
||||
|
||||
func doNotDisturbUserUpdated(_ event: Event) {
|
||||
guard let dndStatus = event.dndStatus, let user = event.user, let id = user.id else {
|
||||
return
|
||||
}
|
||||
|
||||
users[id]?.doNotDisturbStatus = dndStatus
|
||||
doNotDisturbEventsDelegate?.doNotDisturbUserUpdated(self, dndStatus: dndStatus, user: user)
|
||||
}
|
||||
|
||||
//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
|
||||
groupEventsDelegate?.groupOpened(self, group: channel)
|
||||
}
|
||||
|
||||
//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
|
||||
fileEventsDelegate?.fileProcessed(self, file: file)
|
||||
}
|
||||
|
||||
func filePrivate(_ event: Event) {
|
||||
guard let file = event.file, let id = file.id else {
|
||||
return
|
||||
}
|
||||
|
||||
files[id]?.isPublic = false
|
||||
fileEventsDelegate?.fileMadePrivate(self, file: file)
|
||||
}
|
||||
|
||||
func deleteFile(_ event: Event) {
|
||||
guard let file = event.file, let id = file.id else {
|
||||
return
|
||||
}
|
||||
|
||||
if files[id] != nil {
|
||||
files.removeValue(forKey: id)
|
||||
}
|
||||
fileEventsDelegate?.fileDeleted(self, file: file)
|
||||
}
|
||||
|
||||
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
|
||||
fileEventsDelegate?.fileCommentAdded(self, file: file, comment: 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
|
||||
fileEventsDelegate?.fileCommentEdited(self, file: file, 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)
|
||||
fileEventsDelegate?.fileCommentDeleted(self, file: file, comment: comment)
|
||||
}
|
||||
|
||||
//MARK: - Pins
|
||||
func pinAdded(_ event: Event) {
|
||||
guard let id = event.channelID, let item = event.item else {
|
||||
return
|
||||
}
|
||||
|
||||
channels[id]?.pinnedItems.append(item)
|
||||
pinEventsDelegate?.itemPinned(self, item: item, channel: channels[id])
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
pinEventsDelegate?.itemUnpinned(self, item: item, channel: channels[id])
|
||||
}
|
||||
|
||||
//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
|
||||
}
|
||||
|
||||
starEventsDelegate?.itemStarred(self, item: item, star: star)
|
||||
}
|
||||
|
||||
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, let itemUser = event.itemUser 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
|
||||
}
|
||||
|
||||
reactionEventsDelegate?.reactionAdded(self, reaction: reaction, item: item, itemUser: itemUser)
|
||||
}
|
||||
|
||||
func removedReaction(_ event: Event) {
|
||||
guard let item = event.item, let type = item.type, let key = event.reaction, let userID = event.user?.id, let itemUser = event.itemUser 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
|
||||
}
|
||||
|
||||
reactionEventsDelegate?.reactionRemoved(self, reaction: key, item: item, itemUser: itemUser)
|
||||
}
|
||||
|
||||
//MARK: - Preferences
|
||||
func changePreference(_ event: Event) {
|
||||
guard let name = event.name else {
|
||||
return
|
||||
}
|
||||
|
||||
authenticatedUser?.preferences?[name] = event.value
|
||||
slackEventsDelegate?.preferenceChanged(self, preference: name, value: 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
|
||||
slackEventsDelegate?.userChanged(self, user: user)
|
||||
}
|
||||
|
||||
//MARK: - User Presence
|
||||
func presenceChange(_ event: Event) {
|
||||
guard let user = event.user, let id = user.id, let presence = event.presence else {
|
||||
return
|
||||
}
|
||||
|
||||
users[id]?.presence = event.presence
|
||||
slackEventsDelegate?.presenceChanged(self, user: user, presence: presence)
|
||||
}
|
||||
|
||||
//MARK: - Team
|
||||
func teamJoin(_ event: Event) {
|
||||
guard let user = event.user, let id = user.id else {
|
||||
return
|
||||
}
|
||||
|
||||
users[id] = user
|
||||
teamEventsDelegate?.teamJoined(self, user: user)
|
||||
}
|
||||
|
||||
func teamPlanChange(_ event: Event) {
|
||||
guard let plan = event.plan else {
|
||||
return
|
||||
}
|
||||
|
||||
team?.plan = plan
|
||||
teamEventsDelegate?.teamPlanChanged(self, plan: plan)
|
||||
}
|
||||
|
||||
func teamPreferenceChange(_ event: Event) {
|
||||
guard let name = event.name else {
|
||||
return
|
||||
}
|
||||
|
||||
team?.prefs?[name] = event.value
|
||||
teamEventsDelegate?.teamPreferencesChanged(self, preference: name, value: event.value)
|
||||
}
|
||||
|
||||
func teamNameChange(_ event: Event) {
|
||||
guard let name = event.name else {
|
||||
return
|
||||
}
|
||||
|
||||
team?.name = name
|
||||
teamEventsDelegate?.teamNameChanged(self, name: name)
|
||||
}
|
||||
|
||||
func teamDomainChange(_ event: Event) {
|
||||
guard let domain = event.domain else {
|
||||
return
|
||||
}
|
||||
|
||||
team?.domain = domain
|
||||
teamEventsDelegate?.teamDomainChanged(self, domain: domain)
|
||||
}
|
||||
|
||||
func emailDomainChange(_ event: Event) {
|
||||
guard let domain = event.emailDomain else {
|
||||
return
|
||||
}
|
||||
|
||||
team?.emailDomain = domain
|
||||
teamEventsDelegate?.teamEmailDomainChanged(self, domain: domain)
|
||||
}
|
||||
|
||||
func emojiChanged(_ event: Event) {
|
||||
teamEventsDelegate?.teamEmojiChanged(self)
|
||||
}
|
||||
|
||||
//MARK: - Bots
|
||||
func bot(_ event: Event) {
|
||||
guard let bot = event.bot, let id = bot.id else {
|
||||
return
|
||||
}
|
||||
|
||||
bots[id] = bot
|
||||
slackEventsDelegate?.botEvent(self, bot: bot)
|
||||
}
|
||||
|
||||
//MARK: - Subteams
|
||||
func subteam(_ event: Event) {
|
||||
guard let subteam = event.subteam, let id = subteam.id else {
|
||||
return
|
||||
}
|
||||
|
||||
userGroups[id] = subteam
|
||||
subteamEventsDelegate?.subteamEvent(self, userGroup: subteam)
|
||||
}
|
||||
|
||||
func subteamAddedSelf(_ event: Event) {
|
||||
guard let subteamID = event.subteamID, let _ = authenticatedUser?.userGroups else {
|
||||
return
|
||||
}
|
||||
|
||||
authenticatedUser?.userGroups![subteamID] = subteamID
|
||||
subteamEventsDelegate?.subteamSelfAdded(self, subteamID: subteamID)
|
||||
}
|
||||
|
||||
func subteamRemovedSelf(_ event: Event) {
|
||||
guard let subteamID = event.subteamID else {
|
||||
return
|
||||
}
|
||||
|
||||
_ = authenticatedUser?.userGroups?.removeValue(forKey: subteamID)
|
||||
subteamEventsDelegate?.subteamSelfRemoved(self, subteamID: 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])
|
||||
}
|
||||
}
|
||||
|
||||
teamProfileEventsDelegate?.teamProfileChanged(self, profile: profile)
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
teamProfileEventsDelegate?.teamProfileDeleted(self, profile: profile)
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
teamProfileEventsDelegate?.teamProfileReordered(self, profile: profile)
|
||||
}
|
||||
|
||||
//MARK: - Authenticated User
|
||||
func manualPresenceChange(_ event: Event) {
|
||||
guard let presence = event.presence, let user = authenticatedUser else {
|
||||
return
|
||||
}
|
||||
|
||||
authenticatedUser?.presence = presence
|
||||
slackEventsDelegate?.manualPresenceChanged(self, user: user, presence: presence)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
//
|
||||
// Client+Utilities.swift
|
||||
//
|
||||
// Copyright © 2016 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 ClientError: ErrorProtocol {
|
||||
case channelDoesNotExist
|
||||
case userDoesNotExist
|
||||
}
|
||||
|
||||
public extension Client {
|
||||
|
||||
//MARK: - User & Channel
|
||||
public func getChannelIDByName(_ name: String) throws -> String {
|
||||
guard let id = channels.filter({$0.1.name == stripString(name)}).first?.0 else {
|
||||
throw ClientError.channelDoesNotExist
|
||||
}
|
||||
return id
|
||||
}
|
||||
|
||||
public func getUserIDByName(_ name: String) throws -> String {
|
||||
guard let id = users.filter({$0.1.name == stripString(name)}).first?.0 else {
|
||||
throw ClientError.userDoesNotExist
|
||||
}
|
||||
return id
|
||||
}
|
||||
|
||||
public func getImIDForUserWithID(_ id: String, success: (imID: String?)->Void, failure: (error: SlackError)->Void) {
|
||||
let ims = channels.filter{$0.1.isIM == true}
|
||||
let channel = ims.filter{$0.1.user == id}.first
|
||||
if let channel = channel {
|
||||
success(imID: channel.0)
|
||||
} else {
|
||||
webAPI.openIM(id, success: success, failure: failure)
|
||||
}
|
||||
}
|
||||
|
||||
//MARK: - Utilities
|
||||
internal func stripString(_ string: String) -> String {
|
||||
var strippedString = string
|
||||
if string[string.startIndex] == "@" || string[string.startIndex] == "#" {
|
||||
strippedString = string.substring(from: string.characters.index(string.startIndex, offsetBy: 1))
|
||||
}
|
||||
return strippedString
|
||||
}
|
||||
}
|
||||
+161
-144
@@ -24,10 +24,9 @@
|
||||
import Foundation
|
||||
import Starscream
|
||||
|
||||
public class Client: WebSocketDelegate {
|
||||
public final class Client: WebSocketDelegate {
|
||||
|
||||
internal(set) public var connected = false
|
||||
internal(set) public var authenticated = false
|
||||
internal(set) public var authenticatedUser: User?
|
||||
internal(set) public var team: Team?
|
||||
|
||||
@@ -38,172 +37,178 @@ public class Client: WebSocketDelegate {
|
||||
internal(set) public var files = [String: File]()
|
||||
internal(set) public var sentMessages = [String: Message]()
|
||||
|
||||
//MARK: - Delegates
|
||||
public var slackEventsDelegate: SlackEventsDelegate?
|
||||
public var messageEventsDelegate: MessageEventsDelegate?
|
||||
public var doNotDisturbEventsDelegate: DoNotDisturbEventsDelegate?
|
||||
public var channelEventsDelegate: ChannelEventsDelegate?
|
||||
public var groupEventsDelegate: GroupEventsDelegate?
|
||||
public var fileEventsDelegate: FileEventsDelegate?
|
||||
public var pinEventsDelegate: PinEventsDelegate?
|
||||
public var starEventsDelegate: StarEventsDelegate?
|
||||
public var reactionEventsDelegate: ReactionEventsDelegate?
|
||||
public var teamEventsDelegate: TeamEventsDelegate?
|
||||
public var subteamEventsDelegate: SubteamEventsDelegate?
|
||||
public var token = "xoxp-SLACK_AUTH_TOKEN"
|
||||
|
||||
public var webAPI: WebAPI {
|
||||
return WebAPI(token: token)
|
||||
}
|
||||
|
||||
private var token = "SLACK_AUTH_TOKEN"
|
||||
public func setAuthToken(token: String) {
|
||||
internal var webSocket: WebSocket?
|
||||
private let pingPongQueue = DispatchQueue(label: "com.launchsoft.SlackKit", attributes: DispatchQueueAttributes.serial)
|
||||
internal var ping: Double?
|
||||
internal var pong: Double?
|
||||
internal var options: ClientOptions?
|
||||
|
||||
//MARK: - Delegates
|
||||
public weak var connectionEventsDelegate: ConnectionEventsDelegate?
|
||||
public weak var slackEventsDelegate: SlackEventsDelegate?
|
||||
public weak var messageEventsDelegate: MessageEventsDelegate?
|
||||
public weak var doNotDisturbEventsDelegate: DoNotDisturbEventsDelegate?
|
||||
public weak var channelEventsDelegate: ChannelEventsDelegate?
|
||||
public weak var groupEventsDelegate: GroupEventsDelegate?
|
||||
public weak var fileEventsDelegate: FileEventsDelegate?
|
||||
public weak var pinEventsDelegate: PinEventsDelegate?
|
||||
public weak var starEventsDelegate: StarEventsDelegate?
|
||||
public weak var reactionEventsDelegate: ReactionEventsDelegate?
|
||||
public weak var teamEventsDelegate: TeamEventsDelegate?
|
||||
public weak var subteamEventsDelegate: SubteamEventsDelegate?
|
||||
public weak var teamProfileEventsDelegate: TeamProfileEventsDelegate?
|
||||
|
||||
// If you already have an API token
|
||||
internal init(apiToken: String) {
|
||||
self.token = apiToken
|
||||
}
|
||||
|
||||
public func setAuthToken(_ token: String) {
|
||||
self.token = token
|
||||
}
|
||||
|
||||
private var webSocket: WebSocket?
|
||||
|
||||
required public init() {
|
||||
|
||||
}
|
||||
|
||||
public static let sharedInstance = Client()
|
||||
|
||||
//MARK: - Connection
|
||||
public func connect() {
|
||||
let request = NSURLRequest(URL: NSURL(string:"https://slack.com/api/rtm.start?token="+token)!)
|
||||
NSURLConnection.sendAsynchronousRequest(request, queue: NSOperationQueue.currentQueue()!) {
|
||||
(response, data, error) -> Void in
|
||||
guard let data = data else {
|
||||
public func connect(options: ClientOptions = ClientOptions()) {
|
||||
self.options = options
|
||||
webAPI.rtmStart(options.simpleLatest, noUnreads: options.noUnreads, mpimAware: options.mpimAware, success: {
|
||||
(response) -> Void in
|
||||
guard let socketURL = response["url"] as? String, let url = URL(string: socketURL) else {
|
||||
return
|
||||
}
|
||||
do {
|
||||
let result = try NSJSONSerialization.JSONObjectWithData(data, options: []) as! [String: AnyObject]
|
||||
if (result["ok"] as! Bool == true) {
|
||||
self.initialSetup(result)
|
||||
let socketURL = NSURL(string: result["url"] as! String)
|
||||
self.webSocket = WebSocket(url: socketURL!)
|
||||
self.webSocket?.delegate = self
|
||||
self.webSocket?.connect()
|
||||
}
|
||||
} catch _ {
|
||||
print(error)
|
||||
}
|
||||
self.initialSetup(response)
|
||||
self.webSocket = WebSocket(url: url)
|
||||
self.webSocket?.delegate = self
|
||||
self.webSocket?.connect()
|
||||
}, failure: {(error) -> Void in
|
||||
self.connectionEventsDelegate?.clientConnectionFailed(self, error: error)
|
||||
})
|
||||
}
|
||||
|
||||
public func disconnect() {
|
||||
webSocket?.disconnect()
|
||||
}
|
||||
|
||||
//MARK: - RTM Message send
|
||||
public func sendMessage(_ message: String, channelID: String) {
|
||||
guard connected else { return }
|
||||
|
||||
if let data = try? formatMessageToSlackJsonString(msg: message, channel: channelID), let string = String(data: data, encoding: String.Encoding.utf8) {
|
||||
webSocket?.write(string: string)
|
||||
}
|
||||
}
|
||||
|
||||
//MARK: - Message send
|
||||
public func sendMessage(message: String, channelID: String) {
|
||||
if (connected) {
|
||||
if let data = formatMessageToSlackJsonString(msg: message, channel: channelID) {
|
||||
let string = NSString(data: data, encoding: NSUTF8StringEncoding)
|
||||
self.webSocket?.writeString(string as! String)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func formatMessageToSlackJsonString(message: (msg: String, channel: String)) -> NSData? {
|
||||
private func formatMessageToSlackJsonString(_ message: (msg: String, channel: String)) throws -> Data {
|
||||
let json: [String: AnyObject] = [
|
||||
"id": NSDate().timeIntervalSince1970,
|
||||
"id": Date().slackTimestamp(),
|
||||
"type": "message",
|
||||
"channel": message.channel,
|
||||
"text": slackFormatEscaping(message.msg)
|
||||
"text": message.msg.slackFormatEscaping()
|
||||
]
|
||||
addSentMessage(json)
|
||||
do {
|
||||
let data = try NSJSONSerialization.dataWithJSONObject(json, options: NSJSONWritingOptions.PrettyPrinted)
|
||||
return data
|
||||
}
|
||||
catch _ {
|
||||
return nil
|
||||
}
|
||||
return try JSONSerialization.data(withJSONObject: json, options: [])
|
||||
}
|
||||
|
||||
private func addSentMessage(dictionary: [String: AnyObject]) {
|
||||
private func addSentMessage(_ dictionary: [String: AnyObject]) {
|
||||
var message = dictionary
|
||||
let ts = message["id"] as? NSNumber
|
||||
message.removeValueForKey("id")
|
||||
message["ts"] = ts?.stringValue
|
||||
guard let id = message["id"] as? NSNumber else {
|
||||
return
|
||||
}
|
||||
let ts = String(id)
|
||||
message.removeValue(forKey: "id")
|
||||
message["ts"] = ts
|
||||
message["user"] = self.authenticatedUser?.id
|
||||
sentMessages[ts!.stringValue] = Message(message: message)
|
||||
sentMessages[ts] = Message(message: message)
|
||||
}
|
||||
|
||||
private func slackFormatEscaping(string: String) -> String {
|
||||
var escapedString = string.stringByReplacingOccurrencesOfString("&", withString: "&")
|
||||
escapedString = escapedString.stringByReplacingOccurrencesOfString("<", withString: "<")
|
||||
escapedString = escapedString.stringByReplacingOccurrencesOfString(">", withString: ">")
|
||||
return escapedString
|
||||
//MARK: - RTM Ping
|
||||
private func pingRTMServerAtInterval(_ interval: TimeInterval) {
|
||||
let delay = DispatchTime.now() + Double(Int64(interval * Double(NSEC_PER_SEC))) / Double(NSEC_PER_SEC)
|
||||
pingPongQueue.after(when: delay, execute: {
|
||||
guard self.connected && self.timeoutCheck() else {
|
||||
self.disconnect()
|
||||
return
|
||||
}
|
||||
self.sendRTMPing()
|
||||
self.pingRTMServerAtInterval(interval)
|
||||
})
|
||||
}
|
||||
|
||||
private func sendRTMPing() {
|
||||
guard connected else {
|
||||
return
|
||||
}
|
||||
let json: [String: AnyObject] = [
|
||||
"id": Date().slackTimestamp(),
|
||||
"type": "ping",
|
||||
]
|
||||
guard let data = try? JSONSerialization.data(withJSONObject: json, options: []) else {
|
||||
return
|
||||
}
|
||||
if let string = String(data: data, encoding: String.Encoding.utf8) {
|
||||
ping = json["id"] as? Double
|
||||
webSocket?.write(string: string)
|
||||
}
|
||||
}
|
||||
|
||||
private func timeoutCheck() -> Bool {
|
||||
if let pong = pong, let ping = ping, let timeout = options?.timeout {
|
||||
if pong - ping < timeout {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
// Ping-pong or timeout not configured
|
||||
} else {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
//MARK: - Client setup
|
||||
private func initialSetup(json: [String: AnyObject]) {
|
||||
private func initialSetup(_ json: [String: AnyObject]) {
|
||||
team = Team(team: json["team"] as? [String: AnyObject])
|
||||
authenticatedUser = User(user: json["self"] as? [String: AnyObject])
|
||||
authenticatedUser?.doNotDisturbStatus = DoNotDisturbStatus(status: json["dnd"] as? [String: AnyObject])
|
||||
enumerateUsers(json["users"] as? Array)
|
||||
enumerateChannels(json["channels"] as? Array)
|
||||
enumerateGroups(json["groups"] as? Array)
|
||||
enumerateMPIMs(json["mpims"] as? Array)
|
||||
enumerateIMs(json["ims"] as? Array)
|
||||
enumerateBots(json["bots"] as? Array)
|
||||
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: AnyObject])
|
||||
}
|
||||
|
||||
private func enumerateUsers(users: [AnyObject]?) {
|
||||
if let users = users {
|
||||
for user in users {
|
||||
let u = User(user: user as? [String: AnyObject])
|
||||
self.users[u!.id!] = u
|
||||
}
|
||||
private func addUser(_ aUser: [String: AnyObject]) {
|
||||
let user = User(user: aUser)
|
||||
if let id = user.id {
|
||||
users[id] = user
|
||||
}
|
||||
}
|
||||
|
||||
private func enumerateChannels(channels: [AnyObject]?) {
|
||||
if let channels = channels {
|
||||
for channel in channels {
|
||||
let c = Channel(channel: channel as? [String: AnyObject])
|
||||
self.channels[c!.id!] = c
|
||||
}
|
||||
private func addChannel(_ aChannel: [String: AnyObject]) {
|
||||
let channel = Channel(channel: aChannel)
|
||||
if let id = channel.id {
|
||||
channels[id] = channel
|
||||
}
|
||||
}
|
||||
|
||||
private func enumerateGroups(groups: [AnyObject]?) {
|
||||
if let groups = groups {
|
||||
for group in groups {
|
||||
let g = Channel(channel: group as? [String: AnyObject])
|
||||
self.channels[g!.id!] = g
|
||||
}
|
||||
private func addBot(_ aBot: [String: AnyObject]) {
|
||||
let bot = Bot(bot: aBot)
|
||||
if let id = bot.id {
|
||||
bots[id] = bot
|
||||
}
|
||||
}
|
||||
|
||||
private func enumerateIMs(ims: [AnyObject]?) {
|
||||
if let ims = ims {
|
||||
for im in ims {
|
||||
let i = Channel(channel: im as? [String: AnyObject])
|
||||
self.channels[i!.id!] = i
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func enumerateMPIMs(mpims: [AnyObject]?) {
|
||||
if let mpims = mpims {
|
||||
for mpim in mpims {
|
||||
let m = Channel(channel: mpim as? [String: AnyObject])
|
||||
self.channels[m!.id!] = m
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func enumerateBots(bots: [AnyObject]?) {
|
||||
if let bots = bots {
|
||||
for bot in bots {
|
||||
let b = Bot(bot: bot as? [String: AnyObject])
|
||||
self.bots[b!.id!] = b
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func enumerateSubteams(subteams: [String: AnyObject]?) {
|
||||
private func enumerateSubteams(_ subteams: [String: AnyObject]?) {
|
||||
if let subteams = subteams {
|
||||
if let all = subteams["all"] as? [[String: AnyObject]] {
|
||||
for item in all {
|
||||
let u = UserGroup(userGroup: item)
|
||||
self.userGroups[u!.id!] = u
|
||||
self.userGroups[u.id!] = u
|
||||
}
|
||||
}
|
||||
if let auth = subteams["self"] as? [String] {
|
||||
@@ -215,32 +220,44 @@ public class Client: WebSocketDelegate {
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Utilities
|
||||
private func enumerateObjects(_ array: [AnyObject]?, initalizer: ([String: AnyObject])-> Void) {
|
||||
if let array = array {
|
||||
for object in array {
|
||||
if let dictionary = object as? [String: AnyObject] {
|
||||
initalizer(dictionary)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - WebSocketDelegate
|
||||
public func websocketDidConnect(socket: WebSocket) {
|
||||
}
|
||||
|
||||
public func websocketDidDisconnect(socket: WebSocket, error: NSError?) {
|
||||
connected = false
|
||||
authenticated = false
|
||||
webSocket = nil
|
||||
if let delegate = slackEventsDelegate {
|
||||
delegate.clientDisconnected()
|
||||
if let pingInterval = options?.pingInterval {
|
||||
pingRTMServerAtInterval(pingInterval)
|
||||
}
|
||||
}
|
||||
|
||||
public func websocketDidReceiveMessage(socket: WebSocket, text: String) {
|
||||
guard let data = text.dataUsingEncoding(NSUTF8StringEncoding) else {
|
||||
public func websocketDidDisconnect(_ socket: WebSocket, error: NSError?) {
|
||||
connected = false
|
||||
webSocket = nil
|
||||
authenticatedUser = nil
|
||||
connectionEventsDelegate?.clientDisconnected(self)
|
||||
if let options = options, options.reconnect == true {
|
||||
connect(options: options)
|
||||
}
|
||||
}
|
||||
|
||||
public func websocketDidReceiveMessage(_ socket: WebSocket, text: String) {
|
||||
guard let data = text.data(using: String.Encoding.utf8) else {
|
||||
return
|
||||
}
|
||||
do {
|
||||
try EventDispatcher.eventDispatcher(NSJSONSerialization.JSONObjectWithData(data, options: NSJSONReadingOptions.AllowFragments) as! [String: AnyObject])
|
||||
}
|
||||
catch _ {
|
||||
|
||||
|
||||
if let json = (try? JSONSerialization.jsonObject(with: data, options: JSONSerialization.ReadingOptions.allowFragments)) as? [String: AnyObject] {
|
||||
dispatch(json)
|
||||
}
|
||||
}
|
||||
|
||||
public func websocketDidReceiveData(socket: WebSocket, data: NSData) {
|
||||
}
|
||||
|
||||
public func websocketDidReceiveData(_ socket: WebSocket, data: Data) {}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
//
|
||||
// ClientOptions.swift
|
||||
//
|
||||
// Copyright © 2016 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 ClientOptions {
|
||||
|
||||
let simpleLatest: Bool?
|
||||
let noUnreads: Bool?
|
||||
let mpimAware: Bool?
|
||||
let pingInterval: TimeInterval?
|
||||
let timeout: TimeInterval?
|
||||
let reconnect: Bool?
|
||||
|
||||
public init(simpleLatest: Bool? = nil, noUnreads: Bool? = nil, mpimAware: Bool? = nil, pingInterval: TimeInterval? = nil, timeout: TimeInterval? = nil, reconnect: Bool? = nil) {
|
||||
self.simpleLatest = simpleLatest
|
||||
self.noUnreads = noUnreads
|
||||
self.mpimAware = mpimAware
|
||||
self.pingInterval = pingInterval
|
||||
self.timeout = timeout
|
||||
self.reconnect = reconnect
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
//
|
||||
// Comment.swift
|
||||
//
|
||||
// Copyright © 2016 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 {
|
||||
public let id: String?
|
||||
public let user: String?
|
||||
internal(set) public var created: Int?
|
||||
internal(set) public var comment: String?
|
||||
internal(set) public var starred: Bool?
|
||||
internal(set) public var stars: Int?
|
||||
internal(set) public var reactions = [Reaction]()
|
||||
|
||||
internal init(comment:[String: AnyObject]?) {
|
||||
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
|
||||
}
|
||||
|
||||
internal init(id: String?) {
|
||||
self.id = id
|
||||
self.user = nil
|
||||
}
|
||||
}
|
||||
|
||||
extension Comment: Equatable {}
|
||||
|
||||
public func ==(lhs: Comment, rhs: Comment) -> Bool {
|
||||
return lhs.id == rhs.id
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
//
|
||||
// CustomProfile.swift
|
||||
//
|
||||
// Copyright © 2016 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 {
|
||||
internal(set) public var fields = [String: CustomProfileField]()
|
||||
|
||||
internal init(profile: [String: AnyObject]?) {
|
||||
if let eventFields = profile?["fields"] as? [AnyObject] {
|
||||
for field in eventFields {
|
||||
var cpf: CustomProfileField?
|
||||
if let fieldDictionary = field as? [String: AnyObject] {
|
||||
cpf = CustomProfileField(field: fieldDictionary)
|
||||
} else {
|
||||
cpf = CustomProfileField(id: field as? String)
|
||||
}
|
||||
if let id = cpf?.id { fields[id] = cpf }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal init(customFields: [String: AnyObject]?) {
|
||||
if let customFields = customFields {
|
||||
for key in customFields.keys {
|
||||
let cpf = CustomProfileField(field: customFields[key] as? [String: AnyObject])
|
||||
self.fields[key] = cpf
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
//
|
||||
// CustomProfileField.swift
|
||||
//
|
||||
// Copyright © 2016 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 {
|
||||
internal(set) public var id: String?
|
||||
internal(set) public var alt: String?
|
||||
internal(set) public var value: String?
|
||||
internal(set) public var hidden: Bool?
|
||||
internal(set) public var hint: String?
|
||||
internal(set) public var label: String?
|
||||
internal(set) public var options: String?
|
||||
internal(set) public var ordering: Int?
|
||||
internal(set) public var possibleValues: [String]?
|
||||
internal(set) public var type: String?
|
||||
|
||||
internal init(field: [String: AnyObject]?) {
|
||||
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
|
||||
}
|
||||
|
||||
internal init(id: String?) {
|
||||
self.id = id
|
||||
}
|
||||
|
||||
internal 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
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
//
|
||||
// DoNotDisturbStatus.swift
|
||||
//
|
||||
// Copyright © 2016 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 {
|
||||
internal(set) public var enabled: Bool?
|
||||
internal(set) public var nextDoNotDisturbStart: Int?
|
||||
internal(set) public var nextDoNotDisturbEnd: Int?
|
||||
internal(set) public var snoozeEnabled: Bool?
|
||||
internal(set) public var snoozeEndtime: Int?
|
||||
|
||||
internal init(status: [String: AnyObject]?) {
|
||||
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
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// SlackKit.h
|
||||
// Edited.swift
|
||||
//
|
||||
// Copyright © 2016 Peter Zignego. All rights reserved.
|
||||
//
|
||||
@@ -21,10 +21,12 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
//! Project version number for SlackKit.
|
||||
FOUNDATION_EXPORT double SlackKitVersionNumber;
|
||||
|
||||
//! Project version string for SlackKit.
|
||||
FOUNDATION_EXPORT const unsigned char SlackKitVersionString[];
|
||||
public struct Edited {
|
||||
public let user: String?
|
||||
public let ts: String?
|
||||
|
||||
internal init(edited:[String: AnyObject]?) {
|
||||
user = edited?["user"] as? String
|
||||
ts = edited?["ts"] as? String
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// Message.swift
|
||||
// Event.swift
|
||||
//
|
||||
// Copyright © 2016 Peter Zignego. All rights reserved.
|
||||
//
|
||||
@@ -62,6 +62,7 @@ internal enum EventType: String {
|
||||
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"
|
||||
@@ -78,10 +79,14 @@ internal enum EventType: String {
|
||||
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"
|
||||
@@ -138,7 +143,7 @@ internal struct Event {
|
||||
let domain: String?
|
||||
let emailDomain: String?
|
||||
let reaction: String?
|
||||
let replyTo: String?
|
||||
let replyTo: Double?
|
||||
let reactions: [[String: AnyObject]]?
|
||||
let edited: Edited?
|
||||
let bot: Bot?
|
||||
@@ -148,17 +153,15 @@ internal struct Event {
|
||||
let file: File?
|
||||
let message: Message?
|
||||
let nestedMessage: Message?
|
||||
let itemUser: String?
|
||||
let item: Item?
|
||||
let dndStatus: DoNotDisturbStatus?
|
||||
let subteam: UserGroup?
|
||||
let subteamID: String?
|
||||
var profile: CustomProfile?
|
||||
|
||||
init(event:[String: AnyObject]) {
|
||||
if let eventType = event["type"] as? String {
|
||||
type = EventType(rawValue:eventType)
|
||||
} else {
|
||||
type = EventType(rawValue: "ok")
|
||||
}
|
||||
type = EventType(rawValue: event["type"] as? String ?? "ok")
|
||||
ts = event["ts"] as? String
|
||||
subtype = event["subtype"] as? String
|
||||
channelID = event["channel_id"] as? String
|
||||
@@ -178,41 +181,39 @@ internal struct Event {
|
||||
domain = event["domain"] as? String
|
||||
emailDomain = event["email_domain"] as? String
|
||||
reaction = event["reaction"] as? String
|
||||
replyTo = event["reply_to"] as? String
|
||||
replyTo = event["reply_to"] as? Double
|
||||
reactions = event["reactions"] as? [[String: AnyObject]]
|
||||
bot = Bot(bot: event["bot"] as? [String: AnyObject])
|
||||
edited = Edited(edited:event["edited"] as? [String: AnyObject])
|
||||
dndStatus = DoNotDisturbStatus(status: event["dnd_status"] as? [String: AnyObject])
|
||||
itemUser = event["item_user"] as? String
|
||||
item = Item(item: event["item"] as? [String: AnyObject])
|
||||
subteam = UserGroup(userGroup: event["subteam"] as? [String: AnyObject])
|
||||
subteamID = event["subteam_id"] as? String
|
||||
message = Message(message: event)
|
||||
nestedMessage = Message(message: event["message"] as? [String: AnyObject])
|
||||
|
||||
// Comment, Channel, User, and File can come across as Strings or Dictionaries
|
||||
if (Comment(comment: event["comment"] as? [String: AnyObject])?.id == nil) {
|
||||
profile = CustomProfile(profile: event["profile"] as? [String: AnyObject])
|
||||
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: AnyObject] {
|
||||
comment = Comment(comment: commentDictionary)
|
||||
} else {
|
||||
comment = Comment(id: event["comment"] as? String)
|
||||
} else {
|
||||
comment = Comment(comment: event["comment"] as? [String: AnyObject])
|
||||
}
|
||||
|
||||
if (User(user: event["user"] as? [String: AnyObject])?.id == nil) {
|
||||
|
||||
if let userDictionary = event["user"] as? [String: AnyObject] {
|
||||
user = User(user: userDictionary)
|
||||
} else {
|
||||
user = User(id: event["user"] as? String)
|
||||
} else {
|
||||
user = User(user: event["user"] as? [String: AnyObject])
|
||||
}
|
||||
|
||||
if (File(file: event["file"] as? [String: AnyObject])?.id == nil) {
|
||||
file = File(id: event["file"] as? String)
|
||||
|
||||
if let channelDictionary = event["channel"] as? [String: AnyObject] {
|
||||
channel = Channel(channel: channelDictionary)
|
||||
} else {
|
||||
file = File(file: event["file"] as? [String: AnyObject])
|
||||
}
|
||||
|
||||
if (Channel(channel: event["channel"] as? [String: AnyObject])?.id == nil) {
|
||||
channel = Channel(id: event["channel"] as? String)
|
||||
} else {
|
||||
channel = Channel(channel: event["channel"] as? [String: AnyObject])
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -21,81 +21,89 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
import Foundation
|
||||
|
||||
public protocol SlackEventsDelegate {
|
||||
func clientConnected()
|
||||
func clientDisconnected()
|
||||
func preferenceChanged(preference: String, value: AnyObject)
|
||||
func userChanged(user: User)
|
||||
func presenceChanged(user: User?, presence: String?)
|
||||
func manualPresenceChanged(user: User?, presence: String?)
|
||||
func botEvent(bot: Bot)
|
||||
public protocol ConnectionEventsDelegate: class {
|
||||
func clientConnected(_ client: Client)
|
||||
func clientDisconnected(_ client: Client)
|
||||
func clientConnectionFailed(_ client: Client, error: SlackError)
|
||||
}
|
||||
|
||||
public protocol MessageEventsDelegate {
|
||||
func messageSent(message: Message)
|
||||
func messageReceived(message: Message)
|
||||
func messageChanged(message: Message)
|
||||
func messageDeleted(message: Message?)
|
||||
public protocol MessageEventsDelegate: class {
|
||||
func messageSent(_ client: Client, message: Message)
|
||||
func messageReceived(_ client: Client, message: Message)
|
||||
func messageChanged(_ client: Client, message: Message)
|
||||
func messageDeleted(_ client: Client, message: Message?)
|
||||
}
|
||||
|
||||
public protocol ChannelEventsDelegate {
|
||||
func userTyping(channel: Channel?, user: User?)
|
||||
func channelMarked(channel: Channel, timestamp: String?)
|
||||
func channelCreated(channel: Channel)
|
||||
func channelDeleted(channel: Channel)
|
||||
func channelRenamed(channel: Channel)
|
||||
func channelArchived(channel: Channel)
|
||||
func channelHistoryChanged(channel: Channel)
|
||||
func channelJoined(channel: Channel)
|
||||
func channelLeft(channel: Channel)
|
||||
public protocol ChannelEventsDelegate: class {
|
||||
func userTyping(_ client: Client, channel: Channel, user: User)
|
||||
func channelMarked(_ client: Client, channel: Channel, timestamp: String)
|
||||
func channelCreated(_ client: Client, channel: Channel)
|
||||
func channelDeleted(_ client: Client, channel: Channel)
|
||||
func channelRenamed(_ client: Client, channel: Channel)
|
||||
func channelArchived(_ client: Client, channel: Channel)
|
||||
func channelHistoryChanged(_ client: Client, channel: Channel)
|
||||
func channelJoined(_ client: Client, channel: Channel)
|
||||
func channelLeft(_ client: Client, channel: Channel)
|
||||
}
|
||||
|
||||
public protocol DoNotDisturbEventsDelegate {
|
||||
func doNotDisturbUpdated(dndStatus: DoNotDisturbStatus)
|
||||
func doNotDisturbUserUpdated(dndStatus: DoNotDisturbStatus, user: User?)
|
||||
public protocol DoNotDisturbEventsDelegate: class {
|
||||
func doNotDisturbUpdated(_ client: Client, dndStatus: DoNotDisturbStatus)
|
||||
func doNotDisturbUserUpdated(_ client: Client, dndStatus: DoNotDisturbStatus, user: User)
|
||||
}
|
||||
|
||||
public protocol GroupEventsDelegate {
|
||||
func groupOpened(group: Channel)
|
||||
public protocol GroupEventsDelegate: class {
|
||||
func groupOpened(_ client: Client, group: Channel)
|
||||
}
|
||||
|
||||
public protocol FileEventsDelegate {
|
||||
func fileProcessed(file: File)
|
||||
func fileMadePrivate(file: File)
|
||||
func fileDeleted(file: File)
|
||||
func fileCommentAdded(file: File, comment: Comment)
|
||||
func fileCommentEdited(file: File, comment: Comment)
|
||||
func fileCommentDeleted(file: File, comment: Comment)
|
||||
public protocol FileEventsDelegate: class {
|
||||
func fileProcessed(_ client: Client, file: File)
|
||||
func fileMadePrivate(_ client: Client, file: File)
|
||||
func fileDeleted(_ client: Client, file: File)
|
||||
func fileCommentAdded(_ client: Client, file: File, comment: Comment)
|
||||
func fileCommentEdited(_ client: Client, file: File, comment: Comment)
|
||||
func fileCommentDeleted(_ client: Client, file: File, comment: Comment)
|
||||
}
|
||||
|
||||
public protocol PinEventsDelegate {
|
||||
func itemPinned(item: Item?, channel: Channel?)
|
||||
func itemUnpinned(item: Item?, channel: Channel?)
|
||||
public protocol PinEventsDelegate: class {
|
||||
func itemPinned(_ client: Client, item: Item, channel: Channel?)
|
||||
func itemUnpinned(_ client: Client, item: Item, channel: Channel?)
|
||||
}
|
||||
|
||||
public protocol StarEventsDelegate {
|
||||
func itemStarred(item: Item, star: Bool)
|
||||
public protocol StarEventsDelegate: class {
|
||||
func itemStarred(_ client: Client, item: Item, star: Bool)
|
||||
}
|
||||
|
||||
public protocol ReactionEventsDelegate {
|
||||
func reactionAdded(reaction: String?, item: Item?)
|
||||
func reactionRemoved(reaction: String?, item: Item?)
|
||||
public protocol ReactionEventsDelegate: class {
|
||||
func reactionAdded(_ client: Client, reaction: String, item: Item, itemUser: String)
|
||||
func reactionRemoved(_ client: Client, reaction: String, item: Item, itemUser: String)
|
||||
}
|
||||
|
||||
public protocol TeamEventsDelegate {
|
||||
func teamJoined(user: User)
|
||||
func teamPlanChanged(plan: String)
|
||||
func teamPreferencesChanged(preference: String, value: AnyObject)
|
||||
func teamNameChanged(name: String)
|
||||
func teamDomainChanged(domain: String)
|
||||
func teamEmailDomainChanged(domain: String)
|
||||
func teamEmojiChanged()
|
||||
public protocol SlackEventsDelegate: class {
|
||||
func preferenceChanged(_ client: Client, preference: String, value: AnyObject?)
|
||||
func userChanged(_ client: Client, user: User)
|
||||
func presenceChanged(_ client: Client, user: User, presence: String)
|
||||
func manualPresenceChanged(_ client: Client, user: User, presence: String)
|
||||
func botEvent(_ client: Client, bot: Bot)
|
||||
}
|
||||
|
||||
public protocol SubteamEventsDelegate {
|
||||
func subteamEvent(userGroup: UserGroup)
|
||||
func subteamSelfAdded(subteamID: String)
|
||||
func subteamSelfRemoved(subteamID: String)
|
||||
public protocol TeamEventsDelegate: class {
|
||||
func teamJoined(_ client: Client, user: User)
|
||||
func teamPlanChanged(_ client: Client, plan: String)
|
||||
func teamPreferencesChanged(_ client: Client, preference: String, value: AnyObject?)
|
||||
func teamNameChanged(_ client: Client, name: String)
|
||||
func teamDomainChanged(_ client: Client, domain: String)
|
||||
func teamEmailDomainChanged(_ client: Client, domain: String)
|
||||
func teamEmojiChanged(_ client: Client)
|
||||
}
|
||||
|
||||
public protocol SubteamEventsDelegate: class {
|
||||
func subteamEvent(_ client: Client, userGroup: UserGroup)
|
||||
func subteamSelfAdded(_ client: Client, subteamID: String)
|
||||
func subteamSelfRemoved(_ client: Client, subteamID: String)
|
||||
}
|
||||
|
||||
public protocol TeamProfileEventsDelegate: class {
|
||||
func teamProfileChanged(_ client: Client, profile: CustomProfile)
|
||||
func teamProfileDeleted(_ client: Client, profile: CustomProfile)
|
||||
func teamProfileReordered(_ client: Client, profile: CustomProfile)
|
||||
}
|
||||
|
||||
@@ -1,159 +0,0 @@
|
||||
//
|
||||
// EventDispatcher.swift
|
||||
//
|
||||
// Copyright © 2016 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.
|
||||
|
||||
internal struct EventDispatcher {
|
||||
|
||||
static func eventDispatcher(event: [String: AnyObject]) {
|
||||
let event = Event(event: event)
|
||||
if let type = event.type {
|
||||
switch type {
|
||||
case .Hello:
|
||||
EventHandler.connected()
|
||||
case .Ok:
|
||||
EventHandler.messageSent(event)
|
||||
case .Message:
|
||||
if (event.subtype != nil) {
|
||||
messageDispatcher(event)
|
||||
} else {
|
||||
EventHandler.messageReceived(event)
|
||||
}
|
||||
case .UserTyping:
|
||||
EventHandler.userTyping(event)
|
||||
case .ChannelMarked, .IMMarked, .GroupMarked:
|
||||
EventHandler.channelMarked(event)
|
||||
case .ChannelCreated, .IMCreated:
|
||||
EventHandler.channelCreated(event)
|
||||
case .ChannelJoined, .GroupJoined:
|
||||
EventHandler.channelJoined(event)
|
||||
case .ChannelLeft, .GroupLeft:
|
||||
EventHandler.channelLeft(event)
|
||||
case .ChannelDeleted:
|
||||
EventHandler.channelDeleted(event)
|
||||
case .ChannelRenamed, .GroupRename:
|
||||
EventHandler.channelRenamed(event)
|
||||
case .ChannelArchive, .GroupArchive:
|
||||
EventHandler.channelArchived(event, archived: true)
|
||||
case .ChannelUnarchive, .GroupUnarchive:
|
||||
EventHandler.channelArchived(event, archived: false)
|
||||
case .ChannelHistoryChanged, .IMHistoryChanged, .GroupHistoryChanged:
|
||||
EventHandler.channelHistoryChanged(event)
|
||||
case .DNDUpdated:
|
||||
EventHandler.doNotDisturbUpdated(event)
|
||||
case .DNDUpatedUser:
|
||||
EventHandler.doNotDisturbUserUpdated(event)
|
||||
case .IMOpen, .GroupOpen:
|
||||
EventHandler.open(event, open: true)
|
||||
case .IMClose, .GroupClose:
|
||||
EventHandler.open(event, open: false)
|
||||
case .FileCreated:
|
||||
EventHandler.processFile(event)
|
||||
case .FileShared:
|
||||
EventHandler.processFile(event)
|
||||
case .FileUnshared:
|
||||
EventHandler.processFile(event)
|
||||
case .FilePublic:
|
||||
EventHandler.processFile(event)
|
||||
case .FilePrivate:
|
||||
EventHandler.filePrivate(event)
|
||||
case .FileChanged:
|
||||
EventHandler.processFile(event)
|
||||
case .FileDeleted:
|
||||
EventHandler.deleteFile(event)
|
||||
case .FileCommentAdded:
|
||||
EventHandler.fileCommentAdded(event)
|
||||
case .FileCommentEdited:
|
||||
EventHandler.fileCommentEdited(event)
|
||||
case .FileCommentDeleted:
|
||||
EventHandler.fileCommentDeleted(event)
|
||||
case .PinAdded:
|
||||
EventHandler.pinAdded(event)
|
||||
case .PinRemoved:
|
||||
EventHandler.pinRemoved(event)
|
||||
case .PresenceChange:
|
||||
EventHandler.presenceChange(event)
|
||||
case .ManualPresenceChange:
|
||||
EventHandler.manualPresenceChange(event)
|
||||
case .PrefChange:
|
||||
EventHandler.changePreference(event)
|
||||
case .UserChange:
|
||||
EventHandler.userChange(event)
|
||||
case .TeamJoin:
|
||||
EventHandler.teamJoin(event)
|
||||
case .StarAdded:
|
||||
EventHandler.itemStarred(event, star: true)
|
||||
case .StarRemoved:
|
||||
EventHandler.itemStarred(event, star: false)
|
||||
case .ReactionAdded:
|
||||
EventHandler.addedReaction(event)
|
||||
case .ReactionRemoved:
|
||||
EventHandler.removedReaction(event)
|
||||
case .EmojiChanged:
|
||||
EventHandler.emojiChanged(event)
|
||||
case .CommandsChanged:
|
||||
// Not implemented per Slack documentation.
|
||||
break
|
||||
case .TeamPlanChange:
|
||||
EventHandler.teamPlanChange(event)
|
||||
case .TeamPrefChange:
|
||||
EventHandler.teamPreferenceChange(event)
|
||||
case .TeamRename:
|
||||
EventHandler.teamNameChange(event)
|
||||
case .TeamDomainChange:
|
||||
EventHandler.teamDomainChange(event)
|
||||
case .EmailDomainChange:
|
||||
EventHandler.emailDomainChange(event)
|
||||
case .BotAdded:
|
||||
EventHandler.bot(event)
|
||||
case .BotChanged:
|
||||
EventHandler.bot(event)
|
||||
case .AccountsChanged:
|
||||
// Not implemented per Slack documentation.
|
||||
break
|
||||
case .TeamMigrationStarted:
|
||||
Client.sharedInstance.connect()
|
||||
case .SubteamCreated, .SubteamUpdated:
|
||||
EventHandler.subteam(event)
|
||||
case .SubteamSelfAdded:
|
||||
EventHandler.subteamAddedSelf(event)
|
||||
case.SubteamSelfRemoved:
|
||||
EventHandler.subteamRemovedSelf(event)
|
||||
case .Error:
|
||||
print("Error: \(event)")
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static func messageDispatcher(event:Event) {
|
||||
let subtype = MessageSubtype(rawValue: event.subtype!)!
|
||||
switch subtype {
|
||||
case .MessageChanged:
|
||||
EventHandler.messageChanged(event)
|
||||
case .MessageDeleted:
|
||||
EventHandler.messageDeleted(event)
|
||||
default:
|
||||
EventHandler.messageReceived(event)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,600 +0,0 @@
|
||||
//
|
||||
// EventHandler.swift
|
||||
//
|
||||
// Copyright © 2016 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
|
||||
|
||||
internal struct EventHandler {
|
||||
|
||||
//MARK: - Initial connection
|
||||
static func connected() {
|
||||
Client.sharedInstance.connected = true
|
||||
|
||||
if let delegate = Client.sharedInstance.slackEventsDelegate {
|
||||
delegate.clientConnected()
|
||||
}
|
||||
}
|
||||
|
||||
//MARK: - Messages
|
||||
|
||||
static func messageSent(event: Event) {
|
||||
if let reply = event.replyTo, message = Client.sharedInstance.sentMessages[reply], channel = message.channel, ts = message.ts {
|
||||
message.ts = event.ts
|
||||
message.text = event.text
|
||||
Client.sharedInstance.channels[channel]?.messages[ts] = message
|
||||
|
||||
if let delegate = Client.sharedInstance.messageEventsDelegate {
|
||||
delegate.messageSent(message)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static func messageReceived(event: Event) {
|
||||
if let channel = event.channel, message = event.message, id = channel.id, ts = message.ts {
|
||||
Client.sharedInstance.channels[id]?.messages[ts] = message
|
||||
|
||||
if let delegate = Client.sharedInstance.messageEventsDelegate {
|
||||
delegate.messageReceived(message)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static func messageChanged(event: Event) {
|
||||
if let id = event.channel?.id, nested = event.nestedMessage, ts = nested.ts {
|
||||
Client.sharedInstance.channels[id]?.messages[ts] = nested
|
||||
|
||||
if let delegate = Client.sharedInstance.messageEventsDelegate {
|
||||
delegate.messageChanged(nested)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static func messageDeleted(event: Event) {
|
||||
if let id = event.channel?.id, key = event.message?.deletedTs {
|
||||
let message = Client.sharedInstance.channels[id]?.messages[key]
|
||||
Client.sharedInstance.channels[id]?.messages.removeValueForKey(key)
|
||||
|
||||
if let delegate = Client.sharedInstance.messageEventsDelegate {
|
||||
delegate.messageDeleted(message)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//MARK: - Channels
|
||||
static func userTyping(event: Event) {
|
||||
if let channelID = event.channel?.id, userID = event.user?.id {
|
||||
if let _ = Client.sharedInstance.channels[channelID] {
|
||||
if (!Client.sharedInstance.channels[channelID]!.usersTyping.contains(userID)) {
|
||||
Client.sharedInstance.channels[channelID]?.usersTyping.append(userID)
|
||||
|
||||
if let delegate = Client.sharedInstance.channelEventsDelegate {
|
||||
delegate.userTyping(event.channel, user: event.user)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let timeout = dispatch_time(DISPATCH_TIME_NOW, Int64(5.0 * Double(NSEC_PER_SEC)))
|
||||
dispatch_after(timeout, dispatch_get_main_queue()) {
|
||||
if let index = Client.sharedInstance.channels[channelID]?.usersTyping.indexOf(userID) {
|
||||
Client.sharedInstance.channels[channelID]?.usersTyping.removeAtIndex(index)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static func channelMarked(event: Event) {
|
||||
if let channel = event.channel, id = channel.id {
|
||||
Client.sharedInstance.channels[id]?.lastRead = event.ts
|
||||
|
||||
if let delegate = Client.sharedInstance.channelEventsDelegate {
|
||||
delegate.channelMarked(channel, timestamp: event.ts)
|
||||
}
|
||||
}
|
||||
//TODO: Recalculate unreads
|
||||
}
|
||||
|
||||
static func channelCreated(event: Event) {
|
||||
if let channel = event.channel, id = channel.id {
|
||||
Client.sharedInstance.channels[id] = channel
|
||||
|
||||
if let delegate = Client.sharedInstance.channelEventsDelegate {
|
||||
delegate.channelCreated(channel)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static func channelDeleted(event: Event) {
|
||||
if let channel = event.channel, id = channel.id {
|
||||
Client.sharedInstance.channels.removeValueForKey(id)
|
||||
|
||||
if let delegate = Client.sharedInstance.channelEventsDelegate {
|
||||
delegate.channelDeleted(channel)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static func channelJoined(event: Event) {
|
||||
if let channel = event.channel, id = channel.id {
|
||||
Client.sharedInstance.channels[id] = event.channel
|
||||
|
||||
if let delegate = Client.sharedInstance.channelEventsDelegate {
|
||||
delegate.channelJoined(channel)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static func channelLeft(event: Event) {
|
||||
if let channel = event.channel, id = channel.id, userID = Client.sharedInstance.authenticatedUser?.id {
|
||||
if let index = Client.sharedInstance.channels[id]?.members.indexOf(userID) {
|
||||
Client.sharedInstance.channels[id]?.members.removeAtIndex(index)
|
||||
|
||||
if let delegate = Client.sharedInstance.channelEventsDelegate {
|
||||
delegate.channelLeft(channel)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static func channelRenamed(event: Event) {
|
||||
if let channel = event.channel, id = channel.id {
|
||||
Client.sharedInstance.channels[id]?.name = channel.name
|
||||
|
||||
if let delegate = Client.sharedInstance.channelEventsDelegate {
|
||||
delegate.channelRenamed(channel)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static func channelArchived(event: Event, archived: Bool) {
|
||||
if let channel = event.channel, id = channel.id {
|
||||
Client.sharedInstance.channels[id]?.isArchived = archived
|
||||
|
||||
if let delegate = Client.sharedInstance.channelEventsDelegate {
|
||||
delegate.channelArchived(channel)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static func channelHistoryChanged(event: Event) {
|
||||
if let channel = event.channel {
|
||||
//TODO: Reload chat history if there are any cached messages before latest
|
||||
|
||||
if let delegate = Client.sharedInstance.channelEventsDelegate {
|
||||
delegate.channelHistoryChanged(channel)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//MARK: - Do Not Disturb
|
||||
static func doNotDisturbUpdated(event: Event) {
|
||||
if let dndStatus = event.dndStatus {
|
||||
Client.sharedInstance.authenticatedUser?.doNotDisturbStatus = dndStatus
|
||||
|
||||
if let delegate = Client.sharedInstance.doNotDisturbEventsDelegate {
|
||||
delegate.doNotDisturbUpdated(dndStatus)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static func doNotDisturbUserUpdated(event: Event) {
|
||||
if let dndStatus = event.dndStatus, user = event.user, id = user.id {
|
||||
Client.sharedInstance.users[id]?.doNotDisturbStatus = dndStatus
|
||||
|
||||
if let delegate = Client.sharedInstance.doNotDisturbEventsDelegate {
|
||||
delegate.doNotDisturbUserUpdated(dndStatus, user: user)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//MARK: - IM & Group Open/Close
|
||||
static func open(event: Event, open: Bool) {
|
||||
if let channel = event.channel, id = channel.id {
|
||||
Client.sharedInstance.channels[id]?.isOpen = open
|
||||
|
||||
if let delegate = Client.sharedInstance.groupEventsDelegate {
|
||||
delegate.groupOpened(channel)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//MARK: - Files
|
||||
static func processFile(event: Event) {
|
||||
if let file = event.file, id = file.id {
|
||||
if let comment = file.initialComment, commentID = comment.id {
|
||||
if Client.sharedInstance.files[id]?.comments[commentID] == nil {
|
||||
Client.sharedInstance.files[id]?.comments[commentID] = comment
|
||||
}
|
||||
}
|
||||
|
||||
Client.sharedInstance.files[id] = file
|
||||
|
||||
if let delegate = Client.sharedInstance.fileEventsDelegate {
|
||||
delegate.fileProcessed(file)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static func filePrivate(event: Event) {
|
||||
if let file = event.file, id = file.id {
|
||||
Client.sharedInstance.files[id]?.isPublic = false
|
||||
|
||||
if let delegate = Client.sharedInstance.fileEventsDelegate {
|
||||
delegate.fileMadePrivate(file)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static func deleteFile(event: Event) {
|
||||
if let file = event.file, id = file.id {
|
||||
if Client.sharedInstance.files[id] != nil {
|
||||
Client.sharedInstance.files.removeValueForKey(id)
|
||||
}
|
||||
|
||||
if let delegate = Client.sharedInstance.fileEventsDelegate {
|
||||
delegate.fileDeleted(file)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static func fileCommentAdded(event: Event) {
|
||||
if let file = event.file, id = file.id, comment = event.comment, commentID = comment.id {
|
||||
Client.sharedInstance.files[id]?.comments[commentID] = comment
|
||||
|
||||
if let delegate = Client.sharedInstance.fileEventsDelegate {
|
||||
delegate.fileCommentAdded(file, comment: comment)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static func fileCommentEdited(event: Event) {
|
||||
if let file = event.file, id = file.id, comment = event.comment, commentID = comment.id {
|
||||
Client.sharedInstance.files[id]?.comments[commentID]?.comment = comment.comment
|
||||
|
||||
if let delegate = Client.sharedInstance.fileEventsDelegate {
|
||||
delegate.fileCommentEdited(file, comment: comment)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static func fileCommentDeleted(event: Event) {
|
||||
if let file = event.file, id = file.id, comment = event.comment, commentID = comment.id {
|
||||
Client.sharedInstance.files[id]?.comments.removeValueForKey(commentID)
|
||||
|
||||
if let delegate = Client.sharedInstance.fileEventsDelegate {
|
||||
delegate.fileCommentDeleted(file, comment: comment)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//MARK: - Pins
|
||||
static func pinAdded(event: Event) {
|
||||
if let id = event.channelID, item = event.item {
|
||||
Client.sharedInstance.channels[id]?.pinnedItems.append(item)
|
||||
|
||||
if let delegate = Client.sharedInstance.pinEventsDelegate {
|
||||
delegate.itemPinned(item, channel: Client.sharedInstance.channels[id])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static func pinRemoved(event: Event) {
|
||||
if let id = event.channelID {
|
||||
if let pins = Client.sharedInstance.channels[id]?.pinnedItems.filter({$0 != event.item}) {
|
||||
Client.sharedInstance.channels[id]?.pinnedItems = pins
|
||||
}
|
||||
|
||||
if let delegate = Client.sharedInstance.pinEventsDelegate {
|
||||
delegate.itemUnpinned(event.item, channel: Client.sharedInstance.channels[id])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//MARK: - Stars
|
||||
static func itemStarred(event: Event, star: Bool) {
|
||||
if let item = event.item, type = item.type {
|
||||
switch type {
|
||||
case "message":
|
||||
starMessage(item, star: star)
|
||||
case "file":
|
||||
starFile(item, star: star)
|
||||
case "file_comment":
|
||||
starComment(item)
|
||||
default:
|
||||
break
|
||||
}
|
||||
|
||||
if let delegate = Client.sharedInstance.starEventsDelegate {
|
||||
delegate.itemStarred(item, star: star)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static func starMessage(item: Item, star: Bool) {
|
||||
if let message = item.message, ts = message.ts, channel = item.channel {
|
||||
if let _ = Client.sharedInstance.channels[channel]?.messages[ts] {
|
||||
Client.sharedInstance.channels[channel]?.messages[ts]?.isStarred = star
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static func starFile(item: Item, star: Bool) {
|
||||
if let file = item.file, id = file.id {
|
||||
Client.sharedInstance.files[id]?.isStarred = star
|
||||
if let stars = Client.sharedInstance.files[id]?.stars {
|
||||
if star == true {
|
||||
Client.sharedInstance.files[id]?.stars = stars + 1
|
||||
} else {
|
||||
if stars > 0 {
|
||||
Client.sharedInstance.files[id]?.stars = stars - 1
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static func starComment(item: Item) {
|
||||
if let file = item.file, id = file.id, comment = item.comment, commentID = comment.id {
|
||||
Client.sharedInstance.files[id]?.comments[commentID] = comment
|
||||
}
|
||||
}
|
||||
|
||||
//MARK: - Reactions
|
||||
static func addedReaction(event: Event) {
|
||||
if let item = event.item, type = item.type, key = event.reaction, userID = event.user?.id {
|
||||
switch type {
|
||||
case "message":
|
||||
if let channel = item.channel, ts = item.ts {
|
||||
if let message = Client.sharedInstance.channels[channel]?.messages[ts] {
|
||||
if (message.reactions[key]) == nil {
|
||||
message.reactions[key] = Reaction(name: event.reaction, user: userID)
|
||||
} else {
|
||||
message.reactions[key]?.users[userID] = userID
|
||||
}
|
||||
}
|
||||
}
|
||||
case "file":
|
||||
if let id = item.file?.id, file = Client.sharedInstance.files[id] {
|
||||
if file.reactions[key] == nil {
|
||||
Client.sharedInstance.files[id]?.reactions[key] = Reaction(name: event.reaction, user: userID)
|
||||
} else {
|
||||
Client.sharedInstance.files[id]?.reactions[key]?.users[userID] = userID
|
||||
}
|
||||
}
|
||||
case "file_comment":
|
||||
if let id = item.file?.id, file = Client.sharedInstance.files[id], commentID = item.fileCommentID {
|
||||
if file.comments[commentID]?.reactions[key] == nil {
|
||||
Client.sharedInstance.files[id]?.comments[commentID]?.reactions[key] = Reaction(name: event.reaction, user: userID)
|
||||
} else {
|
||||
Client.sharedInstance.files[id]?.comments[commentID]?.reactions[key]?.users[userID] = userID
|
||||
}
|
||||
}
|
||||
break
|
||||
default:
|
||||
break
|
||||
}
|
||||
|
||||
if let delegate = Client.sharedInstance.reactionEventsDelegate {
|
||||
delegate.reactionAdded(event.reaction, item: event.item)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static func removedReaction(event: Event) {
|
||||
if let item = event.item, type = item.type, key = event.reaction, userID = event.user?.id {
|
||||
switch type {
|
||||
case "message":
|
||||
if let channel = item.channel, ts = item.ts {
|
||||
if let message = Client.sharedInstance.channels[channel]?.messages[ts] {
|
||||
if (message.reactions[key]) != nil {
|
||||
message.reactions[key]?.users.removeValueForKey(userID)
|
||||
}
|
||||
if (message.reactions[key]?.users.count == 0) {
|
||||
message.reactions.removeValueForKey(key)
|
||||
}
|
||||
}
|
||||
}
|
||||
case "file":
|
||||
if let itemFile = item.file, id = itemFile.id, file = Client.sharedInstance.files[id] {
|
||||
if file.reactions[key] != nil {
|
||||
Client.sharedInstance.files[id]?.reactions[key]?.users.removeValueForKey(userID)
|
||||
}
|
||||
if Client.sharedInstance.files[id]?.reactions[key]?.users.count == 0 {
|
||||
Client.sharedInstance.files[id]?.reactions.removeValueForKey(key)
|
||||
}
|
||||
}
|
||||
case "file_comment":
|
||||
if let id = item.file?.id, file = Client.sharedInstance.files[id], commentID = item.fileCommentID {
|
||||
if file.comments[commentID]?.reactions[key] != nil {
|
||||
Client.sharedInstance.files[id]?.comments[commentID]?.reactions[key]?.users.removeValueForKey(userID)
|
||||
}
|
||||
if Client.sharedInstance.files[id]?.comments[commentID]?.reactions[key]?.users.count == 0 {
|
||||
Client.sharedInstance.files[id]?.comments[commentID]?.reactions.removeValueForKey(key)
|
||||
}
|
||||
}
|
||||
break
|
||||
default:
|
||||
break
|
||||
}
|
||||
|
||||
if let delegate = Client.sharedInstance.reactionEventsDelegate {
|
||||
delegate.reactionAdded(event.reaction, item: event.item)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//MARK: - Preferences
|
||||
static func changePreference(event: Event) {
|
||||
if let name = event.name {
|
||||
Client.sharedInstance.authenticatedUser?.preferences?[name] = event.value
|
||||
|
||||
if let delegate = Client.sharedInstance.slackEventsDelegate, value = event.value {
|
||||
delegate.preferenceChanged(name, value: value)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Mark: - User Change
|
||||
static func userChange(event: Event) {
|
||||
if let user = event.user, id = user.id {
|
||||
let preferences = Client.sharedInstance.users[id]?.preferences
|
||||
Client.sharedInstance.users[id] = user
|
||||
Client.sharedInstance.users[id]?.preferences = preferences
|
||||
|
||||
if let delegate = Client.sharedInstance.slackEventsDelegate {
|
||||
delegate.userChanged(user)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//MARK: - User Presence
|
||||
static func presenceChange(event: Event) {
|
||||
if let user = event.user, id = user.id {
|
||||
Client.sharedInstance.users[id]?.presence = event.presence
|
||||
|
||||
if let delegate = Client.sharedInstance.slackEventsDelegate {
|
||||
delegate.presenceChanged(user, presence: event.presence)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//MARK: - Team
|
||||
static func teamJoin(event: Event) {
|
||||
if let user = event.user, id = user.id {
|
||||
Client.sharedInstance.users[id] = user
|
||||
|
||||
if let delegate = Client.sharedInstance.teamEventsDelegate {
|
||||
delegate.teamJoined(user)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static func teamPlanChange(event: Event) {
|
||||
if let plan = event.plan {
|
||||
Client.sharedInstance.team?.plan = plan
|
||||
|
||||
if let delegate = Client.sharedInstance.teamEventsDelegate {
|
||||
delegate.teamPlanChanged(plan)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static func teamPreferenceChange(event: Event) {
|
||||
if let name = event.name {
|
||||
Client.sharedInstance.team?.prefs?[name] = event.value
|
||||
|
||||
if let delegate = Client.sharedInstance.teamEventsDelegate, value = event.value {
|
||||
delegate.teamPreferencesChanged(name, value: value)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static func teamNameChange(event: Event) {
|
||||
if let name = event.name {
|
||||
Client.sharedInstance.team?.name = name
|
||||
|
||||
if let delegate = Client.sharedInstance.teamEventsDelegate {
|
||||
delegate.teamNameChanged(name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static func teamDomainChange(event: Event) {
|
||||
if let domain = event.domain {
|
||||
Client.sharedInstance.team?.domain = domain
|
||||
|
||||
if let delegate = Client.sharedInstance.teamEventsDelegate {
|
||||
delegate.teamDomainChanged(domain)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static func emailDomainChange(event: Event) {
|
||||
if let domain = event.emailDomain {
|
||||
Client.sharedInstance.team?.emailDomain = domain
|
||||
|
||||
if let delegate = Client.sharedInstance.teamEventsDelegate {
|
||||
delegate.teamEmailDomainChanged(domain)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static func emojiChanged(event: Event) {
|
||||
//TODO: Call emoji.list here
|
||||
|
||||
if let delegate = Client.sharedInstance.teamEventsDelegate {
|
||||
delegate.teamEmojiChanged()
|
||||
}
|
||||
}
|
||||
|
||||
//MARK: - Bots
|
||||
static func bot(event: Event) {
|
||||
if let bot = event.bot, id = bot.id {
|
||||
Client.sharedInstance.bots[id] = bot
|
||||
|
||||
if let delegate = Client.sharedInstance.slackEventsDelegate {
|
||||
delegate.botEvent(bot)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//MARK: - Subteams
|
||||
static func subteam(event: Event) {
|
||||
if let subteam = event.subteam, id = subteam.id {
|
||||
Client.sharedInstance.userGroups[id] = subteam
|
||||
|
||||
if let delegate = Client.sharedInstance.subteamEventsDelegate {
|
||||
delegate.subteamEvent(subteam)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static func subteamAddedSelf(event: Event) {
|
||||
if let subteamID = event.subteamID, _ = Client.sharedInstance.authenticatedUser?.userGroups {
|
||||
Client.sharedInstance.authenticatedUser?.userGroups![subteamID] = subteamID
|
||||
|
||||
if let delegate = Client.sharedInstance.subteamEventsDelegate {
|
||||
delegate.subteamSelfAdded(subteamID)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static func subteamRemovedSelf(event: Event) {
|
||||
if let subteamID = event.subteamID {
|
||||
Client.sharedInstance.authenticatedUser?.userGroups?.removeValueForKey(subteamID)
|
||||
|
||||
if let delegate = Client.sharedInstance.subteamEventsDelegate {
|
||||
delegate.subteamSelfRemoved(subteamID)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//MARK: - Authenticated User
|
||||
static func manualPresenceChange(event: Event) {
|
||||
Client.sharedInstance.authenticatedUser?.presence = event.presence
|
||||
|
||||
if let delegate = Client.sharedInstance.slackEventsDelegate {
|
||||
delegate.manualPresenceChanged(Client.sharedInstance.authenticatedUser, presence: event.presence)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
//
|
||||
// Extensions.swift
|
||||
//
|
||||
// Copyright © 2016 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 {
|
||||
|
||||
func slackTimestamp() -> Double {
|
||||
return NSNumber(value: timeIntervalSince1970).doubleValue
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
internal extension String {
|
||||
|
||||
func slackFormatEscaping() -> String {
|
||||
var escapedString = replacingOccurrences(of: "&", with: "&")
|
||||
escapedString = replacingOccurrences(of: "<", with: "<")
|
||||
escapedString = replacingOccurrences(of: ">", with: ">")
|
||||
return escapedString
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
internal extension Dictionary where Key: StringLiteralConvertible, Value: AnyObject {
|
||||
|
||||
var requestStringFromParameters: String {
|
||||
var requestString = ""
|
||||
for key in self.keys {
|
||||
if let value = self[key] as? String, let encodedValue = value.addingPercentEncoding(withAllowedCharacters: CharacterSet.urlHostAllowed) {
|
||||
requestString += "&\(key)=\(encodedValue)"
|
||||
} else if let value = self[key] as? Int {
|
||||
requestString += "&\(key)=\(value)"
|
||||
}
|
||||
}
|
||||
|
||||
return requestString
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+53
-14
@@ -22,7 +22,7 @@
|
||||
// THE SOFTWARE.
|
||||
|
||||
public struct File {
|
||||
|
||||
|
||||
public let id: String?
|
||||
public let created: Int?
|
||||
public let name: String?
|
||||
@@ -36,8 +36,6 @@ public struct File {
|
||||
public let isExternal: Bool?
|
||||
public let externalType: String?
|
||||
public let size: Int?
|
||||
public let url: String?
|
||||
public let urlDownload: String?
|
||||
public let urlPrivate: String?
|
||||
public let urlPrivateDownload: String?
|
||||
public let thumb64: String?
|
||||
@@ -46,6 +44,22 @@ public struct File {
|
||||
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?
|
||||
@@ -62,9 +76,9 @@ public struct File {
|
||||
internal(set) public var isStarred: Bool?
|
||||
internal(set) public var pinnedTo: [String]?
|
||||
internal(set) public var comments = [String: Comment]()
|
||||
internal(set) public var reactions = [String: Reaction]()
|
||||
internal(set) public var reactions = [Reaction]()
|
||||
|
||||
init?(file:[String: AnyObject]?) {
|
||||
public init(file:[String: AnyObject]?) {
|
||||
id = file?["id"] as? String
|
||||
created = file?["created"] as? Int
|
||||
name = file?["name"] as? String
|
||||
@@ -78,8 +92,6 @@ public struct File {
|
||||
isExternal = file?["is_external"] as? Bool
|
||||
externalType = file?["external_type"] as? String
|
||||
size = file?["size"] as? Int
|
||||
url = file?["url"] as? String
|
||||
urlDownload = file?["url_download"] as? String
|
||||
urlPrivate = file?["url_private"] as? String
|
||||
urlPrivateDownload = file?["url_private_download"] as? String
|
||||
thumb64 = file?["thumb_64"] as? String
|
||||
@@ -88,6 +100,22 @@ public struct File {
|
||||
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
|
||||
@@ -103,13 +131,10 @@ public struct File {
|
||||
stars = file?["num_stars"] as? Int
|
||||
isStarred = file?["is_starred"] as? Bool
|
||||
pinnedTo = file?["pinned_to"] as? [String]
|
||||
if let reactions = file?["reactions"] as? [[String: AnyObject]] {
|
||||
self.reactions = Reaction.reactionsFromArray(reactions)
|
||||
}
|
||||
|
||||
reactions = Reaction.reactionsFromArray(file?["reactions"] as? [[String: AnyObject]])
|
||||
}
|
||||
|
||||
init?(id:String?) {
|
||||
internal init(id:String?) {
|
||||
self.id = id
|
||||
created = nil
|
||||
name = nil
|
||||
@@ -122,8 +147,6 @@ public struct File {
|
||||
isExternal = nil
|
||||
externalType = nil
|
||||
size = nil
|
||||
url = nil
|
||||
urlDownload = nil
|
||||
urlPrivate = nil
|
||||
urlPrivateDownload = nil
|
||||
thumb64 = nil
|
||||
@@ -132,6 +155,22 @@ public struct File {
|
||||
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
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
//
|
||||
// History.swift
|
||||
//
|
||||
// Copyright © 2016 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 {
|
||||
|
||||
internal(set) public var latest: Date?
|
||||
internal(set) public var messages = [Message]()
|
||||
public let hasMore: Bool?
|
||||
|
||||
internal init(history: [String: AnyObject]?) {
|
||||
if let latestStr = history?["latest"] as? String, let latestDouble = Double(latestStr) {
|
||||
latest = Date(timeIntervalSince1970: TimeInterval(latestDouble))
|
||||
}
|
||||
if let msgs = history?["messages"] as? [[String: AnyObject]] {
|
||||
for message in msgs {
|
||||
messages.append(Message(message: message))
|
||||
}
|
||||
}
|
||||
hasMore = history?["has_more"] as? Bool
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
//
|
||||
// IncomingWebhook.swift
|
||||
//
|
||||
// Copyright © 2016 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 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: AnyObject]?) {
|
||||
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
|
||||
}
|
||||
|
||||
public init(url: String, channel: String? = nil, username: String? = nil, iconEmoji: String? = nil, iconURL: String? = nil) {
|
||||
self.url = url
|
||||
self.channel = channel
|
||||
self.username = username
|
||||
self.iconEmoji = iconEmoji
|
||||
self.iconURL = iconURL
|
||||
self.configurationURL = nil
|
||||
}
|
||||
|
||||
public func postMessage(_ response: Response, success: ((Bool)->Void)? = nil, failure: ((SlackError)->Void)? = nil) {
|
||||
if let url = self.url, let data = try? JSONSerialization.data(withJSONObject: jsonBody(response.json()), options: []) {
|
||||
NetworkInterface().customRequest(url, data: data, success: { _ in
|
||||
success?(true)
|
||||
}, errorClosure: {(error) in
|
||||
failure?(error)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
private func jsonBody(_ response: [String: AnyObject]) -> [String: AnyObject] {
|
||||
var json = response
|
||||
json["channel"] = channel
|
||||
json["username"] = username
|
||||
json["icon_emoji"] = iconEmoji
|
||||
json["icon_url"] = iconURL
|
||||
return json
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
//
|
||||
// Item.swift
|
||||
//
|
||||
// Copyright © 2016 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 {
|
||||
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?
|
||||
|
||||
internal init(item:[String: AnyObject]?) {
|
||||
type = item?["type"] as? String
|
||||
ts = item?["ts"] as? String
|
||||
channel = item?["channel"] as? String
|
||||
|
||||
message = Message(message: item?["message"] as? [String: AnyObject])
|
||||
|
||||
// Comment and File can come across as Strings or Dictionaries
|
||||
if let commentDictionary = item?["comment"] as? [String: AnyObject] {
|
||||
comment = Comment(comment: commentDictionary)
|
||||
} else {
|
||||
comment = Comment(id: item?["comment"] as? String)
|
||||
}
|
||||
|
||||
if let fileDictionary = item?["file"] as? [String: AnyObject] {
|
||||
file = File(file: fileDictionary)
|
||||
} else {
|
||||
file = File(id: item?["file"] as? String)
|
||||
}
|
||||
|
||||
fileCommentID = item?["file_comment"] as? String
|
||||
}
|
||||
}
|
||||
|
||||
extension Item: Equatable {}
|
||||
|
||||
public 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
|
||||
}
|
||||
@@ -21,14 +21,7 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
public enum ItemType: String {
|
||||
case ChannelMessage = "C"
|
||||
case PrivateGroupMessage = "G"
|
||||
case File = "F"
|
||||
case FileComments = "Fc"
|
||||
}
|
||||
|
||||
public class Message {
|
||||
public final class Message {
|
||||
|
||||
public let type = "message"
|
||||
public let subtype: String?
|
||||
@@ -52,9 +45,13 @@ public class Message {
|
||||
internal(set) var pinnedTo: [String]?
|
||||
public let comment: Comment?
|
||||
public let file: File?
|
||||
internal(set) public var reactions = [String: Reaction]()
|
||||
internal(set) public var reactions = [Reaction]()
|
||||
internal(set) public var attachments: [Attachment]?
|
||||
internal(set) public var responseType: ResponseType?
|
||||
internal(set) public var replaceOriginal: Bool?
|
||||
internal(set) public var deleteOriginal: Bool?
|
||||
|
||||
init?(message: [String: AnyObject]?) {
|
||||
public init(message: [String: AnyObject]?) {
|
||||
subtype = message?["subtype"] as? String
|
||||
ts = message?["ts"] as? String
|
||||
user = message?["user"] as? String
|
||||
@@ -76,13 +73,28 @@ public class Message {
|
||||
pinnedTo = message?["pinned_to"] as? [String]
|
||||
comment = Comment(comment: message?["comment"] as? [String: AnyObject])
|
||||
file = File(file: message?["file"] as? [String: AnyObject])
|
||||
if let messageReactions = message?["reactions"] as? [[String: AnyObject]] {
|
||||
for react in messageReactions {
|
||||
let reaction = Reaction(reaction: react)
|
||||
self.reactions[reaction!.name!] = reaction
|
||||
}
|
||||
}
|
||||
reactions = Reaction.reactionsFromArray(message?["reactions"] as? [[String: AnyObject]])
|
||||
attachments = (message?["attachments"] as? [[String: AnyObject]])?.map{Attachment(attachment: $0)}
|
||||
responseType = ResponseType(rawValue: message?["response_type"] as? String ?? "")
|
||||
replaceOriginal = message?["replace_original"] as? Bool
|
||||
deleteOriginal = message?["delete_original"] as? Bool
|
||||
}
|
||||
|
||||
internal 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
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
extension Message: Equatable {}
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
//
|
||||
// MessageActionRequest.swift
|
||||
//
|
||||
// Copyright © 2016 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.
|
||||
|
||||
internal struct MessageActionRequest: Request {
|
||||
|
||||
let action: Action?
|
||||
let callbackID: String?
|
||||
let team: Team?
|
||||
let channel: Channel?
|
||||
let user: User?
|
||||
let actionTS: String?
|
||||
let messageTS: String?
|
||||
let attachmentID: String?
|
||||
let token: String?
|
||||
let originalMessage: Message?
|
||||
let responseURL: String
|
||||
|
||||
init(response: [String: AnyObject]?) {
|
||||
action = (response?["actions"] as? [[String:AnyObject]])?.map({Action(action: $0)}).first
|
||||
callbackID = response?["callback_id"] as? String
|
||||
team = Team(team: response?["team"] as? [String: AnyObject])
|
||||
channel = Channel(channel: response?["channel"] as? [String: AnyObject])
|
||||
user = User(user: response?["channel"] as? [String: AnyObject])
|
||||
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(message: response?["original_message"] as? [String: AnyObject])
|
||||
responseURL = response?["response_url"] as? String ?? ""
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
//
|
||||
// MessageActionResponder.swift
|
||||
//
|
||||
// Copyright © 2016 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 MessageActionResponder {
|
||||
|
||||
public var responses:[(Action, Response)]
|
||||
|
||||
public init(responses:[(Action, Response)]) {
|
||||
self.responses = responses
|
||||
}
|
||||
|
||||
internal func responseForRequest(_ request:MessageActionRequest) -> Reply? {
|
||||
if let response = responses.filter({$0.0.name == request.action?.name}).first?.1 {
|
||||
return Reply.json(response: response)
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
//
|
||||
// MessageActionServer.swift
|
||||
//
|
||||
// Copyright © 2016 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 class MessageActionServer: Server {
|
||||
|
||||
internal let responder: MessageActionResponder
|
||||
|
||||
required public init(token: String, route: String, responder: MessageActionResponder) {
|
||||
self.responder = responder
|
||||
super.init(token: token)
|
||||
addRoute(route)
|
||||
}
|
||||
|
||||
internal func addRoute(_ route: String) {
|
||||
http.POST["/\(route)"] = { request in
|
||||
let payload = request.parseUrlencodedForm()
|
||||
let actionRequest = MessageActionRequest(response: self.jsonFromRequest(payload[0].1))
|
||||
if let reply = self.responder.responseForRequest(actionRequest), actionRequest.token == self.token {
|
||||
return self.request(actionRequest, reply: reply)
|
||||
} else {
|
||||
return .badRequest(.text("Bad request."))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,153 @@
|
||||
//
|
||||
// NetworkInterface.swift
|
||||
//
|
||||
// Copyright © 2016 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
|
||||
|
||||
internal struct NetworkInterface {
|
||||
|
||||
private let apiUrl = "https://slack.com/api/"
|
||||
|
||||
internal func request(_ endpoint: Endpoint, token: String? = nil, parameters: [String: AnyObject]?, successClosure: ([String: AnyObject])->Void, errorClosure: (SlackError)->Void) {
|
||||
var requestString = "\(apiUrl)\(endpoint.rawValue)?"
|
||||
if let token = token {
|
||||
requestString += "token=\(token)"
|
||||
}
|
||||
if let params = parameters {
|
||||
requestString += params.requestStringFromParameters
|
||||
}
|
||||
guard let url = URL(string: requestString) else {
|
||||
errorClosure(SlackError.ClientNetworkError)
|
||||
return
|
||||
}
|
||||
let request = URLRequest(url:url)
|
||||
URLSession.shared.dataTask(with: request) {
|
||||
(data, response, internalError) -> Void in
|
||||
self.handleResponse(data, response: response, internalError: internalError, successClosure: {(json) in
|
||||
successClosure(json)
|
||||
}, errorClosure: {(error) in
|
||||
errorClosure(error)
|
||||
})
|
||||
}.resume()
|
||||
}
|
||||
|
||||
internal func customRequest(_ url: String, data: Data, success: (Bool)->Void, errorClosure: (SlackError)->Void) {
|
||||
guard let url = URL(string: url.removePercentEncoding()) 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
|
||||
|
||||
URLSession.shared.dataTask(with: request) {
|
||||
(data, response, internalError) -> Void in
|
||||
if internalError == nil {
|
||||
success(true)
|
||||
} else {
|
||||
errorClosure(SlackError.ClientNetworkError)
|
||||
}
|
||||
}.resume()
|
||||
}
|
||||
|
||||
internal func uploadRequest(_ token: String, data: Data, parameters: [String: AnyObject]?, successClosure: ([String: AnyObject])->Void, errorClosure: (SlackError)->Void) {
|
||||
var requestString = "\(apiUrl)\(Endpoint.FilesUpload.rawValue)?token=\(token)"
|
||||
if let params = parameters {
|
||||
requestString = requestString + params.requestStringFromParameters
|
||||
}
|
||||
guard let url = URL(string: requestString) else {
|
||||
errorClosure(SlackError.ClientNetworkError)
|
||||
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"
|
||||
|
||||
var requestBodyData: Data = Data()
|
||||
requestBodyData.append(boundaryStart.data(using: String.Encoding.utf8)!)
|
||||
requestBodyData.append(contentDispositionString.data(using: String.Encoding.utf8)!)
|
||||
requestBodyData.append(contentTypeString.data(using: String.Encoding.utf8)!)
|
||||
requestBodyData.append(data)
|
||||
requestBodyData.append("\r\n".data(using: String.Encoding.utf8)!)
|
||||
requestBodyData.append(boundaryEnd.data(using: String.Encoding.utf8)!)
|
||||
|
||||
request.setValue(contentType, forHTTPHeaderField: "Content-Type")
|
||||
request.httpBody = requestBodyData as Data
|
||||
|
||||
URLSession.shared.dataTask(with: request) {
|
||||
(data, response, internalError) -> Void in
|
||||
self.handleResponse(data, response: response, internalError: internalError, successClosure: {(json) in
|
||||
successClosure(json)
|
||||
}, errorClosure: {(error) in
|
||||
errorClosure(error)
|
||||
})
|
||||
}.resume()
|
||||
}
|
||||
|
||||
private func handleResponse(_ data: Data?, response:URLResponse?, internalError:NSError?, successClosure: ([String: AnyObject])->Void, errorClosure: (SlackError)->Void) {
|
||||
guard let data = data, let response = response as? HTTPURLResponse else {
|
||||
errorClosure(SlackError.ClientNetworkError)
|
||||
return
|
||||
}
|
||||
do {
|
||||
guard let json = try JSONSerialization.jsonObject(with: data, options: []) as? [String: AnyObject] else {
|
||||
errorClosure(SlackError.ClientJSONError)
|
||||
return
|
||||
}
|
||||
|
||||
switch response.statusCode {
|
||||
case 200:
|
||||
if (json["ok"] as! Bool == true) {
|
||||
successClosure(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 {
|
||||
errorClosure(slackError)
|
||||
} else {
|
||||
errorClosure(SlackError.UnknownError)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func randomBoundary() -> String {
|
||||
return String(format: "slackkit.boundary.%08x%08x", arc4random(), arc4random())
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
//
|
||||
// OAuthResponse.swift
|
||||
//
|
||||
// Copyright © 2016 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.
|
||||
|
||||
internal struct OAuthResponse {
|
||||
|
||||
let accessToken: String?
|
||||
let scope: [Scope]?
|
||||
let userID: String?
|
||||
let teamName: String?
|
||||
let teamID: String?
|
||||
let incomingWebhook: IncomingWebhook?
|
||||
let bot: Bot?
|
||||
|
||||
init(response: [String: AnyObject]?) {
|
||||
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: AnyObject])
|
||||
bot = Bot(botUser: response?["bot"] as? [String: AnyObject])
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
//
|
||||
// OAuthServer.swift
|
||||
//
|
||||
// Copyright © 2016 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 Swifter
|
||||
|
||||
internal protocol OAuthDelegate {
|
||||
func userAuthed(_ response: OAuthResponse)
|
||||
}
|
||||
|
||||
public struct OAuthServer {
|
||||
|
||||
private let oauthURL = "https://slack.com/oauth/authorize"
|
||||
|
||||
private let http = HttpServer()
|
||||
private let clientID: String
|
||||
private let clientSecret: String
|
||||
private let state: String?
|
||||
private let redirectURI: String?
|
||||
private var delegate: OAuthDelegate?
|
||||
|
||||
internal init(clientID: String, clientSecret: String, state: String? = nil, redirectURI: String? = nil, port:in_port_t = 8080, forceIPV4: Bool = false, delegate: OAuthDelegate? = nil) throws {
|
||||
self.clientID = clientID
|
||||
self.clientSecret = clientSecret
|
||||
self.state = state ?? "state"
|
||||
self.redirectURI = redirectURI
|
||||
self.delegate = delegate
|
||||
oauthRoute()
|
||||
start(port, forceIPV4: forceIPV4)
|
||||
}
|
||||
|
||||
public func start(_ port: in_port_t = 8080, forceIPV4: Bool = false) {
|
||||
do {
|
||||
try http.start(port, forceIPv4: forceIPV4)
|
||||
} catch let error as NSError {
|
||||
print("Server failed to start with error: \(error)")
|
||||
}
|
||||
}
|
||||
|
||||
public func stop() {
|
||||
http.stop()
|
||||
}
|
||||
|
||||
private func oauthRoute() {
|
||||
http["/oauth"] = { request in
|
||||
guard let response = AuthorizeResponse(queryParameters: request.queryParams), response.state == self.state else {
|
||||
return .badRequest(.text("Bad request."))
|
||||
}
|
||||
WebAPI.oauthAccess(self.clientID, clientSecret: self.clientSecret, code: response.code, redirectURI: self.redirectURI, success: {(response) in
|
||||
self.delegate?.userAuthed(OAuthResponse(response: response))
|
||||
}, failure: {(error) in
|
||||
print("Authorization failed")
|
||||
})
|
||||
if let redirect = self.redirectURI {
|
||||
return .movedPermanently(redirect)
|
||||
}
|
||||
return .ok(.text("Authentication successful."))
|
||||
}
|
||||
}
|
||||
|
||||
private func oauthURLRequest(_ authorize: AuthorizeRequest) -> URLRequest? {
|
||||
var requestString = "\(oauthURL)?client_id=\(authorize.clientID)"
|
||||
requestString += authorize.parameters.requestStringFromParameters
|
||||
guard let url = URL(string: requestString) else {
|
||||
return nil
|
||||
}
|
||||
return URLRequest(url:url)
|
||||
}
|
||||
|
||||
public func authorizeRequest(_ scope:[Scope], redirectURI: String, state: String = "slackkit", team: String? = nil) -> URLRequest? {
|
||||
let request = AuthorizeRequest(clientID: clientID, scope: scope, redirectURI: redirectURI, state: state, team: team)
|
||||
return oauthURLRequest(request)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
//
|
||||
// Reaction.swift
|
||||
//
|
||||
// Copyright © 2016 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 {
|
||||
public let name: String?
|
||||
internal(set) public var user: String?
|
||||
|
||||
internal init(reaction:[String: AnyObject]?) {
|
||||
name = reaction?["name"] as? String
|
||||
}
|
||||
|
||||
internal init(name: String, user: String) {
|
||||
self.name = name
|
||||
self.user = user
|
||||
}
|
||||
|
||||
static func reactionsFromArray(_ array: [[String: AnyObject]]?) -> [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
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
extension Reaction: Equatable {}
|
||||
|
||||
public func ==(lhs: Reaction, rhs: Reaction) -> Bool {
|
||||
return lhs.name == rhs.name
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
//
|
||||
// Response.swift
|
||||
//
|
||||
// Copyright © 2016 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 Response {
|
||||
|
||||
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 func json() -> [String: AnyObject] {
|
||||
var json = [String : AnyObject]()
|
||||
json["text"] = text
|
||||
json["response_type"] = responseType?.rawValue
|
||||
json["attachments"] = attachments?.flatMap({$0.dictionary()})
|
||||
return json
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
//
|
||||
// Scope.swift
|
||||
//
|
||||
// Copyright © 2016 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"
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
//
|
||||
// Server.swift
|
||||
//
|
||||
// Copyright © 2016 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 Swifter
|
||||
|
||||
internal enum Reply {
|
||||
case json(response: Response)
|
||||
case text(body: String)
|
||||
case badRequest
|
||||
}
|
||||
|
||||
internal protocol Request {
|
||||
var responseURL: String { get }
|
||||
}
|
||||
|
||||
public class Server {
|
||||
|
||||
internal let http = HttpServer()
|
||||
internal let token: String
|
||||
|
||||
internal init(token: String) {
|
||||
self.token = token
|
||||
}
|
||||
|
||||
public func start(_ port: in_port_t = 8080, forceIPV4: Bool = false) {
|
||||
do {
|
||||
try http.start(port, forceIPv4: forceIPV4)
|
||||
} catch let error as NSError {
|
||||
print("Server failed to start with error: \(error)")
|
||||
}
|
||||
}
|
||||
|
||||
public func stop() {
|
||||
http.stop()
|
||||
}
|
||||
|
||||
internal func request(_ request:Request, reply: Reply) -> HttpResponse {
|
||||
switch reply {
|
||||
case .text(let body):
|
||||
return .ok(.text(body))
|
||||
case .json(let response):
|
||||
return .ok(.json(response.json()))
|
||||
case .badRequest:
|
||||
return .badRequest(.text("Bad request."))
|
||||
}
|
||||
}
|
||||
|
||||
internal func dictionaryFromRequest(_ body: [UInt8]) -> [String: AnyObject]? {
|
||||
let string = String(data: Data(bytes: UnsafePointer<UInt8>(body), count: body.count), encoding: String.Encoding.utf8)
|
||||
if let body = string?.components(separatedBy: "&") {
|
||||
var dict: [String: AnyObject] = [:]
|
||||
for argument in body {
|
||||
let kv = argument.components(separatedBy: "=")
|
||||
if let key = kv.first, let value = kv.last {
|
||||
dict[key] = value
|
||||
}
|
||||
}
|
||||
return dict
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
internal func jsonFromRequest(_ string: String) -> [String: AnyObject]? {
|
||||
guard let data = string.data(using: String.Encoding.utf8) else {
|
||||
return nil
|
||||
}
|
||||
return (try? JSONSerialization.jsonObject(with: data, options: [])) as? [String: AnyObject] ?? nil
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
//
|
||||
// SlackError.swift
|
||||
//
|
||||
// Copyright © 2016 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, ErrorProtocol {
|
||||
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 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
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
//
|
||||
// SlackKit.swift
|
||||
//
|
||||
// Copyright © 2016 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 final class SlackKit: OAuthDelegate {
|
||||
|
||||
internal(set) public var oauth: OAuthServer?
|
||||
internal(set) public var clients: [String: Client] = [:]
|
||||
private let clientOptions: ClientOptions
|
||||
// Initalization block
|
||||
public var onClientInitalization: ((Client) -> Void)?
|
||||
|
||||
// If you already have an API token
|
||||
public init(withAPIToken token: String, clientOptions: ClientOptions = ClientOptions()) {
|
||||
self.clientOptions = clientOptions
|
||||
let client = Client(apiToken: token)
|
||||
self.onClientInitalization?(client)
|
||||
clients[token] = client
|
||||
client.connect(options: self.clientOptions)
|
||||
}
|
||||
|
||||
// If you're going to be receiving and/or initiating OAuth requests, provide a client ID and secret
|
||||
public init(clientID: String, clientSecret: String, state: String? = nil, redirectURI: String? = nil, port:in_port_t = 8080, forceIPV4: Bool = false, clientOptions: ClientOptions = ClientOptions()) {
|
||||
self.clientOptions = clientOptions
|
||||
oauth = try? OAuthServer(clientID: clientID, clientSecret: clientSecret, state: state, redirectURI: redirectURI, port: port, forceIPV4: forceIPV4, delegate: self)
|
||||
}
|
||||
|
||||
internal func userAuthed(_ response: OAuthResponse) {
|
||||
// User auth
|
||||
if let token = response.accessToken {
|
||||
let client = Client(apiToken: token)
|
||||
self.onClientInitalization?(client)
|
||||
clients[token] = client
|
||||
}
|
||||
// Bot User
|
||||
if let token = response.bot?.botToken {
|
||||
let client = Client(apiToken: token)
|
||||
self.onClientInitalization?(client)
|
||||
clients[token] = client
|
||||
client.connect(options: self.clientOptions)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -23,23 +23,25 @@
|
||||
|
||||
public struct Team {
|
||||
|
||||
public let id: String
|
||||
public let id: String?
|
||||
internal(set) public var name: String?
|
||||
internal(set) public var emailDomain: String?
|
||||
internal(set) public var domain: String?
|
||||
internal(set) public var emailDomain: String?
|
||||
internal(set) public var messageEditWindowMinutes: Int?
|
||||
internal(set) public var overStorageLimit: Bool?
|
||||
internal(set) public var prefs: [String: AnyObject]?
|
||||
internal(set) public var plan: String?
|
||||
internal(set) public var icon: TeamIcon?
|
||||
|
||||
internal init?(team: [String: AnyObject]?) {
|
||||
id = team?["id"] as! String
|
||||
name = team?["id"] as? String
|
||||
emailDomain = team?["email_domain"] as? String
|
||||
internal init(team: [String: AnyObject]?) {
|
||||
id = team?["id"] as? String
|
||||
name = team?["name"] as? String
|
||||
domain = team?["domain"] as? String
|
||||
messageEditWindowMinutes = team?["mesg_edit_window_mins"] as? Int
|
||||
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: AnyObject]
|
||||
plan = team?["plan"] as? String
|
||||
icon = TeamIcon(icon: team?["icon"] as? [String: AnyObject])
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
//
|
||||
// TeamIcon.swift
|
||||
//
|
||||
// Copyright © 2016 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 {
|
||||
internal(set) public var image34: String?
|
||||
internal(set) public var image44: String?
|
||||
internal(set) public var image68: String?
|
||||
internal(set) public var image88: String?
|
||||
internal(set) public var image102: String?
|
||||
internal(set) public var image132: String?
|
||||
internal(set) public var imageOriginal: String?
|
||||
internal(set) public var imageDefault: Bool?
|
||||
|
||||
internal init(icon: [String: AnyObject]?) {
|
||||
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
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
//
|
||||
// Topic.swift
|
||||
//
|
||||
// Copyright © 2016 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?
|
||||
|
||||
internal init(topic: [String: AnyObject]?) {
|
||||
value = topic?["value"] as? String
|
||||
creator = topic?["creator"] as? String
|
||||
lastSet = topic?["last_set"] as? Int
|
||||
}
|
||||
}
|
||||
@@ -1,177 +0,0 @@
|
||||
//
|
||||
// Types.swift
|
||||
//
|
||||
// Copyright © 2016 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.
|
||||
|
||||
// MARK: - Edited
|
||||
public struct Edited {
|
||||
public let user: String?
|
||||
public let ts: String?
|
||||
|
||||
internal init?(edited:[String: AnyObject]?) {
|
||||
user = edited?["user"] as? String
|
||||
ts = edited?["ts"] as? String
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Reaction
|
||||
public struct Reaction {
|
||||
public let name: String?
|
||||
internal(set) public var users = [String: String]()
|
||||
|
||||
internal init?(reaction:[String: AnyObject]?) {
|
||||
name = reaction?["name"] as? String
|
||||
}
|
||||
|
||||
internal init?(name: String?, user: String) {
|
||||
self.name = name
|
||||
users[user] = user
|
||||
}
|
||||
|
||||
internal init?(name: String?, users: [String: String]) {
|
||||
self.name = name
|
||||
self.users = users
|
||||
}
|
||||
|
||||
static func reactionsFromArray(array: [[String: AnyObject]]) -> [String: Reaction] {
|
||||
var reactions = [String: Reaction]()
|
||||
var userDictionary = [String: String]()
|
||||
for reaction in array {
|
||||
if let users = reaction["users"] as? [String] {
|
||||
for user in users {
|
||||
userDictionary[user] = user
|
||||
}
|
||||
}
|
||||
if let name = reaction["name"] as? String {
|
||||
reactions[name] = Reaction(name: name, users: userDictionary)
|
||||
}
|
||||
}
|
||||
return reactions
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
extension Reaction: Equatable {}
|
||||
|
||||
public func ==(lhs: Reaction, rhs: Reaction) -> Bool {
|
||||
return lhs.name == rhs.name
|
||||
}
|
||||
|
||||
// MARK: - Comment
|
||||
public struct Comment {
|
||||
public let id: String?
|
||||
public let user: String?
|
||||
internal(set) public var created: Int?
|
||||
internal(set) public var comment: String?
|
||||
internal(set) public var starred: Bool?
|
||||
internal(set) public var stars: Int?
|
||||
internal(set) public var reactions = [String: Reaction]()
|
||||
|
||||
internal init?(comment:[String: AnyObject]?) {
|
||||
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
|
||||
}
|
||||
|
||||
internal init?(id: String?) {
|
||||
self.id = id
|
||||
self.user = nil
|
||||
}
|
||||
}
|
||||
|
||||
extension Comment: Equatable {}
|
||||
|
||||
public func ==(lhs: Comment, rhs: Comment) -> Bool {
|
||||
return lhs.id == rhs.id
|
||||
}
|
||||
|
||||
// MARK: - Item
|
||||
public struct Item {
|
||||
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?
|
||||
|
||||
internal init?(item:[String: AnyObject]?) {
|
||||
type = item?["type"] as? String
|
||||
ts = item?["ts"] as? String
|
||||
channel = item?["channel"] as? String
|
||||
|
||||
message = Message(message: item?["message"] as? [String: AnyObject])
|
||||
|
||||
// Comment and File can come across as Strings or Dictionaries
|
||||
if (Comment(comment: item?["comment"] as? [String: AnyObject])?.id == nil) {
|
||||
comment = Comment(id: item?["comment"] as? String)
|
||||
} else {
|
||||
comment = Comment(comment: item?["comment"] as? [String: AnyObject])
|
||||
}
|
||||
if (File(file: item?["file"] as? [String: AnyObject])?.id == nil) {
|
||||
file = File(id: item?["file"] as? String)
|
||||
} else {
|
||||
file = File(file: item?["file"] as? [String: AnyObject])
|
||||
}
|
||||
|
||||
fileCommentID = item?["file_comment"] as? String
|
||||
}
|
||||
}
|
||||
|
||||
extension Item: Equatable {}
|
||||
|
||||
public 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
|
||||
}
|
||||
|
||||
// MARK: - Topic
|
||||
public struct Topic {
|
||||
public let value: String?
|
||||
public let creator: String?
|
||||
public let lastSet: Int?
|
||||
|
||||
internal init?(topic: [String: AnyObject]?) {
|
||||
value = topic?["value"] as? String
|
||||
creator = topic?["creator"] as? String
|
||||
lastSet = topic?["last_set"] as? Int
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Do Not Disturb Status
|
||||
public struct DoNotDisturbStatus {
|
||||
internal(set) public var enabled: Bool?
|
||||
internal(set) public var nextDoNotDisturbStart: Int?
|
||||
internal(set) public var nextDoNotDisturbEnd: Int?
|
||||
internal(set) public var snoozeEnabled: Bool?
|
||||
internal(set) public var snoozeEndtime: Int?
|
||||
|
||||
internal init?(status: [String: AnyObject]?) {
|
||||
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
|
||||
}
|
||||
|
||||
}
|
||||
@@ -35,8 +35,9 @@ public struct User {
|
||||
internal(set) public var image48: String?
|
||||
internal(set) public var image72: String?
|
||||
internal(set) public var image192: String?
|
||||
internal(set) public var customProfile: CustomProfile?
|
||||
|
||||
internal init?(profile: [String: AnyObject]?) {
|
||||
internal init(profile: [String: AnyObject]?) {
|
||||
firstName = profile?["first_name"] as? String
|
||||
lastName = profile?["last_name"] as? String
|
||||
realName = profile?["real_name"] as? String
|
||||
@@ -48,9 +49,11 @@ public struct User {
|
||||
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: AnyObject])
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public let id: String?
|
||||
internal(set) public var name: String?
|
||||
internal(set) public var deleted: Bool?
|
||||
@@ -71,10 +74,10 @@ public struct User {
|
||||
internal(set) public var timeZoneLabel: String?
|
||||
internal(set) public var timeZoneOffSet: Int?
|
||||
internal(set) public var preferences: [String: AnyObject]?
|
||||
// Client use
|
||||
// Client properties
|
||||
internal(set) public var userGroups: [String: String]?
|
||||
|
||||
internal init?(user: [String: AnyObject]?) {
|
||||
internal init(user: [String: AnyObject]?) {
|
||||
id = user?["id"] as? String
|
||||
name = user?["name"] as? String
|
||||
deleted = user?["deleted"] as? Bool
|
||||
@@ -96,8 +99,8 @@ public struct User {
|
||||
preferences = user?["prefs"] as? [String: AnyObject]
|
||||
}
|
||||
|
||||
internal init?(id: String?) {
|
||||
internal init(id: String?) {
|
||||
self.id = id
|
||||
self.isBot = nil
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -21,11 +21,9 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
|
||||
public struct UserGroup {
|
||||
|
||||
public let id: String?
|
||||
|
||||
internal(set) public var teamID: String?
|
||||
public let isUserGroup: Bool?
|
||||
internal(set) public var name: String?
|
||||
@@ -43,7 +41,7 @@ public struct UserGroup {
|
||||
internal(set) public var users: [String]?
|
||||
internal(set) public var userCount: Int?
|
||||
|
||||
internal init?(userGroup: [String: AnyObject]?) {
|
||||
internal init(userGroup: [String: AnyObject]?) {
|
||||
id = userGroup?["id"] as? String
|
||||
teamID = userGroup?["team_id"] as? String
|
||||
isUserGroup = userGroup?["is_usergroup"] as? Bool
|
||||
|
||||
@@ -0,0 +1,769 @@
|
||||
//
|
||||
// WebAPI.swift
|
||||
//
|
||||
// Copyright © 2016 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
|
||||
|
||||
internal enum Endpoint: String {
|
||||
case APITest = "api.test"
|
||||
case AuthRevoke = "auth.revoke"
|
||||
case AuthTest = "auth.test"
|
||||
case ChannelsHistory = "channels.history"
|
||||
case ChannelsInfo = "channels.info"
|
||||
case ChannelsList = "channels.list"
|
||||
case ChannelsMark = "channels.mark"
|
||||
case ChannelsSetPurpose = "channels.setPurpose"
|
||||
case ChannelsSetTopic = "channels.setTopic"
|
||||
case ChatDelete = "chat.delete"
|
||||
case ChatPostMessage = "chat.postMessage"
|
||||
case 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 func rtmStart(_ simpleLatest: Bool? = nil, noUnreads: Bool? = nil, mpimAware: Bool? = nil, success: ((response: [String: AnyObject])->Void)?, failure: FailureClosure?) {
|
||||
let parameters: [String: AnyObject?] = ["simple_latest": simpleLatest, "no_unreads": noUnreads, "mpim_aware": mpimAware]
|
||||
networkInterface.request(.RTMStart, token: token, parameters: WebAPI.filterNilParameters(parameters), successClosure: {
|
||||
(response) -> Void in
|
||||
success?(response: response)
|
||||
}) {(error) -> Void in
|
||||
failure?(error: error)
|
||||
}
|
||||
}
|
||||
|
||||
//MARK: - Auth
|
||||
public func authenticationTest(_ success: ((authenticated: Bool)->Void)?, failure: FailureClosure?) {
|
||||
networkInterface.request(.AuthTest, token: token, parameters: nil, successClosure: {
|
||||
(response) -> Void in
|
||||
success?(authenticated: true)
|
||||
}) {(error) -> Void in
|
||||
failure?(error: error)
|
||||
}
|
||||
}
|
||||
|
||||
public static func oauthAccess(_ clientID: String, clientSecret: String, code: String, redirectURI: String? = nil, success: ((response: [String: AnyObject])->Void)?, failure: ((SlackError)->Void)?) {
|
||||
let parameters: [String: AnyObject?] = ["client_id": clientID, "client_secret": clientSecret, "code": code, "redirect_uri": redirectURI]
|
||||
NetworkInterface().request(.OAuthAccess, parameters: filterNilParameters(parameters), successClosure: {
|
||||
(response) -> Void in
|
||||
success?(response:response)
|
||||
}) {(error) -> Void in
|
||||
failure?(error)
|
||||
}
|
||||
}
|
||||
|
||||
public static func oauthRevoke(_ token: String, test: Bool? = nil, success: ((revoked:Bool)->Void)?, failure: ((SlackError)->Void)?) {
|
||||
let parameters: [String: AnyObject?] = ["token": token, "test": test]
|
||||
NetworkInterface().request(.AuthRevoke, parameters: filterNilParameters(parameters), successClosure: {
|
||||
(response) -> Void in
|
||||
success?(revoked:true)
|
||||
}) {(error) -> Void 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) -> Void in
|
||||
success?(history: history)
|
||||
}) {(error) -> Void in
|
||||
failure?(error: error)
|
||||
}
|
||||
}
|
||||
|
||||
public func channelInfo(_ id: String, success: ((channel: Channel)->Void)?, failure: FailureClosure?) {
|
||||
info(.ChannelsInfo, type:ChannelType.Channel, id: id, success: {
|
||||
(channel) -> Void in
|
||||
success?(channel: channel)
|
||||
}) { (error) -> Void in
|
||||
failure?(error: error)
|
||||
}
|
||||
}
|
||||
|
||||
public func channelsList(_ excludeArchived: Bool = false, success: ((channels: [[String: AnyObject]]?)->Void)?, failure: FailureClosure?) {
|
||||
list(.ChannelsList, type:ChannelType.Channel, excludeArchived: excludeArchived, success: {
|
||||
(channels) -> Void in
|
||||
success?(channels: channels)
|
||||
}) {(error) -> Void in
|
||||
failure?(error: error)
|
||||
}
|
||||
}
|
||||
|
||||
public func markChannel(_ channel: String, timestamp: String, success: ((ts: String)->Void)?, failure: FailureClosure?) {
|
||||
mark(.ChannelsMark, channel: channel, timestamp: timestamp, success: {
|
||||
(ts) -> Void in
|
||||
success?(ts:timestamp)
|
||||
}) {(error) -> Void in
|
||||
failure?(error: error)
|
||||
}
|
||||
}
|
||||
|
||||
public func setChannelPurpose(_ channel: String, purpose: String, success: ((purposeSet: Bool)->Void)?, failure: FailureClosure?) {
|
||||
setInfo(.ChannelsSetPurpose, type: .Purpose, channel: channel, text: purpose, success: {
|
||||
(purposeSet) -> Void in
|
||||
success?(purposeSet: purposeSet)
|
||||
}) { (error) -> Void in
|
||||
failure?(error: error)
|
||||
}
|
||||
}
|
||||
|
||||
public func setChannelTopic(_ channel: String, topic: String, success: ((topicSet: Bool)->Void)?, failure: FailureClosure?) {
|
||||
setInfo(.ChannelsSetTopic, type: .Topic, channel: channel, text: topic, success: {
|
||||
(topicSet) -> Void in
|
||||
success?(topicSet: topicSet)
|
||||
}) {(error) -> Void in
|
||||
failure?(error: error)
|
||||
}
|
||||
}
|
||||
|
||||
//MARK: - Messaging
|
||||
public func deleteMessage(_ channel: String, ts: String, success: ((deleted: Bool)->Void)?, failure: FailureClosure?) {
|
||||
let parameters: [String: AnyObject] = ["channel": channel, "ts": ts]
|
||||
networkInterface.request(.ChatDelete, token: token, parameters: parameters, successClosure: { (response) -> Void in
|
||||
success?(deleted: true)
|
||||
}) {(error) -> Void in
|
||||
failure?(error: 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: AnyObject?] = ["channel":channel, "text":text.slackFormatEscaping(), "as_user":asUser, "parse":parse?.rawValue, "link_names":linkNames, "unfurl_links":unfurlLinks, "unfurlMedia":unfurlMedia, "username":username, "attachments":encodeAttachments(attachments), "icon_url":iconURL, "icon_emoji":iconEmoji]
|
||||
networkInterface.request(.ChatPostMessage, token: token, parameters: WebAPI.filterNilParameters(parameters), successClosure: {
|
||||
(response) -> Void in
|
||||
success?((ts: response["ts"] as? String, response["channel"] as? String))
|
||||
}) {(error) -> Void in
|
||||
failure?(error: 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: AnyObject?] = ["channel": channel, "ts": ts, "text": message.slackFormatEscaping(), "parse": parse.rawValue, "link_names": linkNames, "attachments":encodeAttachments(attachments)]
|
||||
networkInterface.request(.ChatUpdate, token: token, parameters: WebAPI.filterNilParameters(parameters), successClosure: {
|
||||
(response) -> Void in
|
||||
success?(updated: true)
|
||||
}) {(error) -> Void in
|
||||
failure?(error: error)
|
||||
}
|
||||
}
|
||||
|
||||
//MARK: - Do Not Disturb
|
||||
public func dndInfo(_ user: String? = nil, success: ((status: DoNotDisturbStatus)->Void)?, failure: FailureClosure?) {
|
||||
let parameters: [String: AnyObject?] = ["user": user]
|
||||
networkInterface.request(.DNDInfo, token: token, parameters: WebAPI.filterNilParameters(parameters), successClosure: {
|
||||
(response) -> Void in
|
||||
success?(status: DoNotDisturbStatus(status: response))
|
||||
}) {(error) -> Void in
|
||||
failure?(error: error)
|
||||
}
|
||||
}
|
||||
|
||||
public func dndTeamInfo(_ users: [String]? = nil, success: ((statuses: [String: DoNotDisturbStatus])->Void)?, failure: FailureClosure?) {
|
||||
let parameters: [String: AnyObject?] = ["users":users?.joined(separator: ",")]
|
||||
networkInterface.request(.DNDTeamInfo, token: token, parameters: WebAPI.filterNilParameters(parameters), successClosure: {
|
||||
(response) -> Void in
|
||||
guard let usersDictionary = response["users"] as? [String: AnyObject] else {
|
||||
success?(statuses: [:])
|
||||
return
|
||||
}
|
||||
success?(statuses: self.enumerateDNDStatuses(usersDictionary))
|
||||
}) {(error) -> Void in
|
||||
failure?(error: error)
|
||||
}
|
||||
}
|
||||
|
||||
//MARK: - Emoji
|
||||
public func emojiList(_ success: ((emojiList: [String: AnyObject]?)->Void)?, failure: FailureClosure?) {
|
||||
networkInterface.request(.EmojiList, token: token, parameters: nil, successClosure: {
|
||||
(response) -> Void in
|
||||
success?(emojiList: response["emoji"] as? [String: AnyObject])
|
||||
}) { (error) -> Void in
|
||||
failure?(error: error)
|
||||
}
|
||||
}
|
||||
|
||||
//MARK: - Files
|
||||
public func deleteFile(_ fileID: String, success: ((deleted: Bool)->Void)?, failure: FailureClosure?) {
|
||||
let parameters = ["file":fileID]
|
||||
networkInterface.request(.FilesDelete, token: token, parameters: parameters, successClosure: {
|
||||
(response) -> Void in
|
||||
success?(deleted: true)
|
||||
}) {(error) -> Void in
|
||||
failure?(error: error)
|
||||
}
|
||||
}
|
||||
|
||||
public func fileInfo(_ fileID: String, commentCount: Int = 100, totalPages: Int = 1, success: ((file: File)->Void)?, failure: FailureClosure?) {
|
||||
let parameters: [String: AnyObject] = ["file":fileID, "count": commentCount, "totalPages":totalPages]
|
||||
networkInterface.request(.FilesInfo, token: token, parameters: parameters, successClosure: {
|
||||
(response) in
|
||||
var file = File(file: response["file"] as? [String: AnyObject])
|
||||
(response["comments"] as? [[String: AnyObject]])?.forEach { comment in
|
||||
let comment = Comment(comment: comment)
|
||||
if let id = comment.id {
|
||||
file.comments[id] = comment
|
||||
}
|
||||
}
|
||||
success?(file: file)
|
||||
}) {(error) in
|
||||
failure?(error: 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: AnyObject?] = ["file":file, "filename": filename, "filetype":filetype, "title":title, "initial_comment":initialComment, "channels":channels?.joined(separator: ",")]
|
||||
networkInterface.uploadRequest(token, data: file, parameters: WebAPI.filterNilParameters(parameters), successClosure: {
|
||||
(response) -> Void in
|
||||
success?(file: File(file: response["file"] as? [String: AnyObject]))
|
||||
}) {(error) -> Void in
|
||||
failure?(error: error)
|
||||
}
|
||||
}
|
||||
|
||||
//MARK: - File Comments
|
||||
public func addFileComment(_ fileID: String, comment: String, success: ((comment: Comment)->Void)?, failure: FailureClosure?) {
|
||||
let parameters: [String: AnyObject] = ["file":fileID, "comment":comment.slackFormatEscaping()]
|
||||
networkInterface.request(.FilesCommentsAdd, token: token, parameters: parameters, successClosure: {
|
||||
(response) -> Void in
|
||||
success?(comment: Comment(comment: response["comment"] as? [String: AnyObject]))
|
||||
}) {(error) -> Void in
|
||||
failure?(error: error)
|
||||
}
|
||||
}
|
||||
|
||||
public func editFileComment(_ fileID: String, commentID: String, comment: String, success: ((comment: Comment)->Void)?, failure: FailureClosure?) {
|
||||
let parameters: [String: AnyObject] = ["file":fileID, "id":commentID, "comment":comment.slackFormatEscaping()]
|
||||
networkInterface.request(.FilesCommentsEdit, token: token, parameters: parameters, successClosure: {
|
||||
(response) -> Void in
|
||||
success?(comment: Comment(comment: response["comment"] as? [String: AnyObject]))
|
||||
}) {(error) -> Void in
|
||||
failure?(error: error)
|
||||
}
|
||||
}
|
||||
|
||||
public func deleteFileComment(_ fileID: String, commentID: String, success: ((deleted: Bool?)->Void)?, failure: FailureClosure?) {
|
||||
let parameters: [String: AnyObject] = ["file":fileID, "id": commentID]
|
||||
networkInterface.request(.FilesCommentsDelete, token: token, parameters: parameters, successClosure: {
|
||||
(response) -> Void in
|
||||
success?(deleted: true)
|
||||
}) {(error) -> Void in
|
||||
failure?(error: error)
|
||||
}
|
||||
}
|
||||
|
||||
//MARK: - Groups
|
||||
public func closeGroup(_ groupID: String, success: ((closed: Bool)->Void)?, failure: FailureClosure?) {
|
||||
close(.GroupsClose, channelID: groupID, success: {
|
||||
(closed) -> Void in
|
||||
success?(closed:closed)
|
||||
}) {(error) -> Void in
|
||||
failure?(error: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) -> Void in
|
||||
success?(history: history)
|
||||
}) {(error) -> Void in
|
||||
failure?(error: error)
|
||||
}
|
||||
}
|
||||
|
||||
public func groupInfo(_ id: String, success: ((channel: Channel)->Void)?, failure: FailureClosure?) {
|
||||
info(.GroupsInfo, type:ChannelType.Group, id: id, success: {
|
||||
(channel) -> Void in
|
||||
success?(channel: channel)
|
||||
}) {(error) -> Void in
|
||||
failure?(error: error)
|
||||
}
|
||||
}
|
||||
|
||||
public func groupsList(_ excludeArchived: Bool = false, success: ((channels: [[String: AnyObject]]?)->Void)?, failure: FailureClosure?) {
|
||||
list(.GroupsList, type:ChannelType.Group, excludeArchived: excludeArchived, success: {
|
||||
(channels) -> Void in
|
||||
success?(channels: channels)
|
||||
}) {(error) -> Void in
|
||||
failure?(error: error)
|
||||
}
|
||||
}
|
||||
|
||||
public func markGroup(_ channel: String, timestamp: String, success: ((ts: String)->Void)?, failure: FailureClosure?) {
|
||||
mark(.GroupsMark, channel: channel, timestamp: timestamp, success: {
|
||||
(ts) -> Void in
|
||||
success?(ts: timestamp)
|
||||
}) {(error) -> Void in
|
||||
failure?(error: error)
|
||||
}
|
||||
}
|
||||
|
||||
public func openGroup(_ channel: String, success: ((opened: Bool)->Void)?, failure: FailureClosure?) {
|
||||
let parameters = ["channel":channel]
|
||||
networkInterface.request(.GroupsOpen, token: token, parameters: parameters, successClosure: {
|
||||
(response) -> Void in
|
||||
success?(opened: true)
|
||||
}) {(error) -> Void in
|
||||
failure?(error: error)
|
||||
}
|
||||
}
|
||||
|
||||
public func setGroupPurpose(_ channel: String, purpose: String, success: ((purposeSet: Bool)->Void)?, failure: FailureClosure?) {
|
||||
setInfo(.GroupsSetPurpose, type: .Purpose, channel: channel, text: purpose, success: {
|
||||
(purposeSet) -> Void in
|
||||
success?(purposeSet: purposeSet)
|
||||
}) {(error) -> Void in
|
||||
failure?(error: error)
|
||||
}
|
||||
}
|
||||
|
||||
public func setGroupTopic(_ channel: String, topic: String, success: ((topicSet: Bool)->Void)?, failure: FailureClosure?) {
|
||||
setInfo(.GroupsSetTopic, type: .Topic, channel: channel, text: topic, success: {
|
||||
(topicSet) -> Void in
|
||||
success?(topicSet: topicSet)
|
||||
}) {(error) -> Void in
|
||||
failure?(error: error)
|
||||
}
|
||||
}
|
||||
|
||||
//MARK: - IM
|
||||
public func closeIM(_ channel: String, success: ((closed: Bool)->Void)?, failure: FailureClosure?) {
|
||||
close(.IMClose, channelID: channel, success: {
|
||||
(closed) -> Void in
|
||||
success?(closed: closed)
|
||||
}) {(error) -> Void in
|
||||
failure?(error: 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) -> Void in
|
||||
success?(history: history)
|
||||
}) {(error) -> Void in
|
||||
failure?(error: error)
|
||||
}
|
||||
}
|
||||
|
||||
public func imsList(_ excludeArchived: Bool = false, success: ((channels: [[String: AnyObject]]?)->Void)?, failure: FailureClosure?) {
|
||||
list(.IMList, type:ChannelType.IM, excludeArchived: excludeArchived, success: {
|
||||
(channels) -> Void in
|
||||
success?(channels: channels)
|
||||
}) {(error) -> Void in
|
||||
failure?(error: error)
|
||||
}
|
||||
}
|
||||
|
||||
public func markIM(_ channel: String, timestamp: String, success: ((ts: String)->Void)?, failure: FailureClosure?) {
|
||||
mark(.IMMark, channel: channel, timestamp: timestamp, success: {
|
||||
(ts) -> Void in
|
||||
success?(ts: timestamp)
|
||||
}) {(error) -> Void in
|
||||
failure?(error: error)
|
||||
}
|
||||
}
|
||||
|
||||
public func openIM(_ userID: String, success: ((imID: String?)->Void)?, failure: FailureClosure?) {
|
||||
let parameters = ["user":userID]
|
||||
networkInterface.request(.IMOpen, token: token, parameters: parameters, successClosure: {
|
||||
(response) -> Void in
|
||||
let group = response["channel"] as? [String: AnyObject]
|
||||
success?(imID: group?["id"] as? String)
|
||||
}) {(error) -> Void in
|
||||
failure?(error: error)
|
||||
}
|
||||
}
|
||||
|
||||
//MARK: - MPIM
|
||||
public func closeMPIM(_ channel: String, success: ((closed: Bool)->Void)?, failure: FailureClosure?) {
|
||||
close(.MPIMClose, channelID: channel, success: {
|
||||
(closed) -> Void in
|
||||
success?(closed: closed)
|
||||
}) {(error) -> Void in
|
||||
failure?(error: 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) -> Void in
|
||||
success?(history: history)
|
||||
}) {(error) -> Void in
|
||||
failure?(error: error)
|
||||
}
|
||||
}
|
||||
|
||||
public func mpimsList(_ excludeArchived: Bool = false, success: ((channels: [[String: AnyObject]]?)->Void)?, failure: FailureClosure?) {
|
||||
list(.MPIMList, type:ChannelType.Group, excludeArchived: excludeArchived, success: {
|
||||
(channels) -> Void in
|
||||
success?(channels: channels)
|
||||
}) {(error) -> Void in
|
||||
failure?(error: error)
|
||||
}
|
||||
}
|
||||
|
||||
public func markMPIM(_ channel: String, timestamp: String, success: ((ts: String)->Void)?, failure: FailureClosure?) {
|
||||
mark(.MPIMMark, channel: channel, timestamp: timestamp, success: {
|
||||
(ts) -> Void in
|
||||
success?(ts: timestamp)
|
||||
}) {(error) -> Void in
|
||||
failure?(error: error)
|
||||
}
|
||||
}
|
||||
|
||||
public func openMPIM(_ userIDs: [String], success: ((mpimID: String?)->Void)?, failure: FailureClosure?) {
|
||||
let parameters = ["users":userIDs.joined(separator: ",")]
|
||||
networkInterface.request(.MPIMOpen, token: token, parameters: parameters, successClosure: {
|
||||
(response) -> Void in
|
||||
let group = response["group"] as? [String: AnyObject]
|
||||
success?(mpimID: group?["id"] as? String)
|
||||
}) {(error) -> Void in
|
||||
failure?(error: 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) -> Void in
|
||||
success?(pinned: ok)
|
||||
}) {(error) -> Void in
|
||||
failure?(error: 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) -> Void in
|
||||
success?(unpinned: ok)
|
||||
}) {(error) -> Void in
|
||||
failure?(error: 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: AnyObject?] = ["channel":channel, "file":file, "file_comment":fileComment, "timestamp":timestamp]
|
||||
networkInterface.request(endpoint, token: token, parameters: WebAPI.filterNilParameters(parameters), successClosure: {
|
||||
(response) -> Void in
|
||||
success?(ok: true)
|
||||
}){(error) -> Void in
|
||||
failure?(error: 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) -> Void in
|
||||
success?(reacted: ok)
|
||||
}) {(error) -> Void in
|
||||
failure?(error: 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) -> Void in
|
||||
success?(unreacted: ok)
|
||||
}) {(error) -> Void in
|
||||
failure?(error: 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: AnyObject?] = ["name":name, "file":file, "file_comment":fileComment, "channel":channel, "timestamp":timestamp]
|
||||
networkInterface.request(endpoint, token: token, parameters: WebAPI.filterNilParameters(parameters), successClosure: {
|
||||
(response) -> Void in
|
||||
success?(ok: true)
|
||||
}) {(error) -> Void in
|
||||
failure?(error: 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) -> Void in
|
||||
success?(starred: ok)
|
||||
}) {(error) -> Void in
|
||||
failure?(error: 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) -> Void in
|
||||
success?(unstarred: ok)
|
||||
}) {(error) -> Void in
|
||||
failure?(error: error)
|
||||
}
|
||||
}
|
||||
|
||||
private func star(_ endpoint: Endpoint, file: String?, fileComment: String?, channel: String?, timestamp: String?, success: ((ok: Bool)->Void)?, failure: FailureClosure?) {
|
||||
let parameters: [String: AnyObject?] = ["file":file, "file_comment":fileComment, "channel":channel, "timestamp":timestamp]
|
||||
networkInterface.request(endpoint, token: token, parameters: WebAPI.filterNilParameters(parameters), successClosure: {
|
||||
(response) -> Void in
|
||||
success?(ok: true)
|
||||
}) {(error) -> Void in
|
||||
failure?(error: error)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//MARK: - Team
|
||||
public func teamInfo(_ success: ((info: [String: AnyObject]?)->Void)?, failure: FailureClosure?) {
|
||||
networkInterface.request(.TeamInfo, token: token, parameters: nil, successClosure: {
|
||||
(response) -> Void in
|
||||
success?(info: response["team"] as? [String: AnyObject])
|
||||
}) {(error) -> Void in
|
||||
failure?(error: error)
|
||||
}
|
||||
}
|
||||
|
||||
//MARK: - Users
|
||||
public func userPresence(_ user: String, success: ((presence: String?)->Void)?, failure: FailureClosure?) {
|
||||
let parameters: [String: AnyObject] = ["user":user]
|
||||
networkInterface.request(.UsersGetPresence, token: token, parameters: parameters, successClosure: {
|
||||
(response) -> Void in
|
||||
success?(presence: response["presence"] as? String)
|
||||
}){(error) -> Void in
|
||||
failure?(error: error)
|
||||
}
|
||||
}
|
||||
|
||||
public func userInfo(_ id: String, success: ((user: User)->Void)?, failure: FailureClosure?) {
|
||||
let parameters: [String: AnyObject] = ["user":id]
|
||||
networkInterface.request(.UsersInfo, token: token, parameters: parameters, successClosure: {
|
||||
(response) -> Void in
|
||||
success?(user: User(user: response["user"] as? [String: AnyObject]))
|
||||
}) {(error) -> Void in
|
||||
failure?(error: error)
|
||||
}
|
||||
}
|
||||
|
||||
public func usersList(_ includePresence: Bool = false, success: ((userList: [[String: AnyObject]]?)->Void)?, failure: FailureClosure?) {
|
||||
let parameters: [String: AnyObject] = ["presence":includePresence]
|
||||
networkInterface.request(.UsersList, token: token, parameters: parameters, successClosure: {
|
||||
(response) -> Void in
|
||||
success?(userList: response["members"] as? [[String: AnyObject]])
|
||||
}){(error) -> Void in
|
||||
failure?(error: error)
|
||||
}
|
||||
}
|
||||
|
||||
public func setUserActive(_ success: ((success: Bool)->Void)?, failure: FailureClosure?) {
|
||||
networkInterface.request(.UsersSetActive, token: token, parameters: nil, successClosure: {
|
||||
(response) -> Void in
|
||||
success?(success: true)
|
||||
}) {(error) -> Void in
|
||||
failure?(error: error)
|
||||
}
|
||||
}
|
||||
|
||||
public func setUserPresence(_ presence: Presence, success: ((success: Bool)->Void)?, failure: FailureClosure?) {
|
||||
let parameters: [String: AnyObject] = ["presence":presence.rawValue]
|
||||
networkInterface.request(.UsersSetPresence, token: token, parameters: parameters, successClosure: {
|
||||
(response) -> Void in
|
||||
success?(success:true)
|
||||
}) {(error) -> Void in
|
||||
failure?(error: error)
|
||||
}
|
||||
}
|
||||
|
||||
//MARK: - Channel Utilities
|
||||
private func close(_ endpoint: Endpoint, channelID: String, success: ((closed: Bool)->Void)?, failure: FailureClosure?) {
|
||||
let parameters: [String: AnyObject] = ["channel":channelID]
|
||||
networkInterface.request(endpoint, token: token, parameters: parameters, successClosure: {
|
||||
(response) -> Void in
|
||||
success?(closed: true)
|
||||
}) {(error) -> Void in
|
||||
failure?(error: 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: AnyObject] = ["channel": id, "latest": latest, "oldest": oldest, "inclusive":inclusive, "count":count, "unreads":unreads]
|
||||
networkInterface.request(endpoint, token: token, parameters: parameters, successClosure: {
|
||||
(response) -> Void in
|
||||
success?(history: History(history: response))
|
||||
}) {(error) -> Void in
|
||||
failure?(error: error)
|
||||
}
|
||||
}
|
||||
|
||||
private func info(_ endpoint: Endpoint, type: ChannelType, id: String, success: ((channel: Channel)->Void)?, failure: FailureClosure?) {
|
||||
let parameters: [String: AnyObject] = ["channel": id]
|
||||
networkInterface.request(endpoint, token: token, parameters: parameters, successClosure: {
|
||||
(response) -> Void in
|
||||
success?(channel: Channel(channel: response[type.rawValue] as? [String: AnyObject]))
|
||||
}) {(error) -> Void in
|
||||
failure?(error: error)
|
||||
}
|
||||
}
|
||||
|
||||
private func list(_ endpoint: Endpoint, type: ChannelType, excludeArchived: Bool = false, success: ((channels: [[String: AnyObject]]?)->Void)?, failure: FailureClosure?) {
|
||||
let parameters: [String: AnyObject] = ["exclude_archived": excludeArchived]
|
||||
networkInterface.request(endpoint, token: token, parameters: parameters, successClosure: {
|
||||
(response) -> Void in
|
||||
success?(channels: response[type.rawValue+"s"] as? [[String: AnyObject]])
|
||||
}) {(error) -> Void in
|
||||
failure?(error: error)
|
||||
}
|
||||
}
|
||||
|
||||
private func mark(_ endpoint: Endpoint, channel: String, timestamp: String, success: ((ts: String)->Void)?, failure: FailureClosure?) {
|
||||
let parameters: [String: AnyObject] = ["channel": channel, "ts": timestamp]
|
||||
networkInterface.request(endpoint, token: token, parameters: parameters, successClosure: {
|
||||
(response) -> Void in
|
||||
success?(ts: timestamp)
|
||||
}) {(error) -> Void in
|
||||
failure?(error: error)
|
||||
}
|
||||
}
|
||||
|
||||
private func setInfo(_ endpoint: Endpoint, type: InfoType, channel: String, text: String, success: ((success: Bool)->Void)?, failure: FailureClosure?) {
|
||||
let parameters: [String: AnyObject] = ["channel": channel, type.rawValue: text]
|
||||
networkInterface.request(endpoint, token: token, parameters: parameters, successClosure: {
|
||||
(response) -> Void in
|
||||
success?(success: true)
|
||||
}) {(error) -> Void in
|
||||
failure?(error: error)
|
||||
}
|
||||
}
|
||||
|
||||
//MARK: - Encode Attachments
|
||||
private func encodeAttachments(_ attachments: [Attachment?]?) -> String? {
|
||||
if let attachments = attachments {
|
||||
var attachmentArray: [[String: AnyObject]] = []
|
||||
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: - Filter Nil Parameters
|
||||
internal static func filterNilParameters(_ parameters: [String: AnyObject?]) -> [String: AnyObject] {
|
||||
var finalParameters = [String: AnyObject]()
|
||||
for (key, value) in parameters {
|
||||
if let unwrapped = value {
|
||||
finalParameters[key] = unwrapped
|
||||
}
|
||||
}
|
||||
return finalParameters
|
||||
}
|
||||
|
||||
//MARK: - Enumerate Do Not Disturb Status
|
||||
private func enumerateDNDStatuses(_ statuses: [String: AnyObject]) -> [String: DoNotDisturbStatus] {
|
||||
var retVal = [String: DoNotDisturbStatus]()
|
||||
for key in statuses.keys {
|
||||
retVal[key] = DoNotDisturbStatus(status: statuses[key] as? [String: AnyObject])
|
||||
}
|
||||
return retVal
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
//
|
||||
// WebhookRequest.swift
|
||||
//
|
||||
// Copyright © 2016 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.
|
||||
|
||||
internal struct WebhookRequest: Request {
|
||||
|
||||
let token: String?
|
||||
let teamID: String
|
||||
let teamDomain: String
|
||||
let channelID: String
|
||||
let channelName: String
|
||||
let userID: String
|
||||
let userName: String
|
||||
let command: String
|
||||
let text: String
|
||||
let responseURL: String
|
||||
|
||||
init(request: [String: AnyObject]?) {
|
||||
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 ?? ""
|
||||
userID = request?["user_id"] as? String ?? ""
|
||||
userName = request?["user_name"] as? String ?? ""
|
||||
command = request?["command"] as? String ?? ""
|
||||
text = request?["text"] as? String ?? ""
|
||||
responseURL = request?["response_url"] as? String ?? ""
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
//
|
||||
// WebhookServer.swift
|
||||
//
|
||||
// Copyright © 2016 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 class WebhookServer: Server {
|
||||
|
||||
public init(token: String, route: String, response: Response) {
|
||||
super.init(token: token)
|
||||
addRoute(route, response: response)
|
||||
}
|
||||
|
||||
public func addRoute(_ route: String, response: Response) {
|
||||
http["/\(route)"] = { request in
|
||||
let webhookRequest = WebhookRequest(request: self.dictionaryFromRequest(request.body))
|
||||
if webhookRequest.token == self.token {
|
||||
return self.request(webhookRequest, reply: self.replyForResponse(response))
|
||||
} else {
|
||||
return .badRequest(.text("Bad request."))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func replyForResponse(_ response: Response) -> Reply {
|
||||
if response.attachments == nil && response.responseType == nil {
|
||||
return Reply.text(body: response.text)
|
||||
} else {
|
||||
return Reply.json(response: response)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>en</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>$(EXECUTABLE_NAME)</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>$(PRODUCT_NAME)</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>FMWK</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>2.0.0</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>$(CURRENT_PROJECT_VERSION)</string>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
<string>Copyright © 2016 Peter Zignego. All rights reserved.</string>
|
||||
<key>NSPrincipalClass</key>
|
||||
<string></string>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>en</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>$(EXECUTABLE_NAME)</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>$(PRODUCT_NAME)</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>FMWK</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>2.0.0</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>$(CURRENT_PROJECT_VERSION)</string>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
<string>Copyright © 2016 Peter Zignego. All rights reserved.</string>
|
||||
<key>NSPrincipalClass</key>
|
||||
<string></string>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -15,7 +15,7 @@
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>FMWK</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<string>2.0.0</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
Reference in New Issue
Block a user