Class: MPI::Responses::ParserBase
- Inherits:
-
Object
- Object
- MPI::Responses::ParserBase
- Defined in:
- lib/mpi/responses/parser_base.rb
Direct Known Subclasses
Constant Summary collapse
- EXTERNAL_RESPONSE_CODES =
MVI response code options.
{ success: 'AA', failure: 'AR', invalid_request: 'AE' }.freeze
Instance Method Summary collapse
-
#failed_or_invalid? ⇒ Boolean
MVI returns failed or invalid codes if the request is malformed or MVI throws an internal error.
-
#failed_request? ⇒ Boolean
MVI returns failed if MVI throws an internal error.
-
#initialize(code = nil) ⇒ ParserBase
constructor
A new instance of ParserBase.
-
#invalid_request? ⇒ Boolean
MVI returns invalid request if request is malformed.
- #locate_element(el, path) ⇒ Object
- #locate_elements(el, path) ⇒ Object
- #unknown_error? ⇒ Boolean
Constructor Details
#initialize(code = nil) ⇒ ParserBase
Returns a new instance of ParserBase.
13 14 15 |
# File 'lib/mpi/responses/parser_base.rb', line 13 def initialize(code = nil) @code = code end |
Instance Method Details
#failed_or_invalid? ⇒ Boolean
MVI returns failed or invalid codes if the request is malformed or MVI throws an internal error.
20 21 22 |
# File 'lib/mpi/responses/parser_base.rb', line 20 def failed_or_invalid? invalid_request? || failed_request? end |
#failed_request? ⇒ Boolean
MVI returns failed if MVI throws an internal error.
27 28 29 |
# File 'lib/mpi/responses/parser_base.rb', line 27 def failed_request? EXTERNAL_RESPONSE_CODES[:failure] == @code end |
#invalid_request? ⇒ Boolean
MVI returns invalid request if request is malformed.
34 35 36 |
# File 'lib/mpi/responses/parser_base.rb', line 34 def invalid_request? EXTERNAL_RESPONSE_CODES[:invalid_request] == @code end |
#locate_element(el, path) ⇒ Object
42 43 44 |
# File 'lib/mpi/responses/parser_base.rb', line 42 def locate_element(el, path) locate_elements(el, path)&.first end |
#locate_elements(el, path) ⇒ Object
46 47 48 49 50 |
# File 'lib/mpi/responses/parser_base.rb', line 46 def locate_elements(el, path) return [] unless el.present? && el.is_a?(Ox::Element) el.locate(path) end |
#unknown_error? ⇒ Boolean
38 39 40 |
# File 'lib/mpi/responses/parser_base.rb', line 38 def unknown_error? @code.nil? end |