mxd_tracker 0.1.3 → 0.1.4
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/lib/mxd_tracker/mxd.rb +16 -4
- data/lib/mxd_tracker/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b0357b847c2990ce23bfbf50c2a16590b1148722
|
4
|
+
data.tar.gz: ef7b6b313f86a072b4d578b8ef3ea75db88d2abd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2408f15b221e5ca99293a0d0da9cd743ab47e68f008d0562c7fe39ed9536e330f9f5ac5b4745ec71eb1e39ddf75a55f8e1bacbca1723115a89600309356f4d39
|
7
|
+
data.tar.gz: e397390813711b7f5e7b0295d75e21a1bcff623146eea220087ad1af106003837a9f2701ff554dd2ceb0d3fc1ca3c37f1e4c7cb856a27d72ae5c21c8b313db54
|
data/lib/mxd_tracker/mxd.rb
CHANGED
@@ -22,14 +22,16 @@ module MxdTracker
|
|
22
22
|
private
|
23
23
|
|
24
24
|
def self.construct_path(tracking_attribute, value, zip_code)
|
25
|
+
sanitized_zip_code = sanitize_zip_code(zip_code)
|
26
|
+
raise "Invalid ZipCode" unless sanitized_zip_code
|
25
27
|
if tracking_attribute == :tracking_number
|
26
|
-
"/trackShipmentByIdAndZipOnly.htm?trackingId=#{value}&zip_code=#{
|
28
|
+
"/trackShipmentByIdAndZipOnly.htm?trackingId=#{value}&zip_code=#{sanitized_zip_code}"
|
27
29
|
elsif tracking_attribute == :waybill_number
|
28
|
-
"/trackShipmentByWbAndZipOnly.htm?wayBill=#{value}&zip_code=#{
|
30
|
+
"/trackShipmentByWbAndZipOnly.htm?wayBill=#{value}&zip_code=#{sanitized_zip_code}"
|
29
31
|
elsif tracking_attribute == :order_number
|
30
|
-
"/trackShipmentByRefAndZip.htm?refno=#{value}&zipCode=#{
|
32
|
+
"/trackShipmentByRefAndZip.htm?refno=#{value}&zipCode=#{sanitized_zip_code}"
|
31
33
|
else
|
32
|
-
"/trackShipmentByPhoneAndZip.htm?zip=#{
|
34
|
+
"/trackShipmentByPhoneAndZip.htm?zip=#{sanitized_zip_code}&phone=#{value}"
|
33
35
|
end
|
34
36
|
end
|
35
37
|
|
@@ -51,5 +53,15 @@ module MxdTracker
|
|
51
53
|
end
|
52
54
|
end
|
53
55
|
|
56
|
+
def self.sanitize_zip_code(zip_code)
|
57
|
+
# MXD urls expect only five digit numeric zip codes
|
58
|
+
zip_code.to_s.gsub!(/(-{1}\d+$)/, '')
|
59
|
+
if zip_code.length != 5
|
60
|
+
false
|
61
|
+
else
|
62
|
+
zip_code
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
54
66
|
end
|
55
67
|
end
|
data/lib/mxd_tracker/version.rb
CHANGED