mirror of https://github.com/docusealco/docuseal
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
690 B
25 lines
690 B
# frozen_string_literal: true
|
|
|
|
module Api
|
|
class SubmissionsVoidController < ApiBaseController
|
|
load_and_authorize_resource :submission
|
|
|
|
before_action only: :create do
|
|
authorize!(:destroy, @submission)
|
|
end
|
|
|
|
def create
|
|
Submissions::Void.call(@submission, user: current_user, reason: params[:reason], request:)
|
|
|
|
render json: {
|
|
id: @submission.id,
|
|
status: 'voided',
|
|
voided_at: @submission.voided_at,
|
|
void_reason: @submission.void_reason
|
|
}
|
|
rescue Submissions::Void::ReasonRequiredError, Submissions::Void::NotVoidableError => e
|
|
render json: { error: e.message }, status: :unprocessable_content
|
|
end
|
|
end
|
|
end
|