Class: DebtManagementCenter::StatementIdentifierService
- Inherits:
-
Object
- Object
- DebtManagementCenter::StatementIdentifierService
- 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
- #get_icn ⇒ Object
-
#initialize(statement) ⇒ StatementIdentifierService
constructor
A new instance of StatementIdentifierService.
- #vista_account_id ⇒ Object
Methods included from SentryLogging
#log_exception_to_sentry, #log_message_to_sentry, #non_nil_hash?, #normalize_level, #rails_logger
Constructor Details
#initialize(statement) ⇒ StatementIdentifierService
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_icn ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/debt_management_center/statement_identifier_service.rb', line 42 def get_icn mpi_response = get_mpi_profile if mpi_response.ok? StatsD.increment("#{STATSD_KEY_PREFIX}.mpi.success") mpi_response.profile.icn else StatsD.increment("#{STATSD_KEY_PREFIX}.mpi.failure") raise mpi_response.error end rescue *RETRYABLE_ERRORS => e raise RetryableError, e end |
#vista_account_id ⇒ Object
55 56 57 58 59 |
# File 'lib/debt_management_center/statement_identifier_service.rb', line 55 def vista_account_id offset = 16 - (@facility_id + @identifier).length padding = '0' * offset if offset >= 0 "#{@facility_id}#{padding}#{@identifier}" end |