Class: V0::IncomeAndAssetsClaimsController
- Inherits:
-
ClaimsBaseController
- Object
- ActionController::API
- ApplicationController
- ClaimsBaseController
- V0::IncomeAndAssetsClaimsController
- Defined in:
- app/controllers/v0/income_and_assets_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
-
#check_flipper_flag ⇒ Object
private
Raises an exception if the income and assets flipper flag isn’t enabled.
-
#claim_class ⇒ Object
a subclass of SavedClaim, runs json-schema validations and performs any storage and attachment processing.
-
#create ⇒ Object
POST creates and validates an instance of ‘claim_class`.
-
#filtered_params ⇒ Object
private
Filters out the parameters to form access.
-
#ia_monitor ⇒ IncomeAndAssets::Claims::Monitor
private
retreive a monitor for tracking.
-
#log_validation_error_to_metadata(in_progress_form, claim) ⇒ Object
private
include validation error on in_progress_form metadata.
-
#short_name ⇒ Object
an identifier that matches the parameter that the form will be set as in the JSON submission.
-
#show ⇒ Object
GET serialized 0969 income and assets form data.
Methods inherited from ClaimsBaseController
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
#check_flipper_flag ⇒ Object (private)
Raises an exception if the income and assets flipper flag isn’t enabled.
59 60 61 62 |
# File 'app/controllers/v0/income_and_assets_claims_controller.rb', line 59 def check_flipper_flag raise Common::Exceptions::Forbidden unless Flipper.enabled?(:pension_income_and_assets_clarification, current_user) end |
#claim_class ⇒ Object
a subclass of SavedClaim, runs json-schema validations and performs any storage and attachment processing
16 17 18 |
# File 'app/controllers/v0/income_and_assets_claims_controller.rb', line 16 def claim_class SavedClaim::IncomeAndAssets end |
#create ⇒ Object
POST creates and validates an instance of ‘claim_class`
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'app/controllers/v0/income_and_assets_claims_controller.rb', line 33 def create claim = claim_class.new(form: filtered_params[:form]) ia_monitor.track_create_attempt(claim, current_user&.user_account_uuid) 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 (in_progress_form, claim) raise Common::Exceptions::ValidationErrors, claim.errors end claim.upload_to_lighthouse(current_user) ia_monitor.track_create_success(in_progress_form&.id, claim, current_user&.user_account_uuid) clear_saved_form(claim.form_id) render json: SavedClaimSerializer.new(claim) rescue => e ia_monitor.track_create_error(in_progress_form&.id, claim, current_user&.user_account_uuid, e) raise e end |
#filtered_params ⇒ Object (private)
Filters out the parameters to form access.
65 66 67 |
# File 'app/controllers/v0/income_and_assets_claims_controller.rb', line 65 def filtered_params params.require(short_name.to_sym).permit(:form) end |
#ia_monitor ⇒ IncomeAndAssets::Claims::Monitor (private)
retreive a monitor for tracking
89 90 91 |
# File 'app/controllers/v0/income_and_assets_claims_controller.rb', line 89 def ia_monitor @monitor ||= IncomeAndAssets::Claims::Monitor.new 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?`
76 77 78 79 80 81 82 |
# File 'app/controllers/v0/income_and_assets_claims_controller.rb', line 76 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 |
#short_name ⇒ Object
an identifier that matches the parameter that the form will be set as in the JSON submission.
11 12 13 |
# File 'app/controllers/v0/income_and_assets_claims_controller.rb', line 11 def short_name 'income_and_assets_claim' end |
#show ⇒ Object
GET serialized 0969 income and assets form data
21 22 23 24 25 26 27 28 29 30 |
# File 'app/controllers/v0/income_and_assets_claims_controller.rb', line 21 def show claim = claim_class.find_by!(guid: params[:id]) # raises ActiveRecord::RecordNotFound render json: SavedClaimSerializer.new(claim) rescue ActiveRecord::RecordNotFound => e ia_monitor.track_show404(params[:id], current_user&.user_account_uuid, e) render(json: { error: e.to_s }, status: :not_found) rescue => e ia_monitor.track_show_error(params[:id], current_user&.user_account_uuid, e) raise e end |