class Lita::Handlers::VisitorNotificationHandler

Public Instance Methods

notify_visitor(response) click to toggle source
# File lib/lita/handlers/visitor_notification_handler.rb, line 15
def notify_visitor(response)
  groups = response.matches[0]
  if groups.size == 2
    notification = {
      :guest_name => groups[0],
      :location_name => groups[1],
    }
  else
    notification = {
      :host_name => groups[0],
      :guest_name => groups[1],
      :location_name => groups[2],
    }
  end
  payload = notification.to_json
  if config.webhook_url
    resp = HTTParty.post(
      config.webhook_url,
      body: payload,
      headers: config.webhook_headers,
    )
  end
  response.reply(payload)
end