Class: V0::BurialClaimsController
- Inherits:
-
ApplicationController
- Object
- ActionController::API
- ApplicationController
- V0::BurialClaimsController
- Defined in:
- app/controllers/v0/burial_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 Attribute Summary
Attributes inherited from ApplicationController
Instance Method Summary collapse
-
#claim_class ⇒ Object
private
a subclass of SavedClaim, runs json-schema validations and performs any storage and attachment processing.
- #create ⇒ Object
- #create_claim ⇒ Object private
-
#filtered_params ⇒ Object
private
Filters out the parameters to form access.
-
#log_validation_error_to_metadata(in_progress_form, claim) ⇒ Object
private
include validation error on in_progress_form metadata.
-
#monitor ⇒ Burials::Monitor
private
retreive a monitor for tracking.
- #process_and_upload_to_lighthouse(in_progress_form, claim) ⇒ Object private
-
#short_name ⇒ Object
private
an identifier that matches the parameter that the form will be set as in the JSON submission.
- #show ⇒ Object
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
#claim_class ⇒ Object (private)
a subclass of SavedClaim, runs json-schema validations and performs any storage and attachment processing
60 61 62 |
# File 'app/controllers/v0/burial_claims_controller.rb', line 60 def claim_class SavedClaim::Burial end |
#create ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'app/controllers/v0/burial_claims_controller.rb', line 25 def create PensionBurial::TagSentry.tag_sentry claim = create_claim monitor.track_create_attempt(claim, current_user) in_progress_form = current_user ? InProgressForm.form_for_user(claim.form_id, current_user) : nil claim.form_start_date = in_progress_form.created_at if in_progress_form unless claim.save Sentry.(team: 'benefits-memorial-1') # tag sentry logs with team name monitor.track_create_validation_error(in_progress_form, claim, current_user) (in_progress_form, claim) raise Common::Exceptions::ValidationErrors, claim.errors end process_and_upload_to_lighthouse(in_progress_form, claim) monitor.track_create_success(in_progress_form, claim, current_user) clear_saved_form(claim.form_id) render json: SavedClaimSerializer.new(claim) rescue => e monitor.track_create_error(in_progress_form, claim, current_user, e) raise e end |
#create_claim ⇒ Object (private)
64 65 66 67 68 69 70 71 |
# File 'app/controllers/v0/burial_claims_controller.rb', line 64 def create_claim if Flipper.enabled?(:va_burial_v2) form = filtered_params[:form] claim_class.new(form:, formV2: form.present? ? JSON.parse(form)['formV2'] : nil) else claim_class.new(form: filtered_params[:form]) end end |
#filtered_params ⇒ Object (private)
Filters out the parameters to form access.
83 84 85 |
# File 'app/controllers/v0/burial_claims_controller.rb', line 83 def filtered_params params.require(short_name.to_sym).permit(:form) end |
#log_validation_error_to_metadata(in_progress_form, claim) ⇒ Object (private)
include validation error on in_progress_form metadata. ‘noop` if in_progress_form is `blank?`
94 95 96 97 98 99 100 |
# File 'app/controllers/v0/burial_claims_controller.rb', line 94 def (in_progress_form, claim) return if in_progress_form.blank? = in_progress_form. ['submission']['error_message'] = claim&.errors&.errors&.to_s in_progress_form.update(metadata:) end |
#monitor ⇒ Burials::Monitor (private)
retreive a monitor for tracking
107 108 109 |
# File 'app/controllers/v0/burial_claims_controller.rb', line 107 def monitor @monitor ||= Burials::Monitor.new end |
#process_and_upload_to_lighthouse(in_progress_form, claim) ⇒ Object (private)
73 74 75 76 77 78 79 80 |
# File 'app/controllers/v0/burial_claims_controller.rb', line 73 def process_and_upload_to_lighthouse(in_progress_form, claim) claim. Lighthouse::SubmitBenefitsIntakeClaim.perform_async(claim.id) rescue => e monitor.(in_progress_form, claim, current_user) raise e end |
#short_name ⇒ Object (private)
an identifier that matches the parameter that the form will be set as in the JSON submission.
55 56 57 |
# File 'app/controllers/v0/burial_claims_controller.rb', line 55 def short_name 'burial_claim' end |
#show ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'app/controllers/v0/burial_claims_controller.rb', line 14 def show claim = claim_class.find_by!(guid: params[:id]) render json: SavedClaimSerializer.new(claim) rescue ActiveRecord::RecordNotFound => e monitor.track_show404(params[:id], current_user, e) render(json: { error: e.to_s }, status: :not_found) rescue => e monitor.track_show_error(params[:id], current_user, e) raise e end |