Class: HipchatNotification

Inherits:
Object
  • Object
show all
Defined in:
app/models/hipchat_notification.rb

Defined Under Namespace

Classes: Message

Instance Method Summary collapse

Constructor Details

#initialize(deploy) ⇒ HipchatNotification



3
4
5
6
# File 'app/models/hipchat_notification.rb', line 3

def initialize(deploy)
  @deploy = deploy
  @stage = deploy.stage
end

Instance Method Details

#deliverObject



8
9
10
11
12
13
14
15
16
17
18
19
# File 'app/models/hipchat_notification.rb', line 8

def deliver
  message = Message.new(@deploy)
  begin
    hipchat[@stage.hipchat_rooms.first.name].send message.from, message.to_s, **message.style
  rescue HipChat::UnknownRoom => e
    Rails.logger.error("Room did not existed")
  rescue HipChat::Unauthorized => e
    Rails.logger.error("Invalid token to post to room")
  rescue HipChat::UnknownResponseCode => e
    Rails.logger.error("Could not deliver hipchat message: #{e.message}")
  end
end