Class: SlackbotFrd::SlackMethods::UsersList
- Inherits:
-
Object
- Object
- SlackbotFrd::SlackMethods::UsersList
- Includes:
- HTTParty
- Defined in:
- lib/slackbot_frd/slack_methods/users_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) ⇒ UsersList
constructor
A new instance of UsersList.
- #names_to_ids ⇒ Object
Constructor Details
#initialize(token) ⇒ UsersList
Returns a new instance of UsersList.
12 13 14 |
# File 'lib/slackbot_frd/slack_methods/users_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/users_list.rb', line 10 def response @response end |
Instance Method Details
#connect ⇒ Object
16 17 18 19 |
# File 'lib/slackbot_frd/slack_methods/users_list.rb', line 16 def connect @response = JSON.parse(self.class.post('', :body => { token: @token } ).body) self end |
#ids_to_names ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/slackbot_frd/slack_methods/users_list.rb', line 21 def ids_to_names retval = {} @response["members"].each do |user| retval[user["id"]] = user["name"] end retval end |
#names_to_ids ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/slackbot_frd/slack_methods/users_list.rb', line 29 def names_to_ids retval = {} @response["members"].each do |user| retval[user["name"]] = user["id"] end retval end |