module ServiceOperation::ServiceNotification
Extensions to ServiceOperation::Base
for sending notifications via the ServiceNotifications gem.
Constants
- VALID_SERVICE_NOTIFICATION_STATUSES
Public Class Methods
included(base)
click to toggle source
# File lib/service_operation/service_notification.rb, line 8 def self.included(base) base.extend ClassMethods end
Public Instance Methods
call()
click to toggle source
modify to suit in sub class
# File lib/service_operation/service_notification.rb, line 45 def call context.response ||= notify end
Private Instance Methods
notify(options = nil)
click to toggle source
@return [Hash] response from ServiceNotifications
# File lib/service_operation/service_notification.rb, line 52 def notify(options = nil) options ||= payload options = service_notifications_defaults.merge(options) status, body = self.class.service_notifications_post options unless VALID_SERVICE_NOTIFICATION_STATUSES.include?(status) context.service_notifications_response = body fail!(status) end body end
payload()
click to toggle source
A standard ServiceNotification
payload for {#notify} to use @abstract @return [Hash]
# File lib/service_operation/service_notification.rb, line 69 def payload raise 'define in subclass' end
service_notifications_api_key()
click to toggle source
define in sub class or pass in payload @abstract @return [String]
# File lib/service_operation/service_notification.rb, line 84 def service_notifications_api_key raise 'define in subclass' end
service_notifications_defaults()
click to toggle source
# File lib/service_operation/service_notification.rb, line 73 def service_notifications_defaults { url: service_notifications_url, api_key: service_notifications_api_key, instant: true, notification: 'inline' } end
service_notifications_url()
click to toggle source
# File lib/service_operation/service_notification.rb, line 88 def service_notifications_url ENV['SERVICE_NOTIFICATIONS_URL'] end