Class: SlackbotFrd::SlackMethods::ChannelsInfo

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/slackbot_frd/slack_methods/channels_info.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(token:, channel:) ⇒ ChannelsInfo

Returns a new instance of ChannelsInfo.



16
17
18
19
# File 'lib/slackbot_frd/slack_methods/channels_info.rb', line 16

def initialize(token:, channel:)
  @token = token
  @channel = channel
end

Instance Attribute Details

#responseObject (readonly)

Returns the value of attribute response.



10
11
12
# File 'lib/slackbot_frd/slack_methods/channels_info.rb', line 10

def response
  @response
end

Class Method Details

.members(token:, channel:) ⇒ Object



12
13
14
# File 'lib/slackbot_frd/slack_methods/channels_info.rb', line 12

def self.members(token:, channel:)
  ChannelsInfo.new(token: token, channel: channel).connect.members
end

Instance Method Details

#connectObject



21
22
23
24
25
# File 'lib/slackbot_frd/slack_methods/channels_info.rb', line 21

def connect
  @response = JSON.parse(self.class.post('', :body => { token: @token, channel: @channel } ).body)
  ValidateSlack.response(@response)
  self
end

#membersObject Also known as: users



27
28
29
30
31
32
33
# File 'lib/slackbot_frd/slack_methods/channels_info.rb', line 27

def members
  if @response['channel']
    @response['channel']['members']
  else
    []
  end
end