Class: SlackbotFrd::SlackMethods::ChannelsInvite

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(token:, user:, channel:) ⇒ ChannelsInvite

Returns a new instance of ChannelsInvite.



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

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

Instance Attribute Details

#responseObject (readonly)

Returns the value of attribute response.



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

def response
  @response
end

Class Method Details

.invite(token:, user:, channel:) ⇒ Object



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

def self.invite(token:, user:, channel:)
  ChannelsInvite.new(token: token, user: user, channel: channel).run
end

Instance Method Details

#runObject



22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/slackbot_frd/slack_methods/channels_invite.rb', line 22

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