Class: SlackbotFrd::SlackMethods::UsersInfo

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(token:, user_id:) ⇒ UsersInfo

Returns a new instance of UsersInfo.



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

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

Instance Attribute Details

#responseObject (readonly)

Returns the value of attribute response.



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

def response
  @response
end

Class Method Details

.info(token:, user_id:) ⇒ Object



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

def self.info(token:, user_id:)
  UsersInfo.new(token: token, user_id: user_id).connect.info
end

Instance Method Details

#connectObject



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

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

#infoObject



27
28
29
# File 'lib/slackbot_frd/slack_methods/users_info.rb', line 27

def info
  @response["user"]
end