Class: V0::PensionClaimsController

Inherits:
ClaimsBaseController show all
Defined in:
app/controllers/v0/pension_claims_controller.rb

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 Method Summary collapse

Methods inherited from ClaimsBaseController

#show

Methods inherited from ApplicationController

#clear_saved_form, #cors_preflight, #routing_error

Methods included from Traceable

#set_trace_tags

Methods included from SentryLogging

#log_exception_to_sentry, #log_message_to_sentry, #non_nil_hash?, #normalize_level, #rails_logger

Methods included from SignIn::Authentication

#authenticate, #authenticate_service_account, #load_user

Methods included from Headers

#block_unknown_hosts, #set_app_info_headers

Methods included from AuthenticationAndSSOConcerns

#authenticate, #clear_session, #extend_session!, #load_user, #log_sso_info, #render_unauthorized, #reset_session, #set_api_cookie!, #set_session_expiration_header, #sso_logging_info, #validate_inbound_login_params, #validate_session

Instance Method Details

#claim_classObject



11
12
13
# File 'app/controllers/v0/pension_claims_controller.rb', line 11

def claim_class
  SavedClaim::Pension
end

#createObject

Creates and validates an instance of the class, removing any copies of the form that had been previously saved by the user.



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'app/controllers/v0/pension_claims_controller.rb', line 17

def create
  PensionBurial::TagSentry.tag_sentry

  claim = claim_class.new(form: filtered_params[:form])
  user_uuid = current_user&.uuid
  Rails.logger.info("Begin #{claim.class::FORM} Submission",
                    { guid: claim.guid, user_uuid: })

  in_progress_form = current_user ? InProgressForm.form_for_user(claim.form_id, current_user) : nil
  claim.itf_datetime = in_progress_form.created_at if in_progress_form

  unless claim.save
    StatsD.increment("#{stats_key}.failure")
    raise Common::Exceptions::ValidationErrors, claim
  end

  use_lighthouse = Flipper.enabled?(:pension_claim_submission_to_lighthouse)
  use_lighthouse ? claim.upload_to_lighthouse : claim.process_attachments!

  StatsD.increment("#{stats_key}.success")
  Rails.logger.info("Submit #{claim.class::FORM} Success",
                    { confirmation_number: claim.confirmation_number, user_uuid: })

  clear_saved_form(claim.form_id)
  render(json: claim)
end

#short_nameObject



7
8
9
# File 'app/controllers/v0/pension_claims_controller.rb', line 7

def short_name
  'pension_claim'
end