active_shipping 1.7.0 → 1.7.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: aded0a13e4d317dc8bb370ae2203c874282a2a47
4
- data.tar.gz: 296ade65ae145953d279045449ba84757abcf02e
3
+ metadata.gz: ab948e86e9c144422b55594fc95f88034607cec2
4
+ data.tar.gz: 41d45d0e901d21086d43ec7be167ae90653a2bf6
5
5
  SHA512:
6
- metadata.gz: 9053d50d49b00869a4e29bb8a04d48bb44fa86f189eed51c1f8a2846a0c95baf9ff6b8d4fbebe6f72178be256e4b612650b97d22851a12c03a56fe0be86a5ad7
7
- data.tar.gz: 03afa606338e9aedac600911f886f11b6945ae617cd41ab3336d2620c36d354cc2ce682d54a2a55c861397caf907cd039dba12612e26d105c654a5dd45f97f8d
6
+ metadata.gz: 6e0984b2657b841ea40c6d98a3362fc5390d0c9ccaac2946202df6635211486738a623a425a10f1d7b5adc058028e890588035b7797403d1eba5e7cf7bb987fe
7
+ data.tar.gz: c0e2bd4ffa66008a1915002c509412884aae77b3485c922e20a8078ae45934af52e3f22b2dcc741f6a26e2e266805b7b4c7b81a4d8b09b297b4c2dcc1f22d327
@@ -481,11 +481,12 @@ module ActiveShipping
481
481
  raise ActiveShipping::ResponseError, "No Shipping" unless doc.at('non-contract-shipment-info')
482
482
  options = {
483
483
  :shipping_id => doc.root.at('shipment-id').text,
484
- :tracking_number => doc.root.at('tracking-pin').text,
485
484
  :details_url => doc.root.at_xpath("links/link[@rel='details']")['href'],
486
485
  :label_url => doc.root.at_xpath("links/link[@rel='label']")['href'],
487
486
  :receipt_url => doc.root.at_xpath("links/link[@rel='receipt']")['href'],
488
487
  }
488
+ options[:tracking_number] = doc.root.at('tracking-pin').text if doc.root.at('tracking-pin')
489
+
489
490
  CPPWSShippingResponse.new(true, "", {}, options)
490
491
  end
491
492
 
@@ -194,7 +194,7 @@ module ActiveShipping
194
194
  xml = parse_ship_confirm(confirm_response)
195
195
  success = response_success?(xml)
196
196
  message = response_message(xml)
197
- raise message unless success
197
+ raise ActiveShipping::ResponseContentError, StandardError.new(message) unless success
198
198
  digest = response_digest(xml)
199
199
 
200
200
  # STEP 2: Accept. Use shipment digest in first response to get the actual label.
@@ -748,6 +748,13 @@ module ActiveShipping
748
748
  end
749
749
  end
750
750
  end
751
+
752
+ if package_value = package.options[:insured_value]
753
+ xml.InsuredValue do
754
+ xml.CurrencyCode(package.options[:currency] || 'USD')
755
+ xml.MonetaryValue(package_value.to_f)
756
+ end
757
+ end
751
758
  end
752
759
 
753
760
  # not implemented: * Shipment/Package/LargePackageIndicator element
@@ -843,7 +850,7 @@ module ActiveShipping
843
850
  type_code = activity.at('Status/StatusType/Code').text
844
851
  zoneless_time = parse_ups_datetime(:time => activity.at('Time'), :date => activity.at('Date'))
845
852
  location = location_from_address_node(activity.at('ActivityLocation/Address'))
846
- ShipmentEvent.new(description, zoneless_time, location, nil, type_code)
853
+ ShipmentEvent.new(description, zoneless_time, location, description, type_code)
847
854
  end
848
855
 
849
856
  shipment_events = shipment_events.sort_by(&:time)
@@ -113,6 +113,8 @@ module ActiveShipping
113
113
  :package_service => 'PACKAGESERVICE'
114
114
  }
115
115
 
116
+ ATTEMPTED_DELIVERY_CODES = %w(02 53 54 55 56 H0)
117
+
116
118
  # Array of U.S. possessions according to USPS: https://www.usps.com/ship/official-abbreviations.htm
117
119
  US_POSSESSIONS = %w(AS FM GU MH MP PW PR VI)
118
120
 
@@ -630,8 +632,7 @@ module ActiveShipping
630
632
 
631
633
  shipment_events = shipment_events.sort_by(&:time)
632
634
 
633
- # USPS defines a delivery attempt with code 55
634
- attempted_delivery_date = shipment_events.detect{ |shipment_event| shipment_event.type_code=="55" }.try(:time)
635
+ attempted_delivery_date = shipment_events.detect{ |shipment_event| ATTEMPTED_DELIVERY_CODES.include?(shipment_event.type_code) }.try(:time)
635
636
 
636
637
  if last_shipment = shipment_events.last
637
638
  status = last_shipment.status
@@ -1,3 +1,3 @@
1
1
  module ActiveShipping
2
- VERSION = "1.7.0"
2
+ VERSION = "1.7.1"
3
3
  end
@@ -283,7 +283,7 @@ class RemoteUPSTest < Minitest::Test
283
283
  assert response.success?
284
284
  refute_empty response.delivery_estimates
285
285
  ground_delivery_estimate = response.delivery_estimates.select {|de| de.service_name == "UPS Ground"}.first
286
- assert_equal Date.parse(1.business_days.from_now.to_s), ground_delivery_estimate.date
286
+ assert_equal 1.business_days.after(today), ground_delivery_estimate.date
287
287
  end
