class UPS::Parsers::BaseParser
Attributes
response[R]
Public Class Methods
new(response)
click to toggle source
# File lib/ups/parsers/base_parser.rb, line 9 def initialize(response) @response = response end
Public Instance Methods
error_description()
click to toggle source
# File lib/ups/parsers/base_parser.rb, line 25 def error_description build_error_description(error_response) end
parsed_response()
click to toggle source
# File lib/ups/parsers/base_parser.rb, line 29 def parsed_response @parsed_response ||= Ox.load(response, mode: :hash) end
status_code()
click to toggle source
# File lib/ups/parsers/base_parser.rb, line 17 def status_code root_response[:Response][:ResponseStatusCode] end
status_description()
click to toggle source
# File lib/ups/parsers/base_parser.rb, line 21 def status_description root_response[:Response][:ResponseStatusDescription] end
success?()
click to toggle source
# File lib/ups/parsers/base_parser.rb, line 13 def success? status_code == '1' end
Private Instance Methods
build_error_description(errors_node)
click to toggle source
# File lib/ups/parsers/base_parser.rb, line 39 def build_error_description(errors_node) return errors_node.last[:ErrorDescription] if errors_node.is_a?(Array) errors_node[:ErrorDescription] end
error_response()
click to toggle source
# File lib/ups/parsers/base_parser.rb, line 45 def error_response root_response[:Response][:Error] end
normalize_response_into_array(response_node)
click to toggle source
# File lib/ups/parsers/base_parser.rb, line 35 def normalize_response_into_array(response_node) [response_node].flatten end