hip_chat_notifier_worker.rb 490 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
module Ci
  class HipChatNotifierWorker
    include Sidekiq::Worker

    def perform(message, options={})
      room   = options.delete('room')
      token  = options.delete('token')
      server = options.delete('server')
      name   = options.delete('service_name')
      client_opts = {
        api_version: 'v2',
        server_url: server
      }

      client = HipChat::Client.new(token, client_opts)
      client[room].send(name, message, options.symbolize_keys)
    end
  end
end