active_shipping 1.4.2 → 1.4.3
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 +4 -4
- data/CHANGELOG.md +6 -0
- data/lib/active_shipping/carriers/ups.rb +14 -5
- data/lib/active_shipping/carriers/usps.rb +2 -5
- data/lib/active_shipping/version.rb +1 -1
- data/test/credentials.yml +7 -0
- data/test/remote/fedex_test.rb +14 -10
- data/test/remote/ups_surepost_test.rb +33 -0
- data/test/remote/usps_test.rb +2 -2
- data/test/unit/carriers/ups_test.rb +38 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 787a6c033d0e874b93023c65650dd231b14388e3
|
4
|
+
data.tar.gz: eabb0d27b5948b93fc80f413002f41b3c9650809
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9b6b88bfd80ceca470c6b6246045aafe48c68778e74fe3d4993c285f0abb11d18e083b68639011cc0676d33939fc52afb4c3f9e64d0d4d8c6efab55f9ca0ba65
|
7
|
+
data.tar.gz: dc4afa712eb251fb20f251743f0b6c64c805e97c643c1735dd8142241994d35e554aec863edab5f2cd1db45ad93f5cb709e63287b4194033a13e0bbe9faf74a4
|
data/CHANGELOG.md
CHANGED
@@ -650,11 +650,19 @@ module ActiveShipping
|
|
650
650
|
end
|
651
651
|
|
652
652
|
xml.PackageWeight do
|
653
|
+
if (options[:service] || options[:service_code]) == DEFAULT_SERVICE_NAME_TO_CODE["UPS SurePost (USPS) < 1lb"]
|
654
|
+
# SurePost < 1lb uses OZS, not LBS
|
655
|
+
code = options[:imperial] ? 'OZS' : 'KGS'
|
656
|
+
weight = options[:imperial] ? package.oz : package.kgs
|
657
|
+
else
|
658
|
+
code = options[:imperial] ? 'LBS' : 'KGS'
|
659
|
+
weight = options[:imperial] ? package.lbs : package.kgs
|
660
|
+
end
|
653
661
|
xml.UnitOfMeasurement do
|
654
|
-
xml.Code(
|
662
|
+
xml.Code(code)
|
655
663
|
end
|
656
664
|
|
657
|
-
value = ((
|
665
|
+
value = ((weight).to_f * 1000).round / 1000.0 # 3 decimals
|
658
666
|
xml.Weight([value, 0.1].max)
|
659
667
|
end
|
660
668
|
|
@@ -764,9 +772,10 @@ module ActiveShipping
|
|
764
772
|
unless activities.empty?
|
765
773
|
shipment_events = activities.map do |activity|
|
766
774
|
description = activity.at('Status/StatusType/Description').text
|
775
|
+
type_code = activity.at('Status/StatusType/Code').text
|
767
776
|
zoneless_time = parse_ups_datetime(:time => activity.at('Time'), :date => activity.at('Date'))
|
768
777
|
location = location_from_address_node(activity.at('ActivityLocation/Address'))
|
769
|
-
ShipmentEvent.new(description, zoneless_time, location)
|
778
|
+
ShipmentEvent.new(description, zoneless_time, location, nil, type_code)
|
770
779
|
end
|
771
780
|
|
772
781
|
shipment_events = shipment_events.sort_by(&:time)
|
@@ -776,7 +785,7 @@ module ActiveShipping
|
|
776
785
|
# This adds an origin event to the shipment activity in such cases.
|
777
786
|
if origin && !(shipment_events.count == 1 && status == :delivered)
|
778
787
|
first_event = shipment_events[0]
|
779
|
-
origin_event = ShipmentEvent.new(first_event.name, first_event.time, origin)
|
788
|
+
origin_event = ShipmentEvent.new(first_event.name, first_event.time, origin, first_event.message, first_event.type_code)
|
780
789
|
|
781
790
|
if within_same_area?(origin, first_event.location)
|
782
791
|
shipment_events[0] = origin_event
|
@@ -795,7 +804,7 @@ module ActiveShipping
|
|
795
804
|
unless destination
|
796
805
|
destination = shipment_events[-1].location
|
797
806
|
end
|
798
|
-
shipment_events[-1] = ShipmentEvent.new(shipment_events.last.name, shipment_events.last.time, destination)
|
807
|
+
shipment_events[-1] = ShipmentEvent.new(shipment_events.last.name, shipment_events.last.time, destination, shipment_events.last.message, shipment_events.last.type_code)
|
799
808
|
end
|
800
809
|
end
|
801
810
|
|
@@ -22,11 +22,9 @@ module ActiveShipping
|
|
22
22
|
|
23
23
|
TEST_DOMAINS = { # indexed by security; e.g. TEST_DOMAINS[USE_SSL[:rates]]
|
24
24
|
true => 'secure.shippingapis.com',
|
25
|
-
false => '
|
25
|
+
false => 'stg-production.shippingapis.com'
|
26
26
|
}
|
27
27
|
|
28
|
-
TEST_RESOURCE = 'ShippingAPITest.dll'
|
29
|
-
|
30
28
|
API_CODES = {
|
31
29
|
:us_rates => 'RateV4',
|
32
30
|
:world_rates => 'IntlRateV2',
|
@@ -684,8 +682,7 @@ module ActiveShipping
|
|
684
682
|
def request_url(action, request, test)
|
685
683
|
scheme = USE_SSL[action] ? 'https://' : 'http://'
|
686
684
|
host = test ? TEST_DOMAINS[USE_SSL[action]] : LIVE_DOMAIN
|
687
|
-
|
688
|
-
"#{scheme}#{host}/#{resource}?API=#{API_CODES[action]}&XML=#{URI.encode(request)}"
|
685
|
+
"#{scheme}#{host}/#{LIVE_RESOURCE}?API=#{API_CODES[action]}&XML=#{URI.encode(request)}"
|
689
686
|
end
|
690
687
|
|
691
688
|
def strip_zip(zip)
|
data/test/credentials.yml
CHANGED
@@ -21,6 +21,13 @@ ups:
|
|
21
21
|
origin_account: <%= ENV['ACTIVESHIPPING_UPS_ORIGIN_ACCOUNT'] %>
|
22
22
|
origin_name: <%= ENV['ACTIVESHIPPING_UPS_ORIGIN_NAME'] %>
|
23
23
|
|
24
|
+
ups_surepost:
|
25
|
+
login: <%= ENV['ACTIVESHIPPING_UPS_SUREPOST_LOGIN'] %>
|
26
|
+
key: <%= ENV['ACTIVESHIPPING_UPS_SUREPOST_KEY'] %>
|
27
|
+
password: <%= ENV['ACTIVESHIPPING_UPS_SUREPOST_PASSWORD'] %>
|
28
|
+
origin_account: <%= ENV['ACTIVESHIPPING_UPS_SUREPOST_ORIGIN_ACCOUNT'] %>
|
29
|
+
origin_name: <%= ENV['ACTIVESHIPPING_UPS_SUREPOST_ORIGIN_NAME'] %>
|
30
|
+
|
24
31
|
ups_third_party_billing:
|
25
32
|
account: <%= ENV['ACTIVESHIPPING_UPS_THIRD_PARTY_BILLING_ACCOUNT'] %>
|
26
33
|
zip: <%= ENV['ACTIVESHIPPING_UPS_THIRD_PARTY_BILLING_POSTAL_CODE'] %>
|
data/test/remote/fedex_test.rb
CHANGED
@@ -216,28 +216,32 @@ class RemoteFedExTest < Minitest::Test
|
|
216
216
|
### find_tracking_info
|
217
217
|
|
218
218
|
def test_find_tracking_info_for_delivered_shipment
|
219
|
-
|
220
|
-
response = @carrier.find_tracking_info('123456789012', unique_identifier: '2457178000~123456789012~FX')
|
219
|
+
response = @carrier.find_tracking_info('122816215025810')
|
221
220
|
assert response.success?
|
222
221
|
assert response.delivered?
|
223
|
-
assert_equal '
|
222
|
+
assert_equal '122816215025810', response.tracking_number
|
224
223
|
assert_equal :delivered, response.status
|
225
224
|
assert_equal 'DL', response.status_code
|
226
225
|
assert_equal "Delivered", response.status_description
|
227
226
|
|
228
|
-
assert_equal Time.parse('
|
227
|
+
assert_equal Time.parse('Fri, 03 Jan 2014'), response.ship_time
|
229
228
|
assert_equal nil, response.scheduled_delivery_date
|
230
|
-
assert_equal Time.parse('
|
229
|
+
assert_equal Time.parse('2014-01-09 18:31:00 +0000'), response.actual_delivery_date
|
231
230
|
|
232
|
-
|
231
|
+
origin_address = ActiveShipping::Location.new(
|
232
|
+
city: 'SPOKANE',
|
233
|
+
country: 'US',
|
234
|
+
state: 'WA'
|
235
|
+
)
|
236
|
+
assert_equal origin_address.to_hash, response.origin.to_hash
|
233
237
|
|
234
238
|
destination_address = ActiveShipping::Location.new(
|
235
|
-
city: '
|
239
|
+
city: 'NORTON',
|
236
240
|
country: 'US',
|
237
|
-
state: '
|
241
|
+
state: 'VA'
|
238
242
|
)
|
239
243
|
assert_equal destination_address.to_hash, response.destination.to_hash
|
240
|
-
assert_equal
|
244
|
+
assert_equal 11, response.shipment_events.length
|
241
245
|
end
|
242
246
|
|
243
247
|
def test_find_tracking_info_for_in_transit_shipment_1
|
@@ -293,7 +297,7 @@ class RemoteFedExTest < Minitest::Test
|
|
293
297
|
|
294
298
|
def test_find_tracking_info_not_found
|
295
299
|
assert_raises(ActiveShipping::ShipmentNotFound) do
|
296
|
-
@carrier.find_tracking_info('
|
300
|
+
@carrier.find_tracking_info('199997777713')
|
297
301
|
end
|
298
302
|
end
|
299
303
|
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class RemoteUPSSurepostTest < Minitest::Test
|
4
|
+
include ActiveShipping::Test::Credentials
|
5
|
+
include ActiveShipping::Test::Fixtures
|
6
|
+
|
7
|
+
def setup
|
8
|
+
@options = credentials(:ups_surepost).merge(:test => true)
|
9
|
+
@carrier = UPS.new(@options)
|
10
|
+
rescue NoCredentialsFound => e
|
11
|
+
skip(e.message)
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_obtain_surpost_less_than_one_lb_shipping_label
|
15
|
+
response = @carrier.create_shipment(
|
16
|
+
location_fixtures[:beverly_hills],
|
17
|
+
location_fixtures[:new_york_with_name],
|
18
|
+
package_fixtures.values_at(:small_half_pound),
|
19
|
+
{
|
20
|
+
:test => true,
|
21
|
+
:service_code => "92"
|
22
|
+
}
|
23
|
+
)
|
24
|
+
|
25
|
+
assert response.success?
|
26
|
+
|
27
|
+
# All behavior specific to how a LabelResponse behaves in the
|
28
|
+
# context of UPS label data is a matter for unit tests. If
|
29
|
+
# the data changes substantially, the create_shipment
|
30
|
+
# ought to raise an exception and this test will fail.
|
31
|
+
assert_instance_of ActiveShipping::LabelResponse, response
|
32
|
+
end
|
33
|
+
end
|
data/test/remote/usps_test.rb
CHANGED
@@ -12,7 +12,7 @@ class RemoteUSPSTest < Minitest::Test
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def test_tracking
|
15
|
-
response = @carrier.find_tracking_info('LN284529912US', :
|
15
|
+
response = @carrier.find_tracking_info('LN284529912US', test: false)
|
16
16
|
assert response.success?, response.message
|
17
17
|
assert_equal 9,response.shipment_events.size
|
18
18
|
assert_equal 'DELIVERED', response.shipment_events.last.message
|
@@ -21,7 +21,7 @@ class RemoteUSPSTest < Minitest::Test
|
|
21
21
|
|
22
22
|
def test_tracking_with_bad_number
|
23
23
|
assert_raises(ResponseError) do
|
24
|
-
@carrier.find_tracking_info('abc123xyz')
|
24
|
+
@carrier.find_tracking_info('abc123xyz', test: false)
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
@@ -128,6 +128,12 @@ 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_correct_type_codes_for_shipment_events
|
132
|
+
@carrier.expects(:commit).returns(@tracking_response)
|
133
|
+
response = @carrier.find_tracking_info('1Z5FX0076803466397')
|
134
|
+
assert_equal ["M", "I", "I", "I", "I", "I", "I", "D"], response.shipment_events.map(&:type_code)
|
135
|
+
end
|
136
|
+
|
131
137
|
def test_add_origin_and_destination_data_to_shipment_events_where_appropriate
|
132
138
|
@carrier.expects(:commit).returns(@tracking_response)
|
133
139
|
response = @carrier.find_tracking_info('1Z5FX0076803466397')
|
@@ -536,4 +542,36 @@ class UPSTest < Minitest::Test
|
|
536
542
|
def test_maximum_address_field_length
|
537
543
|
assert_equal 35, @carrier.maximum_address_field_length
|
538
544
|
end
|
545
|
+
|
546
|
+
def test_package_surepost_less_than_one_lb_service
|
547
|
+
xml_builder = Nokogiri::XML::Builder.new do |xml|
|
548
|
+
@carrier.send(:build_package_node,
|
549
|
+
xml,
|
550
|
+
package_fixtures[:small_half_pound],
|
551
|
+
{
|
552
|
+
:service => "92",
|
553
|
+
:imperial => true
|
554
|
+
}
|
555
|
+
)
|
556
|
+
end
|
557
|
+
request = Nokogiri::XML(xml_builder.to_xml)
|
558
|
+
assert_equal 'OZS', request.search('/Package/PackageWeight/UnitOfMeasurement/Code').text
|
559
|
+
assert_equal '8.0', request.search('/Package/PackageWeight/Weight').text
|
560
|
+
end
|
561
|
+
|
562
|
+
def test_package_surepost_less_than_one_lb_service_code
|
563
|
+
xml_builder = Nokogiri::XML::Builder.new do |xml|
|
564
|
+
@carrier.send(:build_package_node,
|
565
|
+
xml,
|
566
|
+
package_fixtures[:small_half_pound],
|
567
|
+
{
|
568
|
+
:service_code => "92",
|
569
|
+
:imperial => true
|
570
|
+
}
|
571
|
+
)
|
572
|
+
end
|
573
|
+
request = Nokogiri::XML(xml_builder.to_xml)
|
574
|
+
assert_equal 'OZS', request.search('/Package/PackageWeight/UnitOfMeasurement/Code').text
|
575
|
+
assert_equal '8.0', request.search('/Package/PackageWeight/Weight').text
|
576
|
+
end
|
539
577
|
end
|
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.
|
4
|
+
version: 1.4.3
|
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-
|
14
|
+
date: 2015-08-11 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: quantified
|
@@ -371,6 +371,7 @@ files:
|
|
371
371
|
- test/remote/new_zealand_post_test.rb
|
372
372
|
- test/remote/shipwire_test.rb
|
373
373
|
- test/remote/stamps_test.rb
|
374
|
+
- test/remote/ups_surepost_test.rb
|
374
375
|
- test/remote/ups_test.rb
|
375
376
|
- test/remote/usps_returns_test.rb
|
376
377
|
- test/remote/usps_test.rb
|
@@ -576,6 +577,7 @@ test_files:
|
|
576
577
|
- test/remote/new_zealand_post_test.rb
|
577
578
|
- test/remote/shipwire_test.rb
|
578
579
|
- test/remote/stamps_test.rb
|
580
|
+
- test/remote/ups_surepost_test.rb
|
579
581
|
- test/remote/ups_test.rb
|
580
582
|
- test/remote/usps_returns_test.rb
|
581
583
|
- test/remote/usps_test.rb
|