module Slack::Web::Api::Endpoints::Channels

Public Instance Methods

channels_archive(options = {}) click to toggle source

Archives a channel.

@option options [channel] :channel

Channel to archive.

@see api.slack.com/methods/channels.archive @see github.com/slack-ruby/slack-api-ref/blob/master/methods/channels/channels.archive.json

# 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 = {}) click to toggle source

Creates a channel.

@option options [Object] :name

Name of channel to create.

@option options [Object] :validate

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

@see api.slack.com/methods/channels.create @see github.com/slack-ruby/slack-api-ref/blob/master/methods/channels/channels.create.json

# 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_delete(options = {}) click to toggle source

Delete a channel (undocumented)

@option options [channel] :channel

Channel to delete.

@see github.com/slack-ruby/slack-api-ref/blob/master/methods/undocumented/channels/channels.delete.json

# File lib/slack/web/api/endpoints/channels.rb, line 41
def channels_delete(options = {})
  throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
  options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
  logger.warn('The channels.delete method is undocumented.')
  post('channels.delete', options)
end
channels_history(options = {}) click to toggle source

Fetches history of messages and events from a channel.

@option options [channel] :channel

Channel to fetch history for.

@option options [Object] :inclusive

Include messages with latest or oldest timestamp in results.

@option options [timestamp] :latest

End of time range of messages to include in results.

@option options [timestamp] :oldest

Start of time range of messages to include in results.

@option options [Object] :unreads

Include unread_count_display in the output?.

@see api.slack.com/methods/channels.history @see github.com/slack-ruby/slack-api-ref/blob/master/methods/channels/channels.history.json

# File lib/slack/web/api/endpoints/channels.rb, line 63
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 = {}) click to toggle source

Gets information about a channel.

@option options [channel] :channel

Channel to get info on.

@option options [Object] :include_locale

Set this to true to receive the locale for this channel. Defaults to false.

@see api.slack.com/methods/channels.info @see github.com/slack-ruby/slack-api-ref/blob/master/methods/channels/channels.info.json

# File lib/slack/web/api/endpoints/channels.rb, line 78
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 = {}) click to toggle source

Invites a user to a channel.

@option options [channel] :channel

Channel to invite user to.

@option options [user] :user

User to invite to channel.

@see api.slack.com/methods/channels.invite @see github.com/slack-ruby/slack-api-ref/blob/master/methods/channels/channels.invite.json

# File lib/slack/web/api/endpoints/channels.rb, line 93
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 = {}) click to toggle source

Joins a channel, creating it if needed.

@option options [Object] :name

Name of channel to join.

@option options [Object] :validate

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

@see api.slack.com/methods/channels.join @see github.com/slack-ruby/slack-api-ref/blob/master/methods/channels/channels.join.json

# File lib/slack/web/api/endpoints/channels.rb, line 110
def channels_join(options = {})
  throw ArgumentError.new('Required arguments :name missing') if options[:name].nil?
  post('channels.join', options)
end
channels_kick(options = {}) click to toggle source

Removes a user from a channel.

@option options [channel] :channel

Channel to remove user from.

@option options [user] :user

User to remove from channel.

@see api.slack.com/methods/channels.kick @see github.com/slack-ruby/slack-api-ref/blob/master/methods/channels/channels.kick.json

# File lib/slack/web/api/endpoints/channels.rb, line 124
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 = {}) click to toggle source

Leaves a channel.

@option options [channel] :channel

Channel to leave.

@see api.slack.com/methods/channels.leave @see github.com/slack-ruby/slack-api-ref/blob/master/methods/channels/channels.leave.json

# File lib/slack/web/api/endpoints/channels.rb, line 139
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 = {}) { |page| ... } click to toggle source

Lists all channels in a Slack team.

@option options [Object] :cursor

Paginate through collections of data by setting the cursor parameter to a next_cursor attribute returned by a previous request's response_metadata. Default value fetches the first "page" of the collection. See pagination for more detail.

@option options [Object] :exclude_archived

Exclude archived channels from the list.

@option options [Object] :exclude_members

Exclude the members collection from each channel.

@option options [Object] :limit

The maximum number of items to return. Fewer than the requested number of items may be returned, even if the end of the users list hasn't been reached.

@see api.slack.com/methods/channels.list @see github.com/slack-ruby/slack-api-ref/blob/master/methods/channels/channels.list.json

# File lib/slack/web/api/endpoints/channels.rb, line 158
def channels_list(options = {})
  if block_given?
    Pagination::Cursor.new(self, :channels_list, options).each do |page|
      yield page
    end
  else
    post('channels.list', options)
  end
end
channels_mark(options = {}) click to toggle source

Sets the read cursor in a channel.

@option options [channel] :channel

Channel to set reading cursor in.

@option options [timestamp] :ts

Timestamp of the most recently seen message.

@see api.slack.com/methods/channels.mark @see github.com/slack-ruby/slack-api-ref/blob/master/methods/channels/channels.mark.json

# File lib/slack/web/api/endpoints/channels.rb, line 177
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 = {}) click to toggle source

Renames a channel.

@option options [channel] :channel

Channel to rename.

@option options [Object] :name

New name for channel.

@option options [Object] :validate

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

@see api.slack.com/methods/channels.rename @see github.com/slack-ruby/slack-api-ref/blob/master/methods/channels/channels.rename.json

# File lib/slack/web/api/endpoints/channels.rb, line 195
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 = {}) click to toggle source

Retrieve a thread of messages posted to a channel

@option options [channel] :channel

Channel to fetch thread from.

@option options [Object] :thread_ts

Unique identifier of a thread's parent message.

@see api.slack.com/methods/channels.replies @see github.com/slack-ruby/slack-api-ref/blob/master/methods/channels/channels.replies.json

# File lib/slack/web/api/endpoints/channels.rb, line 211
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 = {}) click to toggle source

Sets the purpose for a channel.

@option options [channel] :channel

Channel to set the purpose of.

@option options [Object] :purpose

The new purpose.

@see api.slack.com/methods/channels.setPurpose @see github.com/slack-ruby/slack-api-ref/blob/master/methods/channels/channels.setPurpose.json

# File lib/slack/web/api/endpoints/channels.rb, line 227
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 = {}) click to toggle source

Sets the topic for a channel.

@option options [channel] :channel

Channel to set the topic of.

@option options [Object] :topic

The new topic.

@see api.slack.com/methods/channels.setTopic @see github.com/slack-ruby/slack-api-ref/blob/master/methods/channels/channels.setTopic.json

# File lib/slack/web/api/endpoints/channels.rb, line 243
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 = {}) click to toggle source

Unarchives a channel.

@option options [channel] :channel

Channel to unarchive.

@see api.slack.com/methods/channels.unarchive @see github.com/slack-ruby/slack-api-ref/blob/master/methods/channels/channels.unarchive.json

# File lib/slack/web/api/endpoints/channels.rb, line 257
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