Class: V0::IntentToFilesController
- Inherits:
-
ApplicationController
- Object
- ActionController::API
- ApplicationController
- V0::IntentToFilesController
- Extended by:
- Logging::ThirdPartyTransaction::MethodWrapper
- Defined in:
- app/controllers/v0/intent_to_files_controller.rb
Constant Summary collapse
- TYPES =
currently, only ‘compensation` is supported. This will be expanded to include `pension` and `survivor` in the future.
%w[compensation].freeze
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
- #active ⇒ Object
- #authorize_service ⇒ Object private
- #index ⇒ Object
- #service ⇒ Object private
- #set_success_response ⇒ Object private
- #strategy ⇒ Object private
- #submit ⇒ Object
- #validate_type_param ⇒ Object private
Methods included from Logging::ThirdPartyTransaction::MethodWrapper
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
#active ⇒ Object
49 50 51 52 |
# File 'app/controllers/v0/intent_to_files_controller.rb', line 49 def active response = strategy.cache_or_service(@current_user.uuid, params[:type]) { service.get_active(params[:type]) } render json: IntentToFileSerializer.new(response) end |
#authorize_service ⇒ Object (private)
90 91 92 93 94 95 96 97 98 |
# File 'app/controllers/v0/intent_to_files_controller.rb', line 90 def # Is this necessary if we've fully migrated to Lighthouse? EVSS tests still exist in the request spec, # so it might be necessary until those are removed if Flipper.enabled?(ApiProviderFactory::FEATURE_TOGGLE_INTENT_TO_FILE, @current_user) :lighthouse, :itf_access? else :evss, :access_form526? end end |
#index ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'app/controllers/v0/intent_to_files_controller.rb', line 31 def index intent_to_file_provider = ApiProviderFactory.call( type: ApiProviderFactory::FACTORIES[:intent_to_file], provider: nil, options: {}, current_user: @current_user, feature_toggle: ApiProviderFactory::FEATURE_TOGGLE_INTENT_TO_FILE ) type = params['itf_type'] || 'compensation' if Flipper.enabled?(:disability_compensation_production_tester, @current_user) Rails.logger.info("ITF GET call skipped for user #{@current_user.uuid}") response = set_success_response else response = intent_to_file_provider.get_intent_to_file(type, nil, nil) end render json: IntentToFileSerializer.new(response) end |
#service ⇒ Object (private)
105 106 107 |
# File 'app/controllers/v0/intent_to_files_controller.rb', line 105 def service EVSS::IntentToFile::Service.new(@current_user) end |
#set_success_response ⇒ Object (private)
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'app/controllers/v0/intent_to_files_controller.rb', line 74 def set_success_response DisabilityCompensation::ApiProvider::IntentToFilesResponse.new( intent_to_file: [ DisabilityCompensation::ApiProvider::IntentToFile.new( id: '0', creation_date: DateTime.now, expiration_date: DateTime.now + 1.year, source: '', participant_id: 0, status: 'active', type: 'compensation' ) ] ) end |
#strategy ⇒ Object (private)
109 110 111 |
# File 'app/controllers/v0/intent_to_files_controller.rb', line 109 def strategy EVSS::IntentToFile::ResponseStrategy.new end |
#submit ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'app/controllers/v0/intent_to_files_controller.rb', line 54 def submit intent_to_file_provider = ApiProviderFactory.call( type: ApiProviderFactory::FACTORIES[:intent_to_file], provider: nil, options: {}, current_user: @current_user, feature_toggle: ApiProviderFactory::FEATURE_TOGGLE_INTENT_TO_FILE ) type = params['itf_type'] || 'compensation' if Flipper.enabled?(:disability_compensation_production_tester, @current_user) Rails.logger.info("ITF submit call skipped for user #{@current_user.uuid}") response = set_success_response else response = intent_to_file_provider.create_intent_to_file(type, nil, nil) end render json: IntentToFileSerializer.new(response) end |
#validate_type_param ⇒ Object (private)
100 101 102 103 |
# File 'app/controllers/v0/intent_to_files_controller.rb', line 100 def validate_type_param raise Common::Exceptions::InvalidFieldValue.new('type', params[:type]) unless TYPES.include?(params[:type]) end |