2021-04-29 16:53:32 +00:00
|
|
|
class Api::V1::Accounts::CampaignsController < Api::V1::Accounts::BaseController
|
|
|
|
before_action :campaign, except: [:index, :create]
|
|
|
|
before_action :check_authorization
|
|
|
|
|
|
|
|
def index
|
|
|
|
@campaigns = Current.account.campaigns
|
|
|
|
end
|
|
|
|
|
|
|
|
def create
|
|
|
|
@campaign = Current.account.campaigns.create!(campaign_params)
|
|
|
|
end
|
|
|
|
|
2021-06-15 08:44:59 +00:00
|
|
|
def destroy
|
|
|
|
@campaign.destroy
|
|
|
|
head :ok
|
|
|
|
end
|
|
|
|
|
2021-04-29 16:53:32 +00:00
|
|
|
def show; end
|
|
|
|
|
|
|
|
def update
|
|
|
|
@campaign.update(campaign_params)
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def campaign
|
|
|
|
@campaign ||= Current.account.campaigns.find_by(display_id: params[:id])
|
|
|
|
end
|
|
|
|
|
|
|
|
def campaign_params
|
2021-07-14 06:54:09 +00:00
|
|
|
params.require(:campaign).permit(:title, :description, :message, :enabled, :inbox_id, :sender_id,
|
|
|
|
:scheduled_at, audience: [:type, :id], trigger_rules: {})
|
2021-04-29 16:53:32 +00:00
|
|
|
end
|
|
|
|
end
|