Class: ActiveMerchant::Shipping::TrackingResponse

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

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.



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/active_shipping/shipping/tracking_response.rb', line 15

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]
  @scheduled_delivery_date = options[:scheduled_delivery_date]
  @tracking_number = options[:tracking_number]
  @shipment_events = Array(options[:shipment_events])
  @origin, @destination = options[:origin], options[:destination]
  super
end

Instance Attribute Details

#carrierObject (readonly)

symbol



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

def carrier
  @carrier
end

#carrier_nameObject (readonly)

string



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

def carrier_name
  @carrier_name
end

#destinationObject (readonly)

Returns the value of attribute destination.



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

def destination
  @destination
end

#originObject (readonly)

Returns the value of attribute origin.



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

def origin
  @origin
end

#scheduled_delivery_dateObject (readonly)

time



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

def scheduled_delivery_date
  @scheduled_delivery_date
end

#shipment_eventsObject (readonly)

array of ShipmentEvents in chronological order



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

def shipment_events
  @shipment_events
end

#statusObject (readonly)

symbol



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

def status
  @status
end

#status_codeObject (readonly)

string



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

def status_code
  @status_code
end

#status_descriptionObject (readonly)

string



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

def status_description
  @status_description
end

#tracking_numberObject (readonly)

string



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

def tracking_number
  @tracking_number
end

Instance Method Details

#has_exception?Boolean Also known as: exception?

Returns:

  • (Boolean)


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

def has_exception?
  @status == :exception
end

#is_delivered?Boolean Also known as: delivered?

Returns:

  • (Boolean)


32
33
34
# File 'lib/active_shipping/shipping/tracking_response.rb', line 32

def is_delivered?
  @status == :delivered
end

#latest_eventObject Also known as: exception_event



28
29
30
# File 'lib/active_shipping/shipping/tracking_response.rb', line 28

def latest_event
  @shipment_events.last
end