class GovukNotifyRails::Delivery
Attributes
settings[RW]
Public Class Methods
new(settings)
click to toggle source
# File lib/govuk_notify_rails/delivery.rb, line 5 def initialize(settings) self.settings = settings end
Public Instance Methods
deliver!(message)
click to toggle source
# File lib/govuk_notify_rails/delivery.rb, line 9 def deliver!(message) response = notify_client.send_email( payload_for(message) ) message.govuk_notify_response = response end
Private Instance Methods
api_key()
click to toggle source
# File lib/govuk_notify_rails/delivery.rb, line 18 def api_key settings[:api_key] end
notify_client()
click to toggle source
# File lib/govuk_notify_rails/delivery.rb, line 32 def notify_client @notify_client ||= Notifications::Client.new(api_key) end
payload_for(message)
click to toggle source
# File lib/govuk_notify_rails/delivery.rb, line 22 def payload_for(message) { email_address: message.to.first, template_id: message.govuk_notify_template, reference: message.govuk_notify_reference, personalisation: message.govuk_notify_personalisation, email_reply_to_id: message.govuk_notify_email_reply_to }.compact end