active_shipping 1.13.2 → 1.13.3

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: eac04ea30bfda9ffec4adfe13de0c4dabd4ebe69
4
- data.tar.gz: 960fc2506a4e244125d53136cbeaaa777f10fca3
3
+ metadata.gz: f7ada26d664d2d94b53b1dcb1268109f8efadaa3
4
+ data.tar.gz: 5b3ca7781a192d331afb9a5b780233a60181db02
5
5
  SHA512:
6
- metadata.gz: a2ba4217456c82b4d5b7ce05d93f1191a856781e97ecba893173d02ca055ce9213cdab4d7e0d808ea1900a0d80e8e771c3ec1b74664ec366adaad6a62a9f773c
7
- data.tar.gz: ed16ffc04b809427a91e2739247c4e09bf45c85543a6650564bb780dd96d3c077f631123f4179fe6218283ddbb1acf0d662b317b74121e0616bbeab4a529f781
6
+ metadata.gz: 684c2b83d4c3d74159095d3d0d184f2023c2f42e2481efd16f8a923ec68199db61ded9dbf09529537f325ac7b0da37fb7943091b92ea9c039de3afe082486e5a
7
+ data.tar.gz: e2b2e6cfca043f95987876b252f2059f20a5e62d1552e357c11e55ffeddbaf1d93fb92c8a7cca69a36f28c3191e189c9f2f36c620138d5ac3d83f22698b9906d
@@ -1,5 +1,15 @@
1
1
  # ActiveShipping CHANGELOG
2
2
 
3
+ ### v1.13.3
4
+ - CanadaPostPWS no longer modifies locations passed to it
5
+
6
+ ### v1.13.2
7
+ - Bump active_utils to 3.3.1
8
+ - Allow activesupport <5.2.0
9
+
10
+ ### v1.13.1
11
+ - Fix up UPS tracker parsing for Kosovo (KV)
12
+
3
13
  ### v1.13.0
4
14
  - Add default location for CanadaPost PWS
5
15
  - Patch UPS to use old Kosovo country code
@@ -359,9 +359,6 @@ module ActiveShipping
359
359
  # :cod, :cod_amount, :insurance, :insurance_amount, :signature_required, :pa18, :pa19, :hfp, :dns, :lad
360
360
  #
361
361
  def build_shipment_request(origin, destination, package, line_items = [], options = {})
362
- origin = sanitize_location(origin)
363
- destination = sanitize_location(destination)
364
-
365
362
  builder = Nokogiri::XML::Builder.new do |xml|
366
363
  xml.public_send('non-contract-shipment', :xmlns => "http://www.canadapost.ca/ws/ncshipment") do
367
364
  xml.public_send('delivery-spec') do
@@ -385,7 +382,8 @@ module ActiveShipping
385
382
  xml.public_send('service-code', options[:service])
386
383
  end
387
384
 
388
- def shipment_sender_node(xml, location, options)
385
+ def shipment_sender_node(xml, sender, options)
386
+ location = location_from_hash(sender)
389
387
  xml.public_send('sender') do
390
388
  xml.public_send('name', location.name)
391
389
  xml.public_send('company', location.company) if location.company.present?
@@ -396,12 +394,13 @@ module ActiveShipping
396
394
  xml.public_send('city', location.city)
397
395
  xml.public_send('prov-state', location.province)
398
396
  # xml.public_send('country-code', location.country_code)
399
- xml.public_send('postal-zip-code', location.postal_code)
397
+ xml.public_send('postal-zip-code', get_sanitized_postal_code(location))
400
398
  end
401
399
  end
402
400
  end
403
401
 
404
- def shipment_destination_node(xml, location, options)
402
+ def shipment_destination_node(xml, destination, options)
403
+ location = location_from_hash(destination)
405
404
  xml.public_send('destination') do
406
405
  xml.public_send('name', location.name)
407
406
  xml.public_send('company', location.company) if location.company.present?
@@ -412,7 +411,7 @@ module ActiveShipping
412
411
  xml.public_send('city', location.city)
413
412
  xml.public_send('prov-state', location.province) unless location.province.blank?
414
413
  xml.public_send('country-code', location.country_code)
415
- xml.public_send('postal-zip-code', location.postal_code)
414
+ xml.public_send('postal-zip-code', get_sanitized_postal_code(location))
416
415
  end
417
416
  end
418
417
  end
@@ -446,7 +445,7 @@ module ActiveShipping
446
445
  end
447
446
 
448
447
  def shipment_customs_node(xml, destination, line_items, options)
449
- return unless destination.country_code != 'CA'
448
+ return unless location_from_hash(destination).country_code != 'CA'
450
449
 
451
450
  xml.public_send('customs') do
452
451
  currency = options[:currency] || "CAD"
@@ -690,24 +689,25 @@ module ActiveShipping
690
689
  end
691
690
 
692
691
  def origin_node(xml, location)
693
- origin = sanitize_location(location)
694
- xml.public_send("origin-postal-code", origin.zip)
692
+ origin = location_from_hash(location)
693
+ xml.public_send("origin-postal-code", get_sanitized_postal_code(origin))
695
694
  end
696
695
 
697
696
  def destination_node(xml, location)
698
- destination = sanitize_location(location)
697
+ destination = location_from_hash(location)
698
+ postal_code = get_sanitized_postal_code(destination)
699
699
  case destination.country_code
700
700
  when 'CA'
701
701
  xml.public_send('destination') do
702
702
  xml.public_send('domestic') do
703
- xml.public_send('postal-code', destination.postal_code)
703
+ xml.public_send('postal-code', postal_code)
704
704
  end
705
705
  end
706
706
 
707
707
  when 'US'
708
708
  xml.public_send('destination') do
709
709
  xml.public_send('united-states') do
710
- xml.public_send('zip-code', destination.postal_code)
710
+ xml.public_send('zip-code', postal_code)
711
711
  end
712
712
  end
713
713
 
@@ -776,17 +776,13 @@ module ActiveShipping
776
776
  DateTime.strptime((options[:shipping_date] || Time.now).to_s, "%Y-%m-%d")
777
777
  end
778
778
 
779
- def sanitize_location(location)
780
- location_hash = location.is_a?(Location) ? location.to_hash : location
781
- location_hash = sanitize_zip(location_hash)
782
- Location.new(location_hash)
779
+ def location_from_hash(location)
780
+ return location if location.is_a?(Location)
781
+ return Location.new(location)
783
782
  end
784
783
 
785
- def sanitize_zip(hash)
786
- [:postal_code, :zip].each do |attr|
787
- hash[attr].gsub!(/\s+/, '') if hash[attr]
788
- end
789
- hash
784
+ def get_sanitized_postal_code(location)
785
+ location.try(:postal_code).try(:gsub, /\s+/, '')
790
786
  end
791
787
 
792
788
  def sanitize_weight_kg(kg)
@@ -1,3 +1,3 @@
1
1
  module ActiveShipping
2
- VERSION = "1.13.2"
2
+ VERSION = "1.13.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_shipping
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.13.2
4
+ version: 1.13.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shopify
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-03-29 00:00:00.000000000 Z
11
+ date: 2017-04-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: quantified