Class: DebtManagementCenter::StatementIdentifierService
- Inherits:
-
Object
- Object
- DebtManagementCenter::StatementIdentifierService
show all
- Includes:
- SentryLogging
- Defined in:
- lib/debt_management_center/statement_identifier_service.rb
Defined Under Namespace
Classes: MalformedMCPStatement, RetryableError, Vet360IdNotFound
Constant Summary
collapse
- STATSD_KEY_PREFIX =
'api.copay_notifications.new_statement'
- RETRYABLE_ERRORS =
[
Common::Exceptions::GatewayTimeout,
Breakers::OutageException,
Faraday::ConnectionFailed,
Common::Exceptions::BackendServiceException
].freeze
Instance Method Summary
collapse
#log_exception_to_sentry, #log_message_to_sentry, #non_nil_hash?, #normalize_level, #rails_logger, #set_sentry_metadata
Constructor Details
Returns a new instance of StatementIdentifierService.
32
33
34
35
36
37
38
39
40
|
# File 'lib/debt_management_center/statement_identifier_service.rb', line 32
def initialize(statement)
@statement = statement
raise MalformedMCPStatement, statement unless legal_statement
@identifier = @statement['veteranIdentifier']
@identifier_type = @statement['identifierType']
@facility_id = @statement['facilityNum']
@identifier_key = nil
end
|
Instance Method Details
#get_mpi_data ⇒ Object
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/debt_management_center/statement_identifier_service.rb', line 42
def get_mpi_data
mpi_response = get_mpi_profile
if mpi_response.ok?
StatsD.increment("#{STATSD_KEY_PREFIX}.mpi.success")
profile = mpi_response.profile
{
icn: profile.icn,
first_name: profile.given_names.first
}
else
StatsD.increment("#{STATSD_KEY_PREFIX}.mpi.failure")
raise mpi_response.error
end
rescue *RETRYABLE_ERRORS => e
raise RetryableError, e
end
|
#get_mpi_profile ⇒ Object
#legal_statement ⇒ Object
80
81
82
83
84
|
# File 'lib/debt_management_center/statement_identifier_service.rb', line 80
def legal_statement
@statement['veteranIdentifier'] &&
@statement['identifierType'] &&
@statement['facilityNum']
end
|
#vista_account_id ⇒ Object
59
60
61
62
63
|
# File 'lib/debt_management_center/statement_identifier_service.rb', line 59
def vista_account_id
offset = 16 - (@facility_id + @identifier).length
padding = '0' * offset if offset >= 0
"#{@facility_id}#{padding}#{@identifier}"
end
|