Class: V0::CoeController
- Inherits:
-
ApplicationController
- Object
- ActionController::API
- ApplicationController
- V0::CoeController
- Defined in:
- app/controllers/v0/coe_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 Method Summary collapse
- #document_download ⇒ Object
- #document_upload ⇒ Object
- #documents ⇒ Object
- #download_coe ⇒ Object
- #status ⇒ Object
- #submit_coe_claim ⇒ Object
Methods inherited from ApplicationController
#clear_saved_form, #cors_preflight, #routing_error
Methods included from Traceable
Methods included from SentryLogging
#log_exception_to_sentry, #log_message_to_sentry, #non_nil_hash?, #normalize_level, #rails_logger
Methods included from SignIn::Authentication
#authenticate, #authenticate_service_account, #load_user
Methods included from Headers
#block_unknown_hosts, #set_app_info_headers
Methods included from AuthenticationAndSSOConcerns
#authenticate, #clear_session, #extend_session!, #load_user, #log_sso_info, #render_unauthorized, #reset_session, #set_api_cookie!, #set_session_expiration_header, #sso_logging_info, #validate_inbound_login_params, #validate_session
Instance Method Details
#document_download ⇒ Object
68 69 70 71 |
# File 'app/controllers/v0/coe_controller.rb', line 68 def document_download res = lgy_service.get_document(params[:id]) send_data(res.body, type: 'application/pdf', disposition: 'attachment') end |
#document_upload ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'app/controllers/v0/coe_controller.rb', line 48 def document_upload status = 201 # Each document is uploaded individually .each do || file_extension = ['file_type'] if %w[jpg jpeg png pdf].include? file_extension.downcase document_data = build_document_data() response = lgy_service.post_document(payload: document_data) unless response.status == 201 status = response.status break end end end render(json: status) end |
#documents ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 |
# File 'app/controllers/v0/coe_controller.rb', line 36 def documents documents = lgy_service.get_coe_documents.body # Vet-uploaded docs have documentType `Veteran Correspondence`. We are not # currently displaying these on the COE status page, so they are omitted. # In the near future, we will display them, and can remove this `reject` # block. notification_letters = documents.reject { |doc| doc['document_type']&.include?('Veteran Correspondence') } # Documents should be sorted from most to least recent sorted_notification_letters = notification_letters.sort_by { |doc| doc['create_date'] }.reverse render json: { data: { attributes: sorted_notification_letters } }, status: :ok end |
#download_coe ⇒ Object
14 15 16 17 18 |
# File 'app/controllers/v0/coe_controller.rb', line 14 def download_coe res = lgy_service.get_coe_file send_data(res.body, type: 'application/pdf', disposition: 'attachment') end |
#status ⇒ Object
9 10 11 12 |
# File 'app/controllers/v0/coe_controller.rb', line 9 def status coe_status = lgy_service.coe_status render json: { data: { attributes: coe_status } }, status: :ok end |
#submit_coe_claim ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'app/controllers/v0/coe_controller.rb', line 20 def submit_coe_claim claim = SavedClaim::CoeClaim.new(form: filtered_params[:form]) unless claim.save StatsD.increment("#{stats_key}.failure") Raven.(team: 'vfs-ebenefits') # tag sentry logs with team name raise Common::Exceptions::ValidationErrors, claim end response = claim.send_to_lgy(edipi: current_user.edipi, icn: current_user.icn) Rails.logger.info "ClaimID=#{claim.confirmation_number} Form=#{claim.class::FORM}" clear_saved_form(claim.form_id) render json: { data: { attributes: { reference_number: response, claim: } } } end |