Sha256: 837df925c29ec9f302c46bba59afef779f9f4430e3c4fcce31ed2906490f4cc7

Contents?: true

Size: 1005 Bytes

Versions: 10

Compression:

Stored size: 1005 Bytes

Contents

require 'json'
require 'net/http'
require 'uri'
require 'logger'

module Direct7
  class SLACK
    def initialize(client)
      @client = client
      @log = Logger.new(STDOUT) # You can customize the log destination as needed
    end

    def send_slack_message(content, work_space_name, channel_name, report_url = nil)
      message = {
        'channel' => 'slack',
        'content' => content,
        'work_space_name' => work_space_name,
        'channel_name' => channel_name
      }
      message_globals = {
        'report_url' => report_url
      }
      response = @client.post(@client.host, '/messages/v1/send', true, params= {
        'messages' => [message],
        'message_globals' => message_globals
      })

      @log.info('Message sent successfully.')
      response
    end

    def get_status(request_id)
      response = @client.get(@client.host, "/report/v1/message-log/#{request_id}")
      @log.info('Message status retrieved successfully.')
      response
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
direct7-0.0.18 lib/direct7/slack.rb
direct7-0.0.17 lib/direct7/slack.rb
direct7-0.0.16 lib/direct7/slack.rb
direct7-0.0.13 lib/direct7/slack.rb
direct7-0.0.12 lib/direct7/slack.rb
direct7-0.0.11 lib/direct7/slack.rb
direct7-0.0.10 lib/direct7/slack.rb
direct7-0.0.9 lib/direct7/slack.rb
direct7-0.0.8 lib/direct7/slack.rb
direct7-0.0.1 lib/direct7/slack.rb