2019-07-30 21:29:24 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-03-25 16:15:39 +00:00
|
|
|
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
2018-03-25 17:30:42 +00:00
|
|
|
module Nonprofits
|
2019-07-30 21:29:24 +00:00
|
|
|
class EmailListsController < ApplicationController
|
|
|
|
include Controllers::NonprofitHelper
|
2018-03-25 17:30:42 +00:00
|
|
|
|
2019-07-30 21:29:24 +00:00
|
|
|
before_action :authenticate_nonprofit_user!
|
2018-03-25 17:30:42 +00:00
|
|
|
|
2019-07-30 21:29:24 +00:00
|
|
|
def index
|
2019-08-06 14:06:14 +00:00
|
|
|
render_json { Qx.fetch(:email_lists, nonprofit_id: email_list_params[:nonprofit_id]) }
|
2019-07-30 21:29:24 +00:00
|
|
|
end
|
2018-03-25 17:30:42 +00:00
|
|
|
|
2019-07-30 21:29:24 +00:00
|
|
|
def create
|
2019-08-06 14:06:14 +00:00
|
|
|
tag_master_ids = email_list_params[:tag_masters].values.map(&:to_i)
|
|
|
|
render_json { InsertEmailLists.for_mailchimp(email_list_params[:nonprofit_id], tag_master_ids) }
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def email_list_params
|
|
|
|
params.permit(:nonprofit_id, :tag_masters)
|
2019-07-30 21:29:24 +00:00
|
|
|
end
|
2018-03-25 17:30:42 +00:00
|
|
|
end
|
|
|
|
end
|