Class: V0::VirtualAgent::VirtualAgentClaimStatusController
- Inherits:
-
ApplicationController
- Object
- ActionController::API
- ApplicationController
- V0::VirtualAgent::VirtualAgentClaimStatusController
- Includes:
- IgnoreNotFound
- Defined in:
- app/controllers/v0/virtual_agent/virtual_agent_claim_status_controller.rb
Defined Under Namespace
Classes: ServiceException
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
- #get_claim_from_lighthouse(id) ⇒ Object private
- #index ⇒ Object
- #lighthouse_service ⇒ Object private
- #order_claims_lighthouse(claims) ⇒ Object private
- #poll_claims_from_lighthouse ⇒ Object private
- #report_exception_handler(exception) ⇒ Object private
- #report_or_error(cxdw_reporting_service, conversation_id) ⇒ Object private
- #service_exception_handler(exception) ⇒ Object private
- #show ⇒ Object
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 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
#get_claim_from_lighthouse(id) ⇒ Object (private)
56 57 58 |
# File 'app/controllers/v0/virtual_agent/virtual_agent_claim_status_controller.rb', line 56 def get_claim_from_lighthouse(id) lighthouse_service.get_claim(id) end |
#index ⇒ Object
17 18 19 20 21 22 |
# File 'app/controllers/v0/virtual_agent/virtual_agent_claim_status_controller.rb', line 17 def index render json: { data: poll_claims_from_lighthouse, meta: { sync_status: 'SUCCESS' } } end |
#lighthouse_service ⇒ Object (private)
60 61 62 |
# File 'app/controllers/v0/virtual_agent/virtual_agent_claim_status_controller.rb', line 60 def lighthouse_service BenefitsClaims::Service.new(current_user.icn) end |
#order_claims_lighthouse(claims) ⇒ Object (private)
70 71 72 73 74 75 76 77 |
# File 'app/controllers/v0/virtual_agent/virtual_agent_claim_status_controller.rb', line 70 def order_claims_lighthouse(claims) claims .sort_by do |claim| Date.strptime(claim['attributes']['claimPhaseDates']['phaseChangeDate'], '%Y-%m-%d').to_time.to_i end .reverse end |
#poll_claims_from_lighthouse ⇒ Object (private)
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/virtual_agent/virtual_agent_claim_status_controller.rb', line 33 def poll_claims_from_lighthouse raw_claim_list = lighthouse_service.get_claims['data'] cxdw_reporting_service = V0::VirtualAgent::ReportToCxdw.new conversation_id = params[:conversation_id] if conversation_id.blank? Rails.logger.error( 'V0::VirtualAgent::VirtualAgentClaimStatusController#poll_claims_from_lighthouse ' \ 'conversation_id is missing in parameters' ) raise ActionController::ParameterMissing, 'conversation_id' end begin claims = order_claims_lighthouse(raw_claim_list) report_or_error(cxdw_reporting_service, conversation_id) claims rescue Faraday::ClientError => e report_or_error(cxdw_reporting_service, conversation_id) service_exception_handler(error) raise BenefitsClaims::ServiceException.new(e.response), 'Could not retrieve claims' end end |
#report_exception_handler(exception) ⇒ Object (private)
85 86 87 88 |
# File 'app/controllers/v0/virtual_agent/virtual_agent_claim_status_controller.rb', line 85 def report_exception_handler(exception) context = 'An error occurred while attempting to report the claim(s).' log_exception_to_sentry(exception, 'context' => context) end |
#report_or_error(cxdw_reporting_service, conversation_id) ⇒ Object (private)
64 65 66 67 68 |
# File 'app/controllers/v0/virtual_agent/virtual_agent_claim_status_controller.rb', line 64 def report_or_error(cxdw_reporting_service, conversation_id) cxdw_reporting_service.report_to_cxdw(current_user.icn, conversation_id) rescue => e report_exception_handler(e) end |
#service_exception_handler(exception) ⇒ Object (private)
79 80 81 82 83 |
# File 'app/controllers/v0/virtual_agent/virtual_agent_claim_status_controller.rb', line 79 def service_exception_handler(exception) context = 'An error occurred while attempting to retrieve the claim(s).' log_exception_to_sentry(exception, 'context' => context) render nothing: true, status: :service_unavailable end |
#show ⇒ Object
24 25 26 27 28 29 |
# File 'app/controllers/v0/virtual_agent/virtual_agent_claim_status_controller.rb', line 24 def show render json: { data: get_claim_from_lighthouse(params[:id]), meta: { sync_status: 'SUCCESS' } } end |