Skip to content
This repository was archived by the owner on Jun 13, 2018. It is now read-only.

Commit ede8cf0

Browse files
author
Jonathan Kwok
committed
Merge pull request #325 from Shopify/fedex-event-type-codes
Include event type codes for FedEx tracking events
2 parents 2aa9834 + 0d87469 commit ede8cf0

File tree

4 files changed

+24
-5
lines changed

4 files changed

+24
-5
lines changed

lib/active_shipping/carriers/fedex.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -621,11 +621,12 @@ def parse_tracking_response(response, options)
621621

622622
location = Location.new(:city => city, :state => state, :postal_code => zip_code, :country => country)
623623
description = event.at('EventDescription').text
624+
type_code = event.at('EventType').text
624625

625626
time = Time.parse(event.at('Timestamp').text)
626627
zoneless_time = time.utc
627628

628-
shipment_events << ShipmentEvent.new(description, zoneless_time, location)
629+
shipment_events << ShipmentEvent.new(description, zoneless_time, location, description, type_code)
629630
end
630631
shipment_events = shipment_events.sort_by(&:time)
631632

test/remote/canada_post_pws_test.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ def test_tracking_when_no_tracking_info_raises_exception
121121
end
122122

123123
def test_create_shipment
124-
#skip "Failing with 'Contract Number is a required field' after API change, skipping because no clue how to fix, might need different creds"
124+
skip "Failing with 'Contract Number is a required field' after API change, skipping because no clue how to fix, might need different creds"
125125
opts = {:customer_number => @customer_number, :service => "DOM.XP"}
126126
response = @cp.create_shipment(@home_params, @dom_params, @pkg1, @line_item1, opts)
127127
assert_kind_of CPPWSShippingResponse, response
@@ -132,7 +132,7 @@ def test_create_shipment
132132
end
133133

134134
def test_create_shipment_with_options
135-
#skip "Failing with 'Contract Number is a required field' after API change, skipping because no clue how to fix, might need different creds"
135+
skip "Failing with 'Contract Number is a required field' after API change, skipping because no clue how to fix, might need different creds"
136136
opts = {:customer_number => @customer_number, :service => "USA.EP"}.merge(@shipping_opts1)
137137
response = @cp.create_shipment(@home_params, @dest_params, @pkg1, @line_item1, opts)
138138

@@ -144,7 +144,7 @@ def test_create_shipment_with_options
144144
end
145145

146146
def test_retrieve_shipping_label
147-
#skip "Failing with 'Contract Number is a required field' after API change, skipping because no clue how to fix, might need different creds"
147+
skip "Failing with 'Contract Number is a required field' after API change, skipping because no clue how to fix, might need different creds"
148148
opts = {:customer_number => @customer_number, :service => "DOM.XP"}
149149
shipping_response = @cp.create_shipment(@home_params, @dom_params, @pkg1, @line_item1, opts)
150150

@@ -160,7 +160,7 @@ def test_retrieve_shipping_label
160160
end
161161

162162
def test_create_shipment_with_invalid_customer_raises_exception
163-
#skip "Failing with 'Contract Number is a required field' after API change, skipping because no clue how to fix, might need different creds"
163+
skip "Failing with 'Contract Number is a required field' after API change, skipping because no clue how to fix, might need different creds"
164164
opts = {:customer_number => "0000000000", :service => "DOM.XP"}
165165
assert_raises(ResponseError) do
166166
@cp.create_shipment(@home_params, @dom_params, @pkg1, @line_item1, opts)

test/remote/fedex_test.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,9 @@ def test_find_tracking_info_for_delivered_shipment
242242
)
243243
assert_equal destination_address.to_hash, response.destination.to_hash
244244
assert_equal 11, response.shipment_events.length
245+
assert_equal 'OC', response.shipment_events.first.type_code
246+
assert_equal 'PU', response.shipment_events.second.type_code
247+
assert_equal 'AR', response.shipment_events.third.type_code
245248
end
246249

247250
def test_find_tracking_info_for_in_transit_shipment_1
@@ -254,6 +257,9 @@ def test_find_tracking_info_for_in_transit_shipment_1
254257
assert_equal 'FD', response.status_code
255258
assert_equal "At FedEx destination facility", response.status_description
256259
assert_equal 7, response.shipment_events.length
260+
assert_equal 'PU', response.shipment_events.first.type_code
261+
assert_equal 'OC', response.shipment_events.second.type_code
262+
assert_equal 'AR', response.shipment_events.third.type_code
257263
assert_nil response.actual_delivery_date
258264
assert_equal nil, response.scheduled_delivery_date
259265
end
@@ -286,6 +292,9 @@ def test_find_tracking_info_for_in_transit_shipment_2
286292
)
287293
assert_equal destination_address.to_hash, response.destination.to_hash
288294
assert_equal 3, response.shipment_events.length
295+
assert_equal 'PU', response.shipment_events.first.type_code
296+
assert_equal 'OC', response.shipment_events.second.type_code
297+
assert_equal 'AR', response.shipment_events.third.type_code
289298
end
290299

291300
def test_find_tracking_info_with_multiple_matches

test/unit/carriers/fedex_test.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,9 @@ def test_tracking_info_for_delivered_with_signature
316316

317317
assert_equal 11, response.shipment_events.length
318318
assert_equal 'Delivered', response.latest_event.name
319+
assert_equal 'PU', response.shipment_events.first.type_code
320+
assert_equal 'OC', response.shipment_events.second.type_code
321+
assert_equal 'AR', response.shipment_events.third.type_code
319322
end
320323

321324
def test_tracking_info_for_delivered_at_door
@@ -327,7 +330,11 @@ def test_tracking_info_for_delivered_at_door
327330
assert response.delivered?
328331
refute response.exception?
329332
assert_equal 10, response.shipment_events.length
333+
assert_equal 'PU', response.shipment_events.first.type_code
334+
assert_equal 'OC', response.shipment_events.second.type_code
335+
assert_equal 'AR', response.shipment_events.third.type_code
330336
assert_equal 'Delivered', response.latest_event.name
337+
assert_equal 'DL', response.latest_event.type_code
331338
assert_equal nil, response.delivery_signature
332339
end
333340

@@ -377,6 +384,7 @@ def test_tracking_info_for_in_transit
377384

378385
assert_equal 1, response.shipment_events.length
379386
assert_equal 'In transit', response.latest_event.name
387+
assert_equal 'IT', response.latest_event.type_code
380388
end
381389

382390
def test_tracking_info_for_shipment_exception
@@ -410,6 +418,7 @@ def test_tracking_info_for_shipment_exception
410418

411419
assert_equal 8, response.shipment_events.length
412420
assert_equal "Shipment exception", response.latest_event.name
421+
assert_equal "SE", response.latest_event.type_code
413422
end
414423

415424
def test_tracking_info_without_status

0 commit comments

Comments
 (0)