Class: SlackbotFrd::SlackMethods::ChannelsList
- Inherits:
-
Object
- Object
- SlackbotFrd::SlackMethods::ChannelsList
- Includes:
- HTTParty
- Defined in:
- lib/slackbot_frd/slack_methods/channels_list.rb
Instance Attribute Summary collapse
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Instance Method Summary collapse
- #connect ⇒ Object
- #ids_to_names ⇒ Object
-
#initialize(token) ⇒ ChannelsList
constructor
A new instance of ChannelsList.
- #names_to_ids ⇒ Object
Constructor Details
#initialize(token) ⇒ ChannelsList
Returns a new instance of ChannelsList.
12 13 14 |
# File 'lib/slackbot_frd/slack_methods/channels_list.rb', line 12 def initialize(token) @token = token end |
Instance Attribute Details
#response ⇒ Object (readonly)
Returns the value of attribute response.
10 11 12 |
# File 'lib/slackbot_frd/slack_methods/channels_list.rb', line 10 def response @response end |
Instance Method Details
#connect ⇒ Object
16 17 18 19 20 |
# 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 ⇒ Object
22 23 24 25 26 27 28 |
# 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 ⇒ Object
30 31 32 33 34 35 36 |
# 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 |