Class: UPS::Parsers::BaseParser

Inherits:
Object
  • Object
show all
Defined in:
lib/ups/parsers/base_parser.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ BaseParser

Returns a new instance of BaseParser.



9
10
11
# File 'lib/ups/parsers/base_parser.rb', line 9

def initialize(response)
  @response = response
end

Instance Attribute Details

#responseObject (readonly)

Returns the value of attribute response.



7
8
9
# File 'lib/ups/parsers/base_parser.rb', line 7

def response
  @response
end

Instance Method Details

#error_descriptionObject



25
26
27
# File 'lib/ups/parsers/base_parser.rb', line 25

def error_description
  build_error_description(error_response)
end

#parsed_responseObject



29
30
31
# File 'lib/ups/parsers/base_parser.rb', line 29

def parsed_response
  @parsed_response ||= Ox.load(response, mode: :hash)
end

#status_codeObject



17
18
19
# File 'lib/ups/parsers/base_parser.rb', line 17

def status_code
  root_response[:Response][:ResponseStatusCode]
end

#status_descriptionObject



21
22
23
# File 'lib/ups/parsers/base_parser.rb', line 21

def status_description
  root_response[:Response][:ResponseStatusDescription]
end

#success?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/ups/parsers/base_parser.rb', line 13

def success?
  status_code == '1'
end