Module: Slack::Web::Api::Mixins::Conversations

Includes:
Ids
Included in:
Endpoints
Defined in:
lib/slack/web/api/mixins/conversations.id.rb

Instance Method Summary collapse

Instance Method Details

#conversations_id(options = {}) ⇒ Object

This method returns a channel ID given a channel name.

Parameters:

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

    a customizable set of options

Options Hash (options):

  • :channel (channel)

    Channel to get ID for, prefixed with #.

  • :team_id (string)

    The team id to search for channels in, required if token belongs to org-wide app. This field will be ignored if the API call is sent using a workspace-level token.

  • :id_exclude_archived (boolean)

    Set to true to exclude archived channels from the search

  • :id_limit (integer)

    The page size used for conversations_list calls required to find the channel’s ID

  • :id_types (string)

    The types of conversations to use when searching for the ID. A comma-separated list containing one or more of public_channel, private_channel, mpim, im

Raises:

  • (ArgumentError)


25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/slack/web/api/mixins/conversations.id.rb', line 25

def conversations_id(options = {})
  name = options[:channel]
  raise ArgumentError, 'Required arguments :channel missing' if name.nil?

  id_for(
    key: :channel,
    name: name,
    prefix: '#',
    enum_method: :conversations_list,
    list_method: :channels,
    options: {
      team_id: options.fetch(:team_id, nil),
      exclude_archived: options.fetch(:id_exclude_archived, nil),
      limit: options.fetch(:id_limit, Slack::Web.config.conversations_id_page_size),
      types: options.fetch(:id_types, nil)
    }.compact
  )
end