Class: BenefitsClaims::Service
- Inherits:
-
Common::Client::Base
- Object
- Common::Client::Base
- BenefitsClaims::Service
- Defined in:
- lib/lighthouse/benefits_claims/service.rb
Constant Summary collapse
- STATSD_KEY_PREFIX =
'api.benefits_claims'
- FILTERED_STATUSES =
%w[CANCELED ERRORED PENDING].freeze
Instance Method Summary collapse
-
#create_intent_to_file(type, claimant_ssn, lighthouse_client_id = nil, lighthouse_rsa_key_path = nil, options = {}) ⇒ Object
For type “survivor”, the request must include claimantSsn and be made by a valid Veteran Representative.
- #get_claim(id, lighthouse_client_id = nil, lighthouse_rsa_key_path = nil, options = {}) ⇒ Object
- #get_claims(lighthouse_client_id = nil, lighthouse_rsa_key_path = nil, options = {}) ⇒ Object
- #get_intent_to_file(type, lighthouse_client_id = nil, lighthouse_rsa_key_path = nil, options = {}) ⇒ Object
-
#initialize(icn) ⇒ Service
constructor
A new instance of Service.
- #submit5103(id, lighthouse_client_id = nil, lighthouse_rsa_key_path = nil, options = {}) ⇒ Object
-
#submit526(body, lighthouse_client_id = nil, lighthouse_rsa_key_path = nil, options = {}) ⇒ Object
submit form526 to Lighthouse API endpoint: /services/claims/v2/veterans/veteranId/526 attributes in the Lighthouse request schema.
Methods inherited from Common::Client::Base
configuration, #raise_backend_exception
Methods included from SentryLogging
#log_exception_to_sentry, #log_message_to_sentry, #non_nil_hash?, #normalize_level, #rails_logger
Constructor Details
#initialize(icn) ⇒ Service
Returns a new instance of Service.
15 16 17 18 19 20 |
# File 'lib/lighthouse/benefits_claims/service.rb', line 15 def initialize(icn) @icn = icn raise ArgumentError, 'no ICN passed in for LH API request.' if icn.blank? super() end |
Instance Method Details
#create_intent_to_file(type, claimant_ssn, lighthouse_client_id = nil, lighthouse_rsa_key_path = nil, options = {}) ⇒ Object
For type “survivor”, the request must include claimantSsn and be made by a valid Veteran Representative. If the Representative is not a Veteran or a VA employee, this method is currently not available to them, and they should use the Benefits Intake API as an alternative.
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/lighthouse/benefits_claims/service.rb', line 59 def create_intent_to_file(type, claimant_ssn, lighthouse_client_id = nil, lighthouse_rsa_key_path = nil, = {}) if claimant_ssn.blank? && type == 'survivor' raise ArgumentError, 'BenefitsClaims::Service: No SSN provided for survivor type create request.' end endpoint = 'benefits_claims/intent_to_file' path = "#{@icn}/intent-to-file" config.post( path, { data: { type: 'intent_to_file', attributes: { type:, claimantSsn: claimant_ssn } } }, lighthouse_client_id, lighthouse_rsa_key_path, ).body rescue Faraday::ClientError, Faraday::ServerError => e handle_error(e, lighthouse_client_id, endpoint) end |
#get_claim(id, lighthouse_client_id = nil, lighthouse_rsa_key_path = nil, options = {}) ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/lighthouse/benefits_claims/service.rb', line 32 def get_claim(id, lighthouse_client_id = nil, lighthouse_rsa_key_path = nil, = {}) config.get("#{@icn}/claims/#{id}", lighthouse_client_id, lighthouse_rsa_key_path, ).body rescue Faraday::TimeoutError raise BenefitsClaims::ServiceException.new({ status: 504 }), 'Lighthouse Error' rescue Faraday::ClientError, Faraday::ServerError => e raise BenefitsClaims::ServiceException.new(e.response), 'Lighthouse Error' end |
#get_claims(lighthouse_client_id = nil, lighthouse_rsa_key_path = nil, options = {}) ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/lighthouse/benefits_claims/service.rb', line 22 def get_claims(lighthouse_client_id = nil, lighthouse_rsa_key_path = nil, = {}) claims = config.get("#{@icn}/claims", lighthouse_client_id, lighthouse_rsa_key_path, ).body claims['data'] = filter_by_status(claims['data']) claims rescue Faraday::TimeoutError raise BenefitsClaims::ServiceException.new({ status: 504 }), 'Lighthouse Error' rescue Faraday::ClientError, Faraday::ServerError => e raise BenefitsClaims::ServiceException.new(e.response), 'Lighthouse Error' end |
#get_intent_to_file(type, lighthouse_client_id = nil, lighthouse_rsa_key_path = nil, options = {}) ⇒ Object
48 49 50 51 52 53 54 |
# File 'lib/lighthouse/benefits_claims/service.rb', line 48 def get_intent_to_file(type, lighthouse_client_id = nil, lighthouse_rsa_key_path = nil, = {}) endpoint = 'benefits_claims/intent_to_file' path = "#{@icn}/intent-to-file/#{type}" config.get(path, lighthouse_client_id, lighthouse_rsa_key_path, ).body rescue Faraday::ClientError, Faraday::ServerError => e handle_error(e, lighthouse_client_id, endpoint) end |
#submit5103(id, lighthouse_client_id = nil, lighthouse_rsa_key_path = nil, options = {}) ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/lighthouse/benefits_claims/service.rb', line 40 def submit5103(id, lighthouse_client_id = nil, lighthouse_rsa_key_path = nil, = {}) config.post("#{@icn}/claims/#{id}/5103", {}, lighthouse_client_id, lighthouse_rsa_key_path, ).body rescue Faraday::TimeoutError raise BenefitsClaims::ServiceException.new({ status: 504 }), 'Lighthouse Error' rescue Faraday::ClientError, Faraday::ServerError => e raise BenefitsClaims::ServiceException.new(e.response), 'Lighthouse Error' end |
#submit526(body, lighthouse_client_id = nil, lighthouse_rsa_key_path = nil, options = {}) ⇒ Object
submit form526 to Lighthouse API endpoint: /services/claims/v2/veterans/veteranId/526 attributes in the Lighthouse request schema
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/lighthouse/benefits_claims/service.rb', line 93 def submit526(body, lighthouse_client_id = nil, lighthouse_rsa_key_path = nil, = {}) endpoint = 'benefits_claims/form/526' path = "#{@icn}/526" # if we're coming straight from the transformation service without # making this a jsonapi request body first ({data: {type:, attributes}}), # this will put it in the correct format for transmission body = { data: { type: 'form/526', attributes: body } }.as_json.deep_transform_keys { |k| k.camelize(:lower) } # Inflection settings force 'current_va_employee' to render as 'currentVAEmployee' in the above camelize() call # Since Lighthouse needs 'currentVaEmployee', the following workaround renames it. fix_current_va_employee(body) response = config.post( path, body, lighthouse_client_id, lighthouse_rsa_key_path, ) submit_response(response, [:body_only]) rescue Faraday::ClientError, Faraday::ServerError => e handle_error(e, lighthouse_client_id, endpoint) end |