Class: CzechPostB2bClient::ResponseParsers::SendParcelsParser
- Inherits:
-
BaseParser
- Object
- SteppedService::Base
- BaseParser
- CzechPostB2bClient::ResponseParsers::SendParcelsParser
- Defined in:
- lib/czech_post_b2b_client/response_parsers/send_parcels_parser.rb
Instance Attribute Summary
Attributes inherited from SteppedService::Base
Instance Method Summary collapse
- #build_result ⇒ Object
-
#cpost_time_zone ⇒ Object
just for info.
- #parse_time_with_correction(b2b_time_str) ⇒ Object
Methods inherited from BaseParser
Methods inherited from SteppedService::Base
call, #call, #errors, #failure?, #finished?, #steps, #success?
Constructor Details
This class inherits a constructor from CzechPostB2bClient::ResponseParsers::BaseParser
Instance Method Details
#build_result ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'lib/czech_post_b2b_client/response_parsers/send_parcels_parser.rb', line 6 def build_result super @result[:async_result] = { transaction_id: response_header.dig('idTransaction'), processing_end_expected_at: parse_time_with_correction(response_header.dig('timeStampProcessing')) } end |
#cpost_time_zone ⇒ Object
just for info
30 31 32 |
# File 'lib/czech_post_b2b_client/response_parsers/send_parcels_parser.rb', line 30 def cpost_time_zone timezone('Europe/Prague') end |
#parse_time_with_correction(b2b_time_str) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/czech_post_b2b_client/response_parsers/send_parcels_parser.rb', line 15 def parse_time_with_correction(b2b_time_str) # b2b time in XML is NOT CORRECT! They return CET time value with UTC timezone # Like `2016-02-25T09:30:03.678Z`, which is actually `2016-02-25T09:30:03.678+0100` (CET) # Or `2016-05-25T09:30:03.678Z`, which is actually `2016-05-25T09:30:03.678+0200` (CET + DST) # But we must be prepare for unnoticed fix by CPost # unfortunattely this can be done for only freshly generated XMLs (comparing b2b_time with Time.now.utc) # but we have to kepp it compatible for old XML # so we pass it up and leave comments in documenation # Users of this gem will have to care of it Time.parse(b2b_time_str) end |