Class: NotificationServices::HubotService

Inherits:
NotificationService
  • Object
show all
Defined in:
app/models/notification_services/hubot_service.rb

Constant Summary collapse

Label =
"hubot"

Instance Method Summary collapse

Instance Method Details

#check_paramsObject


14
15
16
17
18
# File 'app/models/notification_services/hubot_service.rb', line 14

def check_params
  if Fields.detect {|f| self[f[0]].blank? }
    errors.add :base, 'You must specify the URL of your hubot'
  end
end

#create_notification(problem) ⇒ Object


28
29
30
# File 'app/models/notification_services/hubot_service.rb', line 28

def create_notification(problem)
  HTTParty.post(url, :body => {:message => message_for_hubot(problem), :room => room_id})
end

#message_for_hubot(problem) ⇒ Object


24
25
26
# File 'app/models/notification_services/hubot_service.rb', line 24

def message_for_hubot(problem)
  "[#{problem.app.name}][#{problem.environment}][#{problem.where}]: #{problem.error_class} #{problem_url(problem)}"
end

#urlObject


20
21
22
# File 'app/models/notification_services/hubot_service.rb', line 20

def url
  api_token
end