slack-ruby 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e5a0fb441d7414a2a0da1a58f4e6931b57b421b8
4
- data.tar.gz: 859b4e78624453ea375dc41887bbe60b72b83b87
3
+ metadata.gz: 3f074cb6479f2a0dd14697315aa72a73e0251cc3
4
+ data.tar.gz: 7000599487522caf432ab6fe86268050a330b79c
5
5
  SHA512:
6
- metadata.gz: 3ca8aa7091c3c760b4b787aad9ab659131f55f8aaccd18465f431cbf56bc5028750f850b393fb27d7e1537e816ff30b13f12d043ab5de227a22f9628b2f364ec
7
- data.tar.gz: 2a8870d09739ed85b71f22a26faead18883b08fe252864a8953680a1059aff8b8722eb3323b15ea643a45009b138320d88553e65a4e0229d9dbe9d0a6fd7655e
6
+ metadata.gz: eb992a603b00664ee58f4f2a312f5957021b67f42b44f89ea5330fd11131e8a9bf78957104dba109d2804ef08a5e281fbfdfc0155737377ea51c78bf1032796e
7
+ data.tar.gz: 20390238b3894f53fedca4941e595aa4fd365d1d9dbb3610264f1bbfb0391c8f4a94c3f42a5c80542186c94186ec766181406ea9f1b0c6cbe6f2724a64069ff9
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Slack::Ruby
2
2
 
3
- TODO: Write a gem description
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
- TODO: Write usage instructions here
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/[my-github-username]/slack-ruby/fork )
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`)
@@ -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, args, &block)
22
- @connection.call(@command, sub_command, args, &block)
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) && args.length == 1 && args[0].class == Hash then
37
- call(name.to_s, args[0], &block)
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
@@ -30,11 +30,11 @@ module Slack
30
30
  @token = token
31
31
  end
32
32
 
33
- # ### Slack::RPC::Connection.call(command, sub_commnad, args, &block)
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, args, &block)
37
- faraday_response = connection.get("#{command}.#{sub_command}", args.clone.merge({:token => @token}))
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
@@ -1,3 +1,3 @@
1
1
  module Slack
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slack-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - morou