288
288
 
289
289
  def test_delivery_date_estimates_within_zip_with_no_value
@@ -302,7 +302,7 @@ class RemoteUPSTest < Minitest::Test
302
302
  assert response.success?
303
303
  refute_empty response.delivery_estimates
304
304
  ground_delivery_estimate = response.delivery_estimates.select {|de| de.service_name == "UPS Ground"}.first
305
- assert_equal Date.parse(1.business_days.from_now.to_s), ground_delivery_estimate.date
305
+ assert_equal 1.business_days.after(today), ground_delivery_estimate.date
306
306
  end
307
307
 
308
308
  def test_delivery_date_estimates_across_zips
@@ -321,9 +321,9 @@ class RemoteUPSTest < Minitest::Test
321
321
  assert response.success?
322
322
  refute_empty response.delivery_estimates
323
323
  ground_delivery_estimate = response.delivery_estimates.select {|de| de.service_name == "UPS Ground"}.first
324
- assert_equal Date.parse(3.business_days.from_now.to_s), ground_delivery_estimate.date
324
+ assert_equal 3.business_days.after(today), ground_delivery_estimate.date
325
325
  next_day_delivery_estimate = response.delivery_estimates.select {|de| de.service_name == "UPS Next Day Air"}.first
326
- assert_equal Date.parse(1.business_days.from_now.to_s), next_day_delivery_estimate.date
326
+ assert_equal 1.business_days.after(today), next_day_delivery_estimate.date
327
327
  end
328
328
 
329
329
  def test_rate_with_single_service
@@ -458,4 +458,16 @@ class RemoteUPSTest < Minitest::Test
458
458
  assert response.success?
459
459
  assert_instance_of ActiveShipping::LabelResponse, response
460
460
  end
461
+
462
+ def test_create_shipment_with_insured_value
463
+ response = @carrier.create_shipment(
464
+ location_fixtures[:beverly_hills_with_name],
465
+ location_fixtures[:new_york_with_name],
466
+ package_fixtures.values_at(:insured_value),
467
+ :test => true
468
+ )
469
+
470
+ assert response.success?
471
+ assert_instance_of ActiveShipping::LabelResponse, response
472
+ end
461
473
  end
@@ -12,12 +12,12 @@ class RemoteUSPSTest < Minitest::Test
12
12
  end
13
13
 
14
14
  def test_tracking_with_attempted_delivery
15
- response = @carrier.find_tracking_info('9405515901606017103876', test: false)
15
+ response = @carrier.find_tracking_info('CJ509046330US', test: false)
16
16
  assert response.success?, response.message
17
- assert_equal 9,response.shipment_events.size
17
+ assert_equal 10,response.shipment_events.size
18
18
  assert_equal 'DELIVERED', response.shipment_events.last.message
19
- assert_equal Time.parse('2015-12-10 14:42:00 UTC'), response.attempted_delivery_date
20
- assert_equal Time.parse('2015-12-24 10:51:00 UTC'), response.actual_delivery_date
19
+ assert_equal Time.parse('2016-04-21 13:46:00 UTC'), response.attempted_delivery_date
20
+ assert_equal Time.parse('2016-04-25 17:13:00 UTC'), response.actual_delivery_date
21
21
  end
22
22
 
23
23
  def test_tracking_with_bad_number
data/test/test_helper.rb CHANGED
@@ -87,6 +87,7 @@ module ActiveShipping::Test
87
87
  :chocolate_stuff => Package.new(80, [2, 6, 12], :units => :imperial),
88
88
  :frozen_stuff => Package.new(80, [2, 6, 12], :units => :imperial, :dry_ice => {weight: 1.4}),
89
89
  :declared_value => Package.new(80, [2, 6, 12], :units => :imperial, :currency => 'USD', :value => 999.99),
90
+ :insured_value => Package.new(80, [2, 6, 12], :units => :imperial, :currency => 'USD', :insured_value => 999.99),
90
91
  :tshirts => Package.new(10 * 16, nil, :units => :imperial),
91
92
  :shipping_container => Package.new(2200000, [2440, 2600, 6058], :description => '20 ft Standard Container', :units => :metric),
92
93
  :largest_gold_bar => Package.new(250000, [45.5, 22.5, 17], :value => 15300000),
@@ -128,6 +128,19 @@ class UPSTest < Minitest::Test
128
128
  "DELIVERED"], response.shipment_events.map(&:name)
129
129
  end
130
130
 
131
+ def test_find_tracking_info_should_have_messages_for_shipment_events
132
+ @carrier.expects(:commit).returns(@tracking_response)
133
+ response = @carrier.find_tracking_info('1Z5FX0076803466397')
134
+ assert_equal ["BILLING INFORMATION RECEIVED",
135
+ "IMPORT SCAN",
136
+ "LOCATION SCAN",
137
+ "LOCATION SCAN",
138
+ "DEPARTURE SCAN",
139
+ "ARRIVAL SCAN",
140
+ "OUT FOR DELIVERY",
141
+ "DELIVERED"], response.shipment_events.map(&:message)
142
+ end
143
+
131
144
  def test_find_tracking_info_should_have_correct_type_codes_for_shipment_events
132
145
  @carrier.expects(:commit).returns(@tracking_response)
133
146
  response = @carrier.find_tracking_info('1Z5FX0076803466397')
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.7.0
4
+ version: 1.7.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: 2016-03-29 00:00:00.000000000 Z
14
+ date: 2016-04-27 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: quantified