class PocztaPolska::Event
The Event
class stores information about a point on the package's way.
Attributes
data[R]
@return [Hash] Original data from the XML response
Public Class Methods
new(data)
click to toggle source
# File lib/poczta_polska/event.rb, line 8 def initialize(data) @data = data end
Public Instance Methods
code()
click to toggle source
@return [Symbol] code of the event
# File lib/poczta_polska/event.rb, line 18 def code @data[:kod].to_sym end
final?()
click to toggle source
@return [Boolean] whether this is the final event (delivery, receiving in the post office, etc.)
# File lib/poczta_polska/event.rb, line 33 def final? @data[:konczace] end
name()
click to toggle source
@return [String] human-readable name of the event
# File lib/poczta_polska/event.rb, line 23 def name @data[:nazwa].to_s end
office()
click to toggle source
@return [String] name of the post office
# File lib/poczta_polska/event.rb, line 28 def office @data[:jednostka][:nazwa].to_s end
office_details()
click to toggle source
Returns detailed information about the post office connected with this event, only if the {Tracker#check}/{Tracker#check_many} method was called with details
set to true
. @return [Office]
# File lib/poczta_polska/event.rb, line 41 def office_details office = @data[:jednostka][:dane_szczegolowe] Office.new(office) unless office.nil? end
reason()
click to toggle source
Returns a reason of the event (available only for certain events and certain users) or nil
. The keys in the hash are :code
and :name
. @return [Hash]
# File lib/poczta_polska/event.rb, line 49 def reason { code: @data[:przyczyna][:kod].to_sym, name: @data[:przyczyna][:nazwa].to_s } unless @data[:przyczyna].nil? end
time()
click to toggle source
@return [DateTime] date and time of the event
# File lib/poczta_polska/event.rb, line 13 def time DateTime.parse(@data[:czas]) end