class PocztaPolska::Package
The Package
class contains all necessary information about a tracked package.
Attributes
@return [Hash] Original data from the XML response
Public Class Methods
# File lib/poczta_polska/package.rb, line 8 def initialize(data) @data = data end
Public Instance Methods
@return [Symbol] origin country code
# File lib/poczta_polska/package.rb, line 28 def country_from @data[:dane_przesylki][:kod_kraju_nadania].to_sym end
@return [String] origin country name
# File lib/poczta_polska/package.rb, line 33 def country_from_str @data[:dane_przesylki][:kraj_nadania].to_s end
@return [Symbol] destination country code
# File lib/poczta_polska/package.rb, line 38 def country_to @data[:dane_przesylki][:kod_kraju_przezn].to_sym end
@return [String] destination country name
# File lib/poczta_polska/package.rb, line 43 def country_to_str @data[:dane_przesylki][:kraj_przezn].to_s end
Returns a list of all events connected with the package @return [Array<Event>]
# File lib/poczta_polska/package.rb, line 87 def events @data[:dane_przesylki][:zdarzenia][:zdarzenie]&.map { |e| Event.new(e) } || [] end
@return [String] package ID
# File lib/poczta_polska/package.rb, line 13 def id @data[:numer].to_s end
@return [Float] mass of the package
# File lib/poczta_polska/package.rb, line 58 def mass @data[:dane_przesylki][:masa] end
@return [String] origin post office name
# File lib/poczta_polska/package.rb, line 48 def office_from @data[:dane_przesylki][:urzad_nadania][:nazwa].to_s end
Returns detailed information about the origin post office, only if the {Tracker#check}/{Tracker#check_many} method was called with details
set to true
. @return [Office]
# File lib/poczta_polska/package.rb, line 71 def office_from_details office = @data[:dane_przesylki][:urzad_nadania][:dane_szczegolowe] Office.new(office) unless office.nil? end
@return [String] destination post office name
# File lib/poczta_polska/package.rb, line 53 def office_to @data[:dane_przesylki][:urzad_przezn][:nazwa].to_s end
Returns detailed information about the destination post office, only if the {Tracker#check}/{Tracker#check_many} method was called with details
set to true
. @return [Office]
# File lib/poczta_polska/package.rb, line 80 def office_to_details office = @data[:dane_przesylki][:urzad_przezn][:dane_szczegolowe] Office.new(office) unless office.nil? end
@return [Boolean] whether the service has been finished (delivered, received in the post office, etc.)
# File lib/poczta_polska/package.rb, line 63 def ready? @data[:dane_przesylki][:zakonczono_obsluge] end
@return [Symbol] package type code
# File lib/poczta_polska/package.rb, line 18 def type @data[:dane_przesylki][:kod_rodz_przes].to_sym end
@return [String] human-readable package type
# File lib/poczta_polska/package.rb, line 23 def type_str @data[:dane_przesylki][:rodz_przes].to_s end