slack-ruby 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +33 -3
- data/lib/slack/rpc/command.rb +5 -4
- data/lib/slack/rpc/connection.rb +3 -3
- data/lib/slack/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3f074cb6479f2a0dd14697315aa72a73e0251cc3
|
4
|
+
data.tar.gz: 7000599487522caf432ab6fe86268050a330b79c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eb992a603b00664ee58f4f2a312f5957021b67f42b44f89ea5330fd11131e8a9bf78957104dba109d2804ef08a5e281fbfdfc0155737377ea51c78bf1032796e
|
7
|
+
data.tar.gz: 20390238b3894f53fedca4941e595aa4fd365d1d9dbb3610264f1bbfb0391c8f4a94c3f42a5c80542186c94186ec766181406ea9f1b0c6cbe6f2724a64069ff9
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Slack::Ruby
|
2
2
|
|
3
|
-
|
3
|
+
A Ruby interface to [Slack API](https://api.slack.com/).
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
@@ -20,11 +20,41 @@ Or install it yourself as:
|
|
20
20
|
|
21
21
|
## Usage
|
22
22
|
|
23
|
-
|
23
|
+
### How to use RPC-Style Web API
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
require "slack"
|
27
|
+
|
28
|
+
# create RPC client object with OAuth token
|
29
|
+
client = Slack::RPC::Client.new("xxxx-xxxxxxxxx-xxxx")
|
30
|
+
|
31
|
+
# execute RPC command and retrieve response
|
32
|
+
client.channels.archive(:channel => "C1234567890") do |response|
|
33
|
+
# your own code
|
34
|
+
end
|
35
|
+
|
36
|
+
# or you can get response as returned object
|
37
|
+
response = client.channels.unarchive(:channel => "C1234567890")
|
38
|
+
# your own code
|
39
|
+
```
|
40
|
+
|
41
|
+
#### RPC command
|
42
|
+
|
43
|
+
see [Slack Web API Document](https://api.slack.com/web)
|
44
|
+
|
45
|
+
#### Response object
|
46
|
+
|
47
|
+
- ```Slack::RPC::Response.status``` is HTTP status code as integer
|
48
|
+
- ```Slack::RPC::Response.headers``` is HTTP response header as Hash object
|
49
|
+
- ```Slack::RPC::Response.body``` is HTTP response body as Hash object
|
50
|
+
|
51
|
+
### How to use Real Time Messaging API
|
52
|
+
|
53
|
+
TODO
|
24
54
|
|
25
55
|
## Contributing
|
26
56
|
|
27
|
-
1. Fork it ( https://github.com/
|
57
|
+
1. Fork it ( https://github.com/morou/slack-ruby/fork )
|
28
58
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
29
59
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
30
60
|
4. Push to the branch (`git push origin my-new-feature`)
|
data/lib/slack/rpc/command.rb
CHANGED
@@ -18,8 +18,8 @@ module Slack
|
|
18
18
|
# ### Slack::RPC::Command.invoke_command
|
19
19
|
# Invokes Slack RPC-Style command
|
20
20
|
#
|
21
|
-
def call(sub_command,
|
22
|
-
@connection.call(@command, sub_command,
|
21
|
+
def call(sub_command, params, &block)
|
22
|
+
@connection.call(@command, sub_command, params, &block)
|
23
23
|
end
|
24
24
|
|
25
25
|
# ### Slack::RPC::Command.respond_to?(name)
|
@@ -33,8 +33,9 @@ module Slack
|
|
33
33
|
# Invoked by Ruby when obj is sent a message it cannot handle.
|
34
34
|
#
|
35
35
|
def method_missing(name, *args, &block)
|
36
|
-
if @sub_commands.include?(name.to_s)
|
37
|
-
|
36
|
+
if @sub_commands.include?(name.to_s) then
|
37
|
+
params = (args.length == 1 && args[0].class == Hash) ? args[0] : {}
|
38
|
+
call(name.to_s, params, &block)
|
38
39
|
else
|
39
40
|
super
|
40
41
|
end
|
data/lib/slack/rpc/connection.rb
CHANGED
@@ -30,11 +30,11 @@ module Slack
|
|
30
30
|
@token = token
|
31
31
|
end
|
32
32
|
|
33
|
-
# ### Slack::RPC::Connection.call(command, sub_commnad,
|
33
|
+
# ### Slack::RPC::Connection.call(command, sub_commnad, params, &block)
|
34
34
|
# Call Slack RPC-Style command
|
35
35
|
#
|
36
|
-
def call(command, sub_command,
|
37
|
-
faraday_response = connection.get("#{command}.#{sub_command}",
|
36
|
+
def call(command, sub_command, params, &block)
|
37
|
+
faraday_response = connection.get("#{command}.#{sub_command}", params.clone.merge({:token => @token}))
|
38
38
|
response = Response.new(faraday_response)
|
39
39
|
if block then
|
40
40
|
yield response
|
data/lib/slack/version.rb
CHANGED