Created
November 5, 2024 23:08
-
-
Save Hasstrup/066a761b09f378ac57bb12927eda5055 to your computer and use it in GitHub Desktop.
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 characters
# frozen_string_literal: true | |
class Templates::TemplatesController < ApplicationController | |
before_action :ensure_current_user! | |
def dispatch_mail | |
context = ::Templates::Templates::Contexts::EmailDispatch.call(input: email_dispatch_input) | |
return error_response(context.message) unless context.success? | |
render json: ::Templates::TemplateBlueprint.render(context.payload), status: :created | |
end | |
private | |
def email_dispatch_input | |
@email_dispatch_input ||= | |
::Templates::Templates::EmailDispatchInput.new(**including_current_user(template_mail_dispatch_params)) | |
end | |
def template_mail_dispatch_params | |
@template_mail_dispatch_params ||= params.permit(*%i[template_id strategy]) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment