Created
October 27, 2021 18:06
-
-
Save WagnerMatos/a063543cb7360f81773f3a6931cbac24 to your computer and use it in GitHub Desktop.
Revisions
-
WagnerMatos renamed this gist
Oct 27, 2021 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
WagnerMatos created this gist
Oct 27, 2021 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,72 @@ # controller class MyController < ApplicationController TEMPLATE_ID = "TEMPLATE_ID" def create authorize ... if send_email redirect_to @referer, success: success_message else redirect_to @referer, error: error_message end end private def set_case_attachable ... end def send_email ... Notify::Email.new( client_email: "email@email.com", template_id: TEMPLATE_ID, ... ).deliver_now end def magic_link_url(name, gid) ... end def success_message ... end def error_message ... end end # PORO module Notify class Email include PoroAttributes NOTIFY_API_KEY = SOME_KEY attribute :client_email attribute :template_id attribute :personalisation, default: -> {} def deliver_now send_email rescue Notifications::Client::RequestError raise # Retry elsewhere end private def send_email notify.send_email(...) end def notify @notify ||= ExternalLibrary::Client.new(SOME_API_KEY) end end end