Class: UPS::Parsers::TrackParser
Instance Attribute Summary
Attributes inherited from BaseParser
#response
Instance Method Summary
collapse
Methods inherited from BaseParser
#error_description, #parsed_response, #status_code, #status_description, #success?
Constructor Details
#initialize(response) ⇒ TrackParser
Returns a new instance of TrackParser.
7
8
9
10
|
# File 'lib/ups/parsers/track_parser.rb', line 7
def initialize(response)
super(response.gsub(/\\"/, '"').gsub(/\\n/, "\n"))
end
|
Instance Method Details
#activities ⇒ Object
20
21
22
|
# File 'lib/ups/parsers/track_parser.rb', line 20
def activities
normalize_response_into_array(root_response[:Shipment][:Package][:Activity])
end
|
#status_date ⇒ Object
24
25
26
|
# File 'lib/ups/parsers/track_parser.rb', line 24
def status_date
Date.parse(latest_activity[:Date])
end
|
#status_type_code ⇒ Object
32
33
34
|
# File 'lib/ups/parsers/track_parser.rb', line 32
def status_type_code
status_type[:Code]
end
|
#status_type_description ⇒ Object
28
29
30
|
# File 'lib/ups/parsers/track_parser.rb', line 28
def status_type_description
status_type[:Description]
end
|
#to_h ⇒ Object
12
13
14
15
16
17
18
|
# File 'lib/ups/parsers/track_parser.rb', line 12
def to_h
{
status_date: status_date,
status_type_description: status_type_description,
status_type_code: status_type_code
}
end
|