active_shipping 1.2.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/active_shipping.rb +1 -4
- data/lib/active_shipping/carriers/usps.rb +7 -3
- data/lib/active_shipping/version.rb +1 -1
- data/test/fixtures/xml/usps/world_rate_request_with_value.xml +4 -0
- data/test/fixtures/xml/usps/world_rate_request_without_value.xml +4 -0
- data/test/unit/carriers/usps_test.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1d7d90329e0d2d80ee6f1eb5ae1f2bdc1f16b6dc
|
4
|
+
data.tar.gz: ba9ce52d2f832b124ef5ccd67f4140888eac68d4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 549c8f94cc474cd8e00050433bf1b0fddcdb41c2d6afd8a894151e607bb8f33c3f4a77c2c486d9088ed785cde069de5fab9ca012fa2691e4936b81aafb82c2f6
|
7
|
+
data.tar.gz: e7999cb24985d89f9de6896ae7534619c6f354c72ba5cd0ac85869d6ffd858255a647d1824d131ee3d327127195a685a3ac5414ceecf2d5d219effc7d108e658
|
data/CHANGELOG.md
CHANGED
data/lib/active_shipping.rb
CHANGED
@@ -21,10 +21,7 @@
|
|
21
21
|
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
22
|
#++
|
23
23
|
|
24
|
-
require 'active_support'
|
25
|
-
require 'active_support/json'
|
26
|
-
require 'active_support/core_ext/enumerable'
|
27
|
-
require 'active_support/core_ext/class/attribute_accessors'
|
24
|
+
require 'active_support/all'
|
28
25
|
require 'active_utils'
|
29
26
|
|
30
27
|
require 'nokogiri'
|
@@ -234,7 +234,7 @@ module ActiveShipping
|
|
234
234
|
def extract_event_details(node)
|
235
235
|
description = node.at('Event').text.upcase
|
236
236
|
|
237
|
-
if prefix = ONLY_PREFIX_EVENTS.find { |p| description.
|
237
|
+
if prefix = ONLY_PREFIX_EVENTS.find { |p| description.start_with?(p) }
|
238
238
|
description = prefix
|
239
239
|
end
|
240
240
|
|
@@ -291,7 +291,7 @@ module ActiveShipping
|
|
291
291
|
end
|
292
292
|
|
293
293
|
def world_rates(origin, destination, packages, options = {})
|
294
|
-
request = build_world_rate_request(packages, destination, options)
|
294
|
+
request = build_world_rate_request(origin, packages, destination, options)
|
295
295
|
# never use test mode; rate requests just won't work on test servers
|
296
296
|
parse_rate_response(origin, destination, packages, commit(:world_rates, request, false), options)
|
297
297
|
end
|
@@ -371,10 +371,11 @@ module ActiveShipping
|
|
371
371
|
#
|
372
372
|
# package.options[:mail_type] -- one of [:package, :postcard, :matter_for_the_blind, :envelope].
|
373
373
|
# Defaults to :package.
|
374
|
-
def build_world_rate_request(packages, destination, options)
|
374
|
+
def build_world_rate_request(origin, packages, destination, options)
|
375
375
|
country = COUNTRY_NAME_CONVERSIONS[destination.country.code(:alpha2).value] || destination.country.name
|
376
376
|
xml_builder = Nokogiri::XML::Builder.new do |xml|
|
377
377
|
xml.IntlRateV2Request('USERID' => @options[:login]) do
|
378
|
+
xml.Revision(2)
|
378
379
|
Array(packages).each_with_index do |package, id|
|
379
380
|
xml.Package('ID' => id) do
|
380
381
|
xml.Pounds(0)
|
@@ -402,6 +403,9 @@ module ActiveShipping
|
|
402
403
|
if commercial_type = commercial_type(options)
|
403
404
|
xml.public_send(COMMERCIAL_FLAG_NAME.fetch(commercial_type), 'Y')
|
404
405
|
end
|
406
|
+
xml.OriginZip(origin.zip)
|
407
|
+
xml.AcceptanceDateTime((options[:acceptance_time] || Time.now.utc).iso8601)
|
408
|
+
xml.DestinationPostalCode(destination.zip)
|
405
409
|
end
|
406
410
|
end
|
407
411
|
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
<?xml version="1.0"?>
|
2
2
|
<IntlRateV2Request USERID="login">
|
3
|
+
<Revision>2</Revision>
|
3
4
|
<Package ID="0">
|
4
5
|
<Pounds>0</Pounds>
|
5
6
|
<Ounces>120</Ounces>
|
@@ -16,5 +17,8 @@
|
|
16
17
|
<Length>15.00</Length>
|
17
18
|
<Height>4.50</Height>
|
18
19
|
<Girth>29.00</Girth>
|
20
|
+
<OriginZip>90210</OriginZip>
|
21
|
+
<AcceptanceDateTime>2015-06-01T20:34:29Z</AcceptanceDateTime>
|
22
|
+
<DestinationPostalCode>K1P 1J1</DestinationPostalCode>
|
19
23
|
</Package>
|
20
24
|
</IntlRateV2Request>
|
@@ -1,5 +1,6 @@
|
|
1
1
|
<?xml version="1.0"?>
|
2
2
|
<IntlRateV2Request USERID="login">
|
3
|
+
<Revision>2</Revision>
|
3
4
|
<Package ID="0">
|
4
5
|
<Pounds>0</Pounds>
|
5
6
|
<Ounces>9</Ounces>
|
@@ -16,5 +17,8 @@
|
|
16
17
|
<Length>7.48</Length>
|
17
18
|
<Height>0.79</Height>
|
18
19
|
<Girth>12.60</Girth>
|
20
|
+
<OriginZip>90210</OriginZip>
|
21
|
+
<AcceptanceDateTime>2015-06-01T20:34:29Z</AcceptanceDateTime>
|
22
|
+
<DestinationPostalCode>K1P 1J1</DestinationPostalCode>
|
19
23
|
</Package>
|
20
24
|
</IntlRateV2Request>
|
@@ -233,14 +233,14 @@ class USPSTest < Minitest::Test
|
|
233
233
|
expected_request = xml_fixture('usps/world_rate_request_without_value')
|
234
234
|
@carrier.expects(:commit).with(:world_rates, expected_request, false).returns(expected_request)
|
235
235
|
@carrier.expects(:parse_rate_response)
|
236
|
-
@carrier.find_rates(location_fixtures[:beverly_hills], location_fixtures[:ottawa], package_fixtures[:book], :test => true)
|
236
|
+
@carrier.find_rates(location_fixtures[:beverly_hills], location_fixtures[:ottawa], package_fixtures[:book], :test => true, :acceptance_time => Time.parse("2015-06-01T20:34:29Z"))
|
237
237
|
end
|
238
238
|
|
239
239
|
def test_build_world_rate_request_with_package_value
|
240
240
|
expected_request = xml_fixture('usps/world_rate_request_with_value')
|
241
241
|
@carrier.expects(:commit).with(:world_rates, expected_request, false).returns(expected_request)
|
242
242
|
@carrier.expects(:parse_rate_response)
|
243
|
-
@carrier.find_rates(location_fixtures[:beverly_hills], location_fixtures[:ottawa], package_fixtures[:american_wii], :test => true)
|
243
|
+
@carrier.find_rates(location_fixtures[:beverly_hills], location_fixtures[:ottawa], package_fixtures[:american_wii], :test => true, :acceptance_time => Time.parse("2015-06-01T20:34:29Z"))
|
244
244
|
end
|
245
245
|
|
246
246
|
def test_initialize_options_requirements
|
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.2.
|
4
|
+
version: 1.2.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-
|
14
|
+
date: 2015-06-02 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: quantified
|