Class: V1::Post911GIBillStatusesController
- Inherits:
-
ApplicationController
- Object
- ActionController::API
- ApplicationController
- V1::Post911GIBillStatusesController
- Includes:
- IgnoreNotFound, SentryLogging
- Defined in:
- app/controllers/v1/post911_gi_bill_statuses_controller.rb
Constant Summary collapse
- STATSD_GI_BILL_TOTAL_KEY =
'api.lighthouse.gi_bill_status.total'
- STATSD_GI_BILL_FAIL_KEY =
'api.lighthouse.gi_bill_status.fail'
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
- #handle_error(e) ⇒ Object private
- #log_vet_not_found(user, timestamp) ⇒ Object private
- #service ⇒ Object private
- #show ⇒ Object
- #user_json(user) ⇒ Object private
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 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 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
#handle_error(e) ⇒ Object (private)
28 29 30 31 32 33 |
# File 'app/controllers/v1/post911_gi_bill_statuses_controller.rb', line 28 def handle_error(e) status = e.errors.first[:status].to_i log_vet_not_found(@current_user, Time.now.in_time_zone('Eastern Time (US & Canada)')) if status == 404 StatsD.increment(STATSD_GI_BILL_FAIL_KEY, tags: ["error:#{status}"]) render json: { errors: e.errors }, status: status || :internal_server_error end |
#log_vet_not_found(user, timestamp) ⇒ Object (private)
35 36 37 38 39 40 |
# File 'app/controllers/v1/post911_gi_bill_statuses_controller.rb', line 35 def log_vet_not_found(user, ) PersonalInformationLog.create( data: { timestamp:, user: user_json(user) }, error_class: 'BenefitsEducation::NotFound' ) end |
#service ⇒ Object (private)
58 59 60 |
# File 'app/controllers/v1/post911_gi_bill_statuses_controller.rb', line 58 def service BenefitsEducation::Service.new(@current_user&.icn) end |
#show ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'app/controllers/v1/post911_gi_bill_statuses_controller.rb', line 15 def show response = service.get_gi_bill_status render json: Post911GIBillStatusSerializer.new(response) rescue Breakers::OutageException => e raise e rescue => e handle_error(e) ensure StatsD.increment(STATSD_GI_BILL_TOTAL_KEY) end |
#user_json(user) ⇒ Object (private)
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'app/controllers/v1/post911_gi_bill_statuses_controller.rb', line 42 def user_json(user) { first_name: user.first_name, last_name: user.last_name, assurance_level: user.loa[:current].to_s, birls_id: user.birls_id, icn: user.icn, edipi: user.edipi, mhv_correlation_id: user.mhv_correlation_id, participant_id: user.participant_id, vet360_id: user.vet360_id, ssn: user.ssn, birth_date: Formatters::DateFormatter.format_date(user.birth_date, :datetime_iso8601) }.to_json end |