Module: Slack::Web::Api::Endpoints::Channels

Included in:
Slack::Web::Api::Endpoints
Defined in:
lib/slack/web/api/endpoints/channels.rb

Instance Method Summary collapse

Instance Method Details

#channels_archive(options = {}) ⇒ Object

Archives a channel.

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :channel (channel)

    Channel to archive.

See Also:



15
16
17
18
19
# File 'lib/slack/web/api/endpoints/channels.rb', line 15

def channels_archive(options = {})
  throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
  options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
  post('channels.archive', options)
end

#channels_create(options = {}) ⇒ Object

Creates a channel.

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :name (Object)

    Name of channel to create.

  • :validate (Object)

    Whether to return errors on invalid channel name instead of modifying it to meet the specified criteria.

See Also:



30
31
32
33
# File 'lib/slack/web/api/endpoints/channels.rb', line 30

def channels_create(options = {})
  throw ArgumentError.new('Required arguments :name missing') if options[:name].nil?
  post('channels.create', options)
end

#channels_history(options = {}) ⇒ Object

Fetches history of messages and events from a channel.

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :channel (channel)

    Channel to fetch history for.

  • :inclusive (Object)

    Include messages with latest or oldest timestamp in results.

  • :latest (timestamp)

    End of time range of messages to include in results.

  • :oldest (timestamp)

    Start of time range of messages to include in results.

  • :unreads (Object)

    Include unread_count_display in the output?.

See Also:



50
51
52
53
54
# File 'lib/slack/web/api/endpoints/channels.rb', line 50

def channels_history(options = {})
  throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
  options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
  post('channels.history', options)
end

#channels_info(options = {}) ⇒ Object

Gets information about a channel.

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :channel (channel)

    Channel to get info on.

See Also:



63
64
65
66
67
# File 'lib/slack/web/api/endpoints/channels.rb', line 63

def channels_info(options = {})
  throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
  options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
  post('channels.info', options)
end

#channels_invite(options = {}) ⇒ Object

Invites a user to a channel.

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :channel (channel)

    Channel to invite user to.

  • :user (user)

    User to invite to channel.

See Also:



78
79
80
81
82
83
84
# File 'lib/slack/web/api/endpoints/channels.rb', line 78

def channels_invite(options = {})
  throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
  throw ArgumentError.new('Required arguments :user missing') if options[:user].nil?
  options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
  options = options.merge(user: users_id(options)['user']['id']) if options[:user]
  post('channels.invite', options)
end

#channels_join(options = {}) ⇒ Object

Joins a channel, creating it if needed.

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :name (Object)

    Name of channel to join.

  • :validate (Object)

    Whether to return errors on invalid channel name instead of modifying it to meet the specified criteria.

See Also:



95
96
97
98
# File 'lib/slack/web/api/endpoints/channels.rb', line 95

def channels_join(options = {})
  throw ArgumentError.new('Required arguments :name missing') if options[:name].nil?
  post('channels.join', options)
end

#channels_kick(options = {}) ⇒ Object

Removes a user from a channel.

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :channel (channel)

    Channel to remove user from.

  • :user (user)

    User to remove from channel.

See Also:



109
110
111
112
113
114
115
# File 'lib/slack/web/api/endpoints/channels.rb', line 109

def channels_kick(options = {})
  throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
  throw ArgumentError.new('Required arguments :user missing') if options[:user].nil?
  options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
  options = options.merge(user: users_id(options)['user']['id']) if options[:user]
  post('channels.kick', options)
end

#channels_leave(options = {}) ⇒ Object

Leaves a channel.

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :channel (channel)

    Channel to leave.

See Also:



124
125
126
127
128
# File 'lib/slack/web/api/endpoints/channels.rb', line 124

def channels_leave(options = {})
  throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
  options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
  post('channels.leave', options)
end

#channels_list(options = {}) ⇒ Object

Lists all channels in a Slack team.

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :exclude_archived (Object)

    Exclude archived channels from the list.

  • :exclude_members (Object)

    Exclude the members collection from each channel.

See Also:



139
140
141
# File 'lib/slack/web/api/endpoints/channels.rb', line 139

def channels_list(options = {})
  post('channels.list', options)
end

#channels_mark(options = {}) ⇒ Object

Sets the read cursor in a channel.

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :channel (channel)

    Channel to set reading cursor in.

  • :ts (timestamp)

    Timestamp of the most recently seen message.

See Also:



152
153
154
155
156
157
# File 'lib/slack/web/api/endpoints/channels.rb', line 152

def channels_mark(options = {})
  throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
  throw ArgumentError.new('Required arguments :ts missing') if options[:ts].nil?
  options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
  post('channels.mark', options)
end

#channels_rename(options = {}) ⇒ Object

Renames a channel.

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :channel (channel)

    Channel to rename.

  • :name (Object)

    New name for channel.

  • :validate (Object)

    Whether to return errors on invalid channel name instead of modifying it to meet the specified criteria.

See Also:



170
171
172
173
174
175
# File 'lib/slack/web/api/endpoints/channels.rb', line 170

def channels_rename(options = {})
  throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
  throw ArgumentError.new('Required arguments :name missing') if options[:name].nil?
  options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
  post('channels.rename', options)
end

#channels_replies(options = {}) ⇒ Object

Retrieve a thread of messages posted to a channel

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :channel (channel)

    Channel to fetch thread from.

  • :thread_ts (Object)

    Unique identifier of a thread’s parent message.

See Also:



186
187
188
189
190
191
# File 'lib/slack/web/api/endpoints/channels.rb', line 186

def channels_replies(options = {})
  throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
  throw ArgumentError.new('Required arguments :thread_ts missing') if options[:thread_ts].nil?
  options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
  post('channels.replies', options)
end

#channels_setPurpose(options = {}) ⇒ Object

Sets the purpose for a channel.

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :channel (channel)

    Channel to set the purpose of.

  • :purpose (Object)

    The new purpose.

See Also:



202
203
204
205
206
207
# File 'lib/slack/web/api/endpoints/channels.rb', line 202

def channels_setPurpose(options = {})
  throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
  throw ArgumentError.new('Required arguments :purpose missing') if options[:purpose].nil?
  options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
  post('channels.setPurpose', options)
end

#channels_setTopic(options = {}) ⇒ Object

Sets the topic for a channel.

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :channel (channel)

    Channel to set the topic of.

  • :topic (Object)

    The new topic.

See Also:



218
219
220
221
222
223
# File 'lib/slack/web/api/endpoints/channels.rb', line 218

def channels_setTopic(options = {})
  throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
  throw ArgumentError.new('Required arguments :topic missing') if options[:topic].nil?
  options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
  post('channels.setTopic', options)
end

#channels_unarchive(options = {}) ⇒ Object

Unarchives a channel.

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :channel (channel)

    Channel to unarchive.

See Also:



232
233
234
235
236
# File 'lib/slack/web/api/endpoints/channels.rb', line 232

def channels_unarchive(options = {})
  throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
  options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
  post('channels.unarchive', options)
end