Class: Sincerely::SendController

Inherits:
ApplicationController show all
Defined in:
app/controllers/sincerely/send_controller.rb

Instance Method Summary collapse

Instance Method Details

#create ⇒ Object



15
16
17
18
19
20
21
# File 'app/controllers/sincerely/send_controller.rb', line 15

def create
  return render_error('No valid recipients provided') if recipients.empty?
  return render_error("Maximum #{MAX_RECIPIENTS} recipients allowed") if recipients.size > MAX_RECIPIENTS
  return render_error('Template not found') unless template

  render json: send_results
end

#new ⇒ Object



11
12
13
# File 'app/controllers/sincerely/send_controller.rb', line 11

def new
  @templates = available_templates
end

#template_variables ⇒ Object



23
24
25
26
27
# File 'app/controllers/sincerely/send_controller.rb', line 23

def template_variables
  return render json: { variables: [] } unless template

  render json: { variables: extract_liquid_variables.uniq.sort }
end