scinote-web/app/controllers/api/service/projects_json_export_controller.rb
ajugo 90db2bace9
API endpoint to generate with ELN data for Validaide [SCI-6663][SCI-6798] (#4012)
* Manuscript JSON data SCI-6663

* Clean code for generate manuscript data [SCI-6663]

* Include project data into json [SCI-6663]

* Fix hound [SCI-6663]

* Fix hound [SCI-6663]

* Remove manuscript naming [SCI-6663]

* Add local storage assets capabilites [SCI-6663]

* Rename project [SCI-6663]

* Enable multple projects and clean input [SCI-6798]

* Fix hound [SCI-6798]
2022-05-19 09:08:05 +02:00

34 lines
1.2 KiB
Ruby

# frozen_string_literal: true
module Api
module Service
class ProjectsJsonExportController < BaseController
require 'uri'
def projects_json_export
projects_json_export_params = projects_json_export_data_params
valid_url?(projects_json_export_params[:callback_url])
ProjectsJsonExportJob.perform_later(projects_json_export_params[:task_ids],
projects_json_export_params[:callback_url],
current_user)
render json: { status: :ok }, status: :accepted
end
private
def projects_json_export_data_params
raise ActionController::ParameterMissing, I18n.t('api.service.errors.missing_task_ids') unless
params.require(:data).require(:task_ids)
raise ActionController::ParameterMissing, I18n.t('api.service.errors.callback_missing') unless
params.require(:data).require(:callback_url)
params.require(:data).permit(:callback_url, task_ids: [])
end
def valid_url?(url)
uri = URI.parse(url)
raise URI::InvalidURIError if uri.host.blank?
end
end
end
end