Class: Shippinglogic::FedEx::Track::Details

Inherits:
Object
  • Object
show all
Defined in:
lib/shippinglogic/fedex/track.rb

Defined Under Namespace

Classes: Event

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ Details

Returns a new instance of Details.



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/shippinglogic/fedex/track.rb', line 63

def initialize(response)
  details = response[:track_details]
  
  self.origin_city = details[:origin_location_address][:city]
  self.origin_state = details[:origin_location_address][:state_or_province_code]
  self.origin_country = details[:origin_location_address][:country_code]
  self.origin_residential = details[:origin_location_address][:residential] == "true"
  
  self.destination_city = details[:destination_address][:city]
  self.destination_state = details[:destination_address][:state_or_province_code]
  self.destination_country = details[:destination_address][:country_code]
  self.destination_residential = details[:destination_address][:residential] == "true"
  
  self.signature_name = details[:delivery_signature_name]
  self.service_type = details[:service_type]
  self.status = details[:status_description]
  self.delivery_at = Time.parse(details[:actual_delivery_timestamp])
  
  self.events = response[:track_details][:events].collect do |details|
    event = Event.new
    event.name = details[:event_description]
    event.type = details[:event_type]
    event.occured_at = Time.parse(details[:timestamp])
    event.city = details[:address][:city]
    event.state = details[:address][:state_or_province_code]
    event.postal_code = details[:address][:postal_code]
    event.country = details[:address][:country_code]
    event.residential = details[:address][:residential] == "true"
    event
  end
end

Instance Attribute Details

#delivery_atObject

Returns the value of attribute delivery_at.



41
42
43
# File 'lib/shippinglogic/fedex/track.rb', line 41

def delivery_at
  @delivery_at
end

#destination_cityObject

Returns the value of attribute destination_city.



41
42
43
# File 'lib/shippinglogic/fedex/track.rb', line 41

def destination_city
  @destination_city
end

#destination_countryObject

Returns the value of attribute destination_country.



41
42
43
# File 'lib/shippinglogic/fedex/track.rb', line 41

def destination_country
  @destination_country
end

#destination_residentialObject

Returns the value of attribute destination_residential.



41
42
43
# File 'lib/shippinglogic/fedex/track.rb', line 41

def destination_residential
  @destination_residential
end

#destination_stateObject

Returns the value of attribute destination_state.



41
42
43
# File 'lib/shippinglogic/fedex/track.rb', line 41

def destination_state
  @destination_state
end

#eventsObject

Returns the value of attribute events.



41
42
43
# File 'lib/shippinglogic/fedex/track.rb', line 41

def events
  @events
end

#origin_cityObject

Returns the value of attribute origin_city.



41
42
43
# File 'lib/shippinglogic/fedex/track.rb', line 41

def origin_city
  @origin_city
end

#origin_countryObject

Returns the value of attribute origin_country.



41
42
43
# File 'lib/shippinglogic/fedex/track.rb', line 41

def origin_country
  @origin_country
end

#origin_residentialObject

Returns the value of attribute origin_residential.



41
42
43
# File 'lib/shippinglogic/fedex/track.rb', line 41

def origin_residential
  @origin_residential
end

#origin_stateObject

Returns the value of attribute origin_state.



41
42
43
# File 'lib/shippinglogic/fedex/track.rb', line 41

def origin_state
  @origin_state
end

#service_typeObject

Returns the value of attribute service_type.



41
42
43
# File 'lib/shippinglogic/fedex/track.rb', line 41

def service_type
  @service_type
end

#signature_nameObject

Returns the value of attribute signature_name.



41
42
43
# File 'lib/shippinglogic/fedex/track.rb', line 41

def signature_name
  @signature_name
end

#statusObject

Returns the value of attribute status.



41
42
43
# File 'lib/shippinglogic/fedex/track.rb', line 41

def status
  @status
end

Instance Method Details

#destination_residential?Boolean

Returns:

  • (Boolean)


59
60
61
# File 'lib/shippinglogic/fedex/track.rb', line 59

def destination_residential?
  destination_residential == true
end

#origin_residential?Boolean

Returns:

  • (Boolean)


55
56
57
# File 'lib/shippinglogic/fedex/track.rb', line 55

def origin_residential?
  origin_residential == true
end