class SlackbotFrd::SlackMethods::ChannelsList

Attributes

response[R]

Public Class Methods

new(token) click to toggle source
# File lib/slackbot_frd/slack_methods/channels_list.rb, line 12
def initialize(token)
  @token = token
end

Public Instance Methods

connect() click to toggle source
# File lib/slackbot_frd/slack_methods/channels_list.rb, line 16
def connect
  @response = JSON.parse(self.class.post('', :body => { token: @token } ).body)
  ValidateSlack.response(@response)
  self
end
ids_to_names() click to toggle source
# File lib/slackbot_frd/slack_methods/channels_list.rb, line 22
def ids_to_names
  retval = {}
  @response['channels'].each do |channel|
    retval[channel['id']] = channel['name']
  end
  retval
end
names_to_ids() click to toggle source
# File lib/slackbot_frd/slack_methods/channels_list.rb, line 30
def names_to_ids
  retval = {}
  @response['channels'].each do |channel|
    retval[channel['name']] = channel['id']
  end
  retval
end