Class: Slk::Api::Bots
- Inherits:
-
Object
- Object
- Slk::Api::Bots
- Defined in:
- lib/slk/api/bots.rb
Overview
Wrapper for Slack bots.info API endpoint
Instance Method Summary collapse
-
#get_name(bot_id) ⇒ String?
Get bot name by ID.
-
#info(bot_id) ⇒ Hash?
Look up bot information by ID.
-
#initialize(api_client, workspace, on_debug: nil) ⇒ Bots
constructor
A new instance of Bots.
Constructor Details
#initialize(api_client, workspace, on_debug: nil) ⇒ Bots
Returns a new instance of Bots.
7 8 9 10 11 |
# File 'lib/slk/api/bots.rb', line 7 def initialize(api_client, workspace, on_debug: nil) @api = api_client @workspace = workspace @on_debug = on_debug end |
Instance Method Details
#get_name(bot_id) ⇒ String?
Get bot name by ID
27 28 29 30 |
# File 'lib/slk/api/bots.rb', line 27 def get_name(bot_id) bot = info(bot_id) bot&.dig('name') end |
#info(bot_id) ⇒ Hash?
Look up bot information by ID
16 17 18 19 20 21 22 |
# File 'lib/slk/api/bots.rb', line 16 def info(bot_id) response = @api.post_form(@workspace, 'bots.info', { bot: bot_id }) response['bot'] if response['ok'] rescue ApiError => e @on_debug&.call("Bot lookup failed for #{bot_id}: #{e.}") nil end |