Class: Uc3DmpApiCore::Notifier
- Inherits:
-
Object
- Object
- Uc3DmpApiCore::Notifier
- Defined in:
- lib/uc3-dmp-api-core/notifier.rb
Overview
Helper functions to send emails via SNS or publish events to EventBridge
Class Method Summary collapse
-
.notify_administrator(source:, details:, event: {}) ⇒ Object
Sends the Administrator an email notification ——————————————————————————–.
Class Method Details
.notify_administrator(source:, details:, event: {}) ⇒ Object
Sends the Administrator an email notification
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/uc3-dmp-api-core/notifier.rb', line 11 def notify_administrator(source:, details:, event: {}) Aws::SNS::Client.new.publish( topic_arn: ENV.fetch('SNS_FATAL_ERROR_TOPIC', nil), subject: "DMPTool - fatal error in - #{source}", message: (source:, details:, event:) ) true rescue Aws::Errors::ServiceError => e puts "Uc3DmpCore.Notifier - Unable to notify administrator via SNS! - #{e.} - on #{source}" puts " - EVENT: #{event.to_json}" if event.is_a?(Hash) && event.keys.any? puts " - DETAILS: #{details.to_json}" if details.is_a?(Hash) && details.keys.any? false end |