active_shipping 1.4.0 → 1.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 02e598e6f3f22df641b4384ef5bfac4ccf12adf5
4
- data.tar.gz: 3f85700bd9c69ba3d5c3b21b84d7c42c9ec66487
3
+ metadata.gz: dd48481b481a814eb384648586dedb803fee087a
4
+ data.tar.gz: 3afaa54b882c0e9c99d9e48ff44ebcce7bf0c529
5
5
  SHA512:
6
- metadata.gz: 34bdf173c3c6b0aee4b3ef7fdb36a4c502e87d4a79d14d9d5bff1a545638f97143ba9504424d77d6bfbd73f9f5c5659ac650e9adc1bd180d0974b5f9de39a0a4
7
- data.tar.gz: 73b86a63d94164dc3a7c2f0fb3b3d7c5c1a6f2c248308426b3fffb96142d70a76cc572202d9b03aea745472871d66a7f6061d2eb233c7e0f69a6da6c8c3dba91
6
+ metadata.gz: 3f91853a5d54afa636178fa34187c466f72cae2135f99e54a405069062078598ee931ec41989fc51ca3c5d2696b26573f558d52671d49d8ece796f5553185e33
7
+ data.tar.gz: 2f7eca19d72c45b2c74b6f6f14f3f0bc8c5644f578d778f54fb24e9f19453fda5be338f101533141dcef279c3bf2d2999eccb4838528daa52d92b5f8444ba77f
data/.travis.yml CHANGED
@@ -17,3 +17,9 @@ env:
17
17
  global:
18
18
  - ACTIVESHIPPING_NEW_ZEALAND_POST_KEY=4d9dc0f0-dda0-012e-066f-000c29b44ac0
19
19
  - ACTIVESHIPPING_CANADA_POST_LOGIN=CPC_DEMO_XML
20
+ - ACTIVESHIPPING_USPS_LOGIN=677JADED7283
21
+ - ACTIVESHIPPING_UPS_LOGIN=shopifolk
22
+ - ACTIVESHIPPING_UPS_KEY=7CE85DED4C9D07AB
23
+ - ACTIVESHIPPING_UPS_PASSWORD=Shopify_rocks
24
+ - ACTIVESHIPPING_UPS_ORIGIN_ACCOUNT=X3V606
25
+ - ACTIVESHIPPING_UPS_ORIGIN_NAME=Shopify
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # ActiveShipping CHANGELOG
2
2
 
3
+ ### v1.4.1
4
+
5
+ - Raise error on invalid status code with FedEx
6
+ - Fix USPS tracking to certain countries
7
+ - Fix USPS tracking of events with no time
8
+ - Fix USPS batch tracking error messages.
9
+ - Fix FedEx logging exception
10
+
3
11
  ### v1.4.0
4
12
 
5
13
  - Added support for USPS merchant returns service
@@ -171,8 +171,6 @@ module ActiveShipping
171
171
  request = build_shipment_request(origin, destination, packages, options)
172
172
  logger.debug(request) if logger
173
173
 
174
- logger.debug(confirm_response) if logger
175
-
176
174
  response = commit(save_request(request), (options[:test] || false))
177
175
  parse_ship_response(response)
178
176
  end
@@ -585,7 +583,11 @@ module ActiveShipping
585
583
  raise ActiveShipping::Error, "Tracking response does not contain status information"
586
584
  end
587
585
 
588
- status_code = status_detail.at('Code').text
586
+ status_code = status_detail.at('Code').try(:text)
587
+ if status_code.nil?
588
+ raise ActiveShipping::Error, "Tracking response does not contain status code"
589
+ end
590
+
589
591
  status_description = (status_detail.at('AncillaryDetails/ReasonDescription') || status_detail.at('Description')).text
590
592
  status = TRACKING_STATUS_CODES[status_code]
591
593
 
@@ -154,6 +154,13 @@ module ActiveShipping
154
154
  "WS" => "Western Samoa"
155
155
  }
156
156
 
