slack-ruby-client 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (77) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +4 -0
  3. data/.gitmodules +3 -0
  4. data/.rspec +2 -0
  5. data/.rubocop.yml +6 -0
  6. data/.rubocop_todo.yml +34 -0
  7. data/.travis.yml +6 -0
  8. data/CHANGELOG.md +4 -0
  9. data/CONTRIBUTING.md +139 -0
  10. data/Gemfile +3 -0
  11. data/LICENSE.md +22 -0
  12. data/README.md +123 -0
  13. data/RELEASING.md +67 -0
  14. data/Rakefile +19 -0
  15. data/examples/hi_real_time/Gemfile +3 -0
  16. data/examples/hi_real_time/hi.gif +0 -0
  17. data/examples/hi_real_time/hi.rb +27 -0
  18. data/examples/hi_real_time_and_web/Gemfile +3 -0
  19. data/examples/hi_real_time_and_web/hi.gif +0 -0
  20. data/examples/hi_real_time_and_web/hi.rb +24 -0
  21. data/examples/hi_web/Gemfile +3 -0
  22. data/examples/hi_web/hi.gif +0 -0
  23. data/examples/hi_web/hi.rb +14 -0
  24. data/lib/slack-ruby-client.rb +23 -0
  25. data/lib/slack.rb +1 -0
  26. data/lib/slack/config.rb +17 -0
  27. data/lib/slack/real_time/api/message.rb +20 -0
  28. data/lib/slack/real_time/api/message_id.rb +14 -0
  29. data/lib/slack/real_time/api/ping.rb +16 -0
  30. data/lib/slack/real_time/api/typing.rb +17 -0
  31. data/lib/slack/real_time/client.rb +91 -0
  32. data/lib/slack/real_time/socket.rb +41 -0
  33. data/lib/slack/version.rb +3 -0
  34. data/lib/slack/web/api/endpoints.rb +39 -0
  35. data/lib/slack/web/api/endpoints/api.rb +25 -0
  36. data/lib/slack/web/api/endpoints/auth.rb +21 -0
  37. data/lib/slack/web/api/endpoints/channels.rb +216 -0
  38. data/lib/slack/web/api/endpoints/chat.rb +78 -0
  39. data/lib/slack/web/api/endpoints/emoji.rb +21 -0
  40. data/lib/slack/web/api/endpoints/files.rb +76 -0
  41. data/lib/slack/web/api/endpoints/groups.rb +229 -0
  42. data/lib/slack/web/api/endpoints/im.rb +82 -0
  43. data/lib/slack/web/api/endpoints/oauth.rb +32 -0
  44. data/lib/slack/web/api/endpoints/presence.rb +24 -0
  45. data/lib/slack/web/api/endpoints/rtm.rb +21 -0
  46. data/lib/slack/web/api/endpoints/search.rb +68 -0
  47. data/lib/slack/web/api/endpoints/stars.rb +23 -0
  48. data/lib/slack/web/api/endpoints/users.rb +70 -0
  49. data/lib/slack/web/api/error.rb +8 -0
  50. data/lib/slack/web/api/schema/method.json +45 -0
  51. data/lib/slack/web/api/tasks/generate.rake +37 -0
  52. data/lib/slack/web/api/templates/endpoints.erb +17 -0
  53. data/lib/slack/web/api/templates/method.erb +39 -0
  54. data/lib/slack/web/client.rb +17 -0
  55. data/lib/slack/web/config.rb +36 -0
  56. data/lib/slack/web/faraday/connection.rb +25 -0
  57. data/lib/slack/web/faraday/request.rb +39 -0
  58. data/lib/slack/web/faraday/response/raise_error.rb +14 -0
  59. data/lib/slack_ruby_client.rb +1 -0
  60. data/screenshots/register-bot.png +0 -0
  61. data/slack-ruby-client.gemspec +28 -0
  62. data/spec/fixtures/slack/web/auth_test_error.yml +48 -0
  63. data/spec/fixtures/slack/web/auth_test_success.yml +57 -0
  64. data/spec/fixtures/slack/web/rtm_start.yml +73 -0
  65. data/spec/slack/config_spec.rb +14 -0
  66. data/spec/slack/real_time/api/message_spec.rb +15 -0
  67. data/spec/slack/real_time/api/ping_spec.rb +15 -0
  68. data/spec/slack/real_time/api/typing_spec.rb +15 -0
  69. data/spec/slack/real_time/client_spec.rb +51 -0
  70. data/spec/slack/real_time/socket_spec.rb +42 -0
  71. data/spec/slack/version_spec.rb +7 -0
  72. data/spec/slack/web/api/endpoints/auth_spec.rb +15 -0
  73. data/spec/slack/web/client_spec.rb +31 -0
  74. data/spec/spec_helper.rb +14 -0
  75. data/spec/support/real_time/connected_client.rb +13 -0
  76. data/spec/support/vcr.rb +8 -0
  77. metadata +287 -0
