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.



57
58
59
60
61
62
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
# File 'lib/shippinglogic/fedex/track.rb', line 57

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.tracking_number = details[:tracking_number]
  
  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.



34
35
36
# File 'lib/shippinglogic/fedex/track.rb', line 34

def delivery_at
  @delivery_at
end

#destination_cityObject

Returns the value of attribute destination_city.



34
35
36
# File 'lib/shippinglogic/fedex/track.rb', line 34

def destination_city
  @destination_city
end

#destination_countryObject

Returns the value of attribute destination_country.



34
35
36
# File 'lib/shippinglogic/fedex/track.rb', line 34

def destination_country
  @destination_country
end

#destination_residentialObject

Returns the value of attribute destination_residential.



34
35
36
# File 'lib/shippinglogic/fedex/track.rb', line 34

def destination_residential
  @destination_residential
end

#destination_stateObject

Returns the value of attribute destination_state.



34
35
36
# File 'lib/shippinglogic/fedex/track.rb', line 34

def destination_state
  @destination_state
end

#eventsObject

Returns the value of attribute events.



34
35
36
# File 'lib/shippinglogic/fedex/track.rb', line 34

def events
  @events
end

#origin_cityObject

Returns the value of attribute origin_city.



34
35
36
# File 'lib/shippinglogic/fedex/track.rb', line 34

def origin_city
  @origin_city
end

#origin_countryObject

Returns the value of attribute origin_country.



34
35
36
# File 'lib/shippinglogic/fedex/track.rb', line 34

def origin_country
  @origin_country
end

#origin_residentialObject

Returns the value of attribute origin_residential.



34
35
36
# File 'lib/shippinglogic/fedex/track.rb', line 34

def origin_residential
  @origin_residential
end

#origin_stateObject

Returns the value of attribute origin_state.



34
35
36
# File 'lib/shippinglogic/fedex/track.rb', line 34

def origin_state
  @origin_state
end

#service_typeObject

Returns the value of attribute service_type.



34
35
36
# File 'lib/shippinglogic/fedex/track.rb', line 34

def service_type
  @service_type
end

#signature_nameObject

Returns the value of attribute signature_name.



34
35
36
# File 'lib/shippinglogic/fedex/track.rb', line 34

def signature_name
  @signature_name
end

#statusObject

Returns the value of attribute status.



34
35
36
# File 'lib/shippinglogic/fedex/track.rb', line 34

def status
  @status
end

#tracking_numberObject

Returns the value of attribute tracking_number.



34
35
36
# File 'lib/shippinglogic/fedex/track.rb', line 34

def tracking_number
  @tracking_number
end

Instance Method Details

#destination_residential?Boolean

Returns:

  • (Boolean)


53
54
55
# File 'lib/shippinglogic/fedex/track.rb', line 53

def destination_residential?
  destination_residential == true
end

#origin_residential?Boolean

Returns:

  • (Boolean)


49
50
51
# File 'lib/shippinglogic/fedex/track.rb', line 49

def origin_residential?
  origin_residential == true
end