157
+ TRACKING_ODD_COUNTRY_NAMES = {
158
+ 'TAIWAN' => 'TW',
159
+ 'MACEDONIA THE FORMER YUGOSLAV REPUBLIC OF'=> 'MK',
160
+ 'MICRONESIA FEDERATED STATES OF' => 'FM',
161
+ 'MOLDOVA REPUBLIC OF' => 'MD',
162
+ }
163
+
157
164
  RESPONSE_ERROR_MESSAGES = [
158
165
  /There is no record of that mail item/,
159
166
  /This Information has not been included in this Test Server\./,
@@ -238,7 +245,14 @@ module ActiveShipping
238
245
  description = prefix
239
246
  end
240
247
 
241
- timestamp = "#{node.at('EventDate').text}, #{node.at('EventTime').text}"
248
+ time = if node.at('EventDate').text.present?
249
+ timestamp = "#{node.at('EventDate').text}, #{node.at('EventTime').text}"
250
+ Time.parse(timestamp)
251
+ else
252
+ # Arbitrary time in past, because we need to sort properly by time
253
+ Time.parse("Jan 01, 2000")
254
+ end
255
+
242
256
  event_code = node.at('EventCode').text
243
257
  city = node.at('EventCity').try(:text)
244
258
  state = node.at('EventState').try(:text)
@@ -250,7 +264,6 @@ module ActiveShipping
250
264
  # USPS returns upcased country names which ActiveUtils doesn't recognize without translation
251
265
  country = find_country_code_case_insensitive(country)
252
266
 
253
- time = Time.parse(timestamp)
254
267
  zoneless_time = Time.utc(time.year, time.month, time.mday, time.hour, time.min, time.sec)
255
268
  location = Location.new(city: city, state: state, postal_code: zip_code, country: country)
256
269
  EventDetails.new(description, time, zoneless_time, location, event_code)
@@ -639,7 +652,7 @@ module ActiveShipping
639
652
  end
640
653
 
641
654
  def error_description_node(node)
642
- node.xpath('//Error/Description')
655
+ node.xpath('Error/Description')
643
656
  end
644
657
 
645
658
  def response_status_node(node)
@@ -655,7 +668,10 @@ module ActiveShipping
655
668
  end
656
669
 
657
670
  def find_country_code_case_insensitive(name)
658
- upcase_name = name.upcase
671
+ upcase_name = name.upcase.gsub(' ', ', ')
672
+ if special = TRACKING_ODD_COUNTRY_NAMES[upcase_name]
673
+ return special
674
+ end
659
675
  country = ActiveUtils::Country::COUNTRIES.detect { |c| c[:name].upcase == upcase_name }
660
676
  raise ActiveShipping::Error, "No country found for #{name}" unless country
661
677
  country[:alpha2]
@@ -1,3 +1,3 @@
1
1
  module ActiveShipping
2
- VERSION = "1.4.0"
2
+ VERSION = "1.4.1"
3
3
  end
@@ -0,0 +1,84 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <TrackReply xmlns="http://fedex.com/ws/track/v7" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
3
+ <HighestSeverity>SUCCESS</HighestSeverity>
4
+ <Notifications>
5
+ <Severity>SUCCESS</Severity>
6
+ <Source>trck</Source>
7
+ <Code>0</Code>
8
+ <Message>Request was successfully processed.</Message>
9
+ <LocalizedMessage>Request was successfully processed.</LocalizedMessage>
10
+ </Notifications>
11
+ <TransactionDetail>
12
+ <CustomerTransactionId>ActiveShipping</CustomerTransactionId>
13
+ </TransactionDetail>
14
+ <Version>
15
+ <ServiceId>trck</ServiceId>
16
+ <Major>7</Major>
17
+ <Intermediate>0</Intermediate>
18
+ <Minor>0</Minor>
19
+ </Version>
20
+ <CompletedTrackDetails>
21
+ <HighestSeverity>SUCCESS</HighestSeverity>
22
+ <Notifications>
23
+ <Severity>SUCCESS</Severity>
24
+ <Source>trck</Source>
25
+ <Code>0</Code>
26
+ <Message>Request was successfully processed.</Message>
27
+ <LocalizedMessage>Request was successfully processed.</LocalizedMessage>
28
+ </Notifications>
29
+ <DuplicateWaybill>false</DuplicateWaybill>
30
+ <MoreData>false</MoreData>
31
+ <TrackDetails>
32
+ <Notification>
33
+ <Severity>SUCCESS</Severity>
34
+ <Source>trck</Source>
35
+ <Code>0</Code>
36
+ <Message>Request was successfully processed.</Message>
37
+ <LocalizedMessage>Request was successfully processed.</LocalizedMessage>
38
+ </Notification>
39
+ <TrackingNumber>123456789012</TrackingNumber>
40
+ <TrackingNumberUniqueIdentifier>123456789012~123456789012~FX</TrackingNumberUniqueIdentifier>
41
+ <CarrierCode>FDXE</CarrierCode>
42
+ <OperatingCompanyOrCarrierDescription>FedEx Express</OperatingCompanyOrCarrierDescription>
43
+ <Service>
44
+ <Type>STANDARD_OVERNIGHT</Type>
45
+ <Description>FedEx Standard Overnight</Description>
46
+ </Service>
47
+ <PackageSequenceNumber>0</PackageSequenceNumber>
48
+ <PackageCount>0</PackageCount>
49
+ <SpecialHandlings>
50
+ <Type>DELIVER_WEEKDAY</Type>
51
+ <Description>Deliver Weekday</Description>
52
+ <PaymentType>OTHER</PaymentType>
53
+ </SpecialHandlings>
54
+ <SpecialHandlings>
55
+ <Type>RESIDENTIAL_DELIVERY</Type>
56
+ <Description>Residential Delivery</Description>
57
+ <PaymentType>OTHER</PaymentType>
58
+ </SpecialHandlings>
59
+ <SpecialHandlings>
60
+ <Type>DIRECT_SIGNATURE_OPTION</Type>
61
+ <Description>Direct Signature Required</Description>
62
+ <PaymentType>OTHER</PaymentType>
63
+ </SpecialHandlings>
64
+ <ShipTimestamp>2014-05-30T12:19:00+00:00</ShipTimestamp>
65
+ <DestinationAddress>
66
+ <City>COLUMBIA</City>
67
+ <StateOrProvinceCode>SC</StateOrProvinceCode>
68
+ <CountryCode>US</CountryCode>
69
+ <CountryName>United States</CountryName>
70
+ <Residential>false</Residential>
71
+ </DestinationAddress>
72
+ <ActualDeliveryAddress>
73
+ <City>COLUMBIA</City>
74
+ <StateOrProvinceCode>SC</StateOrProvinceCode>
75
+ <CountryCode>US</CountryCode>
76
+ <CountryName>United States</CountryName>
77
+ <Residential>false</Residential>
78
+ </ActualDeliveryAddress>
79
+ <DeliveryAttempts>0</DeliveryAttempts>
80
+ <TotalUniqueAddressCountInConsolidation>0</TotalUniqueAddressCountInConsolidation>
81
+ <RedirectToHoldEligibility>INELIGIBLE</RedirectToHoldEligibility>
82
+ </TrackDetails>
83
+ </CompletedTrackDetails>
84
+ </TrackReply>
@@ -0,0 +1,89 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <TrackReply xmlns="http://fedex.com/ws/track/v7" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
3
+ <HighestSeverity>SUCCESS</HighestSeverity>
4
+ <Notifications>
5
+ <Severity>SUCCESS</Severity>
6
+ <Source>trck</Source>
7
+ <Code>0</Code>
8
+ <Message>Request was successfully processed.</Message>
9
+ <LocalizedMessage>Request was successfully processed.</LocalizedMessage>
10
+ </Notifications>
11
+ <TransactionDetail>
12
+ <CustomerTransactionId>ActiveShipping</CustomerTransactionId>
13
+ </TransactionDetail>
14
+ <Version>
15
+ <ServiceId>trck</ServiceId>
16
+ <Major>7</Major>
17
+ <Intermediate>0</Intermediate>
18
+ <Minor>0</Minor>
19
+ </Version>
20
+ <CompletedTrackDetails>
21
+ <HighestSeverity>SUCCESS</HighestSeverity>
22
+ <Notifications>
23
+ <Severity>SUCCESS</Severity>
24
+ <Source>trck</Source>
25
+ <Code>0</Code>
26
+ <Message>Request was successfully processed.</Message>
27
+ <LocalizedMessage>Request was successfully processed.</LocalizedMessage>
28
+ </Notifications>
29
+ <DuplicateWaybill>false</DuplicateWaybill>
30
+ <MoreData>false</MoreData>
31
+ <TrackDetails>
32
+ <Notification>
33
+ <Severity>SUCCESS</Severity>
34
+ <Source>trck</Source>
35
+ <Code>0</Code>
36
+ <Message>Request was successfully processed.</Message>
37
+ <LocalizedMessage>Request was successfully processed.</LocalizedMessage>
38
+ </Notification>
39
+ <TrackingNumber>123456789012</TrackingNumber>
40
+ <TrackingNumberUniqueIdentifier>123456789012~123456789012~FX</TrackingNumberUniqueIdentifier>
41
+ <StatusDetail>
42
+ <Location>
43
+ <Residential>false</Residential>
44
+ </Location>
45
+ </StatusDetail>
46
+ <CarrierCode>FDXE</CarrierCode>
47
+ <OperatingCompanyOrCarrierDescription>FedEx Express</OperatingCompanyOrCarrierDescription>
48
+ <Service>
49
+ <Type>STANDARD_OVERNIGHT</Type>
50
+ <Description>FedEx Standard Overnight</Description>
51
+ </Service>
52
+ <PackageSequenceNumber>0</PackageSequenceNumber>
53
+ <PackageCount>0</PackageCount>
54
+ <SpecialHandlings>
55
+ <Type>DELIVER_WEEKDAY</Type>
56
+ <Description>Deliver Weekday</Description>
57
+ <PaymentType>OTHER</PaymentType>
58
+ </SpecialHandlings>
59
+ <SpecialHandlings>
60
+ <Type>RESIDENTIAL_DELIVERY</Type>
61
+ <Description>Residential Delivery</Description>
62
+ <PaymentType>OTHER</PaymentType>
63
+ </SpecialHandlings>
64
+ <SpecialHandlings>
65
+ <Type>DIRECT_SIGNATURE_OPTION</Type>
66
+ <Description>Direct Signature Required</Description>
67
+ <PaymentType>OTHER</PaymentType>
68
+ </SpecialHandlings>
69
+ <ShipTimestamp>2014-05-30T12:19:00+00:00</ShipTimestamp>
70
+ <DestinationAddress>
71
+ <City>COLUMBIA</City>
72
+ <StateOrProvinceCode>SC</StateOrProvinceCode>
73
+ <CountryCode>US</CountryCode>
74
+ <CountryName>United States</CountryName>
75
+ <Residential>false</Residential>
76
+ </DestinationAddress>
77
+ <ActualDeliveryAddress>
78
+ <City>COLUMBIA</City>
79
+ <StateOrProvinceCode>SC</StateOrProvinceCode>
80
+ <CountryCode>US</CountryCode>
81
+ <CountryName>United States</CountryName>
82
+ <Residential>false</Residential>
83
+ </ActualDeliveryAddress>
84
+ <DeliveryAttempts>0</DeliveryAttempts>
85
+ <TotalUniqueAddressCountInConsolidation>0</TotalUniqueAddressCountInConsolidation>
86
+ <RedirectToHoldEligibility>INELIGIBLE</RedirectToHoldEligibility>
87
+ </TrackDetails>
88
+ </CompletedTrackDetails>
89
+ </TrackReply>
@@ -37,5 +37,17 @@
37
37
  <AuthorizedAgent>false</AuthorizedAgent>
38
38
  <EventCode>OF</EventCode>
39
39
  </TrackSummary>
40
+ <TrackDetail>
41
+ <EventTime/><EventDate/>
42
+ <Event>Origin Post is Preparing Shipment</Event>
43
+ <EventCity/>
44
+ <EventState/>
45
+ <EventZIPCode/>
46
+ <EventCountry/>
47
+ <FirmName/>
48
+ <Name/>
49
+ <AuthorizedAgent>false</AuthorizedAgent>
50
+ <EventCode>NP</EventCode>
51
+ </TrackDetail>
40
52
  </TrackInfo>
41
53
  </TrackResponse>
@@ -220,4 +220,12 @@
220
220
  <HelpContext/>
221
221
  </Error>
222
222
  </TrackInfo>
223
+ <TrackInfo ID="CJ422417033US">
224
+ <Error>
225
+ <Number>-2147219303</Number>
226
+ <Description>Duplicate</Description>
227
+ <HelpFile/>
228
+ <HelpContext/>
229
+ </Error>
230
+ </TrackInfo>
223
231
  </TrackResponse>
@@ -338,7 +338,7 @@ class RemoteUPSTest < Minitest::Test
338
338
  assert response.success?
339
339
  refute_empty response.delivery_estimates
340
340
  ww_express_estimate = response.delivery_estimates.select {|de| de.service_name == "UPS Worldwide Express"}.first
341
- assert_equal Date.parse(1.business_day.from_now.to_s), ww_express_estimate.date
341
+ assert_equal Date.parse(1.day.from_now.to_s), ww_express_estimate.date
342
342
  end
343
343
 
344
344
  def test_void_shipment
@@ -457,6 +457,30 @@ class FedExTest < Minitest::Test
457
457
  assert_equal msg, error.message
458
458
  end
459
459
 
460
+ def test_tracking_info_with_empty_status_detail
461
+ mock_response = xml_fixture('fedex/tracking_response_empty_status_detail')
462
+ @carrier.expects(:commit).returns(mock_response)
463
+
464
+ error = assert_raises(ActiveShipping::Error) do
465
+ @carrier.find_tracking_info('123456789012')
466
+ end
467
+
468
+ msg = 'Tracking response does not contain status information'
469
+ assert_equal msg, error.message
470
+ end
471
+
472
+ def test_tracking_info_with_invalid_status_code
473
+ mock_response = xml_fixture('fedex/tracking_response_invalid_status_code')
474
+ @carrier.expects(:commit).returns(mock_response)
475
+
476
+ error = assert_raises(ActiveShipping::Error) do
477
+ @carrier.find_tracking_info('123456789012')
478
+ end
479
+
480
+ msg = 'Tracking response does not contain status code'
481
+ assert_equal msg, error.message
482
+ end
483
+
460
484
  def test_create_shipment
461
485
  confirm_response = xml_fixture('fedex/create_shipment_response')
462
486
  @carrier.stubs(:commit).returns(confirm_response)
@@ -138,6 +138,19 @@ class USPSTest < Minitest::Test
138
138
  assert_equal :out_for_delivery, response.status
139
139
  assert_nil response.scheduled_delivery_date
140
140
  assert_nil response.shipment_events.last.location.city
141
+
142
+ assert_equal 'NP', response.shipment_events.first.type_code
143
+ assert_equal Time.parse('Jan 01, 2000'), response.shipment_events.first.time
144
+
145
+ special_country = xml_fixture('usps/tracking_response_alt').gsub('CANADA','TAIWAN')
146
+ @carrier.expects(:commit).returns(special_country)
147
+ response = @carrier.find_tracking_info('9102901000462189604217', :test => true)
148
+ assert_equal 'Taiwan, Province of China', response.shipment_events.last.location.country.name
149
+
150
+ special_country = xml_fixture('usps/tracking_response_alt').gsub('CANADA','KOREA REPUBLIC OF')
151
+ @carrier.expects(:commit).returns(special_country)
152
+ response = @carrier.find_tracking_info('9102901000462189604217', :test => true)
153
+ assert_equal 'Korea, Republic of', response.shipment_events.last.location.country.name
141
154
  end
142
155
 
143
156
  def test_find_tracking_info_destination
@@ -173,7 +186,7 @@ class USPSTest < Minitest::Test
173
186
  def test_batch_find_tracking_info_should_return_a_tracking_response_array
174
187
  @carrier.expects(:commit).returns(@batch_tracking_response)
175
188
  responses = @carrier.batch_find_tracking_info(@tracking_infos_array, :test => true)
176
- assert_equal 3, responses.length
189
+ assert_equal 4, responses.length
177
190
  assert responses.all? { |x| x.instance_of? ActiveShipping::TrackingResponse}
178
191
  end
179
192
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_shipping
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - James MacAulay
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2015-06-16 00:00:00.000000000 Z
14
+ date: 2015-07-02 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: quantified
@@ -280,7 +280,9 @@ files:
280
280
  - test/fixtures/xml/fedex/tracking_response_delivered_at_door.xml
281
281
  - test/fixtures/xml/fedex/tracking_response_delivered_at_facility.xml
282
282
  - test/fixtures/xml/fedex/tracking_response_delivered_with_signature.xml
283
+ - test/fixtures/xml/fedex/tracking_response_empty_status_detail.xml
283
284
  - test/fixtures/xml/fedex/tracking_response_in_transit.xml
285
+ - test/fixtures/xml/fedex/tracking_response_invalid_status_code.xml
284
286
  - test/fixtures/xml/fedex/tracking_response_invalid_tracking_number.xml
285
287
  - test/fixtures/xml/fedex/tracking_response_multiple_results.xml
286
288
  - test/fixtures/xml/fedex/tracking_response_not_found.xml
@@ -483,7 +485,9 @@ test_files:
483
485
  - test/fixtures/xml/fedex/tracking_response_delivered_at_door.xml
484
486
  - test/fixtures/xml/fedex/tracking_response_delivered_at_facility.xml
485
487
  - test/fixtures/xml/fedex/tracking_response_delivered_with_signature.xml
488
+ - test/fixtures/xml/fedex/tracking_response_empty_status_detail.xml
486
489
  - test/fixtures/xml/fedex/tracking_response_in_transit.xml
490
+ - test/fixtures/xml/fedex/tracking_response_invalid_status_code.xml
487
491
  - test/fixtures/xml/fedex/tracking_response_invalid_tracking_number.xml
488
492
  - test/fixtures/xml/fedex/tracking_response_multiple_results.xml
489
493
  - test/fixtures/xml/fedex/tracking_response_not_found.xml