Class: SlackbotFrd::SlackMethods::GroupsInvite

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of GroupsInvite.



17
18
19
20
21
22
# File 'lib/slackbot_frd/slack_methods/group_invite.rb', line 17

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/group_invite.rb', line 10

def response
  @response
end

Class Method Details

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



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

def self.invite(token:, user:, channel:)
  SlackbotFrd::Log.info(user.to_s)
  GroupsInvite.new(token: token, user: user, channel: channel).run
end

Instance Method Details

#runObject



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/slackbot_frd/slack_methods/group_invite.rb', line 24

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