Class: MPI::Responses::AddParser
- Inherits:
-
ParserBase
- Object
- ParserBase
- MPI::Responses::AddParser
- Includes:
- Identity::Parsers::GCIds, SentryLogging
- Defined in:
- lib/mpi/responses/add_parser.rb
Overview
Parses an MVI response and returns an MviProfile
Constant Summary collapse
- ACKNOWLEDGEMENT_DETAIL_CODE_XPATH =
'acknowledgement/acknowledgementDetail/code'
- ACKNOWLEDGEMENT_DETAIL_TEXT_XPATH =
'acknowledgement/acknowledgementDetail/text'
- ACKNOWLEDGEMENT_TARGET_MESSAGE_ID_EXTENSION_XPATH =
'acknowledgement/targetMessage/id/@extension'
- BODY_XPATH =
'env:Envelope/env:Body/idm:MCCI_IN000002UV01'
- CODE_XPATH =
'acknowledgement/typeCode/@code'
Constants included from Identity::Parsers::GCIdsConstants
Identity::Parsers::GCIdsConstants::ACTIVE_MHV_IDS_REGEX, Identity::Parsers::GCIdsConstants::BIRLS_IDS_REGEX, Identity::Parsers::GCIdsConstants::CERNER_FACILITY_IDS_REGEX, Identity::Parsers::GCIdsConstants::CERNER_ID_REGEX, Identity::Parsers::GCIdsConstants::DOD_ROOT_OID, Identity::Parsers::GCIdsConstants::EDIPI_REGEX, Identity::Parsers::GCIdsConstants::ICN_ASSIGNING_AUTHORITY_ID, Identity::Parsers::GCIdsConstants::ICN_REGEX, Identity::Parsers::GCIdsConstants::IDENTIFIERS_SPLIT_TOKEN, Identity::Parsers::GCIdsConstants::IDME_ID_REGEX, Identity::Parsers::GCIdsConstants::IDS_SPLIT_TOKEN, Identity::Parsers::GCIdsConstants::ID_MAPPINGS, Identity::Parsers::GCIdsConstants::LOGINGOV_ID_REGEX, Identity::Parsers::GCIdsConstants::MHV_IDS_REGEX, Identity::Parsers::GCIdsConstants::MHV_IEN_REGEX, Identity::Parsers::GCIdsConstants::PERMANENT_ICN_REGEX, Identity::Parsers::GCIdsConstants::SEC_ID_REGEX, Identity::Parsers::GCIdsConstants::VA_ROOT_OID, Identity::Parsers::GCIdsConstants::VBA_CORP_ID_REGEX, Identity::Parsers::GCIdsConstants::VET360_ID_REGEX, Identity::Parsers::GCIdsConstants::VHA_FACILITY_IDS_REGEX
Constants inherited from ParserBase
ParserBase::EXTERNAL_RESPONSE_CODES
Instance Method Summary collapse
- #error_details(mpi_codes) ⇒ Object
-
#initialize(response) ⇒ ProfileParser
constructor
Creates a new parser instance.
-
#parse ⇒ Array
Parse the response.
Methods included from Identity::Parsers::GCIds
#parse_string_gcids, #parse_xml_gcids
Methods included from Identity::Parsers::GCIdsHelper
#sanitize_edipi, #sanitize_id, #sanitize_id_array
Methods included from SentryLogging
#log_exception_to_sentry, #log_message_to_sentry, #non_nil_hash?, #normalize_level, #rails_logger
Methods inherited from ParserBase
#failed_or_invalid?, #failed_request?, #invalid_request?, #locate_element, #locate_elements, #unknown_error?
Constructor Details
#initialize(response) ⇒ ProfileParser
Creates a new parser instance.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/mpi/responses/add_parser.rb', line 24 def initialize(response) @original_body = locate_element(response.body, BODY_XPATH) @code = locate_element(@original_body, CODE_XPATH) @transaction_id = response.response_headers['x-global-transaction-id'] if failed_or_invalid? PersonalInformationLog.create( error_class: 'MPI::Errors', data: { payload: response.body } ) end end |
Instance Method Details
#error_details(mpi_codes) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/mpi/responses/add_parser.rb', line 50 def error_details(mpi_codes) error_details = { ack_detail_code: @code, id_extension: locate_element(@original_body, ACKNOWLEDGEMENT_TARGET_MESSAGE_ID_EXTENSION_XPATH), error_texts: [] } error_text_nodes = locate_elements(@original_body, ACKNOWLEDGEMENT_DETAIL_TEXT_XPATH) if error_text_nodes.nil? error_details[:error_texts] = error_text_nodes else error_text_nodes.each do |node| error_text = node.text || node&.nodes&.first&.value error_details[:error_texts].append(error_text) unless error_details[:error_texts].include?(error_text) end end mpi_codes[:error_details] = error_details mpi_codes rescue mpi_codes end |
#parse ⇒ Array
Parse the response.
42 43 44 45 46 47 48 |
# File 'lib/mpi/responses/add_parser.rb', line 42 def parse raw_codes = locate_elements(@original_body, ACKNOWLEDGEMENT_DETAIL_CODE_XPATH) return [] unless raw_codes attributes = raw_codes.map(&:attributes) parse_ids(attributes).merge({ transaction_id: @transaction_id }) end |