@@ -0,0 +1,3 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gem 'slack-ruby-client', path: '../..'
@@ -0,0 +1,27 @@
1
+ require 'slack-ruby-client'
2
+
3
+ Slack.configure do |config|
4
+ config.token = ENV['SLACK_API_TOKEN']
5
+ fail 'Missing ENV[SLACK_API_TOKEN]!' unless config.token
6
+ end
7
+
8
+ client = Slack::RealTime::Client.new
9
+
10
+ client.on :hello do
11
+ puts 'Successfully connected.'
12
+ end
13
+
14
+ client.on :message do |data|
15
+ puts data
16
+
17
+ client.typing channel: data['channel']
18
+
19
+ case data['text']
20
+ when 'bot hi' then
21
+ client.message channel: data['channel'], text: "Hi <@#{data['user']}>!"
22
+ when /^bot/ then
23
+ client.message channel: data['channel'], text: "Sorry <@#{data['user']}>, what?"
24
+ end
25
+ end
26
+
27
+ client.start!
@@ -0,0 +1,3 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gem 'slack-ruby-client', path: '../..'
@@ -0,0 +1,24 @@
1
+ require 'slack-ruby-client'
2
+
3
+ Slack.configure do |config|
4
+ config.token = ENV['SLACK_API_TOKEN']
5
+ fail 'Missing ENV[SLACK_API_TOKEN]!' unless config.token
6
+ end
7
+
8
+ client = Slack::RealTime::Client.new
9
+
10
+ client.on :hello do
11
+ puts 'Successfully connected.'
12
+ end
13
+
14
+ client.on :message do |data|
15
+ puts data
16
+ case data['text']
17
+ when 'bot hi' then
18
+ client.web_client.chat_postMessage channel: data['channel'], text: "Hi <@#{data['user']}>!"
19
+ when /^bot/ then
20
+ client.web_client.chat_postMessage channel: data['channel'], text: "Sorry <@#{data['user']}>, what?"
21
+ end
22
+ end
23
+
24
+ client.start!
@@ -0,0 +1,3 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gem 'slack-ruby-client', path: '../..'
Binary file
@@ -0,0 +1,14 @@
1
+ require 'slack-ruby-client'
2
+
3
+ Slack.configure do |config|
4
+ config.token = ENV['SLACK_API_TOKEN']
5
+ fail 'Missing ENV[SLACK_API_TOKEN]!' unless config.token
6
+ end
7
+
8
+ client = Slack::Web::Client.new
9
+
10
+ client.auth_test
11
+
12
+ general_channel = client.channels_list['channels'].detect { |c| c['name'] == 't3' }
13
+
14
+ client.chat_postMessage(channel: general_channel['id'], text: 'Hello World', as_user: true)
@@ -0,0 +1,23 @@
1
+ require 'slack/version'
2
+ require 'slack/config'
3
+
4
+ # Web API
5
+ require 'faraday'
6
+ require 'faraday_middleware'
7
+ require 'slack/web/config'
8
+ require 'slack/web/api/error'
9
+ require 'slack/web/faraday/response/raise_error'
10
+ require 'slack/web/faraday/connection'
11
+ require 'slack/web/faraday/request'
12
+ require 'slack/web/api/endpoints'
13
+ require 'slack/web/client'
14
+
15
+ # RealTime API
16
+ require 'faye/websocket'
17
+ require 'eventmachine'
18
+ require 'slack/real_time/socket'
19
+ require 'slack/real_time/api/message_id'
20
+ require 'slack/real_time/api/ping'
21
+ require 'slack/real_time/api/message'
22
+ require 'slack/real_time/api/typing'
23
+ require 'slack/real_time/client'
@@ -0,0 +1 @@
1
+ require 'slack-ruby-client'
@@ -0,0 +1,17 @@
1
+ module Slack
2
+ module Config
3
+ extend self
4
+
5
+ attr_accessor :token
6
+ end
7
+
8
+ class << self
9
+ def configure
10
+ block_given? ? yield(Config) : Config
11
+ end
12
+
13
+ def config
14
+ Config
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,20 @@
1
+ module Slack
2
+ module RealTime
3
+ module Api
4
+ module Message
5
+ #
6
+ # Sends a message to a channel.
7
+ #
8
+ # @option options [channel] :channel
9
+ # Channel to send message to. Can be a public channel, private group or IM channel. Can be an encoded ID, or a name.
10
+ # @option options [Object] :text
11
+ # Text of the message to send. See below for an explanation of formatting.
12
+ def message(options = {})
13
+ throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
14
+ throw ArgumentError.new('Required arguments :text missing') if options[:text].nil?
15
+ send_json({ type: 'message', id: next_id }.merge(options))
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,14 @@
1
+ module Slack
2
+ module RealTime
3
+ module Api
4
+ module MessageId
5
+ private
6
+
7
+ def next_id
8
+ @next_id ||= 0
9
+ @next_id += 1
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,16 @@
1
+ module Slack
2
+ module RealTime
3
+ module Api
4
+ module Ping
5
+ #
6
+ # Clients should try to quickly detect disconnections, even in idle periods, so that users can easily tell the
7
+ # difference between being disconnected and everyone being quiet. Not all web browsers support the WebSocket
8
+ # ping spec, so the RTM protocol also supports ping/pong messages.
9
+ #
10
+ def ping(options = {})
11
+ send_json({ type: 'ping', id: next_id }.merge(options))
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,17 @@
1
+ module Slack
2
+ module RealTime
3
+ module Api
4
+ module Typing
5
+ #
6
+ # Send a typing indicator to indicate that the user is currently writing a message.
7
+ #
8
+ # @option options [channel] :channel
9
+ # Channel to send message to. Can be a public channel, private group or IM channel. Can be an encoded ID, or a name.
10
+ def typing(options = {})
11
+ throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
12
+ send_json({ type: 'typing', id: next_id }.merge(options))
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,91 @@
1
+ module Slack
2
+ module RealTime
3
+ class Client
4
+ class ClientNotStartedError < StandardError; end
5
+ class ClientAlreadyStartedError < StandardError; end
6
+
7
+ include Api::MessageId
8
+ include Api::Ping
9
+ include Api::Message
10
+ include Api::Typing
11
+
12
+ attr_accessor :web_client
13
+
14
+ def initialize
15
+ @callbacks = {}
16
+ @web_client = Slack::Web::Client.new
17
+ end
18
+
19
+ [:url, :team, :self, :users, :channels, :ims, :bots].each do |attr|
20
+ define_method attr do
21
+ @options[attr.to_s] if @options
22
+ end
23
+ end
24
+
25
+ def on(type, &block)
26
+ type = type.to_s
27
+ @callbacks[type] ||= []
28
+ @callbacks[type] << block
29
+ end
30
+
31
+ def start!
32
+ fail ClientAlreadyStartedError if started?
33
+ EM.run do
34
+ @options = web_client.rtm_start
35
+ @socket = Slack::RealTime::Socket.new(@options['url'])
36
+
37
+ @socket.connect! do |ws|
38
+ ws.on :open do |event|
39
+ open(event)
40
+ end
41
+
42
+ ws.on :message do |event|
43
+ dispatch(event)
44
+ end
45
+
46
+ ws.on :close do |event|
47
+ close(event)
48
+ end
49
+ end
50
+ end
51
+ end
52
+
53
+ def stop!
54
+ fail ClientNotStartedError unless started?
55
+ @socket.disconnect! if @socket
56
+ end
57
+
58
+ def started?
59
+ @socket && @socket.connected?
60
+ end
61
+
62
+ protected
63
+
64
+ def send_json(data)
65
+ fail ClientNotStartedError unless started?
66
+ @socket.send_data(data.to_json)
67
+ end
68
+
69
+ def open(_event)
70
+ end
71
+
72
+ def close(_event)
73
+ @socket = nil
74
+ EM.stop
75
+ end
76
+
77
+ def dispatch(event)
78
+ return false unless event.data
79
+ data = JSON.parse(event.data)
80
+ type = data['type']
81
+ return false unless type
82
+ callbacks = @callbacks[type.to_s]
83
+ return false unless callbacks
84
+ callbacks.each do |c|
85
+ c.call(data)
86
+ end
87
+ true
88
+ end
89
+ end
90
+ end
91
+ end
@@ -0,0 +1,41 @@
1
+ module Slack
2
+ module RealTime
3
+ class Socket
4
+ attr_accessor :url
5
+
6
+ def initialize(url)
7
+ @url = url
8
+ end
9
+
10
+ def send_data(data)
11
+ @ws.send(data) if @ws
12
+ end
13
+
14
+ def connect!(&_block)
15
+ return if connected?
16
+
17
+ @ws = Faye::WebSocket::Client.new(url)
18
+
19
+ @ws.on :close do |event|
20
+ close(event)
21
+ end
22
+
23
+ yield @ws if block_given?
24
+ end
25
+
26
+ def disconnect!
27
+ @ws.close if @ws
28
+ end
29
+
30
+ def connected?
31
+ !@ws.nil?
32
+ end
33
+
34
+ protected
35
+
36
+ def close(_event)
37
+ @ws = nil
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,3 @@
1
+ module Slack
2
+ VERSION = '0.1.0'
3
+ end
@@ -0,0 +1,39 @@
1
+ # This file was auto-generated by lib/slack/web/api/tasks/generate.rake
2
+
3
+ require 'slack/web/api/endpoints/api'
4
+ require 'slack/web/api/endpoints/auth'
5
+ require 'slack/web/api/endpoints/channels'
6
+ require 'slack/web/api/endpoints/chat'
7
+ require 'slack/web/api/endpoints/emoji'
8
+ require 'slack/web/api/endpoints/files'
9
+ require 'slack/web/api/endpoints/groups'
10
+ require 'slack/web/api/endpoints/im'
11
+ require 'slack/web/api/endpoints/oauth'
12
+ require 'slack/web/api/endpoints/presence'
13
+ require 'slack/web/api/endpoints/rtm'
14
+ require 'slack/web/api/endpoints/search'
15
+ require 'slack/web/api/endpoints/stars'
16
+ require 'slack/web/api/endpoints/users'
17
+
18
+ module Slack
19
+ module Web
20
+ module Api
21
+ module Endpoints
22
+ include Api
23
+ include Auth
24
+ include Channels
25
+ include Chat
26
+ include Emoji
27
+ include Files
28
+ include Groups
29
+ include Im
30
+ include Oauth
31
+ include Presence
32
+ include Rtm
33
+ include Search
34
+ include Stars
35
+ include Users
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,25 @@
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 Api
8
+ #
9
+ # Checks API calling code.
10
+ #
11
+ # @option options [Object] :error
12
+ # Error response to return
13
+ # @option options [Object] :foo
14
+ # example property to return
15
+ # @see https://api.slack.com/methods/api.test
16
+ # @see https://github.com/slackhq/slack-api-docs/blob/master/methods/api.test.md
17
+ # @see https://github.com/slackhq/slack-api-docs/blob/master/methods/api.test.json
18
+ def api_test(options = {})
19
+ post('api.test', options)
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,21 @@
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 Auth
8
+ #
9
+ # Checks authentication & identity.
10
+ #
11
+ # @see https://api.slack.com/methods/auth.test
12
+ # @see https://github.com/slackhq/slack-api-docs/blob/master/methods/auth.test.md
13
+ # @see https://github.com/slackhq/slack-api-docs/blob/master/methods/auth.test.json
14
+ def auth_test(options = {})
15
+ post('auth.test', options)
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,216 @@
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 Channels
8
+ #
9
+ # Archives a channel.
10
+ #
11
+ # @option options [channel] :channel
12
+ # Channel to archive
13
+ # @see https://api.slack.com/methods/channels.archive
14
+ # @see https://github.com/slackhq/slack-api-docs/blob/master/methods/channels.archive.md
15
+ # @see https://github.com/slackhq/slack-api-docs/blob/master/methods/channels.archive.json
16
+ def channels_archive(options = {})
17
+ throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
18
+ post('channels.archive', options)
19
+ end
20
+
21
+ #
22
+ # Creates a channel.
23
+ #
24
+ # @option options [Object] :name
25
+ # Name of channel to create
26
+ # @see https://api.slack.com/methods/channels.create
27
+ # @see https://github.com/slackhq/slack-api-docs/blob/master/methods/channels.create.md
28
+ # @see https://github.com/slackhq/slack-api-docs/blob/master/methods/channels.create.json
29
+ def channels_create(options = {})
30
+ throw ArgumentError.new('Required arguments :name missing') if options[:name].nil?
31
+ post('channels.create', options)
32
+ end
33
+
34
+ #
35
+ # Fetches history of messages and events from a channel.
36
+ #
37
+ # @option options [channel] :channel
38
+ # Channel to fetch history for.
39
+ # @option options [timestamp] :latest
40
+ # Latest message timestamp to include in results.
41
+ # @option options [timestamp] :oldest
42
+ # Oldest message timestamp to include in results.
43
+ # @option options [Object] :count
44
+ # Number of messages to return, between 1 and 1000.
45
+ # @see https://api.slack.com/methods/channels.history
46
+ # @see https://github.com/slackhq/slack-api-docs/blob/master/methods/channels.history.md
47
+ # @see https://github.com/slackhq/slack-api-docs/blob/master/methods/channels.history.json
48
+ def channels_history(options = {})
49
+ throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
50
+ post('channels.history', options)
51
+ end
52
+
53
+ #
54
+ # Gets information about a channel.
55
+ #
56
+ # @option options [channel] :channel
57
+ # Channel to get info on
58
+ # @see https://api.slack.com/methods/channels.info
59
+ # @see https://github.com/slackhq/slack-api-docs/blob/master/methods/channels.info.md
60
+ # @see https://github.com/slackhq/slack-api-docs/blob/master/methods/channels.info.json
61
+ def channels_info(options = {})
62
+ throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
63
+ post('channels.info', options)
64
+ end
65
+
66
+ #
67
+ # Invites a user to a channel.
68
+ #
69
+ # @option options [channel] :channel
70
+ # Channel to invite user to.
71
+ # @option options [user] :user
72
+ # User to invite to channel.
73
+ # @see https://api.slack.com/methods/channels.invite
74
+ # @see https://github.com/slackhq/slack-api-docs/blob/master/methods/channels.invite.md
75
+ # @see https://github.com/slackhq/slack-api-docs/blob/master/methods/channels.invite.json
76
+ def channels_invite(options = {})
77
+ throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
78
+ throw ArgumentError.new('Required arguments :user missing') if options[:user].nil?
79
+ post('channels.invite', options)
80
+ end
81
+
82
+ #
83
+ # Joins a channel, creating it if needed.
84
+ #
85
+ # @option options [Object] :name
86
+ # Name of channel to join
87
+ # @see https://api.slack.com/methods/channels.join
88
+ # @see https://github.com/slackhq/slack-api-docs/blob/master/methods/channels.join.md
89
+ # @see https://github.com/slackhq/slack-api-docs/blob/master/methods/channels.join.json
90
+ def channels_join(options = {})
91
+ throw ArgumentError.new('Required arguments :name missing') if options[:name].nil?
92
+ post('channels.join', options)
93
+ end
94
+
95
+ #
96
+ # Removes a user from a channel.
97
+ #
98
+ # @option options [channel] :channel
99
+ # Channel to remove user from.
100
+ # @option options [user] :user
101
+ # User to remove from channel.
102
+ # @see https://api.slack.com/methods/channels.kick
103
+ # @see https://github.com/slackhq/slack-api-docs/blob/master/methods/channels.kick.md
104
+ # @see https://github.com/slackhq/slack-api-docs/blob/master/methods/channels.kick.json
105
+ def channels_kick(options = {})
106
+ throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
107
+ throw ArgumentError.new('Required arguments :user missing') if options[:user].nil?
108
+ post('channels.kick', options)
109
+ end
110
+
111
+ #
112
+ # Leaves a channel.
113
+ #
114
+ # @option options [channel] :channel
115
+ # Channel to leave
116
+ # @see https://api.slack.com/methods/channels.leave
117
+ # @see https://github.com/slackhq/slack-api-docs/blob/master/methods/channels.leave.md
118
+ # @see https://github.com/slackhq/slack-api-docs/blob/master/methods/channels.leave.json
119
+ def channels_leave(options = {})
120
+ throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
121
+ post('channels.leave', options)
122
+ end
123
+
124
+ #
125
+ # Lists all channels in a Slack team.
126
+ #
127
+ # @option options [Object] :exclude_archived
128
+ # Don't return archived channels.
129
+ # @see https://api.slack.com/methods/channels.list
130
+ # @see https://github.com/slackhq/slack-api-docs/blob/master/methods/channels.list.md
131
+ # @see https://github.com/slackhq/slack-api-docs/blob/master/methods/channels.list.json
132
+ def channels_list(options = {})
133
+ post('channels.list', options)
134
+ end
135
+
136
+ #
137
+ # Sets the read cursor in a channel.
138
+ #
139
+ # @option options [channel] :channel
140
+ # Channel to set reading cursor in.
141
+ # @option options [timestamp] :ts
142
+ # Timestamp of the most recently seen message.
143
+ # @see https://api.slack.com/methods/channels.mark
144
+ # @see https://github.com/slackhq/slack-api-docs/blob/master/methods/channels.mark.md
145
+ # @see https://github.com/slackhq/slack-api-docs/blob/master/methods/channels.mark.json
146
+ def channels_mark(options = {})
147
+ throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
148
+ throw ArgumentError.new('Required arguments :ts missing') if options[:ts].nil?
149
+ post('channels.mark', options)
150
+ end
151
+
152
+ #
153
+ # Renames a channel.
154
+ #
155
+ # @option options [channel] :channel
156
+ # Channel to rename
157
+ # @option options [Object] :name
158
+ # New name for channel.
159
+ # @see https://api.slack.com/methods/channels.rename
160
+ # @see https://github.com/slackhq/slack-api-docs/blob/master/methods/channels.rename.md
161
+ # @see https://github.com/slackhq/slack-api-docs/blob/master/methods/channels.rename.json
162
+ def channels_rename(options = {})
163
+ throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
164
+ throw ArgumentError.new('Required arguments :name missing') if options[:name].nil?
165
+ post('channels.rename', options)
166
+ end
167
+
168
+ #
169
+ # Sets the purpose for a channel.
170
+ #
171
+ # @option options [channel] :channel
172
+ # Channel to set the purpose of
173
+ # @option options [Object] :purpose
174
+ # The new purpose
175
+ # @see https://api.slack.com/methods/channels.setPurpose
176
+ # @see https://github.com/slackhq/slack-api-docs/blob/master/methods/channels.setPurpose.md
177
+ # @see https://github.com/slackhq/slack-api-docs/blob/master/methods/channels.setPurpose.json
178
+ def channels_setPurpose(options = {})
179
+ throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
180
+ throw ArgumentError.new('Required arguments :purpose missing') if options[:purpose].nil?
181
+ post('channels.setPurpose', options)
182
+ end
183
+
184
+ #
185
+ # Sets the topic for a channel.
186
+ #
187
+ # @option options [channel] :channel
188
+ # Channel to set the topic of
189
+ # @option options [Object] :topic
190
+ # The new topic
191
+ # @see https://api.slack.com/methods/channels.setTopic
192
+ # @see https://github.com/slackhq/slack-api-docs/blob/master/methods/channels.setTopic.md
193
+ # @see https://github.com/slackhq/slack-api-docs/blob/master/methods/channels.setTopic.json
194
+ def channels_setTopic(options = {})
195
+ throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
196
+ throw ArgumentError.new('Required arguments :topic missing') if options[:topic].nil?
197
+ post('channels.setTopic', options)
198
+ end
199
+
200
+ #
201
+ # Unarchives a channel.
202
+ #
203
+ # @option options [channel] :channel
204
+ # Channel to unarchive
205
+ # @see https://api.slack.com/methods/channels.unarchive
206
+ # @see https://github.com/slackhq/slack-api-docs/blob/master/methods/channels.unarchive.md
207
+ # @see https://github.com/slackhq/slack-api-docs/blob/master/methods/channels.unarchive.json
208
+ def channels_unarchive(options = {})
209
+ throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
210
+ post('channels.unarchive', options)
211
+ end
212
+ end
213
+ end
214
+ end
215
+ end
216
+ end