Module: Slack::Web::Channels
- Included in:
- Slack::Web
- Defined in:
- lib/slack/web/channels.rb
Overview
Module for the channels methods. Get info on your team's Slack channels, create or archive channels, invite users, set the topic and purpose, and mark a channel as read.
Constant Summary collapse
- SCOPE =
Endpoint scope
'channels'
Instance Method Summary collapse
-
#channels_archive(params = {}) ⇒ Object
Archives a channel.
-
#channels_create(params = {}) ⇒ Object
Creates a channel.
-
#channels_history(params = {}) ⇒ Object
Fetches history of messages and events from a channel.
-
#channels_info(params = {}) ⇒ Object
Gets information about a channel.
-
#channels_invite(params = {}) ⇒ Object
Invites a user to a channel.
-
#channels_join(params = {}) ⇒ Object
Joins a channel, creating it if needed.
-
#channels_kick(params = {}) ⇒ Object
Removes a user from a channel.
-
#channels_leave(params = {}) ⇒ Object
Leaves a channel.
-
#channels_list(params = {}) ⇒ Object
Lists all channels in a Slack team.
-
#channels_mark(params = {}) ⇒ Object
Sets the read cursor in a channel.
-
#channels_rename(params = {}) ⇒ Object
Renames a channel.
-
#channels_set_purpose(params = {}) ⇒ Object
Sets the purpose for a channel.
-
#channels_set_topic(params = {}) ⇒ Object
Sets the topic for a channel.
-
#channels_unarchive(params = {}) ⇒ Object
Unarchives a channel.
Instance Method Details
#channels_archive(params = {}) ⇒ Object
Archives a channel.
21 22 23 24 25 |
# File 'lib/slack/web/channels.rb', line 21 def channels_archive(params = {}) fail ArgumentError, "Required arguments 'channel' missing" if params['channel'].nil? response = @session.do_post "#{SCOPE}.archive", params Slack.parse_response(response) end |
#channels_create(params = {}) ⇒ Object
Creates a channel.
35 36 37 38 39 |
# File 'lib/slack/web/channels.rb', line 35 def channels_create(params = {}) fail ArgumentError, "Required arguments 'name' missing" if params['name'].nil? response = @session.do_post "#{SCOPE}.create", params Slack.parse_response(response) end |
#channels_history(params = {}) ⇒ Object
Fetches history of messages and events from a channel.
57 58 59 60 61 |
# File 'lib/slack/web/channels.rb', line 57 def channels_history(params = {}) fail ArgumentError, "Required arguments 'channel' missing" if params['channel'].nil? response = @session.do_post "#{SCOPE}.history", params Slack.parse_response(response) end |
#channels_info(params = {}) ⇒ Object
Gets information about a channel.
71 72 73 74 75 |
# File 'lib/slack/web/channels.rb', line 71 def channels_info(params = {}) fail ArgumentError, "Required arguments 'channel' missing" if params['channel'].nil? response = @session.do_post "#{SCOPE}.info", params Slack.parse_response(response) end |
#channels_invite(params = {}) ⇒ Object
Invites a user to a channel.
87 88 89 90 91 92 |
# File 'lib/slack/web/channels.rb', line 87 def channels_invite(params = {}) fail ArgumentError, "Required arguments 'channel' missing" if params['channel'].nil? fail ArgumentError, "Required arguments 'user' missing" if params['user'].nil? response = @session.do_post "#{SCOPE}.invite", params Slack.parse_response(response) end |
#channels_join(params = {}) ⇒ Object
Joins a channel, creating it if needed.
102 103 104 105 106 |
# File 'lib/slack/web/channels.rb', line 102 def channels_join(params = {}) fail ArgumentError, "Required arguments 'name' missing" if params['name'].nil? response = @session.do_post "#{SCOPE}.join", params Slack.parse_response(response) end |
#channels_kick(params = {}) ⇒ Object
Removes a user from a channel.
118 119 120 121 122 123 |
# File 'lib/slack/web/channels.rb', line 118 def channels_kick(params = {}) fail ArgumentError, "Required arguments 'channel' missing" if params['channel'].nil? fail ArgumentError, "Required arguments 'user' missing" if params['user'].nil? response = @session.do_post "#{SCOPE}.kick", params Slack.parse_response(response) end |
#channels_leave(params = {}) ⇒ Object
Leaves a channel.
132 133 134 135 136 |
# File 'lib/slack/web/channels.rb', line 132 def channels_leave(params = {}) fail ArgumentError, "Required arguments 'channel' missing" if params['channel'].nil? response = @session.do_post "#{SCOPE}.leave", params Slack.parse_response(response) end |
#channels_list(params = {}) ⇒ Object
Lists all channels in a Slack team.
146 147 148 149 |
# File 'lib/slack/web/channels.rb', line 146 def channels_list(params = {}) response = @session.do_post "#{SCOPE}.list", params Slack.parse_response(response) end |
#channels_mark(params = {}) ⇒ Object
Sets the read cursor in a channel.
161 162 163 164 165 166 |
# File 'lib/slack/web/channels.rb', line 161 def channels_mark(params = {}) fail ArgumentError, "Required arguments 'channel' missing" if params['channel'].nil? fail ArgumentError, "Required arguments 'ts' missing" if params['ts'].nil? response = @session.do_post "#{SCOPE}.mark", params Slack.parse_response(response) end |
#channels_rename(params = {}) ⇒ Object
Renames a channel.
178 179 180 181 182 183 |
# File 'lib/slack/web/channels.rb', line 178 def channels_rename(params = {}) fail ArgumentError, "Required arguments 'channel' missing" if params['channel'].nil? fail ArgumentError, "Required arguments 'name' missing" if params['name'].nil? response = @session.do_post "#{SCOPE}.rename", params Slack.parse_response(response) end |
#channels_set_purpose(params = {}) ⇒ Object
Sets the purpose for a channel.
195 196 197 198 199 200 |
# File 'lib/slack/web/channels.rb', line 195 def channels_set_purpose(params = {}) fail ArgumentError, "Required arguments 'channel' missing" if params['channel'].nil? fail ArgumentError, "Required arguments 'purpose' missing" if params['purpose'].nil? response = @session.do_post "#{SCOPE}.setPurpose", params Slack.parse_response(response) end |
#channels_set_topic(params = {}) ⇒ Object
Sets the topic for a channel.
212 213 214 215 216 217 |
# File 'lib/slack/web/channels.rb', line 212 def channels_set_topic(params = {}) fail ArgumentError, "Required arguments 'channel' missing" if params['channel'].nil? fail ArgumentError, "Required arguments 'topic' missing" if params['topic'].nil? response = @session.do_post "#{SCOPE}.setTopic", params Slack.parse_response(response) end |
#channels_unarchive(params = {}) ⇒ Object
Unarchives a channel.
227 228 229 230 231 |
# File 'lib/slack/web/channels.rb', line 227 def channels_unarchive(params = {}) fail ArgumentError, "Required arguments 'channel' missing" if params['channel'].nil? response = @session.do_post "#{SCOPE}.unarchive", params Slack.parse_response(response) end |