Class: V0::InProgressFormsController
- Inherits:
-
ApplicationController
- Object
- ActionController::API
- ApplicationController
- V0::InProgressFormsController
- Includes:
- IgnoreNotFound
- Defined in:
- app/controllers/v0/in_progress_forms_controller.rb
Direct Known Subclasses
Constant Summary
Constants inherited from ApplicationController
ApplicationController::VERSION_STATUS
Constants included from SignIn::Authentication
SignIn::Authentication::BEARER_PATTERN
Constants included from ExceptionHandling
ExceptionHandling::SKIP_SENTRY_EXCEPTION_TYPES
Instance Attribute Summary
Attributes inherited from ApplicationController
Instance Method Summary collapse
- #camelize_with_olivebranch(form_json) ⇒ Object private
-
#camelized_prefill_for_user ⇒ Object
private
the front end is always expecting camelCase –this ensures that, even if the OliveBranch inflection header isn’t used, camelCase keys are sent.
- #destroy ⇒ Object
- #form_for_user ⇒ Object private
- #form_id ⇒ Object private
- #index ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Methods included from IgnoreNotFound
Methods inherited from ApplicationController
#clear_saved_form, #cors_preflight, #pagination_params, #render_job_id, #routing_error, #set_csrf_header
Methods included from Traceable
Methods included from SentryControllerLogging
#set_tags_and_extra_context, #tags_context, #user_context
Methods included from SentryLogging
#log_exception_to_sentry, #log_message_to_sentry, #non_nil_hash?, #normalize_level, #rails_logger, #set_sentry_metadata
Methods included from Instrumentation
Methods included from SignIn::Authentication
#access_token, #access_token_authenticate, #authenticate, #authenticate_access_token, #bearer_token, #cookie_access_token, #handle_authenticate_error, #load_user, #load_user_object, #scrub_bearer_token, #validate_request_ip
Methods included from Headers
Methods included from ExceptionHandling
#render_errors, #report_mapped_exception, #report_original_exception, #skip_sentry_exception?, #skip_sentry_exception_types
Methods included from AuthenticationAndSSOConcerns
#authenticate, #clear_session, #extend_session!, #load_user, #log_sso_info, #render_unauthorized, #reset_session, #set_api_cookie!, #set_current_user, #set_session_expiration_header, #set_session_object, #sign_in_service_exp_time, #sign_in_service_session, #sso_cookie_content, #sso_logging_info, #validate_inbound_login_params, #validate_session
Methods included from SignIn::AudienceValidator
#authenticate, #validate_audience!
Instance Method Details
#camelize_with_olivebranch(form_json) ⇒ Object (private)
61 62 63 64 65 66 67 68 |
# File 'app/controllers/v0/in_progress_forms_controller.rb', line 61 def camelize_with_olivebranch(form_json) # camelize exactly as OliveBranch would # inspired by vets-api/blob/327b26c76ea7904744014ea35463022e8b50f3fb/lib/tasks/support/schema_camelizer.rb#L27 OliveBranch::Transformations.transform( form_json, OliveBranch::Transformations.method(:camelize) ) end |
#camelized_prefill_for_user ⇒ Object (private)
the front end is always expecting camelCase –this ensures that, even if the OliveBranch inflection header isn’t used, camelCase keys are sent
57 58 59 |
# File 'app/controllers/v0/in_progress_forms_controller.rb', line 57 def camelized_prefill_for_user camelize_with_olivebranch(FormProfile.for(form_id: params[:id], user: @current_user).prefill.as_json) end |
#destroy ⇒ Object
38 39 40 41 42 43 |
# File 'app/controllers/v0/in_progress_forms_controller.rb', line 38 def destroy raise Common::Exceptions::RecordNotFound, form_id if form_for_user.blank? form_for_user.destroy render json: InProgressFormSerializer.new(form_for_user) end |
#form_for_user ⇒ Object (private)
47 48 49 |
# File 'app/controllers/v0/in_progress_forms_controller.rb', line 47 def form_for_user @form_for_user ||= InProgressForm.submission_pending.form_for_user(form_id, @current_user) end |
#form_id ⇒ Object (private)
51 52 53 |
# File 'app/controllers/v0/in_progress_forms_controller.rb', line 51 def form_id params[:id] end |
#index ⇒ Object
8 9 10 11 12 13 |
# File 'app/controllers/v0/in_progress_forms_controller.rb', line 8 def index # the keys of metadata shouldn't be deeply transformed, which might corrupt some keys # see https://github.com/department-of-veterans-affairs/va.gov-team/issues/17595 for more details pending_submissions = InProgressForm.submission_pending.for_user(@current_user) render json: InProgressFormSerializer.new(pending_submissions) end |
#show ⇒ Object
15 16 17 |
# File 'app/controllers/v0/in_progress_forms_controller.rb', line 15 def show render json: form_for_user&. || camelized_prefill_for_user end |
#update ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'app/controllers/v0/in_progress_forms_controller.rb', line 19 def update form = InProgressForm.form_for_user(form_id, @current_user) || InProgressForm.new(form_id:, user_uuid: @current_user.uuid) form.user_account = @current_user.user_account form.real_user_uuid = @current_user.uuid ClaimFastTracking::MaxCfiMetrics.log_form_update(form, params) form.update!(form_data: params[:form_data] || params[:formData], metadata: params[:metadata]) if Flipper.enabled?(:intent_to_file_lighthouse_enabled, @current_user) && form.id_previously_changed? && Lighthouse::CreateIntentToFileJob::ITF_FORMS.include?(form.form_id) Lighthouse::CreateIntentToFileJob.perform_async(form.id, @current_user.icn, @current_user.participant_id) end render json: InProgressFormSerializer.new(form) end |