Class: Direct7::SLACK
- Inherits:
-
Object
- Object
- Direct7::SLACK
- Defined in:
- lib/direct7/slack.rb
Instance Method Summary collapse
- #get_status(request_id) ⇒ Object
-
#initialize(client) ⇒ SLACK
constructor
A new instance of SLACK.
- #send_slack_message(content, work_space_name, channel_name, report_url = nil) ⇒ Object
Constructor Details
#initialize(client) ⇒ SLACK
Returns a new instance of SLACK.
8 9 10 11 |
# File 'lib/direct7/slack.rb', line 8 def initialize(client) @client = client @log = Logger.new(STDOUT) # You can customize the log destination as needed end |
Instance Method Details
#get_status(request_id) ⇒ Object
32 33 34 35 36 |
# File 'lib/direct7/slack.rb', line 32 def get_status(request_id) response = @client.get(@client.host, "/report/v1/message-log/#{request_id}") @log.info('Message status retrieved successfully.') response end |
#send_slack_message(content, work_space_name, channel_name, report_url = nil) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/direct7/slack.rb', line 13 def (content, work_space_name, channel_name, report_url = nil) = { 'channel' => 'slack', 'content' => content, 'work_space_name' => work_space_name, 'channel_name' => channel_name } = { 'report_url' => report_url } response = @client.post(@client.host, '/messages/v1/send', true, params= { 'messages' => [], 'message_globals' => }) @log.info('Message sent successfully.') response end |