slack-ruby-client-bhe 0.5.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +17 -0
- data/.gitignore +4 -0
- data/.gitmodules +3 -0
- data/.rspec +2 -0
- data/.rubocop.yml +6 -0
- data/.rubocop_todo.yml +78 -0
- data/.travis.yml +26 -0
- data/CHANGELOG.md +79 -0
- data/CONTRIBUTING.md +157 -0
- data/Gemfile +5 -0
- data/LICENSE.md +22 -0
- data/README.md +385 -0
- data/RELEASING.md +69 -0
- data/Rakefile +19 -0
- data/UPGRADING.md +26 -0
- data/bin/commands.rb +21 -0
- data/bin/commands/api.rb +14 -0
- data/bin/commands/auth.rb +12 -0
- data/bin/commands/channels.rb +149 -0
- data/bin/commands/chat.rb +47 -0
- data/bin/commands/dnd.rb +47 -0
- data/bin/commands/emoji.rb +12 -0
- data/bin/commands/files.rb +72 -0
- data/bin/commands/groups.rb +167 -0
- data/bin/commands/im.rb +53 -0
- data/bin/commands/mpim.rb +53 -0
- data/bin/commands/oauth.rb +16 -0
- data/bin/commands/pins.rb +37 -0
- data/bin/commands/reactions.rb +53 -0
- data/bin/commands/rtm.rb +15 -0
- data/bin/commands/search.rb +40 -0
- data/bin/commands/stars.rb +37 -0
- data/bin/commands/team.rb +32 -0
- data/bin/commands/usergroups.rb +73 -0
- data/bin/commands/users.rb +57 -0
- data/bin/slack +50 -0
- data/examples/hi_real_time/Gemfile +5 -0
- data/examples/hi_real_time/hi.gif +0 -0
- data/examples/hi_real_time/hi.rb +32 -0
- data/examples/hi_real_time_and_web/Gemfile +5 -0
- data/examples/hi_real_time_and_web/hi.gif +0 -0
- data/examples/hi_real_time_and_web/hi.rb +24 -0
- data/examples/hi_real_time_async/Gemfile +5 -0
- data/examples/hi_real_time_async/hi.rb +29 -0
- data/examples/hi_web/Gemfile +3 -0
- data/examples/hi_web/hi.gif +0 -0
- data/examples/hi_web/hi.rb +12 -0
- data/examples/new_ticket/Gemfile +3 -0
- data/examples/new_ticket/new_ticket.rb +25 -0
- data/lib/slack-ruby-client.rb +29 -0
- data/lib/slack.rb +1 -0
- data/lib/slack/config.rb +21 -0
- data/lib/slack/messages/formatting.rb +30 -0
- data/lib/slack/real_time/api/message.rb +20 -0
- data/lib/slack/real_time/api/message_id.rb +14 -0
- data/lib/slack/real_time/api/ping.rb +16 -0
- data/lib/slack/real_time/api/typing.rb +17 -0
- data/lib/slack/real_time/client.rb +152 -0
- data/lib/slack/real_time/concurrency.rb +8 -0
- data/lib/slack/real_time/concurrency/celluloid.rb +93 -0
- data/lib/slack/real_time/concurrency/eventmachine.rb +39 -0
- data/lib/slack/real_time/config.rb +55 -0
- data/lib/slack/real_time/socket.rb +81 -0
- data/lib/slack/version.rb +3 -0
- data/lib/slack/web/api/endpoints.rb +53 -0
- data/lib/slack/web/api/endpoints/api.rb +24 -0
- data/lib/slack/web/api/endpoints/auth.rb +20 -0
- data/lib/slack/web/api/endpoints/channels.rb +220 -0
- data/lib/slack/web/api/endpoints/chat.rb +91 -0
- data/lib/slack/web/api/endpoints/dnd.rb +64 -0
- data/lib/slack/web/api/endpoints/emoji.rb +20 -0
- data/lib/slack/web/api/endpoints/files.rb +108 -0
- data/lib/slack/web/api/endpoints/groups.rb +247 -0
- data/lib/slack/web/api/endpoints/im.rb +85 -0
- data/lib/slack/web/api/endpoints/mpim.rb +84 -0
- data/lib/slack/web/api/endpoints/oauth.rb +32 -0
- data/lib/slack/web/api/endpoints/pins.rb +64 -0
- data/lib/slack/web/api/endpoints/presence.rb +23 -0
- data/lib/slack/web/api/endpoints/reactions.rb +89 -0
- data/lib/slack/web/api/endpoints/rtm.rb +27 -0
- data/lib/slack/web/api/endpoints/search.rb +65 -0
- data/lib/slack/web/api/endpoints/stars.rb +61 -0
- data/lib/slack/web/api/endpoints/team.rb +47 -0
- data/lib/slack/web/api/endpoints/usergroups.rb +113 -0
- data/lib/slack/web/api/endpoints/users.rb +73 -0
- data/lib/slack/web/api/error.rb +14 -0
- data/lib/slack/web/api/mixins.rb +3 -0
- data/lib/slack/web/api/mixins/channels.id.json +20 -0
- data/lib/slack/web/api/mixins/channels.id.rb +26 -0
- data/lib/slack/web/api/mixins/groups.id.json +20 -0
- data/lib/slack/web/api/mixins/groups.id.rb +26 -0
- data/lib/slack/web/api/mixins/users.id.json +20 -0
- data/lib/slack/web/api/mixins/users.id.rb +26 -0
- data/lib/slack/web/api/patches/chat.1.text-attachments-required.patch +13 -0
- data/lib/slack/web/api/patches/chat.2.attachments-json.patch +17 -0
- data/lib/slack/web/api/schema/group.json +14 -0
- data/lib/slack/web/api/schema/method.json +45 -0
- data/lib/slack/web/api/tasks/generate.rake +61 -0
- data/lib/slack/web/api/templates/command.erb +34 -0
- data/lib/slack/web/api/templates/commands.erb +5 -0
- data/lib/slack/web/api/templates/endpoints.erb +21 -0
- data/lib/slack/web/api/templates/method.erb +49 -0
- data/lib/slack/web/client.rb +28 -0
- data/lib/slack/web/config.rb +41 -0
- data/lib/slack/web/faraday/connection.rb +29 -0
- data/lib/slack/web/faraday/request.rb +39 -0
- data/lib/slack/web/faraday/response/raise_error.rb +15 -0
- data/lib/slack_ruby_client.rb +1 -0
- data/screenshots/register-bot.png +0 -0
- data/slack-ruby-client.gemspec +31 -0
- data/slack.png +0 -0
- data/spec/fixtures/slack/web/429_error.yml +83 -0
- data/spec/fixtures/slack/web/auth_test_error.yml +48 -0
- data/spec/fixtures/slack/web/auth_test_success.yml +57 -0
- data/spec/fixtures/slack/web/channels_info.yml +46 -0
- data/spec/fixtures/slack/web/groups_info.yml +43 -0
- data/spec/fixtures/slack/web/rtm_start.yml +73 -0
- data/spec/fixtures/slack/web/users_info.yml +130 -0
- data/spec/fixtures/slack/web/users_list.yml +72 -0
- data/spec/integration/integration_spec.rb +107 -0
- data/spec/slack/config_spec.rb +14 -0
- data/spec/slack/messages/formatting_spec.rb +43 -0
- data/spec/slack/real_time/api/message_spec.rb +15 -0
- data/spec/slack/real_time/api/ping_spec.rb +15 -0
- data/spec/slack/real_time/api/typing_spec.rb +15 -0
- data/spec/slack/real_time/client_spec.rb +198 -0
- data/spec/slack/real_time/concurrency/celluloid_spec.rb +58 -0
- data/spec/slack/real_time/concurrency/eventmachine_spec.rb +49 -0
- data/spec/slack/slack_spec.rb +58 -0
- data/spec/slack/version_spec.rb +7 -0
- data/spec/slack/web/api/endpoints/auth_spec.rb +20 -0
- data/spec/slack/web/api/endpoints/channels_spec.rb +11 -0
- data/spec/slack/web/api/endpoints/chat_spec.rb +33 -0
- data/spec/slack/web/api/endpoints/groups_spec.rb +11 -0
- data/spec/slack/web/api/endpoints/users_spec.rb +17 -0
- data/spec/slack/web/api/error_spec.rb +14 -0
- data/spec/slack/web/api/mixins/channels_spec.rb +31 -0
- data/spec/slack/web/api/mixins/groups_spec.rb +31 -0
- data/spec/slack/web/api/mixins/users_spec.rb +31 -0
- data/spec/slack/web/client_spec.rb +134 -0
- data/spec/spec_helper.rb +14 -0
- data/spec/support/queue_with_timeout.rb +34 -0
- data/spec/support/real_time/concurrency/mock.rb +31 -0
- data/spec/support/real_time/connected_client.rb +16 -0
- data/spec/support/token.rb +10 -0
- data/spec/support/vcr.rb +8 -0
- metadata +392 -0
@@ -0,0 +1,45 @@
|
|
1
|
+
{
|
2
|
+
"type": "object",
|
3
|
+
"required": [
|
4
|
+
"desc",
|
5
|
+
"args",
|
6
|
+
"errors"
|
7
|
+
],
|
8
|
+
"properties": {
|
9
|
+
"desc": {
|
10
|
+
"type": "string"
|
11
|
+
},
|
12
|
+
"args": {
|
13
|
+
"type": "object",
|
14
|
+
"default": {},
|
15
|
+
"patternProperties": {
|
16
|
+
"^.+$": {
|
17
|
+
"properties": {
|
18
|
+
"required": {
|
19
|
+
"type": "bool",
|
20
|
+
"default": false
|
21
|
+
},
|
22
|
+
"example": {
|
23
|
+
"type": "any",
|
24
|
+
"required": false,
|
25
|
+
"default": ""
|
26
|
+
},
|
27
|
+
"type": {
|
28
|
+
"type": "any",
|
29
|
+
"required": false,
|
30
|
+
"default": "Object"
|
31
|
+
},
|
32
|
+
"desc": {
|
33
|
+
"type": "string",
|
34
|
+
"required": true
|
35
|
+
}
|
36
|
+
}
|
37
|
+
}
|
38
|
+
}
|
39
|
+
},
|
40
|
+
"errors": {
|
41
|
+
"type": "object",
|
42
|
+
"default": {}
|
43
|
+
}
|
44
|
+
}
|
45
|
+
}
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# largely from https://github.com/aki017/slack-ruby-gem
|
2
|
+
require 'json-schema'
|
3
|
+
require 'erubis'
|
4
|
+
|
5
|
+
namespace :slack do
|
6
|
+
namespace :web do
|
7
|
+
namespace :api do
|
8
|
+
# update slack-api-ref from https://github.com/dblock/slack-api-ref
|
9
|
+
task :git_update do
|
10
|
+
sh 'git submodule update --init --recursive'
|
11
|
+
sh 'git submodule foreach git pull origin master'
|
12
|
+
end
|
13
|
+
|
14
|
+
desc 'Update API.'
|
15
|
+
task update: [:git_update] do
|
16
|
+
group_schema = JSON.parse(File.read('lib/slack/web/api/schema/group.json'))
|
17
|
+
groups = Dir.glob('lib/slack/web/api/slack-api-ref/groups/**/*.json').each_with_object({}) do |path, result|
|
18
|
+
name = File.basename(path, '.json')
|
19
|
+
parsed = JSON.parse(File.read(path))
|
20
|
+
JSON::Validator.validate(group_schema, parsed, insert_defaults: true)
|
21
|
+
result[name] = parsed
|
22
|
+
end
|
23
|
+
|
24
|
+
method_schema = JSON.parse(File.read('lib/slack/web/api/schema/method.json'))
|
25
|
+
data = [
|
26
|
+
Dir.glob('lib/slack/web/api/slack-api-ref/methods/**/*.json'),
|
27
|
+
Dir.glob('lib/slack/web/api/mixins/**/*.json')
|
28
|
+
].flatten.each_with_object({}) do |path, result|
|
29
|
+
name = File.basename(path, '.json')
|
30
|
+
prefix, name = name.split('.')
|
31
|
+
result[prefix] ||= {}
|
32
|
+
parsed = JSON.parse(File.read(path))
|
33
|
+
JSON::Validator.validate(method_schema, parsed, insert_defaults: true)
|
34
|
+
result[prefix][name] = parsed
|
35
|
+
end
|
36
|
+
|
37
|
+
method_template = Erubis::Eruby.new(File.read('lib/slack/web/api/templates/method.erb'))
|
38
|
+
command_template = Erubis::Eruby.new(File.read('lib/slack/web/api/templates/command.erb'))
|
39
|
+
data.each_with_index do |(group, names), index|
|
40
|
+
printf "%2d/%2d %10s %s\n", index, data.size, group, names.keys
|
41
|
+
# method
|
42
|
+
rendered_method = method_template.result(group: group, names: names)
|
43
|
+
File.write "lib/slack/web/api/endpoints/#{group}.rb", rendered_method
|
44
|
+
Dir.glob("lib/slack/web/api/patches/#{group}*.patch").sort.each do |patch|
|
45
|
+
puts "- patching #{patch}"
|
46
|
+
system("git apply #{patch}") || fail('failed to apply patch')
|
47
|
+
end
|
48
|
+
# command
|
49
|
+
rendered_command = command_template.result(group: groups[group], names: names)
|
50
|
+
File.write "bin/commands/#{group}.rb", rendered_command
|
51
|
+
end
|
52
|
+
|
53
|
+
endpoints_template = Erubis::Eruby.new(File.read('lib/slack/web/api/templates/endpoints.erb'))
|
54
|
+
File.write 'lib/slack/web/api/endpoints.rb', endpoints_template.result(files: data.keys)
|
55
|
+
|
56
|
+
commands_template = Erubis::Eruby.new(File.read('lib/slack/web/api/templates/commands.erb'))
|
57
|
+
File.write 'bin/commands.rb', commands_template.result(files: data.keys)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# This file was auto-generated by lib/slack/web/api/tasks/generate.rake
|
2
|
+
|
3
|
+
<% desc = group['desc'] || "#{group['name'].capitalize} methods." %>
|
4
|
+
<% if desc.include?("'") %>
|
5
|
+
desc "<%= desc %>"
|
6
|
+
<% else %>
|
7
|
+
desc '<%= desc %>'
|
8
|
+
<% end %>
|
9
|
+
command '<%= group['name'] %>' do |g|
|
10
|
+
<% names.each_with_index do |(name, data), index| %>
|
11
|
+
<% if index > 0 %>
|
12
|
+
|
13
|
+
<% end %>
|
14
|
+
<% short_desc = data["desc"].split("\n").first %>
|
15
|
+
<% if short_desc.include?("'") %>
|
16
|
+
g.desc "<%= short_desc %>"
|
17
|
+
<% else %>
|
18
|
+
g.desc '<%= short_desc %>'
|
19
|
+
<% end %>
|
20
|
+
g.long_desc %( <%= data["desc"].split("\n").join(" ") %> )
|
21
|
+
g.command '<%= name %>' do |c|
|
22
|
+
<% data["args"].each do |arg_name, arg_v| %>
|
23
|
+
<% if arg_v["desc"].include?("'") %>
|
24
|
+
c.flag '<%= arg_name %>', desc: "<%= arg_v["desc"] %>"
|
25
|
+
<% else %>
|
26
|
+
c.flag '<%= arg_name %>', desc: '<%= arg_v["desc"] %>'
|
27
|
+
<% end %>
|
28
|
+
<% end %>
|
29
|
+
c.action do |_global_options, options, _args|
|
30
|
+
puts JSON.dump($client.<%=group['name'] %>_<%= name %>(options))
|
31
|
+
end
|
32
|
+
end
|
33
|
+
<% end %>
|
34
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# This file was auto-generated by lib/slack/web/api/tasks/generate.rake
|
2
|
+
|
3
|
+
<% files.each do |f| %>
|
4
|
+
require 'slack/web/api/endpoints/<%= f %>'
|
5
|
+
<% end %>
|
6
|
+
|
7
|
+
module Slack
|
8
|
+
module Web
|
9
|
+
module Api
|
10
|
+
module Endpoints
|
11
|
+
include Slack::Web::Api::Mixins::Channels
|
12
|
+
include Slack::Web::Api::Mixins::Users
|
13
|
+
include Slack::Web::Api::Mixins::Groups
|
14
|
+
|
15
|
+
<% files.each do |f| %>
|
16
|
+
include <%= f.capitalize %>
|
17
|
+
<% end %>
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# This file was auto-generated by lib/slack/web/api/tasks/generate.rake
|
2
|
+
|
3
|
+
module Slack
|
4
|
+
module Web
|
5
|
+
module Api
|
6
|
+
module Endpoints
|
7
|
+
module <%= group.capitalize %>
|
8
|
+
<% names.each_with_index do |(name, data), index| %>
|
9
|
+
<% next if data['mixin'] %>
|
10
|
+
<% if index > 0 %>
|
11
|
+
|
12
|
+
<% end %>
|
13
|
+
#
|
14
|
+
<% data['desc'].split("\n").each do |line| %>
|
15
|
+
# <%= line %>
|
16
|
+
<% end %>
|
17
|
+
#
|
18
|
+
<% data['args'].each do |arg_name, arg_v| %>
|
19
|
+
# @option options [<%= arg_v['type'] %>] :<%= arg_name %>
|
20
|
+
<% arg_v['desc'].lines.each do |l| %>
|
21
|
+
<% if l.strip.length > 0 %>
|
22
|
+
# <%= l.strip %>
|
23
|
+
<% else %>
|
24
|
+
#
|
25
|
+
<% end %>
|
26
|
+
<% end %>
|
27
|
+
<% end %>
|
28
|
+
# @see https://api.slack.com/methods/<%= group %>.<%= name %>
|
29
|
+
# @see https://github.com/dblock/slack-api-ref/blob/master/methods/<%= group %>.<%= name %>.json
|
30
|
+
def <%= group %>_<%= name %>(options = {})
|
31
|
+
<% data['args'].select{ |k, v| v['required'] }.each do |arg_name, arg_v| %>
|
32
|
+
throw ArgumentError.new('Required arguments :<%= arg_name %> missing') if options[:<%= arg_name %>].nil?
|
33
|
+
<% end %>
|
34
|
+
<% if data['group'] == 'groups' && data['args']['channel'] && !data['args']['channel']['desc'].include?('Can be an encoded ID, or a name.') %>
|
35
|
+
options = options.merge(channel: groups_id(options)['group']['id']) if options[:channel]
|
36
|
+
<% elsif data['args']['channel'] && !data['args']['channel']['desc'].include?('Can be an encoded ID, or a name.') %>
|
37
|
+
options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
|
38
|
+
<% end %>
|
39
|
+
<% if data['args']['user'] %>
|
40
|
+
options = options.merge(user: users_id(options)['user']['id']) if options[:user]
|
41
|
+
<% end %>
|
42
|
+
post('<%= group %>.<%= name %>', options)
|
43
|
+
end
|
44
|
+
<% end %>
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Slack
|
2
|
+
module Web
|
3
|
+
class Client
|
4
|
+
include Faraday::Connection
|
5
|
+
include Faraday::Request
|
6
|
+
include Api::Endpoints
|
7
|
+
|
8
|
+
attr_accessor(*Config::ATTRIBUTES)
|
9
|
+
|
10
|
+
def initialize(options = {})
|
11
|
+
Slack::Web::Config::ATTRIBUTES.each do |key|
|
12
|
+
send("#{key}=", options[key] || Slack::Web.config.send(key))
|
13
|
+
end
|
14
|
+
@token ||= Slack.config.token
|
15
|
+
end
|
16
|
+
|
17
|
+
class << self
|
18
|
+
def configure
|
19
|
+
block_given? ? yield(Config) : Config
|
20
|
+
end
|
21
|
+
|
22
|
+
def config
|
23
|
+
Config
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module Slack
|
2
|
+
module Web
|
3
|
+
module Config
|
4
|
+
extend self
|
5
|
+
|
6
|
+
ATTRIBUTES = [
|
7
|
+
:proxy,
|
8
|
+
:user_agent,
|
9
|
+
:ca_path,
|
10
|
+
:ca_file,
|
11
|
+
:logger,
|
12
|
+
:endpoint,
|
13
|
+
:token
|
14
|
+
]
|
15
|
+
|
16
|
+
attr_accessor(*Config::ATTRIBUTES)
|
17
|
+
|
18
|
+
def reset
|
19
|
+
self.endpoint = 'https://slack.com/api/'
|
20
|
+
self.user_agent = "Slack Ruby Client/#{Slack::VERSION}"
|
21
|
+
self.ca_path = `openssl version -a | grep OPENSSLDIR | awk '{print $2}'|sed -e 's/\"//g'`
|
22
|
+
self.ca_file = "#{ca_path}/ca-certificates.crt"
|
23
|
+
self.token = nil
|
24
|
+
self.proxy = nil
|
25
|
+
self.logger = nil
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
class << self
|
30
|
+
def configure
|
31
|
+
block_given? ? yield(Config) : Config
|
32
|
+
end
|
33
|
+
|
34
|
+
def config
|
35
|
+
Config
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
Slack::Web::Config.reset
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Slack
|
2
|
+
module Web
|
3
|
+
module Faraday
|
4
|
+
module Connection
|
5
|
+
private
|
6
|
+
|
7
|
+
def connection
|
8
|
+
options = {
|
9
|
+
headers: { 'Accept' => 'application/json; charset=utf-8' }
|
10
|
+
}
|
11
|
+
|
12
|
+
options[:headers]['User-Agent'] = user_agent if user_agent
|
13
|
+
options[:proxy] = proxy if proxy
|
14
|
+
options[:ssl] = { ca_path: ca_path, ca_file: ca_file }
|
15
|
+
|
16
|
+
::Faraday::Connection.new(endpoint, options) do |connection|
|
17
|
+
connection.use ::Faraday::Request::Multipart
|
18
|
+
connection.use ::Faraday::Request::UrlEncoded
|
19
|
+
connection.use ::Slack::Web::Faraday::Response::RaiseError
|
20
|
+
connection.use ::FaradayMiddleware::ParseJson
|
21
|
+
connection.use ::Faraday::Response::RaiseError
|
22
|
+
connection.response :logger, logger if logger
|
23
|
+
connection.adapter ::Faraday.default_adapter
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module Slack
|
2
|
+
module Web
|
3
|
+
module Faraday
|
4
|
+
module Request
|
5
|
+
def get(path, options = {})
|
6
|
+
request(:get, path, options)
|
7
|
+
end
|
8
|
+
|
9
|
+
def post(path, options = {})
|
10
|
+
request(:post, path, options)
|
11
|
+
end
|
12
|
+
|
13
|
+
def put(path, options = {})
|
14
|
+
request(:put, path, options)
|
15
|
+
end
|
16
|
+
|
17
|
+
def delete(path, options = {})
|
18
|
+
request(:delete, path, options)
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def request(method, path, options)
|
24
|
+
options = options.merge(token: token)
|
25
|
+
response = connection.send(method) do |request|
|
26
|
+
case method
|
27
|
+
when :get, :delete
|
28
|
+
request.url(path, options)
|
29
|
+
when :post, :put
|
30
|
+
request.path = path
|
31
|
+
request.body = options unless options.empty?
|
32
|
+
end
|
33
|
+
end
|
34
|
+
response.body
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Slack
|
2
|
+
module Web
|
3
|
+
module Faraday
|
4
|
+
module Response
|
5
|
+
class RaiseError < ::Faraday::Response::Middleware
|
6
|
+
def on_complete(env)
|
7
|
+
body = env.body
|
8
|
+
return if body['ok']
|
9
|
+
fail Slack::Web::Api::Error.new(body['error'], env.response)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'slack-ruby-client'
|
Binary file
|
@@ -0,0 +1,31 @@
|
|
1
|
+
$LOAD_PATH.push File.expand_path('../lib', __FILE__)
|
2
|
+
require 'slack/version'
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = 'slack-ruby-client-bhe'
|
6
|
+
s.bindir = 'bin'
|
7
|
+
s.executables << 'slack'
|
8
|
+
s.version = Slack::VERSION
|
9
|
+
s.authors = ['Daniel Doubrovkine']
|
10
|
+
s.email = 'dblock@dblock.org'
|
11
|
+
s.platform = Gem::Platform::RUBY
|
12
|
+
s.required_rubygems_version = '>= 1.3.6'
|
13
|
+
s.files = `git ls-files`.split("\n")
|
14
|
+
s.test_files = `git ls-files -- spec/*`.split("\n")
|
15
|
+
s.require_paths = ['lib']
|
16
|
+
s.homepage = 'http://github.com/dblock/slack-ruby-client'
|
17
|
+
s.licenses = ['MIT']
|
18
|
+
s.summary = 'Slack Web and RealTime API client.'
|
19
|
+
s.add_dependency 'faraday'
|
20
|
+
s.add_dependency 'faraday_middleware'
|
21
|
+
s.add_dependency 'json'
|
22
|
+
s.add_dependency 'websocket-driver'
|
23
|
+
s.add_dependency 'gli'
|
24
|
+
s.add_development_dependency 'erubis'
|
25
|
+
s.add_development_dependency 'json-schema'
|
26
|
+
s.add_development_dependency 'rake'
|
27
|
+
s.add_development_dependency 'rspec'
|
28
|
+
s.add_development_dependency 'vcr'
|
29
|
+
s.add_development_dependency 'webmock'
|
30
|
+
s.add_development_dependency 'rubocop', '0.35.0'
|
31
|
+
end
|
data/slack.png
ADDED
Binary file
|
@@ -0,0 +1,83 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: https://slack.com/api/auth.test
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: token=
|
9
|
+
headers:
|
10
|
+
Accept:
|
11
|
+
- application/json; charset=utf-8
|
12
|
+
User-Agent:
|
13
|
+
- Slack Ruby Client 0.1.0
|
14
|
+
Content-Type:
|
15
|
+
- application/x-www-form-urlencoded
|
16
|
+
Accept-Encoding:
|
17
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
18
|
+
response:
|
19
|
+
status:
|
20
|
+
code: 429
|
21
|
+
message: OK
|
22
|
+
headers:
|
23
|
+
Access-Control-Allow-Origin:
|
24
|
+
- '*'
|
25
|
+
Date:
|
26
|
+
- Sat, 25 Jul 2015 14:42:07 GMT
|
27
|
+
Server:
|
28
|
+
- Apache
|
29
|
+
Connection:
|
30
|
+
- keep-alive
|
31
|
+
body:
|
32
|
+
encoding: US-ASCII
|
33
|
+
string: ''
|
34
|
+
http_version:
|
35
|
+
recorded_at: Sat, 25 Jul 2015 14:42:08 GMT
|
36
|
+
- request:
|
37
|
+
method: post
|
38
|
+
uri: https://slack.com/api/auth.test
|
39
|
+
body:
|
40
|
+
encoding: UTF-8
|
41
|
+
string: token
|
42
|
+
headers:
|
43
|
+
Accept:
|
44
|
+
- application/json; charset=utf-8
|
45
|
+
User-Agent:
|
46
|
+
- Slack Ruby Client/0.5.0
|
47
|
+
Content-Type:
|
48
|
+
- application/x-www-form-urlencoded
|
49
|
+
Accept-Encoding:
|
50
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
51
|
+
response:
|
52
|
+
status:
|
53
|
+
code: 200
|
54
|
+
message: OK
|
55
|
+
headers:
|
56
|
+
Access-Control-Allow-Origin:
|
57
|
+
- '*'
|
58
|
+
Content-Security-Policy:
|
59
|
+
- referrer no-referrer;
|
60
|
+
Content-Type:
|
61
|
+
- application/json; charset=utf-8
|
62
|
+
Date:
|
63
|
+
- Tue, 24 Nov 2015 20:03:05 GMT
|
64
|
+
Server:
|
65
|
+
- Apache
|
66
|
+
Strict-Transport-Security:
|
67
|
+
- max-age=31536000; includeSubDomains; preload
|
68
|
+
X-Accepted-Oauth-Scopes:
|
69
|
+
- identify
|
70
|
+
X-Content-Type-Options:
|
71
|
+
- nosniff
|
72
|
+
X-Xss-Protection:
|
73
|
+
- '0'
|
74
|
+
Content-Length:
|
75
|
+
- '33'
|
76
|
+
Connection:
|
77
|
+
- keep-alive
|
78
|
+
body:
|
79
|
+
encoding: UTF-8
|
80
|
+
string: '{"ok":false,"error":"not_authed"}'
|
81
|
+
http_version:
|
82
|
+
recorded_at: Tue, 24 Nov 2015 20:03:05 GMT
|
83
|
+
recorded_with: VCR 2.9.3
|