Sha256: c600c8e36299d0b3950bd9a41ae853b3cbd667caae4b70a4ce755fd73ce3815f

Contents?: true

Size: 670 Bytes

Versions: 1

Compression:

Stored size: 670 Bytes

Contents

module GovukNotifyRails
  class Delivery
    attr_accessor :settings

    def initialize(settings)
      self.settings = settings
    end

    def deliver!(message)
      notify_client.send_email(payload_for(message))
    end

    private

    def service_id
      settings[:service_id]
    end

    def secret_key
      settings[:secret_key]
    end

    def payload_for(message)
      {
        to: message.to.first,
        template: message.govuk_notify_template,
        personalisation: message.govuk_notify_personalisation
      }.compact
    end

    def notify_client
      @notify_client ||= Notifications::Client.new(service_id, secret_key)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
govuk_notify_rails-1.0.0 lib/govuk_notify_rails/delivery.rb