Class: ActiveMerchant::Shipping::TrackingResponse

Inherits:
Response show all
Defined in:
lib/active_shipping/shipping/tracking_response.rb

Direct Known Subclasses

CPPWSTrackingResponse

Instance Attribute Summary collapse

Attributes inherited from Response

#message, #params, #request, #test, #xml

Instance Method Summary collapse

Methods inherited from Response

#success?, #test?

Constructor Details

#initialize(success, message, params = {}, options = {}) ⇒ TrackingResponse

Returns a new instance of TrackingResponse


17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/active_shipping/shipping/tracking_response.rb', line 17

def initialize(success, message, params = {}, options = {})
  @carrier = options[:carrier].parameterize.to_sym
  @carrier_name = options[:carrier]
  @status = options[:status]
  @status_code = options[:status_code]
  @status_description = options[:status_description]
  @ship_time = options[:ship_time]
  @scheduled_delivery_date = options[:scheduled_delivery_date]
  @actual_delivery_date = options[:actual_delivery_date]
  @delivery_signature = options[:delivery_signature]
  @tracking_number = options[:tracking_number]
  @shipment_events = Array(options[:shipment_events])
  @shipper_address = options[:shipper_address]
  @origin = options[:origin]
  @destination = options[:destination]
  super
end

Instance Attribute Details

#actual_delivery_dateObject (readonly) Also known as: actual_delivery_time

time


11
12
13
# File 'lib/active_shipping/shipping/tracking_response.rb', line 11

def actual_delivery_date
  @actual_delivery_date
end

#carrierObject (readonly)

symbol


4
5
6
# File 'lib/active_shipping/shipping/tracking_response.rb', line 4

def carrier
  @carrier
end

#carrier_nameObject (readonly)

string


5
6
7
# File 'lib/active_shipping/shipping/tracking_response.rb', line 5

def carrier_name
  @carrier_name
end

#delivery_signatureObject (readonly)

string


12
13
14
# File 'lib/active_shipping/shipping/tracking_response.rb', line 12

def delivery_signature
  @delivery_signature
end

#destinationObject (readonly)

Location objects


15
16
17
# File 'lib/active_shipping/shipping/tracking_response.rb', line 15

def destination
  @destination
end

#originObject (readonly)

Location objects


15
16
17
# File 'lib/active_shipping/shipping/tracking_response.rb', line 15

def origin
  @origin
end

#scheduled_delivery_dateObject (readonly) Also known as: scheduled_delivery_time

time


10
11
12
# File 'lib/active_shipping/shipping/tracking_response.rb', line 10

def scheduled_delivery_date
  @scheduled_delivery_date
end

#ship_timeObject (readonly)

time


9
10
11
# File 'lib/active_shipping/shipping/tracking_response.rb', line 9

def ship_time
  @ship_time
end

#shipment_eventsObject (readonly)

array of ShipmentEvents in chronological order


14
15
16
# File 'lib/active_shipping/shipping/tracking_response.rb', line 14

def shipment_events
  @shipment_events
end

#shipper_addressObject (readonly)

Location objects


15
16
17
# File 'lib/active_shipping/shipping/tracking_response.rb', line 15

def shipper_address
  @shipper_address
end

#statusObject (readonly)

symbol


6
7
8
# File 'lib/active_shipping/shipping/tracking_response.rb', line 6

def status
  @status
end

#status_codeObject (readonly)

string


7
8
9
# File 'lib/active_shipping/shipping/tracking_response.rb', line 7

def status_code
  @status_code
end

#status_descriptionObject (readonly)

string


8
9
10
# File 'lib/active_shipping/shipping/tracking_response.rb', line 8

def status_description
  @status_description
end

#tracking_numberObject (readonly)

string


13
14
15
# File 'lib/active_shipping/shipping/tracking_response.rb', line 13

def tracking_number
  @tracking_number
end

Instance Method Details

#has_exception?Boolean Also known as: exception?

Returns:

  • (Boolean)

43
44
45
# File 'lib/active_shipping/shipping/tracking_response.rb', line 43

def has_exception?
  @status == :exception
end

#is_delivered?Boolean Also known as: delivered?

Returns:

  • (Boolean)

39
40
41
# File 'lib/active_shipping/shipping/tracking_response.rb', line 39

def is_delivered?
  @status == :delivered
end

#latest_eventObject Also known as: exception_event


35
36
37
# File 'lib/active_shipping/shipping/tracking_response.rb', line 35

def latest_event
  @shipment_events.last
end